UNPKG

@avalabs/hw-app-avalanche

Version:

Node API for Avalanche App (Ledger Nano S/X/S+)

82 lines (81 loc) 3.94 kB
/** ****************************************************************************** * (c) 2019-2020 Zondax GmbH * (c) 2016-2017 Ledger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************* */ import Transport from "@ledgerhq/hw-transport"; import { LedgerError } from "./common"; import { ResponseAddress, ResponseAppInfo, ResponseSign, ResponseVersion, ResponseWalletId, ResponseXPub } from "./types"; import { LedgerEthTransactionResolution, LoadConfig, ResolutionConfig } from "@ledgerhq/hw-app-eth/lib/services/types"; import { EIP712Message } from "@ledgerhq/types-live"; export * from "./types"; export { LedgerError }; export default class AvalancheApp { transport: Transport; private eth; constructor(transport: Transport, ethScrambleKey?: string, ethLoadConfig?: LoadConfig); private static prepareChunks; private signGetChunks; private concatMessageAndChangePath; private signSendChunk; signHash(path_prefix: string, signing_paths: Array<string>, hash: Buffer, curve_type?: number): Promise<ResponseSign>; private _signAndCollect; sign(path_prefix: string, signing_paths: Array<string>, message: Buffer, change_paths?: Array<string>, curve_type?: number): Promise<ResponseSign>; signMsg(path_prefix: string, signing_paths: Array<string>, message: string, curve_type?: number): Promise<ResponseSign>; getVersion(): Promise<ResponseVersion>; getAppInfo(): Promise<ResponseAppInfo>; private _pubkey; getAddressAndPubKey(path: string, show: boolean, hrp?: string, chainid?: string, curve_type?: number): Promise<ResponseAddress>; private _xpub; getExtendedPubKey(path: string, show: boolean, hrp?: string, chainid?: string): Promise<ResponseXPub>; private _walletId; getWalletId(): Promise<ResponseWalletId>; showWalletId(): Promise<ResponseWalletId>; signEVMTransaction(path: string, rawTxHex: string, resolution?: LedgerEthTransactionResolution | null): Promise<{ s: string; v: string; r: string; }>; getETHAddress(path: string, boolDisplay?: boolean, boolChaincode?: boolean): Promise<{ publicKey: string; address: string; chainCode?: string; }>; getAppConfiguration(): Promise<{ arbitraryDataEnabled: number; erc20ProvisioningNecessary: number; starkEnabled: number; starkv2Supported: number; version: string; }>; provideERC20TokenInformation(ticker: string, contractName: string, address: string, decimals: number, chainId: number): Promise<boolean>; provideNFTInformation(collectionName: string, contractAddress: string, chainId: bigint): Promise<boolean>; _generateFakeDerSignature(): Buffer; setPlugin(contractAddress: string, methodSelector: string, chainId: bigint): Promise<boolean>; clearSignTransaction(path: string, rawTxHex: string, resolutionConfig: ResolutionConfig, throwOnError?: boolean): Promise<{ r: string; s: string; v: string; }>; signEIP712Message(path: string, jsonMessage: EIP712Message, fullImplem?: boolean): Promise<{ v: number; s: string; r: string; }>; signEIP712HashedMessage(path: string, domainSeparatorHex: string, hashStructMessageHex: string): Promise<{ v: number; s: string; r: string; }>; }