@ledgerhq/coin-cardano 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +35 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/account.d.ts +7 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +41 -0
- package/lib/account.js.map +1 -0
- package/lib/address.unit.test.d.ts +2 -0
- package/lib/address.unit.test.d.ts.map +1 -0
- package/lib/address.unit.test.js +21 -0
- package/lib/address.unit.test.js.map +1 -0
- package/lib/api/api-types.d.ts +106 -0
- package/lib/api/api-types.d.ts.map +1 -0
- package/lib/api/api-types.js +9 -0
- package/lib/api/api-types.js.map +1 -0
- package/lib/api/getDelegationInfo.d.ts +4 -0
- package/lib/api/getDelegationInfo.d.ts.map +1 -0
- package/lib/api/getDelegationInfo.js +48 -0
- package/lib/api/getDelegationInfo.js.map +1 -0
- package/lib/api/getNetworkInfo.d.ts +5 -0
- package/lib/api/getNetworkInfo.d.ts.map +1 -0
- package/lib/api/getNetworkInfo.js +46 -0
- package/lib/api/getNetworkInfo.js.map +1 -0
- package/lib/api/getPools.d.ts +5 -0
- package/lib/api/getPools.d.ts.map +1 -0
- package/lib/api/getPools.js +45 -0
- package/lib/api/getPools.js.map +1 -0
- package/lib/api/getTransactions.d.ts +10 -0
- package/lib/api/getTransactions.d.ts.map +1 -0
- package/lib/api/getTransactions.js +139 -0
- package/lib/api/getTransactions.js.map +1 -0
- package/lib/api/submitTransaction.d.ts +7 -0
- package/lib/api/submitTransaction.d.ts.map +1 -0
- package/lib/api/submitTransaction.js +34 -0
- package/lib/api/submitTransaction.js.map +1 -0
- package/lib/bridge/index.d.ts +11 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +70 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +113 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +8 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +28 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/buildOptimisticOperation.d.ts +4 -0
- package/lib/buildOptimisticOperation.d.ts.map +1 -0
- package/lib/buildOptimisticOperation.js +125 -0
- package/lib/buildOptimisticOperation.js.map +1 -0
- package/lib/buildSubAccounts.d.ts +26 -0
- package/lib/buildSubAccounts.d.ts.map +1 -0
- package/lib/buildSubAccounts.js +124 -0
- package/lib/buildSubAccounts.js.map +1 -0
- package/lib/buildTransaction.d.ts +11 -0
- package/lib/buildTransaction.d.ts.map +1 -0
- package/lib/buildTransaction.js +342 -0
- package/lib/buildTransaction.js.map +1 -0
- package/lib/cli-transaction.d.ts +18 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +66 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/constants.d.ts +8 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +12 -0
- package/lib/constants.js.map +1 -0
- package/lib/createTransaction.d.ts +9 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +23 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/datasets/rawAccount.1.d.ts +3 -0
- package/lib/datasets/rawAccount.1.d.ts.map +1 -0
- package/lib/datasets/rawAccount.1.js +20 -0
- package/lib/datasets/rawAccount.1.js.map +1 -0
- package/lib/datasets/scanAccounts.d.ts +5 -0
- package/lib/datasets/scanAccounts.d.ts.map +1 -0
- package/lib/datasets/scanAccounts.js +27 -0
- package/lib/datasets/scanAccounts.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +11 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +106 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +22 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +18 -0
- package/lib/errors.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +9 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +53 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +4 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +214 -0
- package/lib/getTransactionStatus.js.map +1 -0
- package/lib/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib/getTransactionStatus.unit.test.js +54 -0
- package/lib/getTransactionStatus.unit.test.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +37 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/logic.d.ts +88 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +264 -0
- package/lib/logic.js.map +1 -0
- package/lib/logic.unit.test.d.ts +2 -0
- package/lib/logic.unit.test.d.ts.map +1 -0
- package/lib/logic.unit.test.js +40 -0
- package/lib/logic.unit.test.js.map +1 -0
- package/lib/networks.d.ts +3 -0
- package/lib/networks.d.ts.map +1 -0
- package/lib/networks.js +36 -0
- package/lib/networks.js.map +1 -0
- package/lib/postSyncPatch.d.ts +6 -0
- package/lib/postSyncPatch.d.ts.map +1 -0
- package/lib/postSyncPatch.js +35 -0
- package/lib/postSyncPatch.js.map +1 -0
- package/lib/prepareTransaction.d.ts +10 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +44 -0
- package/lib/prepareTransaction.js.map +1 -0
- package/lib/serialization.d.ts +7 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +146 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signOperation.d.ts +9 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +71 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +92 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +218 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +4 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +128 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronisation.d.ts +6 -0
- package/lib/synchronisation.d.ts.map +1 -0
- package/lib/synchronisation.js +237 -0
- package/lib/synchronisation.js.map +1 -0
- package/lib/synchronisation.unit.test.d.ts +2 -0
- package/lib/synchronisation.unit.test.d.ts.map +1 -0
- package/lib/synchronisation.unit.test.js +129 -0
- package/lib/synchronisation.unit.test.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +43 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types.d.ts +188 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +18 -0
- package/lib/types.js.map +1 -0
- package/lib/typhonSerializer.d.ts +17 -0
- package/lib/typhonSerializer.d.ts.map +1 -0
- package/lib/typhonSerializer.js +213 -0
- package/lib/typhonSerializer.js.map +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +8 -0
- package/lib/utils.js.map +1 -0
- package/lib-es/account.d.ts +7 -0
- package/lib-es/account.d.ts.map +1 -0
- package/lib-es/account.js +34 -0
- package/lib-es/account.js.map +1 -0
- package/lib-es/address.unit.test.d.ts +2 -0
- package/lib-es/address.unit.test.d.ts.map +1 -0
- package/lib-es/address.unit.test.js +19 -0
- package/lib-es/address.unit.test.js.map +1 -0
- package/lib-es/api/api-types.d.ts +106 -0
- package/lib-es/api/api-types.d.ts.map +1 -0
- package/lib-es/api/api-types.js +6 -0
- package/lib-es/api/api-types.js.map +1 -0
- package/lib-es/api/getDelegationInfo.d.ts +4 -0
- package/lib-es/api/getDelegationInfo.d.ts.map +1 -0
- package/lib-es/api/getDelegationInfo.js +41 -0
- package/lib-es/api/getDelegationInfo.js.map +1 -0
- package/lib-es/api/getNetworkInfo.d.ts +5 -0
- package/lib-es/api/getNetworkInfo.d.ts.map +1 -0
- package/lib-es/api/getNetworkInfo.js +39 -0
- package/lib-es/api/getNetworkInfo.js.map +1 -0
- package/lib-es/api/getPools.d.ts +5 -0
- package/lib-es/api/getPools.d.ts.map +1 -0
- package/lib-es/api/getPools.js +37 -0
- package/lib-es/api/getPools.js.map +1 -0
- package/lib-es/api/getTransactions.d.ts +10 -0
- package/lib-es/api/getTransactions.d.ts.map +1 -0
- package/lib-es/api/getTransactions.js +132 -0
- package/lib-es/api/getTransactions.js.map +1 -0
- package/lib-es/api/submitTransaction.d.ts +7 -0
- package/lib-es/api/submitTransaction.d.ts.map +1 -0
- package/lib-es/api/submitTransaction.js +27 -0
- package/lib-es/api/submitTransaction.js.map +1 -0
- package/lib-es/bridge/index.d.ts +11 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +61 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +107 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +8 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +24 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/buildOptimisticOperation.d.ts +4 -0
- package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
- package/lib-es/buildOptimisticOperation.js +118 -0
- package/lib-es/buildOptimisticOperation.js.map +1 -0
- package/lib-es/buildSubAccounts.d.ts +26 -0
- package/lib-es/buildSubAccounts.d.ts.map +1 -0
- package/lib-es/buildSubAccounts.js +114 -0
- package/lib-es/buildSubAccounts.js.map +1 -0
- package/lib-es/buildTransaction.d.ts +11 -0
- package/lib-es/buildTransaction.d.ts.map +1 -0
- package/lib-es/buildTransaction.js +335 -0
- package/lib-es/buildTransaction.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +18 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +60 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/constants.d.ts +8 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +9 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/createTransaction.d.ts +9 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +16 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/datasets/rawAccount.1.d.ts +3 -0
- package/lib-es/datasets/rawAccount.1.d.ts.map +1 -0
- package/lib-es/datasets/rawAccount.1.js +17 -0
- package/lib-es/datasets/rawAccount.1.js.map +1 -0
- package/lib-es/datasets/scanAccounts.d.ts +5 -0
- package/lib-es/datasets/scanAccounts.d.ts.map +1 -0
- package/lib-es/datasets/scanAccounts.js +24 -0
- package/lib-es/datasets/scanAccounts.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +11 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +101 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +22 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +15 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +9 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +49 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +4 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +210 -0
- package/lib-es/getTransactionStatus.js.map +1 -0
- package/lib-es/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib-es/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.unit.test.js +49 -0
- package/lib-es/getTransactionStatus.unit.test.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +35 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/logic.d.ts +88 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +236 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/logic.unit.test.d.ts +2 -0
- package/lib-es/logic.unit.test.d.ts.map +1 -0
- package/lib-es/logic.unit.test.js +35 -0
- package/lib-es/logic.unit.test.js.map +1 -0
- package/lib-es/networks.d.ts +3 -0
- package/lib-es/networks.d.ts.map +1 -0
- package/lib-es/networks.js +32 -0
- package/lib-es/networks.js.map +1 -0
- package/lib-es/postSyncPatch.d.ts +6 -0
- package/lib-es/postSyncPatch.d.ts.map +1 -0
- package/lib-es/postSyncPatch.js +31 -0
- package/lib-es/postSyncPatch.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +10 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +40 -0
- package/lib-es/prepareTransaction.js.map +1 -0
- package/lib-es/serialization.d.ts +7 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +139 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signOperation.d.ts +9 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +64 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +92 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +7 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +213 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +4 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +125 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronisation.d.ts +6 -0
- package/lib-es/synchronisation.d.ts.map +1 -0
- package/lib-es/synchronisation.js +230 -0
- package/lib-es/synchronisation.js.map +1 -0
- package/lib-es/synchronisation.unit.test.d.ts +2 -0
- package/lib-es/synchronisation.unit.test.d.ts.map +1 -0
- package/lib-es/synchronisation.unit.test.js +124 -0
- package/lib-es/synchronisation.unit.test.js.map +1 -0
- package/lib-es/transaction.d.ts +15 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +37 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types.d.ts +188 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +15 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/typhonSerializer.d.ts +17 -0
- package/lib-es/typhonSerializer.d.ts.map +1 -0
- package/lib-es/typhonSerializer.js +207 -0
- package/lib-es/typhonSerializer.js.map +1 -0
- package/lib-es/utils.d.ts +2 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +5 -0
- package/lib-es/utils.js.map +1 -0
- package/package.json +91 -0
- package/src/account.ts +39 -0
- package/src/address.unit.test.ts +32 -0
- package/src/api/api-types.ts +115 -0
- package/src/api/getDelegationInfo.ts +39 -0
- package/src/api/getNetworkInfo.ts +34 -0
- package/src/api/getPools.ts +35 -0
- package/src/api/getTransactions.ts +218 -0
- package/src/api/submitTransaction.ts +24 -0
- package/src/bridge/index.ts +69 -0
- package/src/bridge.integration.test.ts +113 -0
- package/src/broadcast.ts +21 -0
- package/src/buildOptimisticOperation.ts +181 -0
- package/src/buildSubAccounts.ts +170 -0
- package/src/buildTransaction.ts +435 -0
- package/src/cli-transaction.ts +82 -0
- package/src/constants.ts +10 -0
- package/src/createTransaction.ts +18 -0
- package/src/datasets/rawAccount.1.ts +19 -0
- package/src/datasets/scanAccounts.ts +23 -0
- package/src/deviceTransactionConfig.ts +128 -0
- package/src/errors.ts +18 -0
- package/src/estimateMaxSpendable.ts +61 -0
- package/src/getTransactionStatus.ts +251 -0
- package/src/getTransactionStatus.unit.test.ts +45 -0
- package/src/hw-getAddress.ts +37 -0
- package/src/logic.ts +330 -0
- package/src/logic.unit.test.ts +39 -0
- package/src/networks.ts +33 -0
- package/src/postSyncPatch.ts +42 -0
- package/src/prepareTransaction.ts +41 -0
- package/src/serialization.ts +219 -0
- package/src/signOperation.ts +82 -0
- package/src/signer.ts +98 -0
- package/src/specs.ts +253 -0
- package/src/speculos-deviceActions.ts +132 -0
- package/src/synchronisation.ts +347 -0
- package/src/synchronisation.unit.test.ts +137 -0
- package/src/transaction.ts +66 -0
- package/src/types.ts +227 -0
- package/src/typhonSerializer.ts +259 -0
- package/src/utils.ts +4 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,OAAO,OAAO,CAAC;AAC5B,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,eAAO,MAAM,oBAAoB,QAAiC,CAAC;AACnE,eAAO,MAAM,4BAA4B,QAAyC,CAAC"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CARDANO_TESTNET_API_ENDPOINT = exports.CARDANO_API_ENDPOINT = exports.MEMO_LABEL = exports.CARDANO_COIN_TYPE = exports.CARDANO_PURPOSE = exports.TTL_GAP = exports.STAKING_ADDRESS_INDEX = void 0;
|
|
4
|
+
const live_env_1 = require("@ledgerhq/live-env");
|
|
5
|
+
exports.STAKING_ADDRESS_INDEX = 0;
|
|
6
|
+
exports.TTL_GAP = 7200;
|
|
7
|
+
exports.CARDANO_PURPOSE = 1852;
|
|
8
|
+
exports.CARDANO_COIN_TYPE = 1815;
|
|
9
|
+
exports.MEMO_LABEL = 674;
|
|
10
|
+
exports.CARDANO_API_ENDPOINT = (0, live_env_1.getEnv)("CARDANO_API_ENDPOINT");
|
|
11
|
+
exports.CARDANO_TESTNET_API_ENDPOINT = (0, live_env_1.getEnv)("CARDANO_TESTNET_API_ENDPOINT");
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE/B,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAC1B,QAAA,OAAO,GAAG,IAAI,CAAC;AACf,QAAA,eAAe,GAAG,IAAI,CAAC;AACvB,QAAA,iBAAiB,GAAG,IAAI,CAAC;AACzB,QAAA,UAAU,GAAG,GAAG,CAAC;AAEjB,QAAA,oBAAoB,GAAG,IAAA,iBAAM,EAAC,sBAAsB,CAAC,CAAC;AACtD,QAAA,4BAA4B,GAAG,IAAA,iBAAM,EAAC,8BAA8B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import { Transaction } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Create an empty transaction
|
|
5
|
+
*
|
|
6
|
+
* @returns {Transaction}
|
|
7
|
+
*/
|
|
8
|
+
export declare const createTransaction: AccountBridge<Transaction>["createTransaction"];
|
|
9
|
+
//# sourceMappingURL=createTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransaction.d.ts","sourceRoot":"","sources":["../src/createTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAQ5E,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createTransaction = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
/**
|
|
9
|
+
* Create an empty transaction
|
|
10
|
+
*
|
|
11
|
+
* @returns {Transaction}
|
|
12
|
+
*/
|
|
13
|
+
const createTransaction = () => ({
|
|
14
|
+
family: "cardano",
|
|
15
|
+
mode: "send",
|
|
16
|
+
amount: new bignumber_js_1.default(0),
|
|
17
|
+
recipient: "",
|
|
18
|
+
useAllAmount: false,
|
|
19
|
+
fees: new bignumber_js_1.default(0),
|
|
20
|
+
poolId: undefined,
|
|
21
|
+
});
|
|
22
|
+
exports.createTransaction = createTransaction;
|
|
23
|
+
//# sourceMappingURL=createTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransaction.js","sourceRoot":"","sources":["../src/createTransaction.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC;;;;GAIG;AACI,MAAM,iBAAiB,GAAoD,GAAG,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;IACxB,SAAS,EAAE,EAAE;IACb,YAAY,EAAE,KAAK;IACnB,IAAI,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;IACtB,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AARU,QAAA,iBAAiB,qBAQ3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawAccount.1.d.ts","sourceRoot":"","sources":["../../src/datasets/rawAccount.1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,kBAAkB,EAAE,UAgBhC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cardanoRawAccount1 = void 0;
|
|
4
|
+
exports.cardanoRawAccount1 = {
|
|
5
|
+
id: "js:2:cardano_testnet:806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d:cardano",
|
|
6
|
+
seedIdentifier: "bea94629d5cf776b8374a00afa15686f0b0742dd0330f86804c61202",
|
|
7
|
+
name: "Cardano (Testnet) 1",
|
|
8
|
+
derivationMode: "cardano",
|
|
9
|
+
index: 0,
|
|
10
|
+
freshAddress: "addr_test1qpj84xm4jlpcsvmrnldj86zz7g4mwzr7qg90wdjpn64uea44mcsd3mzvmr9qhfscxkyla3aqnzttwepay9mt3fz84smqyjvhh4",
|
|
11
|
+
freshAddressPath: "1852'/1815'/0'/0/2",
|
|
12
|
+
blockHeight: 0,
|
|
13
|
+
operations: [],
|
|
14
|
+
pendingOperations: [],
|
|
15
|
+
currencyId: "cardano_testnet",
|
|
16
|
+
lastSyncDate: "",
|
|
17
|
+
balance: "10098829375",
|
|
18
|
+
xpub: "806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d",
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=rawAccount.1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawAccount.1.js","sourceRoot":"","sources":["../../src/datasets/rawAccount.1.ts"],"names":[],"mappings":";;;AAEa,QAAA,kBAAkB,GAAe;IAC5C,EAAE,EAAE,+JAA+J;IACnK,cAAc,EAAE,0DAA0D;IAC1E,IAAI,EAAE,qBAAqB;IAC3B,cAAc,EAAE,SAAS;IACzB,KAAK,EAAE,CAAC;IACR,YAAY,EACV,8GAA8G;IAChH,gBAAgB,EAAE,oBAAoB;IACtC,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,EAAE;IACd,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,iBAAiB;IAC7B,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,kIAAkI;CACzI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanAccounts.d.ts","sourceRoot":"","sources":["../../src/datasets/scanAccounts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;GAsB/B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cardanoScanAccounts = void 0;
|
|
4
|
+
exports.cardanoScanAccounts = [
|
|
5
|
+
{
|
|
6
|
+
name: "cardano_testnet seed 1",
|
|
7
|
+
apdus: `
|
|
8
|
+
=> d700000000
|
|
9
|
+
<= 050000009000
|
|
10
|
+
=> d71101002d0000058000073c8000071780000000000000000000000022058000073c80000717800000000000000200000000
|
|
11
|
+
<= 00bea94629d5cf776b8374a00afa15686f0b0742dd0330f86804c61202b5de20d8ec4cd8ca0ba6183589fec7a09896b7643d2176b8a447ac369000
|
|
12
|
+
=> d700000000
|
|
13
|
+
<= 050000009000
|
|
14
|
+
=> d71000000d038000073c8000071780000000
|
|
15
|
+
<= 806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d9000
|
|
16
|
+
=> d700000000
|
|
17
|
+
<= 050000009000
|
|
18
|
+
=> d71101002d0000058000073c8000071780000001000000000000000022058000073c80000717800000010000000200000000
|
|
19
|
+
<= 0009457d98f405191765830c1afe91cc32b5f45c193a9aad4b606f8f5dd599d97135c125c5633d3d4431be87a9cff26ec08d388833bfcc530f9000
|
|
20
|
+
=> d700000000
|
|
21
|
+
<= 050000009000
|
|
22
|
+
=> d71000000d038000073c8000071780000001
|
|
23
|
+
<= ed5e0d059cb2eed53ea30b9ba84bb3aaa6c2364c6305a0c9a7e8944aa439884a642cc2f06e601808926e14b6e27417be0b0323d5a5149f1eebab8fc4e1fe14d49000
|
|
24
|
+
`,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
//# sourceMappingURL=scanAccounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanAccounts.js","sourceRoot":"","sources":["../../src/datasets/scanAccounts.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;IACjC;QACE,IAAI,EAAE,wBAAwB;QAC9B,KAAK,EAAE;;;;;;;;;;;;;;;;;KAiBN;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
|
|
2
|
+
import { Account, AccountLike } from "@ledgerhq/types-live";
|
|
3
|
+
import { Transaction, TransactionStatus } from "./types";
|
|
4
|
+
declare function getDeviceTransactionConfig({ account, transaction, parentAccount, }: {
|
|
5
|
+
account: AccountLike;
|
|
6
|
+
parentAccount: Account | null | undefined;
|
|
7
|
+
transaction: Transaction;
|
|
8
|
+
status: TransactionStatus;
|
|
9
|
+
}): Array<DeviceTransactionField>;
|
|
10
|
+
export default getDeviceTransactionConfig;
|
|
11
|
+
//# sourceMappingURL=deviceTransactionConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.d.ts","sourceRoot":"","sources":["../src/deviceTransactionConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,IAAI,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAC1H,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAkB,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AASzE,iBAAS,0BAA0B,CAAC,EAClC,OAAO,EACP,WAAW,EACX,aAAa,GACd,EAAE;IACD,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAqGhC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
+
const index_1 = require("@ledgerhq/coin-framework/account/index");
|
|
8
|
+
const index_2 = require("@ledgerhq/coin-framework/currencies/index");
|
|
9
|
+
const buildSubAccounts_1 = require("./buildSubAccounts");
|
|
10
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
11
|
+
const logic_1 = require("./logic");
|
|
12
|
+
function getDeviceTransactionConfig({ account, transaction, parentAccount, }) {
|
|
13
|
+
const { mode } = transaction;
|
|
14
|
+
const fields = [];
|
|
15
|
+
const mainAccount = (0, index_1.getMainAccount)(account, parentAccount);
|
|
16
|
+
const cardanoResources = mainAccount.cardanoResources;
|
|
17
|
+
const { fees } = transaction;
|
|
18
|
+
if (fees) {
|
|
19
|
+
fields.push({
|
|
20
|
+
type: "text",
|
|
21
|
+
label: "Transaction Fee",
|
|
22
|
+
value: (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(account).units[0], fees, {
|
|
23
|
+
showCode: true,
|
|
24
|
+
disableRounding: true,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (mode === "send") {
|
|
29
|
+
if (account.type === "TokenAccount") {
|
|
30
|
+
const { assetId } = (0, buildSubAccounts_1.decodeTokenCurrencyId)(account.token.id);
|
|
31
|
+
const { policyId, assetName } = (0, buildSubAccounts_1.decodeTokenAssetId)(assetId);
|
|
32
|
+
const transactionAmount = transaction.useAllAmount ? account.balance : transaction.amount;
|
|
33
|
+
const tokensToSend = [
|
|
34
|
+
{
|
|
35
|
+
policyId,
|
|
36
|
+
assetName,
|
|
37
|
+
amount: transactionAmount,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
const requiredMinAdaForTokens = typhonjs_1.utils.calculateMinUtxoAmount(tokensToSend, new bignumber_js_1.default(cardanoResources.protocolParams.lovelacePerUtxoWord));
|
|
41
|
+
fields.push({
|
|
42
|
+
type: "text",
|
|
43
|
+
label: "ADA",
|
|
44
|
+
value: (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(mainAccount).units[0], requiredMinAdaForTokens, {
|
|
45
|
+
showCode: true,
|
|
46
|
+
disableRounding: true,
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
fields.push({
|
|
50
|
+
type: "text",
|
|
51
|
+
label: "Token Name",
|
|
52
|
+
value: (0, logic_1.decodeTokenName)(assetName),
|
|
53
|
+
});
|
|
54
|
+
fields.push({
|
|
55
|
+
type: "text",
|
|
56
|
+
label: "Amount",
|
|
57
|
+
value: (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(account).units[0], transactionAmount, {
|
|
58
|
+
showCode: true,
|
|
59
|
+
disableRounding: true,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else if (account.type === "Account") {
|
|
64
|
+
fields.push({
|
|
65
|
+
type: "text",
|
|
66
|
+
label: "Amount",
|
|
67
|
+
value: (0, index_2.formatCurrencyUnit)((0, index_1.getAccountCurrency)(account).units[0], transaction.amount, {
|
|
68
|
+
showCode: true,
|
|
69
|
+
disableRounding: true,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (mode === "delegate" && account.type === "Account") {
|
|
75
|
+
const stakeCredential = (0, logic_1.getAccountStakeCredential)(account.xpub, account.index);
|
|
76
|
+
fields.push({
|
|
77
|
+
type: "text",
|
|
78
|
+
label: "Staking key",
|
|
79
|
+
value: (0, logic_1.getBipPathString)({
|
|
80
|
+
account: stakeCredential.path.account,
|
|
81
|
+
chain: stakeCredential.path.chain,
|
|
82
|
+
index: stakeCredential.path.index,
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
fields.push({
|
|
86
|
+
type: "text",
|
|
87
|
+
label: "Delegate stake to",
|
|
88
|
+
value: (0, logic_1.getBech32PoolId)(transaction.poolId, account.currency.id),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else if (mode === "undelegate" && account.type === "Account") {
|
|
92
|
+
const stakeCredential = (0, logic_1.getAccountStakeCredential)(account.xpub, account.index);
|
|
93
|
+
fields.push({
|
|
94
|
+
type: "text",
|
|
95
|
+
label: "Staking key",
|
|
96
|
+
value: (0, logic_1.getBipPathString)({
|
|
97
|
+
account: stakeCredential.path.account,
|
|
98
|
+
chain: stakeCredential.path.chain,
|
|
99
|
+
index: stakeCredential.path.index,
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return fields;
|
|
104
|
+
}
|
|
105
|
+
exports.default = getDeviceTransactionConfig;
|
|
106
|
+
//# sourceMappingURL=deviceTransactionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.js","sourceRoot":"","sources":["../src/deviceTransactionConfig.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AACrC,kEAA4F;AAC5F,qEAA+E;AAG/E,yDAA+E;AAE/E,iDAA0D;AAC1D,mCAKiB;AAEjB,SAAS,0BAA0B,CAAC,EAClC,OAAO,EACP,WAAW,EACX,aAAa,GAMd;IACC,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;IAC7B,MAAM,MAAM,GAA6B,EAAE,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAA,sBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,gBAAgB,GAAI,WAA8B,CAAC,gBAAgB,CAAC;IAE1E,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;IAC7B,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,iBAAiB;YACxB,KAAK,EAAE,IAAA,0BAAkB,EAAC,IAAA,0BAAkB,EAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE;gBACpE,QAAQ,EAAE,IAAI;gBACd,eAAe,EAAE,IAAI;aACtB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACpC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,wCAAqB,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5D,MAAM,EAAE,QAAQ,EAA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IAAA,wBAAgB,EAAC;gBACtB,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO;gBACrC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK;gBACjC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK;aAClC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kBAAe,0BAA0B,CAAC"}
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cardano error thrown when transaction amount is less then minUtxo
|
|
3
|
+
*/
|
|
4
|
+
export declare const CardanoMinAmountError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Cardano error thrown when user don't have enough fund for deposit
|
|
9
|
+
*/
|
|
10
|
+
export declare const CardanoStakeKeyDepositError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Cardano error thrown when not enough funds to perform transaction
|
|
15
|
+
*/
|
|
16
|
+
export declare const CardanoNotEnoughFunds: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const CardanoInvalidPoolId: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;EAAkD,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;EAAwD,CAAC;AAEjG;;GAEG;AACH,eAAO,MAAM,qBAAqB;;EAAkD,CAAC;AAErF,eAAO,MAAM,oBAAoB;;EAAiD,CAAC"}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CardanoInvalidPoolId = exports.CardanoNotEnoughFunds = exports.CardanoStakeKeyDepositError = exports.CardanoMinAmountError = void 0;
|
|
4
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
5
|
+
/**
|
|
6
|
+
* Cardano error thrown when transaction amount is less then minUtxo
|
|
7
|
+
*/
|
|
8
|
+
exports.CardanoMinAmountError = (0, errors_1.createCustomErrorClass)("CardanoMinAmountError");
|
|
9
|
+
/**
|
|
10
|
+
* Cardano error thrown when user don't have enough fund for deposit
|
|
11
|
+
*/
|
|
12
|
+
exports.CardanoStakeKeyDepositError = (0, errors_1.createCustomErrorClass)("CardanoStakeKeyDepositError");
|
|
13
|
+
/**
|
|
14
|
+
* Cardano error thrown when not enough funds to perform transaction
|
|
15
|
+
*/
|
|
16
|
+
exports.CardanoNotEnoughFunds = (0, errors_1.createCustomErrorClass)("CardanoNotEnoughFunds");
|
|
17
|
+
exports.CardanoInvalidPoolId = (0, errors_1.createCustomErrorClass)("CardanoInvalidPoolId");
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAE1D;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,+BAAsB,EAAC,uBAAuB,CAAC,CAAC;AAErF;;GAEG;AACU,QAAA,2BAA2B,GAAG,IAAA,+BAAsB,EAAC,6BAA6B,CAAC,CAAC;AAEjG;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,+BAAsB,EAAC,uBAAuB,CAAC,CAAC;AAExE,QAAA,oBAAoB,GAAG,IAAA,+BAAsB,EAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import type { CardanoAccount, Transaction } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the maximum possible amount for transaction
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} param - the account, parentAccount and transaction
|
|
7
|
+
*/
|
|
8
|
+
export declare const estimateMaxSpendable: AccountBridge<Transaction, CardanoAccount>["estimateMaxSpendable"];
|
|
9
|
+
//# sourceMappingURL=estimateMaxSpendable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.d.ts","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAC9C,WAAW,EACX,cAAc,CACf,CAAC,sBAAsB,CAuCvB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.estimateMaxSpendable = void 0;
|
|
13
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
14
|
+
const logs_1 = require("@ledgerhq/logs");
|
|
15
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
16
|
+
const index_1 = require("@ledgerhq/coin-framework/account/index");
|
|
17
|
+
const createTransaction_1 = require("./createTransaction");
|
|
18
|
+
const buildTransaction_1 = require("./buildTransaction");
|
|
19
|
+
/**
|
|
20
|
+
* Returns the maximum possible amount for transaction
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} param - the account, parentAccount and transaction
|
|
23
|
+
*/
|
|
24
|
+
const estimateMaxSpendable = (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, parentAccount, transaction }) {
|
|
25
|
+
const mainAccount = (0, index_1.getMainAccount)(account, parentAccount);
|
|
26
|
+
if (mainAccount.cardanoResources.utxos.length === 0) {
|
|
27
|
+
return new bignumber_js_1.BigNumber(0);
|
|
28
|
+
}
|
|
29
|
+
if (account.type === "TokenAccount") {
|
|
30
|
+
return account.balance;
|
|
31
|
+
}
|
|
32
|
+
const dummyRecipient = "addr1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv2t5am";
|
|
33
|
+
const t = Object.assign(Object.assign(Object.assign({}, (0, createTransaction_1.createTransaction)(account)), transaction), { recipient: dummyRecipient,
|
|
34
|
+
// amount field will not be used to build a transaction when useAllAmount is true
|
|
35
|
+
amount: new bignumber_js_1.BigNumber(0), useAllAmount: true });
|
|
36
|
+
let typhonTransaction;
|
|
37
|
+
try {
|
|
38
|
+
typhonTransaction = yield (0, buildTransaction_1.buildTransaction)(mainAccount, t);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
(0, logs_1.log)("cardano-error", "Failed to estimate max spendable: " + String(error));
|
|
42
|
+
return new bignumber_js_1.BigNumber(0);
|
|
43
|
+
}
|
|
44
|
+
const transactionAmount = typhonTransaction
|
|
45
|
+
.getOutputs()
|
|
46
|
+
.filter(o => !(o.address instanceof typhonjs_1.address.BaseAddress) ||
|
|
47
|
+
!(o.address.paymentCredential.type === typhonjs_1.types.HashType.ADDRESS) ||
|
|
48
|
+
o.address.paymentCredential.bipPath === undefined)
|
|
49
|
+
.reduce((total, o) => total.plus(o.amount), new bignumber_js_1.BigNumber(0));
|
|
50
|
+
return transactionAmount;
|
|
51
|
+
});
|
|
52
|
+
exports.estimateMaxSpendable = estimateMaxSpendable;
|
|
53
|
+
//# sourceMappingURL=estimateMaxSpendable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAI4B;AAC5B,yCAAqC;AACrC,+CAAyC;AAEzC,kEAAwE;AAExE,2DAAwD;AACxD,yDAAsD;AAEtD;;;;GAIG;AACI,MAAM,oBAAoB,GAGL,KAAgD,EAAE,4CAA3C,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE;IACxE,MAAM,WAAW,GAAG,IAAA,sBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE3D,IAAI,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,OAAO,IAAI,wBAAS,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,cAAc,GAClB,yGAAyG,CAAC;IAC5G,MAAM,CAAC,iDACF,IAAA,qCAAiB,EAAC,OAAO,CAAC,GAC1B,WAAW,KACd,SAAS,EAAE,cAAc;QACzB,iFAAiF;QACjF,MAAM,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC,EACxB,YAAY,EAAE,IAAI,GACnB,CAAC;IACF,IAAI,iBAAoC,CAAC;IACzC,IAAI,CAAC;QACH,iBAAiB,GAAG,MAAM,IAAA,mCAAgB,EAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,UAAG,EAAC,eAAe,EAAE,oCAAoC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3E,OAAO,IAAI,wBAAS,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,iBAAiB,GAAG,iBAAiB;SACxC,UAAU,EAAE;SACZ,MAAM,CACL,CAAC,CAAC,EAAE,CACF,CAAC,CAAC,CAAC,CAAC,OAAO,YAAY,kBAAa,CAAC,WAAW,CAAC;QACjD,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,KAAK,gBAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;QACpE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,KAAK,SAAS,CACpD;SACA,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAA,CAAC;AA1CW,QAAA,oBAAoB,wBA0C/B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import type { CardanoAccount, Transaction, TransactionStatus } from "./types";
|
|
3
|
+
export declare const getTransactionStatus: AccountBridge<Transaction, CardanoAccount, TransactionStatus>["getTransactionStatus"];
|
|
4
|
+
//# sourceMappingURL=getTransactionStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTransactionStatus.d.ts","sourceRoot":"","sources":["../src/getTransactionStatus.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAarD,OAAO,KAAK,EACV,cAAc,EAGd,WAAW,EACX,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAC9C,WAAW,EACX,cAAc,EACd,iBAAiB,CAClB,CAAC,sBAAsB,CA2BvB,CAAC"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getTransactionStatus = void 0;
|
|
13
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
14
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
15
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
16
|
+
const buildSubAccounts_1 = require("./buildSubAccounts");
|
|
17
|
+
const estimateMaxSpendable_1 = require("./estimateMaxSpendable");
|
|
18
|
+
const buildTransaction_1 = require("./buildTransaction");
|
|
19
|
+
const logic_1 = require("./logic");
|
|
20
|
+
const networks_1 = require("./networks");
|
|
21
|
+
const errors_2 = require("./errors");
|
|
22
|
+
const getTransactionStatus = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
if (account.pendingOperations.length > 0) {
|
|
24
|
+
throw new errors_1.AccountAwaitingSendPendingOperations();
|
|
25
|
+
}
|
|
26
|
+
if (account.cardanoResources.utxos.length === 0) {
|
|
27
|
+
const errors = {
|
|
28
|
+
amount: new errors_2.CardanoNotEnoughFunds(),
|
|
29
|
+
};
|
|
30
|
+
return Promise.resolve({
|
|
31
|
+
errors,
|
|
32
|
+
warnings: {},
|
|
33
|
+
estimatedFees: new bignumber_js_1.BigNumber(0),
|
|
34
|
+
amount: new bignumber_js_1.BigNumber(transaction.amount),
|
|
35
|
+
totalSpent: new bignumber_js_1.BigNumber(transaction.amount),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (transaction.mode === "send") {
|
|
39
|
+
return getSendTransactionStatus(account, transaction);
|
|
40
|
+
}
|
|
41
|
+
else if (transaction.mode === "delegate") {
|
|
42
|
+
return getDelegateTransactionStatus(account, transaction);
|
|
43
|
+
}
|
|
44
|
+
else if (transaction.mode === "undelegate") {
|
|
45
|
+
return getUndelegateTransactionStatus(account, transaction);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error("Invalid transaction mode");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
exports.getTransactionStatus = getTransactionStatus;
|
|
52
|
+
function getSendTransactionStatus(account, transaction) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const errors = {};
|
|
55
|
+
const warnings = {};
|
|
56
|
+
const useAllAmount = !!transaction.useAllAmount;
|
|
57
|
+
const cardanoResources = account.cardanoResources;
|
|
58
|
+
const networkParams = (0, networks_1.getNetworkParameters)(account.currency.id);
|
|
59
|
+
const estimatedFees = transaction.fees || new bignumber_js_1.BigNumber(0);
|
|
60
|
+
let amount = transaction.amount;
|
|
61
|
+
let totalSpent = estimatedFees;
|
|
62
|
+
const tokenAccount = transaction.subAccountId && account.subAccounts
|
|
63
|
+
? account.subAccounts.find(a => {
|
|
64
|
+
return a.id === transaction.subAccountId;
|
|
65
|
+
})
|
|
66
|
+
: undefined;
|
|
67
|
+
let tokensToSend = [];
|
|
68
|
+
if (transaction.subAccountId) {
|
|
69
|
+
// Token transaction
|
|
70
|
+
if (!tokenAccount || tokenAccount.type !== "TokenAccount") {
|
|
71
|
+
throw new Error("TokenAccount not found");
|
|
72
|
+
}
|
|
73
|
+
const { assetId } = (0, buildSubAccounts_1.decodeTokenCurrencyId)(tokenAccount.token.id);
|
|
74
|
+
const { policyId, assetName } = (0, buildSubAccounts_1.decodeTokenAssetId)(assetId);
|
|
75
|
+
amount = transaction.useAllAmount ? tokenAccount.balance : transaction.amount;
|
|
76
|
+
totalSpent = amount;
|
|
77
|
+
tokensToSend = [
|
|
78
|
+
{
|
|
79
|
+
policyId,
|
|
80
|
+
assetName,
|
|
81
|
+
amount,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// ADA transaction
|
|
87
|
+
amount = transaction.useAllAmount
|
|
88
|
+
? yield (0, estimateMaxSpendable_1.estimateMaxSpendable)({ account: account, transaction: transaction })
|
|
89
|
+
: amount;
|
|
90
|
+
totalSpent = amount.plus(estimatedFees);
|
|
91
|
+
}
|
|
92
|
+
const minTransactionAmount = typhonjs_1.utils.calculateMinUtxoAmount(tokensToSend, new bignumber_js_1.BigNumber(cardanoResources.protocolParams.lovelacePerUtxoWord), false);
|
|
93
|
+
if (!transaction.fees) {
|
|
94
|
+
errors.fees = new errors_1.FeeNotLoaded();
|
|
95
|
+
}
|
|
96
|
+
if (!transaction.recipient) {
|
|
97
|
+
errors.recipient = new errors_1.RecipientRequired();
|
|
98
|
+
}
|
|
99
|
+
else if (!(0, logic_1.isValidAddress)(transaction.recipient, networkParams.networkId)) {
|
|
100
|
+
errors.recipient = new errors_1.InvalidAddress("", {
|
|
101
|
+
currencyName: account.currency.name,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (!amount.gt(0)) {
|
|
105
|
+
errors.amount = useAllAmount ? new errors_2.CardanoNotEnoughFunds() : new errors_1.AmountRequired();
|
|
106
|
+
}
|
|
107
|
+
else if (!transaction.subAccountId && amount.lt(minTransactionAmount)) {
|
|
108
|
+
errors.amount = new errors_2.CardanoMinAmountError("", {
|
|
109
|
+
amount: minTransactionAmount.div(1e6).toString(),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else if (tokenAccount ? totalSpent.gt(tokenAccount.balance) : totalSpent.gt(account.balance)) {
|
|
113
|
+
errors.amount = new errors_1.NotEnoughBalance();
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
try {
|
|
117
|
+
yield (0, buildTransaction_1.buildTransaction)(account, transaction);
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
if (e.message.toLowerCase() === "not enough ada" ||
|
|
121
|
+
e.message.toLowerCase() === "not enough tokens") {
|
|
122
|
+
errors.amount = new errors_2.CardanoNotEnoughFunds();
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return Promise.resolve({
|
|
130
|
+
errors,
|
|
131
|
+
warnings,
|
|
132
|
+
estimatedFees,
|
|
133
|
+
amount,
|
|
134
|
+
totalSpent,
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function getDelegateTransactionStatus(account, transaction) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
var _a;
|
|
141
|
+
const errors = {};
|
|
142
|
+
const warnings = {};
|
|
143
|
+
if (!transaction.fees) {
|
|
144
|
+
errors.fees = new errors_1.FeeNotLoaded();
|
|
145
|
+
}
|
|
146
|
+
const estimatedFees = transaction.fees || new bignumber_js_1.BigNumber(0);
|
|
147
|
+
if (!transaction.poolId || !(0, logic_1.isHexString)(transaction.poolId) || transaction.poolId.length !== 56) {
|
|
148
|
+
errors.poolId = new errors_2.CardanoInvalidPoolId();
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
try {
|
|
152
|
+
yield (0, buildTransaction_1.buildTransaction)(account, transaction);
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
if (e.message.toLowerCase() === "not enough ada" ||
|
|
156
|
+
e.message.toLowerCase() === "not enough tokens") {
|
|
157
|
+
errors.amount = new errors_2.CardanoNotEnoughFunds();
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
throw e;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const stakeKeyRegisterDeposit = new bignumber_js_1.BigNumber(account.cardanoResources.protocolParams.stakeKeyDeposit);
|
|
165
|
+
if (!((_a = account.cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.status) &&
|
|
166
|
+
account.spendableBalance.isLessThan(stakeKeyRegisterDeposit)) {
|
|
167
|
+
errors.amount = new errors_2.CardanoStakeKeyDepositError("", {
|
|
168
|
+
depositAmount: stakeKeyRegisterDeposit.div(1e6).toString(),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return Promise.resolve({
|
|
172
|
+
errors,
|
|
173
|
+
warnings,
|
|
174
|
+
estimatedFees,
|
|
175
|
+
amount: new bignumber_js_1.BigNumber(0),
|
|
176
|
+
totalSpent: estimatedFees,
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function getUndelegateTransactionStatus(account, transaction) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
var _a;
|
|
183
|
+
const errors = {};
|
|
184
|
+
const warnings = {};
|
|
185
|
+
const cardanoResources = account.cardanoResources;
|
|
186
|
+
const estimatedFees = transaction.fees || new bignumber_js_1.BigNumber(0);
|
|
187
|
+
if (!((_a = cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.status)) {
|
|
188
|
+
throw new Error("StakeKey is not registered");
|
|
189
|
+
}
|
|
190
|
+
if (account.balance.eq(0)) {
|
|
191
|
+
throw new errors_2.CardanoNotEnoughFunds();
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
yield (0, buildTransaction_1.buildTransaction)(account, transaction);
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
if (e.message.toLowerCase() === "not enough ada" ||
|
|
198
|
+
e.message.toLowerCase() === "not enough tokens") {
|
|
199
|
+
errors.amount = new errors_2.CardanoNotEnoughFunds();
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
throw e;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return Promise.resolve({
|
|
206
|
+
errors,
|
|
207
|
+
warnings,
|
|
208
|
+
estimatedFees,
|
|
209
|
+
amount: new bignumber_js_1.BigNumber(0),
|
|
210
|
+
totalSpent: estimatedFees,
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=getTransactionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTransactionStatus.js","sourceRoot":"","sources":["../src/getTransactionStatus.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAO0B;AAC1B,+CAAyC;AAEzC,iDAA0D;AAC1D,yDAA+E;AAC/E,iEAA8D;AAC9D,yDAAsD;AACtD,mCAAsD;AACtD,yCAAkD;AAClD,qCAKkB;AASX,MAAM,oBAAoB,GAIL,CAAO,OAAO,EAAE,WAAW,EAAE,EAAE;IACzD,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,6CAAoC,EAAE,CAAC;IACnD,CAAC;IAED,IAAI,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG;YACb,MAAM,EAAE,IAAI,8BAAqB,EAAE;SACpC,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,MAAM;YACN,QAAQ,E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