@ledgerhq/coin-vechain 2.9.1 → 2.9.2-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.unimportedrc.json +16 -4
- package/CHANGELOG.md +11 -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 +10 -9
- 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,329 @@
|
|
|
1
|
+
import { signMessage } from "./signMessage";
|
|
2
|
+
import { VechainSDKTransaction, VechainSigner } from "../types";
|
|
3
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
4
|
+
|
|
5
|
+
// Mock dependencies
|
|
6
|
+
jest.mock("../types", () => ({
|
|
7
|
+
...jest.requireActual("../types"),
|
|
8
|
+
VechainSDKTransaction: {
|
|
9
|
+
of: jest.fn(),
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const mockedVechainSDKTransaction = jest.mocked(VechainSDKTransaction);
|
|
14
|
+
|
|
15
|
+
describe("signMessage", () => {
|
|
16
|
+
const mockDeviceId = "mock-device-id";
|
|
17
|
+
const mockPath = "44'/818'/0'/0/0";
|
|
18
|
+
|
|
19
|
+
const mockSigner: VechainSigner = {
|
|
20
|
+
getAddress: jest.fn(),
|
|
21
|
+
signTransaction: jest.fn(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const mockSignerContext: SignerContext<VechainSigner> = jest.fn();
|
|
25
|
+
|
|
26
|
+
const mockTransactionObject = {
|
|
27
|
+
chainTag: 74,
|
|
28
|
+
blockRef: "0x00000000000b2bce",
|
|
29
|
+
expiration: 18,
|
|
30
|
+
clauses: [
|
|
31
|
+
{
|
|
32
|
+
to: "0x456789012345678901234567890123456789abcd",
|
|
33
|
+
value: "1000000000000000000",
|
|
34
|
+
data: "0x",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
maxFeePerGas: 10000000000000,
|
|
38
|
+
maxPriorityFeePerGas: 1000000000000,
|
|
39
|
+
gas: 21000,
|
|
40
|
+
dependsOn: null,
|
|
41
|
+
nonce: "0x12345678",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const mockUnsignedTransaction = {
|
|
45
|
+
encoded: Buffer.from("mockencodedtransaction", "hex"),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
jest.clearAllMocks();
|
|
50
|
+
mockedVechainSDKTransaction.of.mockReturnValue(mockUnsignedTransaction as any);
|
|
51
|
+
(mockSigner.signTransaction as jest.Mock).mockResolvedValue(Buffer.from("signature123", "hex"));
|
|
52
|
+
(mockSignerContext as jest.Mock).mockImplementation((deviceId, callback) =>
|
|
53
|
+
callback(mockSigner),
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("message parsing", () => {
|
|
58
|
+
it("should parse valid JSON message", async () => {
|
|
59
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
60
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
61
|
+
|
|
62
|
+
const result = await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
63
|
+
|
|
64
|
+
// JSON parsing is handled internally by the function
|
|
65
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
|
|
66
|
+
expect(result).toBe("");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should parse valid JSON rawMessage when message is empty", async () => {
|
|
70
|
+
const rawMessage = JSON.stringify(mockTransactionObject);
|
|
71
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
72
|
+
|
|
73
|
+
const result = await signMessageFn(mockDeviceId, mockPath, "", rawMessage);
|
|
74
|
+
|
|
75
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
|
|
76
|
+
expect(result).toBe("");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should prefer message over rawMessage when both are provided", async () => {
|
|
80
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
81
|
+
const differentRawMessage = JSON.stringify({ different: "object" });
|
|
82
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
83
|
+
|
|
84
|
+
await signMessageFn(mockDeviceId, mockPath, message, differentRawMessage);
|
|
85
|
+
|
|
86
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("should throw error for invalid JSON message", async () => {
|
|
90
|
+
const invalidMessage = "invalid json {";
|
|
91
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
92
|
+
|
|
93
|
+
await expect(signMessageFn(mockDeviceId, mockPath, invalidMessage, "")).rejects.toThrow(
|
|
94
|
+
"Message is not a valid JSON object",
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should throw error for invalid JSON rawMessage", async () => {
|
|
99
|
+
const invalidRawMessage = "invalid json {";
|
|
100
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
101
|
+
|
|
102
|
+
await expect(signMessageFn(mockDeviceId, mockPath, "", invalidRawMessage)).rejects.toThrow(
|
|
103
|
+
"Message is not a valid JSON object",
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("should throw error when both message and rawMessage are empty", async () => {
|
|
108
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
109
|
+
|
|
110
|
+
await expect(signMessageFn(mockDeviceId, mockPath, "", "")).rejects.toThrow(
|
|
111
|
+
"Message is not a valid JSON object",
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("transaction creation", () => {
|
|
117
|
+
it("should create VechainSDKTransaction from parsed object", async () => {
|
|
118
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
119
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
120
|
+
|
|
121
|
+
await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
122
|
+
|
|
123
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("should handle VechainSDKTransaction creation errors", async () => {
|
|
127
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
128
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
129
|
+
|
|
130
|
+
mockedVechainSDKTransaction.of.mockImplementation(() => {
|
|
131
|
+
throw new Error("Invalid transaction");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
await expect(signMessageFn(mockDeviceId, mockPath, message, "")).rejects.toThrow(
|
|
135
|
+
"Message is not a valid JSON object",
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("should handle different transaction structures", async () => {
|
|
140
|
+
const tokenTransaction = {
|
|
141
|
+
...mockTransactionObject,
|
|
142
|
+
clauses: [
|
|
143
|
+
{
|
|
144
|
+
to: "0x0000000000000000000000000000456e65726779",
|
|
145
|
+
value: "0",
|
|
146
|
+
data: "0xa9059cbb000000000000000000000000456789012345678901234567890123456789abcd0000000000000000000000000000000000000000000000000de0b6b3a7640000",
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const message = JSON.stringify(tokenTransaction);
|
|
152
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
153
|
+
|
|
154
|
+
await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
155
|
+
|
|
156
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(tokenTransaction);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe("signing process", () => {
|
|
161
|
+
it("should call signer with correct parameters", async () => {
|
|
162
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
163
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
164
|
+
|
|
165
|
+
await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
166
|
+
|
|
167
|
+
expect(mockSignerContext).toHaveBeenCalledWith(mockDeviceId, expect.any(Function));
|
|
168
|
+
expect(mockSigner.signTransaction).toHaveBeenCalledWith(
|
|
169
|
+
mockPath,
|
|
170
|
+
mockUnsignedTransaction.encoded.toString("hex"),
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should convert encoded transaction to hex string", async () => {
|
|
175
|
+
const customEncoded = Buffer.from("customtransaction", "utf8");
|
|
176
|
+
const customUnsigned = { encoded: customEncoded };
|
|
177
|
+
mockedVechainSDKTransaction.of.mockReturnValue(customUnsigned as any);
|
|
178
|
+
|
|
179
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
180
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
181
|
+
|
|
182
|
+
await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
183
|
+
|
|
184
|
+
expect(mockSigner.signTransaction).toHaveBeenCalledWith(
|
|
185
|
+
mockPath,
|
|
186
|
+
customEncoded.toString("hex"),
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("should return signature as hex string", async () => {
|
|
191
|
+
const signatureBuffer = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
192
|
+
(mockSigner.signTransaction as jest.Mock).mockResolvedValue(signatureBuffer);
|
|
193
|
+
|
|
194
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
195
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
196
|
+
|
|
197
|
+
const result = await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
198
|
+
|
|
199
|
+
expect(result).toBe("12345678");
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should handle signer errors", async () => {
|
|
203
|
+
const signerError = new Error("Hardware wallet error");
|
|
204
|
+
(mockSigner.signTransaction as jest.Mock).mockRejectedValue(signerError);
|
|
205
|
+
|
|
206
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
207
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
208
|
+
|
|
209
|
+
await expect(signMessageFn(mockDeviceId, mockPath, message, "")).rejects.toThrow(
|
|
210
|
+
"Hardware wallet error",
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("should handle signerContext errors", async () => {
|
|
215
|
+
const contextError = new Error("Signer context failed");
|
|
216
|
+
(mockSignerContext as jest.Mock).mockRejectedValue(contextError);
|
|
217
|
+
|
|
218
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
219
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
220
|
+
|
|
221
|
+
await expect(signMessageFn(mockDeviceId, mockPath, message, "")).rejects.toThrow(
|
|
222
|
+
"Signer context failed",
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
describe("different input scenarios", () => {
|
|
228
|
+
it("should handle different device IDs", async () => {
|
|
229
|
+
const deviceIds = ["device1", "device2", "device3"];
|
|
230
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
231
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
232
|
+
|
|
233
|
+
for (const deviceId of deviceIds) {
|
|
234
|
+
await signMessageFn(deviceId, mockPath, message, "");
|
|
235
|
+
expect(mockSignerContext).toHaveBeenCalledWith(deviceId, expect.any(Function));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("should handle different derivation paths", async () => {
|
|
240
|
+
const paths = ["44'/818'/0'/0/0", "44'/818'/1'/0/0", "44'/818'/0'/0/1"];
|
|
241
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
242
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
243
|
+
|
|
244
|
+
for (const path of paths) {
|
|
245
|
+
await signMessageFn(mockDeviceId, path, message, "");
|
|
246
|
+
expect(mockSigner.signTransaction).toHaveBeenCalledWith(path, expect.any(String));
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("should handle complex transaction objects", async () => {
|
|
251
|
+
const complexTransaction = {
|
|
252
|
+
...mockTransactionObject,
|
|
253
|
+
clauses: [
|
|
254
|
+
{
|
|
255
|
+
to: "0x456789012345678901234567890123456789abcd",
|
|
256
|
+
value: "1000000000000000000",
|
|
257
|
+
data: "0x",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
to: "0x0000000000000000000000000000456e65726779",
|
|
261
|
+
value: "0",
|
|
262
|
+
data: "0xa9059cbb",
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
dependsOn: "0xprevious123",
|
|
266
|
+
gas: 50000,
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const message = JSON.stringify(complexTransaction);
|
|
270
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
271
|
+
|
|
272
|
+
await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
273
|
+
|
|
274
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(complexTransaction);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should handle minimal transaction objects", async () => {
|
|
278
|
+
const minimalTransaction = {
|
|
279
|
+
chainTag: 74,
|
|
280
|
+
blockRef: "0x0000000000000000",
|
|
281
|
+
expiration: 18,
|
|
282
|
+
clauses: [],
|
|
283
|
+
maxFeePerGas: 0,
|
|
284
|
+
maxPriorityFeePerGas: 0,
|
|
285
|
+
gas: 0,
|
|
286
|
+
dependsOn: null,
|
|
287
|
+
nonce: "0x00000000",
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const message = JSON.stringify(minimalTransaction);
|
|
291
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
292
|
+
|
|
293
|
+
await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
294
|
+
|
|
295
|
+
expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(minimalTransaction);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
describe("signature formatting", () => {
|
|
300
|
+
it("should handle different signature lengths", async () => {
|
|
301
|
+
const signatures = [
|
|
302
|
+
Buffer.from("12", "hex"),
|
|
303
|
+
Buffer.from("1234567890abcdef", "hex"),
|
|
304
|
+
Buffer.from("ff".repeat(32), "hex"),
|
|
305
|
+
];
|
|
306
|
+
|
|
307
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
308
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
309
|
+
|
|
310
|
+
for (const signature of signatures) {
|
|
311
|
+
(mockSigner.signTransaction as jest.Mock).mockResolvedValueOnce(signature);
|
|
312
|
+
const result = await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
313
|
+
expect(result).toBe(signature.toString("hex"));
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it("should handle empty signature buffer", async () => {
|
|
318
|
+
const emptySignature = Buffer.alloc(0);
|
|
319
|
+
(mockSigner.signTransaction as jest.Mock).mockResolvedValue(emptySignature);
|
|
320
|
+
|
|
321
|
+
const message = JSON.stringify(mockTransactionObject);
|
|
322
|
+
const signMessageFn = signMessage(mockSignerContext);
|
|
323
|
+
|
|
324
|
+
const result = await signMessageFn(mockDeviceId, mockPath, message, "");
|
|
325
|
+
|
|
326
|
+
expect(result).toBe("");
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { Transaction as ThorTransaction } from "thor-devkit";
|
|
2
1
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
3
|
-
import { VechainSigner } from "../types";
|
|
2
|
+
import { VechainSDKTransaction, VechainSigner } from "../types";
|
|
4
3
|
|
|
5
4
|
export const signMessage =
|
|
6
5
|
(signerContext: SignerContext<VechainSigner>) =>
|
|
7
6
|
async (deviceId: string, path: string, message: string, rawMessage: string) => {
|
|
8
7
|
let messageObj;
|
|
9
|
-
let unsigned:
|
|
8
|
+
let unsigned: VechainSDKTransaction;
|
|
10
9
|
try {
|
|
11
10
|
if (message) messageObj = JSON.parse(message);
|
|
12
11
|
else messageObj = JSON.parse(rawMessage);
|
|
13
|
-
unsigned =
|
|
12
|
+
unsigned = VechainSDKTransaction.of(messageObj);
|
|
14
13
|
} catch (e) {
|
|
15
14
|
throw new Error("Message is not a valid JSON object");
|
|
16
15
|
}
|
|
17
16
|
const result = await signerContext(deviceId, signer =>
|
|
18
|
-
signer.signTransaction(path, unsigned.
|
|
17
|
+
signer.signTransaction(path, Buffer.from(unsigned.encoded).toString("hex")),
|
|
19
18
|
);
|
|
20
19
|
|
|
21
20
|
return result.toString("hex");
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AccountRaw,
|
|
4
|
+
CurrenciesData,
|
|
5
|
+
DatasetTest,
|
|
6
|
+
TransactionStatusCommon,
|
|
7
|
+
} from "@ledgerhq/types-live";
|
|
3
8
|
import type { Transaction } from "../types";
|
|
4
9
|
import { fromTransactionRaw } from "../bridge/transaction";
|
|
5
|
-
import {
|
|
10
|
+
import { MAINNET_CHAIN_TAG } from "../types";
|
|
6
11
|
import { vechain1, vechain3 } from "../datasets";
|
|
7
12
|
import { generateNonce } from "../common-logic";
|
|
8
13
|
|
|
9
14
|
import vechainScanAccounts1 from "../datasets/vechain.scanAccounts.1";
|
|
10
15
|
import { AmountRequired, NotEnoughBalance } from "@ledgerhq/errors";
|
|
11
|
-
import VIP180 from "../contracts/abis/VIP180";
|
|
12
16
|
import { CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
13
17
|
import { NotEnoughVTHO } from "../errors";
|
|
14
18
|
import {
|
|
@@ -16,6 +20,7 @@ import {
|
|
|
16
20
|
setSupportedCurrencies,
|
|
17
21
|
} from "@ledgerhq/coin-framework/currencies/index";
|
|
18
22
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
23
|
+
import { ABIContract, VIP180_ABI } from "@vechain/sdk-core";
|
|
19
24
|
|
|
20
25
|
const listSupported = listSupportedCurrencies();
|
|
21
26
|
listSupported.push(getCryptoCurrencyById("vechain"));
|
|
@@ -36,7 +41,7 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
36
41
|
family: "vechain",
|
|
37
42
|
estimatedFees: "210000000000000000",
|
|
38
43
|
recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
39
|
-
amount:
|
|
44
|
+
amount: (1e18).toString(), // 1 VET
|
|
40
45
|
body: {
|
|
41
46
|
chainTag: MAINNET_CHAIN_TAG,
|
|
42
47
|
blockRef: "0x00634a0c856ec1db",
|
|
@@ -44,22 +49,26 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
44
49
|
clauses: [
|
|
45
50
|
{
|
|
46
51
|
to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
47
|
-
value:
|
|
52
|
+
value: (1e18).toString(), // 1 VET
|
|
48
53
|
data: "0x",
|
|
49
54
|
},
|
|
50
55
|
],
|
|
51
|
-
gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
|
|
52
56
|
gas: "0",
|
|
57
|
+
maxFeePerGas: 0,
|
|
58
|
+
maxPriorityFeePerGas: 0,
|
|
53
59
|
dependsOn: null,
|
|
54
60
|
nonce: generateNonce(),
|
|
55
61
|
},
|
|
56
62
|
}),
|
|
57
|
-
expectedStatus: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
|
|
64
|
+
const estimatedFees = status.estimatedFees;
|
|
65
|
+
return {
|
|
66
|
+
amount: new BigNumber(1e18), // 1 VET
|
|
67
|
+
estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
|
|
68
|
+
totalSpent: new BigNumber(1e18),
|
|
69
|
+
errors: {},
|
|
70
|
+
warnings: {},
|
|
71
|
+
};
|
|
63
72
|
},
|
|
64
73
|
},
|
|
65
74
|
{
|
|
@@ -70,7 +79,7 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
70
79
|
"js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain+vechain%2Fvip180%2Fvtho",
|
|
71
80
|
estimatedFees: "515180000000000000",
|
|
72
81
|
recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
73
|
-
amount:
|
|
82
|
+
amount: (1e19).toString(), // 10 VTHO
|
|
74
83
|
body: {
|
|
75
84
|
chainTag: MAINNET_CHAIN_TAG,
|
|
76
85
|
blockRef: "0x00634a0c856ec1db",
|
|
@@ -79,24 +88,30 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
79
88
|
{
|
|
80
89
|
to: "0x0000000000000000000000000000456e65726779",
|
|
81
90
|
value: 0,
|
|
82
|
-
data:
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
data: ABIContract.ofAbi(VIP180_ABI)
|
|
92
|
+
.encodeFunctionInput("transfer", [
|
|
93
|
+
"0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
94
|
+
"9000000000000000000",
|
|
95
|
+
])
|
|
96
|
+
.toString(),
|
|
86
97
|
},
|
|
87
98
|
],
|
|
88
|
-
gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
|
|
89
99
|
gas: "0",
|
|
100
|
+
maxFeePerGas: 0,
|
|
101
|
+
maxPriorityFeePerGas: 0,
|
|
90
102
|
dependsOn: null,
|
|
91
103
|
nonce: generateNonce(),
|
|
92
104
|
},
|
|
93
105
|
}),
|
|
94
|
-
expectedStatus: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
|
|
107
|
+
const estimatedFees = status.estimatedFees;
|
|
108
|
+
return {
|
|
109
|
+
amount: new BigNumber(1e19), // 10 VTHO
|
|
110
|
+
estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
|
|
111
|
+
totalSpent: new BigNumber(1e19).plus(estimatedFees), // fees are calculated during preparation and therefore cannot be guessed without mocks
|
|
112
|
+
errors: {},
|
|
113
|
+
warnings: {},
|
|
114
|
+
};
|
|
100
115
|
},
|
|
101
116
|
},
|
|
102
117
|
{
|
|
@@ -111,8 +126,9 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
111
126
|
blockRef: "0x00634a0c856ec1db",
|
|
112
127
|
expiration: 18,
|
|
113
128
|
clauses: [{ to: "", value: 0, data: "0x" }],
|
|
114
|
-
gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
|
|
115
129
|
gas: "0",
|
|
130
|
+
maxFeePerGas: 0,
|
|
131
|
+
maxPriorityFeePerGas: 0,
|
|
116
132
|
dependsOn: null,
|
|
117
133
|
nonce: generateNonce(),
|
|
118
134
|
},
|
|
@@ -130,7 +146,7 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
130
146
|
family: "vechain",
|
|
131
147
|
estimatedFees: "210000000000000000",
|
|
132
148
|
recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
133
|
-
amount:
|
|
149
|
+
amount: (2e19).toString(), // 20 VET
|
|
134
150
|
body: {
|
|
135
151
|
chainTag: MAINNET_CHAIN_TAG,
|
|
136
152
|
blockRef: "0x00634a0c856ec1db",
|
|
@@ -138,24 +154,28 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
138
154
|
clauses: [
|
|
139
155
|
{
|
|
140
156
|
to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
141
|
-
value:
|
|
157
|
+
value: (2e19).toString(), // 20 VET
|
|
142
158
|
data: "0x",
|
|
143
159
|
},
|
|
144
160
|
],
|
|
145
|
-
gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
|
|
146
161
|
gas: "0",
|
|
162
|
+
maxFeePerGas: 0,
|
|
163
|
+
maxPriorityFeePerGas: 0,
|
|
147
164
|
dependsOn: null,
|
|
148
165
|
nonce: generateNonce(),
|
|
149
166
|
},
|
|
150
167
|
}),
|
|
151
|
-
expectedStatus: {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
amount: new
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
|
|
169
|
+
const estimatedFees = status.estimatedFees;
|
|
170
|
+
return {
|
|
171
|
+
amount: new BigNumber(2e19), // 20 VET
|
|
172
|
+
errors: {
|
|
173
|
+
amount: new NotEnoughBalance(),
|
|
174
|
+
},
|
|
175
|
+
warnings: {},
|
|
176
|
+
totalSpent: new BigNumber(2e19),
|
|
177
|
+
estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
|
|
178
|
+
};
|
|
159
179
|
},
|
|
160
180
|
},
|
|
161
181
|
{
|
|
@@ -166,7 +186,7 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
166
186
|
"js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain+vechain%2Fvip180%2Fvtho",
|
|
167
187
|
estimatedFees: "515820000000000000",
|
|
168
188
|
recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
169
|
-
amount:
|
|
189
|
+
amount: (2e19).toString(), // 20 VTHO
|
|
170
190
|
body: {
|
|
171
191
|
chainTag: MAINNET_CHAIN_TAG,
|
|
172
192
|
blockRef: "0x00634a0c856ec1db",
|
|
@@ -174,24 +194,28 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
174
194
|
clauses: [
|
|
175
195
|
{
|
|
176
196
|
to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
177
|
-
value:
|
|
197
|
+
value: (2e19).toString(), // 20 VTHO
|
|
178
198
|
data: "0x",
|
|
179
199
|
},
|
|
180
200
|
],
|
|
181
|
-
gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
|
|
182
201
|
gas: "0",
|
|
202
|
+
maxFeePerGas: 0,
|
|
203
|
+
maxPriorityFeePerGas: 0,
|
|
183
204
|
dependsOn: null,
|
|
184
205
|
nonce: generateNonce(),
|
|
185
206
|
},
|
|
186
207
|
}),
|
|
187
|
-
expectedStatus: {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
amount: new
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
208
|
+
expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
|
|
209
|
+
const estimatedFees = status.estimatedFees;
|
|
210
|
+
return {
|
|
211
|
+
amount: new BigNumber(2e19), // 20 VTHO
|
|
212
|
+
errors: {
|
|
213
|
+
amount: new NotEnoughBalance(),
|
|
214
|
+
},
|
|
215
|
+
warnings: {},
|
|
216
|
+
totalSpent: new BigNumber(2e19).plus(estimatedFees),
|
|
217
|
+
estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
|
|
218
|
+
};
|
|
195
219
|
},
|
|
196
220
|
},
|
|
197
221
|
],
|
|
@@ -211,7 +235,7 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
211
235
|
family: "vechain",
|
|
212
236
|
estimatedFees: "210000000000000000",
|
|
213
237
|
recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
214
|
-
amount:
|
|
238
|
+
amount: (1e18).toString(), // 1 VET
|
|
215
239
|
body: {
|
|
216
240
|
chainTag: MAINNET_CHAIN_TAG,
|
|
217
241
|
blockRef: "0x00634a0c856ec1db",
|
|
@@ -219,24 +243,28 @@ const vechain: CurrenciesData<Transaction> = {
|
|
|
219
243
|
clauses: [
|
|
220
244
|
{
|
|
221
245
|
to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
|
|
222
|
-
value:
|
|
246
|
+
value: (1e18).toString(),
|
|
223
247
|
data: "0x",
|
|
224
248
|
},
|
|
225
249
|
],
|
|
226
|
-
gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
|
|
227
250
|
gas: "0",
|
|
251
|
+
maxFeePerGas: 0,
|
|
252
|
+
maxPriorityFeePerGas: 0,
|
|
228
253
|
dependsOn: null,
|
|
229
254
|
nonce: generateNonce(),
|
|
230
255
|
},
|
|
231
256
|
}),
|
|
232
|
-
expectedStatus: {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
257
|
+
expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
|
|
258
|
+
const estimatedFees = status.estimatedFees;
|
|
259
|
+
return {
|
|
260
|
+
amount: new BigNumber(1e18), // 1 VET
|
|
261
|
+
estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
|
|
262
|
+
totalSpent: new BigNumber(1e18),
|
|
263
|
+
errors: {
|
|
264
|
+
amount: new NotEnoughVTHO(),
|
|
265
|
+
},
|
|
266
|
+
warnings: {},
|
|
267
|
+
};
|
|
240
268
|
},
|
|
241
269
|
},
|
|
242
270
|
],
|
package/src/test/cli.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import flatMap from "lodash/flatMap";
|
|
2
2
|
import { Transaction, Transaction as VechainTransaction } from "../types";
|
|
3
3
|
import type { Account, AccountLike } from "@ledgerhq/types-live";
|
|
4
|
-
import { VTHO_ADDRESS } from "../contracts/constants";
|
|
5
|
-
import VIP180 from "../contracts/abis/VIP180";
|
|
6
4
|
import { MustBeVechain } from "../errors";
|
|
5
|
+
import { ABIContract, VIP180_ABI, VTHO_ADDRESS } from "@vechain/sdk-core";
|
|
7
6
|
|
|
8
7
|
type CliTools = {
|
|
9
8
|
options: Array<{
|
|
@@ -63,7 +62,9 @@ function inferTransactions(
|
|
|
63
62
|
clauses.push({
|
|
64
63
|
value: 0,
|
|
65
64
|
to: VTHO_ADDRESS,
|
|
66
|
-
data:
|
|
65
|
+
data: ABIContract.ofAbi(VIP180_ABI)
|
|
66
|
+
.encodeFunctionInput("transfer", [transaction.recipient, transaction.amount.toFixed()])
|
|
67
|
+
.toString(),
|
|
67
68
|
});
|
|
68
69
|
} else {
|
|
69
70
|
throw new MustBeVechain();
|