UNPKG

@blooo/hw-app-concordium

Version:

Ledger Hardware Wallet Concordium Application API

233 lines 9.31 kB
import Transport from "@ledgerhq/hw-transport"; import { Mode, ExportType, IExportPrivateKeyData, ISimpleTransferTransaction, ISimpleTransferWithMemoTransaction, ISimpleTransferWithScheduleTransaction, ISimpleTransferWithScheduleAndMemoTransaction, IConfigureDelegationTransaction, IRegisterDataTransaction, ITransferToPublicTransaction, IDeployModuleTransaction, IInitContractTransaction, IUpdateContractTransaction, IPublicInfoForIpTransaction, ICredentialDeploymentTransaction, IUpdateCredentialsTransaction, IConfigureBakerTransaction } from "./type"; /** * Concordium API * * @param transport a transport for sending commands to a device * @param scrambleKey a scramble key * * @example * import Concordium from "@blooo/hw-app-concordium"; * const Concordium = new Concordium(transport); */ export default class Concordium { private transport; constructor(transport: Transport, scrambleKey?: string); /** * Verify address. * * @param isLegacy - Flag to indicate if the legacy mode is used. * @param id - The identity number. * @param cred - The credential number. * @param idp - Mandatory if isLegacy is false. The identity provider number. * @returns A promise that resolves to an object containing the status. * * @example * concordium.verifyAddress(12,12,12).then(r => r.status) */ verifyAddress(isLegacy: boolean, id: number, cred: number, idp?: number): Promise<{ status: string; }>; /** * Get Concordium address (public key) for a BIP32 path. * * @param path - A BIP32 path. * @param display - Flag to show display. * @param signedKey - Flag to sign key. * @returns A promise that resolves to an object with the public key and optionally the signed public key. * * @example * concordium.getPublicKey("1105'/0'/0'/0/0/0/0/", true, false) */ getPublicKey(path: string, display?: boolean, signedKey?: boolean): Promise<{ publicKey: string; signedPublicKey?: string; }>; /** * Export a private key. * * @param data - The data required for exporting the private key. * @param exportType - The type of export, either PRF_KEY_SEED or PRF_KEY. * @param mode - The mode, either DISPLAY, NO_DISPLAY, or EXPORT_CRED_ID. * @returns A promise that resolves to an object with the private key and optionally the credential ID. */ exportPrivateKeyLegacy(data: IExportPrivateKeyData, exportType: ExportType, mode: Mode): Promise<{ privateKey: string; credentialId?: string; }>; /** * Export a private key. * * @param data - The data required for exporting the private key. * @param exportType - The type of export, either PRF_KEY_SEED or PRF_KEY. * @param mode - The mode, either DISPLAY, NO_DISPLAY, or EXPORT_CRED_ID. * @returns A promise that resolves to an object with the private key and optionally the credential ID. */ exportPrivateKeyNew(data: IExportPrivateKeyData, exportType: ExportType, mode: Mode): Promise<{ privateKey: string; credentialId?: string; }>; /** * Signs a Concordium transaction using the specified account index. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. * @throws Error if the user declines the transaction. * * @example * concordium.signTransfer(txn).then(r => r.signature) */ signTransfer(txn: ISimpleTransferTransaction, path: string): Promise<{ signature: string; }>; /** * Signs a simple transfer with a memo. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signTransferWithMemo(txn: ISimpleTransferWithMemoTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a transfer with a schedule. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signTransferWithSchedule(txn: ISimpleTransferWithScheduleTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a transfer with a schedule and a memo. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signTransferWithScheduleAndMemo(txn: ISimpleTransferWithScheduleAndMemoTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a configure delegation transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signConfigureDelegation(txn: IConfigureDelegationTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a configure baker transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signConfigureBaker(txn: IConfigureBakerTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a register data transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signRegisterData(txn: IRegisterDataTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a transfer to public transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signTransferToPublic(txn: ITransferToPublicTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a deploy module transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signDeployModule(txn: IDeployModuleTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs an init contract transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signInitContract(txn: IInitContractTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs an update contract transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signUpdateContract(txn: IUpdateContractTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs public info for IP transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signPublicInfoForIp(txn: IPublicInfoForIpTransaction, path: string): Promise<{ signature: string[]; }>; /** * Signs a credential deployment transaction. * * @param txn - The transaction to sign. * @param isNew - Flag indicating if it's a new credential. * @param addressOrExpiry - The address or expiry date. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signCredentialDeployment(txn: ICredentialDeploymentTransaction, isNew: boolean, addressOrExpiry: string | BigInt, path: string): Promise<{ signature: string[]; }>; /** * Signs an update credentials transaction. * * @param txn - The transaction to sign. * @param path - The derivation path to use for signing. * @returns A promise that resolves to an object containing the signature. */ signUpdateCredentials(txn: IUpdateCredentialsTransaction, path: string): Promise<{ signature: string[]; }>; /** * Sends a command to the device. * * @param instruction - The instruction code. * @param p1 - The first parameter. * @param p2 - The second parameter. * @param payload - The payload to send. * @returns A promise that resolves to the device's response. */ private sendToDevice; /** * Throws an error if the device response indicates a failure. * * @param reply - The device's response. */ private throwOnFailure; } //# sourceMappingURL=Concordium.d.ts.map