@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,454 @@
|
|
|
1
|
+
import resolver from "./getAddress";
|
|
2
|
+
import { VechainSigner } from "../types";
|
|
3
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
4
|
+
import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
|
|
5
|
+
import eip55 from "eip55";
|
|
6
|
+
|
|
7
|
+
// Mock dependencies
|
|
8
|
+
jest.mock("eip55");
|
|
9
|
+
|
|
10
|
+
const mockedEip55 = jest.mocked(eip55);
|
|
11
|
+
|
|
12
|
+
describe("getAddress resolver", () => {
|
|
13
|
+
const mockDeviceId = "mock-device-id";
|
|
14
|
+
const mockPath = "44'/818'/0'/0/0";
|
|
15
|
+
|
|
16
|
+
const mockSigner: VechainSigner = {
|
|
17
|
+
getAddress: jest.fn(),
|
|
18
|
+
signTransaction: jest.fn(),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const mockSignerContext: SignerContext<VechainSigner> = jest.fn();
|
|
22
|
+
|
|
23
|
+
const mockSignerResponse = {
|
|
24
|
+
address: "0x742d35cc6634c0532925a3b8d0b251d8c1743ec4",
|
|
25
|
+
publicKey: Buffer.from(
|
|
26
|
+
"04abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab",
|
|
27
|
+
"hex",
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(mockSignerResponse);
|
|
34
|
+
(mockSignerContext as jest.Mock).mockImplementation((deviceId, callback) =>
|
|
35
|
+
callback(mockSigner),
|
|
36
|
+
);
|
|
37
|
+
mockedEip55.encode.mockReturnValue("0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("basic functionality", () => {
|
|
41
|
+
it("should get address with verify false", async () => {
|
|
42
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
43
|
+
const options: GetAddressOptions = {
|
|
44
|
+
path: mockPath,
|
|
45
|
+
verify: false,
|
|
46
|
+
currency: {} as any,
|
|
47
|
+
derivationMode: "" as any,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
51
|
+
|
|
52
|
+
expect(result).toEqual({
|
|
53
|
+
address: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
54
|
+
publicKey: mockSignerResponse.publicKey,
|
|
55
|
+
path: mockPath,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(mockSigner.getAddress).toHaveBeenCalledWith(mockPath, false, false);
|
|
59
|
+
expect(mockedEip55.encode).toHaveBeenCalledWith(mockSignerResponse.address);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should get address with verify true", async () => {
|
|
63
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
64
|
+
const options: GetAddressOptions = {
|
|
65
|
+
path: mockPath,
|
|
66
|
+
verify: true,
|
|
67
|
+
currency: {} as any,
|
|
68
|
+
derivationMode: "" as any,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
72
|
+
|
|
73
|
+
expect(result).toEqual({
|
|
74
|
+
address: "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4",
|
|
75
|
+
publicKey: mockSignerResponse.publicKey,
|
|
76
|
+
path: mockPath,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expect(mockSigner.getAddress).toHaveBeenCalledWith(mockPath, true, false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should always pass false as third parameter (askChainCode)", async () => {
|
|
83
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
84
|
+
const options: GetAddressOptions = {
|
|
85
|
+
path: mockPath,
|
|
86
|
+
verify: true,
|
|
87
|
+
currency: {} as any,
|
|
88
|
+
derivationMode: "" as any,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
await getAddressFn(mockDeviceId, options);
|
|
92
|
+
|
|
93
|
+
expect(mockSigner.getAddress).toHaveBeenCalledWith(mockPath, true, false);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("address encoding", () => {
|
|
98
|
+
it("should encode address using eip55", async () => {
|
|
99
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
100
|
+
const options: GetAddressOptions = {
|
|
101
|
+
path: mockPath,
|
|
102
|
+
verify: false,
|
|
103
|
+
currency: {} as any,
|
|
104
|
+
derivationMode: "" as any,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
await getAddressFn(mockDeviceId, options);
|
|
108
|
+
|
|
109
|
+
expect(mockedEip55.encode).toHaveBeenCalledWith(mockSignerResponse.address);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("should handle different address formats from signer", async () => {
|
|
113
|
+
const addresses = [
|
|
114
|
+
"0x742d35cc6634c0532925a3b8d0b251d8c1743ec4",
|
|
115
|
+
"0X742D35CC6634C0532925A3B8D0B251D8C1743EC4",
|
|
116
|
+
"742d35cc6634c0532925a3b8d0b251d8c1743ec4",
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
120
|
+
const options: GetAddressOptions = {
|
|
121
|
+
path: mockPath,
|
|
122
|
+
verify: false,
|
|
123
|
+
currency: {} as any,
|
|
124
|
+
derivationMode: "" as any,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
for (const address of addresses) {
|
|
128
|
+
const customResponse = { ...mockSignerResponse, address };
|
|
129
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValueOnce(customResponse);
|
|
130
|
+
mockedEip55.encode.mockReturnValueOnce(`0x${address.replace(/^0x/i, "")}`);
|
|
131
|
+
|
|
132
|
+
await getAddressFn(mockDeviceId, options);
|
|
133
|
+
|
|
134
|
+
expect(mockedEip55.encode).toHaveBeenCalledWith(address);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("should return encoded address from eip55", async () => {
|
|
139
|
+
const encodedAddress = "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4";
|
|
140
|
+
mockedEip55.encode.mockReturnValue(encodedAddress);
|
|
141
|
+
|
|
142
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
143
|
+
const options: GetAddressOptions = {
|
|
144
|
+
path: mockPath,
|
|
145
|
+
verify: false,
|
|
146
|
+
currency: {} as any,
|
|
147
|
+
derivationMode: "" as any,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
151
|
+
|
|
152
|
+
expect(result.address).toBe(encodedAddress);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("error handling", () => {
|
|
157
|
+
it("should throw error when address is empty", async () => {
|
|
158
|
+
const invalidResponse = { ...mockSignerResponse, address: "" };
|
|
159
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(invalidResponse);
|
|
160
|
+
|
|
161
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
162
|
+
const options: GetAddressOptions = {
|
|
163
|
+
path: mockPath,
|
|
164
|
+
verify: false,
|
|
165
|
+
currency: {} as any,
|
|
166
|
+
derivationMode: "" as any,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow(
|
|
170
|
+
"[vechain] Response is empty ",
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should throw error when address is null", async () => {
|
|
175
|
+
const invalidResponse = { ...mockSignerResponse, address: null };
|
|
176
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(invalidResponse);
|
|
177
|
+
|
|
178
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
179
|
+
const options: GetAddressOptions = {
|
|
180
|
+
path: mockPath,
|
|
181
|
+
verify: false,
|
|
182
|
+
currency: {} as any,
|
|
183
|
+
derivationMode: "" as any,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow(
|
|
187
|
+
"[vechain] Response is empty null ",
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("should throw error when address is undefined", async () => {
|
|
192
|
+
const invalidResponse = { ...mockSignerResponse, address: undefined };
|
|
193
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(invalidResponse);
|
|
194
|
+
|
|
195
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
196
|
+
const options: GetAddressOptions = {
|
|
197
|
+
path: mockPath,
|
|
198
|
+
verify: false,
|
|
199
|
+
currency: {} as any,
|
|
200
|
+
derivationMode: "" as any,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow(
|
|
204
|
+
"[vechain] Response is empty undefined ",
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("should throw error when publicKey is empty", async () => {
|
|
209
|
+
const invalidResponse = { ...mockSignerResponse, publicKey: Buffer.alloc(0) };
|
|
210
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(invalidResponse);
|
|
211
|
+
|
|
212
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
213
|
+
const options: GetAddressOptions = {
|
|
214
|
+
path: mockPath,
|
|
215
|
+
verify: false,
|
|
216
|
+
currency: {} as any,
|
|
217
|
+
derivationMode: "" as any,
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow(
|
|
221
|
+
"[vechain] Response is empty",
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("should handle signer errors", async () => {
|
|
226
|
+
const signerError = new Error("Hardware wallet error");
|
|
227
|
+
(mockSigner.getAddress as jest.Mock).mockRejectedValue(signerError);
|
|
228
|
+
|
|
229
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
230
|
+
const options: GetAddressOptions = {
|
|
231
|
+
path: mockPath,
|
|
232
|
+
verify: false,
|
|
233
|
+
currency: {} as any,
|
|
234
|
+
derivationMode: "" as any,
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow("Hardware wallet error");
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("should handle signerContext errors", async () => {
|
|
241
|
+
const contextError = new Error("Signer context failed");
|
|
242
|
+
(mockSignerContext as jest.Mock).mockRejectedValue(contextError);
|
|
243
|
+
|
|
244
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
245
|
+
const options: GetAddressOptions = {
|
|
246
|
+
path: mockPath,
|
|
247
|
+
verify: false,
|
|
248
|
+
currency: {} as any,
|
|
249
|
+
derivationMode: "" as any,
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow("Signer context failed");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("should handle eip55 encoding errors", async () => {
|
|
256
|
+
// Reset the mock to not throw an error initially
|
|
257
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(mockSignerResponse);
|
|
258
|
+
|
|
259
|
+
const encodingError = new Error("Invalid address format");
|
|
260
|
+
mockedEip55.encode.mockImplementation(() => {
|
|
261
|
+
throw encodingError;
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
265
|
+
const options: GetAddressOptions = {
|
|
266
|
+
path: mockPath,
|
|
267
|
+
verify: false,
|
|
268
|
+
currency: {} as any,
|
|
269
|
+
derivationMode: "" as any,
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
await expect(getAddressFn(mockDeviceId, options)).rejects.toThrow("Invalid address format");
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe("different derivation paths", () => {
|
|
277
|
+
it("should handle different derivation paths", async () => {
|
|
278
|
+
const paths = ["44'/818'/0'/0/0", "44'/818'/1'/0/0", "44'/818'/0'/0/1", "44'/818'/2'/0/5"];
|
|
279
|
+
|
|
280
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
281
|
+
|
|
282
|
+
for (const path of paths) {
|
|
283
|
+
const options: GetAddressOptions = {
|
|
284
|
+
path,
|
|
285
|
+
verify: false,
|
|
286
|
+
currency: {} as any,
|
|
287
|
+
derivationMode: "" as any,
|
|
288
|
+
};
|
|
289
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
290
|
+
|
|
291
|
+
expect(mockSigner.getAddress).toHaveBeenCalledWith(path, false, false);
|
|
292
|
+
expect(result.path).toBe(path);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("should handle empty path", async () => {
|
|
297
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
298
|
+
const options: GetAddressOptions = {
|
|
299
|
+
path: "",
|
|
300
|
+
verify: false,
|
|
301
|
+
currency: {} as any,
|
|
302
|
+
derivationMode: "" as any,
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
await getAddressFn(mockDeviceId, options);
|
|
306
|
+
|
|
307
|
+
expect(mockSigner.getAddress).toHaveBeenCalledWith("", false, false);
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
describe("different device IDs", () => {
|
|
312
|
+
it("should handle different device IDs", async () => {
|
|
313
|
+
const deviceIds = ["device1", "device2", "device3"];
|
|
314
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
315
|
+
const options: GetAddressOptions = {
|
|
316
|
+
path: mockPath,
|
|
317
|
+
verify: false,
|
|
318
|
+
currency: {} as any,
|
|
319
|
+
derivationMode: "" as any,
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
for (const deviceId of deviceIds) {
|
|
323
|
+
await getAddressFn(deviceId, options);
|
|
324
|
+
expect(mockSignerContext).toHaveBeenCalledWith(deviceId, expect.any(Function));
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe("publicKey handling", () => {
|
|
330
|
+
it("should return publicKey from signer response", async () => {
|
|
331
|
+
const customPublicKey = Buffer.from("abcdef1234567890", "hex"); // Valid hex with length > 0
|
|
332
|
+
const customResponse = { ...mockSignerResponse, publicKey: customPublicKey };
|
|
333
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(customResponse);
|
|
334
|
+
|
|
335
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
336
|
+
const options: GetAddressOptions = {
|
|
337
|
+
path: mockPath,
|
|
338
|
+
verify: false,
|
|
339
|
+
currency: {} as any,
|
|
340
|
+
derivationMode: "" as any,
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
344
|
+
|
|
345
|
+
expect(result.publicKey).toBe(customPublicKey);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("should handle different publicKey lengths", async () => {
|
|
349
|
+
const publicKeys = [
|
|
350
|
+
Buffer.from("12", "hex"),
|
|
351
|
+
Buffer.from("1234567890abcdef", "hex"),
|
|
352
|
+
Buffer.from("04" + "ab".repeat(32) + "cd".repeat(32), "hex"), // 65 bytes (uncompressed)
|
|
353
|
+
];
|
|
354
|
+
|
|
355
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
356
|
+
const options: GetAddressOptions = {
|
|
357
|
+
path: mockPath,
|
|
358
|
+
verify: false,
|
|
359
|
+
currency: {} as any,
|
|
360
|
+
derivationMode: "" as any,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
for (const publicKey of publicKeys) {
|
|
364
|
+
const customResponse = { ...mockSignerResponse, publicKey };
|
|
365
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValueOnce(customResponse);
|
|
366
|
+
|
|
367
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
368
|
+
|
|
369
|
+
expect(result.publicKey).toBe(publicKey);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
describe("verify parameter behavior", () => {
|
|
375
|
+
it("should pass verify parameter correctly to signer", async () => {
|
|
376
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
377
|
+
|
|
378
|
+
// Test verify: true
|
|
379
|
+
await getAddressFn(mockDeviceId, {
|
|
380
|
+
path: mockPath,
|
|
381
|
+
verify: true,
|
|
382
|
+
currency: {} as any,
|
|
383
|
+
derivationMode: "" as any,
|
|
384
|
+
});
|
|
385
|
+
expect(mockSigner.getAddress).toHaveBeenLastCalledWith(mockPath, true, false);
|
|
386
|
+
|
|
387
|
+
// Test verify: false
|
|
388
|
+
await getAddressFn(mockDeviceId, {
|
|
389
|
+
path: mockPath,
|
|
390
|
+
verify: false,
|
|
391
|
+
currency: {} as any,
|
|
392
|
+
derivationMode: "" as any,
|
|
393
|
+
});
|
|
394
|
+
expect(mockSigner.getAddress).toHaveBeenLastCalledWith(mockPath, false, false);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it("should handle undefined verify parameter", async () => {
|
|
398
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
399
|
+
const options = { path: mockPath } as GetAddressOptions;
|
|
400
|
+
|
|
401
|
+
await getAddressFn(mockDeviceId, options);
|
|
402
|
+
|
|
403
|
+
expect(mockSigner.getAddress).toHaveBeenCalledWith(mockPath, undefined, false);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
describe("integration scenarios", () => {
|
|
408
|
+
it("should work with real-like addresses and public keys", async () => {
|
|
409
|
+
const realAddress = "0x742d35cc6634c0532925a3b8d0b251d8c1743ec4";
|
|
410
|
+
const realPublicKey = Buffer.from(
|
|
411
|
+
"04abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab",
|
|
412
|
+
"hex",
|
|
413
|
+
);
|
|
414
|
+
const realResponse = { address: realAddress, publicKey: realPublicKey };
|
|
415
|
+
const encodedAddress = "0x742d35Cc6634C0532925a3b8D0B251d8c1743eC4";
|
|
416
|
+
|
|
417
|
+
(mockSigner.getAddress as jest.Mock).mockResolvedValue(realResponse);
|
|
418
|
+
mockedEip55.encode.mockReturnValue(encodedAddress);
|
|
419
|
+
|
|
420
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
421
|
+
const options: GetAddressOptions = {
|
|
422
|
+
path: "44'/818'/0'/0/0",
|
|
423
|
+
verify: true,
|
|
424
|
+
currency: {} as any,
|
|
425
|
+
derivationMode: "" as any,
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const result = await getAddressFn("real-device", options);
|
|
429
|
+
|
|
430
|
+
expect(result).toEqual({
|
|
431
|
+
address: encodedAddress,
|
|
432
|
+
publicKey: realPublicKey,
|
|
433
|
+
path: "44'/818'/0'/0/0",
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("should maintain result structure consistency", async () => {
|
|
438
|
+
const getAddressFn = resolver(mockSignerContext);
|
|
439
|
+
const options: GetAddressOptions = {
|
|
440
|
+
path: mockPath,
|
|
441
|
+
verify: false,
|
|
442
|
+
currency: {} as any,
|
|
443
|
+
derivationMode: "" as any,
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
const result = await getAddressFn(mockDeviceId, options);
|
|
447
|
+
|
|
448
|
+
expect(result).toHaveProperty("address");
|
|
449
|
+
expect(result).toHaveProperty("publicKey");
|
|
450
|
+
expect(result).toHaveProperty("path");
|
|
451
|
+
expect(Object.keys(result)).toHaveLength(3);
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
});
|