@ledgerhq/coin-vechain 2.2.0-next.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/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +74 -0
- package/CHANGELOG.md +1186 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/account.d.ts +7 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +19 -0
- package/lib/account.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +8 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +27 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/buildOptimisticOperatioin.d.ts +4 -0
- package/lib/bridge/buildOptimisticOperatioin.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperatioin.js +56 -0
- package/lib/bridge/buildOptimisticOperatioin.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +9 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +36 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +29 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +5 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +76 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +10 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +64 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +10 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +38 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +8 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +43 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/synchronisation.d.ts +4 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -0
- package/lib/bridge/synchronisation.js +84 -0
- package/lib/bridge/synchronisation.js.map +1 -0
- package/lib/bridge/transaction.d.ts +17 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +56 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/common-logic/address-utils.d.ts +2 -0
- package/lib/common-logic/address-utils.d.ts.map +1 -0
- package/lib/common-logic/address-utils.js +19 -0
- package/lib/common-logic/address-utils.js.map +1 -0
- package/lib/common-logic/hex-utils.d.ts +8 -0
- package/lib/common-logic/hex-utils.d.ts.map +1 -0
- package/lib/common-logic/hex-utils.js +52 -0
- package/lib/common-logic/hex-utils.js.map +1 -0
- package/lib/common-logic/index.d.ts +7 -0
- package/lib/common-logic/index.d.ts.map +1 -0
- package/lib/common-logic/index.js +23 -0
- package/lib/common-logic/index.js.map +1 -0
- package/lib/common-logic/logic.d.ts +5 -0
- package/lib/common-logic/logic.d.ts.map +1 -0
- package/lib/common-logic/logic.js +46 -0
- package/lib/common-logic/logic.js.map +1 -0
- package/lib/common-logic/mapping-utils.d.ts +5 -0
- package/lib/common-logic/mapping-utils.d.ts.map +1 -0
- package/lib/common-logic/mapping-utils.js +61 -0
- package/lib/common-logic/mapping-utils.js.map +1 -0
- package/lib/common-logic/pad-address.d.ts +2 -0
- package/lib/common-logic/pad-address.d.ts.map +1 -0
- package/lib/common-logic/pad-address.js +13 -0
- package/lib/common-logic/pad-address.js.map +1 -0
- package/lib/common-logic/transaction-utils.d.ts +30 -0
- package/lib/common-logic/transaction-utils.d.ts.map +1 -0
- package/lib/common-logic/transaction-utils.js +164 -0
- package/lib/common-logic/transaction-utils.js.map +1 -0
- package/lib/config.d.ts +5 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +17 -0
- package/lib/config.js.map +1 -0
- package/lib/contracts/abis/VIP180.d.ts +17 -0
- package/lib/contracts/abis/VIP180.d.ts.map +1 -0
- package/lib/contracts/abis/VIP180.js +265 -0
- package/lib/contracts/abis/VIP180.js.map +1 -0
- package/lib/contracts/abis/params.d.ts +8 -0
- package/lib/contracts/abis/params.d.ts.map +1 -0
- package/lib/contracts/abis/params.js +69 -0
- package/lib/contracts/abis/params.js.map +1 -0
- package/lib/contracts/constants.d.ts +6 -0
- package/lib/contracts/constants.d.ts.map +1 -0
- package/lib/contracts/constants.js +10 -0
- package/lib/contracts/constants.js.map +1 -0
- package/lib/datasets/index.d.ts +3 -0
- package/lib/datasets/index.d.ts.map +1 -0
- package/lib/datasets/index.js +23 -0
- package/lib/datasets/index.js.map +1 -0
- package/lib/datasets/vechain.d.ts +5 -0
- package/lib/datasets/vechain.d.ts.map +1 -0
- package/lib/datasets/vechain.js +91 -0
- package/lib/datasets/vechain.js.map +1 -0
- package/lib/datasets/vechain.scanAccounts.1.d.ts +6 -0
- package/lib/datasets/vechain.scanAccounts.1.d.ts.map +1 -0
- package/lib/datasets/vechain.scanAccounts.1.js +16 -0
- package/lib/datasets/vechain.scanAccounts.1.js.map +1 -0
- package/lib/errors.d.ts +10 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +8 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/mock.d.ts +9 -0
- package/lib/mock.d.ts.map +1 -0
- package/lib/mock.js +13 -0
- package/lib/mock.js.map +1 -0
- package/lib/network/index.d.ts +3 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +22 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/sdk.d.ts +47 -0
- package/lib/network/sdk.d.ts.map +1 -0
- package/lib/network/sdk.js +164 -0
- package/lib/network/sdk.js.map +1 -0
- package/lib/signer/getAddress.d.ts +6 -0
- package/lib/signer/getAddress.d.ts.map +1 -0
- package/lib/signer/getAddress.js +32 -0
- package/lib/signer/getAddress.js.map +1 -0
- package/lib/signer/index.d.ts +4 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +23 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/signer/signMessage.d.ts +4 -0
- package/lib/signer/signMessage.d.ts.map +1 -0
- package/lib/signer/signMessage.js +31 -0
- package/lib/signer/signMessage.js.map +1 -0
- package/lib/test/bot-deviceActions.d.ts +7 -0
- package/lib/test/bot-deviceActions.d.ts.map +1 -0
- package/lib/test/bot-deviceActions.js +23 -0
- package/lib/test/bot-deviceActions.js.map +1 -0
- package/lib/test/bot-specs.d.ts +8 -0
- package/lib/test/bot-specs.d.ts.map +1 -0
- package/lib/test/bot-specs.js +161 -0
- package/lib/test/bot-specs.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts +4 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib/test/bridgeDatasetTest.js +252 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +17 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +51 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +6 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +26 -0
- package/lib/test/index.js.map +1 -0
- package/lib/types/bridge.d.ts +25 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.js +3 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/constants.d.ts +6 -0
- package/lib/types/constants.d.ts.map +1 -0
- package/lib/types/constants.js +9 -0
- package/lib/types/constants.js.map +1 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +21 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/network.d.ts +71 -0
- package/lib/types/network.d.ts.map +1 -0
- package/lib/types/network.js +3 -0
- package/lib/types/network.js.map +1 -0
- package/lib/types/signer.d.ts +12 -0
- package/lib/types/signer.d.ts.map +1 -0
- package/lib/types/signer.js +3 -0
- package/lib/types/signer.js.map +1 -0
- package/lib-es/account.d.ts +7 -0
- package/lib-es/account.d.ts.map +1 -0
- package/lib-es/account.js +17 -0
- package/lib-es/account.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +8 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +23 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperatioin.d.ts +4 -0
- package/lib-es/bridge/buildOptimisticOperatioin.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperatioin.js +49 -0
- package/lib-es/bridge/buildOptimisticOperatioin.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +9 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +29 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +22 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +5 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +69 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +10 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +55 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +10 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +34 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +8 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +39 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/synchronisation.d.ts +4 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -0
- package/lib-es/bridge/synchronisation.js +77 -0
- package/lib-es/bridge/synchronisation.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +17 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +48 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/common-logic/address-utils.d.ts +2 -0
- package/lib-es/common-logic/address-utils.d.ts.map +1 -0
- package/lib-es/common-logic/address-utils.js +12 -0
- package/lib-es/common-logic/address-utils.js.map +1 -0
- package/lib-es/common-logic/hex-utils.d.ts +8 -0
- package/lib-es/common-logic/hex-utils.d.ts.map +1 -0
- package/lib-es/common-logic/hex-utils.js +50 -0
- package/lib-es/common-logic/hex-utils.js.map +1 -0
- package/lib-es/common-logic/index.d.ts +7 -0
- package/lib-es/common-logic/index.d.ts.map +1 -0
- package/lib-es/common-logic/index.js +7 -0
- package/lib-es/common-logic/index.js.map +1 -0
- package/lib-es/common-logic/logic.d.ts +5 -0
- package/lib-es/common-logic/logic.d.ts.map +1 -0
- package/lib-es/common-logic/logic.js +38 -0
- package/lib-es/common-logic/logic.js.map +1 -0
- package/lib-es/common-logic/mapping-utils.d.ts +5 -0
- package/lib-es/common-logic/mapping-utils.d.ts.map +1 -0
- package/lib-es/common-logic/mapping-utils.js +53 -0
- package/lib-es/common-logic/mapping-utils.js.map +1 -0
- package/lib-es/common-logic/pad-address.d.ts +2 -0
- package/lib-es/common-logic/pad-address.d.ts.map +1 -0
- package/lib-es/common-logic/pad-address.js +9 -0
- package/lib-es/common-logic/pad-address.js.map +1 -0
- package/lib-es/common-logic/transaction-utils.d.ts +30 -0
- package/lib-es/common-logic/transaction-utils.d.ts.map +1 -0
- package/lib-es/common-logic/transaction-utils.js +153 -0
- package/lib-es/common-logic/transaction-utils.js.map +1 -0
- package/lib-es/config.d.ts +5 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +12 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/contracts/abis/VIP180.d.ts +17 -0
- package/lib-es/contracts/abis/VIP180.d.ts.map +1 -0
- package/lib-es/contracts/abis/VIP180.js +263 -0
- package/lib-es/contracts/abis/VIP180.js.map +1 -0
- package/lib-es/contracts/abis/params.d.ts +8 -0
- package/lib-es/contracts/abis/params.d.ts.map +1 -0
- package/lib-es/contracts/abis/params.js +67 -0
- package/lib-es/contracts/abis/params.js.map +1 -0
- package/lib-es/contracts/constants.d.ts +6 -0
- package/lib-es/contracts/constants.d.ts.map +1 -0
- package/lib-es/contracts/constants.js +7 -0
- package/lib-es/contracts/constants.js.map +1 -0
- package/lib-es/datasets/index.d.ts +3 -0
- package/lib-es/datasets/index.d.ts.map +1 -0
- package/lib-es/datasets/index.js +3 -0
- package/lib-es/datasets/index.js.map +1 -0
- package/lib-es/datasets/vechain.d.ts +5 -0
- package/lib-es/datasets/vechain.d.ts.map +1 -0
- package/lib-es/datasets/vechain.js +88 -0
- package/lib-es/datasets/vechain.js.map +1 -0
- package/lib-es/datasets/vechain.scanAccounts.1.d.ts +6 -0
- package/lib-es/datasets/vechain.scanAccounts.1.d.ts.map +1 -0
- package/lib-es/datasets/vechain.scanAccounts.1.js +14 -0
- package/lib-es/datasets/vechain.scanAccounts.1.js.map +1 -0
- package/lib-es/errors.d.ts +10 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +5 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/index.d.ts +2 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +2 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/mock.d.ts +9 -0
- package/lib-es/mock.d.ts.map +1 -0
- package/lib-es/mock.js +11 -0
- package/lib-es/mock.js.map +1 -0
- package/lib-es/network/index.d.ts +3 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +3 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/sdk.d.ts +47 -0
- package/lib-es/network/sdk.d.ts.map +1 -0
- package/lib-es/network/sdk.js +150 -0
- package/lib-es/network/sdk.js.map +1 -0
- package/lib-es/signer/getAddress.d.ts +6 -0
- package/lib-es/signer/getAddress.d.ts.map +1 -0
- package/lib-es/signer/getAddress.js +27 -0
- package/lib-es/signer/getAddress.js.map +1 -0
- package/lib-es/signer/index.d.ts +4 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +4 -0
- package/lib-es/signer/index.js.map +1 -0
- package/lib-es/signer/signMessage.d.ts +4 -0
- package/lib-es/signer/signMessage.d.ts.map +1 -0
- package/lib-es/signer/signMessage.js +27 -0
- package/lib-es/signer/signMessage.js.map +1 -0
- package/lib-es/test/bot-deviceActions.d.ts +7 -0
- package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
- package/lib-es/test/bot-deviceActions.js +21 -0
- package/lib-es/test/bot-deviceActions.js.map +1 -0
- package/lib-es/test/bot-specs.d.ts +8 -0
- package/lib-es/test/bot-specs.d.ts.map +1 -0
- package/lib-es/test/bot-specs.js +156 -0
- package/lib-es/test/bot-specs.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib-es/test/bridgeDatasetTest.js +246 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +17 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +45 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +6 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +6 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/types/bridge.d.ts +25 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.js +2 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/constants.d.ts +6 -0
- package/lib-es/types/constants.d.ts.map +1 -0
- package/lib-es/types/constants.js +6 -0
- package/lib-es/types/constants.js.map +1 -0
- package/lib-es/types/index.d.ts +5 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +5 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/network.d.ts +71 -0
- package/lib-es/types/network.d.ts.map +1 -0
- package/lib-es/types/network.js +2 -0
- package/lib-es/types/network.js.map +1 -0
- package/lib-es/types/signer.d.ts +12 -0
- package/lib-es/types/signer.d.ts.map +1 -0
- package/lib-es/types/signer.js +2 -0
- package/lib-es/types/signer.js.map +1 -0
- package/package.json +120 -0
- package/src/__snapshots__/bridge.integration.test.ts.snap +146 -0
- package/src/account.ts +22 -0
- package/src/bridge/broadcast.ts +23 -0
- package/src/bridge/buildOptimisticOperatioin.ts +46 -0
- package/src/bridge/createTransaction.ts +31 -0
- package/src/bridge/estimateMaxSpendable.ts +18 -0
- package/src/bridge/getTransactionStatus.ts +76 -0
- package/src/bridge/index.ts +63 -0
- package/src/bridge/prepareTransaction.ts +41 -0
- package/src/bridge/signOperation.ts +53 -0
- package/src/bridge/synchronisation.ts +86 -0
- package/src/bridge/transaction.ts +79 -0
- package/src/common-logic/address-utils.ts +11 -0
- package/src/common-logic/hex-utils.ts +53 -0
- package/src/common-logic/index.ts +6 -0
- package/src/common-logic/logic.ts +44 -0
- package/src/common-logic/mapping-utils.ts +67 -0
- package/src/common-logic/pad-address.ts +8 -0
- package/src/common-logic/transaction-utils.ts +190 -0
- package/src/config.ts +18 -0
- package/src/contracts/abis/VIP180.ts +265 -0
- package/src/contracts/abis/params.ts +70 -0
- package/src/contracts/constants.ts +11 -0
- package/src/datasets/index.ts +2 -0
- package/src/datasets/vechain.scanAccounts.1.ts +13 -0
- package/src/datasets/vechain.ts +92 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +1 -0
- package/src/mock.ts +14 -0
- package/src/network/index.ts +2 -0
- package/src/network/sdk.ts +177 -0
- package/src/signer/getAddress.ts +25 -0
- package/src/signer/index.ts +4 -0
- package/src/signer/signMessage.ts +22 -0
- package/src/test/bot-deviceActions.ts +24 -0
- package/src/test/bot-specs.ts +210 -0
- package/src/test/bridgeDatasetTest.ts +262 -0
- package/src/test/cli.ts +86 -0
- package/src/test/index.ts +6 -0
- package/src/types/bridge.ts +35 -0
- package/src/types/constants.ts +5 -0
- package/src/types/index.ts +4 -0
- package/src/types/network.ts +81 -0
- package/src/types/signer.ts +10 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { abi } from "thor-devkit";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* EVENTS
|
|
5
|
+
*/
|
|
6
|
+
const ApprovalEvent: abi.Event.Definition = {
|
|
7
|
+
anonymous: false,
|
|
8
|
+
inputs: [
|
|
9
|
+
{
|
|
10
|
+
indexed: true,
|
|
11
|
+
internalType: "address",
|
|
12
|
+
name: "owner",
|
|
13
|
+
type: "address",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
indexed: true,
|
|
17
|
+
internalType: "address",
|
|
18
|
+
name: "spender",
|
|
19
|
+
type: "address",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
indexed: false,
|
|
23
|
+
internalType: "uint256",
|
|
24
|
+
name: "value",
|
|
25
|
+
type: "uint256",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
name: "Approval",
|
|
29
|
+
type: "event",
|
|
30
|
+
};
|
|
31
|
+
const TransferEvent: abi.Event.Definition = {
|
|
32
|
+
anonymous: false,
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
indexed: true,
|
|
36
|
+
internalType: "address",
|
|
37
|
+
name: "from",
|
|
38
|
+
type: "address",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
indexed: true,
|
|
42
|
+
internalType: "address",
|
|
43
|
+
name: "to",
|
|
44
|
+
type: "address",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
indexed: false,
|
|
48
|
+
internalType: "uint256",
|
|
49
|
+
name: "value",
|
|
50
|
+
type: "uint256",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
name: "Transfer",
|
|
54
|
+
type: "event",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* FUNCTIONS
|
|
59
|
+
*/
|
|
60
|
+
const allowance: abi.Function.Definition = {
|
|
61
|
+
inputs: [
|
|
62
|
+
{
|
|
63
|
+
internalType: "address",
|
|
64
|
+
name: "owner",
|
|
65
|
+
type: "address",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
internalType: "address",
|
|
69
|
+
name: "spender",
|
|
70
|
+
type: "address",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
name: "allowance",
|
|
74
|
+
outputs: [
|
|
75
|
+
{
|
|
76
|
+
internalType: "uint256",
|
|
77
|
+
name: "",
|
|
78
|
+
type: "uint256",
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
stateMutability: "view",
|
|
82
|
+
type: "function",
|
|
83
|
+
};
|
|
84
|
+
const approve: abi.Function.Definition = {
|
|
85
|
+
inputs: [
|
|
86
|
+
{
|
|
87
|
+
internalType: "address",
|
|
88
|
+
name: "spender",
|
|
89
|
+
type: "address",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
internalType: "uint256",
|
|
93
|
+
name: "amount",
|
|
94
|
+
type: "uint256",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
name: "approve",
|
|
98
|
+
outputs: [
|
|
99
|
+
{
|
|
100
|
+
internalType: "bool",
|
|
101
|
+
name: "",
|
|
102
|
+
type: "bool",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
stateMutability: "nonpayable",
|
|
106
|
+
type: "function",
|
|
107
|
+
};
|
|
108
|
+
const balanceOf: abi.Function.Definition = {
|
|
109
|
+
inputs: [
|
|
110
|
+
{
|
|
111
|
+
internalType: "address",
|
|
112
|
+
name: "account",
|
|
113
|
+
type: "address",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
name: "balanceOf",
|
|
117
|
+
outputs: [
|
|
118
|
+
{
|
|
119
|
+
internalType: "uint256",
|
|
120
|
+
name: "",
|
|
121
|
+
type: "uint256",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
stateMutability: "view",
|
|
125
|
+
type: "function",
|
|
126
|
+
};
|
|
127
|
+
const decimals: abi.Function.Definition = {
|
|
128
|
+
inputs: [],
|
|
129
|
+
name: "decimals",
|
|
130
|
+
outputs: [
|
|
131
|
+
{
|
|
132
|
+
internalType: "uint8",
|
|
133
|
+
name: "",
|
|
134
|
+
type: "uint8",
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
stateMutability: "view",
|
|
138
|
+
type: "function",
|
|
139
|
+
};
|
|
140
|
+
const name: abi.Function.Definition = {
|
|
141
|
+
inputs: [],
|
|
142
|
+
name: "name",
|
|
143
|
+
outputs: [
|
|
144
|
+
{
|
|
145
|
+
internalType: "string",
|
|
146
|
+
name: "",
|
|
147
|
+
type: "string",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
stateMutability: "view",
|
|
151
|
+
type: "function",
|
|
152
|
+
};
|
|
153
|
+
const supportsInterface: abi.Function.Definition = {
|
|
154
|
+
inputs: [
|
|
155
|
+
{
|
|
156
|
+
internalType: "bytes4",
|
|
157
|
+
name: "interfaceId",
|
|
158
|
+
type: "bytes4",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
name: "supportsInterface",
|
|
162
|
+
outputs: [
|
|
163
|
+
{
|
|
164
|
+
internalType: "bool",
|
|
165
|
+
name: "",
|
|
166
|
+
type: "bool",
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
stateMutability: "view",
|
|
170
|
+
type: "function",
|
|
171
|
+
};
|
|
172
|
+
const symbol: abi.Function.Definition = {
|
|
173
|
+
inputs: [],
|
|
174
|
+
name: "symbol",
|
|
175
|
+
outputs: [
|
|
176
|
+
{
|
|
177
|
+
internalType: "string",
|
|
178
|
+
name: "",
|
|
179
|
+
type: "string",
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
stateMutability: "view",
|
|
183
|
+
type: "function",
|
|
184
|
+
};
|
|
185
|
+
const totalSupply: abi.Function.Definition = {
|
|
186
|
+
inputs: [],
|
|
187
|
+
name: "totalSupply",
|
|
188
|
+
outputs: [
|
|
189
|
+
{
|
|
190
|
+
internalType: "uint256",
|
|
191
|
+
name: "",
|
|
192
|
+
type: "uint256",
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
stateMutability: "view",
|
|
196
|
+
type: "function",
|
|
197
|
+
};
|
|
198
|
+
const transfer: abi.Function.Definition = {
|
|
199
|
+
inputs: [
|
|
200
|
+
{
|
|
201
|
+
internalType: "address",
|
|
202
|
+
name: "to",
|
|
203
|
+
type: "address",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
internalType: "uint256",
|
|
207
|
+
name: "amount",
|
|
208
|
+
type: "uint256",
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
name: "transfer",
|
|
212
|
+
outputs: [
|
|
213
|
+
{
|
|
214
|
+
internalType: "bool",
|
|
215
|
+
name: "",
|
|
216
|
+
type: "bool",
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
stateMutability: "nonpayable",
|
|
220
|
+
type: "function",
|
|
221
|
+
};
|
|
222
|
+
const transferFrom: abi.Function.Definition = {
|
|
223
|
+
inputs: [
|
|
224
|
+
{
|
|
225
|
+
internalType: "address",
|
|
226
|
+
name: "from",
|
|
227
|
+
type: "address",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
internalType: "address",
|
|
231
|
+
name: "to",
|
|
232
|
+
type: "address",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
internalType: "uint256",
|
|
236
|
+
name: "amount",
|
|
237
|
+
type: "uint256",
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
name: "transferFrom",
|
|
241
|
+
outputs: [
|
|
242
|
+
{
|
|
243
|
+
internalType: "bool",
|
|
244
|
+
name: "",
|
|
245
|
+
type: "bool",
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
stateMutability: "nonpayable",
|
|
249
|
+
type: "function",
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export default {
|
|
253
|
+
ApprovalEvent: new abi.Event(ApprovalEvent),
|
|
254
|
+
TransferEvent: new abi.Event(TransferEvent),
|
|
255
|
+
allowance: new abi.Function(allowance),
|
|
256
|
+
approve: new abi.Function(approve),
|
|
257
|
+
balanceOf: new abi.Function(balanceOf),
|
|
258
|
+
decimals: new abi.Function(decimals),
|
|
259
|
+
name: new abi.Function(name),
|
|
260
|
+
supportsInterface: new abi.Function(supportsInterface),
|
|
261
|
+
symbol: new abi.Function(symbol),
|
|
262
|
+
totalSupply: new abi.Function(totalSupply),
|
|
263
|
+
transfer: new abi.Function(transfer),
|
|
264
|
+
transferFrom: new abi.Function(transferFrom),
|
|
265
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { abi } from "thor-devkit";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* FUNCTIONS
|
|
5
|
+
*/
|
|
6
|
+
const set: abi.Function.Definition = {
|
|
7
|
+
constant: false,
|
|
8
|
+
inputs: [
|
|
9
|
+
{
|
|
10
|
+
name: "_key",
|
|
11
|
+
type: "bytes32",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "_value",
|
|
15
|
+
type: "uint256",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
name: "set",
|
|
19
|
+
outputs: [],
|
|
20
|
+
payable: false,
|
|
21
|
+
stateMutability: "nonpayable",
|
|
22
|
+
type: "function",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const get: abi.Function.Definition = {
|
|
26
|
+
constant: true,
|
|
27
|
+
inputs: [
|
|
28
|
+
{
|
|
29
|
+
name: "_key",
|
|
30
|
+
type: "bytes32",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
name: "get",
|
|
34
|
+
outputs: [
|
|
35
|
+
{
|
|
36
|
+
name: "",
|
|
37
|
+
type: "uint256",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
payable: false,
|
|
41
|
+
stateMutability: "view",
|
|
42
|
+
type: "function",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* EVENTS
|
|
47
|
+
*/
|
|
48
|
+
const Set: abi.Event.Definition = {
|
|
49
|
+
anonymous: false,
|
|
50
|
+
inputs: [
|
|
51
|
+
{
|
|
52
|
+
indexed: true,
|
|
53
|
+
name: "key",
|
|
54
|
+
type: "bytes32",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
indexed: false,
|
|
58
|
+
name: "value",
|
|
59
|
+
type: "uint256",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
name: "Set",
|
|
63
|
+
type: "event",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default {
|
|
67
|
+
set: new abi.Function(set),
|
|
68
|
+
get: new abi.Function(get),
|
|
69
|
+
Set: new abi.Event(Set),
|
|
70
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const TransferEventSignature =
|
|
2
|
+
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
|
|
3
|
+
|
|
4
|
+
export const VTHO_ADDRESS = "0x0000000000000000000000000000456e65726779";
|
|
5
|
+
|
|
6
|
+
// params.sol - builtin contract (https://www.vechain.org/whitepaper/#bit_v48i3)
|
|
7
|
+
export const PARAMS_ADDRESS = "0x0000000000000000000000000000506172616d73";
|
|
8
|
+
export const REWARD_RATIO_KEY =
|
|
9
|
+
"0x00000000000000000000000000000000000000007265776172642d726174696f";
|
|
10
|
+
export const BASE_GAS_PRICE_KEY =
|
|
11
|
+
"0x000000000000000000000000000000000000626173652d6761732d7072696365";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
name: "vechain seed 1",
|
|
4
|
+
apdus: `
|
|
5
|
+
=> e002000015058000002c80000332800000000000000000000000
|
|
6
|
+
<= 4104de5a8f11cc426ff5617aeffd397c5dd77b58424662f368f2cd539a8c42fd2e7d0c6245c9c3a4306f70d7f292e95642651a6832d66fd9823fa6a0af575113e94e28306665363638383534386630433330333933326242313937423041393630333466316437346462619000
|
|
7
|
+
=> e002000015058000002c80000332800000000000000000000001
|
|
8
|
+
<= 4104c1295d6d253841866b1cf8adbb63004d74849370d6301c839c7f57fa764b2eab0ae8fd4ea092a0ee3c2ca3bc61542b4becae04b5e1ed91e698a4a4d620a512dd28303239363142393242384432304134656131326631663143654641373444643742343335354138369000
|
|
9
|
+
=> e002000015058000002c80000332800000000000000000000002
|
|
10
|
+
<= 41047ff6eb07f97f5db006f9777d96a44bcb4cd35bf149ff9ed63d9b5fba32e167caa272a2b648e826aa4b9e7c88871d69096424c59634bc260e28fc1c1a3d5f204728466243383635334330623834326464333333363143453839333842323465343037646434383338439000
|
|
11
|
+
`,
|
|
12
|
+
},
|
|
13
|
+
];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { AccountRaw } from "@ledgerhq/types-live";
|
|
2
|
+
|
|
3
|
+
// NOTE: account information is fetched from the blockchain so this is just integration for those information
|
|
4
|
+
// so you you should not rely on that, here the important part are ids and index
|
|
5
|
+
|
|
6
|
+
export const vechain1: AccountRaw = {
|
|
7
|
+
id: "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain",
|
|
8
|
+
seedIdentifier: "0x0fe6688548f0C303932bB197B0A96034f1d74dba",
|
|
9
|
+
name: "Vechain 1",
|
|
10
|
+
derivationMode: "vechain",
|
|
11
|
+
index: 0,
|
|
12
|
+
freshAddress: "0x0fe6688548f0C303932bB197B0A96034f1d74dba",
|
|
13
|
+
freshAddressPath: "44'/818'/0'/0/0",
|
|
14
|
+
blockHeight: 15156315,
|
|
15
|
+
operations: [],
|
|
16
|
+
pendingOperations: [],
|
|
17
|
+
currencyId: "vechain",
|
|
18
|
+
feesCurrencyId: "vechain/vip180/vtho",
|
|
19
|
+
lastSyncDate: "2023-04-21T14:22:48.395Z",
|
|
20
|
+
balance: "10000000000000000000",
|
|
21
|
+
subAccounts: [
|
|
22
|
+
{
|
|
23
|
+
type: "TokenAccountRaw",
|
|
24
|
+
id: "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain+vechain%2Fvip180%2Fvtho",
|
|
25
|
+
parentId: "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain",
|
|
26
|
+
tokenId: "vechain/vip180/vtho",
|
|
27
|
+
balance: "10000000000000000000",
|
|
28
|
+
operations: [],
|
|
29
|
+
pendingOperations: [],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
swapHistory: [],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const vechain2: AccountRaw = {
|
|
36
|
+
id: "js:2:vechain:0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86:vechain",
|
|
37
|
+
seedIdentifier: "0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86",
|
|
38
|
+
name: "Vechain 2",
|
|
39
|
+
derivationMode: "vechain",
|
|
40
|
+
index: 1,
|
|
41
|
+
freshAddress: "0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86",
|
|
42
|
+
freshAddressPath: "44'/818'/0'/0/1",
|
|
43
|
+
blockHeight: 15156315,
|
|
44
|
+
operations: [],
|
|
45
|
+
pendingOperations: [],
|
|
46
|
+
currencyId: "vechain",
|
|
47
|
+
feesCurrencyId: "vechain/vip180/vtho",
|
|
48
|
+
lastSyncDate: "2023-04-21T14:22:48.395Z",
|
|
49
|
+
balance: "10000000000000000000",
|
|
50
|
+
subAccounts: [
|
|
51
|
+
{
|
|
52
|
+
type: "TokenAccountRaw",
|
|
53
|
+
id: "js:2:vechain:0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86:vechain+vechain%2Fvip180%2Fvtho",
|
|
54
|
+
parentId: "js:2:vechain:0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86:vechain",
|
|
55
|
+
tokenId: "vechain/vip180/vtho",
|
|
56
|
+
balance: "0",
|
|
57
|
+
operations: [],
|
|
58
|
+
pendingOperations: [],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
swapHistory: [],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// account with vtho but no vet
|
|
65
|
+
export const vechain3: AccountRaw = {
|
|
66
|
+
id: "js:2:vechain:0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0:vechain",
|
|
67
|
+
seedIdentifier: "0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0",
|
|
68
|
+
name: "Vechain 3",
|
|
69
|
+
derivationMode: "vechain",
|
|
70
|
+
index: 1,
|
|
71
|
+
freshAddress: "0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0",
|
|
72
|
+
freshAddressPath: "44'/818'/0'/0/0",
|
|
73
|
+
blockHeight: 15156315,
|
|
74
|
+
operations: [],
|
|
75
|
+
pendingOperations: [],
|
|
76
|
+
currencyId: "vechain",
|
|
77
|
+
feesCurrencyId: "vechain/vip180/vtho",
|
|
78
|
+
lastSyncDate: "2023-11-13T13:55:32.004Z",
|
|
79
|
+
balance: "0",
|
|
80
|
+
subAccounts: [
|
|
81
|
+
{
|
|
82
|
+
type: "TokenAccountRaw",
|
|
83
|
+
id: "js:2:vechain:0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0:vechain+vechain%2Fvip180%2Fvtho",
|
|
84
|
+
parentId: "js:2:vechain:0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0:vechain",
|
|
85
|
+
tokenId: "vechain/vip180/vtho",
|
|
86
|
+
balance: "1000000000000000",
|
|
87
|
+
operations: [],
|
|
88
|
+
pendingOperations: [],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
swapHistory: [],
|
|
92
|
+
};
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
|
+
|
|
3
|
+
export const NotEnoughVTHO = createCustomErrorClass("NotEnoughVTHO");
|
|
4
|
+
export const MustBeVechain = createCustomErrorClass("MustBeVechain");
|
|
5
|
+
export const ImpossibleToCalculateAmountAndFees = createCustomErrorClass(
|
|
6
|
+
"ImpossibleToCalculateAmountAndFees",
|
|
7
|
+
);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createBridges } from "./bridge/index";
|
package/src/mock.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
2
|
+
|
|
3
|
+
function postSyncAccount(account: Account): Account {
|
|
4
|
+
return account;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function postScanAccount(account: Account): Account {
|
|
8
|
+
return account;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
postSyncAccount,
|
|
13
|
+
postScanAccount,
|
|
14
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import network from "@ledgerhq/live-network/network";
|
|
3
|
+
import { AccountResponse, VetTxsQuery, TokenTxsQuery, Query, QueryResponse } from "../types";
|
|
4
|
+
import type { Operation } from "@ledgerhq/types-live";
|
|
5
|
+
import {
|
|
6
|
+
mapVetTransfersToOperations,
|
|
7
|
+
mapTokenTransfersToOperations,
|
|
8
|
+
padAddress,
|
|
9
|
+
} from "../common-logic";
|
|
10
|
+
import { TransferEventSignature } from "../contracts/constants";
|
|
11
|
+
import { Transaction } from "thor-devkit";
|
|
12
|
+
import { HEX_PREFIX } from "../types";
|
|
13
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
14
|
+
|
|
15
|
+
const BASE_URL = getEnv("API_VECHAIN_THOREST");
|
|
16
|
+
|
|
17
|
+
export const getAccount = async (address: string): Promise<AccountResponse> => {
|
|
18
|
+
const { data } = await network({
|
|
19
|
+
method: "GET",
|
|
20
|
+
url: `${BASE_URL}/accounts/${address}`,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return data;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getLastBlockHeight = async (): Promise<number> => {
|
|
27
|
+
const { data } = await network({
|
|
28
|
+
method: "GET",
|
|
29
|
+
url: `${BASE_URL}/blocks/best`,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return data.number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get VET operations
|
|
37
|
+
* @param accountId
|
|
38
|
+
* @param addr
|
|
39
|
+
* @param startAt
|
|
40
|
+
* @returns an array of operations
|
|
41
|
+
*/
|
|
42
|
+
export const getOperations = async (
|
|
43
|
+
accountId: string,
|
|
44
|
+
addr: string,
|
|
45
|
+
startAt: number,
|
|
46
|
+
): Promise<Operation[]> => {
|
|
47
|
+
const query: VetTxsQuery = {
|
|
48
|
+
range: {
|
|
49
|
+
unit: "block",
|
|
50
|
+
from: startAt,
|
|
51
|
+
},
|
|
52
|
+
criteriaSet: [{ sender: addr }, { recipient: addr }],
|
|
53
|
+
order: "desc",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const { data } = await network({
|
|
57
|
+
method: "POST",
|
|
58
|
+
url: `${BASE_URL}/logs/transfer`,
|
|
59
|
+
data: JSON.stringify(query),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const operations: Operation[] = await mapVetTransfersToOperations(data, accountId, addr);
|
|
63
|
+
|
|
64
|
+
return operations;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get operations for a fungible token
|
|
69
|
+
* @param accountId
|
|
70
|
+
* @param addr
|
|
71
|
+
* @param tokenAddr - The token address (The VTHO token address is available from constants.ts)
|
|
72
|
+
* @param startAt
|
|
73
|
+
* @returns an array of operations
|
|
74
|
+
*/
|
|
75
|
+
export const getTokenOperations = async (
|
|
76
|
+
accountId: string,
|
|
77
|
+
addr: string,
|
|
78
|
+
tokenAddr: string,
|
|
79
|
+
startAt: number,
|
|
80
|
+
): Promise<Operation[]> => {
|
|
81
|
+
const paddedAddress = padAddress(addr);
|
|
82
|
+
|
|
83
|
+
const query: TokenTxsQuery = {
|
|
84
|
+
range: {
|
|
85
|
+
unit: "block",
|
|
86
|
+
from: startAt,
|
|
87
|
+
},
|
|
88
|
+
criteriaSet: [
|
|
89
|
+
{
|
|
90
|
+
address: tokenAddr,
|
|
91
|
+
topic0: TransferEventSignature,
|
|
92
|
+
topic1: paddedAddress,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
address: tokenAddr,
|
|
96
|
+
topic0: TransferEventSignature,
|
|
97
|
+
topic2: paddedAddress,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
order: "desc",
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const { data } = await network({
|
|
104
|
+
method: "POST",
|
|
105
|
+
url: `${BASE_URL}/logs/event`,
|
|
106
|
+
data: JSON.stringify(query),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const operations = await mapTokenTransfersToOperations(data, accountId, addr);
|
|
110
|
+
return operations;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Submit a transaction and return the ID
|
|
115
|
+
* @param tx - The transaction to submit
|
|
116
|
+
* @returns transaction ID
|
|
117
|
+
*/
|
|
118
|
+
export const submit = async (tx: Transaction): Promise<string> => {
|
|
119
|
+
const encodedRawTx = {
|
|
120
|
+
raw: `${HEX_PREFIX}${tx.encode().toString("hex")}`,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const { data } = await network({
|
|
124
|
+
method: "POST",
|
|
125
|
+
url: `${BASE_URL}/transactions`,
|
|
126
|
+
data: encodedRawTx,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Expect a transaction ID
|
|
130
|
+
if (!data.id) throw Error("Expected an ID to be returned");
|
|
131
|
+
|
|
132
|
+
return data.id;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Query the blockchain
|
|
137
|
+
* @param queryData - The query data
|
|
138
|
+
* @returns a result of the query
|
|
139
|
+
*/
|
|
140
|
+
export const query = async (queryData: Query[]): Promise<QueryResponse[]> => {
|
|
141
|
+
const { data } = await network({
|
|
142
|
+
method: "POST",
|
|
143
|
+
url: `${BASE_URL}/accounts/*`,
|
|
144
|
+
data: { clauses: queryData },
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
return data;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get the block ref to use in a transaction
|
|
152
|
+
* @returns the block ref of head
|
|
153
|
+
*/
|
|
154
|
+
export const getBlockRef = async (): Promise<string> => {
|
|
155
|
+
const { data } = await network({
|
|
156
|
+
method: "GET",
|
|
157
|
+
url: `${BASE_URL}/blocks/best`,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return data.id.slice(0, 18);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get fees paid for the transaction
|
|
165
|
+
* @param transactionId - the id of the transaction
|
|
166
|
+
* @return the fee paid in VTHO or 0
|
|
167
|
+
*/
|
|
168
|
+
export const getFees = async (transactionID: string): Promise<BigNumber> => {
|
|
169
|
+
const { data } = await network({
|
|
170
|
+
method: "GET",
|
|
171
|
+
url: `${BASE_URL}/transactions/${transactionID}/receipt`,
|
|
172
|
+
params: { id: transactionID },
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (!data || !data.paid) return new BigNumber(0);
|
|
176
|
+
return new BigNumber(data.paid);
|
|
177
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
2
|
+
import eip55 from "eip55";
|
|
3
|
+
import { VechainSigner } from "../types";
|
|
4
|
+
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
5
|
+
import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
|
|
6
|
+
|
|
7
|
+
const resolver = (signerContext: SignerContext<VechainSigner>): GetAddressFn => {
|
|
8
|
+
return async (deviceId: string, { path, verify }: GetAddressOptions) => {
|
|
9
|
+
const sig = await signerContext(deviceId, async signer => {
|
|
10
|
+
return await signer.getAddress(path, verify, false); // Note: Do we need to check askChainCode or false?
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (!sig.address || !sig.publicKey.length)
|
|
14
|
+
throw Error(`[vechain] Response is empty ${sig.address} ${sig.publicKey}`);
|
|
15
|
+
|
|
16
|
+
const address = eip55.encode(sig.address);
|
|
17
|
+
return {
|
|
18
|
+
address,
|
|
19
|
+
publicKey: sig.publicKey,
|
|
20
|
+
path,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default resolver;
|