@zondax/ledger-substrate
Version:
TS / Node API for Substrate/Polkadot based apps running on Ledger devices
157 lines (156 loc) • 6.27 kB
TypeScript
/** ******************************************************************************
* (c) 2019 - 2022 Zondax AG
* (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 type Transport from '@ledgerhq/hw-transport';
import { ISubstrateAppLegacy, type ResponseAddress, type ResponseAllowlistHash, type ResponseAllowlistPubKey, type ResponseSign, type ResponseVersion, SCHEME } from './common';
/**
* Class representing a Substrate application.
*/
export declare class SubstrateApp implements ISubstrateAppLegacy {
transport: Transport;
cla: number;
slip0044: number;
/**
* Create a SubstrateApp instance.
* @param transport - The transport instance.
* @param cla - The CLA value.
* @param slip0044 - The SLIP-0044 value.
*/
constructor(transport: Transport, cla: number, slip0044: number);
/**
* Serialize the BIP44 path.
* @param slip0044 - The SLIP-0044 value.
* @param account - The account index.
* @param change - The change index.
* @param addressIndex - The address index.
* @returns The serialized path.
*/
static serializePath(slip0044: number, account: number, change: number, addressIndex: number): Buffer<ArrayBuffer>;
/**
* Split a message into chunks.
* @param message - The message to split.
* @returns The message chunks.
*/
static GetChunks(message: Buffer): Buffer<ArrayBuffer>[];
/**
* Get chunks for signing.
* @param slip0044 - The SLIP-0044 value.
* @param account - The account index.
* @param change - The change index.
* @param addressIndex - The address index.
* @param message - The message to sign.
* @returns The chunks for signing.
*/
static signGetChunks(slip0044: number, account: number, change: number, addressIndex: number, message: Buffer): Buffer<ArrayBuffer>[];
/**
* Get the version of the application.
* @returns The version response.
*/
getVersion(): Promise<ResponseVersion>;
/**
* Get application information.
* @returns The application information.
*/
appInfo(): Promise<any>;
/**
* Get the address.
* @param account - The account index.
* @param change - The change index.
* @param addressIndex - The address index.
* @param [requireConfirmation=false] - Whether confirmation is required.
* @param [scheme=SCHEME.ED25519] - The scheme.
* @returns The address response.
*/
getAddress(account: number, change: number, addressIndex: number, requireConfirmation?: boolean, scheme?: SCHEME): Promise<ResponseAddress>;
/**
* Send a chunk for signing.
* @private
* @param chunkIdx - The chunk index.
* @param chunkNum - The total number of chunks.
* @param chunk - The chunk data.
* @param [scheme=SCHEME.ED25519] - The scheme.
* @param [ins=INS.SIGN] - The instruction.
* @returns The response.
*/
private signSendChunk;
/**
* Implementation of the signing process.
* @private
* @param account - The account index.
* @param change - The change index.
* @param addressIndex - The address index.
* @param message - The message to sign.
* @param ins - The instruction.
* @param [scheme=SCHEME.ED25519] - The scheme.
* @returns The signing response.
*/
private signImpl;
/**
* Sign a message.
* @param account - The account index.
* @param change - The change index.
* @param addressIndex - The address index.
* @param message - The message to sign.
* @param [scheme=SCHEME.ED25519] - The scheme.
* @returns The signing response.
*/
sign(account: number, change: number, addressIndex: number, message: Buffer, scheme?: SCHEME): Promise<ResponseSign>;
/**
* Sign a raw message.
* @param account - The account index.
* @param change - The change index.
* @param addressIndex - The address index.
* @param message - The message to sign.
* @param [scheme=SCHEME.ED25519] - The scheme.
* @returns The signing response.
*/
signRaw(account: number, change: number, addressIndex: number, message: Buffer, scheme?: SCHEME): Promise<ResponseSign>;
/**
* @deprecated This function is deprecated and will be removed in future versions.
* Get the allowlist public key.
* @returns The allowlist public key response.
*/
getAllowlistPubKey(): Promise<ResponseAllowlistPubKey>;
/**
* @deprecated This function is deprecated and will be removed in future versions.
* Set the allowlist public key.
* @param pk - The public key.
* @returns The response.
*/
setAllowlistPubKey(pk: Buffer): Promise<any>;
/**
* @deprecated This function is deprecated and will be removed in future versions.
* Get the allowlist hash.
* @returns The allowlist hash response.
*/
getAllowlistHash(): Promise<ResponseAllowlistHash>;
/**
* @deprecated This function is deprecated and will be removed in future versions.
* Send a chunk for uploading the allowlist.
* @param chunkIdx - The chunk index.
* @param chunkNum - The total number of chunks.
* @param chunk - The chunk data.
* @returns The response.
*/
uploadSendChunk(chunkIdx: number, chunkNum: number, chunk: Buffer): Promise<any>;
/**
* @deprecated This function is deprecated and will be removed in future versions.
* Upload the allowlist.
* @param message - The allowlist message.
* @returns The response.
*/
uploadAllowlist(message: Buffer): Promise<any>;
}