@ledgerhq/coin-vechain 2.9.1-nightly.1 → 2.10.0-nightly.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/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +16 -4
- package/CHANGELOG.md +14 -0
- package/lib/bridge/broadcast.d.ts.map +1 -1
- package/lib/bridge/broadcast.js +2 -3
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/broadcast.test.d.ts +2 -0
- package/lib/bridge/broadcast.test.d.ts.map +1 -0
- package/lib/bridge/broadcast.test.js +188 -0
- package/lib/bridge/broadcast.test.js.map +1 -0
- package/lib/bridge/buildOptimisticOperatioin.test.d.ts +2 -0
- package/lib/bridge/buildOptimisticOperatioin.test.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperatioin.test.js +286 -0
- package/lib/bridge/buildOptimisticOperatioin.test.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -1
- package/lib/bridge/createTransaction.js +2 -1
- package/lib/bridge/createTransaction.js.map +1 -1
- package/lib/bridge/createTransaction.test.d.ts +2 -0
- package/lib/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib/bridge/createTransaction.test.js +167 -0
- package/lib/bridge/createTransaction.test.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.test.d.ts +2 -0
- package/lib/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.test.js +269 -0
- package/lib/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +3 -1
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.test.js +282 -0
- package/lib/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib/bridge/helpers.test.d.ts +2 -0
- package/lib/bridge/helpers.test.d.ts.map +1 -0
- package/lib/bridge/helpers.test.js +298 -0
- package/lib/bridge/helpers.test.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +10 -3
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.test.js +277 -0
- package/lib/bridge/prepareTransaction.test.js.map +1 -0
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +3 -3
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/signOperation.test.d.ts +2 -0
- package/lib/bridge/signOperation.test.d.ts.map +1 -0
- package/lib/bridge/signOperation.test.js +295 -0
- package/lib/bridge/signOperation.test.js.map +1 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +2 -2
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/bridge/transaction.test.d.ts +2 -0
- package/lib/bridge/transaction.test.d.ts.map +1 -0
- package/lib/bridge/transaction.test.js +353 -0
- package/lib/bridge/transaction.test.js.map +1 -0
- package/lib/common-logic/calculateClauses.d.ts +5 -0
- package/lib/common-logic/calculateClauses.d.ts.map +1 -0
- package/lib/common-logic/{logic.js → calculateClauses.js} +7 -10
- package/lib/common-logic/calculateClauses.js.map +1 -0
- package/lib/common-logic/calculateClauses.test.d.ts +2 -0
- package/lib/common-logic/calculateClauses.test.d.ts.map +1 -0
- package/lib/common-logic/calculateClauses.test.js +156 -0
- package/lib/common-logic/calculateClauses.test.js.map +1 -0
- package/lib/common-logic/calculateGasFees.d.ts +9 -0
- package/lib/common-logic/calculateGasFees.d.ts.map +1 -0
- package/lib/common-logic/calculateGasFees.js +39 -0
- package/lib/common-logic/calculateGasFees.js.map +1 -0
- package/lib/common-logic/calculateGasFees.test.d.ts +2 -0
- package/lib/common-logic/calculateGasFees.test.d.ts.map +1 -0
- package/lib/common-logic/calculateGasFees.test.js +279 -0
- package/lib/common-logic/calculateGasFees.test.js.map +1 -0
- package/lib/common-logic/calculateTransactionInfo.d.ts +10 -0
- package/lib/common-logic/calculateTransactionInfo.d.ts.map +1 -0
- package/lib/common-logic/calculateTransactionInfo.js +81 -0
- package/lib/common-logic/calculateTransactionInfo.js.map +1 -0
- package/lib/common-logic/calculateTransactionInfo.test.d.ts +2 -0
- package/lib/common-logic/calculateTransactionInfo.test.d.ts.map +1 -0
- package/lib/common-logic/calculateTransactionInfo.test.js +314 -0
- package/lib/common-logic/calculateTransactionInfo.test.js.map +1 -0
- package/lib/common-logic/estimateGas.d.ts +10 -0
- package/lib/common-logic/estimateGas.d.ts.map +1 -0
- package/lib/common-logic/estimateGas.js +17 -0
- package/lib/common-logic/estimateGas.js.map +1 -0
- package/lib/common-logic/estimateGas.test.d.ts +2 -0
- package/lib/common-logic/estimateGas.test.d.ts.map +1 -0
- package/lib/common-logic/estimateGas.test.js +129 -0
- package/lib/common-logic/estimateGas.test.js.map +1 -0
- package/lib/common-logic/fixPrefixCase.d.ts +2 -0
- package/lib/common-logic/fixPrefixCase.d.ts.map +1 -0
- package/lib/common-logic/fixPrefixCase.js +9 -0
- package/lib/common-logic/fixPrefixCase.js.map +1 -0
- package/lib/common-logic/fixPrefixCase.test.d.ts +2 -0
- package/lib/common-logic/fixPrefixCase.test.d.ts.map +1 -0
- package/lib/common-logic/fixPrefixCase.test.js +46 -0
- package/lib/common-logic/fixPrefixCase.test.js.map +1 -0
- package/lib/common-logic/generateNonce.d.ts +6 -0
- package/lib/common-logic/generateNonce.d.ts.map +1 -0
- package/lib/common-logic/generateNonce.js +13 -0
- package/lib/common-logic/generateNonce.js.map +1 -0
- package/lib/common-logic/generateNonce.test.d.ts +2 -0
- package/lib/common-logic/generateNonce.test.d.ts.map +1 -0
- package/lib/common-logic/generateNonce.test.js +59 -0
- package/lib/common-logic/generateNonce.test.js.map +1 -0
- package/lib/common-logic/getThorClient.d.ts +7 -0
- package/lib/common-logic/getThorClient.d.ts.map +1 -0
- package/lib/common-logic/getThorClient.js +14 -0
- package/lib/common-logic/getThorClient.js.map +1 -0
- package/lib/common-logic/getThorClient.test.d.ts +2 -0
- package/lib/common-logic/getThorClient.test.d.ts.map +1 -0
- package/lib/common-logic/getThorClient.test.js +53 -0
- package/lib/common-logic/getThorClient.test.js.map +1 -0
- package/lib/common-logic/index.d.ts +8 -6
- package/lib/common-logic/index.d.ts.map +1 -1
- package/lib/common-logic/index.js +8 -6
- package/lib/common-logic/index.js.map +1 -1
- package/lib/common-logic/{mapping-utils.d.ts → mapTransfersToOperations.d.ts} +2 -2
- package/lib/common-logic/mapTransfersToOperations.d.ts.map +1 -0
- package/lib/common-logic/{mapping-utils.js → mapTransfersToOperations.js} +26 -19
- package/lib/common-logic/mapTransfersToOperations.js.map +1 -0
- package/lib/common-logic/mapTransfersToOperations.test.d.ts +2 -0
- package/lib/common-logic/mapTransfersToOperations.test.d.ts.map +1 -0
- package/lib/common-logic/mapTransfersToOperations.test.js +274 -0
- package/lib/common-logic/mapTransfersToOperations.test.js.map +1 -0
- package/lib/common-logic/{pad-address.d.ts → padAddress.d.ts} +1 -1
- package/lib/common-logic/padAddress.d.ts.map +1 -0
- package/lib/common-logic/{pad-address.js → padAddress.js} +1 -1
- package/lib/common-logic/padAddress.js.map +1 -0
- package/lib/common-logic/padAddress.test.d.ts +2 -0
- package/lib/common-logic/padAddress.test.d.ts.map +1 -0
- package/lib/common-logic/padAddress.test.js +59 -0
- package/lib/common-logic/padAddress.test.js.map +1 -0
- package/lib/common-logic/parseAddress.d.ts +7 -0
- package/lib/common-logic/parseAddress.d.ts.map +1 -0
- package/lib/common-logic/parseAddress.js +15 -0
- package/lib/common-logic/parseAddress.js.map +1 -0
- package/lib/common-logic/parseAddress.test.d.ts +2 -0
- package/lib/common-logic/parseAddress.test.d.ts.map +1 -0
- package/lib/common-logic/parseAddress.test.js +97 -0
- package/lib/common-logic/parseAddress.test.js.map +1 -0
- package/lib/constants/env.d.ts +2 -0
- package/lib/constants/env.d.ts.map +1 -0
- package/lib/constants/env.js +6 -0
- package/lib/constants/env.js.map +1 -0
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/constants/index.js +18 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/network/sdk.d.ts +3 -10
- package/lib/network/sdk.d.ts.map +1 -1
- package/lib/network/sdk.js +15 -30
- package/lib/network/sdk.js.map +1 -1
- package/lib/signer/getAddress.test.d.ts +2 -0
- package/lib/signer/getAddress.test.d.ts.map +1 -0
- package/lib/signer/getAddress.test.js +357 -0
- package/lib/signer/getAddress.test.js.map +1 -0
- package/lib/signer/signMessage.d.ts.map +1 -1
- package/lib/signer/signMessage.js +3 -3
- package/lib/signer/signMessage.js.map +1 -1
- package/lib/signer/signMessage.test.d.ts +2 -0
- package/lib/signer/signMessage.test.d.ts.map +1 -0
- package/lib/signer/signMessage.test.js +242 -0
- package/lib/signer/signMessage.test.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +79 -53
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/cli.d.ts.map +1 -1
- package/lib/test/cli.js +5 -4
- package/lib/test/cli.js.map +1 -1
- package/lib/types/bridge.d.ts +11 -3
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/bridge.js +3 -0
- package/lib/types/bridge.js.map +1 -1
- package/lib/types/constants.d.ts +0 -3
- package/lib/types/constants.d.ts.map +1 -1
- package/lib/types/constants.js +1 -4
- package/lib/types/constants.js.map +1 -1
- package/lib/types/signer.d.ts +0 -2
- package/lib/types/signer.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.js +2 -3
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/broadcast.test.d.ts +2 -0
- package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.test.js +183 -0
- package/lib-es/bridge/broadcast.test.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperatioin.test.d.ts +2 -0
- package/lib-es/bridge/buildOptimisticOperatioin.test.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperatioin.test.js +281 -0
- package/lib-es/bridge/buildOptimisticOperatioin.test.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -1
- package/lib-es/bridge/createTransaction.js +3 -2
- package/lib-es/bridge/createTransaction.js.map +1 -1
- package/lib-es/bridge/createTransaction.test.d.ts +2 -0
- package/lib-es/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.test.js +162 -0
- package/lib-es/bridge/createTransaction.test.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.test.d.ts +2 -0
- package/lib-es/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.test.js +264 -0
- package/lib-es/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +4 -2
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.test.js +277 -0
- package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib-es/bridge/helpers.test.d.ts +2 -0
- package/lib-es/bridge/helpers.test.d.ts.map +1 -0
- package/lib-es/bridge/helpers.test.js +293 -0
- package/lib-es/bridge/helpers.test.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +11 -4
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.test.js +272 -0
- package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +3 -3
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/signOperation.test.d.ts +2 -0
- package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.test.js +290 -0
- package/lib-es/bridge/signOperation.test.js.map +1 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +1 -1
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/bridge/transaction.test.d.ts +2 -0
- package/lib-es/bridge/transaction.test.d.ts.map +1 -0
- package/lib-es/bridge/transaction.test.js +347 -0
- package/lib-es/bridge/transaction.test.js.map +1 -0
- package/lib-es/common-logic/calculateClauses.d.ts +5 -0
- package/lib-es/common-logic/calculateClauses.d.ts.map +1 -0
- package/lib-es/common-logic/{logic.js → calculateClauses.js} +6 -6
- package/lib-es/common-logic/calculateClauses.js.map +1 -0
- package/lib-es/common-logic/calculateClauses.test.d.ts +2 -0
- package/lib-es/common-logic/calculateClauses.test.d.ts.map +1 -0
- package/lib-es/common-logic/calculateClauses.test.js +151 -0
- package/lib-es/common-logic/calculateClauses.test.js.map +1 -0
- package/lib-es/common-logic/calculateGasFees.d.ts +9 -0
- package/lib-es/common-logic/calculateGasFees.d.ts.map +1 -0
- package/lib-es/common-logic/calculateGasFees.js +32 -0
- package/lib-es/common-logic/calculateGasFees.js.map +1 -0
- package/lib-es/common-logic/calculateGasFees.test.d.ts +2 -0
- package/lib-es/common-logic/calculateGasFees.test.d.ts.map +1 -0
- package/lib-es/common-logic/calculateGasFees.test.js +274 -0
- package/lib-es/common-logic/calculateGasFees.test.js.map +1 -0
- package/lib-es/common-logic/calculateTransactionInfo.d.ts +10 -0
- package/lib-es/common-logic/calculateTransactionInfo.d.ts.map +1 -0
- package/lib-es/common-logic/calculateTransactionInfo.js +74 -0
- package/lib-es/common-logic/calculateTransactionInfo.js.map +1 -0
- package/lib-es/common-logic/calculateTransactionInfo.test.d.ts +2 -0
- package/lib-es/common-logic/calculateTransactionInfo.test.d.ts.map +1 -0
- package/lib-es/common-logic/calculateTransactionInfo.test.js +309 -0
- package/lib-es/common-logic/calculateTransactionInfo.test.js.map +1 -0
- package/lib-es/common-logic/estimateGas.d.ts +10 -0
- package/lib-es/common-logic/estimateGas.d.ts.map +1 -0
- package/lib-es/common-logic/estimateGas.js +13 -0
- package/lib-es/common-logic/estimateGas.js.map +1 -0
- package/lib-es/common-logic/estimateGas.test.d.ts +2 -0
- package/lib-es/common-logic/estimateGas.test.d.ts.map +1 -0
- package/lib-es/common-logic/estimateGas.test.js +127 -0
- package/lib-es/common-logic/estimateGas.test.js.map +1 -0
- package/lib-es/common-logic/fixPrefixCase.d.ts +2 -0
- package/lib-es/common-logic/fixPrefixCase.d.ts.map +1 -0
- package/lib-es/common-logic/fixPrefixCase.js +5 -0
- package/lib-es/common-logic/fixPrefixCase.js.map +1 -0
- package/lib-es/common-logic/fixPrefixCase.test.d.ts +2 -0
- package/lib-es/common-logic/fixPrefixCase.test.d.ts.map +1 -0
- package/lib-es/common-logic/fixPrefixCase.test.js +44 -0
- package/lib-es/common-logic/fixPrefixCase.test.js.map +1 -0
- package/lib-es/common-logic/generateNonce.d.ts +6 -0
- package/lib-es/common-logic/generateNonce.d.ts.map +1 -0
- package/lib-es/common-logic/generateNonce.js +9 -0
- package/lib-es/common-logic/generateNonce.js.map +1 -0
- package/lib-es/common-logic/generateNonce.test.d.ts +2 -0
- package/lib-es/common-logic/generateNonce.test.d.ts.map +1 -0
- package/lib-es/common-logic/generateNonce.test.js +57 -0
- package/lib-es/common-logic/generateNonce.test.js.map +1 -0
- package/lib-es/common-logic/getThorClient.d.ts +7 -0
- package/lib-es/common-logic/getThorClient.d.ts.map +1 -0
- package/lib-es/common-logic/getThorClient.js +10 -0
- package/lib-es/common-logic/getThorClient.js.map +1 -0
- package/lib-es/common-logic/getThorClient.test.d.ts +2 -0
- package/lib-es/common-logic/getThorClient.test.d.ts.map +1 -0
- package/lib-es/common-logic/getThorClient.test.js +51 -0
- package/lib-es/common-logic/getThorClient.test.js.map +1 -0
- package/lib-es/common-logic/index.d.ts +8 -6
- package/lib-es/common-logic/index.d.ts.map +1 -1
- package/lib-es/common-logic/index.js +8 -6
- package/lib-es/common-logic/index.js.map +1 -1
- package/lib-es/common-logic/{mapping-utils.d.ts → mapTransfersToOperations.d.ts} +2 -2
- package/lib-es/common-logic/mapTransfersToOperations.d.ts.map +1 -0
- package/lib-es/common-logic/mapTransfersToOperations.js +51 -0
- package/lib-es/common-logic/mapTransfersToOperations.js.map +1 -0
- package/lib-es/common-logic/mapTransfersToOperations.test.d.ts +2 -0
- package/lib-es/common-logic/mapTransfersToOperations.test.d.ts.map +1 -0
- package/lib-es/common-logic/mapTransfersToOperations.test.js +269 -0
- package/lib-es/common-logic/mapTransfersToOperations.test.js.map +1 -0
- package/lib-es/common-logic/{pad-address.d.ts → padAddress.d.ts} +1 -1
- package/lib-es/common-logic/padAddress.d.ts.map +1 -0
- package/lib-es/common-logic/{pad-address.js → padAddress.js} +1 -1
- package/lib-es/common-logic/padAddress.js.map +1 -0
- package/lib-es/common-logic/padAddress.test.d.ts +2 -0
- package/lib-es/common-logic/padAddress.test.d.ts.map +1 -0
- package/lib-es/common-logic/padAddress.test.js +57 -0
- package/lib-es/common-logic/padAddress.test.js.map +1 -0
- package/lib-es/common-logic/parseAddress.d.ts +7 -0
- package/lib-es/common-logic/parseAddress.d.ts.map +1 -0
- package/lib-es/common-logic/parseAddress.js +11 -0
- package/lib-es/common-logic/parseAddress.js.map +1 -0
- package/lib-es/common-logic/parseAddress.test.d.ts +2 -0
- package/lib-es/common-logic/parseAddress.test.d.ts.map +1 -0
- package/lib-es/common-logic/parseAddress.test.js +95 -0
- package/lib-es/common-logic/parseAddress.test.js.map +1 -0
- package/lib-es/constants/env.d.ts +2 -0
- package/lib-es/constants/env.d.ts.map +1 -0
- package/lib-es/constants/env.js +3 -0
- package/lib-es/constants/env.js.map +1 -0
- package/lib-es/constants/index.d.ts +2 -0
- package/lib-es/constants/index.d.ts.map +1 -0
- package/lib-es/constants/index.js +2 -0
- package/lib-es/constants/index.js.map +1 -0
- package/lib-es/network/sdk.d.ts +3 -10
- package/lib-es/network/sdk.d.ts.map +1 -1
- package/lib-es/network/sdk.js +5 -19
- package/lib-es/network/sdk.js.map +1 -1
- package/lib-es/signer/getAddress.test.d.ts +2 -0
- package/lib-es/signer/getAddress.test.d.ts.map +1 -0
- package/lib-es/signer/getAddress.test.js +352 -0
- package/lib-es/signer/getAddress.test.js.map +1 -0
- package/lib-es/signer/signMessage.d.ts.map +1 -1
- package/lib-es/signer/signMessage.js +3 -3
- package/lib-es/signer/signMessage.js.map +1 -1
- package/lib-es/signer/signMessage.test.d.ts +2 -0
- package/lib-es/signer/signMessage.test.d.ts.map +1 -0
- package/lib-es/signer/signMessage.test.js +240 -0
- package/lib-es/signer/signMessage.test.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +80 -54
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/cli.d.ts.map +1 -1
- package/lib-es/test/cli.js +4 -3
- package/lib-es/test/cli.js.map +1 -1
- package/lib-es/types/bridge.d.ts +11 -3
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/lib-es/types/bridge.js +6 -1
- package/lib-es/types/bridge.js.map +1 -1
- package/lib-es/types/constants.d.ts +0 -3
- package/lib-es/types/constants.d.ts.map +1 -1
- package/lib-es/types/constants.js +0 -3
- package/lib-es/types/constants.js.map +1 -1
- package/lib-es/types/signer.d.ts +0 -2
- package/lib-es/types/signer.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/bridge/broadcast.test.ts +236 -0
- package/src/bridge/broadcast.ts +4 -5
- package/src/bridge/buildOptimisticOperatioin.test.ts +364 -0
- package/src/bridge/createTransaction.test.ts +201 -0
- package/src/bridge/createTransaction.ts +3 -2
- package/src/bridge/estimateMaxSpendable.test.ts +319 -0
- package/src/bridge/getTransactionStatus.test.ts +353 -0
- package/src/bridge/getTransactionStatus.ts +4 -2
- package/src/bridge/helpers.test.ts +356 -0
- package/src/bridge/prepareTransaction.test.ts +345 -0
- package/src/bridge/prepareTransaction.ts +20 -10
- package/src/bridge/signOperation.test.ts +354 -0
- package/src/bridge/signOperation.ts +6 -3
- package/src/bridge/synchronisation.ts +1 -1
- package/src/bridge/transaction.test.ts +440 -0
- package/src/common-logic/calculateClauses.test.ts +186 -0
- package/src/common-logic/calculateClauses.ts +44 -0
- package/src/common-logic/calculateGasFees.test.ts +363 -0
- package/src/common-logic/calculateGasFees.ts +45 -0
- package/src/common-logic/calculateTransactionInfo.test.ts +396 -0
- package/src/common-logic/calculateTransactionInfo.ts +96 -0
- package/src/common-logic/estimateGas.test.ts +162 -0
- package/src/common-logic/estimateGas.ts +18 -0
- package/src/common-logic/fixPrefixCase.test.ts +51 -0
- package/src/common-logic/fixPrefixCase.ts +5 -0
- package/src/common-logic/generateNonce.test.ts +72 -0
- package/src/common-logic/generateNonce.ts +9 -0
- package/src/common-logic/getThorClient.test.ts +66 -0
- package/src/common-logic/getThorClient.ts +10 -0
- package/src/common-logic/index.ts +8 -6
- package/src/common-logic/mapTransfersToOperations.test.ts +342 -0
- package/src/common-logic/mapTransfersToOperations.ts +77 -0
- package/src/common-logic/padAddress.test.ts +65 -0
- package/src/common-logic/parseAddress.test.ts +130 -0
- package/src/common-logic/parseAddress.ts +11 -0
- package/src/constants/env.ts +3 -0
- package/src/constants/index.ts +1 -0
- package/src/network/sdk.ts +22 -30
- package/src/signer/getAddress.test.ts +454 -0
- package/src/signer/signMessage.test.ts +329 -0
- package/src/signer/signMessage.ts +4 -5
- package/src/test/bridgeDatasetTest.ts +86 -58
- package/src/test/cli.ts +4 -3
- package/src/types/bridge.ts +16 -3
- package/src/types/constants.ts +0 -3
- package/lib/common-logic/address-utils.d.ts +0 -2
- package/lib/common-logic/address-utils.d.ts.map +0 -1
- package/lib/common-logic/address-utils.js +0 -19
- package/lib/common-logic/address-utils.js.map +0 -1
- package/lib/common-logic/hex-utils.d.ts +0 -8
- package/lib/common-logic/hex-utils.d.ts.map +0 -1
- package/lib/common-logic/hex-utils.js +0 -52
- package/lib/common-logic/hex-utils.js.map +0 -1
- package/lib/common-logic/logic.d.ts +0 -5
- package/lib/common-logic/logic.d.ts.map +0 -1
- package/lib/common-logic/logic.js.map +0 -1
- package/lib/common-logic/mapping-utils.d.ts.map +0 -1
- package/lib/common-logic/mapping-utils.js.map +0 -1
- package/lib/common-logic/pad-address.d.ts.map +0 -1
- package/lib/common-logic/pad-address.js.map +0 -1
- package/lib/common-logic/transaction-utils.d.ts +0 -30
- package/lib/common-logic/transaction-utils.d.ts.map +0 -1
- package/lib/common-logic/transaction-utils.js +0 -161
- package/lib/common-logic/transaction-utils.js.map +0 -1
- package/lib/contracts/abis/VIP180.d.ts +0 -17
- package/lib/contracts/abis/VIP180.d.ts.map +0 -1
- package/lib/contracts/abis/VIP180.js +0 -265
- package/lib/contracts/abis/VIP180.js.map +0 -1
- package/lib/contracts/abis/params.d.ts +0 -8
- package/lib/contracts/abis/params.d.ts.map +0 -1
- package/lib/contracts/abis/params.js +0 -69
- package/lib/contracts/abis/params.js.map +0 -1
- package/lib/contracts/constants.d.ts +0 -6
- package/lib/contracts/constants.d.ts.map +0 -1
- package/lib/contracts/constants.js +0 -10
- package/lib/contracts/constants.js.map +0 -1
- package/lib-es/common-logic/address-utils.d.ts +0 -2
- package/lib-es/common-logic/address-utils.d.ts.map +0 -1
- package/lib-es/common-logic/address-utils.js +0 -12
- package/lib-es/common-logic/address-utils.js.map +0 -1
- package/lib-es/common-logic/hex-utils.d.ts +0 -8
- package/lib-es/common-logic/hex-utils.d.ts.map +0 -1
- package/lib-es/common-logic/hex-utils.js +0 -50
- package/lib-es/common-logic/hex-utils.js.map +0 -1
- package/lib-es/common-logic/logic.d.ts +0 -5
- package/lib-es/common-logic/logic.d.ts.map +0 -1
- package/lib-es/common-logic/logic.js.map +0 -1
- package/lib-es/common-logic/mapping-utils.d.ts.map +0 -1
- package/lib-es/common-logic/mapping-utils.js +0 -44
- package/lib-es/common-logic/mapping-utils.js.map +0 -1
- package/lib-es/common-logic/pad-address.d.ts.map +0 -1
- package/lib-es/common-logic/pad-address.js.map +0 -1
- package/lib-es/common-logic/transaction-utils.d.ts +0 -30
- package/lib-es/common-logic/transaction-utils.d.ts.map +0 -1
- package/lib-es/common-logic/transaction-utils.js +0 -150
- package/lib-es/common-logic/transaction-utils.js.map +0 -1
- package/lib-es/contracts/abis/VIP180.d.ts +0 -17
- package/lib-es/contracts/abis/VIP180.d.ts.map +0 -1
- package/lib-es/contracts/abis/VIP180.js +0 -263
- package/lib-es/contracts/abis/VIP180.js.map +0 -1
- package/lib-es/contracts/abis/params.d.ts +0 -8
- package/lib-es/contracts/abis/params.d.ts.map +0 -1
- package/lib-es/contracts/abis/params.js +0 -67
- package/lib-es/contracts/abis/params.js.map +0 -1
- package/lib-es/contracts/constants.d.ts +0 -6
- package/lib-es/contracts/constants.d.ts.map +0 -1
- package/lib-es/contracts/constants.js +0 -7
- package/lib-es/contracts/constants.js.map +0 -1
- package/src/common-logic/address-utils.ts +0 -11
- package/src/common-logic/hex-utils.ts +0 -53
- package/src/common-logic/logic.ts +0 -44
- package/src/common-logic/mapping-utils.ts +0 -67
- package/src/common-logic/transaction-utils.ts +0 -190
- package/src/contracts/abis/VIP180.ts +0 -265
- package/src/contracts/abis/params.ts +0 -70
- package/src/contracts/constants.ts +0 -11
- /package/src/common-logic/{pad-address.ts → padAddress.ts} +0 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { getTransactionStatus } from "./getTransactionStatus";
|
|
3
|
+
import { calculateTransactionInfo, parseAddress } from "../common-logic";
|
|
4
|
+
import { Transaction } from "../types";
|
|
5
|
+
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
6
|
+
import {
|
|
7
|
+
AmountRequired,
|
|
8
|
+
FeeNotLoaded,
|
|
9
|
+
InvalidAddress,
|
|
10
|
+
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
11
|
+
NotEnoughBalance,
|
|
12
|
+
RecipientRequired,
|
|
13
|
+
} from "@ledgerhq/errors";
|
|
14
|
+
import { NotEnoughVTHO } from "../errors";
|
|
15
|
+
|
|
16
|
+
// Mock dependencies
|
|
17
|
+
jest.mock("../common-logic");
|
|
18
|
+
|
|
19
|
+
const mockedCalculateTransactionInfo = jest.mocked(calculateTransactionInfo);
|
|
20
|
+
const mockedParseAddress = jest.mocked(parseAddress);
|
|
21
|
+
|
|
22
|
+
describe("getTransactionStatus", () => {
|
|
23
|
+
const mockVthoAccount: TokenAccount = {
|
|
24
|
+
type: "TokenAccount",
|
|
25
|
+
id: "vechain:1:0x123:+vtho",
|
|
26
|
+
parentId: "vechain:1:0x123:",
|
|
27
|
+
token: {} as any,
|
|
28
|
+
balance: new BigNumber("1000000000000000000000"), // 1000 VTHO
|
|
29
|
+
spendableBalance: new BigNumber("1000000000000000000000"),
|
|
30
|
+
creationDate: new Date("2022-01-01"),
|
|
31
|
+
operationsCount: 5,
|
|
32
|
+
operations: [],
|
|
33
|
+
pendingOperations: [],
|
|
34
|
+
balanceHistoryCache: { HOUR: {}, DAY: {}, WEEK: {} } as any,
|
|
35
|
+
swapHistory: [],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const mockAccount: Account = {
|
|
39
|
+
type: "Account",
|
|
40
|
+
id: "vechain:1:0x123:",
|
|
41
|
+
seedIdentifier: "seed123",
|
|
42
|
+
derivationMode: "" as any,
|
|
43
|
+
index: 0,
|
|
44
|
+
freshAddress: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
45
|
+
freshAddressPath: "44'/818'/0'/0/0",
|
|
46
|
+
used: true,
|
|
47
|
+
balance: new BigNumber("5000000000000000000"), // 5 VET
|
|
48
|
+
spendableBalance: new BigNumber("5000000000000000000"),
|
|
49
|
+
creationDate: new Date("2022-01-01"),
|
|
50
|
+
blockHeight: 12345,
|
|
51
|
+
currency: { name: "VeChain" } as any,
|
|
52
|
+
operationsCount: 10,
|
|
53
|
+
operations: [],
|
|
54
|
+
pendingOperations: [],
|
|
55
|
+
lastSyncDate: new Date("2022-01-01"),
|
|
56
|
+
balanceHistoryCache: { HOUR: {}, DAY: {}, WEEK: {} } as any,
|
|
57
|
+
swapHistory: [],
|
|
58
|
+
subAccounts: [mockVthoAccount],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const mockTransaction: Transaction = {
|
|
62
|
+
family: "vechain",
|
|
63
|
+
recipient: "0x456789012345678901234567890123456789abcd",
|
|
64
|
+
amount: new BigNumber("1000000000000000000"), // 1 VET
|
|
65
|
+
estimatedFees: "210000000000000000", // 0.21 VET
|
|
66
|
+
body: {
|
|
67
|
+
chainTag: 74,
|
|
68
|
+
blockRef: "0x00000000000b2bce",
|
|
69
|
+
expiration: 18,
|
|
70
|
+
clauses: [],
|
|
71
|
+
maxFeePerGas: 10000000000000,
|
|
72
|
+
maxPriorityFeePerGas: 1000000000000,
|
|
73
|
+
gas: 21000,
|
|
74
|
+
dependsOn: null,
|
|
75
|
+
nonce: "0x12345678",
|
|
76
|
+
},
|
|
77
|
+
} as Transaction;
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
jest.clearAllMocks();
|
|
81
|
+
mockedCalculateTransactionInfo.mockResolvedValue({
|
|
82
|
+
isTokenAccount: false,
|
|
83
|
+
amount: new BigNumber("1000000000000000000"),
|
|
84
|
+
spendableBalance: new BigNumber("4790000000000000000"), // 5 VET - 0.21 VET fees
|
|
85
|
+
balance: new BigNumber("5000000000000000000"),
|
|
86
|
+
tokenAccount: undefined,
|
|
87
|
+
estimatedFees: "210000000000000000",
|
|
88
|
+
estimatedGas: 21000,
|
|
89
|
+
maxFeePerGas: 10000000000000,
|
|
90
|
+
maxPriorityFeePerGas: 1000000000000,
|
|
91
|
+
});
|
|
92
|
+
mockedParseAddress.mockReturnValue(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("successful transaction validation", () => {
|
|
96
|
+
it("should return valid status for a normal VET transaction", async () => {
|
|
97
|
+
const result = await getTransactionStatus(mockAccount, mockTransaction);
|
|
98
|
+
|
|
99
|
+
expect(result.errors).toEqual({});
|
|
100
|
+
expect(result.warnings).toEqual({});
|
|
101
|
+
expect(result.estimatedFees).toEqual(new BigNumber("210000000000000000"));
|
|
102
|
+
expect(result.amount).toEqual(new BigNumber("1000000000000000000"));
|
|
103
|
+
expect(result.totalSpent).toEqual(new BigNumber("1000000000000000000"));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should return valid status for a token transaction", async () => {
|
|
107
|
+
const tokenTransaction: Transaction = {
|
|
108
|
+
...mockTransaction,
|
|
109
|
+
subAccountId: "vechain:1:0x123:+vtho",
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
mockedCalculateTransactionInfo.mockResolvedValue({
|
|
113
|
+
isTokenAccount: true,
|
|
114
|
+
amount: new BigNumber("1000000000000000000"),
|
|
115
|
+
spendableBalance: new BigNumber("999790000000000000000"),
|
|
116
|
+
balance: new BigNumber("1000000000000000000000"),
|
|
117
|
+
tokenAccount: mockVthoAccount,
|
|
118
|
+
estimatedFees: "210000000000000000",
|
|
119
|
+
estimatedGas: 21000,
|
|
120
|
+
maxFeePerGas: 10000000000000,
|
|
121
|
+
maxPriorityFeePerGas: 1000000000000,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const result = await getTransactionStatus(mockAccount, tokenTransaction);
|
|
125
|
+
|
|
126
|
+
expect(result.errors).toEqual({});
|
|
127
|
+
expect(result.totalSpent).toEqual(new BigNumber("1210000000000000000")); // amount + fees
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe("fee validation", () => {
|
|
132
|
+
it("should return FeeNotLoaded error when body is missing", async () => {
|
|
133
|
+
const transactionWithoutBody = { ...mockTransaction, body: undefined } as any;
|
|
134
|
+
|
|
135
|
+
await expect(getTransactionStatus(mockAccount, transactionWithoutBody)).rejects.toThrow();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("should return FeeNotLoaded error when gas is missing", async () => {
|
|
139
|
+
const transactionWithoutGas = {
|
|
140
|
+
...mockTransaction,
|
|
141
|
+
body: { ...mockTransaction.body, gas: undefined },
|
|
142
|
+
} as any;
|
|
143
|
+
|
|
144
|
+
const result = await getTransactionStatus(mockAccount, transactionWithoutGas);
|
|
145
|
+
|
|
146
|
+
expect(result.errors.fees).toBeInstanceOf(FeeNotLoaded);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should return FeeNotLoaded error when gas is zero", async () => {
|
|
150
|
+
const transactionWithZeroGas = {
|
|
151
|
+
...mockTransaction,
|
|
152
|
+
body: { ...mockTransaction.body, gas: 0 },
|
|
153
|
+
} as any;
|
|
154
|
+
|
|
155
|
+
const result = await getTransactionStatus(mockAccount, transactionWithZeroGas);
|
|
156
|
+
|
|
157
|
+
expect(result.errors.fees).toBeInstanceOf(FeeNotLoaded);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe("recipient validation", () => {
|
|
162
|
+
it("should return RecipientRequired error when recipient is empty", async () => {
|
|
163
|
+
const transactionWithoutRecipient = { ...mockTransaction, recipient: "" };
|
|
164
|
+
|
|
165
|
+
const result = await getTransactionStatus(mockAccount, transactionWithoutRecipient);
|
|
166
|
+
|
|
167
|
+
expect(result.errors.recipient).toBeInstanceOf(RecipientRequired);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("should return InvalidAddressBecauseDestinationIsAlsoSource warning when sending to self", async () => {
|
|
171
|
+
const selfTransaction = {
|
|
172
|
+
...mockTransaction,
|
|
173
|
+
recipient: mockAccount.freshAddress,
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const result = await getTransactionStatus(mockAccount, selfTransaction);
|
|
177
|
+
|
|
178
|
+
expect(result.warnings.recipient).toBeInstanceOf(
|
|
179
|
+
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("should handle case-insensitive self-send detection", async () => {
|
|
184
|
+
const selfTransaction = {
|
|
185
|
+
...mockTransaction,
|
|
186
|
+
recipient: mockAccount.freshAddress.toUpperCase(),
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const result = await getTransactionStatus(mockAccount, selfTransaction);
|
|
190
|
+
|
|
191
|
+
expect(result.warnings.recipient).toBeInstanceOf(
|
|
192
|
+
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("should return InvalidAddress error for invalid recipient", async () => {
|
|
197
|
+
mockedParseAddress.mockReturnValue(false);
|
|
198
|
+
|
|
199
|
+
const result = await getTransactionStatus(mockAccount, mockTransaction);
|
|
200
|
+
|
|
201
|
+
expect(result.errors.recipient).toBeInstanceOf(InvalidAddress);
|
|
202
|
+
expect(mockedParseAddress).toHaveBeenCalledWith(mockTransaction.recipient);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe("amount validation", () => {
|
|
207
|
+
it("should return AmountRequired error when amount is zero and not useAllAmount", async () => {
|
|
208
|
+
const zeroAmountTransaction = {
|
|
209
|
+
...mockTransaction,
|
|
210
|
+
amount: new BigNumber(0),
|
|
211
|
+
useAllAmount: false,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const result = await getTransactionStatus(mockAccount, zeroAmountTransaction);
|
|
215
|
+
|
|
216
|
+
expect(result.errors.amount).toBeInstanceOf(AmountRequired);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("should return NotEnoughBalance error when amount is zero and useAllAmount is true", async () => {
|
|
220
|
+
const useAllAmountTransaction = {
|
|
221
|
+
...mockTransaction,
|
|
222
|
+
amount: new BigNumber(0),
|
|
223
|
+
useAllAmount: true,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const result = await getTransactionStatus(mockAccount, useAllAmountTransaction);
|
|
227
|
+
|
|
228
|
+
expect(result.errors.amount).toBeInstanceOf(NotEnoughBalance);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("should return NotEnoughBalance error when amount exceeds spendable balance", async () => {
|
|
232
|
+
const largeAmountTransaction = {
|
|
233
|
+
...mockTransaction,
|
|
234
|
+
amount: new BigNumber("10000000000000000000"), // 10 VET, more than spendable
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
mockedCalculateTransactionInfo.mockResolvedValue({
|
|
238
|
+
isTokenAccount: false,
|
|
239
|
+
amount: new BigNumber("10000000000000000000"),
|
|
240
|
+
spendableBalance: new BigNumber("4790000000000000000"), // Less than amount
|
|
241
|
+
balance: new BigNumber("5000000000000000000"),
|
|
242
|
+
tokenAccount: undefined,
|
|
243
|
+
estimatedFees: "210000000000000000",
|
|
244
|
+
estimatedGas: 21000,
|
|
245
|
+
maxFeePerGas: 10000000000000,
|
|
246
|
+
maxPriorityFeePerGas: 1000000000000,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const result = await getTransactionStatus(mockAccount, largeAmountTransaction);
|
|
250
|
+
|
|
251
|
+
expect(result.errors.amount).toBeInstanceOf(NotEnoughBalance);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe("VTHO balance validation", () => {
|
|
256
|
+
it("should return NotEnoughVTHO error when VTHO balance is insufficient for fees", async () => {
|
|
257
|
+
const accountWithLowVtho: Account = {
|
|
258
|
+
...mockAccount,
|
|
259
|
+
subAccounts: [{ ...mockVthoAccount, balance: new BigNumber("100000000000000000") }], // 0.1 VTHO
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const result = await getTransactionStatus(accountWithLowVtho, mockTransaction);
|
|
263
|
+
|
|
264
|
+
expect(result.errors.amount).toBeInstanceOf(NotEnoughVTHO);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("should handle missing VTHO subaccount gracefully", async () => {
|
|
268
|
+
const accountWithoutVtho: Account = {
|
|
269
|
+
...mockAccount,
|
|
270
|
+
subAccounts: [],
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// This should throw an error when trying to access subAccounts[0].balance
|
|
274
|
+
await expect(getTransactionStatus(accountWithoutVtho, mockTransaction)).rejects.toThrow();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should handle undefined subAccounts gracefully", async () => {
|
|
278
|
+
const accountWithUndefinedSub: Account = {
|
|
279
|
+
...mockAccount,
|
|
280
|
+
subAccounts: [],
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// This should throw an error when trying to access subAccounts[0].balance
|
|
284
|
+
await expect(
|
|
285
|
+
getTransactionStatus(accountWithUndefinedSub, mockTransaction),
|
|
286
|
+
).rejects.toThrow();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should not check VTHO balance for token transactions", async () => {
|
|
290
|
+
const tokenTransaction: Transaction = {
|
|
291
|
+
...mockTransaction,
|
|
292
|
+
subAccountId: "vechain:1:0x123:+vtho",
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
mockedCalculateTransactionInfo.mockResolvedValue({
|
|
296
|
+
isTokenAccount: true,
|
|
297
|
+
amount: new BigNumber("1000000000000000000"),
|
|
298
|
+
spendableBalance: new BigNumber("999790000000000000000"),
|
|
299
|
+
balance: new BigNumber("1000000000000000000000"),
|
|
300
|
+
tokenAccount: mockVthoAccount,
|
|
301
|
+
estimatedFees: "210000000000000000",
|
|
302
|
+
estimatedGas: 21000,
|
|
303
|
+
maxFeePerGas: 10000000000000,
|
|
304
|
+
maxPriorityFeePerGas: 1000000000000,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const accountWithLowVtho: Account = {
|
|
308
|
+
...mockAccount,
|
|
309
|
+
subAccounts: [{ ...mockVthoAccount, balance: new BigNumber("100000000000000000") }],
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const result = await getTransactionStatus(accountWithLowVtho, tokenTransaction);
|
|
313
|
+
|
|
314
|
+
expect(result.errors.amount).toBeUndefined();
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
describe("multiple errors", () => {
|
|
319
|
+
it("should return multiple errors when multiple validations fail", async () => {
|
|
320
|
+
const invalidTransaction = {
|
|
321
|
+
...mockTransaction,
|
|
322
|
+
recipient: "",
|
|
323
|
+
amount: new BigNumber(0),
|
|
324
|
+
useAllAmount: false,
|
|
325
|
+
body: undefined,
|
|
326
|
+
} as any;
|
|
327
|
+
|
|
328
|
+
await expect(getTransactionStatus(mockAccount, invalidTransaction)).rejects.toThrow();
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
describe("calculateTransactionInfo integration", () => {
|
|
333
|
+
it("should call calculateTransactionInfo with correct parameters", async () => {
|
|
334
|
+
await getTransactionStatus(mockAccount, mockTransaction);
|
|
335
|
+
|
|
336
|
+
expect(mockedCalculateTransactionInfo).toHaveBeenCalledWith(mockAccount, mockTransaction, {
|
|
337
|
+
estimatedGas: mockTransaction.body.gas,
|
|
338
|
+
estimatedGasFees: new BigNumber(mockTransaction.estimatedFees),
|
|
339
|
+
maxFeePerGas: mockTransaction.body.maxFeePerGas,
|
|
340
|
+
maxPriorityFeePerGas: mockTransaction.body.maxPriorityFeePerGas,
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it("should handle calculateTransactionInfo errors", async () => {
|
|
345
|
+
const error = new Error("Calculation failed");
|
|
346
|
+
mockedCalculateTransactionInfo.mockRejectedValue(error);
|
|
347
|
+
|
|
348
|
+
await expect(getTransactionStatus(mockAccount, mockTransaction)).rejects.toThrow(
|
|
349
|
+
"Calculation failed",
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
});
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
RecipientRequired,
|
|
9
9
|
} from "@ledgerhq/errors";
|
|
10
10
|
import { AccountBridge } from "@ledgerhq/types-live";
|
|
11
|
-
import { calculateTransactionInfo,
|
|
11
|
+
import { calculateTransactionInfo, parseAddress } from "../common-logic";
|
|
12
12
|
import type { Transaction } from "../types";
|
|
13
13
|
import { NotEnoughVTHO } from "../errors";
|
|
14
14
|
|
|
@@ -26,6 +26,8 @@ export const getTransactionStatus: AccountBridge<Transaction>["getTransactionSta
|
|
|
26
26
|
{
|
|
27
27
|
estimatedGas: body.gas as number,
|
|
28
28
|
estimatedGasFees: new BigNumber(transaction.estimatedFees),
|
|
29
|
+
maxFeePerGas: body.maxFeePerGas as number,
|
|
30
|
+
maxPriorityFeePerGas: body.maxPriorityFeePerGas as number,
|
|
29
31
|
},
|
|
30
32
|
);
|
|
31
33
|
|
|
@@ -37,7 +39,7 @@ export const getTransactionStatus: AccountBridge<Transaction>["getTransactionSta
|
|
|
37
39
|
errors.recipient = new RecipientRequired();
|
|
38
40
|
} else if (freshAddress.toLowerCase() === recipient.toLowerCase()) {
|
|
39
41
|
warnings.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
|
|
40
|
-
} else if (!
|
|
42
|
+
} else if (!parseAddress(recipient)) {
|
|
41
43
|
errors.recipient = new InvalidAddress("", {
|
|
42
44
|
currencyName: currency.name,
|
|
43
45
|
});
|