@ledgerhq/coin-multiversx 0.2.0-next.2
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 +23 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +31 -0
- package/CHANGELOG.md +400 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/api/apiCalls.d.ts +22 -0
- package/lib/api/apiCalls.d.ts.map +1 -0
- package/lib/api/apiCalls.js +153 -0
- package/lib/api/apiCalls.js.map +1 -0
- package/lib/api/dtos/multiversx-account.d.ts +9 -0
- package/lib/api/dtos/multiversx-account.d.ts.map +1 -0
- package/lib/api/dtos/multiversx-account.js +17 -0
- package/lib/api/dtos/multiversx-account.js.map +1 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +16 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/sdk.d.ts +29 -0
- package/lib/api/sdk.d.ts.map +1 -0
- package/lib/api/sdk.js +281 -0
- package/lib/api/sdk.js.map +1 -0
- package/lib/bridge/js.d.ts +11 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +62 -0
- package/lib/bridge/js.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 +142 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +9 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +16 -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 +100 -0
- package/lib/buildOptimisticOperation.js.map +1 -0
- package/lib/buildOptimisticOperation.test.d.ts +2 -0
- package/lib/buildOptimisticOperation.test.d.ts.map +1 -0
- package/lib/buildOptimisticOperation.test.js +78 -0
- package/lib/buildOptimisticOperation.test.js.map +1 -0
- package/lib/buildSubAccounts.d.ts +11 -0
- package/lib/buildSubAccounts.d.ts.map +1 -0
- package/lib/buildSubAccounts.js +117 -0
- package/lib/buildSubAccounts.js.map +1 -0
- package/lib/buildTransaction.d.ts +19 -0
- package/lib/buildTransaction.d.ts.map +1 -0
- package/lib/buildTransaction.js +49 -0
- package/lib/buildTransaction.js.map +1 -0
- package/lib/buildTransaction.unit.test.d.ts +2 -0
- package/lib/buildTransaction.unit.test.d.ts.map +1 -0
- package/lib/buildTransaction.unit.test.js +47 -0
- package/lib/buildTransaction.unit.test.js.map +1 -0
- package/lib/cli-transaction.d.ts +16 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +35 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/config.d.ts +14 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +16 -0
- package/lib/config.js.map +1 -0
- package/lib/constants.d.ts +21 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +27 -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 +26 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/datasets/multiversx1.d.ts +3 -0
- package/lib/datasets/multiversx1.d.ts.map +1 -0
- package/lib/datasets/multiversx1.js +21 -0
- package/lib/datasets/multiversx1.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +10 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +60 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/encode.d.ts +11 -0
- package/lib/encode.d.ts.map +1 -0
- package/lib/encode.js +39 -0
- package/lib/encode.js.map +1 -0
- package/lib/errors.d.ts +16 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +10 -0
- package/lib/errors.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +10 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +35 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/formatters.d.ts +11 -0
- package/lib/formatters.d.ts.map +1 -0
- package/lib/formatters.js +65 -0
- package/lib/formatters.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +5 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +107 -0
- package/lib/getTransactionStatus.js.map +1 -0
- package/lib/helpers/denominate.d.ts +9 -0
- package/lib/helpers/denominate.d.ts.map +1 -0
- package/lib/helpers/denominate.js +75 -0
- package/lib/helpers/denominate.js.map +1 -0
- package/lib/helpers/handleTransactionStatus.d.ts +7 -0
- package/lib/helpers/handleTransactionStatus.d.ts.map +1 -0
- package/lib/helpers/handleTransactionStatus.js +18 -0
- package/lib/helpers/handleTransactionStatus.js.map +1 -0
- package/lib/helpers/hasMinimumDelegableBalance.d.ts +3 -0
- package/lib/helpers/hasMinimumDelegableBalance.d.ts.map +1 -0
- package/lib/helpers/hasMinimumDelegableBalance.js +7 -0
- package/lib/helpers/hasMinimumDelegableBalance.js.map +1 -0
- package/lib/helpers/randomizeProviders.d.ts +7 -0
- package/lib/helpers/randomizeProviders.d.ts.map +1 -0
- package/lib/helpers/randomizeProviders.js +12 -0
- package/lib/helpers/randomizeProviders.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 +14 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/logic.d.ts +15 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +77 -0
- package/lib/logic.js.map +1 -0
- package/lib/preload.d.ts +11 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +94 -0
- package/lib/preload.js.map +1 -0
- package/lib/prepareTransaction.d.ts +10 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +72 -0
- package/lib/prepareTransaction.js.map +1 -0
- package/lib/reconciliation.d.ts +3 -0
- package/lib/reconciliation.d.ts.map +1 -0
- package/lib/reconciliation.js +56 -0
- package/lib/reconciliation.js.map +1 -0
- package/lib/serialization.d.ts +9 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +65 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signOperation.d.ts +10 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +65 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +16 -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 +286 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +16 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +250 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronisation.d.ts +5 -0
- package/lib/synchronisation.d.ts.map +1 -0
- package/lib/synchronisation.js +69 -0
- package/lib/synchronisation.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +62 -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 +17 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/binary.utils.d.ts +5 -0
- package/lib/utils/binary.utils.d.ts.map +1 -0
- package/lib/utils/binary.utils.js +16 -0
- package/lib/utils/binary.utils.js.map +1 -0
- package/lib-es/api/apiCalls.d.ts +22 -0
- package/lib-es/api/apiCalls.d.ts.map +1 -0
- package/lib-es/api/apiCalls.js +147 -0
- package/lib-es/api/apiCalls.js.map +1 -0
- package/lib-es/api/dtos/multiversx-account.d.ts +9 -0
- package/lib-es/api/dtos/multiversx-account.d.ts.map +1 -0
- package/lib-es/api/dtos/multiversx-account.js +13 -0
- package/lib-es/api/dtos/multiversx-account.js.map +1 -0
- package/lib-es/api/index.d.ts +2 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +2 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/sdk.d.ts +29 -0
- package/lib-es/api/sdk.d.ts.map +1 -0
- package/lib-es/api/sdk.js +264 -0
- package/lib-es/api/sdk.js.map +1 -0
- package/lib-es/bridge/js.d.ts +11 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +53 -0
- package/lib-es/bridge/js.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 +139 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +9 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +12 -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 +93 -0
- package/lib-es/buildOptimisticOperation.js.map +1 -0
- package/lib-es/buildOptimisticOperation.test.d.ts +2 -0
- package/lib-es/buildOptimisticOperation.test.d.ts.map +1 -0
- package/lib-es/buildOptimisticOperation.test.js +73 -0
- package/lib-es/buildOptimisticOperation.test.js.map +1 -0
- package/lib-es/buildSubAccounts.d.ts +11 -0
- package/lib-es/buildSubAccounts.d.ts.map +1 -0
- package/lib-es/buildSubAccounts.js +112 -0
- package/lib-es/buildSubAccounts.js.map +1 -0
- package/lib-es/buildTransaction.d.ts +19 -0
- package/lib-es/buildTransaction.d.ts.map +1 -0
- package/lib-es/buildTransaction.js +44 -0
- package/lib-es/buildTransaction.js.map +1 -0
- package/lib-es/buildTransaction.unit.test.d.ts +2 -0
- package/lib-es/buildTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/buildTransaction.unit.test.js +42 -0
- package/lib-es/buildTransaction.unit.test.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +16 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +29 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/config.d.ts +14 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +11 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/constants.d.ts +21 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +21 -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 +19 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/datasets/multiversx1.d.ts +3 -0
- package/lib-es/datasets/multiversx1.d.ts.map +1 -0
- package/lib-es/datasets/multiversx1.js +18 -0
- package/lib-es/datasets/multiversx1.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +10 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +55 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/encode.d.ts +11 -0
- package/lib-es/encode.d.ts.map +1 -0
- package/lib-es/encode.js +35 -0
- package/lib-es/encode.js.map +1 -0
- package/lib-es/errors.d.ts +16 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +7 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +10 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +31 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/formatters.d.ts +11 -0
- package/lib-es/formatters.d.ts.map +1 -0
- package/lib-es/formatters.js +60 -0
- package/lib-es/formatters.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +5 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +100 -0
- package/lib-es/getTransactionStatus.js.map +1 -0
- package/lib-es/helpers/denominate.d.ts +9 -0
- package/lib-es/helpers/denominate.d.ts.map +1 -0
- package/lib-es/helpers/denominate.js +71 -0
- package/lib-es/helpers/denominate.js.map +1 -0
- package/lib-es/helpers/handleTransactionStatus.d.ts +7 -0
- package/lib-es/helpers/handleTransactionStatus.d.ts.map +1 -0
- package/lib-es/helpers/handleTransactionStatus.js +14 -0
- package/lib-es/helpers/handleTransactionStatus.js.map +1 -0
- package/lib-es/helpers/hasMinimumDelegableBalance.d.ts +3 -0
- package/lib-es/helpers/hasMinimumDelegableBalance.d.ts.map +1 -0
- package/lib-es/helpers/hasMinimumDelegableBalance.js +3 -0
- package/lib-es/helpers/hasMinimumDelegableBalance.js.map +1 -0
- package/lib-es/helpers/randomizeProviders.d.ts +7 -0
- package/lib-es/helpers/randomizeProviders.d.ts.map +1 -0
- package/lib-es/helpers/randomizeProviders.js +8 -0
- package/lib-es/helpers/randomizeProviders.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 +12 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/logic.d.ts +15 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +65 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/preload.d.ts +11 -0
- package/lib-es/preload.d.ts.map +1 -0
- package/lib-es/preload.js +85 -0
- package/lib-es/preload.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 +68 -0
- package/lib-es/prepareTransaction.js.map +1 -0
- package/lib-es/reconciliation.d.ts +3 -0
- package/lib-es/reconciliation.d.ts.map +1 -0
- package/lib-es/reconciliation.js +52 -0
- package/lib-es/reconciliation.js.map +1 -0
- package/lib-es/serialization.d.ts +9 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +53 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signOperation.d.ts +10 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +61 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +16 -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 +281 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +16 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +244 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronisation.d.ts +5 -0
- package/lib-es/synchronisation.d.ts.map +1 -0
- package/lib-es/synchronisation.js +62 -0
- package/lib-es/synchronisation.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 +56 -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 +12 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/utils/binary.utils.d.ts +5 -0
- package/lib-es/utils/binary.utils.d.ts.map +1 -0
- package/lib-es/utils/binary.utils.js +12 -0
- package/lib-es/utils/binary.utils.js.map +1 -0
- package/package.json +86 -0
- package/src/__snapshots__/bridge.integration.test.ts.snap +181 -0
- package/src/api/apiCalls.ts +243 -0
- package/src/api/dtos/multiversx-account.ts +20 -0
- package/src/api/index.ts +13 -0
- package/src/api/sdk.ts +368 -0
- package/src/bridge/js.ts +77 -0
- package/src/bridge.integration.test.ts +147 -0
- package/src/broadcast.ts +16 -0
- package/src/buildOptimisticOperation.test.ts +88 -0
- package/src/buildOptimisticOperation.ts +120 -0
- package/src/buildSubAccounts.ts +153 -0
- package/src/buildTransaction.ts +67 -0
- package/src/buildTransaction.unit.test.ts +49 -0
- package/src/cli-transaction.ts +41 -0
- package/src/config.ts +26 -0
- package/src/constants.ts +24 -0
- package/src/createTransaction.ts +21 -0
- package/src/datasets/multiversx1.ts +19 -0
- package/src/deviceTransactionConfig.ts +74 -0
- package/src/encode.ts +46 -0
- package/src/errors.ts +19 -0
- package/src/estimateMaxSpendable.ts +43 -0
- package/src/formatters.ts +76 -0
- package/src/getTransactionStatus.ts +151 -0
- package/src/helpers/denominate.ts +95 -0
- package/src/helpers/handleTransactionStatus.ts +26 -0
- package/src/helpers/hasMinimumDelegableBalance.ts +6 -0
- package/src/helpers/randomizeProviders.ts +20 -0
- package/src/hw-getAddress.ts +19 -0
- package/src/logic.ts +83 -0
- package/src/preload.ts +95 -0
- package/src/prepareTransaction.ts +78 -0
- package/src/reconciliation.ts +64 -0
- package/src/serialization.ts +72 -0
- package/src/signOperation.ts +99 -0
- package/src/signer.ts +21 -0
- package/src/specs.ts +387 -0
- package/src/speculos-deviceActions.ts +269 -0
- package/src/synchronisation.ts +74 -0
- package/src/transaction.ts +76 -0
- package/src/types.ts +235 -0
- package/src/utils/binary.utils.ts +13 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,47 @@
|
|
|
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 buildTransaction_1 = require("./buildTransaction");
|
|
8
|
+
describe("doBuildTransactionToSign", () => {
|
|
9
|
+
it("should serialize transaction without data field", async () => {
|
|
10
|
+
const serializedTransaction = await (0, buildTransaction_1.doBuildTransactionToSign)({
|
|
11
|
+
transaction: {
|
|
12
|
+
family: "multiversx",
|
|
13
|
+
mode: "send",
|
|
14
|
+
fees: null,
|
|
15
|
+
amount: new bignumber_js_1.default("1"),
|
|
16
|
+
recipient: "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
|
|
17
|
+
gasLimit: 50000000,
|
|
18
|
+
},
|
|
19
|
+
sender: "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx",
|
|
20
|
+
nonce: 1,
|
|
21
|
+
value: "0",
|
|
22
|
+
minGasLimit: 50000000,
|
|
23
|
+
chainID: "1",
|
|
24
|
+
});
|
|
25
|
+
expect(serializedTransaction).toEqual(`{"nonce":1,"value":"0","receiver":"erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th","sender":"erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx","gasPrice":1000000000,"gasLimit":50000000,"chainID":"1","version":2,"options":1}`);
|
|
26
|
+
});
|
|
27
|
+
it("should serialize transaction with data field", async () => {
|
|
28
|
+
const serializedTransaction = await (0, buildTransaction_1.doBuildTransactionToSign)({
|
|
29
|
+
transaction: {
|
|
30
|
+
family: "multiversx",
|
|
31
|
+
mode: "send",
|
|
32
|
+
fees: null,
|
|
33
|
+
amount: new bignumber_js_1.default("1"),
|
|
34
|
+
recipient: "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
|
|
35
|
+
data: Buffer.from("ESDTTransfer@55544b2d326638306539@0de0b6b3a7640000").toString("base64"),
|
|
36
|
+
gasLimit: 50000000,
|
|
37
|
+
},
|
|
38
|
+
sender: "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx",
|
|
39
|
+
nonce: 1,
|
|
40
|
+
value: "0",
|
|
41
|
+
minGasLimit: 50000000,
|
|
42
|
+
chainID: "1",
|
|
43
|
+
});
|
|
44
|
+
expect(serializedTransaction).toEqual(`{"nonce":1,"value":"0","receiver":"erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th","sender":"erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx","gasPrice":1000000000,"gasLimit":50000000,"data":"RVNEVFRyYW5zZmVyQDU1NTQ0YjJkMzI2NjM4MzA2NTM5QDBkZTBiNmIzYTc2NDAwMDA=","chainID":"1","version":2,"options":1}`);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=buildTransaction.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTransaction.unit.test.js","sourceRoot":"","sources":["../src/buildTransaction.unit.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AACrC,yDAA8D;AAE9D,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,qBAAqB,GAAG,MAAM,IAAA,2CAAwB,EAAC;YAC3D,WAAW,EAAE;gBACX,MAAM,EAAE,YAAY;gBACpB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,IAAI,sBAAS,CAAC,GAAG,CAAC;gBAC1B,SAAS,EAAE,gEAAgE;gBAC3E,QAAQ,EAAE,QAAQ;aACnB;YACD,MAAM,EAAE,gEAAgE;YACxE,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,GAAG;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CACnC,+PAA+P,CAChQ,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,qBAAqB,GAAG,MAAM,IAAA,2CAAwB,EAAC;YAC3D,WAAW,EAAE;gBACX,MAAM,EAAE,YAAY;gBACpB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,IAAI,sBAAS,CAAC,GAAG,CAAC;gBAC1B,SAAS,EAAE,gEAAgE;gBAC3E,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC1F,QAAQ,EAAE,QAAQ;aACnB;YACD,MAAM,EAAE,gEAAgE;YACxE,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,GAAG;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CACnC,6UAA6U,CAC9U,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction } from "./types";
|
|
3
|
+
declare function inferTransactions(transactions: Array<{
|
|
4
|
+
account: AccountLike;
|
|
5
|
+
transaction: Transaction;
|
|
6
|
+
}>, _opts: Record<string, any>): Transaction[];
|
|
7
|
+
export default function makeCliTools(): {
|
|
8
|
+
options: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
desc: string;
|
|
12
|
+
}[];
|
|
13
|
+
inferTransactions: typeof inferTransactions;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=cli-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-transaction.d.ts","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,SAAS,CAAC;AAS9D,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,EACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,WAAW,EAAE,CAef;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;;;;;;;EAKnC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 invariant_1 = __importDefault(require("invariant"));
|
|
7
|
+
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
8
|
+
const options = [
|
|
9
|
+
{
|
|
10
|
+
name: "mode",
|
|
11
|
+
type: String,
|
|
12
|
+
desc: "mode of transaction: send, delegate, unDelegate, claimRewards",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
function inferTransactions(transactions, _opts) {
|
|
16
|
+
return (0, flatMap_1.default)(transactions, ({ transaction, account }) => {
|
|
17
|
+
(0, invariant_1.default)(transaction.family === "multiversx", "multiversx family");
|
|
18
|
+
if (account.type === "Account") {
|
|
19
|
+
(0, invariant_1.default)(account.multiversxResources, "unactivated account");
|
|
20
|
+
}
|
|
21
|
+
transaction.family = "multiversx";
|
|
22
|
+
return {
|
|
23
|
+
...transaction,
|
|
24
|
+
mode: _opts.mode || "send",
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function makeCliTools() {
|
|
29
|
+
return {
|
|
30
|
+
options,
|
|
31
|
+
inferTransactions,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.default = makeCliTools;
|
|
35
|
+
//# sourceMappingURL=cli-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-transaction.js","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":";;;;;AACA,0DAAkC;AAClC,6DAAqC;AAErC,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,+DAA+D;KACtE;CACF,CAAC;AAEF,SAAS,iBAAiB,CACxB,YAGE,EACF,KAA0B;IAE1B,OAAO,IAAA,iBAAO,EAAC,YAAY,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QACxD,IAAA,mBAAS,EAAC,WAAW,CAAC,MAAM,KAAK,YAAY,EAAE,mBAAmB,CAAC,CAAC;QAEpE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAA,mBAAS,EAAE,OAA6B,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;QACvF,CAAC;QAED,WAAW,CAAC,MAAM,GAAG,YAAY,CAAC;QAElC,OAAO;YACL,GAAG,WAAW;YACd,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAwB,YAAY;IAClC,OAAO;QACL,OAAO;QACP,iBAAiB;KAClB,CAAC;AACJ,CAAC;AALD,+BAKC"}
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
|
2
|
+
export type MultiversXCoinConfig = () => CurrencyConfig & {
|
|
3
|
+
config_currency_multiversx: {
|
|
4
|
+
type: "object";
|
|
5
|
+
default: {
|
|
6
|
+
status: {
|
|
7
|
+
type: "active";
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const setCoinConfig: (config: MultiversXCoinConfig) => void;
|
|
13
|
+
export declare const getCoinConfig: () => ReturnType<MultiversXCoinConfig>;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,MAAM,oBAAoB,GAAG,MAAM,cAAc,GAAG;IACxD,0BAA0B,EAAE;QAC1B,IAAI,EAAE,QAAQ,CAAC;QACf,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ,CAAC;aAChB,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC;AAIF,eAAO,MAAM,aAAa,WAAY,oBAAoB,KAAG,IAE5D,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,WAAW,oBAAoB,CAM/D,CAAC"}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCoinConfig = exports.setCoinConfig = void 0;
|
|
4
|
+
let coinConfig;
|
|
5
|
+
const setCoinConfig = (config) => {
|
|
6
|
+
coinConfig = config;
|
|
7
|
+
};
|
|
8
|
+
exports.setCoinConfig = setCoinConfig;
|
|
9
|
+
const getCoinConfig = () => {
|
|
10
|
+
if (!coinConfig?.()) {
|
|
11
|
+
throw new Error("MultiversX module config not set");
|
|
12
|
+
}
|
|
13
|
+
return coinConfig();
|
|
14
|
+
};
|
|
15
|
+
exports.getCoinConfig = getCoinConfig;
|
|
16
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAaA,IAAI,UAA4C,CAAC;AAE1C,MAAM,aAAa,GAAG,CAAC,MAA4B,EAAQ,EAAE;IAClE,UAAU,GAAG,MAAM,CAAC;AACtB,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEK,MAAM,aAAa,GAAG,GAAqC,EAAE;IAClE,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
export declare const TRANSACTION_OPTIONS_TX_HASH_SIGN = 1;
|
|
3
|
+
export declare const TRANSACTION_VERSION_DEFAULT = 2;
|
|
4
|
+
export declare const METACHAIN_SHARD = 4294967295;
|
|
5
|
+
export declare const MAX_PAGINATION_SIZE = 50;
|
|
6
|
+
export declare const GAS: {
|
|
7
|
+
ESDT_TRANSFER: number;
|
|
8
|
+
DELEGATE: number;
|
|
9
|
+
CLAIM: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const GAS_PRICE = 1000000000;
|
|
12
|
+
export declare const MIN_GAS_LIMIT = 50000;
|
|
13
|
+
export declare const GAS_PER_DATA_BYTE = 1500;
|
|
14
|
+
export declare const GAS_PRICE_MODIFIER = 0.01;
|
|
15
|
+
export declare const CHAIN_ID = "1";
|
|
16
|
+
export declare const MIN_DELEGATION_AMOUNT: BigNumber;
|
|
17
|
+
export declare const DECIMALS_LIMIT = 18;
|
|
18
|
+
export declare const MULTIVERSX_EXPLORER_URL = "https://explorer.multiversx.com";
|
|
19
|
+
export declare const MULTIVERSX_STAKING_POOL = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l";
|
|
20
|
+
export declare const MULTIVERSX_LEDGER_VALIDATOR_ADDRESS = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqppllllls9ftvxy";
|
|
21
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAO,MAAM,gCAAgC,IAAS,CAAC;AACvD,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,GAAG;;;;CAIf,CAAC;AACF,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,QAAQ,MAAM,CAAC;AAC5B,eAAO,MAAM,qBAAqB,EAAE,SAAgD,CAAC;AACrF,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,uBAAuB,oCAAoC,CAAC;AACzE,eAAO,MAAM,uBAAuB,mEAC8B,CAAC;AACnE,eAAO,MAAM,mCAAmC,mEACkB,CAAC"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS = exports.MULTIVERSX_STAKING_POOL = exports.MULTIVERSX_EXPLORER_URL = exports.DECIMALS_LIMIT = exports.MIN_DELEGATION_AMOUNT = exports.CHAIN_ID = exports.GAS_PRICE_MODIFIER = exports.GAS_PER_DATA_BYTE = exports.MIN_GAS_LIMIT = exports.GAS_PRICE = exports.GAS = exports.MAX_PAGINATION_SIZE = exports.METACHAIN_SHARD = exports.TRANSACTION_VERSION_DEFAULT = exports.TRANSACTION_OPTIONS_TX_HASH_SIGN = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
exports.TRANSACTION_OPTIONS_TX_HASH_SIGN = 0b0001;
|
|
9
|
+
exports.TRANSACTION_VERSION_DEFAULT = 2;
|
|
10
|
+
exports.METACHAIN_SHARD = 4294967295;
|
|
11
|
+
exports.MAX_PAGINATION_SIZE = 50;
|
|
12
|
+
exports.GAS = {
|
|
13
|
+
ESDT_TRANSFER: 500000,
|
|
14
|
+
DELEGATE: 75000000,
|
|
15
|
+
CLAIM: 6000000,
|
|
16
|
+
};
|
|
17
|
+
exports.GAS_PRICE = 1000000000;
|
|
18
|
+
exports.MIN_GAS_LIMIT = 50000;
|
|
19
|
+
exports.GAS_PER_DATA_BYTE = 1500;
|
|
20
|
+
exports.GAS_PRICE_MODIFIER = 0.01;
|
|
21
|
+
exports.CHAIN_ID = "1";
|
|
22
|
+
exports.MIN_DELEGATION_AMOUNT = new bignumber_js_1.default("1000000000000000000");
|
|
23
|
+
exports.DECIMALS_LIMIT = 18;
|
|
24
|
+
exports.MULTIVERSX_EXPLORER_URL = "https://explorer.multiversx.com";
|
|
25
|
+
exports.MULTIVERSX_STAKING_POOL = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l";
|
|
26
|
+
exports.MULTIVERSX_LEDGER_VALIDATOR_ADDRESS = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqppllllls9ftvxy";
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAExB,QAAA,gCAAgC,GAAG,MAAM,CAAC;AAC1C,QAAA,2BAA2B,GAAG,CAAC,CAAC;AAChC,QAAA,eAAe,GAAG,UAAU,CAAC;AAC7B,QAAA,mBAAmB,GAAG,EAAE,CAAC;AACzB,QAAA,GAAG,GAAG;IACjB,aAAa,EAAE,MAAM;IACrB,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,OAAO;CACf,CAAC;AACW,QAAA,SAAS,GAAG,UAAU,CAAC;AACvB,QAAA,aAAa,GAAG,KAAK,CAAC;AACtB,QAAA,iBAAiB,GAAG,IAAI,CAAC;AACzB,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,QAAQ,GAAG,GAAG,CAAC;AACf,QAAA,qBAAqB,GAAc,IAAI,sBAAS,CAAC,qBAAqB,CAAC,CAAC;AACxE,QAAA,cAAc,GAAG,EAAE,CAAC;AAEpB,QAAA,uBAAuB,GAAG,iCAAiC,CAAC;AAC5D,QAAA,uBAAuB,GAClC,gEAAgE,CAAC;AACtD,QAAA,mCAAmC,GAC9C,gEAAgE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import { Transaction } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Create an empty t
|
|
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;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAU7E,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const constants_1 = require("./constants");
|
|
9
|
+
/**
|
|
10
|
+
* Create an empty t
|
|
11
|
+
*
|
|
12
|
+
* @returns {Transaction}
|
|
13
|
+
*/
|
|
14
|
+
const createTransaction = () => {
|
|
15
|
+
return {
|
|
16
|
+
family: "multiversx",
|
|
17
|
+
mode: "send",
|
|
18
|
+
amount: new bignumber_js_1.default(0),
|
|
19
|
+
recipient: "",
|
|
20
|
+
useAllAmount: false,
|
|
21
|
+
fees: new bignumber_js_1.default(50000),
|
|
22
|
+
gasLimit: constants_1.MIN_GAS_LIMIT,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.createTransaction = createTransaction;
|
|
26
|
+
//# sourceMappingURL=createTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransaction.js","sourceRoot":"","sources":["../src/createTransaction.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAErC,2CAA4C;AAG5C;;;;GAIG;AACI,MAAM,iBAAiB,GAAoD,GAAG,EAAE;IACrF,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;QACxB,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,IAAI,sBAAS,CAAC,KAAK,CAAC;QAC1B,QAAQ,EAAE,yBAAa;KACxB,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversx1.d.ts","sourceRoot":"","sources":["../../src/datasets/multiversx1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,eAAO,MAAM,WAAW,EAAE,UAgBzB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.multiversx1 = void 0;
|
|
4
|
+
exports.multiversx1 = {
|
|
5
|
+
id: "js:2:multiversx:erd1rnq7m8kdrpyfany4fweqtydsk4pgx0l6dtl6tvcad5wesagruxts62e9rk:",
|
|
6
|
+
seedIdentifier: "erd1rnq7m8kdrpyfany4fweqtydsk4pgx0l6dtl6tvcad5wesagruxts62e9rk",
|
|
7
|
+
name: "MultiversX 1",
|
|
8
|
+
derivationMode: "",
|
|
9
|
+
index: 0,
|
|
10
|
+
freshAddress: "erd1rnq7m8kdrpyfany4fweqtydsk4pgx0l6dtl6tvcad5wesagruxts62e9rk",
|
|
11
|
+
freshAddressPath: "44'/508'/0'/0'/0'",
|
|
12
|
+
pendingOperations: [],
|
|
13
|
+
operations: [],
|
|
14
|
+
// currencyId: "multiversx",
|
|
15
|
+
currencyId: "elrond",
|
|
16
|
+
balance: "",
|
|
17
|
+
blockHeight: 0,
|
|
18
|
+
lastSyncDate: "",
|
|
19
|
+
xpub: "",
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=multiversx1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversx1.js","sourceRoot":"","sources":["../../src/datasets/multiversx1.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAe;IACrC,EAAE,EAAE,iFAAiF;IACrF,cAAc,EAAE,gEAAgE;IAChF,IAAI,EAAE,cAAc;IACpB,cAAc,EAAE,EAAE;IAClB,KAAK,EAAE,CAAC;IACR,YAAY,EAAE,gEAAgE;IAC9E,gBAAgB,EAAE,mBAAmB;IACrC,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE;IACd,4BAA4B;IAC5B,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,EAAE;IAChB,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
|
|
2
|
+
import type { TransactionStatus, Transaction } from "./types";
|
|
3
|
+
import { Account } from "@ledgerhq/types-live";
|
|
4
|
+
declare function getDeviceTransactionConfig({ account, transaction, status: { estimatedFees }, }: {
|
|
5
|
+
account: Account;
|
|
6
|
+
transaction: Transaction;
|
|
7
|
+
status: TransactionStatus;
|
|
8
|
+
}): Array<DeviceTransactionField>;
|
|
9
|
+
export default getDeviceTransactionConfig;
|
|
10
|
+
//# sourceMappingURL=deviceTransactionConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.d.ts","sourceRoot":"","sources":["../src/deviceTransactionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,IAAI,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAC1H,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI9D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,iBAAS,0BAA0B,CAAC,EAClC,OAAO,EACP,WAAW,EACX,MAAM,EAAE,EAAE,aAAa,EAAE,GAC1B,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAuDhC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 currencies_1 = require("@ledgerhq/coin-framework/currencies");
|
|
8
|
+
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
9
|
+
const logic_1 = require("./logic");
|
|
10
|
+
function getDeviceTransactionConfig({ account, transaction, status: { estimatedFees }, }) {
|
|
11
|
+
const fields = [];
|
|
12
|
+
const { subAccountId } = transaction;
|
|
13
|
+
const isEsdtTransfer = subAccountId !== undefined && subAccountId !== null;
|
|
14
|
+
if (isEsdtTransfer) {
|
|
15
|
+
const { token } = (0, account_1.decodeTokenAccountId)(subAccountId);
|
|
16
|
+
if (token) {
|
|
17
|
+
fields.push({
|
|
18
|
+
type: "text",
|
|
19
|
+
label: "Token",
|
|
20
|
+
value: token.name,
|
|
21
|
+
});
|
|
22
|
+
fields.push({
|
|
23
|
+
type: "amount",
|
|
24
|
+
label: "Value",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
fields.push({
|
|
29
|
+
type: "address",
|
|
30
|
+
label: "Receiver",
|
|
31
|
+
address: transaction.recipient,
|
|
32
|
+
});
|
|
33
|
+
if (!isEsdtTransfer) {
|
|
34
|
+
if (!(0, logic_1.isAmountSpentFromBalance)(transaction.mode)) {
|
|
35
|
+
fields.push({
|
|
36
|
+
type: "text",
|
|
37
|
+
label: "Amount",
|
|
38
|
+
value: (0, currencies_1.formatCurrencyUnit)((0, account_1.getAccountCurrency)(account).units[0], new bignumber_js_1.default(0), {
|
|
39
|
+
showCode: true,
|
|
40
|
+
disableRounding: true,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
fields.push({
|
|
46
|
+
type: "amount",
|
|
47
|
+
label: "Amount",
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!estimatedFees.isZero()) {
|
|
52
|
+
fields.push({
|
|
53
|
+
type: "fees",
|
|
54
|
+
label: "Fee",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return fields;
|
|
58
|
+
}
|
|
59
|
+
exports.default = getDeviceTransactionConfig;
|
|
60
|
+
//# sourceMappingURL=deviceTransactionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.js","sourceRoot":"","sources":["../src/deviceTransactionConfig.ts"],"names":[],"mappings":";;;;;AAEA,gEAAqC;AACrC,oEAAyE;AACzE,8DAA4F;AAE5F,mCAAmD;AAEnD,SAAS,0BAA0B,CAAC,EAClC,OAAO,EACP,WAAW,EACX,MAAM,EAAE,EAAE,aAAa,EAAE,GAK1B;IACC,MAAM,MAAM,GAAkC,EAAE,CAAC;IAEjD,MAAM,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC;IACrC,MAAM,cAAc,GAAG,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,IAAI,CAAC;IAE3E,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,8BAAoB,EAAC,YAAY,CAAC,CAAC;QAErD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,OAAO;gBACd,KAAK,EAAE,KAAK,CAAC,IAAI;aAClB,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,OAAO;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC;QACV,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,WAAW,CAAC,SAAS;KAC/B,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,IAAI,CAAC,IAAA,gCAAwB,EAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,IAAA,+BAAkB,EAAC,IAAA,4BAAkB,EAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC,EAAE;oBAChF,QAAQ,EAAE,IAAI;oBACd,eAAe,EAAE,IAAI;iBACtB,CAAC;aACH,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,QAAQ;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kBAAe,0BAA0B,CAAC"}
|
package/lib/encode.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SubAccount } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction } from "./types";
|
|
3
|
+
export declare class MultiversXEncodeTransaction {
|
|
4
|
+
static ESDTTransfer(t: Transaction, ta: SubAccount): string;
|
|
5
|
+
static delegate(): string;
|
|
6
|
+
static claimRewards(): string;
|
|
7
|
+
static withdraw(): string;
|
|
8
|
+
static reDelegateRewards(): string;
|
|
9
|
+
static unDelegate(t: Transaction): string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,qBAAa,2BAA2B;IACtC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,GAAG,MAAM;IAa3D,MAAM,CAAC,QAAQ,IAAI,MAAM;IAIzB,MAAM,CAAC,YAAY,IAAI,MAAM;IAI7B,MAAM,CAAC,QAAQ,IAAI,MAAM;IAIzB,MAAM,CAAC,iBAAiB,IAAI,MAAM;IAIlC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM;CAU1C"}
|
package/lib/encode.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultiversXEncodeTransaction = void 0;
|
|
4
|
+
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
5
|
+
const logic_1 = require("./logic");
|
|
6
|
+
class MultiversXEncodeTransaction {
|
|
7
|
+
static ESDTTransfer(t, ta) {
|
|
8
|
+
const { token } = (0, account_1.decodeTokenAccountId)(ta.id);
|
|
9
|
+
const tokenIdentifierHex = token && (0, logic_1.extractTokenId)(token.id);
|
|
10
|
+
let amountHex = t.useAllAmount ? ta.balance.toString(16) : t.amount.toString(16);
|
|
11
|
+
//hex amount length must be even so protocol would treat it as an ESDT transfer
|
|
12
|
+
if (amountHex.length % 2 !== 0) {
|
|
13
|
+
amountHex = "0" + amountHex;
|
|
14
|
+
}
|
|
15
|
+
return Buffer.from(`ESDTTransfer@${tokenIdentifierHex}@${amountHex}`).toString("base64");
|
|
16
|
+
}
|
|
17
|
+
static delegate() {
|
|
18
|
+
return Buffer.from(`delegate`).toString("base64");
|
|
19
|
+
}
|
|
20
|
+
static claimRewards() {
|
|
21
|
+
return Buffer.from(`claimRewards`).toString("base64");
|
|
22
|
+
}
|
|
23
|
+
static withdraw() {
|
|
24
|
+
return Buffer.from(`withdraw`).toString("base64");
|
|
25
|
+
}
|
|
26
|
+
static reDelegateRewards() {
|
|
27
|
+
return Buffer.from(`reDelegateRewards`).toString("base64");
|
|
28
|
+
}
|
|
29
|
+
static unDelegate(t) {
|
|
30
|
+
let amountHex = t.amount.toString(16);
|
|
31
|
+
//hex amount length must be even
|
|
32
|
+
if (amountHex.length % 2 !== 0) {
|
|
33
|
+
amountHex = "0" + amountHex;
|
|
34
|
+
}
|
|
35
|
+
return Buffer.from(`unDelegate@${amountHex}`).toString("base64");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MultiversXEncodeTransaction = MultiversXEncodeTransaction;
|
|
39
|
+
//# sourceMappingURL=encode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":";;;AACA,8DAAwE;AAExE,mCAAyC;AAEzC,MAAa,2BAA2B;IACtC,MAAM,CAAC,YAAY,CAAC,CAAc,EAAE,EAAc;QAChD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,8BAAoB,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,kBAAkB,GAAG,KAAK,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7D,IAAI,SAAS,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAEjF,+EAA+E;QAC/E,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,SAAS,GAAG,GAAG,GAAG,SAAS,CAAC;QAC9B,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,gBAAgB,kBAAkB,IAAI,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,CAAC,QAAQ;QACb,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,QAAQ;QACb,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,iBAAiB;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,CAAc;QAC9B,IAAI,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAEtC,gCAAgC;QAChC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,SAAS,GAAG,GAAG,GAAG,SAAS,CAAC;QAC9B,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;CACF;AAxCD,kEAwCC"}
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const MultiversXDecimalsLimitReached: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const MultiversXMinDelegatedAmountError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const MultiversXMinUndelegatedAmountError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const MultiversXDelegationBelowMinimumError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const NotEnoughEGLDForFees: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B;;EAE1C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;EAE7C,CAAC;AAEF,eAAO,MAAM,mCAAmC;;EAE/C,CAAC;AAEF,eAAO,MAAM,qCAAqC;;EAEjD,CAAC;AAEF,eAAO,MAAM,oBAAoB;;EAAiD,CAAC"}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotEnoughEGLDForFees = exports.MultiversXDelegationBelowMinimumError = exports.MultiversXMinUndelegatedAmountError = exports.MultiversXMinDelegatedAmountError = exports.MultiversXDecimalsLimitReached = void 0;
|
|
4
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
5
|
+
exports.MultiversXDecimalsLimitReached = (0, errors_1.createCustomErrorClass)("MultiversXDecimalsLimitReached");
|
|
6
|
+
exports.MultiversXMinDelegatedAmountError = (0, errors_1.createCustomErrorClass)("MultiversXMinDelegatedAmountError");
|
|
7
|
+
exports.MultiversXMinUndelegatedAmountError = (0, errors_1.createCustomErrorClass)("MultiversXMinUndelegatedAmountError");
|
|
8
|
+
exports.MultiversXDelegationBelowMinimumError = (0, errors_1.createCustomErrorClass)("MultiversXDelegationBelowMinimumError");
|
|
9
|
+
exports.NotEnoughEGLDForFees = (0, errors_1.createCustomErrorClass)("NotEnoughEGLDForFees");
|
|
10
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAE7C,QAAA,8BAA8B,GAAG,IAAA,+BAAsB,EAClE,gCAAgC,CACjC,CAAC;AAEW,QAAA,iCAAiC,GAAG,IAAA,+BAAsB,EACrE,mCAAmC,CACpC,CAAC;AAEW,QAAA,mCAAmC,GAAG,IAAA,+BAAsB,EACvE,qCAAqC,CACtC,CAAC;AAEW,QAAA,qCAAqC,GAAG,IAAA,+BAAsB,EACzE,uCAAuC,CACxC,CAAC;AAEW,QAAA,oBAAoB,GAAG,IAAA,+BAAsB,EAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import type { 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>["estimateMaxSpendable"];
|
|
9
|
+
export default estimateMaxSpendable;
|
|
10
|
+
//# sourceMappingURL=estimateMaxSpendable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.d.ts","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,sBAAsB,CA4BnF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateMaxSpendable = void 0;
|
|
4
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
5
|
+
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
6
|
+
const api_1 = require("./api");
|
|
7
|
+
const createTransaction_1 = require("./createTransaction");
|
|
8
|
+
/**
|
|
9
|
+
* Returns the maximum possible amount for transaction
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} param - the account, parentAccount and transaction
|
|
12
|
+
*/
|
|
13
|
+
const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => {
|
|
14
|
+
const mainAccount = (0, account_1.getMainAccount)(account, parentAccount);
|
|
15
|
+
const tx = {
|
|
16
|
+
...(0, createTransaction_1.createTransaction)(account),
|
|
17
|
+
subAccountId: account.type === "Account" ? null : account.id,
|
|
18
|
+
...transaction,
|
|
19
|
+
useAllAmount: true,
|
|
20
|
+
};
|
|
21
|
+
const tokenAccount = tx.subAccountId
|
|
22
|
+
? (0, account_1.findSubAccountById)(mainAccount, tx.subAccountId)
|
|
23
|
+
: undefined;
|
|
24
|
+
if (tokenAccount) {
|
|
25
|
+
return tokenAccount.balance;
|
|
26
|
+
}
|
|
27
|
+
const fees = await (0, api_1.getFees)(tx);
|
|
28
|
+
if (fees.gt(mainAccount.spendableBalance)) {
|
|
29
|
+
return new bignumber_js_1.BigNumber(0);
|
|
30
|
+
}
|
|
31
|
+
return mainAccount.spendableBalance.minus(fees);
|
|
32
|
+
};
|
|
33
|
+
exports.estimateMaxSpendable = estimateMaxSpendable;
|
|
34
|
+
exports.default = exports.estimateMaxSpendable;
|
|
35
|
+
//# sourceMappingURL=estimateMaxSpendable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC,8DAAsF;AAEtF,+BAAgC;AAChC,2DAAwD;AAExD;;;;GAIG;AACI,MAAM,oBAAoB,GAAuD,KAAK,EAAE,EAC7F,OAAO,EACP,aAAa,EACb,WAAW,GACZ,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,IAAA,wBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,EAAE,GAAgB;QACtB,GAAG,IAAA,qCAAiB,EAAC,OAAO,CAAC;QAC7B,YAAY,EAAE,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;QAC5D,GAAG,WAAW;QACd,YAAY,EAAE,IAAI;KACnB,CAAC;IAEF,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY;QAClC,CAAC,CAAC,IAAA,4BAAkB,EAAC,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC;QAClD,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,IAAA,aAAO,EAAC,EAAE,CAAC,CAAC;IAE/B,IAAI,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,wBAAS,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC,CAAC;AA5BW,QAAA,oBAAoB,wBA4B/B;AAEF,kBAAe,4BAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Operation } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
import type { MultiversXAccount } from "./types";
|
|
4
|
+
declare function formatAccountSpecifics(account: MultiversXAccount): string;
|
|
5
|
+
declare function formatOperationSpecifics(op: Operation, unit: Unit | null | undefined): string;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
formatAccountSpecifics: typeof formatAccountSpecifics;
|
|
8
|
+
formatOperationSpecifics: typeof formatOperationSpecifics;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,SAAS,CAAC;AAGtE,iBAAS,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CA+ClE;AAED,iBAAS,wBAAwB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAatF;;;;;AAED,wBAGE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 invariant_1 = __importDefault(require("invariant"));
|
|
7
|
+
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
8
|
+
const currencies_1 = require("@ledgerhq/coin-framework/currencies");
|
|
9
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
10
|
+
function formatAccountSpecifics(account) {
|
|
11
|
+
const { multiversxResources } = account;
|
|
12
|
+
(0, invariant_1.default)(multiversxResources, "multiversx account expected");
|
|
13
|
+
const unit = (0, account_1.getAccountCurrency)(account).units[0];
|
|
14
|
+
const formatConfig = {
|
|
15
|
+
disableRounding: true,
|
|
16
|
+
alwaysShowSign: false,
|
|
17
|
+
showCode: true,
|
|
18
|
+
};
|
|
19
|
+
let str = " ";
|
|
20
|
+
if (account.spendableBalance) {
|
|
21
|
+
str += (0, currencies_1.formatCurrencyUnit)(unit, account.spendableBalance, formatConfig) + " spendable. ";
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
str += " 0 spendable.";
|
|
25
|
+
}
|
|
26
|
+
if (multiversxResources && multiversxResources.nonce) {
|
|
27
|
+
str += "\n nonce : " + multiversxResources.nonce;
|
|
28
|
+
}
|
|
29
|
+
if (multiversxResources && multiversxResources.delegations) {
|
|
30
|
+
let delegated = new bignumber_js_1.default(0);
|
|
31
|
+
let undelegating = new bignumber_js_1.default(0);
|
|
32
|
+
let rewards = new bignumber_js_1.default(0);
|
|
33
|
+
for (const delegation of multiversxResources.delegations) {
|
|
34
|
+
delegated = delegated.plus(delegation.userActiveStake);
|
|
35
|
+
undelegating = delegation.userUndelegatedList.reduce((sum, undelegation) => sum.plus(undelegation.amount), undelegating);
|
|
36
|
+
rewards = rewards.plus(delegation.claimableRewards);
|
|
37
|
+
}
|
|
38
|
+
str +=
|
|
39
|
+
delegated && delegated.gt(0)
|
|
40
|
+
? `\n delegated: ${unit ? (0, currencies_1.formatCurrencyUnit)(unit, delegated, formatConfig) : delegated}`
|
|
41
|
+
: undelegating && undelegating.gt(0)
|
|
42
|
+
? `\n undelegating: ${unit ? (0, currencies_1.formatCurrencyUnit)(unit, undelegating, formatConfig) : undelegating}`
|
|
43
|
+
: rewards && rewards.gt(0)
|
|
44
|
+
? `\n rewards: ${unit ? (0, currencies_1.formatCurrencyUnit)(unit, rewards, formatConfig) : rewards}`
|
|
45
|
+
: "";
|
|
46
|
+
}
|
|
47
|
+
return str;
|
|
48
|
+
}
|
|
49
|
+
function formatOperationSpecifics(op, unit) {
|
|
50
|
+
const { amount } = op.extra;
|
|
51
|
+
return amount?.gt && amount.gt(0)
|
|
52
|
+
? " amount: " +
|
|
53
|
+
`${unit
|
|
54
|
+
? (0, currencies_1.formatCurrencyUnit)(unit, new bignumber_js_1.default(amount), {
|
|
55
|
+
showCode: true,
|
|
56
|
+
disableRounding: true,
|
|
57
|
+
}).padEnd(16)
|
|
58
|
+
: amount}`
|
|
59
|
+
: "";
|
|
60
|
+
}
|
|
61
|
+
exports.default = {
|
|
62
|
+
formatAccountSpecifics,
|
|
63
|
+
formatOperationSpecifics,
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,8DAAsE;AACtE,oEAAyE;AAGzE,gEAAqC;AAErC,SAAS,sBAAsB,CAAC,OAA0B;IACxD,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IACxC,IAAA,mBAAS,EAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAA,4BAAkB,EAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG;QACnB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,IAAI,GAAG,GAAG,GAAG,CAAC;IAEd,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,GAAG,IAAI,IAAA,+BAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG,cAAc,CAAC;IAC3F,CAAC;SAAM,CAAC;QACN,GAAG,IAAI,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,mBAAmB,IAAI,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACrD,GAAG,IAAI,cAAc,GAAG,mBAAmB,CAAC,KAAK,CAAC;IACpD,CAAC;IAED,IAAI,mBAAmB,IAAI,mBAAmB,CAAC,WAAW,EAAE,CAAC;QAC3D,IAAI,SAAS,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,YAAY,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,OAAO,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,KAAK,MAAM,UAAU,IAAI,mBAAmB,CAAC,WAAW,EAAE,CAAC;YACzD,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACvD,YAAY,GAAG,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAClD,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EACpD,YAAY,CACb,CAAC;YACF,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QACtD,CAAC;QAED,GAAG;YACD,SAAS,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC1B,CAAC,CAAC,kBAAkB,IAAI,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;gBAC1F,CAAC,CAAC,YAAY,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClC,CAAC,CAAC,qBACE,IAAI,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAChE,EAAE;oBACJ,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;wBACxB,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;wBACpF,CAAC,CAAC,EAAE,CAAC;IACf,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,wBAAwB,CAAC,EAAa,EAAE,IAA6B;IAC5E,MAAM,EAAE,MAAM,EAAE,GAAI,EAA0B,CAAC,KAAK,CAAC;IACrD,OAAO,MAAM,EAAE,EAAE,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,WAAW;YACT,GACE,IAAI;gBACF,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,EAAE,IAAI,sBAAS,CAAC,MAAM,CAAC,EAAE;oBAC9C,QAAQ,EAAE,IAAI;oBACd,eAAe,EAAE,IAAI;iBACtB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;gBACf,CAAC,CAAC,MACN,EAAE;QACN,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,kBAAe;IACb,sBAAsB;IACtB,wBAAwB;CACzB,CAAC"}
|