UNPKG

@ledgerhq/hw-app-celo

Version:
34 lines 1.63 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const hw_app_eth_1 = __importDefault(require("@ledgerhq/hw-app-eth")); const tokens_1 = require("@celo/wallet-ledger/lib/tokens"); const wallet_base_1 = require("@celo/wallet-base"); /** * Heavily inspiried by celo-web-wallet * https://github.com/celo-tools/celo-web-wallet/blob/master/src/features/ledger/CeloLedgerApp.ts */ class Celo extends hw_app_eth_1.default { async signTransaction(path, rawTxHex, resolution) { return super.signTransaction(path, rawTxHex, resolution); } // celo-spender-app below version 1.2.3 used a different private key to validate erc20 token info. // this legacy version of the app also only supported celo type 0 transactions. // if you are reading this after celo moved to op based L2 those celo type 0 transactions will no longer work // so you can safely remove all the legacy paths. async verifyTokenInfo(to, chainId) { const tokenInfo = (0, tokens_1.tokenInfoByAddressAndChainId)(to, chainId); if (tokenInfo) { // celo-spender-app below version 1.2.3 expected unprefixed hex strings only const dataString = `0x${tokenInfo.data.toString("hex")}`; await this.provideERC20TokenInformation(dataString); } } async rlpEncodedTxForLedger(txParams) { return (0, wallet_base_1.rlpEncodedTx)(txParams); } } exports.default = Celo; //# sourceMappingURL=Celo.js.map