@zondax/ledger-cosmos-js
Version:
Node API for Cosmos App (Ledger Nano S/S+/X)
53 lines (52 loc) • 2.33 kB
TypeScript
/** ******************************************************************************
* (c) Zondax AG
*
* 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 BaseApp, { INSGeneric, ResponsePayload } from '@zondax/ledger-js';
import { P2_VALUES } from './consts';
import { type ResponseAddress, type ResponsePubkey, ResponseSign } from './types';
export default class CosmosApp extends BaseApp {
static _INS: {
GET_VERSION: number;
SIGN_SECP256K1: number;
GET_ADDR_SECP256K1: number;
};
static _params: {
cla: number;
ins: INSGeneric;
p1Values: {
ONLY_RETRIEVE: number;
SHOW_ADDRESS_IN_DEVICE: number;
};
chunkSize: number;
requiredPathLengths: number[];
};
/**
* Constructs a new CosmosApp instance.
* @param transport - The transport instance.
* @throws {Error} - If the transport is not defined.
*/
constructor(transport: Transport);
private serializeHRP;
private serializeCosmosPath;
publicKey(path: string): Promise<ResponsePubkey>;
getAddressAndPubKey(path: string, hrp: string): Promise<ResponseAddress>;
showAddressAndPubKey(path: string, hrp: string): Promise<ResponseAddress>;
static getBech32FromPK(hrp: string, pk: Buffer): `${Lowercase<string>}1${string}`;
prepareChunks_hrp(path: string, buffer: Buffer, hrp?: string): Promise<Buffer<ArrayBufferLike>[]>;
signSendCosmosChunk(chunkIdx: number, chunkNum: number, chunk: Buffer, txtype?: P2_VALUES): Promise<ResponsePayload>;
private signImpl;
sign(path: string, buffer: Buffer, hrp?: string, txtype?: P2_VALUES): Promise<ResponseSign>;
}