@ledgerhq/live-common 27.0.0 → 27.1.0-next.1
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/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js +2 -2
- package/lib/__tests__/test-helpers/environment.d.ts +2 -0
- package/lib/__tests__/test-helpers/environment.d.ts.map +1 -0
- package/lib/__tests__/test-helpers/environment.js +107 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -0
- package/lib/__tests__/test-helpers/setup.d.ts +1 -1
- package/lib/__tests__/test-helpers/setup.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/setup.js +1 -101
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/account/serialization.d.ts +2 -0
- package/lib/account/serialization.d.ts.map +1 -1
- package/lib/account/serialization.js +105 -47
- package/lib/account/serialization.js.map +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +1 -0
- package/lib/apps/support.js.map +1 -1
- package/lib/bot/bot-test-context.d.ts +3 -0
- package/lib/bot/bot-test-context.d.ts.map +1 -0
- package/lib/bot/bot-test-context.js +26 -0
- package/lib/bot/bot-test-context.js.map +1 -0
- package/lib/bot/bot-test-context.test.d.ts +2 -0
- package/lib/bot/bot-test-context.test.d.ts.map +1 -0
- package/lib/bot/bot-test-context.test.js +41 -0
- package/lib/bot/bot-test-context.test.js.map +1 -0
- package/lib/bot/cli.d.ts +2 -0
- package/lib/bot/cli.d.ts.map +1 -0
- package/lib/bot/cli.js +14 -0
- package/lib/bot/cli.js.map +1 -0
- package/lib/bot/engine.d.ts +5 -5
- package/lib/bot/engine.d.ts.map +1 -1
- package/lib/bot/engine.js +161 -112
- package/lib/bot/engine.js.map +1 -1
- package/lib/bot/formatters.d.ts +2 -2
- package/lib/bot/formatters.d.ts.map +1 -1
- package/lib/bot/formatters.js +41 -15
- package/lib/bot/formatters.js.map +1 -1
- package/lib/bot/index.d.ts +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +90 -15
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts +2 -1
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +13 -9
- package/lib/bot/specs.js.map +1 -1
- package/lib/bot/types.d.ts +5 -2
- package/lib/bot/types.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.js +65 -0
- package/lib/countervalues/logic.integration.test.js.map +1 -1
- package/lib/countervalues/modules/weth.d.ts.map +1 -1
- package/lib/countervalues/modules/weth.js +5 -10
- package/lib/countervalues/modules/weth.js.map +1 -1
- package/lib/currencies/sortByMarketcap.d.ts +0 -2
- package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
- package/lib/currencies/sortByMarketcap.js +3 -17
- package/lib/currencies/sortByMarketcap.js.map +1 -1
- package/lib/currencies/sortByMarketcap.test.js +0 -5
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/env.js +1 -1
- package/lib/families/algorand/specs.d.ts.map +1 -1
- package/lib/families/algorand/specs.js +18 -10
- package/lib/families/algorand/specs.js.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.d.ts +1 -4
- package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.js +25 -8
- package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
- package/lib/families/bitcoin/bridge/mock.d.ts.map +1 -1
- package/lib/families/bitcoin/bridge/mock.js +6 -1
- package/lib/families/bitcoin/bridge/mock.js.map +1 -1
- package/lib/families/bitcoin/datasets/bitcoin_cash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/bitcoin_cash.js +1 -1
- package/lib/families/bitcoin/datasets/bitcoin_cash.js.map +1 -1
- package/lib/families/bitcoin/datasets/dash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/dash.js +1 -1
- package/lib/families/bitcoin/datasets/dash.js.map +1 -1
- package/lib/families/bitcoin/datasets/decred.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/decred.js +1 -1
- package/lib/families/bitcoin/datasets/decred.js.map +1 -1
- package/lib/families/bitcoin/datasets/digibyte.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/digibyte.js +8 -2
- package/lib/families/bitcoin/datasets/digibyte.js.map +1 -1
- package/lib/families/bitcoin/datasets/dogecoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/dogecoin.js +1 -1
- package/lib/families/bitcoin/datasets/dogecoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/komodo.js +1 -1
- package/lib/families/bitcoin/datasets/komodo.js.map +1 -1
- package/lib/families/bitcoin/datasets/litecoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/litecoin.js +8 -2
- package/lib/families/bitcoin/datasets/litecoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/peercoin.js +1 -1
- package/lib/families/bitcoin/datasets/peercoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/pivx.js +1 -1
- package/lib/families/bitcoin/datasets/pivx.js.map +1 -1
- package/lib/families/bitcoin/datasets/qtum.js +1 -1
- package/lib/families/bitcoin/datasets/qtum.js.map +1 -1
- package/lib/families/bitcoin/datasets/stakenet.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/stakenet.js +1 -1
- package/lib/families/bitcoin/datasets/stakenet.js.map +1 -1
- package/lib/families/bitcoin/datasets/vertcoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/vertcoin.js +1 -1
- package/lib/families/bitcoin/datasets/vertcoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/viacoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/viacoin.js +1 -1
- package/lib/families/bitcoin/datasets/viacoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/zcash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/zcash.js +1 -1
- package/lib/families/bitcoin/datasets/zcash.js.map +1 -1
- package/lib/families/bitcoin/datasets/zencash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/zencash.js +1 -1
- package/lib/families/bitcoin/datasets/zencash.js.map +1 -1
- package/lib/families/bitcoin/platformAdapter.test.d.ts +2 -0
- package/lib/families/bitcoin/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/bitcoin/platformAdapter.test.js +48 -0
- package/lib/families/bitcoin/platformAdapter.test.js.map +1 -0
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +62 -24
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.d.ts +1 -4
- package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.js +2 -4
- package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/cardano/js-estimateMaxSpendable.js +1 -1
- package/lib/families/cardano/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/cardano/specs.d.ts.map +1 -1
- package/lib/families/cardano/specs.js +19 -8
- package/lib/families/cardano/specs.js.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.d.ts +1 -4
- package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.js +2 -2
- package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
- package/lib/families/celo/api/hubble.d.ts +6 -1
- package/lib/families/celo/api/hubble.d.ts.map +1 -1
- package/lib/families/celo/api/hubble.js +135 -13
- package/lib/families/celo/api/hubble.js.map +1 -1
- package/lib/families/celo/api/index.d.ts +1 -1
- package/lib/families/celo/api/index.d.ts.map +1 -1
- package/lib/families/celo/api/index.js +2 -1
- package/lib/families/celo/api/index.js.map +1 -1
- package/lib/families/celo/api/sdk.d.ts +22 -0
- package/lib/families/celo/api/sdk.d.ts.map +1 -1
- package/lib/families/celo/api/sdk.js +168 -1
- package/lib/families/celo/api/sdk.js.map +1 -1
- package/lib/families/celo/bridge/js.d.ts.map +1 -1
- package/lib/families/celo/bridge/js.js +4 -42
- package/lib/families/celo/bridge/js.js.map +1 -1
- package/lib/families/celo/cli-transaction.d.ts +12 -2
- package/lib/families/celo/cli-transaction.d.ts.map +1 -1
- package/lib/families/celo/cli-transaction.js +38 -4
- package/lib/families/celo/cli-transaction.js.map +1 -1
- package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts +1 -0
- package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts.map +1 -1
- package/lib/families/celo/datasets/celo.scanAccounts.1.js +298 -2
- package/lib/families/celo/datasets/celo.scanAccounts.1.js.map +1 -1
- package/lib/families/celo/errors.d.ts +2 -0
- package/lib/families/celo/errors.d.ts.map +1 -0
- package/lib/families/celo/errors.js +6 -0
- package/lib/families/celo/errors.js.map +1 -0
- package/lib/families/celo/js-buildTransaction.d.ts +2 -3
- package/lib/families/celo/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-buildTransaction.js +194 -19
- package/lib/families/celo/js-buildTransaction.js.map +1 -1
- package/lib/families/celo/js-createTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-createTransaction.js +3 -1
- package/lib/families/celo/js-createTransaction.js.map +1 -1
- package/lib/families/celo/js-estimateMaxSpendable.d.ts.map +1 -1
- package/lib/families/celo/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/celo/js-getFeesForTransaction.d.ts +2 -3
- package/lib/families/celo/js-getFeesForTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-getFeesForTransaction.js +137 -10
- package/lib/families/celo/js-getFeesForTransaction.js.map +1 -1
- package/lib/families/celo/js-getTransactionStatus.d.ts +2 -3
- package/lib/families/celo/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/celo/js-getTransactionStatus.js +97 -41
- package/lib/families/celo/js-getTransactionStatus.js.map +1 -1
- package/lib/families/celo/js-prepareTransaction.d.ts +2 -3
- package/lib/families/celo/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-prepareTransaction.js +8 -3
- package/lib/families/celo/js-prepareTransaction.js.map +1 -1
- package/lib/families/celo/js-signOperation.d.ts.map +1 -1
- package/lib/families/celo/js-signOperation.js +17 -3
- package/lib/families/celo/js-signOperation.js.map +1 -1
- package/lib/families/celo/js-synchronisation.d.ts.map +1 -1
- package/lib/families/celo/js-synchronisation.js +51 -6
- package/lib/families/celo/js-synchronisation.js.map +1 -1
- package/lib/families/celo/logic.d.ts +21 -0
- package/lib/families/celo/logic.d.ts.map +1 -0
- package/lib/families/celo/logic.js +132 -0
- package/lib/families/celo/logic.js.map +1 -0
- package/lib/families/celo/preload.d.ts +10 -0
- package/lib/families/celo/preload.d.ts.map +1 -0
- package/lib/families/celo/preload.js +118 -0
- package/lib/families/celo/preload.js.map +1 -0
- package/lib/families/celo/react.d.ts +4 -0
- package/lib/families/celo/react.d.ts.map +1 -0
- package/lib/families/celo/react.js +47 -0
- package/lib/families/celo/react.js.map +1 -0
- package/lib/families/celo/serialization.d.ts +4 -0
- package/lib/families/celo/serialization.d.ts.map +1 -0
- package/lib/families/celo/serialization.js +55 -0
- package/lib/families/celo/serialization.js.map +1 -0
- package/lib/families/celo/specs/createActivateVoteMutation.d.ts +4 -0
- package/lib/families/celo/specs/createActivateVoteMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createActivateVoteMutation.js +38 -0
- package/lib/families/celo/specs/createActivateVoteMutation.js.map +1 -0
- package/lib/families/celo/specs/createLockMutation.d.ts +4 -0
- package/lib/families/celo/specs/createLockMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createLockMutation.js +40 -0
- package/lib/families/celo/specs/createLockMutation.js.map +1 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.d.ts +4 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.js +31 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.js.map +1 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.d.ts +4 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.js +39 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.js.map +1 -0
- package/lib/families/celo/specs/createSendMutation.d.ts +5 -0
- package/lib/families/celo/specs/createSendMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createSendMutation.js +44 -0
- package/lib/families/celo/specs/createSendMutation.js.map +1 -0
- package/lib/families/celo/specs/createUnlockMutation.d.ts +4 -0
- package/lib/families/celo/specs/createUnlockMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createUnlockMutation.js +37 -0
- package/lib/families/celo/specs/createUnlockMutation.js.map +1 -0
- package/lib/families/celo/specs/createVoteMutation.d.ts +4 -0
- package/lib/families/celo/specs/createVoteMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createVoteMutation.js +51 -0
- package/lib/families/celo/specs/createVoteMutation.js.map +1 -0
- package/lib/families/celo/specs/createWithdrawMutation.d.ts +4 -0
- package/lib/families/celo/specs/createWithdrawMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createWithdrawMutation.js +36 -0
- package/lib/families/celo/specs/createWithdrawMutation.js.map +1 -0
- package/lib/families/celo/specs/index.d.ts +9 -0
- package/lib/families/celo/specs/index.d.ts.map +1 -0
- package/lib/families/celo/specs/index.js +25 -0
- package/lib/families/celo/specs/index.js.map +1 -0
- package/lib/families/celo/specs.d.ts +1 -1
- package/lib/families/celo/specs.d.ts.map +1 -1
- package/lib/families/celo/specs.js +22 -37
- package/lib/families/celo/specs.js.map +1 -1
- package/lib/families/celo/speculos-deviceActions.d.ts +1 -4
- package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/celo/speculos-deviceActions.js +24 -4
- package/lib/families/celo/speculos-deviceActions.js.map +1 -1
- package/lib/families/celo/transaction.d.ts.map +1 -1
- package/lib/families/celo/transaction.js +8 -6
- package/lib/families/celo/transaction.js.map +1 -1
- package/lib/families/celo/types.d.ts +102 -1
- package/lib/families/celo/types.d.ts.map +1 -1
- package/lib/families/celo/validators.d.ts +3 -0
- package/lib/families/celo/validators.d.ts.map +1 -0
- package/lib/families/celo/validators.js +6 -0
- package/lib/families/celo/validators.js.map +1 -0
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +41 -25
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/cosmos/speculos-deviceActions.d.ts +1 -4
- package/lib/families/cosmos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cosmos/speculos-deviceActions.js +2 -4
- package/lib/families/cosmos/speculos-deviceActions.js.map +1 -1
- package/lib/families/crypto_org/specs.d.ts.map +1 -1
- package/lib/families/crypto_org/specs.js +3 -0
- package/lib/families/crypto_org/specs.js.map +1 -1
- package/lib/families/crypto_org/speculos-deviceActions.d.ts +1 -4
- package/lib/families/crypto_org/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/crypto_org/speculos-deviceActions.js +2 -2
- package/lib/families/crypto_org/speculos-deviceActions.js.map +1 -1
- package/lib/families/elrond/specs.d.ts.map +1 -1
- package/lib/families/elrond/specs.js +15 -2
- package/lib/families/elrond/specs.js.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.d.ts +1 -4
- package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.js +2 -4
- package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
- package/lib/families/ethereum/platformAdapter.test.d.ts +2 -0
- package/lib/families/ethereum/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/ethereum/platformAdapter.test.js +88 -0
- package/lib/families/ethereum/platformAdapter.test.js.map +1 -0
- package/lib/families/ethereum/specs.d.ts.map +1 -1
- package/lib/families/ethereum/specs.js +36 -12
- package/lib/families/ethereum/specs.js.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.d.ts +1 -4
- package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.js +2 -4
- package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
- package/lib/families/filecoin/specs.d.ts.map +1 -1
- package/lib/families/filecoin/specs.js +2 -0
- package/lib/families/filecoin/specs.js.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.d.ts +1 -4
- package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.js +2 -2
- package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/hedera/specs.d.ts.map +1 -1
- package/lib/families/hedera/specs.js +11 -3
- package/lib/families/hedera/specs.js.map +1 -1
- package/lib/families/hedera/speculos-deviceActions.d.ts +1 -4
- package/lib/families/hedera/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/hedera/speculos-deviceActions.js +4 -4
- package/lib/families/hedera/speculos-deviceActions.js.map +1 -1
- package/lib/families/osmosis/specs.d.ts.map +1 -1
- package/lib/families/osmosis/specs.js +13 -5
- package/lib/families/osmosis/specs.js.map +1 -1
- package/lib/families/osmosis/speculos-deviceActions.d.ts +1 -4
- package/lib/families/osmosis/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/osmosis/speculos-deviceActions.js +2 -4
- package/lib/families/osmosis/speculos-deviceActions.js.map +1 -1
- package/lib/families/polkadot/platformAdapter.test.d.ts +2 -0
- package/lib/families/polkadot/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/polkadot/platformAdapter.test.js +51 -0
- package/lib/families/polkadot/platformAdapter.test.js.map +1 -0
- package/lib/families/polkadot/specs.d.ts.map +1 -1
- package/lib/families/polkadot/specs.js +12 -1
- package/lib/families/polkadot/specs.js.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.d.ts +1 -4
- package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.js +2 -4
- package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
- package/lib/families/ripple/platformAdapter.test.d.ts +2 -0
- package/lib/families/ripple/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/ripple/platformAdapter.test.js +51 -0
- package/lib/families/ripple/platformAdapter.test.js.map +1 -0
- package/lib/families/ripple/specs.d.ts.map +1 -1
- package/lib/families/ripple/specs.js +9 -4
- package/lib/families/ripple/specs.js.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.d.ts +1 -4
- package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.js +2 -4
- package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +2 -2
- package/lib/families/solana/specs.d.ts.map +1 -1
- package/lib/families/solana/specs.js +29 -11
- package/lib/families/solana/specs.js.map +1 -1
- package/lib/families/solana/speculos-deviceActions.d.ts +0 -5
- package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/solana/speculos-deviceActions.js +0 -4
- package/lib/families/solana/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +15 -10
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/specs.d.ts.map +1 -1
- package/lib/families/stellar/specs.js +30 -12
- package/lib/families/stellar/specs.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts +1 -4
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +2 -4
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/tezos/bakers.whitelist-default.d.ts.map +1 -1
- package/lib/families/tezos/bakers.whitelist-default.js +1 -1
- package/lib/families/tezos/bakers.whitelist-default.js.map +1 -1
- package/lib/families/tezos/specs.d.ts.map +1 -1
- package/lib/families/tezos/specs.js +2 -0
- package/lib/families/tezos/specs.js.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.d.ts +1 -4
- package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.js +2 -2
- package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
- package/lib/families/tron/specs.d.ts.map +1 -1
- package/lib/families/tron/specs.js +49 -17
- package/lib/families/tron/specs.js.map +1 -1
- package/lib/families/tron/speculos-deviceActions.d.ts +1 -4
- package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tron/speculos-deviceActions.js +2 -4
- package/lib/families/tron/speculos-deviceActions.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +12 -2
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/hw/getGenuineCheckFromDeviceId.d.ts +22 -0
- package/lib/hw/getGenuineCheckFromDeviceId.d.ts.map +1 -0
- package/lib/hw/getGenuineCheckFromDeviceId.js +49 -0
- package/lib/hw/getGenuineCheckFromDeviceId.js.map +1 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.d.ts +2 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.d.ts.map +1 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.js +84 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.js.map +1 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.d.ts +17 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.d.ts.map +1 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.js +27 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.js.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.d.ts +34 -0
- package/lib/hw/hooks/useGenuineCheck.d.ts.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.js +115 -0
- package/lib/hw/hooks/useGenuineCheck.js.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.test.d.ts +2 -0
- package/lib/hw/hooks/useGenuineCheck.test.d.ts.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.test.js +316 -0
- package/lib/hw/hooks/useGenuineCheck.test.js.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.d.ts +29 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.d.ts.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.js +72 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.js.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.d.ts +2 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.d.ts.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.js +155 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.js.map +1 -0
- package/lib/load/speculos.d.ts +1 -0
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +2 -1
- package/lib/load/speculos.js.map +1 -1
- package/lib/mock/fixtures/cryptoCurrencies.d.ts +5 -0
- package/lib/mock/fixtures/cryptoCurrencies.d.ts.map +1 -0
- package/lib/mock/fixtures/cryptoCurrencies.js +91 -0
- package/lib/mock/fixtures/cryptoCurrencies.js.map +1 -0
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +6 -0
- package/lib/operation.js.map +1 -1
- package/lib/platform/converters.test.js +44 -218
- package/lib/platform/converters.test.js.map +1 -1
- package/lib/platform/logic.d.ts +44 -0
- package/lib/platform/logic.d.ts.map +1 -1
- package/lib/platform/logic.js +147 -1
- package/lib/platform/logic.js.map +1 -1
- package/lib/platform/logic.test.d.ts +2 -0
- package/lib/platform/logic.test.d.ts.map +1 -0
- package/lib/platform/logic.test.js +903 -0
- package/lib/platform/logic.test.js.map +1 -0
- package/lib/platform/react.d.ts +6 -0
- package/lib/platform/react.d.ts.map +1 -1
- package/lib/platform/react.js +6 -0
- package/lib/platform/react.js.map +1 -1
- package/lib/platform/tracking.d.ts +1 -1
- package/lib/platform/tracking.d.ts.map +1 -1
- package/lib/platform/tracking.test.js +14 -41
- package/lib/platform/tracking.test.js.map +1 -1
- package/lib/reconciliation.d.ts.map +1 -1
- package/lib/reconciliation.js +39 -10
- package/lib/reconciliation.js.map +1 -1
- package/package.json +5 -7
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -2
- package/src/__tests__/test-helpers/environment.ts +91 -0
- package/src/__tests__/test-helpers/setup.ts +2 -91
- package/src/account/serialization.ts +125 -66
- package/src/apps/support.ts +1 -0
- package/src/bot/bot-test-context.test.ts +37 -0
- package/src/bot/bot-test-context.ts +24 -0
- package/src/bot/cli.ts +18 -0
- package/src/bot/engine.ts +109 -73
- package/src/bot/formatters.ts +40 -14
- package/src/bot/index.ts +124 -18
- package/src/bot/specs.ts +10 -5
- package/src/bot/types.ts +7 -3
- package/src/countervalues/logic.integration.test.ts +50 -0
- package/src/countervalues/modules/weth.ts +9 -12
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +59 -1
- package/src/currencies/sortByMarketcap.test.ts +1 -12
- package/src/currencies/sortByMarketcap.ts +2 -22
- package/src/env.ts +1 -1
- package/src/families/algorand/__snapshots__/bridge.integration.test.ts.snap +733 -8
- package/src/families/algorand/specs.ts +26 -16
- package/src/families/algorand/speculos-deviceActions.ts +31 -10
- package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +43309 -7957
- package/src/families/bitcoin/bridge/mock.ts +7 -1
- package/src/families/bitcoin/datasets/bitcoin_cash.ts +73 -13
- package/src/families/bitcoin/datasets/dash.ts +29 -17
- package/src/families/bitcoin/datasets/decred.ts +42 -12
- package/src/families/bitcoin/datasets/digibyte.ts +9 -3
- package/src/families/bitcoin/datasets/dogecoin.ts +29 -17
- package/src/families/bitcoin/datasets/komodo.ts +22 -22
- package/src/families/bitcoin/datasets/litecoin.ts +9 -3
- package/src/families/bitcoin/datasets/peercoin.ts +17 -17
- package/src/families/bitcoin/datasets/pivx.ts +17 -17
- package/src/families/bitcoin/datasets/qtum.ts +40 -40
- package/src/families/bitcoin/datasets/stakenet.ts +56 -26
- package/src/families/bitcoin/datasets/vertcoin.ts +43 -55
- package/src/families/bitcoin/datasets/viacoin.ts +35 -23
- package/src/families/bitcoin/datasets/zcash.ts +78 -12
- package/src/families/bitcoin/datasets/zencash.ts +56 -10
- package/src/families/bitcoin/platformAdapter.test.ts +58 -0
- package/src/families/bitcoin/specs.ts +81 -41
- package/src/families/bitcoin/speculos-deviceActions.ts +68 -69
- package/src/families/cardano/js-estimateMaxSpendable.ts +1 -1
- package/src/families/cardano/specs.ts +28 -11
- package/src/families/cardano/speculos-deviceActions.ts +65 -66
- package/src/families/celo/__snapshots__/bridge.integration.test.ts.snap +134 -857
- package/src/families/celo/api/hubble.ts +113 -16
- package/src/families/celo/api/index.ts +1 -1
- package/src/families/celo/api/sdk.ts +88 -0
- package/src/families/celo/bridge/js.ts +2 -3
- package/src/families/celo/cli-transaction.ts +46 -2
- package/src/families/celo/datasets/celo.scanAccounts.1.ts +365 -5
- package/src/families/celo/errors.ts +5 -0
- package/src/families/celo/js-buildTransaction.ts +173 -20
- package/src/families/celo/js-createTransaction.ts +2 -0
- package/src/families/celo/js-estimateMaxSpendable.ts +2 -2
- package/src/families/celo/js-getFeesForTransaction.ts +118 -19
- package/src/families/celo/js-getTransactionStatus.ts +72 -17
- package/src/families/celo/js-prepareTransaction.ts +13 -7
- package/src/families/celo/js-signOperation.ts +22 -5
- package/src/families/celo/js-synchronisation.ts +32 -0
- package/src/families/celo/logic.ts +184 -0
- package/src/families/celo/preload.ts +78 -0
- package/src/families/celo/react.ts +35 -0
- package/src/families/celo/serialization.ts +61 -0
- package/src/families/celo/specs/createActivateVoteMutation.ts +44 -0
- package/src/families/celo/specs/createLockMutation.ts +46 -0
- package/src/families/celo/specs/createRegisterAccountMutation.ts +34 -0
- package/src/families/celo/specs/createRevokeVoteMutation.ts +43 -0
- package/src/families/celo/specs/createSendMutation.ts +44 -0
- package/src/families/celo/specs/createUnlockMutation.ts +44 -0
- package/src/families/celo/specs/createVoteMutation.ts +67 -0
- package/src/families/celo/specs/createWithdrawMutation.ts +44 -0
- package/src/families/celo/specs/index.ts +8 -0
- package/src/families/celo/specs.ts +34 -34
- package/src/families/celo/speculos-deviceActions.ts +63 -45
- package/src/families/celo/transaction.ts +12 -4
- package/src/families/celo/types.ts +113 -0
- package/src/families/celo/validators.ts +2 -0
- package/src/families/cosmos/__snapshots__/bridge.integration.test.ts.snap +246 -5
- package/src/families/cosmos/specs.ts +44 -28
- package/src/families/cosmos/speculos-deviceActions.ts +82 -83
- package/src/families/crypto_org/specs.ts +3 -0
- package/src/families/crypto_org/speculos-deviceActions.ts +58 -59
- package/src/families/elrond/specs.ts +21 -4
- package/src/families/elrond/speculos-deviceActions.ts +41 -42
- package/src/families/ethereum/__snapshots__/bridge.integration.test.ts.snap +90 -90
- package/src/families/ethereum/platformAdapter.test.ts +112 -0
- package/src/families/ethereum/specs.ts +47 -23
- package/src/families/ethereum/speculos-deviceActions.ts +93 -95
- package/src/families/filecoin/specs.ts +2 -1
- package/src/families/filecoin/speculos-deviceActions.ts +61 -62
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +57 -2
- package/src/families/hedera/specs.ts +13 -5
- package/src/families/hedera/speculos-deviceActions.ts +59 -60
- package/src/families/osmosis/specs.ts +15 -7
- package/src/families/osmosis/speculos-deviceActions.ts +82 -83
- package/src/families/polkadot/platformAdapter.test.ts +61 -0
- package/src/families/polkadot/specs.ts +20 -2
- package/src/families/polkadot/speculos-deviceActions.ts +83 -82
- package/src/families/ripple/platformAdapter.test.ts +54 -0
- package/src/families/ripple/specs.ts +14 -7
- package/src/families/ripple/speculos-deviceActions.ts +72 -73
- package/src/families/solana/specs.ts +33 -14
- package/src/families/solana/speculos-deviceActions.ts +0 -5
- package/src/families/stellar/api/horizon.ts +10 -6
- package/src/families/stellar/specs.ts +37 -19
- package/src/families/stellar/speculos-deviceActions.ts +85 -87
- package/src/families/tezos/bakers.whitelist-default.ts +0 -1
- package/src/families/tezos/specs.ts +2 -0
- package/src/families/tezos/speculos-deviceActions.ts +76 -77
- package/src/families/tron/specs.ts +67 -30
- package/src/families/tron/speculos-deviceActions.ts +81 -84
- package/src/hw/getGenuineCheckFromDeviceId.test.ts +98 -0
- package/src/hw/getGenuineCheckFromDeviceId.ts +61 -0
- package/src/hw/getLatestAvailableFirmwareFromDeviceId.ts +37 -0
- package/src/hw/hooks/useGenuineCheck.test.ts +232 -0
- package/src/hw/hooks/useGenuineCheck.ts +138 -0
- package/src/hw/hooks/useGetLatestAvailableFirmware.test.ts +111 -0
- package/src/hw/hooks/useGetLatestAvailableFirmware.ts +90 -0
- package/src/load/speculos.ts +2 -0
- package/src/mock/fixtures/cryptoCurrencies.ts +88 -0
- package/src/operation.ts +6 -0
- package/src/platform/converters.test.ts +49 -282
- package/src/platform/logic.test.ts +756 -0
- package/src/platform/logic.ts +285 -0
- package/src/platform/react.ts +6 -0
- package/src/platform/tracking.test.ts +6 -7
- package/src/platform/tracking.ts +1 -1
- package/src/reconciliation.ts +88 -43
- package/lib/bot/test.bot.d.ts +0 -2
- package/lib/bot/test.bot.d.ts.map +0 -1
- package/lib/bot/test.bot.js +0 -62
- package/lib/bot/test.bot.js.map +0 -1
- package/lib/generated/speculos-deviceActions.d.ts +0 -56
- package/lib/generated/speculos-deviceActions.d.ts.map +0 -1
- package/lib/generated/speculos-deviceActions.js +0 -42
- package/lib/generated/speculos-deviceActions.js.map +0 -1
- package/src/bot/test.bot.ts +0 -21
- package/src/generated/speculos-deviceActions.ts +0 -37
|
@@ -1,38 +1,137 @@
|
|
|
1
|
-
import type { Account } from "@ledgerhq/types-live";
|
|
2
1
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { Transaction } from "
|
|
2
|
+
import type { CeloAccount, Transaction } from "./types";
|
|
4
3
|
import { celoKit } from "./api/sdk";
|
|
4
|
+
import { getPendingStakingOperationAmounts, getVote } from "./logic";
|
|
5
5
|
|
|
6
6
|
const getFeesForTransaction = async ({
|
|
7
7
|
account,
|
|
8
8
|
transaction,
|
|
9
9
|
}: {
|
|
10
|
-
account:
|
|
10
|
+
account: CeloAccount;
|
|
11
11
|
transaction: Transaction;
|
|
12
12
|
}): Promise<BigNumber> => {
|
|
13
|
-
const { amount } = transaction;
|
|
13
|
+
const { amount, index } = transaction;
|
|
14
14
|
const kit = celoKit();
|
|
15
15
|
|
|
16
16
|
// A workaround - estimating gas throws an error if value > funds
|
|
17
|
-
|
|
18
|
-
? account.spendableBalance
|
|
19
|
-
: BigNumber.minimum(amount, account.spendableBalance);
|
|
17
|
+
let value: BigNumber = new BigNumber(0);
|
|
20
18
|
|
|
21
|
-
const
|
|
19
|
+
const pendingOperationAmounts = getPendingStakingOperationAmounts(account);
|
|
20
|
+
const lockedGold = await kit.contracts.getLockedGold();
|
|
21
|
+
const nonvotingLockedGoldBalance =
|
|
22
|
+
await lockedGold.getAccountNonvotingLockedGold(account.freshAddress);
|
|
23
|
+
// Deduct pending vote operations from the non-voting locked balance
|
|
24
|
+
const totalNonVotingLockedBalance = nonvotingLockedGoldBalance.minus(
|
|
25
|
+
pendingOperationAmounts.vote
|
|
26
|
+
);
|
|
27
|
+
// Deduct pending lock operations from the spendable balance
|
|
28
|
+
const totalSpendableBalance = account.spendableBalance.minus(
|
|
29
|
+
pendingOperationAmounts.lock
|
|
30
|
+
);
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
if (
|
|
33
|
+
(transaction.mode === "unlock" || transaction.mode === "vote") &&
|
|
34
|
+
account.celoResources
|
|
35
|
+
) {
|
|
36
|
+
value = transaction.useAllAmount
|
|
37
|
+
? totalNonVotingLockedBalance
|
|
38
|
+
: BigNumber.minimum(amount, totalNonVotingLockedBalance);
|
|
39
|
+
} else if (transaction.mode === "revoke" && account.celoResources) {
|
|
40
|
+
const vote = getVote(account, transaction.recipient, transaction.index);
|
|
41
|
+
if (vote) {
|
|
42
|
+
value = transaction.useAllAmount
|
|
43
|
+
? vote.amount
|
|
44
|
+
: BigNumber.minimum(amount, vote.amount);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
value = transaction.useAllAmount
|
|
48
|
+
? totalSpendableBalance
|
|
49
|
+
: BigNumber.minimum(amount, totalSpendableBalance);
|
|
50
|
+
}
|
|
30
51
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
let gas: number | null = null;
|
|
53
|
+
if (transaction.mode === "lock") {
|
|
54
|
+
gas = await lockedGold
|
|
55
|
+
.lock()
|
|
56
|
+
.txo.estimateGas({ from: account.freshAddress, value: value.toFixed() });
|
|
57
|
+
} else if (transaction.mode === "unlock") {
|
|
58
|
+
const lockedGold = await kit.contracts.getLockedGold();
|
|
59
|
+
|
|
60
|
+
gas = await lockedGold
|
|
61
|
+
.unlock(value)
|
|
62
|
+
.txo.estimateGas({ from: account.freshAddress });
|
|
63
|
+
} else if (transaction.mode === "withdraw") {
|
|
64
|
+
const lockedGold = await kit.contracts.getLockedGold();
|
|
65
|
+
|
|
66
|
+
gas = await lockedGold
|
|
67
|
+
.withdraw(index || 0)
|
|
68
|
+
.txo.estimateGas({ from: account.freshAddress });
|
|
69
|
+
} else if (transaction.mode === "vote") {
|
|
70
|
+
const election = await kit.contracts.getElection();
|
|
71
|
+
|
|
72
|
+
const vote = await election.vote(
|
|
73
|
+
transaction.recipient,
|
|
74
|
+
new BigNumber(value)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
gas = await vote.txo.estimateGas({ from: account.freshAddress });
|
|
78
|
+
} else if (transaction.mode === "revoke") {
|
|
79
|
+
const election = await kit.contracts.getElection();
|
|
80
|
+
const accounts = await kit.contracts.getAccounts();
|
|
81
|
+
const voteSignerAccount = await accounts.voteSignerToAccount(
|
|
82
|
+
account.freshAddress
|
|
83
|
+
);
|
|
84
|
+
const revokeTxs = await election.revoke(
|
|
85
|
+
voteSignerAccount,
|
|
86
|
+
transaction.recipient,
|
|
87
|
+
new BigNumber(value)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const revokeTx = revokeTxs.find((transactionObject) => {
|
|
91
|
+
return (
|
|
92
|
+
(transactionObject.txo as any)._method.name ===
|
|
93
|
+
(transaction.index === 0 ? "revokePending" : "revokeActive")
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
if (!revokeTx) return new BigNumber(0);
|
|
35
97
|
|
|
98
|
+
gas = await revokeTx.txo.estimateGas({ from: account.freshAddress });
|
|
99
|
+
} else if (transaction.mode === "activate") {
|
|
100
|
+
const election = await kit.contracts.getElection();
|
|
101
|
+
const accounts = await kit.contracts.getAccounts();
|
|
102
|
+
const voteSignerAccount = await accounts.voteSignerToAccount(
|
|
103
|
+
account.freshAddress
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const activates = await election.activate(voteSignerAccount);
|
|
107
|
+
|
|
108
|
+
const activate = activates.find(
|
|
109
|
+
(a) => a.txo.arguments[0] === transaction.recipient
|
|
110
|
+
);
|
|
111
|
+
if (!activate) return new BigNumber(0);
|
|
112
|
+
|
|
113
|
+
gas = await activate.txo.estimateGas({ from: account.freshAddress });
|
|
114
|
+
} else if (transaction.mode === "register") {
|
|
115
|
+
const accounts = await kit.contracts.getAccounts();
|
|
116
|
+
|
|
117
|
+
gas = await accounts
|
|
118
|
+
.createAccount()
|
|
119
|
+
.txo.estimateGas({ from: account.freshAddress });
|
|
120
|
+
} else {
|
|
121
|
+
const celoToken = await kit.contracts.getGoldToken();
|
|
122
|
+
|
|
123
|
+
const celoTransaction = {
|
|
124
|
+
from: account.freshAddress,
|
|
125
|
+
to: celoToken.address,
|
|
126
|
+
data: celoToken
|
|
127
|
+
.transfer(transaction.recipient, value.toFixed())
|
|
128
|
+
.txo.encodeABI(),
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
gas = await kit.connection.estimateGasWithInflationFactor(celoTransaction);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const gasPrice = new BigNumber(await kit.connection.gasPrice());
|
|
36
135
|
return gasPrice.times(gas);
|
|
37
136
|
};
|
|
38
137
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction, TransactionStatus } from "./types";
|
|
1
|
+
import { CeloAccount, Transaction, TransactionStatus } from "./types";
|
|
2
2
|
import {
|
|
3
3
|
AmountRequired,
|
|
4
4
|
FeeNotLoaded,
|
|
@@ -9,10 +9,17 @@ import {
|
|
|
9
9
|
} from "@ledgerhq/errors";
|
|
10
10
|
import { BigNumber } from "bignumber.js";
|
|
11
11
|
import { isValidAddress } from "@celo/utils/lib/address";
|
|
12
|
-
import {
|
|
12
|
+
import { CeloAllFundsWarning } from "./errors";
|
|
13
|
+
import { getPendingStakingOperationAmounts, getVote } from "./logic";
|
|
14
|
+
import { celoKit } from "./api/sdk";
|
|
15
|
+
|
|
16
|
+
const kit = celoKit();
|
|
17
|
+
|
|
18
|
+
// Arbitrary buffer for paying fees of next transactions. 0.05 Celo for ~100 transactions
|
|
19
|
+
const FEES_SAFETY_BUFFER = new BigNumber(5000000000000000);
|
|
13
20
|
|
|
14
21
|
const getTransactionStatus = async (
|
|
15
|
-
account:
|
|
22
|
+
account: CeloAccount,
|
|
16
23
|
transaction: Transaction
|
|
17
24
|
): Promise<TransactionStatus> => {
|
|
18
25
|
const errors: any = {};
|
|
@@ -27,34 +34,82 @@ const getTransactionStatus = async (
|
|
|
27
34
|
errors.fees = new FeeNotLoaded();
|
|
28
35
|
}
|
|
29
36
|
|
|
37
|
+
const pendingOperationAmounts = getPendingStakingOperationAmounts(account);
|
|
38
|
+
const lockedGold = await kit.contracts.getLockedGold();
|
|
39
|
+
const nonvotingLockedGoldBalance =
|
|
40
|
+
await lockedGold.getAccountNonvotingLockedGold(account.freshAddress);
|
|
41
|
+
// Deduct pending vote operations from the non-voting locked balance
|
|
42
|
+
const totalNonVotingLockedBalance = nonvotingLockedGoldBalance.minus(
|
|
43
|
+
pendingOperationAmounts.vote
|
|
44
|
+
);
|
|
45
|
+
// Deduct pending lock operations from the spendable balance
|
|
46
|
+
const totalSpendableBalance = account.spendableBalance.minus(
|
|
47
|
+
pendingOperationAmounts.lock
|
|
48
|
+
);
|
|
30
49
|
const estimatedFees = transaction.fees || new BigNumber(0);
|
|
31
50
|
|
|
32
|
-
let amount =
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
let amount: BigNumber = new BigNumber(0);
|
|
52
|
+
if (
|
|
53
|
+
useAllAmount &&
|
|
54
|
+
(transaction.mode === "unlock" || transaction.mode === "vote")
|
|
55
|
+
) {
|
|
56
|
+
amount = totalNonVotingLockedBalance ?? new BigNumber(0);
|
|
57
|
+
} else if (useAllAmount && transaction.mode === "revoke") {
|
|
58
|
+
const revoke = getVote(account, transaction.recipient, transaction.index);
|
|
59
|
+
if (revoke?.amount) amount = revoke.amount;
|
|
60
|
+
} else if (useAllAmount) {
|
|
61
|
+
amount = totalSpendableBalance.minus(estimatedFees);
|
|
62
|
+
} else {
|
|
63
|
+
amount = new BigNumber(transaction.amount);
|
|
64
|
+
}
|
|
35
65
|
|
|
36
66
|
if (amount.lt(0)) amount = new BigNumber(0);
|
|
37
67
|
|
|
38
|
-
if (
|
|
39
|
-
errors.amount
|
|
68
|
+
if (
|
|
69
|
+
!errors.amount &&
|
|
70
|
+
(account.celoResources?.lockedBalance.gt(0) ||
|
|
71
|
+
!!account.celoResources?.pendingWithdrawals?.length) &&
|
|
72
|
+
(transaction.useAllAmount ||
|
|
73
|
+
totalSpendableBalance.minus(amount).lt(FEES_SAFETY_BUFFER)) &&
|
|
74
|
+
["send", "lock"].includes(transaction.mode)
|
|
75
|
+
) {
|
|
76
|
+
warnings.amount = new CeloAllFundsWarning();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!["register", "withdraw", "activate"].includes(transaction.mode)) {
|
|
80
|
+
if (amount.lte(0) && !useAllAmount) {
|
|
81
|
+
errors.amount = new AmountRequired();
|
|
82
|
+
}
|
|
40
83
|
}
|
|
41
84
|
|
|
42
85
|
const totalSpent = amount.plus(estimatedFees);
|
|
43
86
|
|
|
44
|
-
if (
|
|
45
|
-
|
|
87
|
+
if (transaction.mode === "unlock" || transaction.mode === "vote") {
|
|
88
|
+
if (totalNonVotingLockedBalance && amount.gt(totalNonVotingLockedBalance)) {
|
|
89
|
+
errors.amount = new NotEnoughBalance();
|
|
90
|
+
}
|
|
91
|
+
} else if (transaction.mode === "revoke") {
|
|
92
|
+
const revoke = getVote(account, transaction.recipient, transaction.index);
|
|
93
|
+
if (revoke?.amount && amount.gt(revoke.amount))
|
|
94
|
+
errors.amount = new NotEnoughBalance();
|
|
95
|
+
} else {
|
|
96
|
+
if (totalSpent.gt(totalSpendableBalance)) {
|
|
97
|
+
errors.amount = new NotEnoughBalance();
|
|
98
|
+
}
|
|
46
99
|
}
|
|
47
100
|
|
|
48
|
-
if (!errors.amount &&
|
|
101
|
+
if (!errors.amount && totalSpendableBalance.lt(estimatedFees)) {
|
|
49
102
|
errors.amount = new NotEnoughBalance();
|
|
50
103
|
}
|
|
51
104
|
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
105
|
+
if (transaction.mode === "send") {
|
|
106
|
+
if (!transaction.recipient) {
|
|
107
|
+
errors.recipient = new RecipientRequired();
|
|
108
|
+
} else if (!isValidAddress(transaction.recipient)) {
|
|
109
|
+
errors.recipient = new InvalidAddress("", {
|
|
110
|
+
currencyName: account.currency.name,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
58
113
|
}
|
|
59
114
|
|
|
60
115
|
return Promise.resolve({
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { Transaction } from "./types";
|
|
1
|
+
import { CeloAccount, Transaction } from "./types";
|
|
2
2
|
import getFeesForTransaction from "./js-getFeesForTransaction";
|
|
3
3
|
import { isValidAddress } from "@celo/utils/lib/address";
|
|
4
|
-
import
|
|
4
|
+
import BigNumber from "bignumber.js";
|
|
5
5
|
|
|
6
6
|
const sameFees = (a, b) => (!a || !b ? a === b : a.eq(b));
|
|
7
7
|
|
|
8
8
|
const prepareTransaction = async (
|
|
9
|
-
account:
|
|
9
|
+
account: CeloAccount,
|
|
10
10
|
transaction: Transaction
|
|
11
11
|
) => {
|
|
12
|
+
if (transaction.recipient && !isValidAddress(transaction.recipient))
|
|
13
|
+
return transaction;
|
|
14
|
+
|
|
15
|
+
if (["send", "vote"].includes(transaction.mode) && !transaction.recipient)
|
|
16
|
+
return transaction;
|
|
17
|
+
|
|
12
18
|
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
transaction.mode === "vote" &&
|
|
20
|
+
!transaction.useAllAmount &&
|
|
21
|
+
new BigNumber(transaction.amount).lte(0)
|
|
22
|
+
)
|
|
16
23
|
return transaction;
|
|
17
|
-
}
|
|
18
24
|
|
|
19
25
|
const fees = await getFeesForTransaction({ account, transaction });
|
|
20
26
|
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
4
|
-
import type { Transaction } from "./types";
|
|
4
|
+
import type { Transaction, CeloOperationMode, CeloAccount } from "./types";
|
|
5
5
|
import { encodeOperationId } from "../../operation";
|
|
6
6
|
import { CeloApp } from "./hw-app-celo";
|
|
7
7
|
import buildTransaction from "./js-buildTransaction";
|
|
8
8
|
import { rlpEncodedTx, encodeTransaction } from "@celo/wallet-base";
|
|
9
9
|
import { tokenInfoByAddressAndChainId } from "@celo/wallet-ledger/lib/tokens";
|
|
10
10
|
import { withDevice } from "../../hw/deviceAccess";
|
|
11
|
+
|
|
12
|
+
const MODE_TO_TYPE: { [key in CeloOperationMode | "default"]: string } = {
|
|
13
|
+
send: "OUT",
|
|
14
|
+
lock: "LOCK",
|
|
15
|
+
unlock: "UNLOCK",
|
|
16
|
+
withdraw: "WITHDRAW",
|
|
17
|
+
vote: "VOTE",
|
|
18
|
+
revoke: "REVOKE",
|
|
19
|
+
activate: "ACTIVATE",
|
|
20
|
+
register: "REGISTER",
|
|
21
|
+
default: "FEE",
|
|
22
|
+
};
|
|
11
23
|
import type {
|
|
12
24
|
Account,
|
|
13
25
|
Operation,
|
|
26
|
+
OperationType,
|
|
14
27
|
SignOperationEvent,
|
|
15
28
|
} from "@ledgerhq/types-live";
|
|
16
29
|
|
|
@@ -19,9 +32,13 @@ const buildOptimisticOperation = (
|
|
|
19
32
|
transaction: Transaction,
|
|
20
33
|
fee: BigNumber
|
|
21
34
|
): Operation => {
|
|
22
|
-
const type =
|
|
35
|
+
const type = (MODE_TO_TYPE[transaction.mode] ??
|
|
36
|
+
MODE_TO_TYPE.default) as OperationType;
|
|
23
37
|
|
|
24
|
-
const value =
|
|
38
|
+
const value =
|
|
39
|
+
type === "OUT" || type === "LOCK"
|
|
40
|
+
? new BigNumber(transaction.amount).plus(fee)
|
|
41
|
+
: new BigNumber(transaction.amount);
|
|
25
42
|
|
|
26
43
|
const operation: Operation = {
|
|
27
44
|
id: encodeOperationId(account.id, "", type),
|
|
@@ -35,7 +52,7 @@ const buildOptimisticOperation = (
|
|
|
35
52
|
recipients: [transaction.recipient].filter(Boolean),
|
|
36
53
|
accountId: account.id,
|
|
37
54
|
date: new Date(),
|
|
38
|
-
extra: {
|
|
55
|
+
extra: {},
|
|
39
56
|
};
|
|
40
57
|
|
|
41
58
|
return operation;
|
|
@@ -94,7 +111,7 @@ const signOperation = ({
|
|
|
94
111
|
|
|
95
112
|
const celo = new CeloApp(transport);
|
|
96
113
|
const unsignedTransaction = await buildTransaction(
|
|
97
|
-
account,
|
|
114
|
+
account as CeloAccount,
|
|
98
115
|
transaction
|
|
99
116
|
);
|
|
100
117
|
const { chainId, to } = unsignedTransaction;
|
|
@@ -2,10 +2,21 @@ import { encodeAccountId } from "../../account";
|
|
|
2
2
|
import type { GetAccountShape } from "../../bridge/jsHelpers";
|
|
3
3
|
import { makeSync, makeScanAccounts, mergeOps } from "../../bridge/jsHelpers";
|
|
4
4
|
import { getAccountDetails } from "./api";
|
|
5
|
+
import { celoKit } from "./api/sdk";
|
|
6
|
+
import {
|
|
7
|
+
getAccountRegistrationStatus,
|
|
8
|
+
getPendingWithdrawals,
|
|
9
|
+
getVotes,
|
|
10
|
+
} from "./api/sdk";
|
|
11
|
+
|
|
12
|
+
const kit = celoKit();
|
|
5
13
|
|
|
6
14
|
const getAccountShape: GetAccountShape = async (info) => {
|
|
7
15
|
const { address, currency, initialAccount, derivationMode } = info;
|
|
8
16
|
const oldOperations = initialAccount?.operations || [];
|
|
17
|
+
const election = await kit.contracts.getElection();
|
|
18
|
+
const electionConfig = await election.getConfig();
|
|
19
|
+
const lockedGold = await kit.contracts.getLockedGold();
|
|
9
20
|
|
|
10
21
|
const accountId = encodeAccountId({
|
|
11
22
|
type: "js",
|
|
@@ -19,7 +30,18 @@ const getAccountShape: GetAccountShape = async (info) => {
|
|
|
19
30
|
balance,
|
|
20
31
|
spendableBalance,
|
|
21
32
|
operations: newOperations,
|
|
33
|
+
lockedBalance,
|
|
34
|
+
nonvotingLockedBalance,
|
|
22
35
|
} = await getAccountDetails(address, accountId);
|
|
36
|
+
|
|
37
|
+
const accountRegistrationStatus = await getAccountRegistrationStatus(address);
|
|
38
|
+
|
|
39
|
+
const pendingWithdrawals = accountRegistrationStatus
|
|
40
|
+
? await getPendingWithdrawals(address)
|
|
41
|
+
: [];
|
|
42
|
+
|
|
43
|
+
const votes = accountRegistrationStatus ? await getVotes(address) : [];
|
|
44
|
+
|
|
23
45
|
const operations = mergeOps(oldOperations, newOperations);
|
|
24
46
|
const shape = {
|
|
25
47
|
id: accountId,
|
|
@@ -27,6 +49,16 @@ const getAccountShape: GetAccountShape = async (info) => {
|
|
|
27
49
|
spendableBalance,
|
|
28
50
|
operationsCount: operations.length,
|
|
29
51
|
blockHeight,
|
|
52
|
+
celoResources: {
|
|
53
|
+
registrationStatus: accountRegistrationStatus,
|
|
54
|
+
lockedBalance,
|
|
55
|
+
nonvotingLockedBalance,
|
|
56
|
+
pendingWithdrawals,
|
|
57
|
+
votes,
|
|
58
|
+
electionAddress: election.address,
|
|
59
|
+
lockedGoldAddress: lockedGold.address,
|
|
60
|
+
maxNumGroupsVotedFor: electionConfig.maxNumGroupsVotedFor,
|
|
61
|
+
},
|
|
30
62
|
};
|
|
31
63
|
return { ...shape, operations };
|
|
32
64
|
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CeloAccount,
|
|
3
|
+
CeloPendingWithdrawal,
|
|
4
|
+
CeloValidatorGroup,
|
|
5
|
+
CeloVote,
|
|
6
|
+
CeloVoteStatus,
|
|
7
|
+
PendingStakingOperationAmounts,
|
|
8
|
+
} from "./types";
|
|
9
|
+
import { BigNumber } from "bignumber.js";
|
|
10
|
+
import { Operation } from "@ledgerhq/types-live";
|
|
11
|
+
|
|
12
|
+
export const PRELOAD_MAX_AGE = 10 * 60 * 1000; // 10 minutes, used for max age in preload strategy
|
|
13
|
+
const LEDGER_BY_FIGMENT_VALIDATOR_GROUP_ADDRESS =
|
|
14
|
+
"0x0861a61Bf679A30680510EcC238ee43B82C5e843";
|
|
15
|
+
|
|
16
|
+
export const availablePendingWithdrawals = (
|
|
17
|
+
account: CeloAccount
|
|
18
|
+
): CeloPendingWithdrawal[] => {
|
|
19
|
+
const { pendingWithdrawals } = account.celoResources || {};
|
|
20
|
+
|
|
21
|
+
return (pendingWithdrawals || []).filter(
|
|
22
|
+
(withdrawal) => new Date(withdrawal.time.toNumber() * 1000) < new Date()
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const withdrawableBalance = (account: CeloAccount): BigNumber =>
|
|
27
|
+
availablePendingWithdrawals(account).reduce(
|
|
28
|
+
(sum, withdrawal) => sum.plus(withdrawal.value),
|
|
29
|
+
new BigNumber(0)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const hasWithdrawableBalance = (account: CeloAccount): boolean =>
|
|
33
|
+
withdrawableBalance(account).isGreaterThan(0);
|
|
34
|
+
|
|
35
|
+
export const defaultValidatorGroupAddress = (): string =>
|
|
36
|
+
LEDGER_BY_FIGMENT_VALIDATOR_GROUP_ADDRESS;
|
|
37
|
+
|
|
38
|
+
export const isDefaultValidatorGroupAddress = (address: string): boolean =>
|
|
39
|
+
address === LEDGER_BY_FIGMENT_VALIDATOR_GROUP_ADDRESS;
|
|
40
|
+
|
|
41
|
+
export const isDefaultValidatorGroup = (
|
|
42
|
+
validatorGroup: CeloValidatorGroup
|
|
43
|
+
): boolean => isDefaultValidatorGroupAddress(validatorGroup.address);
|
|
44
|
+
|
|
45
|
+
export const activatableVotes = (account: CeloAccount): CeloVote[] => {
|
|
46
|
+
const { votes } = account.celoResources || {};
|
|
47
|
+
|
|
48
|
+
return (votes || []).filter((vote) => vote.activatable);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const hasActivatableVotes = (account: CeloAccount): boolean =>
|
|
52
|
+
activatableVotes(account).length > 0;
|
|
53
|
+
|
|
54
|
+
export const revokableVotes = (account: CeloAccount): CeloVote[] => {
|
|
55
|
+
const { votes } = account.celoResources || {};
|
|
56
|
+
|
|
57
|
+
return (votes || []).filter((vote) => vote.revokable);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const hasRevokableVotes = (account: CeloAccount): boolean =>
|
|
61
|
+
revokableVotes(account).length > 0;
|
|
62
|
+
|
|
63
|
+
export const getVote = (
|
|
64
|
+
account: CeloAccount,
|
|
65
|
+
validatorGroupAddress: string,
|
|
66
|
+
index: number | null | undefined
|
|
67
|
+
): CeloVote | undefined => {
|
|
68
|
+
const { votes } = account.celoResources || {};
|
|
69
|
+
return votes?.find(
|
|
70
|
+
(revoke) =>
|
|
71
|
+
revoke.validatorGroup === validatorGroupAddress && revoke.index == index
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const voteStatus = (vote: CeloVote): CeloVoteStatus =>
|
|
76
|
+
vote.type === "pending" && vote.activatable
|
|
77
|
+
? "awaitingActivation"
|
|
78
|
+
: vote.type;
|
|
79
|
+
|
|
80
|
+
export const fallbackValidatorGroup = (
|
|
81
|
+
address: string
|
|
82
|
+
): CeloValidatorGroup => ({
|
|
83
|
+
address: address,
|
|
84
|
+
name: address,
|
|
85
|
+
votes: new BigNumber(0),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const isAccountRegistrationPending = (
|
|
89
|
+
accountId: string,
|
|
90
|
+
accounts: CeloAccount[]
|
|
91
|
+
): boolean => {
|
|
92
|
+
// If there's a pending "REGISTER" operation and the
|
|
93
|
+
// account's registration status is false, then
|
|
94
|
+
// we know that the account is truly not registered yet.
|
|
95
|
+
const account = accounts.find(
|
|
96
|
+
(currentAccount) => accountId === currentAccount.id
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const isAccountRegistrationPending =
|
|
100
|
+
!!account &&
|
|
101
|
+
account.pendingOperations.some(
|
|
102
|
+
(currentAccount) => currentAccount.type === "REGISTER"
|
|
103
|
+
) &&
|
|
104
|
+
!account.celoResources?.registrationStatus;
|
|
105
|
+
|
|
106
|
+
return isAccountRegistrationPending;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const isOperationTrulyPending = (
|
|
110
|
+
operation: Operation,
|
|
111
|
+
activeOperations: Operation[]
|
|
112
|
+
): boolean => {
|
|
113
|
+
if (
|
|
114
|
+
activeOperations.some(
|
|
115
|
+
(activeOperation) => activeOperation.hash === operation.hash
|
|
116
|
+
)
|
|
117
|
+
) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const initialPendingStakingOperationAmounts: PendingStakingOperationAmounts = {
|
|
125
|
+
vote: new BigNumber(0),
|
|
126
|
+
lock: new BigNumber(0),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const getPendingStakingOperationAmounts = (
|
|
130
|
+
account: CeloAccount
|
|
131
|
+
): PendingStakingOperationAmounts => {
|
|
132
|
+
const operationAmounts = account.pendingOperations.reduce(
|
|
133
|
+
(acc, currentOperation) => {
|
|
134
|
+
if (
|
|
135
|
+
currentOperation.type !== "VOTE" &&
|
|
136
|
+
currentOperation.type !== "LOCK"
|
|
137
|
+
) {
|
|
138
|
+
return acc;
|
|
139
|
+
}
|
|
140
|
+
if (isOperationTrulyPending(currentOperation, account.operations)) {
|
|
141
|
+
const value = new BigNumber(currentOperation.value);
|
|
142
|
+
switch (currentOperation.type) {
|
|
143
|
+
case "VOTE":
|
|
144
|
+
return {
|
|
145
|
+
...acc,
|
|
146
|
+
vote: acc.vote.plus(value),
|
|
147
|
+
};
|
|
148
|
+
case "LOCK":
|
|
149
|
+
return {
|
|
150
|
+
...acc,
|
|
151
|
+
lock: acc.lock.plus(value),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return acc;
|
|
157
|
+
},
|
|
158
|
+
initialPendingStakingOperationAmounts
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
return operationAmounts;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const getValidatorGroupsByVotingActivity = (
|
|
165
|
+
validatorGroups: CeloValidatorGroup[],
|
|
166
|
+
votes: CeloVote[],
|
|
167
|
+
withVotes: boolean
|
|
168
|
+
): CeloValidatorGroup[] => {
|
|
169
|
+
return validatorGroups.filter(
|
|
170
|
+
(v) => votes.some((d) => d.validatorGroup === v.address) === withVotes
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const getValidatorGroupsWithVotes = (
|
|
175
|
+
validatorGroups: CeloValidatorGroup[],
|
|
176
|
+
votes: CeloVote[] | null
|
|
177
|
+
): CeloValidatorGroup[] =>
|
|
178
|
+
getValidatorGroupsByVotingActivity(validatorGroups, votes || [], true);
|
|
179
|
+
|
|
180
|
+
export const getValidatorGroupsWithoutVotes = (
|
|
181
|
+
validatorGroups: CeloValidatorGroup[],
|
|
182
|
+
votes: CeloVote[] | null = []
|
|
183
|
+
): CeloValidatorGroup[] =>
|
|
184
|
+
getValidatorGroupsByVotingActivity(validatorGroups, votes || [], false);
|