@ledgerhq/coin-kaspa 1.1.0-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/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +87 -0
- package/CHANGELOG.md +978 -0
- package/LICENSE.txt +21 -0
- package/jest-global-setup.js +9 -0
- package/jest.config.js +21 -0
- package/jest.integ.config.js +8 -0
- package/lib/bridge/broadcast.d.ts +8 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +16 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/buildInitialOperation.d.ts +5 -0
- package/lib/bridge/buildInitialOperation.d.ts.map +1 -0
- package/lib/bridge/buildInitialOperation.js +31 -0
- package/lib/bridge/buildInitialOperation.js.map +1 -0
- package/lib/bridge/buildTransaction.d.ts +16 -0
- package/lib/bridge/buildTransaction.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.js +63 -0
- package/lib/bridge/buildTransaction.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +4 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +15 -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 +19 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +4 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +68 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +9 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +75 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/initAccount.d.ts +2 -0
- package/lib/bridge/initAccount.d.ts.map +1 -0
- package/lib/bridge/initAccount.js +6 -0
- package/lib/bridge/initAccount.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +14 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +46 -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 +34 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/synchronization.d.ts +4 -0
- package/lib/bridge/synchronization.d.ts.map +1 -0
- package/lib/bridge/synchronization.js +66 -0
- package/lib/bridge/synchronization.js.map +1 -0
- package/lib/config.d.ts +8 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +9 -0
- package/lib/config.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +11 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +32 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +8 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +8 -0
- package/lib/errors.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +14 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/logic/base32.d.ts +30 -0
- package/lib/logic/base32.d.ts.map +1 -0
- package/lib/logic/base32.js +99 -0
- package/lib/logic/base32.js.map +1 -0
- package/lib/logic/bip32.d.ts +9 -0
- package/lib/logic/bip32.d.ts.map +1 -0
- package/lib/logic/bip32.js +23 -0
- package/lib/logic/bip32.js.map +1 -0
- package/lib/logic/getAllTransactions.d.ts +3 -0
- package/lib/logic/getAllTransactions.d.ts.map +1 -0
- package/lib/logic/getAllTransactions.js +19 -0
- package/lib/logic/getAllTransactions.js.map +1 -0
- package/lib/logic/getFeeRate.d.ts +4 -0
- package/lib/logic/getFeeRate.d.ts.map +1 -0
- package/lib/logic/getFeeRate.js +19 -0
- package/lib/logic/getFeeRate.js.map +1 -0
- package/lib/logic/index.d.ts +11 -0
- package/lib/logic/index.d.ts.map +1 -0
- package/lib/logic/index.js +27 -0
- package/lib/logic/index.js.map +1 -0
- package/lib/logic/kaspaAddresses.d.ts +30 -0
- package/lib/logic/kaspaAddresses.d.ts.map +1 -0
- package/lib/logic/kaspaAddresses.js +231 -0
- package/lib/logic/kaspaAddresses.js.map +1 -0
- package/lib/logic/massCalcluation.d.ts +4 -0
- package/lib/logic/massCalcluation.d.ts.map +1 -0
- package/lib/logic/massCalcluation.js +40 -0
- package/lib/logic/massCalcluation.js.map +1 -0
- package/lib/logic/scanAddresses.d.ts +13 -0
- package/lib/logic/scanAddresses.d.ts.map +1 -0
- package/lib/logic/scanAddresses.js +147 -0
- package/lib/logic/scanAddresses.js.map +1 -0
- package/lib/logic/scanOperations.d.ts +3 -0
- package/lib/logic/scanOperations.d.ts.map +1 -0
- package/lib/logic/scanOperations.js +43 -0
- package/lib/logic/scanOperations.js.map +1 -0
- package/lib/logic/scanUtxos.d.ts +8 -0
- package/lib/logic/scanUtxos.d.ts.map +1 -0
- package/lib/logic/scanUtxos.js +39 -0
- package/lib/logic/scanUtxos.js.map +1 -0
- package/lib/logic/tests/bip32.test.d.ts +2 -0
- package/lib/logic/tests/bip32.test.d.ts.map +1 -0
- package/lib/logic/tests/bip32.test.js +64 -0
- package/lib/logic/tests/bip32.test.js.map +1 -0
- package/lib/logic/tests/getFeeRate.test.d.ts +2 -0
- package/lib/logic/tests/getFeeRate.test.d.ts.map +1 -0
- package/lib/logic/tests/getFeeRate.test.js +57 -0
- package/lib/logic/tests/getFeeRate.test.js.map +1 -0
- package/lib/logic/tests/kaspaAddresses.test.d.ts +2 -0
- package/lib/logic/tests/kaspaAddresses.test.d.ts.map +1 -0
- package/lib/logic/tests/kaspaAddresses.test.js +172 -0
- package/lib/logic/tests/kaspaAddresses.test.js.map +1 -0
- package/lib/logic/tests/massCalcluation.test.d.ts +2 -0
- package/lib/logic/tests/massCalcluation.test.d.ts.map +1 -0
- package/lib/logic/tests/massCalcluation.test.js +27 -0
- package/lib/logic/tests/massCalcluation.test.js.map +1 -0
- package/lib/logic/tests/scanAddresses.integ.test.d.ts +2 -0
- package/lib/logic/tests/scanAddresses.integ.test.d.ts.map +1 -0
- package/lib/logic/tests/scanAddresses.integ.test.js +18 -0
- package/lib/logic/tests/scanAddresses.integ.test.js.map +1 -0
- package/lib/logic/tests/scanOperations.integ.test.d.ts +2 -0
- package/lib/logic/tests/scanOperations.integ.test.d.ts.map +1 -0
- package/lib/logic/tests/scanOperations.integ.test.js +254 -0
- package/lib/logic/tests/scanOperations.integ.test.js.map +1 -0
- package/lib/logic/tests/scanOperations.test.d.ts +2 -0
- package/lib/logic/tests/scanOperations.test.d.ts.map +1 -0
- package/lib/logic/tests/scanOperations.test.js +184 -0
- package/lib/logic/tests/scanOperations.test.js.map +1 -0
- package/lib/logic/tests/scanUtxos.integ.test.d.ts +2 -0
- package/lib/logic/tests/scanUtxos.integ.test.d.ts.map +1 -0
- package/lib/logic/tests/scanUtxos.integ.test.js +13 -0
- package/lib/logic/tests/scanUtxos.integ.test.js.map +1 -0
- package/lib/logic/tests/scanUtxos.test.d.ts +2 -0
- package/lib/logic/tests/scanUtxos.test.d.ts.map +1 -0
- package/lib/logic/tests/scanUtxos.test.js +167 -0
- package/lib/logic/tests/scanUtxos.test.js.map +1 -0
- package/lib/logic/tests/utxoLib.test.d.ts +2 -0
- package/lib/logic/tests/utxoLib.test.d.ts.map +1 -0
- package/lib/logic/tests/utxoLib.test.js +26 -0
- package/lib/logic/tests/utxoLib.test.js.map +1 -0
- package/lib/logic/tests/utxoSelection.test.d.ts +10 -0
- package/lib/logic/tests/utxoSelection.test.d.ts.map +1 -0
- package/lib/logic/tests/utxoSelection.test.js +256 -0
- package/lib/logic/tests/utxoSelection.test.js.map +1 -0
- package/lib/logic/tests/validAddress.test.d.ts +2 -0
- package/lib/logic/tests/validAddress.test.d.ts.map +1 -0
- package/lib/logic/tests/validAddress.test.js +56 -0
- package/lib/logic/tests/validAddress.test.js.map +1 -0
- package/lib/logic/utxos/lib.d.ts +6 -0
- package/lib/logic/utxos/lib.d.ts.map +1 -0
- package/lib/logic/utxos/lib.js +27 -0
- package/lib/logic/utxos/lib.js.map +1 -0
- package/lib/logic/utxos/selection.d.ts +8 -0
- package/lib/logic/utxos/selection.d.ts.map +1 -0
- package/lib/logic/utxos/selection.js +80 -0
- package/lib/logic/utxos/selection.js.map +1 -0
- package/lib/network/config.d.ts +3 -0
- package/lib/network/config.d.ts.map +1 -0
- package/lib/network/config.js +8 -0
- package/lib/network/config.js.map +1 -0
- package/lib/network/getAddressesActive.d.ts +3 -0
- package/lib/network/getAddressesActive.d.ts.map +1 -0
- package/lib/network/getAddressesActive.js +25 -0
- package/lib/network/getAddressesActive.js.map +1 -0
- package/lib/network/getBalancesForAddresses.d.ts +3 -0
- package/lib/network/getBalancesForAddresses.d.ts.map +1 -0
- package/lib/network/getBalancesForAddresses.js +25 -0
- package/lib/network/getBalancesForAddresses.js.map +1 -0
- package/lib/network/getBlockDagInfo.d.ts +3 -0
- package/lib/network/getBlockDagInfo.d.ts.map +1 -0
- package/lib/network/getBlockDagInfo.js +24 -0
- package/lib/network/getBlockDagInfo.js.map +1 -0
- package/lib/network/getFeeEstimate.d.ts +3 -0
- package/lib/network/getFeeEstimate.d.ts.map +1 -0
- package/lib/network/getFeeEstimate.js +23 -0
- package/lib/network/getFeeEstimate.js.map +1 -0
- package/lib/network/getTransactions.d.ts +6 -0
- package/lib/network/getTransactions.d.ts.map +1 -0
- package/lib/network/getTransactions.js +19 -0
- package/lib/network/getTransactions.js.map +1 -0
- package/lib/network/getUtxosForAddresses.d.ts +3 -0
- package/lib/network/getUtxosForAddresses.d.ts.map +1 -0
- package/lib/network/getUtxosForAddresses.js +25 -0
- package/lib/network/getUtxosForAddresses.js.map +1 -0
- package/lib/network/getVirtualChainBlueScore.d.ts +2 -0
- package/lib/network/getVirtualChainBlueScore.d.ts.map +1 -0
- package/lib/network/getVirtualChainBlueScore.js +24 -0
- package/lib/network/getVirtualChainBlueScore.js.map +1 -0
- package/lib/network/index.d.ts +9 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +20 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/submitTransaction.d.ts +3 -0
- package/lib/network/submitTransaction.d.ts.map +1 -0
- package/lib/network/submitTransaction.js +27 -0
- package/lib/network/submitTransaction.js.map +1 -0
- package/lib/network/tests/getAddressesActive.test.d.ts +2 -0
- package/lib/network/tests/getAddressesActive.test.d.ts.map +1 -0
- package/lib/network/tests/getAddressesActive.test.js +65 -0
- package/lib/network/tests/getAddressesActive.test.js.map +1 -0
- package/lib/network/tests/getBalancesForAddresss.test.d.ts +2 -0
- package/lib/network/tests/getBalancesForAddresss.test.d.ts.map +1 -0
- package/lib/network/tests/getBalancesForAddresss.test.js +40 -0
- package/lib/network/tests/getBalancesForAddresss.test.js.map +1 -0
- package/lib/network/tests/getBlockDagInfo.test.d.ts +2 -0
- package/lib/network/tests/getBlockDagInfo.test.d.ts.map +1 -0
- package/lib/network/tests/getBlockDagInfo.test.js +36 -0
- package/lib/network/tests/getBlockDagInfo.test.js.map +1 -0
- package/lib/network/tests/getFeeEstimate.test.d.ts +2 -0
- package/lib/network/tests/getFeeEstimate.test.d.ts.map +1 -0
- package/lib/network/tests/getFeeEstimate.test.js +54 -0
- package/lib/network/tests/getFeeEstimate.test.js.map +1 -0
- package/lib/network/tests/getTransactions.test.d.ts +2 -0
- package/lib/network/tests/getTransactions.test.d.ts.map +1 -0
- package/lib/network/tests/getTransactions.test.js +157 -0
- package/lib/network/tests/getTransactions.test.js.map +1 -0
- package/lib/network/tests/getUtxosForAddress.test.d.ts +2 -0
- package/lib/network/tests/getUtxosForAddress.test.d.ts.map +1 -0
- package/lib/network/tests/getUtxosForAddress.test.js +142 -0
- package/lib/network/tests/getUtxosForAddress.test.js.map +1 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.d.ts +2 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.d.ts.map +1 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.js +27 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.js.map +1 -0
- package/lib/network/tests/submitTransaction.test.d.ts +2 -0
- package/lib/network/tests/submitTransaction.test.d.ts.map +1 -0
- package/lib/network/tests/submitTransaction.test.js +43 -0
- package/lib/network/tests/submitTransaction.test.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 +46 -0
- package/lib/test/bridgeDatasetTest.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 +30 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +2 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +18 -0
- package/lib/test/index.js.map +1 -0
- package/lib/transaction.d.ts +16 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +66 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types/addresses.d.ts +18 -0
- package/lib/types/addresses.d.ts.map +1 -0
- package/lib/types/addresses.js +3 -0
- package/lib/types/addresses.js.map +1 -0
- package/lib/types/bridge.d.ts +34 -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/errors.d.ts +10 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +8 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +18 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/kaspaHwTransaction.d.ts +89 -0
- package/lib/types/kaspaHwTransaction.d.ts.map +1 -0
- package/lib/types/kaspaHwTransaction.js +167 -0
- package/lib/types/kaspaHwTransaction.js.map +1 -0
- package/lib/types/kaspaNetwork.d.ts +22 -0
- package/lib/types/kaspaNetwork.d.ts.map +1 -0
- package/lib/types/kaspaNetwork.js +3 -0
- package/lib/types/kaspaNetwork.js.map +1 -0
- package/lib/types/network.d.ts +91 -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 +14 -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/bridge/broadcast.d.ts +8 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +12 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/buildInitialOperation.d.ts +5 -0
- package/lib-es/bridge/buildInitialOperation.d.ts.map +1 -0
- package/lib-es/bridge/buildInitialOperation.js +27 -0
- package/lib-es/bridge/buildInitialOperation.js.map +1 -0
- package/lib-es/bridge/buildTransaction.d.ts +16 -0
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.js +59 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +4 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +11 -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 +15 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +66 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +9 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +68 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/initAccount.d.ts +2 -0
- package/lib-es/bridge/initAccount.d.ts.map +1 -0
- package/lib-es/bridge/initAccount.js +2 -0
- package/lib-es/bridge/initAccount.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +14 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +39 -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 +27 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/synchronization.d.ts +4 -0
- package/lib-es/bridge/synchronization.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.js +62 -0
- package/lib-es/bridge/synchronization.js.map +1 -0
- package/lib-es/config.d.ts +8 -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/deviceTransactionConfig.d.ts +11 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +30 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +8 -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/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +12 -0
- package/lib-es/hw-getAddress.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/logic/base32.d.ts +30 -0
- package/lib-es/logic/base32.d.ts.map +1 -0
- package/lib-es/logic/base32.js +95 -0
- package/lib-es/logic/base32.js.map +1 -0
- package/lib-es/logic/bip32.d.ts +9 -0
- package/lib-es/logic/bip32.d.ts.map +1 -0
- package/lib-es/logic/bip32.js +17 -0
- package/lib-es/logic/bip32.js.map +1 -0
- package/lib-es/logic/getAllTransactions.d.ts +3 -0
- package/lib-es/logic/getAllTransactions.d.ts.map +1 -0
- package/lib-es/logic/getAllTransactions.js +15 -0
- package/lib-es/logic/getAllTransactions.js.map +1 -0
- package/lib-es/logic/getFeeRate.d.ts +4 -0
- package/lib-es/logic/getFeeRate.d.ts.map +1 -0
- package/lib-es/logic/getFeeRate.js +15 -0
- package/lib-es/logic/getFeeRate.js.map +1 -0
- package/lib-es/logic/index.d.ts +11 -0
- package/lib-es/logic/index.d.ts.map +1 -0
- package/lib-es/logic/index.js +11 -0
- package/lib-es/logic/index.js.map +1 -0
- package/lib-es/logic/kaspaAddresses.d.ts +30 -0
- package/lib-es/logic/kaspaAddresses.d.ts.map +1 -0
- package/lib-es/logic/kaspaAddresses.js +219 -0
- package/lib-es/logic/kaspaAddresses.js.map +1 -0
- package/lib-es/logic/massCalcluation.d.ts +4 -0
- package/lib-es/logic/massCalcluation.d.ts.map +1 -0
- package/lib-es/logic/massCalcluation.js +35 -0
- package/lib-es/logic/massCalcluation.js.map +1 -0
- package/lib-es/logic/scanAddresses.d.ts +13 -0
- package/lib-es/logic/scanAddresses.d.ts.map +1 -0
- package/lib-es/logic/scanAddresses.js +140 -0
- package/lib-es/logic/scanAddresses.js.map +1 -0
- package/lib-es/logic/scanOperations.d.ts +3 -0
- package/lib-es/logic/scanOperations.d.ts.map +1 -0
- package/lib-es/logic/scanOperations.js +39 -0
- package/lib-es/logic/scanOperations.js.map +1 -0
- package/lib-es/logic/scanUtxos.d.ts +8 -0
- package/lib-es/logic/scanUtxos.d.ts.map +1 -0
- package/lib-es/logic/scanUtxos.js +35 -0
- package/lib-es/logic/scanUtxos.js.map +1 -0
- package/lib-es/logic/tests/bip32.test.d.ts +2 -0
- package/lib-es/logic/tests/bip32.test.d.ts.map +1 -0
- package/lib-es/logic/tests/bip32.test.js +59 -0
- package/lib-es/logic/tests/bip32.test.js.map +1 -0
- package/lib-es/logic/tests/getFeeRate.test.d.ts +2 -0
- package/lib-es/logic/tests/getFeeRate.test.d.ts.map +1 -0
- package/lib-es/logic/tests/getFeeRate.test.js +55 -0
- package/lib-es/logic/tests/getFeeRate.test.js.map +1 -0
- package/lib-es/logic/tests/kaspaAddresses.test.d.ts +2 -0
- package/lib-es/logic/tests/kaspaAddresses.test.d.ts.map +1 -0
- package/lib-es/logic/tests/kaspaAddresses.test.js +170 -0
- package/lib-es/logic/tests/kaspaAddresses.test.js.map +1 -0
- package/lib-es/logic/tests/massCalcluation.test.d.ts +2 -0
- package/lib-es/logic/tests/massCalcluation.test.d.ts.map +1 -0
- package/lib-es/logic/tests/massCalcluation.test.js +22 -0
- package/lib-es/logic/tests/massCalcluation.test.js.map +1 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.d.ts +2 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.js +16 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.js.map +1 -0
- package/lib-es/logic/tests/scanOperations.integ.test.d.ts +2 -0
- package/lib-es/logic/tests/scanOperations.integ.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanOperations.integ.test.js +249 -0
- package/lib-es/logic/tests/scanOperations.integ.test.js.map +1 -0
- package/lib-es/logic/tests/scanOperations.test.d.ts +2 -0
- package/lib-es/logic/tests/scanOperations.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanOperations.test.js +156 -0
- package/lib-es/logic/tests/scanOperations.test.js.map +1 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.d.ts +2 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.js +11 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.js.map +1 -0
- package/lib-es/logic/tests/scanUtxos.test.d.ts +2 -0
- package/lib-es/logic/tests/scanUtxos.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanUtxos.test.js +139 -0
- package/lib-es/logic/tests/scanUtxos.test.js.map +1 -0
- package/lib-es/logic/tests/utxoLib.test.d.ts +2 -0
- package/lib-es/logic/tests/utxoLib.test.d.ts.map +1 -0
- package/lib-es/logic/tests/utxoLib.test.js +24 -0
- package/lib-es/logic/tests/utxoLib.test.js.map +1 -0
- package/lib-es/logic/tests/utxoSelection.test.d.ts +10 -0
- package/lib-es/logic/tests/utxoSelection.test.d.ts.map +1 -0
- package/lib-es/logic/tests/utxoSelection.test.js +229 -0
- package/lib-es/logic/tests/utxoSelection.test.js.map +1 -0
- package/lib-es/logic/tests/validAddress.test.d.ts +2 -0
- package/lib-es/logic/tests/validAddress.test.d.ts.map +1 -0
- package/lib-es/logic/tests/validAddress.test.js +54 -0
- package/lib-es/logic/tests/validAddress.test.js.map +1 -0
- package/lib-es/logic/utxos/lib.d.ts +6 -0
- package/lib-es/logic/utxos/lib.d.ts.map +1 -0
- package/lib-es/logic/utxos/lib.js +21 -0
- package/lib-es/logic/utxos/lib.js.map +1 -0
- package/lib-es/logic/utxos/selection.d.ts +8 -0
- package/lib-es/logic/utxos/selection.d.ts.map +1 -0
- package/lib-es/logic/utxos/selection.js +76 -0
- package/lib-es/logic/utxos/selection.js.map +1 -0
- package/lib-es/network/config.d.ts +3 -0
- package/lib-es/network/config.d.ts.map +1 -0
- package/lib-es/network/config.js +5 -0
- package/lib-es/network/config.js.map +1 -0
- package/lib-es/network/getAddressesActive.d.ts +3 -0
- package/lib-es/network/getAddressesActive.d.ts.map +1 -0
- package/lib-es/network/getAddressesActive.js +21 -0
- package/lib-es/network/getAddressesActive.js.map +1 -0
- package/lib-es/network/getBalancesForAddresses.d.ts +3 -0
- package/lib-es/network/getBalancesForAddresses.d.ts.map +1 -0
- package/lib-es/network/getBalancesForAddresses.js +21 -0
- package/lib-es/network/getBalancesForAddresses.js.map +1 -0
- package/lib-es/network/getBlockDagInfo.d.ts +3 -0
- package/lib-es/network/getBlockDagInfo.d.ts.map +1 -0
- package/lib-es/network/getBlockDagInfo.js +20 -0
- package/lib-es/network/getBlockDagInfo.js.map +1 -0
- package/lib-es/network/getFeeEstimate.d.ts +3 -0
- package/lib-es/network/getFeeEstimate.d.ts.map +1 -0
- package/lib-es/network/getFeeEstimate.js +19 -0
- package/lib-es/network/getFeeEstimate.js.map +1 -0
- package/lib-es/network/getTransactions.d.ts +6 -0
- package/lib-es/network/getTransactions.d.ts.map +1 -0
- package/lib-es/network/getTransactions.js +15 -0
- package/lib-es/network/getTransactions.js.map +1 -0
- package/lib-es/network/getUtxosForAddresses.d.ts +3 -0
- package/lib-es/network/getUtxosForAddresses.d.ts.map +1 -0
- package/lib-es/network/getUtxosForAddresses.js +21 -0
- package/lib-es/network/getUtxosForAddresses.js.map +1 -0
- package/lib-es/network/getVirtualChainBlueScore.d.ts +2 -0
- package/lib-es/network/getVirtualChainBlueScore.d.ts.map +1 -0
- package/lib-es/network/getVirtualChainBlueScore.js +20 -0
- package/lib-es/network/getVirtualChainBlueScore.js.map +1 -0
- package/lib-es/network/index.d.ts +9 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +9 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/submitTransaction.d.ts +3 -0
- package/lib-es/network/submitTransaction.d.ts.map +1 -0
- package/lib-es/network/submitTransaction.js +23 -0
- package/lib-es/network/submitTransaction.js.map +1 -0
- package/lib-es/network/tests/getAddressesActive.test.d.ts +2 -0
- package/lib-es/network/tests/getAddressesActive.test.d.ts.map +1 -0
- package/lib-es/network/tests/getAddressesActive.test.js +63 -0
- package/lib-es/network/tests/getAddressesActive.test.js.map +1 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.d.ts +2 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.d.ts.map +1 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.js +38 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.js.map +1 -0
- package/lib-es/network/tests/getBlockDagInfo.test.d.ts +2 -0
- package/lib-es/network/tests/getBlockDagInfo.test.d.ts.map +1 -0
- package/lib-es/network/tests/getBlockDagInfo.test.js +34 -0
- package/lib-es/network/tests/getBlockDagInfo.test.js.map +1 -0
- package/lib-es/network/tests/getFeeEstimate.test.d.ts +2 -0
- package/lib-es/network/tests/getFeeEstimate.test.d.ts.map +1 -0
- package/lib-es/network/tests/getFeeEstimate.test.js +52 -0
- package/lib-es/network/tests/getFeeEstimate.test.js.map +1 -0
- package/lib-es/network/tests/getTransactions.test.d.ts +2 -0
- package/lib-es/network/tests/getTransactions.test.d.ts.map +1 -0
- package/lib-es/network/tests/getTransactions.test.js +155 -0
- package/lib-es/network/tests/getTransactions.test.js.map +1 -0
- package/lib-es/network/tests/getUtxosForAddress.test.d.ts +2 -0
- package/lib-es/network/tests/getUtxosForAddress.test.d.ts.map +1 -0
- package/lib-es/network/tests/getUtxosForAddress.test.js +140 -0
- package/lib-es/network/tests/getUtxosForAddress.test.js.map +1 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.d.ts +2 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.d.ts.map +1 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.js +25 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.js.map +1 -0
- package/lib-es/network/tests/submitTransaction.test.d.ts +2 -0
- package/lib-es/network/tests/submitTransaction.test.d.ts.map +1 -0
- package/lib-es/network/tests/submitTransaction.test.js +41 -0
- package/lib-es/network/tests/submitTransaction.test.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 +43 -0
- package/lib-es/test/bridgeDatasetTest.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 +25 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +2 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +2 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/transaction.d.ts +16 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +59 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types/addresses.d.ts +18 -0
- package/lib-es/types/addresses.d.ts.map +1 -0
- package/lib-es/types/addresses.js +2 -0
- package/lib-es/types/addresses.js.map +1 -0
- package/lib-es/types/bridge.d.ts +34 -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/errors.d.ts +10 -0
- package/lib-es/types/errors.d.ts.map +1 -0
- package/lib-es/types/errors.js +5 -0
- package/lib-es/types/errors.js.map +1 -0
- package/lib-es/types/index.d.ts +8 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +2 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/kaspaHwTransaction.d.ts +89 -0
- package/lib-es/types/kaspaHwTransaction.d.ts.map +1 -0
- package/lib-es/types/kaspaHwTransaction.js +160 -0
- package/lib-es/types/kaspaHwTransaction.js.map +1 -0
- package/lib-es/types/kaspaNetwork.d.ts +22 -0
- package/lib-es/types/kaspaNetwork.d.ts.map +1 -0
- package/lib-es/types/kaspaNetwork.js +2 -0
- package/lib-es/types/kaspaNetwork.js.map +1 -0
- package/lib-es/types/network.d.ts +91 -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 +14 -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 +138 -0
- package/src/bridge/broadcast.ts +14 -0
- package/src/bridge/buildInitialOperation.ts +38 -0
- package/src/bridge/buildTransaction.ts +80 -0
- package/src/bridge/createTransaction.ts +13 -0
- package/src/bridge/estimateMaxSpendable.ts +23 -0
- package/src/bridge/getTransactionStatus.ts +116 -0
- package/src/bridge/index.ts +106 -0
- package/src/bridge/initAccount.ts +1 -0
- package/src/bridge/prepareTransaction.ts +48 -0
- package/src/bridge/signOperation.ts +43 -0
- package/src/bridge/synchronization.ts +80 -0
- package/src/config.ts +7 -0
- package/src/deviceTransactionConfig.ts +44 -0
- package/src/errors.ts +6 -0
- package/src/hw-getAddress.ts +17 -0
- package/src/index.ts +1 -0
- package/src/logic/base32.ts +100 -0
- package/src/logic/bip32.ts +21 -0
- package/src/logic/getAllTransactions.ts +22 -0
- package/src/logic/getFeeRate.ts +20 -0
- package/src/logic/index.ts +10 -0
- package/src/logic/kaspaAddresses.ts +274 -0
- package/src/logic/massCalcluation.ts +50 -0
- package/src/logic/scanAddresses.ts +173 -0
- package/src/logic/scanOperations.ts +59 -0
- package/src/logic/scanUtxos.ts +44 -0
- package/src/logic/tests/bip32.test.ts +78 -0
- package/src/logic/tests/getFeeRate.test.ts +64 -0
- package/src/logic/tests/kaspaAddresses.test.ts +278 -0
- package/src/logic/tests/massCalcluation.test.ts +37 -0
- package/src/logic/tests/scanAddresses.integ.test.ts +27 -0
- package/src/logic/tests/scanOperations.integ.test.ts +271 -0
- package/src/logic/tests/scanOperations.test.ts +191 -0
- package/src/logic/tests/scanUtxos.integ.test.ts +14 -0
- package/src/logic/tests/scanUtxos.test.ts +153 -0
- package/src/logic/tests/utxoLib.test.ts +29 -0
- package/src/logic/tests/utxoSelection.test.ts +290 -0
- package/src/logic/tests/validAddress.test.ts +55 -0
- package/src/logic/utxos/lib.ts +40 -0
- package/src/logic/utxos/selection.ts +100 -0
- package/src/network/config.ts +6 -0
- package/src/network/getAddressesActive.ts +27 -0
- package/src/network/getBalancesForAddresses.ts +27 -0
- package/src/network/getBlockDagInfo.ts +22 -0
- package/src/network/getFeeEstimate.ts +21 -0
- package/src/network/getTransactions.ts +25 -0
- package/src/network/getUtxosForAddresses.ts +23 -0
- package/src/network/getVirtualChainBlueScore.ts +21 -0
- package/src/network/index.ts +8 -0
- package/src/network/submitTransaction.ts +27 -0
- package/src/network/tests/getAddressesActive.test.ts +77 -0
- package/src/network/tests/getBalancesForAddresss.test.ts +44 -0
- package/src/network/tests/getBlockDagInfo.test.ts +40 -0
- package/src/network/tests/getFeeEstimate.test.ts +57 -0
- package/src/network/tests/getTransactions.test.ts +173 -0
- package/src/network/tests/getUtxosForAddress.test.ts +159 -0
- package/src/network/tests/getVirtualChainBlueScore.test.ts +29 -0
- package/src/network/tests/submitTransaction.test.ts +53 -0
- package/src/test/bridgeDatasetTest.ts +47 -0
- package/src/test/cli.ts +33 -0
- package/src/test/index.ts +1 -0
- package/src/transaction.ts +84 -0
- package/src/types/addresses.ts +19 -0
- package/src/types/bridge.ts +43 -0
- package/src/types/errors.ts +7 -0
- package/src/types/index.ts +7 -0
- package/src/types/kaspaHwTransaction.ts +234 -0
- package/src/types/kaspaNetwork.ts +21 -0
- package/src/types/network.ts +101 -0
- package/src/types/signer.ts +22 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { API_BASE } from "./config";
|
|
2
|
+
import { ApiResponseSubmitTransaction } from "../types";
|
|
3
|
+
|
|
4
|
+
export const submitTransaction = async (
|
|
5
|
+
transactionJson: string,
|
|
6
|
+
): Promise<ApiResponseSubmitTransaction> => {
|
|
7
|
+
try {
|
|
8
|
+
const response = await fetch(`${API_BASE}/transactions`, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
},
|
|
13
|
+
body: transactionJson,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`Failed to submit transaction. Status: ${response.status}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const txId: string = (await response.json()).transactionId;
|
|
21
|
+
return {
|
|
22
|
+
txId,
|
|
23
|
+
};
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw new Error(`Error submitting transaction: ${error}`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { getAddressesActive } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("getAddressesActive function", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("Gets information about addresses being active or not", async () => {
|
|
10
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
11
|
+
ok: true,
|
|
12
|
+
json: async () => [
|
|
13
|
+
{
|
|
14
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
15
|
+
active: true,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
const addresses = ["kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e"];
|
|
20
|
+
const result = await getAddressesActive(addresses);
|
|
21
|
+
|
|
22
|
+
const expectedResult = [
|
|
23
|
+
{
|
|
24
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
25
|
+
active: true,
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
expect(result).toEqual(expectedResult);
|
|
30
|
+
});
|
|
31
|
+
it("Wrong address should deliver false", async () => {
|
|
32
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
33
|
+
ok: true,
|
|
34
|
+
json: async () => [
|
|
35
|
+
{
|
|
36
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp42",
|
|
37
|
+
active: false,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const addresses = ["kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp42"];
|
|
43
|
+
const result = await getAddressesActive(addresses);
|
|
44
|
+
|
|
45
|
+
const expectedResult = [
|
|
46
|
+
{
|
|
47
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp42",
|
|
48
|
+
active: false,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
expect(result).toEqual(expectedResult);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("Should throw an error if the server returns a bad response", async () => {
|
|
56
|
+
const addresses = ["kaspa:invalid_address"];
|
|
57
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
58
|
+
ok: false,
|
|
59
|
+
status: 404,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await expect(getAddressesActive(addresses)).rejects.toThrow(
|
|
63
|
+
"Failed to fetch active state for addresses kaspa:invalid_address. Status: 404",
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("Should throw an error if fetch throws an exception", async () => {
|
|
68
|
+
const addresses = ["kaspa:another_invalid_address"];
|
|
69
|
+
global.fetch = jest.fn().mockImplementationOnce(() => {
|
|
70
|
+
throw new Error("Network Error");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
await expect(getAddressesActive(addresses)).rejects.toThrow(
|
|
74
|
+
"Error fetching AddressesActives: Network Error",
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getBalancesForAddresses } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("getBalanceForAddress", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("returns the balance for a given address", async () => {
|
|
10
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
11
|
+
ok: true,
|
|
12
|
+
json: async () => [
|
|
13
|
+
{
|
|
14
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
15
|
+
balance: 1122124984318255,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
address: "kaspa:qqkqkzjvr7zwxxmjxjkmxxdwju9kjs6e9u82uh59z07vgaks6gg62v8707g73",
|
|
19
|
+
balance: 132655169913451,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const addresses = [
|
|
25
|
+
"kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
26
|
+
"kaspa:qqkqkzjvr7zwxxmjxjkmxxdwju9kjs6e9u82uh59z07vgaks6gg62v8707g73",
|
|
27
|
+
];
|
|
28
|
+
const result = await getBalancesForAddresses(addresses);
|
|
29
|
+
|
|
30
|
+
expect(result[0].address).toBe(addresses[0]);
|
|
31
|
+
expect(result[0].balance).toBeGreaterThan(0);
|
|
32
|
+
expect(result.length).toBe(2);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("throws an error for an invalid address", async () => {
|
|
36
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
37
|
+
ok: false,
|
|
38
|
+
});
|
|
39
|
+
const invalidAddress = "invalid:address";
|
|
40
|
+
await expect(getBalancesForAddresses([invalidAddress])).rejects.toThrow(
|
|
41
|
+
"Error fetching balance",
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getBlockDagInfo } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("getBlockDagInfo", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("Check if getBlockDagInfo gives correct output", async () => {
|
|
10
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
11
|
+
ok: true,
|
|
12
|
+
json: async () => ({
|
|
13
|
+
networkName: "kaspa-mainnet",
|
|
14
|
+
blockCount: "220840",
|
|
15
|
+
headerCount: "220840",
|
|
16
|
+
tipHashes: ["d604806a806c9a0e4573b772a9b6a6595b4a8ca8baa2ea48a62fb8733f1677b3"],
|
|
17
|
+
difficulty: 620427120032880600,
|
|
18
|
+
pastMedianTime: "1737569348584",
|
|
19
|
+
virtualParentHashes: ["d604806a806c9a0e4573b772a9b6a6595b4a8ca8baa2ea48a62fb8733f1677b3"],
|
|
20
|
+
pruningPointHash: "3914b495474186cbf116561e935a11a1991e42b26e7fbbc4658a0c50cb5d2fa6",
|
|
21
|
+
virtualDaaScore: "101277083",
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const result = await getBlockDagInfo();
|
|
26
|
+
|
|
27
|
+
expect(result.pastMedianTime).toBe("1737569348584");
|
|
28
|
+
expect(result.blockCount).toBe("220840");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it("Should throw an error when fetch returns a 500 response", async () => {
|
|
32
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
33
|
+
ok: false,
|
|
34
|
+
status: 500,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await expect(getBlockDagInfo()).rejects.toThrow(
|
|
38
|
+
"Failed to fetch BlockDAG info. Error: Error: Status: 500",
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getFeeEstimate } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("getFees", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("Error response", async () => {
|
|
10
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
11
|
+
ok: false,
|
|
12
|
+
status: 500,
|
|
13
|
+
statusText: "Internal Server Error",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await expect(getFeeEstimate()).rejects.toThrow("Network response was not ok");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("Check if getFees gives correct output", async () => {
|
|
20
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
21
|
+
ok: true,
|
|
22
|
+
json: async () => ({
|
|
23
|
+
priorityBucket: {
|
|
24
|
+
feerate: 1,
|
|
25
|
+
estimatedSeconds: 0.004,
|
|
26
|
+
},
|
|
27
|
+
normalBuckets: [
|
|
28
|
+
{
|
|
29
|
+
feerate: 1,
|
|
30
|
+
estimatedSeconds: 0.004,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
feerate: 1,
|
|
34
|
+
estimatedSeconds: 0.004,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
lowBuckets: [
|
|
38
|
+
{
|
|
39
|
+
feerate: 1,
|
|
40
|
+
estimatedSeconds: 0.004,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const result = await getFeeEstimate();
|
|
47
|
+
|
|
48
|
+
expect(result.priorityBucket.feerate).toBeGreaterThan(0);
|
|
49
|
+
expect(result.priorityBucket.estimatedSeconds).toBeGreaterThan(0);
|
|
50
|
+
expect(result.normalBuckets.length).toBeGreaterThan(0);
|
|
51
|
+
expect(result.normalBuckets[0].feerate).toBeGreaterThan(0);
|
|
52
|
+
expect(result.normalBuckets[0].estimatedSeconds).toBeGreaterThan(0);
|
|
53
|
+
expect(result.lowBuckets.length).toBeGreaterThan(0);
|
|
54
|
+
expect(result.lowBuckets[0].feerate).toBeGreaterThan(0);
|
|
55
|
+
expect(result.lowBuckets[0].estimatedSeconds).toBeGreaterThan(0);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { getTransactions } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("getTransactions function", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
it("should fetch TXs for (burn)address from real API", async () => {
|
|
9
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
10
|
+
ok: true,
|
|
11
|
+
headers: {
|
|
12
|
+
get: jest.fn(() => ""),
|
|
13
|
+
},
|
|
14
|
+
json: async () => [
|
|
15
|
+
{
|
|
16
|
+
subnetwork_id: "0000000000000000000000000000000000000000",
|
|
17
|
+
transaction_id: "72cee02d1c323e0a9154ebac60630f7e370eb9149afaa3eab9277a284c343964",
|
|
18
|
+
hash: "f383585dd39e9459dd97c0551c359e882c8248db618b8726ff9ed57dfb165440",
|
|
19
|
+
mass: "2036",
|
|
20
|
+
block_hash: [
|
|
21
|
+
"89193a460ae5c9dfc5983b72e71ffba2699d75420e906b4475e69861d62fa124",
|
|
22
|
+
"e194ab7d88ae78a212a388309f0994c3a819dc8d0a5c1f69bd0c811c9017e4bd",
|
|
23
|
+
],
|
|
24
|
+
block_time: 1733730605449,
|
|
25
|
+
is_accepted: true,
|
|
26
|
+
accepting_block_hash: "9a2bdd094ae393f94f1a1dee87a9f467d406f8b2a7d9fd9becf9019f0e5eb922",
|
|
27
|
+
accepting_block_blue_score: 95828655,
|
|
28
|
+
inputs: [
|
|
29
|
+
{
|
|
30
|
+
transaction_id: "72cee02d1c323e0a9154ebac60630f7e370eb9149afaa3eab9277a284c343964",
|
|
31
|
+
index: 0,
|
|
32
|
+
previous_outpoint_hash:
|
|
33
|
+
"6735abfcfeade8fdad092afd5a51ed6089b761fec30ee46a66db3a59ef009b74",
|
|
34
|
+
previous_outpoint_index: "0",
|
|
35
|
+
previous_outpoint_resolved: null,
|
|
36
|
+
previous_outpoint_address: null,
|
|
37
|
+
previous_outpoint_amount: null,
|
|
38
|
+
signature_script:
|
|
39
|
+
"41b317450a27b848bb8e500cdacbf0fd53b1c6e7dfc9e9752e9f4a1892a8b63508f50a47e96acd45995223fb5d41e791f147d7f52fe5d13418a8a7e68cfa2c638901",
|
|
40
|
+
sig_op_count: "1",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
outputs: [
|
|
44
|
+
{
|
|
45
|
+
transaction_id: "72cee02d1c323e0a9154ebac60630f7e370eb9149afaa3eab9277a284c343964",
|
|
46
|
+
index: 0,
|
|
47
|
+
amount: 69000000,
|
|
48
|
+
script_public_key:
|
|
49
|
+
"200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
50
|
+
script_public_key_address:
|
|
51
|
+
"kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
52
|
+
script_public_key_type: "pubkey",
|
|
53
|
+
accepting_block_hash: null,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
transaction_id: "72cee02d1c323e0a9154ebac60630f7e370eb9149afaa3eab9277a284c343964",
|
|
57
|
+
index: 1,
|
|
58
|
+
amount: 230984512,
|
|
59
|
+
script_public_key:
|
|
60
|
+
"2055b8f71e0175003a8ad8ce895d0f0ed6ca84d131115192df4e3842c5d8b049f7ac",
|
|
61
|
+
script_public_key_address:
|
|
62
|
+
"kaspa:qp2m3ac7q96sqw52mr8gjhg0pmtv4px3xyg4ryklfcuy93wckpylwuna456vq",
|
|
63
|
+
script_public_key_type: "pubkey",
|
|
64
|
+
accepting_block_hash: null,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
subnetwork_id: "0000000000000000000000000000000000000000",
|
|
70
|
+
transaction_id: "0ae596c60c4a8b8ff8f9397e70266f68d32effb79ad37826b958f41e40759f90",
|
|
71
|
+
hash: "92d44bdb0fcb210650f7bd62043cb9c0c2013053ac54d1f5ffcb9c016f42f2ea",
|
|
72
|
+
mass: "1624",
|
|
73
|
+
block_hash: ["46ce80a5ff71f84b2a37d7ea615cd93edc4fcacf45a7a95d1d6e51d85360a72e"],
|
|
74
|
+
block_time: 1730564218472,
|
|
75
|
+
is_accepted: true,
|
|
76
|
+
accepting_block_hash: "d16be8f74302ed5fb2ee9873cc4e916aecd3ac346639f44fd5cc4fb0ec7dd076",
|
|
77
|
+
accepting_block_blue_score: 92661331,
|
|
78
|
+
inputs: [
|
|
79
|
+
{
|
|
80
|
+
transaction_id: "0ae596c60c4a8b8ff8f9397e70266f68d32effb79ad37826b958f41e40759f90",
|
|
81
|
+
index: 0,
|
|
82
|
+
previous_outpoint_hash:
|
|
83
|
+
"48c1f630fe28ec4be1fabb8101dade0022d74dbfadab75e52619d5dde6ffdd5f",
|
|
84
|
+
previous_outpoint_index: "0",
|
|
85
|
+
previous_outpoint_resolved: null,
|
|
86
|
+
previous_outpoint_address: null,
|
|
87
|
+
previous_outpoint_amount: null,
|
|
88
|
+
signature_script:
|
|
89
|
+
"419e980873eae21f245208162b341bf62b4702a56d94cd0ab55014359001bf3597bf3936b3cb1634f51c232567f2fa1fdd03fefe126ede1c320e4fa2574aa2506f01",
|
|
90
|
+
sig_op_count: "1",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
outputs: [
|
|
94
|
+
{
|
|
95
|
+
transaction_id: "0ae596c60c4a8b8ff8f9397e70266f68d32effb79ad37826b958f41e40759f90",
|
|
96
|
+
index: 0,
|
|
97
|
+
amount: 3499890212,
|
|
98
|
+
script_public_key:
|
|
99
|
+
"200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
100
|
+
script_public_key_address:
|
|
101
|
+
"kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
102
|
+
script_public_key_type: "pubkey",
|
|
103
|
+
accepting_block_hash: null,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
subnetwork_id: "0000000000000000000000000000000000000000",
|
|
109
|
+
transaction_id: "0958e37fef35f5cc5f53e383f19a1fb589d110bd2e967a34122a48dea1232cb9",
|
|
110
|
+
hash: "7c9881a09bbacefad1f3ed199a7ff531431675dd9e479a46deb97c71aa35fe02",
|
|
111
|
+
mass: "2036",
|
|
112
|
+
block_hash: ["f926e1d1ebb621ce9dc87efca9c4bc02110dee8078ea304c21ab7c65a3d7285b"],
|
|
113
|
+
block_time: 1730187373390,
|
|
114
|
+
is_accepted: true,
|
|
115
|
+
accepting_block_hash: "7bf390afb0a46cd5cc2140540d1aea36f040613873a39fb7d86920ee8ea1cee6",
|
|
116
|
+
accepting_block_blue_score: 92283556,
|
|
117
|
+
inputs: [
|
|
118
|
+
{
|
|
119
|
+
transaction_id: "0958e37fef35f5cc5f53e383f19a1fb589d110bd2e967a34122a48dea1232cb9",
|
|
120
|
+
index: 0,
|
|
121
|
+
previous_outpoint_hash:
|
|
122
|
+
"ba4d2b0d594e61b003036231c88abcc9a5c1f5ef2d6ea878f8b25a2ab9146d2a",
|
|
123
|
+
previous_outpoint_index: "0",
|
|
124
|
+
previous_outpoint_resolved: null,
|
|
125
|
+
previous_outpoint_address: null,
|
|
126
|
+
previous_outpoint_amount: null,
|
|
127
|
+
signature_script:
|
|
128
|
+
"41a157a87e0a98d18fa4bd2b3a21925e4d961861b84a1be6bf37e495e49dba28406692ce0f4075c7b2ddc08edd6bb7db511ac6a2fd48e30cd88e38cc3999294ec301",
|
|
129
|
+
sig_op_count: "1",
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
outputs: [
|
|
133
|
+
{
|
|
134
|
+
transaction_id: "0958e37fef35f5cc5f53e383f19a1fb589d110bd2e967a34122a48dea1232cb9",
|
|
135
|
+
index: 0,
|
|
136
|
+
amount: 100000000,
|
|
137
|
+
script_public_key:
|
|
138
|
+
"200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
139
|
+
script_public_key_address:
|
|
140
|
+
"kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
141
|
+
script_public_key_type: "pubkey",
|
|
142
|
+
accepting_block_hash: null,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
transaction_id: "0958e37fef35f5cc5f53e383f19a1fb589d110bd2e967a34122a48dea1232cb9",
|
|
146
|
+
index: 1,
|
|
147
|
+
amount: 1557776051,
|
|
148
|
+
script_public_key:
|
|
149
|
+
"20ba05376ad62963e66d4a92ac2c73f8183dafcc66dc50960006359a7ad01a75cdac",
|
|
150
|
+
script_public_key_address:
|
|
151
|
+
"kaspa:qzaq2dm26c5k8endf2f2ctrnlqvrmt7vvmw9p9sqqc6e57ksrf6u6xafdlpx5",
|
|
152
|
+
script_public_key_type: "pubkey",
|
|
153
|
+
accepting_block_hash: null,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
const address = "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e";
|
|
160
|
+
const result = await getTransactions(address);
|
|
161
|
+
expect(result.transactions.length).toBe(3);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("should return an error if fetch returns a 500 response", async () => {
|
|
165
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
166
|
+
ok: false,
|
|
167
|
+
status: 500,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const address = "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e";
|
|
171
|
+
await expect(getTransactions(address)).rejects.toThrowError("Network response was not ok.");
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { getUtxosForAddresses } from "../index";
|
|
2
|
+
|
|
3
|
+
interface Outpoint {
|
|
4
|
+
transactionId: string;
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getUtxoForOutpoint(utxos: any[], outpoint: Outpoint): any | null {
|
|
9
|
+
for (const utxo of utxos) {
|
|
10
|
+
if (
|
|
11
|
+
utxo.outpoint.transactionId === outpoint.transactionId &&
|
|
12
|
+
utxo.outpoint.index === outpoint.index
|
|
13
|
+
) {
|
|
14
|
+
return utxo;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("getUtxosForAddress function", () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// Clear all mocks before each test to avoid interference
|
|
23
|
+
jest.clearAllMocks();
|
|
24
|
+
});
|
|
25
|
+
it("should fetch UTXOs for given address from real API", async () => {
|
|
26
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
27
|
+
ok: true,
|
|
28
|
+
json: async () => [
|
|
29
|
+
{
|
|
30
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
31
|
+
outpoint: {
|
|
32
|
+
transactionId: "402f0762218346d622bbaeaa25107ab2398733f44f2369c902b176b25fa81e37",
|
|
33
|
+
index: 0,
|
|
34
|
+
},
|
|
35
|
+
utxoEntry: {
|
|
36
|
+
amount: "5000000000000",
|
|
37
|
+
scriptPublicKey: {
|
|
38
|
+
scriptPublicKey:
|
|
39
|
+
"200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
40
|
+
},
|
|
41
|
+
blockDaaScore: "1490933",
|
|
42
|
+
isCoinbase: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
47
|
+
outpoint: {
|
|
48
|
+
transactionId: "6ef083d4a8a1d3cf31a90409f6af5fdc00264c684da80fd3aeb4f6f29684824b",
|
|
49
|
+
index: 0,
|
|
50
|
+
},
|
|
51
|
+
utxoEntry: {
|
|
52
|
+
amount: "5000000000000",
|
|
53
|
+
scriptPublicKey: {
|
|
54
|
+
scriptPublicKey:
|
|
55
|
+
"200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
56
|
+
},
|
|
57
|
+
blockDaaScore: "1491330",
|
|
58
|
+
isCoinbase: false,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
63
|
+
outpoint: {
|
|
64
|
+
transactionId: "4413257fa1f7884b7cd6f7b42c326da71b45f8c609c3c19609cbf00e5cc66bf4",
|
|
65
|
+
index: 0,
|
|
66
|
+
},
|
|
67
|
+
utxoEntry: {
|
|
68
|
+
amount: "10000000000",
|
|
69
|
+
scriptPublicKey: {
|
|
70
|
+
scriptPublicKey:
|
|
71
|
+
"200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
72
|
+
},
|
|
73
|
+
blockDaaScore: "78211249",
|
|
74
|
+
isCoinbase: false,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
const addresses = ["kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e"];
|
|
80
|
+
const result = await getUtxosForAddresses(addresses);
|
|
81
|
+
|
|
82
|
+
const expectedUtxos = [
|
|
83
|
+
{
|
|
84
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
85
|
+
outpoint: {
|
|
86
|
+
transactionId: "402f0762218346d622bbaeaa25107ab2398733f44f2369c902b176b25fa81e37",
|
|
87
|
+
index: 0,
|
|
88
|
+
},
|
|
89
|
+
utxoEntry: {
|
|
90
|
+
amount: "5000000000000",
|
|
91
|
+
scriptPublicKey: {
|
|
92
|
+
scriptPublicKey: "200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
93
|
+
},
|
|
94
|
+
blockDaaScore: "1490933",
|
|
95
|
+
isCoinbase: false,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
100
|
+
outpoint: {
|
|
101
|
+
transactionId: "6ef083d4a8a1d3cf31a90409f6af5fdc00264c684da80fd3aeb4f6f29684824b",
|
|
102
|
+
index: 0,
|
|
103
|
+
},
|
|
104
|
+
utxoEntry: {
|
|
105
|
+
amount: "5000000000000",
|
|
106
|
+
scriptPublicKey: {
|
|
107
|
+
scriptPublicKey: "200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
108
|
+
},
|
|
109
|
+
blockDaaScore: "1491330",
|
|
110
|
+
isCoinbase: false,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
address: "kaspa:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx9awp4e",
|
|
115
|
+
outpoint: {
|
|
116
|
+
transactionId: "4413257fa1f7884b7cd6f7b42c326da71b45f8c609c3c19609cbf00e5cc66bf4",
|
|
117
|
+
index: 0,
|
|
118
|
+
},
|
|
119
|
+
utxoEntry: {
|
|
120
|
+
amount: "10000000000",
|
|
121
|
+
scriptPublicKey: {
|
|
122
|
+
scriptPublicKey: "200000000000000000000000000000000000000000000000000000000000000000ac",
|
|
123
|
+
},
|
|
124
|
+
blockDaaScore: "78211249",
|
|
125
|
+
isCoinbase: false,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
for (const expectedUtxo of expectedUtxos) {
|
|
131
|
+
const utxoFromResponse = getUtxoForOutpoint(result, {
|
|
132
|
+
transactionId: expectedUtxo.outpoint.transactionId,
|
|
133
|
+
index: 0,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(utxoFromResponse).not.toBeNull();
|
|
137
|
+
expect(utxoFromResponse.address).toEqual(expectedUtxo.address);
|
|
138
|
+
expect(utxoFromResponse.outpoint.transactionId).toEqual(expectedUtxo.outpoint.transactionId);
|
|
139
|
+
expect(utxoFromResponse.outpoint.index).toEqual(expectedUtxo.outpoint.index);
|
|
140
|
+
expect(utxoFromResponse.utxoEntry.amount).toEqual(expectedUtxo.utxoEntry.amount);
|
|
141
|
+
expect(utxoFromResponse.utxoEntry.scriptPublicKey.scriptPublicKey).toEqual(
|
|
142
|
+
expectedUtxo.utxoEntry.scriptPublicKey.scriptPublicKey,
|
|
143
|
+
);
|
|
144
|
+
expect(utxoFromResponse.utxoEntry.blockDaaScore).toEqual(
|
|
145
|
+
expectedUtxo.utxoEntry.blockDaaScore,
|
|
146
|
+
);
|
|
147
|
+
expect(utxoFromResponse.utxoEntry.isCoinbase).toEqual(expectedUtxo.utxoEntry.isCoinbase);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("should throw an error if the response is not ok", async () => {
|
|
152
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
153
|
+
ok: false,
|
|
154
|
+
status: 400,
|
|
155
|
+
});
|
|
156
|
+
const addresses = ["invalidAddress"];
|
|
157
|
+
await expect(getUtxosForAddresses(addresses)).rejects.toThrow();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getVirtualChainBlueScore } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("getVirtualChainBlueScore", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return the blue score from the API response", async () => {
|
|
10
|
+
// Mock the global fetch function
|
|
11
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
12
|
+
ok: true,
|
|
13
|
+
json: async () => ({ blueScore: 12345 }),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const result = await getVirtualChainBlueScore();
|
|
17
|
+
expect(result).toBe(12345);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should throw an error when the fetch fails", async () => {
|
|
21
|
+
// Mock a failed fetch response
|
|
22
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
23
|
+
ok: false,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await expect(getVirtualChainBlueScore()).rejects.toThrow("Failed to fetch");
|
|
27
|
+
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { submitTransaction } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("submitTransaction function", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Clear all mocks before each test to avoid interference
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
});
|
|
8
|
+
it("Gets information about addresses being active or not", async () => {
|
|
9
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
10
|
+
ok: true,
|
|
11
|
+
json: async () => ({
|
|
12
|
+
transactionId: "396f29c47bdd95dddbe868203ce905535a3de1b48af7adeb40b769662885c008",
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
const transactionDetails = {
|
|
16
|
+
dummy: "data",
|
|
17
|
+
};
|
|
18
|
+
const result = await submitTransaction(JSON.stringify(transactionDetails));
|
|
19
|
+
|
|
20
|
+
const expectedResult = {
|
|
21
|
+
txId: "396f29c47bdd95dddbe868203ce905535a3de1b48af7adeb40b769662885c008",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
expect(result).toEqual(expectedResult);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("Throws an error if the response is not ok", async () => {
|
|
28
|
+
global.fetch = jest.fn().mockResolvedValueOnce({
|
|
29
|
+
ok: false,
|
|
30
|
+
status: 500,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const transactionDetails = {
|
|
34
|
+
dummy: "data",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
await expect(submitTransaction(JSON.stringify(transactionDetails))).rejects.toThrow(
|
|
38
|
+
"Failed to submit transaction. Status: 500",
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("Throws an error if there is an exception while submitting", async () => {
|
|
43
|
+
global.fetch = jest.fn().mockRejectedValueOnce(new Error("Network error"));
|
|
44
|
+
|
|
45
|
+
const transactionDetails = {
|
|
46
|
+
dummy: "data",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
await expect(submitTransaction(JSON.stringify(transactionDetails))).rejects.toThrow(
|
|
50
|
+
"Error submitting transaction: Error: Network error",
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
});
|