@ledgerhq/coin-sui 0.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 +23 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +19 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +9 -0
- package/jest.integ.config.js +7 -0
- package/lib/api/chain/index.d.ts +16 -0
- package/lib/api/chain/index.d.ts.map +1 -0
- package/lib/api/chain/index.js +3 -0
- package/lib/api/chain/index.js.map +1 -0
- package/lib/bridge/bridge.integration.test.d.ts +4 -0
- package/lib/bridge/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge/bridge.integration.test.js +136 -0
- package/lib/bridge/bridge.integration.test.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +12 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +20 -0
- package/lib/bridge/broadcast.js.map +1 -0
- 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 +48 -0
- package/lib/bridge/broadcast.test.js.map +1 -0
- package/lib/bridge/buildOptimisticOperation.d.ts +4 -0
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperation.js +76 -0
- package/lib/bridge/buildOptimisticOperation.js.map +1 -0
- package/lib/bridge/buildOptimisticOperation.test.d.ts +2 -0
- package/lib/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperation.test.js +52 -0
- package/lib/bridge/buildOptimisticOperation.test.js.map +1 -0
- package/lib/bridge/buildTransaction.d.ts +9 -0
- package/lib/bridge/buildTransaction.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.js +19 -0
- package/lib/bridge/buildTransaction.js.map +1 -0
- package/lib/bridge/buildTransaction.test.d.ts +2 -0
- package/lib/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.test.js +17 -0
- package/lib/bridge/buildTransaction.test.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +10 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +24 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +14 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +44 -0
- package/lib/bridge/estimateMaxSpendable.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 +25 -0
- package/lib/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib/bridge/formatters.d.ts +10 -0
- package/lib/bridge/formatters.d.ts.map +1 -0
- package/lib/bridge/formatters.js +24 -0
- package/lib/bridge/formatters.js.map +1 -0
- package/lib/bridge/formatters.test.d.ts +2 -0
- package/lib/bridge/formatters.test.d.ts.map +1 -0
- package/lib/bridge/formatters.test.js +18 -0
- package/lib/bridge/formatters.test.js.map +1 -0
- package/lib/bridge/getFeesForTransaction.d.ts +15 -0
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -0
- package/lib/bridge/getFeesForTransaction.js +32 -0
- package/lib/bridge/getFeesForTransaction.js.map +1 -0
- package/lib/bridge/getFeesForTransaction.test.d.ts +2 -0
- package/lib/bridge/getFeesForTransaction.test.d.ts.map +1 -0
- package/lib/bridge/getFeesForTransaction.test.js +35 -0
- package/lib/bridge/getFeesForTransaction.test.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +12 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +59 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- 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 +48 -0
- package/lib/bridge/getTransactionStatus.test.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 +63 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/preload.d.ts +11 -0
- package/lib/bridge/preload.d.ts.map +1 -0
- package/lib/bridge/preload.js +41 -0
- package/lib/bridge/preload.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +13 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +43 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- 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 +45 -0
- package/lib/bridge/prepareTransaction.test.js.map +1 -0
- package/lib/bridge/serialization.d.ts +7 -0
- package/lib/bridge/serialization.d.ts.map +1 -0
- package/lib/bridge/serialization.js +27 -0
- package/lib/bridge/serialization.js.map +1 -0
- package/lib/bridge/serialization.test.d.ts +2 -0
- package/lib/bridge/serialization.test.d.ts.map +1 -0
- package/lib/bridge/serialization.test.js +131 -0
- package/lib/bridge/serialization.test.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +9 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +72 -0
- package/lib/bridge/signOperation.js.map +1 -0
- 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 +76 -0
- package/lib/bridge/signOperation.test.js.map +1 -0
- package/lib/bridge/synchronisation.d.ts +21 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -0
- package/lib/bridge/synchronisation.js +65 -0
- package/lib/bridge/synchronisation.js.map +1 -0
- package/lib/bridge/synchronisation.test.d.ts +2 -0
- package/lib/bridge/synchronisation.test.d.ts.map +1 -0
- package/lib/bridge/synchronisation.test.js +118 -0
- package/lib/bridge/synchronisation.test.js.map +1 -0
- package/lib/bridge/transaction.d.ts +15 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +55 -0
- package/lib/bridge/transaction.js.map +1 -0
- 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 +65 -0
- package/lib/bridge/transaction.test.js.map +1 -0
- package/lib/bridge/utils.d.ts +27 -0
- package/lib/bridge/utils.d.ts.map +1 -0
- package/lib/bridge/utils.js +57 -0
- package/lib/bridge/utils.js.map +1 -0
- package/lib/config.d.ts +15 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +9 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/logic/broadcast.d.ts +9 -0
- package/lib/logic/broadcast.d.ts.map +1 -0
- package/lib/logic/broadcast.js +26 -0
- package/lib/logic/broadcast.js.map +1 -0
- package/lib/logic/craftTransaction.d.ts +17 -0
- package/lib/logic/craftTransaction.d.ts.map +1 -0
- package/lib/logic/craftTransaction.js +22 -0
- package/lib/logic/craftTransaction.js.map +1 -0
- package/lib/logic/estimateFees.d.ts +10 -0
- package/lib/logic/estimateFees.d.ts.map +1 -0
- package/lib/logic/estimateFees.js +20 -0
- package/lib/logic/estimateFees.js.map +1 -0
- package/lib/logic/index.d.ts +4 -0
- package/lib/logic/index.d.ts.map +1 -0
- package/lib/logic/index.js +10 -0
- package/lib/logic/index.js.map +1 -0
- package/lib/network/index.d.ts +18 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +17 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/sdk.d.ts +61 -0
- package/lib/network/sdk.d.ts.map +1 -0
- package/lib/network/sdk.integration.test.d.ts +2 -0
- package/lib/network/sdk.integration.test.d.ts.map +1 -0
- package/lib/network/sdk.integration.test.js +70 -0
- package/lib/network/sdk.integration.test.js.map +1 -0
- package/lib/network/sdk.js +205 -0
- package/lib/network/sdk.js.map +1 -0
- package/lib/network/sdk.test.d.ts +2 -0
- package/lib/network/sdk.test.d.ts.map +1 -0
- package/lib/network/sdk.test.js +166 -0
- package/lib/network/sdk.test.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 +20 -0
- package/lib/signer/getAddress.js.map +1 -0
- 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 +106 -0
- package/lib/signer/getAddress.test.js.map +1 -0
- package/lib/signer/index.d.ts +6 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +11 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/test/cli.d.ts +16 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +16 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/types/bridge.d.ts +72 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.fixture.d.ts +30 -0
- package/lib/types/bridge.fixture.d.ts.map +1 -0
- package/lib/types/bridge.fixture.js +86 -0
- package/lib/types/bridge.fixture.js.map +1 -0
- package/lib/types/bridge.js +3 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +20 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/model.d.ts +6 -0
- package/lib/types/model.d.ts.map +1 -0
- package/lib/types/model.js +3 -0
- package/lib/types/model.js.map +1 -0
- package/lib/types/signer.d.ts +13 -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/utils.d.ts +7 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +13 -0
- package/lib/utils.js.map +1 -0
- package/lib-es/api/chain/index.d.ts +16 -0
- package/lib-es/api/chain/index.d.ts.map +1 -0
- package/lib-es/api/chain/index.js +2 -0
- package/lib-es/api/chain/index.js.map +1 -0
- package/lib-es/bridge/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge/bridge.integration.test.js +130 -0
- package/lib-es/bridge/bridge.integration.test.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +12 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +16 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- 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 +46 -0
- package/lib-es/bridge/broadcast.test.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts +4 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.js +69 -0
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.test.d.ts +2 -0
- package/lib-es/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.test.js +47 -0
- package/lib-es/bridge/buildOptimisticOperation.test.js.map +1 -0
- package/lib-es/bridge/buildTransaction.d.ts +9 -0
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.js +11 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -0
- package/lib-es/bridge/buildTransaction.test.d.ts +2 -0
- package/lib-es/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.test.js +15 -0
- package/lib-es/bridge/buildTransaction.test.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +10 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +20 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +14 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +37 -0
- package/lib-es/bridge/estimateMaxSpendable.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 +23 -0
- package/lib-es/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib-es/bridge/formatters.d.ts +10 -0
- package/lib-es/bridge/formatters.d.ts.map +1 -0
- package/lib-es/bridge/formatters.js +19 -0
- package/lib-es/bridge/formatters.js.map +1 -0
- package/lib-es/bridge/formatters.test.d.ts +2 -0
- package/lib-es/bridge/formatters.test.d.ts.map +1 -0
- package/lib-es/bridge/formatters.test.js +16 -0
- package/lib-es/bridge/formatters.test.js.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.d.ts +15 -0
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.js +29 -0
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.test.d.ts +2 -0
- package/lib-es/bridge/getFeesForTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.test.js +30 -0
- package/lib-es/bridge/getFeesForTransaction.test.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +12 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +55 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- 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 +43 -0
- package/lib-es/bridge/getTransactionStatus.test.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 +56 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/preload.d.ts +11 -0
- package/lib-es/bridge/preload.d.ts.map +1 -0
- package/lib-es/bridge/preload.js +32 -0
- package/lib-es/bridge/preload.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +13 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +36 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- 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 +40 -0
- package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
- package/lib-es/bridge/serialization.d.ts +7 -0
- package/lib-es/bridge/serialization.d.ts.map +1 -0
- package/lib-es/bridge/serialization.js +20 -0
- package/lib-es/bridge/serialization.js.map +1 -0
- package/lib-es/bridge/serialization.test.d.ts +2 -0
- package/lib-es/bridge/serialization.test.d.ts.map +1 -0
- package/lib-es/bridge/serialization.test.js +126 -0
- package/lib-es/bridge/serialization.test.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +9 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +68 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- 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 +71 -0
- package/lib-es/bridge/signOperation.test.js.map +1 -0
- package/lib-es/bridge/synchronisation.d.ts +21 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -0
- package/lib-es/bridge/synchronisation.js +61 -0
- package/lib-es/bridge/synchronisation.js.map +1 -0
- package/lib-es/bridge/synchronisation.test.d.ts +2 -0
- package/lib-es/bridge/synchronisation.test.d.ts.map +1 -0
- package/lib-es/bridge/synchronisation.test.js +113 -0
- package/lib-es/bridge/synchronisation.test.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +15 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +49 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- 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 +63 -0
- package/lib-es/bridge/transaction.test.js.map +1 -0
- package/lib-es/bridge/utils.d.ts +27 -0
- package/lib-es/bridge/utils.d.ts.map +1 -0
- package/lib-es/bridge/utils.js +51 -0
- package/lib-es/bridge/utils.js.map +1 -0
- package/lib-es/config.d.ts +15 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +4 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/index.d.ts +3 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +3 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/logic/broadcast.d.ts +9 -0
- package/lib-es/logic/broadcast.d.ts.map +1 -0
- package/lib-es/logic/broadcast.js +19 -0
- package/lib-es/logic/broadcast.js.map +1 -0
- package/lib-es/logic/craftTransaction.d.ts +17 -0
- package/lib-es/logic/craftTransaction.d.ts.map +1 -0
- package/lib-es/logic/craftTransaction.js +15 -0
- package/lib-es/logic/craftTransaction.js.map +1 -0
- package/lib-es/logic/estimateFees.d.ts +10 -0
- package/lib-es/logic/estimateFees.d.ts.map +1 -0
- package/lib-es/logic/estimateFees.js +13 -0
- package/lib-es/logic/estimateFees.js.map +1 -0
- package/lib-es/logic/index.d.ts +4 -0
- package/lib-es/logic/index.d.ts.map +1 -0
- package/lib-es/logic/index.js +4 -0
- package/lib-es/logic/index.js.map +1 -0
- package/lib-es/network/index.d.ts +18 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +10 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/sdk.d.ts +61 -0
- package/lib-es/network/sdk.d.ts.map +1 -0
- package/lib-es/network/sdk.integration.test.d.ts +2 -0
- package/lib-es/network/sdk.integration.test.d.ts.map +1 -0
- package/lib-es/network/sdk.integration.test.js +65 -0
- package/lib-es/network/sdk.integration.test.js.map +1 -0
- package/lib-es/network/sdk.js +189 -0
- package/lib-es/network/sdk.js.map +1 -0
- package/lib-es/network/sdk.test.d.ts +2 -0
- package/lib-es/network/sdk.test.d.ts.map +1 -0
- package/lib-es/network/sdk.test.js +164 -0
- package/lib-es/network/sdk.test.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 +18 -0
- package/lib-es/signer/getAddress.js.map +1 -0
- 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 +101 -0
- package/lib-es/signer/getAddress.test.js.map +1 -0
- package/lib-es/signer/index.d.ts +6 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +6 -0
- package/lib-es/signer/index.js.map +1 -0
- package/lib-es/test/cli.d.ts +16 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +13 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/types/bridge.d.ts +72 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.fixture.d.ts +30 -0
- package/lib-es/types/bridge.fixture.d.ts.map +1 -0
- package/lib-es/types/bridge.fixture.js +80 -0
- package/lib-es/types/bridge.fixture.js.map +1 -0
- package/lib-es/types/bridge.js +2 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/index.d.ts +4 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +4 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/model.d.ts +6 -0
- package/lib-es/types/model.d.ts.map +1 -0
- package/lib-es/types/model.js +2 -0
- package/lib-es/types/model.js.map +1 -0
- package/lib-es/types/signer.d.ts +13 -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/lib-es/utils.d.ts +7 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +9 -0
- package/lib-es/utils.js.map +1 -0
- package/package.json +152 -0
- package/src/api/chain/index.ts +17 -0
- package/src/bridge/bridge.integration.test.ts +140 -0
- package/src/bridge/broadcast.test.ts +52 -0
- package/src/bridge/broadcast.ts +21 -0
- package/src/bridge/buildOptimisticOperation.test.ts +53 -0
- package/src/bridge/buildOptimisticOperation.ts +105 -0
- package/src/bridge/buildTransaction.test.ts +17 -0
- package/src/bridge/buildTransaction.ts +14 -0
- package/src/bridge/createTransaction.ts +23 -0
- package/src/bridge/estimateMaxSpendable.test.ts +27 -0
- package/src/bridge/estimateMaxSpendable.ts +46 -0
- package/src/bridge/formatters.test.ts +17 -0
- package/src/bridge/formatters.ts +26 -0
- package/src/bridge/getFeesForTransaction.test.ts +36 -0
- package/src/bridge/getFeesForTransaction.ts +37 -0
- package/src/bridge/getTransactionStatus.test.ts +57 -0
- package/src/bridge/getTransactionStatus.ts +73 -0
- package/src/bridge/index.ts +77 -0
- package/src/bridge/preload.ts +46 -0
- package/src/bridge/prepareTransaction.test.ts +47 -0
- package/src/bridge/prepareTransaction.ts +44 -0
- package/src/bridge/serialization.test.ts +135 -0
- package/src/bridge/serialization.ts +24 -0
- package/src/bridge/signOperation.test.ts +80 -0
- package/src/bridge/signOperation.ts +101 -0
- package/src/bridge/synchronisation.test.ts +140 -0
- package/src/bridge/synchronisation.ts +75 -0
- package/src/bridge/transaction.test.ts +73 -0
- package/src/bridge/transaction.ts +61 -0
- package/src/bridge/utils.ts +69 -0
- package/src/config.ts +19 -0
- package/src/index.ts +3 -0
- package/src/logic/broadcast.ts +19 -0
- package/src/logic/craftTransaction.ts +28 -0
- package/src/logic/estimateFees.ts +14 -0
- package/src/logic/index.ts +3 -0
- package/src/network/index.ts +17 -0
- package/src/network/sdk.integration.test.ts +75 -0
- package/src/network/sdk.test.ts +203 -0
- package/src/network/sdk.ts +262 -0
- package/src/signer/getAddress.test.ts +119 -0
- package/src/signer/getAddress.ts +26 -0
- package/src/signer/index.ts +7 -0
- package/src/test/cli.ts +21 -0
- package/src/types/bridge.fixture.ts +84 -0
- package/src/types/bridge.ts +95 -0
- package/src/types/index.ts +3 -0
- package/src/types/model.ts +7 -0
- package/src/types/signer.ts +12 -0
- package/src/utils.ts +8 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PaginatedTransactionResponse,
|
|
3
|
+
QueryTransactionBlocksParams,
|
|
4
|
+
SuiClient,
|
|
5
|
+
ExecuteTransactionBlockParams,
|
|
6
|
+
TransactionEffects,
|
|
7
|
+
} from "@mysten/sui/client";
|
|
8
|
+
import { TransactionBlockData, SuiTransactionBlockResponse, SuiCallArg } from "@mysten/sui/client";
|
|
9
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
10
|
+
import { BigNumber } from "bignumber.js";
|
|
11
|
+
import type { Operation, OperationType } from "@ledgerhq/types-live";
|
|
12
|
+
|
|
13
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
14
|
+
|
|
15
|
+
import { makeLRUCache, minutes } from "@ledgerhq/live-network/cache";
|
|
16
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
17
|
+
|
|
18
|
+
import type { Transaction as TransactionType } from "../types";
|
|
19
|
+
import type { CreateExtrinsicArg } from "../logic/craftTransaction";
|
|
20
|
+
import { ensureAddressFormat } from "../utils";
|
|
21
|
+
|
|
22
|
+
type AsyncApiFunction<T> = (api: SuiClient) => Promise<T>;
|
|
23
|
+
|
|
24
|
+
const rpcUrl = getEnv("API_SUI_NODE_PROXY");
|
|
25
|
+
|
|
26
|
+
let api: SuiClient | null = null;
|
|
27
|
+
|
|
28
|
+
const TRANSACTIONS_REQUEST_LIMIT = 100;
|
|
29
|
+
|
|
30
|
+
const BLOCK_HEIGHT = 5; // sui has no block height metainfo, we use it simulate proper icon statuses in apps
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Connects to Sui Api
|
|
34
|
+
*/
|
|
35
|
+
async function withApi<T>(execute: AsyncApiFunction<T>) {
|
|
36
|
+
if (!api) {
|
|
37
|
+
api = new SuiClient({ url: rpcUrl });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const result = await execute(api);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const getBalanceCached = makeLRUCache(
|
|
45
|
+
({ api, owner }: { api: SuiClient; owner: string }) => api.getBalance({ owner }),
|
|
46
|
+
(params: { api: SuiClient; owner: string }) => params.owner,
|
|
47
|
+
minutes(1),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get account balance
|
|
52
|
+
*/
|
|
53
|
+
export const getAccount = async (addr: string) =>
|
|
54
|
+
withApi(async api => {
|
|
55
|
+
const balance = await getBalanceCached({ api, owner: addr });
|
|
56
|
+
return {
|
|
57
|
+
blockHeight: BLOCK_HEIGHT * 2,
|
|
58
|
+
balance: BigNumber(balance.totalBalance),
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns true if account is the signer
|
|
64
|
+
*/
|
|
65
|
+
export function isSender(addr: string, transaction?: TransactionBlockData): boolean {
|
|
66
|
+
return transaction?.sender === ensureAddressFormat(addr);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Map transaction to an Operation Type
|
|
71
|
+
*/
|
|
72
|
+
export function getOperationType(addr: string, transaction?: TransactionBlockData): OperationType {
|
|
73
|
+
return isSender(addr, transaction) ? "OUT" : "IN";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Extract senders from transaction
|
|
78
|
+
*/
|
|
79
|
+
export const getOperationSenders = (transaction?: TransactionBlockData): string[] => {
|
|
80
|
+
return transaction?.sender ? [transaction?.sender] : [];
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Extract recipients from transaction
|
|
85
|
+
*/
|
|
86
|
+
export const getOperationRecipients = (transaction?: TransactionBlockData): string[] => {
|
|
87
|
+
if (transaction?.transaction.kind === "ProgrammableTransaction") {
|
|
88
|
+
if (!transaction?.transaction?.inputs) return [];
|
|
89
|
+
const recipients: string[] = [];
|
|
90
|
+
transaction.transaction.inputs.forEach((input: SuiCallArg) => {
|
|
91
|
+
if ("valueType" in input && input.valueType === "address") {
|
|
92
|
+
recipients.push(String(input.value));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return recipients;
|
|
96
|
+
}
|
|
97
|
+
return [];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Extract value from transaction
|
|
102
|
+
*/
|
|
103
|
+
export const getOperationAmount = (
|
|
104
|
+
address: string,
|
|
105
|
+
transaction: SuiTransactionBlockResponse,
|
|
106
|
+
): BigNumber => {
|
|
107
|
+
let amount = new BigNumber(0);
|
|
108
|
+
if (!transaction?.balanceChanges) return amount;
|
|
109
|
+
for (const balanceChange of transaction.balanceChanges) {
|
|
110
|
+
if (
|
|
111
|
+
typeof balanceChange.owner !== "string" &&
|
|
112
|
+
"AddressOwner" in balanceChange.owner &&
|
|
113
|
+
balanceChange.owner.AddressOwner === address
|
|
114
|
+
) {
|
|
115
|
+
if (balanceChange.amount[0] === "-") {
|
|
116
|
+
amount = amount.minus(balanceChange.amount);
|
|
117
|
+
} else {
|
|
118
|
+
amount = amount.plus(balanceChange.amount);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return amount;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Extract fee from transaction
|
|
127
|
+
*/
|
|
128
|
+
export const getOperationFee = (transaction: SuiTransactionBlockResponse): BigNumber => {
|
|
129
|
+
const gas = transaction.effects!.gasUsed;
|
|
130
|
+
|
|
131
|
+
const computationCost = BigNumber(gas.computationCost);
|
|
132
|
+
const storageCost = BigNumber(gas.storageCost);
|
|
133
|
+
const storageRebate = BigNumber(gas.storageRebate);
|
|
134
|
+
|
|
135
|
+
return computationCost.plus(storageCost).minus(storageRebate);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Extract date from transaction
|
|
140
|
+
*/
|
|
141
|
+
export const getOperationDate = (transaction: SuiTransactionBlockResponse): Date => {
|
|
142
|
+
return new Date(parseInt(transaction.timestampMs!));
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Map the Sui history transaction to a Ledger Live Operation
|
|
147
|
+
*/
|
|
148
|
+
export function transactionToOperation(
|
|
149
|
+
accountId: string,
|
|
150
|
+
address: string,
|
|
151
|
+
transaction: SuiTransactionBlockResponse,
|
|
152
|
+
): Operation {
|
|
153
|
+
const type = getOperationType(address, transaction.transaction?.data);
|
|
154
|
+
const hash = transaction.digest;
|
|
155
|
+
return {
|
|
156
|
+
id: encodeOperationId(accountId, hash, type),
|
|
157
|
+
accountId,
|
|
158
|
+
blockHash: hash,
|
|
159
|
+
blockHeight: BLOCK_HEIGHT,
|
|
160
|
+
date: getOperationDate(transaction),
|
|
161
|
+
extra: {},
|
|
162
|
+
fee: getOperationFee(transaction),
|
|
163
|
+
hasFailed: transaction.effects?.status.status != "success",
|
|
164
|
+
hash,
|
|
165
|
+
recipients: getOperationRecipients(transaction.transaction?.data),
|
|
166
|
+
senders: getOperationSenders(transaction.transaction?.data),
|
|
167
|
+
type,
|
|
168
|
+
value: getOperationAmount(address, transaction),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Fetch operation list
|
|
174
|
+
*/
|
|
175
|
+
export const getOperations = async (
|
|
176
|
+
accountId: string,
|
|
177
|
+
addr: string,
|
|
178
|
+
inCursor?: string | null | undefined,
|
|
179
|
+
outCursor?: string | null | undefined,
|
|
180
|
+
): Promise<Operation[]> =>
|
|
181
|
+
withApi(async api => {
|
|
182
|
+
const sentOps = await loadOperation({ api, type: "OUT", addr, cursor: outCursor });
|
|
183
|
+
const receivedOps = await loadOperation({ api, type: "IN", addr, cursor: inCursor });
|
|
184
|
+
const rawTransactions = [...sentOps, ...receivedOps].sort(
|
|
185
|
+
(a, b) => Number(b.timestampMs) - Number(a.timestampMs),
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
return rawTransactions.map(transaction => transactionToOperation(accountId, addr, transaction));
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const getTotalGasUsed = (effects?: TransactionEffects | null): bigint => {
|
|
192
|
+
const gasSummary = effects?.gasUsed;
|
|
193
|
+
if (!gasSummary) return BigInt(0);
|
|
194
|
+
return (
|
|
195
|
+
BigInt(gasSummary.computationCost) +
|
|
196
|
+
BigInt(gasSummary.storageCost) -
|
|
197
|
+
BigInt(gasSummary.storageRebate)
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const paymentInfo = async (sender: string, fakeTransaction: TransactionType) =>
|
|
202
|
+
withApi(async api => {
|
|
203
|
+
const tx = new Transaction();
|
|
204
|
+
tx.setSender(ensureAddressFormat(sender));
|
|
205
|
+
const [coin] = tx.splitCoins(tx.gas, [fakeTransaction.amount.toNumber()]);
|
|
206
|
+
tx.transferObjects([coin], fakeTransaction.recipient);
|
|
207
|
+
const txb = await tx.build({ client: api });
|
|
208
|
+
const dryRunTxResponse = await api.dryRunTransactionBlock({ transactionBlock: txb });
|
|
209
|
+
const fees = getTotalGasUsed(dryRunTxResponse.effects);
|
|
210
|
+
return {
|
|
211
|
+
gasBudget: dryRunTxResponse.input.gasData.budget,
|
|
212
|
+
totalGasUsed: fees,
|
|
213
|
+
fees,
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
export const createTransaction = async (address: string, transaction: CreateExtrinsicArg) =>
|
|
218
|
+
withApi(async api => {
|
|
219
|
+
const tx = new Transaction();
|
|
220
|
+
tx.setSender(ensureAddressFormat(address));
|
|
221
|
+
|
|
222
|
+
const [coin] = tx.splitCoins(tx.gas, [transaction.amount.toNumber()]);
|
|
223
|
+
tx.transferObjects([coin], transaction.recipient);
|
|
224
|
+
|
|
225
|
+
return tx.build({ client: api });
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
export const executeTransactionBlock = async (params: ExecuteTransactionBlockParams) =>
|
|
229
|
+
withApi(async api => {
|
|
230
|
+
return api.executeTransactionBlock(params);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// load from curos point or from begining until we reach the end
|
|
234
|
+
const loadOperation = async (params: {
|
|
235
|
+
api: SuiClient;
|
|
236
|
+
type: OperationType;
|
|
237
|
+
addr: string;
|
|
238
|
+
cursor?: string | null | undefined;
|
|
239
|
+
}): Promise<PaginatedTransactionResponse["data"]> => {
|
|
240
|
+
const { api, addr, type, cursor } = params;
|
|
241
|
+
const filter: QueryTransactionBlocksParams["filter"] =
|
|
242
|
+
type === "IN" ? { ToAddress: addr } : { FromAddress: addr };
|
|
243
|
+
|
|
244
|
+
const { data, nextCursor, hasNextPage } = await api.queryTransactionBlocks({
|
|
245
|
+
filter,
|
|
246
|
+
cursor,
|
|
247
|
+
order: "ascending",
|
|
248
|
+
options: {
|
|
249
|
+
showInput: true,
|
|
250
|
+
showBalanceChanges: true,
|
|
251
|
+
showEffects: true, // To get transaction status and gas fee details
|
|
252
|
+
},
|
|
253
|
+
limit: TRANSACTIONS_REQUEST_LIMIT,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
if (hasNextPage) {
|
|
257
|
+
const newData = await loadOperation({ api, type, addr, cursor: nextCursor });
|
|
258
|
+
return [...newData, ...data];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return data;
|
|
262
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import getAddressResolver from "./";
|
|
2
|
+
|
|
3
|
+
describe("getAddress resolver", () => {
|
|
4
|
+
const mockDeviceId = "mock-device-id";
|
|
5
|
+
const mockPath = "44'/784'/0'/0'/0'";
|
|
6
|
+
|
|
7
|
+
it("should successfully resolve an address", async () => {
|
|
8
|
+
// Mock address and public key data
|
|
9
|
+
const mockAddress = Buffer.from("0x123abc");
|
|
10
|
+
const mockPublicKey = Buffer.from("deadbeef");
|
|
11
|
+
|
|
12
|
+
const mockSigner = {
|
|
13
|
+
getPublicKey: jest.fn().mockResolvedValue({
|
|
14
|
+
address: mockAddress,
|
|
15
|
+
publicKey: mockPublicKey,
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const mockSignerContext = jest
|
|
20
|
+
.fn()
|
|
21
|
+
.mockImplementation((deviceId, callback) => callback(mockSigner));
|
|
22
|
+
|
|
23
|
+
const getAddress = getAddressResolver(mockSignerContext);
|
|
24
|
+
|
|
25
|
+
const result = await getAddress(mockDeviceId, {
|
|
26
|
+
currency: {
|
|
27
|
+
type: "CryptoCurrency",
|
|
28
|
+
id: "sui",
|
|
29
|
+
coinType: 784,
|
|
30
|
+
name: "Sui",
|
|
31
|
+
managerAppName: "Sui",
|
|
32
|
+
ticker: "SUI",
|
|
33
|
+
scheme: "sui",
|
|
34
|
+
color: "#000",
|
|
35
|
+
family: "sui",
|
|
36
|
+
units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
|
|
37
|
+
explorerViews: [],
|
|
38
|
+
},
|
|
39
|
+
path: "44'/784'/0'/0'/0'",
|
|
40
|
+
derivationMode: "sui",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(result).toEqual({
|
|
44
|
+
address: "0x" + mockAddress.toString("hex"),
|
|
45
|
+
publicKey: mockPublicKey.toString("hex"),
|
|
46
|
+
path: mockPath,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should throw error when address is missing", async () => {
|
|
51
|
+
const mockSigner = {
|
|
52
|
+
getPublicKey: jest.fn().mockResolvedValue({
|
|
53
|
+
address: null,
|
|
54
|
+
publicKey: Buffer.from("deadbeef"),
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const mockSignerContext = jest
|
|
59
|
+
.fn()
|
|
60
|
+
.mockImplementation((deviceId, callback) => callback(mockSigner));
|
|
61
|
+
|
|
62
|
+
const getAddress = getAddressResolver(mockSignerContext);
|
|
63
|
+
|
|
64
|
+
await expect(
|
|
65
|
+
getAddress(mockDeviceId, {
|
|
66
|
+
currency: {
|
|
67
|
+
type: "CryptoCurrency",
|
|
68
|
+
id: "sui",
|
|
69
|
+
coinType: 784,
|
|
70
|
+
name: "Sui",
|
|
71
|
+
managerAppName: "Sui",
|
|
72
|
+
ticker: "SUI",
|
|
73
|
+
scheme: "sui",
|
|
74
|
+
color: "#000",
|
|
75
|
+
family: "sui",
|
|
76
|
+
units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
|
|
77
|
+
explorerViews: [],
|
|
78
|
+
},
|
|
79
|
+
path: "44'/784'/0'/0'/0'",
|
|
80
|
+
derivationMode: "sui",
|
|
81
|
+
}),
|
|
82
|
+
).rejects.toThrow("Failed to get address from device");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should throw error when publicKey is missing", async () => {
|
|
86
|
+
const mockSigner = {
|
|
87
|
+
getPublicKey: jest.fn().mockResolvedValue({
|
|
88
|
+
address: Buffer.from("0x123abc"),
|
|
89
|
+
publicKey: null,
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const mockSignerContext = jest
|
|
94
|
+
.fn()
|
|
95
|
+
.mockImplementation((deviceId, callback) => callback(mockSigner));
|
|
96
|
+
|
|
97
|
+
const getAddress = getAddressResolver(mockSignerContext);
|
|
98
|
+
|
|
99
|
+
await expect(
|
|
100
|
+
getAddress(mockDeviceId, {
|
|
101
|
+
currency: {
|
|
102
|
+
type: "CryptoCurrency",
|
|
103
|
+
id: "sui",
|
|
104
|
+
coinType: 784,
|
|
105
|
+
name: "Sui",
|
|
106
|
+
managerAppName: "Sui",
|
|
107
|
+
ticker: "SUI",
|
|
108
|
+
scheme: "sui",
|
|
109
|
+
color: "#000",
|
|
110
|
+
family: "sui",
|
|
111
|
+
units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
|
|
112
|
+
explorerViews: [],
|
|
113
|
+
},
|
|
114
|
+
path: "44'/784'/0'/0'/0'",
|
|
115
|
+
derivationMode: "sui",
|
|
116
|
+
}),
|
|
117
|
+
).rejects.toThrow("Failed to get address from device");
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { log } from "@ledgerhq/logs";
|
|
2
|
+
import type { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
3
|
+
import type { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
4
|
+
import type { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
|
|
5
|
+
import type { SuiSigner } from "../types";
|
|
6
|
+
import { ensureAddressFormat } from "../utils";
|
|
7
|
+
|
|
8
|
+
const resolver = (signerContext: SignerContext<SuiSigner>): GetAddressFn => {
|
|
9
|
+
return async (deviceId: string, { path, verify }: GetAddressOptions) => {
|
|
10
|
+
log("debug", "start getAddress process");
|
|
11
|
+
|
|
12
|
+
const result = await signerContext(deviceId, signer => signer.getPublicKey(path, verify));
|
|
13
|
+
|
|
14
|
+
if (!result.address || !result.publicKey) {
|
|
15
|
+
throw Error("Failed to get address from device");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
address: ensureAddressFormat(Buffer.from(result.address).toString("hex")),
|
|
20
|
+
publicKey: Buffer.from(result.publicKey).toString("hex"),
|
|
21
|
+
path,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default resolver;
|
package/src/test/cli.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Options =
|
|
2
|
+
| { name: string; type: StringConstructor; desc: string }
|
|
3
|
+
| { name: string; type: StringConstructor; desc: string; multiple: boolean };
|
|
4
|
+
|
|
5
|
+
const options: Array<Options> = [
|
|
6
|
+
{
|
|
7
|
+
name: "mode",
|
|
8
|
+
type: String,
|
|
9
|
+
desc: "mode of transaction: send",
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export type CliTools = {
|
|
14
|
+
options: Array<Options>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default function makeCliTools(): CliTools {
|
|
18
|
+
return {
|
|
19
|
+
options,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { SuiAccount } from "./bridge";
|
|
3
|
+
|
|
4
|
+
export const createFixtureAccount = (overrides = {}) =>
|
|
5
|
+
({
|
|
6
|
+
type: "Account",
|
|
7
|
+
id: "js:2:sui:0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0:sui",
|
|
8
|
+
used: true,
|
|
9
|
+
seedIdentifier: "99807c4b6e1b8b25120f633f5f7816a393e4d3e7f84bdf24bd8afe725911be91",
|
|
10
|
+
derivationMode: "sui",
|
|
11
|
+
index: 0,
|
|
12
|
+
freshAddress: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
|
|
13
|
+
freshAddressPath: "44'/784'/0'/0'/0'",
|
|
14
|
+
blockHeight: 10,
|
|
15
|
+
creationDate: new Date(),
|
|
16
|
+
balance: BigNumber(17997970360),
|
|
17
|
+
spendableBalance: BigNumber(17997970360),
|
|
18
|
+
operations: [],
|
|
19
|
+
operationsCount: 2,
|
|
20
|
+
pendingOperations: [],
|
|
21
|
+
currency: {
|
|
22
|
+
type: "CryptoCurrency",
|
|
23
|
+
id: "sui",
|
|
24
|
+
coinType: 784,
|
|
25
|
+
name: "Sui",
|
|
26
|
+
managerAppName: "Sui",
|
|
27
|
+
ticker: "SUI",
|
|
28
|
+
scheme: "sui",
|
|
29
|
+
color: "#000",
|
|
30
|
+
family: "sui",
|
|
31
|
+
units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
|
|
32
|
+
explorerViews: [
|
|
33
|
+
{
|
|
34
|
+
tx: "https://suiscan.xyz/mainnet/tx/$hash",
|
|
35
|
+
address: "https://suiscan.xyz/mainnet/account/$address",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
tx: "https://suivision.xyz/txblock/$hash",
|
|
39
|
+
address: "https://suivision.xyz/account/$address",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
lastSyncDate: new Date(),
|
|
44
|
+
swapHistory: [],
|
|
45
|
+
balanceHistoryCache: {
|
|
46
|
+
HOUR: {
|
|
47
|
+
balances: [0],
|
|
48
|
+
latestDate: new Date().getMilliseconds(),
|
|
49
|
+
},
|
|
50
|
+
DAY: { balances: [0], latestDate: new Date().getMilliseconds() },
|
|
51
|
+
WEEK: { balances: [0], latestDate: new Date().getMilliseconds() },
|
|
52
|
+
},
|
|
53
|
+
subAccounts: [],
|
|
54
|
+
suiResources: { nonce: 0 },
|
|
55
|
+
...overrides,
|
|
56
|
+
}) as SuiAccount;
|
|
57
|
+
|
|
58
|
+
export const createFixtureTransaction = (overrides = {}) => ({
|
|
59
|
+
family: "sui" as const,
|
|
60
|
+
mode: "send",
|
|
61
|
+
amount: BigNumber(3000000000),
|
|
62
|
+
recipient: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
|
|
63
|
+
useAllAmount: false,
|
|
64
|
+
fees: BigNumber(3976000),
|
|
65
|
+
errors: {},
|
|
66
|
+
skipVerify: true,
|
|
67
|
+
...overrides,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const createFixtureOperation = (overrides = {}) => ({
|
|
71
|
+
hash: "44298e5b1b7d73efc",
|
|
72
|
+
fee: BigNumber(3976000),
|
|
73
|
+
blockHash: null,
|
|
74
|
+
blockHeight: null,
|
|
75
|
+
extra: { transferAmount: BigNumber(1000000000) },
|
|
76
|
+
id: "js:2:sui:0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0:sui--OUT",
|
|
77
|
+
type: "OUT" as const,
|
|
78
|
+
value: BigNumber(1003976000),
|
|
79
|
+
senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
80
|
+
recipients: ["0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24"],
|
|
81
|
+
accountId: "js:2:sui:0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0:sui",
|
|
82
|
+
date: new Date(),
|
|
83
|
+
...overrides,
|
|
84
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import type {
|
|
3
|
+
TransactionCommon,
|
|
4
|
+
TransactionCommonRaw,
|
|
5
|
+
TransactionStatusCommon,
|
|
6
|
+
TransactionStatusCommonRaw,
|
|
7
|
+
Operation,
|
|
8
|
+
OperationRaw,
|
|
9
|
+
} from "@ledgerhq/types-live";
|
|
10
|
+
import type { Account, AccountRaw } from "@ledgerhq/types-live";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Sui account resources
|
|
14
|
+
*/
|
|
15
|
+
export type SuiResources = object;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sui account resources from raw JSON
|
|
19
|
+
*/
|
|
20
|
+
export type SuiResourcesRaw = object;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Sui transaction
|
|
24
|
+
*/
|
|
25
|
+
export type Transaction = TransactionCommon & {
|
|
26
|
+
mode: string;
|
|
27
|
+
family: "sui";
|
|
28
|
+
amount: BigNumber | null;
|
|
29
|
+
fees?: BigNumber | null;
|
|
30
|
+
errors: Record<string, Error>;
|
|
31
|
+
skipVerify?: boolean;
|
|
32
|
+
// add here all transaction-specific fields when implement other modes than "send"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sui transaction from a raw JSON
|
|
37
|
+
*/
|
|
38
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
39
|
+
family: "sui";
|
|
40
|
+
mode: string;
|
|
41
|
+
fees?: string;
|
|
42
|
+
// also the transaction fields as raw JSON data
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Sui currency data that will be preloaded.
|
|
47
|
+
* You can for instance add a list of validators for Proof-of-Stake blockchains,
|
|
48
|
+
* or any volatile data that could not be set as constants in the code (staking progress, fee estimation variables, etc.)
|
|
49
|
+
*/
|
|
50
|
+
export type SuiPreloadData = object;
|
|
51
|
+
|
|
52
|
+
export type SuiAccount = Account & {
|
|
53
|
+
// On some blockchain, an account can have resources (gained, delegated, ...)
|
|
54
|
+
suiResources?: SuiResources;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type SuiAccountRaw = AccountRaw & {
|
|
58
|
+
suiResources?: SuiResourcesRaw;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
62
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
63
|
+
|
|
64
|
+
export type SuiOperation = Operation<SuiOperationExtra>;
|
|
65
|
+
export type SuiOperationRaw = OperationRaw<SuiOperationExtraRaw>;
|
|
66
|
+
|
|
67
|
+
export type SuiOperationExtra = {
|
|
68
|
+
transferAmount?: BigNumber;
|
|
69
|
+
};
|
|
70
|
+
export type SuiOperationExtraRaw = Record<string, string>;
|
|
71
|
+
|
|
72
|
+
export type SuiSignedOperation = {
|
|
73
|
+
operation: SuiOperation;
|
|
74
|
+
signature: string;
|
|
75
|
+
rawData: {
|
|
76
|
+
unsigned: string;
|
|
77
|
+
serializedSignature: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type TransferCommand = {
|
|
82
|
+
kind: "transfer";
|
|
83
|
+
sender: string;
|
|
84
|
+
recipient: string;
|
|
85
|
+
amount: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type Command = TransferCommand;
|
|
89
|
+
|
|
90
|
+
export type CommandDescriptor = {
|
|
91
|
+
command: Command;
|
|
92
|
+
fee: number;
|
|
93
|
+
warnings: Record<string, Error>;
|
|
94
|
+
errors: Record<string, Error>;
|
|
95
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Sui from "@ledgerhq/hw-app-sui";
|
|
2
|
+
|
|
3
|
+
export type SuiAddress = {
|
|
4
|
+
pubKey: string;
|
|
5
|
+
address: string;
|
|
6
|
+
return_code: number;
|
|
7
|
+
};
|
|
8
|
+
export type SuiSignature = {
|
|
9
|
+
signature: null | string;
|
|
10
|
+
return_code: number;
|
|
11
|
+
};
|
|
12
|
+
export interface SuiSigner extends Sui {}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures that the address is in the format `0x...`
|
|
3
|
+
* @param addr The address to ensure the format of
|
|
4
|
+
* @returns The address in the format `0x...`
|
|
5
|
+
*/
|
|
6
|
+
export function ensureAddressFormat(addr: string): `0x${string}` {
|
|
7
|
+
return (addr?.startsWith("0x") ? addr : `0x${addr}`) as `0x${string}`;
|
|
8
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"downlevelIteration": true,
|
|
7
|
+
"lib": ["es2020", "dom"],
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"exactOptionalPropertyTypes": true,
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"moduleResolution": "bundler"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|