@ledgerhq/coin-vechain 2.9.1-nightly.0 → 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 +24 -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,51 @@
|
|
|
1
|
+
import { fixPrefixCase } from "./fixPrefixCase";
|
|
2
|
+
|
|
3
|
+
describe("fixPrefixCase", () => {
|
|
4
|
+
it("should convert uppercase 0X prefix to lowercase 0x", () => {
|
|
5
|
+
const input = "0X1234567890abcdef";
|
|
6
|
+
const result = fixPrefixCase(input);
|
|
7
|
+
expect(result).toBe("0x1234567890abcdef");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should keep lowercase 0x prefix unchanged", () => {
|
|
11
|
+
const input = "0x1234567890abcdef";
|
|
12
|
+
const result = fixPrefixCase(input);
|
|
13
|
+
expect(result).toBe("0x1234567890abcdef");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should add 0x prefix when missing", () => {
|
|
17
|
+
const input = "1234567890abcdef";
|
|
18
|
+
const result = fixPrefixCase(input);
|
|
19
|
+
expect(result).toBe("0x1234567890abcdef");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should handle empty string by adding 0x prefix", () => {
|
|
23
|
+
const input = "";
|
|
24
|
+
const result = fixPrefixCase(input);
|
|
25
|
+
expect(result).toBe("0x");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should handle mixed case prefix 0X", () => {
|
|
29
|
+
const input = "0X123abc";
|
|
30
|
+
const result = fixPrefixCase(input);
|
|
31
|
+
expect(result).toBe("0x123abc");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should handle string starting with just 0 by adding x", () => {
|
|
35
|
+
const input = "01234";
|
|
36
|
+
const result = fixPrefixCase(input);
|
|
37
|
+
expect(result).toBe("0x01234");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should handle valid ethereum address", () => {
|
|
41
|
+
const input = "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4";
|
|
42
|
+
const result = fixPrefixCase(input);
|
|
43
|
+
expect(result).toBe("0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should handle address without prefix", () => {
|
|
47
|
+
const input = "742d35Cc6634C0532925a3b8D0B251d8c1743eC4";
|
|
48
|
+
const result = fixPrefixCase(input);
|
|
49
|
+
expect(result).toBe("0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { generateNonce } from "./generateNonce";
|
|
2
|
+
import { Hex } from "@vechain/sdk-core";
|
|
3
|
+
|
|
4
|
+
// Mock the Hex.random method
|
|
5
|
+
jest.mock("@vechain/sdk-core", () => ({
|
|
6
|
+
Hex: {
|
|
7
|
+
random: jest.fn(),
|
|
8
|
+
},
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const mockedHex = jest.mocked(Hex);
|
|
12
|
+
|
|
13
|
+
describe("generateNonce", () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should generate a nonce using Hex.random with length 8", () => {
|
|
19
|
+
const mockHexValue = {
|
|
20
|
+
toString: jest.fn().mockReturnValue("0x1234567890abcdef"),
|
|
21
|
+
};
|
|
22
|
+
mockedHex.random.mockReturnValue(mockHexValue as any);
|
|
23
|
+
|
|
24
|
+
const result = generateNonce();
|
|
25
|
+
|
|
26
|
+
expect(mockedHex.random).toHaveBeenCalledWith(8);
|
|
27
|
+
expect(mockHexValue.toString).toHaveBeenCalled();
|
|
28
|
+
expect(result).toBe("0x1234567890abcdef");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should return a string", () => {
|
|
32
|
+
const mockHexValue = {
|
|
33
|
+
toString: jest.fn().mockReturnValue("0xabcdef1234567890"),
|
|
34
|
+
};
|
|
35
|
+
mockedHex.random.mockReturnValue(mockHexValue as any);
|
|
36
|
+
|
|
37
|
+
const result = generateNonce();
|
|
38
|
+
|
|
39
|
+
expect(typeof result).toBe("string");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should call toString on the hex value", () => {
|
|
43
|
+
const mockHexValue = {
|
|
44
|
+
toString: jest.fn().mockReturnValue("0x123456789abcdef0"),
|
|
45
|
+
};
|
|
46
|
+
mockedHex.random.mockReturnValue(mockHexValue as any);
|
|
47
|
+
|
|
48
|
+
generateNonce();
|
|
49
|
+
|
|
50
|
+
expect(mockHexValue.toString).toHaveBeenCalledTimes(1);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should handle different hex values", () => {
|
|
54
|
+
const testCases = [
|
|
55
|
+
"0x0000000000000000",
|
|
56
|
+
"0xffffffffffffffff",
|
|
57
|
+
"0x123456789abcdef0",
|
|
58
|
+
"0xa1b2c3d4e5f67890",
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
testCases.forEach(expectedValue => {
|
|
62
|
+
const mockHexValue = {
|
|
63
|
+
toString: jest.fn().mockReturnValue(expectedValue),
|
|
64
|
+
};
|
|
65
|
+
mockedHex.random.mockReturnValue(mockHexValue as any);
|
|
66
|
+
|
|
67
|
+
const result = generateNonce();
|
|
68
|
+
|
|
69
|
+
expect(result).toBe(expectedValue);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getThorClient } from "./getThorClient";
|
|
2
|
+
import { ThorClient } from "@vechain/sdk-network";
|
|
3
|
+
import { VECHAIN_NODE_URL } from "../constants";
|
|
4
|
+
|
|
5
|
+
// Mock the ThorClient
|
|
6
|
+
jest.mock("@vechain/sdk-network", () => ({
|
|
7
|
+
ThorClient: {
|
|
8
|
+
at: jest.fn(),
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// Mock the constants
|
|
13
|
+
jest.mock("../constants", () => ({
|
|
14
|
+
VECHAIN_NODE_URL: "https://testnet.veblocks.net",
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const mockedThorClient = jest.mocked(ThorClient);
|
|
18
|
+
|
|
19
|
+
describe("getThorClient", () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should create a ThorClient instance with VECHAIN_NODE_URL", () => {
|
|
25
|
+
const mockClient = {
|
|
26
|
+
/* mock ThorClient properties */
|
|
27
|
+
};
|
|
28
|
+
mockedThorClient.at.mockReturnValue(mockClient as any);
|
|
29
|
+
|
|
30
|
+
const result = getThorClient();
|
|
31
|
+
|
|
32
|
+
expect(mockedThorClient.at).toHaveBeenCalledWith(VECHAIN_NODE_URL);
|
|
33
|
+
expect(result).toBe(mockClient);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should return the same type of object from ThorClient.at", () => {
|
|
37
|
+
const mockClient = {
|
|
38
|
+
test: "thorClient",
|
|
39
|
+
transactions: {},
|
|
40
|
+
gas: {},
|
|
41
|
+
};
|
|
42
|
+
mockedThorClient.at.mockReturnValue(mockClient as any);
|
|
43
|
+
|
|
44
|
+
const result = getThorClient();
|
|
45
|
+
|
|
46
|
+
expect(result).toEqual(mockClient);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should call ThorClient.at exactly once", () => {
|
|
50
|
+
const mockClient = {};
|
|
51
|
+
mockedThorClient.at.mockReturnValue(mockClient as any);
|
|
52
|
+
|
|
53
|
+
getThorClient();
|
|
54
|
+
|
|
55
|
+
expect(mockedThorClient.at).toHaveBeenCalledTimes(1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should use the correct URL from constants", () => {
|
|
59
|
+
const mockClient = {};
|
|
60
|
+
mockedThorClient.at.mockReturnValue(mockClient as any);
|
|
61
|
+
|
|
62
|
+
getThorClient();
|
|
63
|
+
|
|
64
|
+
expect(mockedThorClient.at).toHaveBeenCalledWith("https://testnet.veblocks.net");
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThorClient } from "@vechain/sdk-network";
|
|
2
|
+
import { VECHAIN_NODE_URL } from "../constants";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ThorClient instance configured with the VeChain node URL
|
|
6
|
+
* @returns {ThorClient} Configured ThorClient instance for interacting with the VeChain network
|
|
7
|
+
*/
|
|
8
|
+
export const getThorClient = (): ThorClient => {
|
|
9
|
+
return ThorClient.at(VECHAIN_NODE_URL);
|
|
10
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
1
|
+
export * from "./fixPrefixCase";
|
|
2
|
+
export * from "./calculateClauses";
|
|
3
|
+
export * from "./mapTransfersToOperations";
|
|
4
|
+
export * from "./padAddress";
|
|
5
|
+
export * from "./calculateTransactionInfo";
|
|
6
|
+
export * from "./calculateGasFees";
|
|
7
|
+
export * from "./generateNonce";
|
|
8
|
+
export * from "./parseAddress";
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { TransferLog, EventLog } from "../types";
|
|
3
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
4
|
+
|
|
5
|
+
// Mock dependencies before importing the function under test
|
|
6
|
+
jest.mock("../network", () => ({
|
|
7
|
+
getFees: jest.fn(),
|
|
8
|
+
}));
|
|
9
|
+
jest.mock("@ledgerhq/coin-framework/operation", () => ({
|
|
10
|
+
encodeOperationId: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
jest.mock("@vechain/sdk-core", () => ({
|
|
13
|
+
ABIEvent: {
|
|
14
|
+
parseLog: jest.fn(),
|
|
15
|
+
},
|
|
16
|
+
Hex: {
|
|
17
|
+
of: jest.fn(),
|
|
18
|
+
},
|
|
19
|
+
VIP180_ABI: {},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
// Import the functions under test after mocking
|
|
23
|
+
import {
|
|
24
|
+
mapVetTransfersToOperations,
|
|
25
|
+
mapTokenTransfersToOperations,
|
|
26
|
+
} from "./mapTransfersToOperations";
|
|
27
|
+
import { getFees } from "../network";
|
|
28
|
+
|
|
29
|
+
const { ABIEvent, Hex, VIP180_ABI } = jest.requireMock("@vechain/sdk-core");
|
|
30
|
+
|
|
31
|
+
const mockedGetFees = jest.mocked(getFees);
|
|
32
|
+
const mockedEncodeOperationId = jest.mocked(encodeOperationId);
|
|
33
|
+
const mockedABIEvent = ABIEvent;
|
|
34
|
+
const mockedHex = Hex;
|
|
35
|
+
|
|
36
|
+
describe("mapVetTransfersToOperations", () => {
|
|
37
|
+
const mockAccountId = "vechain:1:0x123:";
|
|
38
|
+
const mockAddr = "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4";
|
|
39
|
+
|
|
40
|
+
const mockTransferLogs: TransferLog[] = [
|
|
41
|
+
{
|
|
42
|
+
sender: "0x5034aa590125b64023a0262112b98d72e3c8e40e",
|
|
43
|
+
recipient: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
44
|
+
amount: "1000000000000000000",
|
|
45
|
+
meta: {
|
|
46
|
+
blockID: "0xblock123",
|
|
47
|
+
blockNumber: 12345,
|
|
48
|
+
blockTimestamp: 1640995200,
|
|
49
|
+
txID: "0xtx123",
|
|
50
|
+
txOrigin: "0x5034aa590125b64023a0262112b98d72e3c8e40e",
|
|
51
|
+
clauseIndex: 0,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
sender: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
56
|
+
recipient: "0x456789012345678901234567890123456789abcd",
|
|
57
|
+
amount: "2000000000000000000",
|
|
58
|
+
meta: {
|
|
59
|
+
blockID: "0xblock456",
|
|
60
|
+
blockNumber: 12346,
|
|
61
|
+
blockTimestamp: 1640995260,
|
|
62
|
+
txID: "0xtx456",
|
|
63
|
+
txOrigin: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
64
|
+
clauseIndex: 0,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
jest.clearAllMocks();
|
|
71
|
+
mockedGetFees.mockResolvedValue(new BigNumber("21000000000000000"));
|
|
72
|
+
mockedEncodeOperationId.mockImplementation(
|
|
73
|
+
(accountId, hash, type) => `${accountId}${hash}${type}`,
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should map incoming VET transfers to operations", async () => {
|
|
78
|
+
const result = await mapVetTransfersToOperations(
|
|
79
|
+
[mockTransferLogs[0]],
|
|
80
|
+
mockAccountId,
|
|
81
|
+
mockAddr,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(result).toHaveLength(1);
|
|
85
|
+
expect(result[0]).toEqual({
|
|
86
|
+
id: `${mockAccountId}0xtx123IN`,
|
|
87
|
+
hash: "0xtx123",
|
|
88
|
+
type: "IN",
|
|
89
|
+
value: new BigNumber("1000000000000000000"),
|
|
90
|
+
fee: new BigNumber("21000000000000000"),
|
|
91
|
+
senders: ["0x5034aa590125b64023a0262112b98d72e3c8e40e"],
|
|
92
|
+
recipients: ["0x742d35cc6634c0532925a3b8d0b251d8c1743ec4"],
|
|
93
|
+
blockHeight: 12345,
|
|
94
|
+
blockHash: "0xblock123",
|
|
95
|
+
accountId: mockAccountId,
|
|
96
|
+
date: new Date(1640995200 * 1000),
|
|
97
|
+
extra: {},
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should map outgoing VET transfers to operations", async () => {
|
|
102
|
+
const result = await mapVetTransfersToOperations(
|
|
103
|
+
[mockTransferLogs[1]],
|
|
104
|
+
mockAccountId,
|
|
105
|
+
mockAddr,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(result).toHaveLength(1);
|
|
109
|
+
expect(result[0]).toEqual({
|
|
110
|
+
id: `${mockAccountId}0xtx456OUT`,
|
|
111
|
+
hash: "0xtx456",
|
|
112
|
+
type: "OUT",
|
|
113
|
+
value: new BigNumber("2000000000000000000"),
|
|
114
|
+
fee: new BigNumber("21000000000000000"),
|
|
115
|
+
senders: ["0x742d35cc6634c0532925a3b8d0b251d8c1743ec4"],
|
|
116
|
+
recipients: ["0x456789012345678901234567890123456789abcd"],
|
|
117
|
+
blockHeight: 12346,
|
|
118
|
+
blockHash: "0xblock456",
|
|
119
|
+
accountId: mockAccountId,
|
|
120
|
+
date: new Date(1640995260 * 1000),
|
|
121
|
+
extra: {},
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("should handle multiple transfers", async () => {
|
|
126
|
+
const result = await mapVetTransfersToOperations(mockTransferLogs, mockAccountId, mockAddr);
|
|
127
|
+
|
|
128
|
+
expect(result).toHaveLength(2);
|
|
129
|
+
expect(result[0].type).toBe("IN");
|
|
130
|
+
expect(result[1].type).toBe("OUT");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should call getFees for each transfer", async () => {
|
|
134
|
+
await mapVetTransfersToOperations(mockTransferLogs, mockAccountId, mockAddr);
|
|
135
|
+
|
|
136
|
+
expect(mockedGetFees).toHaveBeenCalledTimes(2);
|
|
137
|
+
expect(mockedGetFees).toHaveBeenCalledWith("0xtx123");
|
|
138
|
+
expect(mockedGetFees).toHaveBeenCalledWith("0xtx456");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("should handle case-insensitive address comparison", async () => {
|
|
142
|
+
const upperCaseAddr = mockAddr.toUpperCase();
|
|
143
|
+
const transferWithUpperCase: TransferLog = {
|
|
144
|
+
...mockTransferLogs[0],
|
|
145
|
+
recipient: upperCaseAddr,
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const result = await mapVetTransfersToOperations(
|
|
149
|
+
[transferWithUpperCase],
|
|
150
|
+
mockAccountId,
|
|
151
|
+
mockAddr,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
expect(result[0].type).toBe("IN");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should convert addresses to lowercase in the operation", async () => {
|
|
158
|
+
const transferWithMixedCase: TransferLog = {
|
|
159
|
+
...mockTransferLogs[0],
|
|
160
|
+
sender: "0x5034AA590125B64023A0262112B98D72E3C8E40E",
|
|
161
|
+
recipient: "0x742D35CC6634C0532925A3B8D0B251D8C1743EC4",
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const result = await mapVetTransfersToOperations(
|
|
165
|
+
[transferWithMixedCase],
|
|
166
|
+
mockAccountId,
|
|
167
|
+
mockAddr,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
expect(result[0].senders[0]).toBe("0x5034aa590125b64023a0262112b98d72e3c8e40e");
|
|
171
|
+
expect(result[0].recipients[0]).toBe("0x742d35cc6634c0532925a3b8d0b251d8c1743ec4");
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe("mapTokenTransfersToOperations", () => {
|
|
176
|
+
const mockAccountId = "vechain:1:0x123:";
|
|
177
|
+
const mockAddr = "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4";
|
|
178
|
+
|
|
179
|
+
const mockEventLogs: EventLog[] = [
|
|
180
|
+
{
|
|
181
|
+
address: "0x0000000000000000000000000000456e65726779",
|
|
182
|
+
topics: [
|
|
183
|
+
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
|
184
|
+
"0x0000000000000000000000005034aa590125b64023a0262112b98d72e3c8e40e",
|
|
185
|
+
"0x000000000000000000000000742d35cc6634c0532925a3b8d0b251d8c1743ec4",
|
|
186
|
+
],
|
|
187
|
+
data: "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
|
|
188
|
+
meta: {
|
|
189
|
+
blockID: "0xblock789",
|
|
190
|
+
blockNumber: 12347,
|
|
191
|
+
blockTimestamp: 1640995320,
|
|
192
|
+
txID: "0xtx789",
|
|
193
|
+
txOrigin: "0x5034aa590125b64023a0262112b98d72e3c8e40e",
|
|
194
|
+
clauseIndex: 0,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
const mockDecodedEvent = {
|
|
200
|
+
eventName: "Transfer" as const,
|
|
201
|
+
args: {
|
|
202
|
+
from: "0x5034aa590125b64023a0262112b98d72e3c8e40e",
|
|
203
|
+
to: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
204
|
+
value: BigInt("1000000000000000000"),
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
beforeEach(() => {
|
|
209
|
+
jest.clearAllMocks();
|
|
210
|
+
mockedGetFees.mockResolvedValue(new BigNumber("37000000000000000"));
|
|
211
|
+
mockedEncodeOperationId.mockImplementation(
|
|
212
|
+
(accountId, hash, type) => `${accountId}${hash}${type}`,
|
|
213
|
+
);
|
|
214
|
+
mockedHex.of.mockImplementation((exp: any) => ({ toString: () => exp.toString() }) as any);
|
|
215
|
+
mockedABIEvent.parseLog.mockReturnValue(mockDecodedEvent);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("should map incoming token transfers to operations", async () => {
|
|
219
|
+
const result = await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
220
|
+
|
|
221
|
+
expect(result).toHaveLength(1);
|
|
222
|
+
expect(result[0]).toEqual({
|
|
223
|
+
id: `${mockAccountId}0xtx789IN`,
|
|
224
|
+
hash: "0xtx789",
|
|
225
|
+
type: "IN",
|
|
226
|
+
value: new BigNumber("1000000000000000000"),
|
|
227
|
+
fee: new BigNumber("37000000000000000"),
|
|
228
|
+
senders: ["0x5034aa590125b64023a0262112b98d72e3c8e40e"],
|
|
229
|
+
recipients: ["0x742d35cc6634c0532925a3b8d0b251d8c1743ec4"],
|
|
230
|
+
blockHeight: 12347,
|
|
231
|
+
blockHash: "0xblock789",
|
|
232
|
+
accountId: mockAccountId,
|
|
233
|
+
date: new Date(1640995320 * 1000),
|
|
234
|
+
extra: {},
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("should map outgoing token transfers to operations", async () => {
|
|
239
|
+
const outgoingEvent = {
|
|
240
|
+
eventName: "Transfer" as const,
|
|
241
|
+
args: {
|
|
242
|
+
from: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
243
|
+
to: "0x456789012345678901234567890123456789abcd",
|
|
244
|
+
value: BigInt("2000000000000000000"),
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
mockedABIEvent.parseLog.mockReturnValue(outgoingEvent);
|
|
248
|
+
|
|
249
|
+
const result = await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
250
|
+
|
|
251
|
+
expect(result[0].type).toBe("OUT");
|
|
252
|
+
expect(result[0].value).toEqual(new BigNumber("2000000000000000000"));
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("should decode event logs correctly", async () => {
|
|
256
|
+
await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
257
|
+
|
|
258
|
+
expect(mockedHex.of).toHaveBeenCalledWith(mockEventLogs[0].data);
|
|
259
|
+
expect(mockedHex.of).toHaveBeenCalledWith(mockEventLogs[0].topics[0]);
|
|
260
|
+
expect(mockedHex.of).toHaveBeenCalledWith(mockEventLogs[0].topics[1]);
|
|
261
|
+
expect(mockedHex.of).toHaveBeenCalledWith(mockEventLogs[0].topics[2]);
|
|
262
|
+
|
|
263
|
+
expect(mockedABIEvent.parseLog).toHaveBeenCalledWith(
|
|
264
|
+
VIP180_ABI,
|
|
265
|
+
expect.objectContaining({
|
|
266
|
+
data: expect.anything(),
|
|
267
|
+
topics: expect.any(Array),
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("should handle bigint values correctly", async () => {
|
|
273
|
+
const largeValueEvent = {
|
|
274
|
+
eventName: "Transfer" as const,
|
|
275
|
+
args: {
|
|
276
|
+
from: "0x5034aa590125b64023a0262112b98d72e3c8e40e",
|
|
277
|
+
to: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
278
|
+
value: BigInt("123456789012345678901234567890"),
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
mockedABIEvent.parseLog.mockReturnValue(largeValueEvent);
|
|
282
|
+
|
|
283
|
+
const result = await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
284
|
+
|
|
285
|
+
expect(result[0].value).toEqual(new BigNumber("123456789012345678901234567890"));
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("should call getFees for each event", async () => {
|
|
289
|
+
await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
290
|
+
|
|
291
|
+
expect(mockedGetFees).toHaveBeenCalledTimes(1);
|
|
292
|
+
expect(mockedGetFees).toHaveBeenCalledWith("0xtx789");
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it("should handle multiple events", async () => {
|
|
296
|
+
const multipleEvents = [
|
|
297
|
+
mockEventLogs[0],
|
|
298
|
+
{
|
|
299
|
+
...mockEventLogs[0],
|
|
300
|
+
meta: { ...mockEventLogs[0].meta, txID: "0xtx790" },
|
|
301
|
+
},
|
|
302
|
+
];
|
|
303
|
+
|
|
304
|
+
await mapTokenTransfersToOperations(multipleEvents, mockAccountId, mockAddr);
|
|
305
|
+
|
|
306
|
+
expect(mockedGetFees).toHaveBeenCalledTimes(2);
|
|
307
|
+
expect(mockedABIEvent.parseLog).toHaveBeenCalledTimes(2);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("should handle case-insensitive address comparison for tokens", async () => {
|
|
311
|
+
const upperCaseEvent = {
|
|
312
|
+
eventName: "Transfer" as const,
|
|
313
|
+
args: {
|
|
314
|
+
from: "0x5034aa590125b64023a0262112b98d72e3c8e40e",
|
|
315
|
+
to: mockAddr.toUpperCase(),
|
|
316
|
+
value: BigInt("1000000000000000000"),
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
mockedABIEvent.parseLog.mockReturnValue(upperCaseEvent);
|
|
320
|
+
|
|
321
|
+
const result = await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
322
|
+
|
|
323
|
+
expect(result[0].type).toBe("IN");
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("should convert token addresses to lowercase", async () => {
|
|
327
|
+
const mixedCaseEvent = {
|
|
328
|
+
eventName: "Transfer" as const,
|
|
329
|
+
args: {
|
|
330
|
+
from: "0x5034AA590125B64023A0262112B98D72E3C8E40E",
|
|
331
|
+
to: "0x742D35CC6634C0532925A3B8D0B251D8C1743EC4",
|
|
332
|
+
value: BigInt("1000000000000000000"),
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
mockedABIEvent.parseLog.mockReturnValue(mixedCaseEvent);
|
|
336
|
+
|
|
337
|
+
const result = await mapTokenTransfersToOperations(mockEventLogs, mockAccountId, mockAddr);
|
|
338
|
+
|
|
339
|
+
expect(result[0].senders[0]).toBe("0x5034aa590125b64023a0262112b98d72e3c8e40e");
|
|
340
|
+
expect(result[0].recipients[0]).toBe("0x742d35cc6634c0532925a3b8d0b251d8c1743ec4");
|
|
341
|
+
});
|
|
342
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { Operation } from "@ledgerhq/types-live";
|
|
3
|
+
import { EventLog, TransferLog } from "../types";
|
|
4
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
5
|
+
import { getFees } from "../network";
|
|
6
|
+
import { ABIEvent, Hex, VIP180_ABI } from "@vechain/sdk-core";
|
|
7
|
+
|
|
8
|
+
export const mapVetTransfersToOperations = async (
|
|
9
|
+
txs: TransferLog[],
|
|
10
|
+
accountId: string,
|
|
11
|
+
addr: string,
|
|
12
|
+
): Promise<Operation[]> => {
|
|
13
|
+
return Promise.all(
|
|
14
|
+
txs.map(async tx => {
|
|
15
|
+
const fees = await getFees(tx.meta.txID);
|
|
16
|
+
return {
|
|
17
|
+
id: encodeOperationId(
|
|
18
|
+
accountId,
|
|
19
|
+
tx.meta.txID,
|
|
20
|
+
tx.recipient.toLowerCase() === addr.toLowerCase() ? "IN" : "OUT",
|
|
21
|
+
),
|
|
22
|
+
hash: tx.meta.txID,
|
|
23
|
+
type: tx.recipient.toLowerCase() === addr.toLowerCase() ? "IN" : "OUT",
|
|
24
|
+
value: new BigNumber(tx.amount),
|
|
25
|
+
fee: new BigNumber(fees),
|
|
26
|
+
senders: [tx.sender.toLowerCase()],
|
|
27
|
+
recipients: [tx.recipient.toLowerCase()],
|
|
28
|
+
blockHeight: tx.meta.blockNumber,
|
|
29
|
+
blockHash: tx.meta.blockID,
|
|
30
|
+
accountId,
|
|
31
|
+
date: new Date(tx.meta.blockTimestamp * 1000),
|
|
32
|
+
extra: {},
|
|
33
|
+
};
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const mapTokenTransfersToOperations = async (
|
|
39
|
+
events: EventLog[],
|
|
40
|
+
accountId: string,
|
|
41
|
+
addr: string,
|
|
42
|
+
): Promise<Operation[]> => {
|
|
43
|
+
return Promise.all(
|
|
44
|
+
events.map(async event => {
|
|
45
|
+
const decoded = ABIEvent.parseLog(VIP180_ABI, {
|
|
46
|
+
data: Hex.of(event.data),
|
|
47
|
+
topics: event.topics.map(topic => Hex.of(topic)),
|
|
48
|
+
}) as {
|
|
49
|
+
eventName: "Transfer";
|
|
50
|
+
args: {
|
|
51
|
+
from: string;
|
|
52
|
+
to: string;
|
|
53
|
+
value: bigint;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const from = decoded.args.from;
|
|
57
|
+
const to = decoded.args.to;
|
|
58
|
+
const value = decoded.args.value;
|
|
59
|
+
const type = to.toLowerCase() === addr.toLowerCase() ? "IN" : "OUT";
|
|
60
|
+
const fees = await getFees(event.meta.txID);
|
|
61
|
+
return {
|
|
62
|
+
id: encodeOperationId(accountId, event.meta.txID, type),
|
|
63
|
+
hash: event.meta.txID,
|
|
64
|
+
type,
|
|
65
|
+
value: new BigNumber(value.toString()),
|
|
66
|
+
fee: fees,
|
|
67
|
+
senders: [from.toLowerCase()],
|
|
68
|
+
recipients: [to.toLowerCase()],
|
|
69
|
+
blockHeight: event.meta.blockNumber,
|
|
70
|
+
blockHash: event.meta.blockID,
|
|
71
|
+
accountId,
|
|
72
|
+
date: new Date(event.meta.blockTimestamp * 1000),
|
|
73
|
+
extra: {},
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
};
|