@ledgerhq/live-common 33.1.1 → 33.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/test-helpers/environment.js +2 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -1
- package/lib/apps/polyfill.d.ts +4 -0
- package/lib/apps/polyfill.d.ts.map +1 -1
- package/lib/apps/polyfill.js +1 -1
- package/lib/apps/polyfill.js.map +1 -1
- package/lib/bridge/useBridgeTransaction.js +1 -2
- package/lib/bridge/useBridgeTransaction.js.map +1 -1
- package/lib/countervalues/api/api.d.ts.map +1 -1
- package/lib/countervalues/api/api.js +1 -1
- package/lib/countervalues/api/api.js.map +1 -1
- package/lib/countervalues/logic.d.ts.map +1 -1
- package/lib/countervalues/logic.js +15 -17
- package/lib/countervalues/logic.js.map +1 -1
- package/lib/countervalues/modules/index.d.ts +1 -1
- package/lib/countervalues/modules/index.d.ts.map +1 -1
- package/lib/countervalues/modules/index.js +7 -2
- package/lib/countervalues/modules/index.js.map +1 -1
- package/lib/countervalues/react.d.ts.map +1 -1
- package/lib/countervalues/react.js.map +1 -1
- package/lib/currencies/mock.d.ts +4 -0
- package/lib/currencies/mock.d.ts.map +1 -0
- package/lib/currencies/mock.js +521 -0
- package/lib/currencies/mock.js.map +1 -0
- package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
- package/lib/currencies/sortByMarketcap.js +16 -10
- package/lib/currencies/sortByMarketcap.js.map +1 -1
- package/lib/currencies/sortByMarketcap.test.js +20 -0
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/data/icons/react/cspr.d.ts +8 -0
- package/lib/data/icons/react/cspr.d.ts.map +1 -0
- package/lib/data/icons/react/cspr.js +38 -0
- package/lib/data/icons/react/cspr.js.map +1 -0
- package/lib/data/icons/react/index.d.ts +2 -0
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +13 -9
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/react/lyx.d.ts +8 -0
- package/lib/data/icons/react/lyx.d.ts.map +1 -0
- package/lib/data/icons/react/lyx.js +34 -0
- package/lib/data/icons/react/lyx.js.map +1 -0
- package/lib/data/icons/reactNative/cspr.d.ts +8 -0
- package/lib/data/icons/reactNative/cspr.d.ts.map +1 -0
- package/lib/data/icons/reactNative/cspr.js +39 -0
- package/lib/data/icons/reactNative/cspr.js.map +1 -0
- package/lib/data/icons/reactNative/index.d.ts +2 -0
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +13 -9
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/data/icons/reactNative/lyx.d.ts +8 -0
- package/lib/data/icons/reactNative/lyx.d.ts.map +1 -0
- package/lib/data/icons/reactNative/lyx.js +35 -0
- package/lib/data/icons/reactNative/lyx.js.map +1 -0
- package/lib/deviceSDK/tasks/core.test.js +10 -1
- package/lib/deviceSDK/tasks/core.test.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
- package/lib/exchange/platform/transfer/completeExchange.js +19 -12
- package/lib/exchange/platform/transfer/completeExchange.js.map +1 -1
- package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.js +6 -1
- package/lib/exchange/swap/completeExchange.js.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.js +5 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
- package/lib/exchange/swap/index.js +2 -2
- package/lib/exchange/swap/index.js.map +1 -1
- package/lib/families/algorand/bridge/mock.d.ts.map +1 -1
- package/lib/families/algorand/bridge/mock.js +3 -1
- package/lib/families/algorand/bridge/mock.js.map +1 -1
- package/lib/families/bitcoin/exchange.d.ts +1 -1
- package/lib/families/casper/api/index.d.ts +11 -0
- package/lib/families/casper/api/index.d.ts.map +1 -0
- package/lib/families/casper/api/index.js +138 -0
- package/lib/families/casper/api/index.js.map +1 -0
- package/lib/families/casper/api/types.d.ts +105 -0
- package/lib/families/casper/api/types.d.ts.map +1 -0
- package/lib/families/casper/api/types.js +3 -0
- package/lib/families/casper/api/types.js.map +1 -0
- package/lib/families/casper/bridge/account.d.ts +5 -0
- package/lib/families/casper/bridge/account.d.ts.map +1 -0
- package/lib/families/casper/bridge/account.js +206 -0
- package/lib/families/casper/bridge/account.js.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/accountShape.d.ts +3 -0
- package/lib/families/casper/bridge/bridgeHelpers/accountShape.d.ts.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/accountShape.js +47 -0
- package/lib/families/casper/bridge/bridgeHelpers/accountShape.js.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/addresses.d.ts +15 -0
- package/lib/families/casper/bridge/bridgeHelpers/addresses.d.ts.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/addresses.js +109 -0
- package/lib/families/casper/bridge/bridgeHelpers/addresses.js.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/fee.d.ts +3 -0
- package/lib/families/casper/bridge/bridgeHelpers/fee.d.ts.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/fee.js +13 -0
- package/lib/families/casper/bridge/bridgeHelpers/fee.js.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/transferId.d.ts +2 -0
- package/lib/families/casper/bridge/bridgeHelpers/transferId.d.ts.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/transferId.js +14 -0
- package/lib/families/casper/bridge/bridgeHelpers/transferId.js.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/txn.d.ts +10 -0
- package/lib/families/casper/bridge/bridgeHelpers/txn.d.ts.map +1 -0
- package/lib/families/casper/bridge/bridgeHelpers/txn.js +95 -0
- package/lib/families/casper/bridge/bridgeHelpers/txn.js.map +1 -0
- package/lib/families/casper/bridge/currency.d.ts +3 -0
- package/lib/families/casper/bridge/currency.d.ts.map +1 -0
- package/lib/families/casper/bridge/currency.js +12 -0
- package/lib/families/casper/bridge/currency.js.map +1 -0
- package/lib/families/casper/bridge/js.d.ts +6 -0
- package/lib/families/casper/bridge/js.d.ts.map +1 -0
- package/lib/families/casper/bridge/js.js +9 -0
- package/lib/families/casper/bridge/js.js.map +1 -0
- package/lib/families/casper/bridge/mock.d.ts +8 -0
- package/lib/families/casper/bridge/mock.d.ts.map +1 -0
- package/lib/families/casper/bridge/mock.js +133 -0
- package/lib/families/casper/bridge/mock.js.map +1 -0
- package/lib/families/casper/bridge.integration.test.d.ts +2 -0
- package/lib/families/casper/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/casper/bridge.integration.test.js +166 -0
- package/lib/families/casper/bridge.integration.test.js.map +1 -0
- package/lib/families/casper/consts.d.ts +11 -0
- package/lib/families/casper/consts.d.ts.map +1 -0
- package/lib/families/casper/consts.js +19 -0
- package/lib/families/casper/consts.js.map +1 -0
- package/lib/families/casper/deviceTransactionConfig.d.ts +17 -0
- package/lib/families/casper/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/families/casper/deviceTransactionConfig.js +26 -0
- package/lib/families/casper/deviceTransactionConfig.js.map +1 -0
- package/lib/families/casper/errors.d.ts +10 -0
- package/lib/families/casper/errors.d.ts.map +1 -0
- package/lib/families/casper/errors.js +8 -0
- package/lib/families/casper/errors.js.map +1 -0
- package/lib/families/casper/hw-getAddress.d.ts +4 -0
- package/lib/families/casper/hw-getAddress.d.ts.map +1 -0
- package/lib/families/casper/hw-getAddress.js +33 -0
- package/lib/families/casper/hw-getAddress.js.map +1 -0
- package/lib/families/casper/hw-signMessage.d.ts +6 -0
- package/lib/families/casper/hw-signMessage.d.ts.map +1 -0
- package/lib/families/casper/hw-signMessage.js +37 -0
- package/lib/families/casper/hw-signMessage.js.map +1 -0
- package/lib/families/casper/msc-utils.d.ts +13 -0
- package/lib/families/casper/msc-utils.d.ts.map +1 -0
- package/lib/families/casper/msc-utils.js +53 -0
- package/lib/families/casper/msc-utils.js.map +1 -0
- package/lib/families/casper/specs.d.ts +7 -0
- package/lib/families/casper/specs.d.ts.map +1 -0
- package/lib/families/casper/specs.js +108 -0
- package/lib/families/casper/specs.js.map +1 -0
- package/lib/families/casper/speculos-deviceActions.d.ts +4 -0
- package/lib/families/casper/speculos-deviceActions.d.ts.map +1 -0
- package/lib/families/casper/speculos-deviceActions.js +53 -0
- package/lib/families/casper/speculos-deviceActions.js.map +1 -0
- package/lib/families/casper/transaction.d.ts +14 -0
- package/lib/families/casper/transaction.d.ts.map +1 -0
- package/lib/families/casper/transaction.js +40 -0
- package/lib/families/casper/transaction.js.map +1 -0
- package/lib/families/casper/types.d.ts +22 -0
- package/lib/families/casper/types.d.ts.map +1 -0
- package/lib/families/casper/types.js +3 -0
- package/lib/families/casper/types.js.map +1 -0
- package/lib/families/crypto_org/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/crypto_org/js-getTransactionStatus.js +3 -1
- package/lib/families/crypto_org/js-getTransactionStatus.js.map +1 -1
- package/lib/families/internet_computer/bridge/account.d.ts.map +1 -1
- package/lib/families/internet_computer/bridge/account.js +6 -2
- package/lib/families/internet_computer/bridge/account.js.map +1 -1
- package/lib/families/near/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/near/js-getTransactionStatus.js +3 -1
- package/lib/families/near/js-getTransactionStatus.js.map +1 -1
- package/lib/families/polkadot/exchange.d.ts +1 -1
- package/lib/families/solana/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/solana/js-prepareTransaction.js +12 -4
- package/lib/families/solana/js-prepareTransaction.js.map +1 -1
- package/lib/families/stacks/bridge/account.d.ts.map +1 -1
- package/lib/families/stacks/bridge/account.js +6 -2
- package/lib/families/stacks/bridge/account.js.map +1 -1
- package/lib/families/stellar/api/horizon.d.ts +22 -6
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +29 -54
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/js-buildTransaction.d.ts +2 -1
- package/lib/families/stellar/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-buildTransaction.js +5 -5
- package/lib/families/stellar/js-buildTransaction.js.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.js +3 -1
- package/lib/families/stellar/js-getTransactionStatus.js.map +1 -1
- package/lib/families/stellar/logic.d.ts.map +1 -1
- package/lib/families/stellar/logic.js +6 -10
- package/lib/families/stellar/logic.js.map +1 -1
- package/lib/families/tron/bridge/js.d.ts.map +1 -1
- package/lib/families/tron/bridge/js.js +3 -1
- package/lib/families/tron/bridge/js.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts +2 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +8 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/helper.d.ts +2 -0
- package/lib/featureFlags/helper.d.ts.map +1 -0
- package/lib/featureFlags/helper.js +10 -0
- package/lib/featureFlags/helper.js.map +1 -0
- package/lib/featureFlags/index.d.ts +1 -0
- package/lib/featureFlags/index.d.ts.map +1 -1
- package/lib/featureFlags/index.js +1 -0
- package/lib/featureFlags/index.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/generated/bridge/js.d.ts +4 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +30 -28
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/bridge/mock.d.ts +4 -0
- package/lib/generated/bridge/mock.d.ts.map +1 -1
- package/lib/generated/bridge/mock.js +18 -16
- package/lib/generated/bridge/mock.js.map +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +4 -1
- package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.js +36 -34
- package/lib/generated/deviceTransactionConfig.js.map +1 -1
- package/lib/generated/exchange.d.ts +2 -2
- package/lib/generated/hw-getAddress.d.ts +1 -0
- package/lib/generated/hw-getAddress.d.ts.map +1 -1
- package/lib/generated/hw-getAddress.js +30 -28
- package/lib/generated/hw-getAddress.js.map +1 -1
- package/lib/generated/hw-signMessage.d.ts +3 -0
- package/lib/generated/hw-signMessage.d.ts.map +1 -1
- package/lib/generated/hw-signMessage.js +8 -6
- package/lib/generated/hw-signMessage.js.map +1 -1
- package/lib/generated/operation.d.ts +13 -0
- package/lib/generated/operation.d.ts.map +1 -0
- package/lib/generated/operation.js +10 -0
- package/lib/generated/operation.js.map +1 -0
- package/lib/generated/specs.d.ts +3 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/generated/specs.js +36 -34
- package/lib/generated/specs.js.map +1 -1
- package/lib/generated/transaction.d.ts +8 -0
- package/lib/generated/transaction.d.ts.map +1 -1
- package/lib/generated/transaction.js +36 -34
- package/lib/generated/transaction.js.map +1 -1
- package/lib/generated/types.d.ts +8 -4
- package/lib/generated/types.d.ts.map +1 -1
- package/lib/hooks/recoverFeatureFlag.d.ts +0 -1
- package/lib/hooks/recoverFeatureFlag.d.ts.map +1 -1
- package/lib/hooks/recoverFeatureFlag.js +1 -6
- package/lib/hooks/recoverFeatureFlag.js.map +1 -1
- package/lib/hooks/useBroadcast.d.ts +8 -0
- package/lib/hooks/useBroadcast.d.ts.map +1 -0
- package/lib/hooks/useBroadcast.js +40 -0
- package/lib/hooks/useBroadcast.js.map +1 -0
- package/lib/hooks/useEnv.d.ts.map +1 -1
- package/lib/hooks/useEnv.js.map +1 -1
- package/lib/manager/api.d.ts.map +1 -1
- package/lib/manager/api.js +9 -3
- package/lib/manager/api.js.map +1 -1
- package/lib/operation.d.ts +24 -0
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +41 -0
- package/lib/operation.js.map +1 -1
- package/lib/wallet-api/react.js +1 -1
- package/lib/wallet-api/react.js.map +1 -1
- package/lib/walletConnect/index.d.ts +8 -0
- package/lib/walletConnect/index.d.ts.map +1 -0
- package/lib/walletConnect/index.js +20 -0
- package/lib/walletConnect/index.js.map +1 -0
- package/lib-es/__tests__/test-helpers/environment.js +2 -0
- package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
- package/lib-es/apps/polyfill.d.ts +4 -0
- package/lib-es/apps/polyfill.d.ts.map +1 -1
- package/lib-es/apps/polyfill.js +1 -1
- package/lib-es/apps/polyfill.js.map +1 -1
- package/lib-es/bridge/useBridgeTransaction.js +1 -2
- package/lib-es/bridge/useBridgeTransaction.js.map +1 -1
- package/lib-es/countervalues/api/api.d.ts.map +1 -1
- package/lib-es/countervalues/api/api.js +1 -1
- package/lib-es/countervalues/api/api.js.map +1 -1
- package/lib-es/countervalues/logic.d.ts.map +1 -1
- package/lib-es/countervalues/logic.js +15 -17
- package/lib-es/countervalues/logic.js.map +1 -1
- package/lib-es/countervalues/modules/index.d.ts +1 -1
- package/lib-es/countervalues/modules/index.d.ts.map +1 -1
- package/lib-es/countervalues/modules/index.js +7 -2
- package/lib-es/countervalues/modules/index.js.map +1 -1
- package/lib-es/countervalues/react.d.ts.map +1 -1
- package/lib-es/countervalues/react.js.map +1 -1
- package/lib-es/currencies/mock.d.ts +4 -0
- package/lib-es/currencies/mock.d.ts.map +1 -0
- package/lib-es/currencies/mock.js +518 -0
- package/lib-es/currencies/mock.js.map +1 -0
- package/lib-es/currencies/sortByMarketcap.d.ts.map +1 -1
- package/lib-es/currencies/sortByMarketcap.js +16 -10
- package/lib-es/currencies/sortByMarketcap.js.map +1 -1
- package/lib-es/currencies/sortByMarketcap.test.js +20 -0
- package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib-es/data/icons/react/cspr.d.ts +8 -0
- package/lib-es/data/icons/react/cspr.d.ts.map +1 -0
- package/lib-es/data/icons/react/cspr.js +13 -0
- package/lib-es/data/icons/react/cspr.js.map +1 -0
- package/lib-es/data/icons/react/index.d.ts +2 -0
- package/lib-es/data/icons/react/index.d.ts.map +1 -1
- package/lib-es/data/icons/react/index.js +2 -0
- package/lib-es/data/icons/react/index.js.map +1 -1
- package/lib-es/data/icons/react/lyx.d.ts +8 -0
- package/lib-es/data/icons/react/lyx.d.ts.map +1 -0
- package/lib-es/data/icons/react/lyx.js +9 -0
- package/lib-es/data/icons/react/lyx.js.map +1 -0
- package/lib-es/data/icons/reactNative/cspr.d.ts +8 -0
- package/lib-es/data/icons/reactNative/cspr.d.ts.map +1 -0
- package/lib-es/data/icons/reactNative/cspr.js +14 -0
- package/lib-es/data/icons/reactNative/cspr.js.map +1 -0
- package/lib-es/data/icons/reactNative/index.d.ts +2 -0
- package/lib-es/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib-es/data/icons/reactNative/index.js +2 -0
- package/lib-es/data/icons/reactNative/index.js.map +1 -1
- package/lib-es/data/icons/reactNative/lyx.d.ts +8 -0
- package/lib-es/data/icons/reactNative/lyx.d.ts.map +1 -0
- package/lib-es/data/icons/reactNative/lyx.js +10 -0
- package/lib-es/data/icons/reactNative/lyx.js.map +1 -0
- package/lib-es/deviceSDK/tasks/core.test.js +10 -1
- package/lib-es/deviceSDK/tasks/core.test.js.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/platform/transfer/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/platform/transfer/completeExchange.js +19 -12
- package/lib-es/exchange/platform/transfer/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib-es/exchange/swap/completeExchange.js +6 -1
- package/lib-es/exchange/swap/completeExchange.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/useSwapTransaction.js +6 -2
- package/lib-es/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
- package/lib-es/exchange/swap/index.js +2 -2
- package/lib-es/exchange/swap/index.js.map +1 -1
- package/lib-es/families/algorand/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/algorand/bridge/mock.js +3 -1
- package/lib-es/families/algorand/bridge/mock.js.map +1 -1
- package/lib-es/families/bitcoin/exchange.d.ts +1 -1
- package/lib-es/families/casper/api/index.d.ts +11 -0
- package/lib-es/families/casper/api/index.d.ts.map +1 -0
- package/lib-es/families/casper/api/index.js +127 -0
- package/lib-es/families/casper/api/index.js.map +1 -0
- package/lib-es/families/casper/api/types.d.ts +105 -0
- package/lib-es/families/casper/api/types.d.ts.map +1 -0
- package/lib-es/families/casper/api/types.js +2 -0
- package/lib-es/families/casper/api/types.js.map +1 -0
- package/lib-es/families/casper/bridge/account.d.ts +5 -0
- package/lib-es/families/casper/bridge/account.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/account.js +200 -0
- package/lib-es/families/casper/bridge/account.js.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/accountShape.d.ts +3 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/accountShape.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/accountShape.js +40 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/accountShape.js.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/addresses.d.ts +15 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/addresses.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/addresses.js +99 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/addresses.js.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/fee.d.ts +3 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/fee.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/fee.js +6 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/fee.js.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/transferId.d.ts +2 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/transferId.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/transferId.js +10 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/transferId.js.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/txn.d.ts +10 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/txn.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/txn.js +85 -0
- package/lib-es/families/casper/bridge/bridgeHelpers/txn.js.map +1 -0
- package/lib-es/families/casper/bridge/currency.d.ts +3 -0
- package/lib-es/families/casper/bridge/currency.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/currency.js +9 -0
- package/lib-es/families/casper/bridge/currency.js.map +1 -0
- package/lib-es/families/casper/bridge/js.d.ts +6 -0
- package/lib-es/families/casper/bridge/js.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/js.js +7 -0
- package/lib-es/families/casper/bridge/js.js.map +1 -0
- package/lib-es/families/casper/bridge/mock.d.ts +8 -0
- package/lib-es/families/casper/bridge/mock.d.ts.map +1 -0
- package/lib-es/families/casper/bridge/mock.js +131 -0
- package/lib-es/families/casper/bridge/mock.js.map +1 -0
- package/lib-es/families/casper/bridge.integration.test.d.ts +2 -0
- package/lib-es/families/casper/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/families/casper/bridge.integration.test.js +161 -0
- package/lib-es/families/casper/bridge.integration.test.js.map +1 -0
- package/lib-es/families/casper/consts.d.ts +11 -0
- package/lib-es/families/casper/consts.d.ts.map +1 -0
- package/lib-es/families/casper/consts.js +16 -0
- package/lib-es/families/casper/consts.js.map +1 -0
- package/lib-es/families/casper/deviceTransactionConfig.d.ts +17 -0
- package/lib-es/families/casper/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/families/casper/deviceTransactionConfig.js +24 -0
- package/lib-es/families/casper/deviceTransactionConfig.js.map +1 -0
- package/lib-es/families/casper/errors.d.ts +10 -0
- package/lib-es/families/casper/errors.d.ts.map +1 -0
- package/lib-es/families/casper/errors.js +5 -0
- package/lib-es/families/casper/errors.js.map +1 -0
- package/lib-es/families/casper/hw-getAddress.d.ts +4 -0
- package/lib-es/families/casper/hw-getAddress.d.ts.map +1 -0
- package/lib-es/families/casper/hw-getAddress.js +28 -0
- package/lib-es/families/casper/hw-getAddress.js.map +1 -0
- package/lib-es/families/casper/hw-signMessage.d.ts +6 -0
- package/lib-es/families/casper/hw-signMessage.d.ts.map +1 -0
- package/lib-es/families/casper/hw-signMessage.js +32 -0
- package/lib-es/families/casper/hw-signMessage.js.map +1 -0
- package/lib-es/families/casper/msc-utils.d.ts +13 -0
- package/lib-es/families/casper/msc-utils.d.ts.map +1 -0
- package/lib-es/families/casper/msc-utils.js +39 -0
- package/lib-es/families/casper/msc-utils.js.map +1 -0
- package/lib-es/families/casper/specs.d.ts +7 -0
- package/lib-es/families/casper/specs.d.ts.map +1 -0
- package/lib-es/families/casper/specs.js +103 -0
- package/lib-es/families/casper/specs.js.map +1 -0
- package/lib-es/families/casper/speculos-deviceActions.d.ts +4 -0
- package/lib-es/families/casper/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/families/casper/speculos-deviceActions.js +50 -0
- package/lib-es/families/casper/speculos-deviceActions.js.map +1 -0
- package/lib-es/families/casper/transaction.d.ts +14 -0
- package/lib-es/families/casper/transaction.d.ts.map +1 -0
- package/lib-es/families/casper/transaction.js +32 -0
- package/lib-es/families/casper/transaction.js.map +1 -0
- package/lib-es/families/casper/types.d.ts +22 -0
- package/lib-es/families/casper/types.d.ts.map +1 -0
- package/lib-es/families/casper/types.js +2 -0
- package/lib-es/families/casper/types.js.map +1 -0
- package/lib-es/families/crypto_org/js-getTransactionStatus.d.ts.map +1 -1
- package/lib-es/families/crypto_org/js-getTransactionStatus.js +3 -1
- package/lib-es/families/crypto_org/js-getTransactionStatus.js.map +1 -1
- package/lib-es/families/internet_computer/bridge/account.d.ts.map +1 -1
- package/lib-es/families/internet_computer/bridge/account.js +6 -2
- package/lib-es/families/internet_computer/bridge/account.js.map +1 -1
- package/lib-es/families/near/js-getTransactionStatus.d.ts.map +1 -1
- package/lib-es/families/near/js-getTransactionStatus.js +3 -1
- package/lib-es/families/near/js-getTransactionStatus.js.map +1 -1
- package/lib-es/families/polkadot/exchange.d.ts +1 -1
- package/lib-es/families/solana/js-prepareTransaction.d.ts.map +1 -1
- package/lib-es/families/solana/js-prepareTransaction.js +12 -4
- package/lib-es/families/solana/js-prepareTransaction.js.map +1 -1
- package/lib-es/families/stacks/bridge/account.d.ts.map +1 -1
- package/lib-es/families/stacks/bridge/account.js +6 -2
- package/lib-es/families/stacks/bridge/account.js.map +1 -1
- package/lib-es/families/stellar/api/horizon.d.ts +22 -6
- package/lib-es/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib-es/families/stellar/api/horizon.js +29 -31
- package/lib-es/families/stellar/api/horizon.js.map +1 -1
- package/lib-es/families/stellar/js-buildTransaction.d.ts +2 -1
- package/lib-es/families/stellar/js-buildTransaction.d.ts.map +1 -1
- package/lib-es/families/stellar/js-buildTransaction.js +5 -5
- package/lib-es/families/stellar/js-buildTransaction.js.map +1 -1
- package/lib-es/families/stellar/js-getTransactionStatus.d.ts.map +1 -1
- package/lib-es/families/stellar/js-getTransactionStatus.js +3 -1
- package/lib-es/families/stellar/js-getTransactionStatus.js.map +1 -1
- package/lib-es/families/stellar/logic.d.ts.map +1 -1
- package/lib-es/families/stellar/logic.js +6 -7
- package/lib-es/families/stellar/logic.js.map +1 -1
- package/lib-es/families/tron/bridge/js.d.ts.map +1 -1
- package/lib-es/families/tron/bridge/js.js +3 -1
- package/lib-es/families/tron/bridge/js.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts +2 -0
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +8 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/helper.d.ts +2 -0
- package/lib-es/featureFlags/helper.d.ts.map +1 -0
- package/lib-es/featureFlags/helper.js +6 -0
- package/lib-es/featureFlags/helper.js.map +1 -0
- package/lib-es/featureFlags/index.d.ts +1 -0
- package/lib-es/featureFlags/index.d.ts.map +1 -1
- package/lib-es/featureFlags/index.js +1 -0
- package/lib-es/featureFlags/index.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +4 -0
- package/lib-es/generated/bridge/js.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.js +2 -0
- package/lib-es/generated/bridge/js.js.map +1 -1
- package/lib-es/generated/bridge/mock.d.ts +4 -0
- package/lib-es/generated/bridge/mock.d.ts.map +1 -1
- package/lib-es/generated/bridge/mock.js +2 -0
- package/lib-es/generated/bridge/mock.js.map +1 -1
- package/lib-es/generated/deviceTransactionConfig.d.ts +4 -1
- package/lib-es/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/generated/deviceTransactionConfig.js +2 -0
- package/lib-es/generated/deviceTransactionConfig.js.map +1 -1
- package/lib-es/generated/exchange.d.ts +2 -2
- package/lib-es/generated/hw-getAddress.d.ts +1 -0
- package/lib-es/generated/hw-getAddress.d.ts.map +1 -1
- package/lib-es/generated/hw-getAddress.js +2 -0
- package/lib-es/generated/hw-getAddress.js.map +1 -1
- package/lib-es/generated/hw-signMessage.d.ts +3 -0
- package/lib-es/generated/hw-signMessage.d.ts.map +1 -1
- package/lib-es/generated/hw-signMessage.js +2 -0
- package/lib-es/generated/hw-signMessage.js.map +1 -1
- package/lib-es/generated/operation.d.ts +13 -0
- package/lib-es/generated/operation.d.ts.map +1 -0
- package/lib-es/generated/operation.js +5 -0
- package/lib-es/generated/operation.js.map +1 -0
- package/lib-es/generated/specs.d.ts +3 -0
- package/lib-es/generated/specs.d.ts.map +1 -1
- package/lib-es/generated/specs.js +2 -0
- package/lib-es/generated/specs.js.map +1 -1
- package/lib-es/generated/transaction.d.ts +8 -0
- package/lib-es/generated/transaction.d.ts.map +1 -1
- package/lib-es/generated/transaction.js +2 -0
- package/lib-es/generated/transaction.js.map +1 -1
- package/lib-es/generated/types.d.ts +8 -4
- package/lib-es/generated/types.d.ts.map +1 -1
- package/lib-es/hooks/recoverFeatureFlag.d.ts +0 -1
- package/lib-es/hooks/recoverFeatureFlag.d.ts.map +1 -1
- package/lib-es/hooks/recoverFeatureFlag.js +0 -4
- package/lib-es/hooks/recoverFeatureFlag.js.map +1 -1
- package/lib-es/hooks/useBroadcast.d.ts +8 -0
- package/lib-es/hooks/useBroadcast.d.ts.map +1 -0
- package/lib-es/hooks/useBroadcast.js +36 -0
- package/lib-es/hooks/useBroadcast.js.map +1 -0
- package/lib-es/hooks/useEnv.d.ts.map +1 -1
- package/lib-es/hooks/useEnv.js.map +1 -1
- package/lib-es/manager/api.d.ts.map +1 -1
- package/lib-es/manager/api.js +9 -3
- package/lib-es/manager/api.js.map +1 -1
- package/lib-es/operation.d.ts +24 -0
- package/lib-es/operation.d.ts.map +1 -1
- package/lib-es/operation.js +34 -0
- package/lib-es/operation.js.map +1 -1
- package/lib-es/wallet-api/react.js +1 -1
- package/lib-es/wallet-api/react.js.map +1 -1
- package/lib-es/walletConnect/index.d.ts +8 -0
- package/lib-es/walletConnect/index.d.ts.map +1 -0
- package/lib-es/walletConnect/index.js +16 -0
- package/lib-es/walletConnect/index.js.map +1 -0
- package/package.json +40 -36
- package/src/__tests__/test-helpers/environment.ts +2 -0
- package/src/apps/polyfill.ts +1 -1
- package/src/bridge/useBridgeTransaction.ts +1 -1
- package/src/countervalues/api/api.ts +7 -1
- package/src/countervalues/logic.ts +39 -18
- package/src/countervalues/modules/index.ts +12 -4
- package/src/countervalues/react.tsx +7 -1
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +51 -8
- package/src/currencies/mock.ts +520 -0
- package/src/currencies/sortByMarketcap.test.ts +21 -0
- package/src/currencies/sortByMarketcap.ts +22 -12
- package/src/data/icons/react/cspr.tsx +12 -0
- package/src/data/icons/react/index.tsx +2 -0
- package/src/data/icons/react/lyx.tsx +12 -0
- package/src/data/icons/reactNative/cspr.tsx +13 -0
- package/src/data/icons/reactNative/index.tsx +2 -0
- package/src/data/icons/reactNative/lyx.tsx +13 -0
- package/src/data/icons/svg/CSPR.svg +8 -0
- package/src/data/icons/svg/LYX.svg +3 -0
- package/src/deviceSDK/tasks/core.test.ts +16 -1
- package/src/exchange/platform/transfer/completeExchange.ts +23 -14
- package/src/exchange/swap/completeExchange.ts +8 -2
- package/src/exchange/swap/hooks/useSwapTransaction.ts +13 -2
- package/src/exchange/swap/index.ts +2 -2
- package/src/families/algorand/bridge/mock.ts +3 -1
- package/src/families/casper/__snapshots__/bridge.integration.test.ts.snap +238 -0
- package/src/families/casper/api/index.ts +166 -0
- package/src/families/casper/api/types.ts +111 -0
- package/src/families/casper/bridge/account.ts +288 -0
- package/src/families/casper/bridge/bridgeHelpers/accountShape.ts +40 -0
- package/src/families/casper/bridge/bridgeHelpers/addresses.ts +120 -0
- package/src/families/casper/bridge/bridgeHelpers/fee.ts +6 -0
- package/src/families/casper/bridge/bridgeHelpers/transferId.ts +9 -0
- package/src/families/casper/bridge/bridgeHelpers/txn.ts +124 -0
- package/src/families/casper/bridge/currency.ts +11 -0
- package/src/families/casper/bridge/js.ts +7 -0
- package/src/families/casper/bridge/mock.ts +169 -0
- package/src/families/casper/bridge.integration.test.ts +168 -0
- package/src/families/casper/consts.ts +19 -0
- package/src/families/casper/deviceTransactionConfig.ts +44 -0
- package/src/families/casper/errors.ts +5 -0
- package/src/families/casper/hw-getAddress.ts +26 -0
- package/src/families/casper/hw-signMessage.ts +28 -0
- package/src/families/casper/msc-utils.ts +53 -0
- package/src/families/casper/specs.ts +126 -0
- package/src/families/casper/speculos-deviceActions.ts +54 -0
- package/src/families/casper/transaction.ts +61 -0
- package/src/families/casper/types.ts +35 -0
- package/src/families/crypto_org/js-getTransactionStatus.ts +3 -1
- package/src/families/internet_computer/bridge/account.ts +6 -2
- package/src/families/near/js-getTransactionStatus.ts +3 -1
- package/src/families/solana/js-prepareTransaction.ts +12 -4
- package/src/families/stacks/bridge/account.ts +6 -2
- package/src/families/stellar/api/horizon.ts +49 -39
- package/src/families/stellar/js-buildTransaction.ts +9 -11
- package/src/families/stellar/js-getTransactionStatus.ts +3 -1
- package/src/families/stellar/logic.ts +6 -8
- package/src/families/tron/bridge/js.ts +3 -1
- package/src/featureFlags/defaultFeatures.ts +9 -2
- package/src/featureFlags/helper.tsx +9 -0
- package/src/featureFlags/index.ts +1 -0
- package/src/generated/bridge/js.ts +2 -0
- package/src/generated/bridge/mock.ts +2 -0
- package/src/generated/deviceTransactionConfig.ts +4 -0
- package/src/generated/hw-getAddress.ts +2 -0
- package/src/generated/hw-signMessage.ts +2 -0
- package/src/generated/operation.ts +5 -0
- package/src/generated/specs.ts +2 -0
- package/src/generated/transaction.ts +2 -0
- package/src/generated/types.ts +8 -0
- package/src/hooks/recoverFeatureFlag.ts +0 -8
- package/src/hooks/useBroadcast.ts +41 -0
- package/src/hooks/useEnv.ts +1 -0
- package/src/manager/api.ts +8 -3
- package/src/operation.ts +67 -0
- package/src/wallet-api/react.ts +1 -1
- package/src/walletConnect/index.ts +20 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export interface NodeRPCPayload {
|
|
2
|
+
jsonrpc: "2.0";
|
|
3
|
+
method:
|
|
4
|
+
| "info_get_status"
|
|
5
|
+
| "chain_get_state_root_hash"
|
|
6
|
+
| "state_get_account_info"
|
|
7
|
+
| "state_get_balance"
|
|
8
|
+
| "account_put_deploy";
|
|
9
|
+
params: any;
|
|
10
|
+
id: 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IndexerResponseRoot<T> {
|
|
14
|
+
data: T[];
|
|
15
|
+
pageCount: number;
|
|
16
|
+
itemCount: number;
|
|
17
|
+
pages: { number: number; url: string }[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ITxnHistoryData {
|
|
21
|
+
deploy_hash: string;
|
|
22
|
+
block_hash: string;
|
|
23
|
+
caller_public_key: string;
|
|
24
|
+
execution_type_id: number;
|
|
25
|
+
contract_hash?: any;
|
|
26
|
+
contract_package_hash?: any;
|
|
27
|
+
cost: string;
|
|
28
|
+
payment_amount: string;
|
|
29
|
+
error_message?: string;
|
|
30
|
+
timestamp: string;
|
|
31
|
+
status: string;
|
|
32
|
+
args: {
|
|
33
|
+
id: {
|
|
34
|
+
parsed?: number;
|
|
35
|
+
cl_type: {
|
|
36
|
+
Option: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
amount: {
|
|
40
|
+
parsed: string;
|
|
41
|
+
cl_type: string;
|
|
42
|
+
};
|
|
43
|
+
target: {
|
|
44
|
+
parsed: string;
|
|
45
|
+
cl_type: {
|
|
46
|
+
ByteArray: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
amount: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface NodeResponseRoot<T> {
|
|
54
|
+
jsonrpc: string;
|
|
55
|
+
id: string;
|
|
56
|
+
result: T;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface NNetworkStatusResponse {
|
|
60
|
+
api_version: string;
|
|
61
|
+
chainspec_name: string;
|
|
62
|
+
starting_state_root_hash: string;
|
|
63
|
+
peers: { node_id: string; address: string }[];
|
|
64
|
+
last_added_block_info: {
|
|
65
|
+
hash: string;
|
|
66
|
+
timestamp: string;
|
|
67
|
+
era_id: number;
|
|
68
|
+
height: number;
|
|
69
|
+
state_root_hash: string;
|
|
70
|
+
creator: string;
|
|
71
|
+
};
|
|
72
|
+
our_public_signing_key: string;
|
|
73
|
+
round_length?: any;
|
|
74
|
+
next_upgrade?: any;
|
|
75
|
+
build_version: string;
|
|
76
|
+
uptime: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface NStateRootHashResponse {
|
|
80
|
+
api_version: string;
|
|
81
|
+
state_root_hash: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface NAccountBalance {
|
|
85
|
+
api_version: string;
|
|
86
|
+
balance_value: string;
|
|
87
|
+
merkle_proof: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface NAccountInfo {
|
|
91
|
+
api_version: string;
|
|
92
|
+
account: {
|
|
93
|
+
account_hash: string;
|
|
94
|
+
named_keys: any[];
|
|
95
|
+
main_purse: string;
|
|
96
|
+
associated_keys: {
|
|
97
|
+
account_hash: string;
|
|
98
|
+
weight: number;
|
|
99
|
+
}[];
|
|
100
|
+
action_thresholds: {
|
|
101
|
+
deployment: number;
|
|
102
|
+
key_management: number;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
merkle_proof: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface NDeployMessagePutResponse {
|
|
109
|
+
api_version: string;
|
|
110
|
+
deploy_hash: string;
|
|
111
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
AccountBridge,
|
|
4
|
+
SignOperationEvent,
|
|
5
|
+
BroadcastFnSignature,
|
|
6
|
+
SignOperationFnSignature,
|
|
7
|
+
AccountLike,
|
|
8
|
+
} from "@ledgerhq/types-live";
|
|
9
|
+
import type { CasperOperation, Transaction, TransactionStatus } from "../types";
|
|
10
|
+
import { makeAccountBridgeReceive, makeSync } from "../../../bridge/jsHelpers";
|
|
11
|
+
|
|
12
|
+
import { getPath, isError } from "../msc-utils";
|
|
13
|
+
import { CLPublicKey, DeployUtil } from "casper-js-sdk";
|
|
14
|
+
import BigNumber from "bignumber.js";
|
|
15
|
+
import {
|
|
16
|
+
CASPER_MINIMUM_VALID_AMOUNT_MOTES,
|
|
17
|
+
CASPER_MAX_TRANSFER_ID,
|
|
18
|
+
MayBlockAccountError,
|
|
19
|
+
InvalidMinimumAmountError,
|
|
20
|
+
} from "../consts";
|
|
21
|
+
import {
|
|
22
|
+
getAddress,
|
|
23
|
+
getPubKeySignature,
|
|
24
|
+
getPublicKeyFromCasperAddress,
|
|
25
|
+
isAddressValid,
|
|
26
|
+
} from "./bridgeHelpers/addresses";
|
|
27
|
+
import { log } from "@ledgerhq/logs";
|
|
28
|
+
import { Observable } from "rxjs";
|
|
29
|
+
import { withDevice } from "../../../hw/deviceAccess";
|
|
30
|
+
import { encodeOperationId, patchOperationWithHash } from "../../../operation";
|
|
31
|
+
import CasperApp from "@zondax/ledger-casper";
|
|
32
|
+
import {
|
|
33
|
+
AmountRequired,
|
|
34
|
+
InvalidAddress,
|
|
35
|
+
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
36
|
+
NotEnoughBalance,
|
|
37
|
+
RecipientRequired,
|
|
38
|
+
} from "@ledgerhq/errors";
|
|
39
|
+
import { CasperInvalidTransferId } from "../errors";
|
|
40
|
+
import { broadcastTx } from "../api";
|
|
41
|
+
import { getMainAccount } from "../../../account/helpers";
|
|
42
|
+
import { createNewDeploy, deployHashToString } from "./bridgeHelpers/txn";
|
|
43
|
+
import { getAccountShape } from "./bridgeHelpers/accountShape";
|
|
44
|
+
import { getEstimatedFees } from "./bridgeHelpers/fee";
|
|
45
|
+
import { isTransferIdValid } from "./bridgeHelpers/transferId";
|
|
46
|
+
import { defaultUpdateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
47
|
+
|
|
48
|
+
const receive = makeAccountBridgeReceive();
|
|
49
|
+
|
|
50
|
+
const createTransaction = (): Transaction => {
|
|
51
|
+
// log("debug", "[createTransaction] creating base tx");
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
family: "casper",
|
|
55
|
+
amount: new BigNumber(0),
|
|
56
|
+
fees: new BigNumber(0),
|
|
57
|
+
recipient: "",
|
|
58
|
+
useAllAmount: false,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const prepareTransaction = async (a: Account, t: Transaction): Promise<Transaction> => {
|
|
63
|
+
// log("debug", "[prepareTransaction] start fn");
|
|
64
|
+
const fees = getEstimatedFees();
|
|
65
|
+
|
|
66
|
+
const amount = t.useAllAmount ? a.spendableBalance.minus(t.fees) : t.amount;
|
|
67
|
+
|
|
68
|
+
// log("debug", "[prepareTransaction] finish fn");
|
|
69
|
+
return defaultUpdateTransaction(t, { fees, amount });
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const getTransactionStatus = async (a: Account, t: Transaction): Promise<TransactionStatus> => {
|
|
73
|
+
const errors: TransactionStatus["errors"] = {};
|
|
74
|
+
const warnings: TransactionStatus["warnings"] = {};
|
|
75
|
+
|
|
76
|
+
const { balance, spendableBalance } = a;
|
|
77
|
+
const { address } = getAddress(a);
|
|
78
|
+
const { recipient, useAllAmount } = t;
|
|
79
|
+
let { amount } = t;
|
|
80
|
+
|
|
81
|
+
if (!recipient) {
|
|
82
|
+
errors.recipient = new RecipientRequired();
|
|
83
|
+
} else if (!isAddressValid(recipient)) {
|
|
84
|
+
errors.recipient = new InvalidAddress("", {
|
|
85
|
+
currencyName: a.currency.name,
|
|
86
|
+
});
|
|
87
|
+
} else if (recipient.toLowerCase() === address.toLowerCase()) {
|
|
88
|
+
errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!isAddressValid(address)) {
|
|
92
|
+
errors.sender = new InvalidAddress("", {
|
|
93
|
+
currencyName: a.currency.name,
|
|
94
|
+
});
|
|
95
|
+
} else if (!isTransferIdValid(t.transferId)) {
|
|
96
|
+
errors.sender = new CasperInvalidTransferId("", {
|
|
97
|
+
maxTransferId: CASPER_MAX_TRANSFER_ID,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const estimatedFees = t.fees;
|
|
102
|
+
|
|
103
|
+
let totalSpent = BigNumber(0);
|
|
104
|
+
|
|
105
|
+
if (useAllAmount) {
|
|
106
|
+
totalSpent = a.spendableBalance;
|
|
107
|
+
amount = totalSpent.minus(estimatedFees);
|
|
108
|
+
if (amount.lte(0) || totalSpent.gt(balance)) {
|
|
109
|
+
errors.amount = new NotEnoughBalance();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!useAllAmount) {
|
|
114
|
+
totalSpent = amount.plus(estimatedFees);
|
|
115
|
+
if (amount.eq(0)) {
|
|
116
|
+
errors.amount = new AmountRequired();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (totalSpent.gt(a.spendableBalance)) {
|
|
120
|
+
errors.amount = new NotEnoughBalance();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (amount.lt(CASPER_MINIMUM_VALID_AMOUNT_MOTES) && !errors.amount) {
|
|
125
|
+
errors.amount = InvalidMinimumAmountError;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
spendableBalance.minus(totalSpent).minus(estimatedFees).lt(CASPER_MINIMUM_VALID_AMOUNT_MOTES)
|
|
130
|
+
) {
|
|
131
|
+
warnings.amount = MayBlockAccountError;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// log("debug", "[getTransactionStatus] finish fn");
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
errors,
|
|
138
|
+
warnings,
|
|
139
|
+
estimatedFees,
|
|
140
|
+
amount,
|
|
141
|
+
totalSpent,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const estimateMaxSpendable = async ({
|
|
146
|
+
account,
|
|
147
|
+
parentAccount,
|
|
148
|
+
transaction,
|
|
149
|
+
}: {
|
|
150
|
+
account: AccountLike;
|
|
151
|
+
parentAccount?: Account | null | undefined;
|
|
152
|
+
transaction?: Transaction | null | undefined;
|
|
153
|
+
}): Promise<BigNumber> => {
|
|
154
|
+
const a = getMainAccount(account, parentAccount);
|
|
155
|
+
let balance = a.spendableBalance;
|
|
156
|
+
|
|
157
|
+
if (balance.eq(0)) return balance;
|
|
158
|
+
|
|
159
|
+
const estimatedFees = transaction?.fees ?? getEstimatedFees();
|
|
160
|
+
|
|
161
|
+
if (balance.lte(estimatedFees)) return new BigNumber(0);
|
|
162
|
+
|
|
163
|
+
balance = balance.minus(estimatedFees);
|
|
164
|
+
|
|
165
|
+
// log("debug", "[estimateMaxSpendable] finish fn");
|
|
166
|
+
|
|
167
|
+
return balance;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const signOperation: SignOperationFnSignature<Transaction> = ({
|
|
171
|
+
account,
|
|
172
|
+
deviceId,
|
|
173
|
+
transaction,
|
|
174
|
+
}): Observable<SignOperationEvent> =>
|
|
175
|
+
withDevice(deviceId)(
|
|
176
|
+
transport =>
|
|
177
|
+
new Observable(o => {
|
|
178
|
+
async function main() {
|
|
179
|
+
// log("debug", "[signOperation] start fn");
|
|
180
|
+
|
|
181
|
+
const { recipient, amount } = transaction;
|
|
182
|
+
const { id: accountId } = account;
|
|
183
|
+
const { address, derivationPath } = getAddress(account);
|
|
184
|
+
|
|
185
|
+
const casper = new CasperApp(transport);
|
|
186
|
+
|
|
187
|
+
const fee = transaction.fees;
|
|
188
|
+
|
|
189
|
+
const deploy = createNewDeploy(
|
|
190
|
+
address,
|
|
191
|
+
recipient,
|
|
192
|
+
transaction.amount,
|
|
193
|
+
transaction.fees,
|
|
194
|
+
transaction.transferId,
|
|
195
|
+
);
|
|
196
|
+
// Serialize tx
|
|
197
|
+
const deployBytes = DeployUtil.deployToBytes(deploy);
|
|
198
|
+
|
|
199
|
+
log("debug", `[signOperation] serialized deploy: [${deployBytes.toString()}]`);
|
|
200
|
+
|
|
201
|
+
o.next({
|
|
202
|
+
type: "device-signature-requested",
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Sign by device
|
|
206
|
+
const result = await casper.sign(getPath(derivationPath), Buffer.from(deployBytes));
|
|
207
|
+
isError(result);
|
|
208
|
+
|
|
209
|
+
o.next({
|
|
210
|
+
type: "device-signature-granted",
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// signature verification
|
|
214
|
+
const deployHash = deployHashToString(deploy.hash, true);
|
|
215
|
+
const signature = result.signatureRS;
|
|
216
|
+
|
|
217
|
+
const pkBuffer = Buffer.from(getPublicKeyFromCasperAddress(address), "hex");
|
|
218
|
+
// sign deploy object
|
|
219
|
+
const signedDeploy = DeployUtil.setSignature(
|
|
220
|
+
deploy,
|
|
221
|
+
signature,
|
|
222
|
+
new CLPublicKey(pkBuffer, getPubKeySignature(address)),
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const operation: CasperOperation = {
|
|
226
|
+
id: encodeOperationId(accountId, deployHash, "OUT"),
|
|
227
|
+
hash: deployHash,
|
|
228
|
+
type: "OUT",
|
|
229
|
+
senders: [address],
|
|
230
|
+
recipients: [recipient],
|
|
231
|
+
accountId,
|
|
232
|
+
value: amount.plus(fee),
|
|
233
|
+
fee,
|
|
234
|
+
blockHash: null,
|
|
235
|
+
blockHeight: null,
|
|
236
|
+
date: new Date(),
|
|
237
|
+
extra: {
|
|
238
|
+
transferId: transaction.transferId,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
o.next({
|
|
243
|
+
type: "signed",
|
|
244
|
+
signedOperation: {
|
|
245
|
+
operation,
|
|
246
|
+
signature: JSON.stringify(DeployUtil.deployToJson(signedDeploy)),
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
main().then(
|
|
252
|
+
() => o.complete(),
|
|
253
|
+
e => o.error(e),
|
|
254
|
+
);
|
|
255
|
+
}),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const broadcast: BroadcastFnSignature = async ({ signedOperation: { signature, operation } }) => {
|
|
259
|
+
// log("debug", "[broadcast] start fn");
|
|
260
|
+
|
|
261
|
+
const tx = DeployUtil.deployFromJson(JSON.parse(signature)).unwrap();
|
|
262
|
+
|
|
263
|
+
// log("debug", `[broadcast] isDeployOk ${DeployUtil.validateDeploy(tx).ok}`);
|
|
264
|
+
const resp = await broadcastTx(tx);
|
|
265
|
+
const { deploy_hash } = resp;
|
|
266
|
+
|
|
267
|
+
const result = patchOperationWithHash(operation, deploy_hash);
|
|
268
|
+
|
|
269
|
+
// log("debug", "[broadcast] finish fn");
|
|
270
|
+
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const sync = makeSync({ getAccountShape });
|
|
275
|
+
|
|
276
|
+
const accountBridge: AccountBridge<Transaction> = {
|
|
277
|
+
estimateMaxSpendable,
|
|
278
|
+
createTransaction,
|
|
279
|
+
updateTransaction: defaultUpdateTransaction,
|
|
280
|
+
getTransactionStatus,
|
|
281
|
+
prepareTransaction,
|
|
282
|
+
sync,
|
|
283
|
+
receive,
|
|
284
|
+
signOperation,
|
|
285
|
+
broadcast,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export { accountBridge };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { flatMap } from "lodash";
|
|
2
|
+
import { log } from "@ledgerhq/logs";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
import { encodeAccountId } from "../../../../account";
|
|
5
|
+
|
|
6
|
+
import { GetAccountShape } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
7
|
+
import { fetchBalance, fetchNetworkStatus, fetchTxs, fetchAccountStateInfo } from "../../api/index";
|
|
8
|
+
import { mapTxToOps } from "./txn";
|
|
9
|
+
import { NAccountBalance, ITxnHistoryData } from "../../api/types";
|
|
10
|
+
|
|
11
|
+
export const getAccountShape: GetAccountShape = async info => {
|
|
12
|
+
const { address, currency, derivationMode } = info;
|
|
13
|
+
|
|
14
|
+
const accountId = encodeAccountId({
|
|
15
|
+
type: "js",
|
|
16
|
+
version: "2",
|
|
17
|
+
currencyId: currency.id,
|
|
18
|
+
xpubOrAddress: address,
|
|
19
|
+
derivationMode,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
log("debug", `Generation account shape for ${address}`);
|
|
23
|
+
|
|
24
|
+
const { purseUref, accountHash } = await fetchAccountStateInfo(address);
|
|
25
|
+
|
|
26
|
+
const blockHeight = await fetchNetworkStatus();
|
|
27
|
+
|
|
28
|
+
const balance: NAccountBalance = purseUref
|
|
29
|
+
? await fetchBalance(purseUref)
|
|
30
|
+
: { balance_value: "0", api_version: "", merkle_proof: "" };
|
|
31
|
+
const txs: ITxnHistoryData[] = purseUref ? await fetchTxs(address) : [];
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
id: accountId,
|
|
35
|
+
balance: new BigNumber(balance.balance_value),
|
|
36
|
+
spendableBalance: new BigNumber(balance.balance_value),
|
|
37
|
+
operations: flatMap(txs, mapTxToOps(accountId, accountHash ?? "")),
|
|
38
|
+
blockHeight: blockHeight.last_added_block_info.height,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { CASPER_CHECKSUM_HEX_LEN, CASPER_SMALL_BYTES_COUNT } from "../../consts";
|
|
2
|
+
|
|
3
|
+
import { Account, Address } from "@ledgerhq/types-live";
|
|
4
|
+
import { CLPublicKey, CLPublicKeyTag } from "casper-js-sdk";
|
|
5
|
+
import { blake2bFinal, blake2bInit, blake2bUpdate } from "blakejs";
|
|
6
|
+
import { InvalidAddress } from "@ledgerhq/errors";
|
|
7
|
+
|
|
8
|
+
export const getAddress = (a: Account): Address =>
|
|
9
|
+
a.freshAddresses.length > 0
|
|
10
|
+
? a.freshAddresses[0]
|
|
11
|
+
: { address: a.freshAddress, derivationPath: a.freshAddressPath };
|
|
12
|
+
|
|
13
|
+
export const getPubKeySignature = (pubKey: string): CLPublicKeyTag => {
|
|
14
|
+
const signature = pubKey.substring(0, 2);
|
|
15
|
+
|
|
16
|
+
if (signature === "01") return CLPublicKeyTag.ED25519;
|
|
17
|
+
|
|
18
|
+
if (signature === "02") return CLPublicKeyTag.SECP256K1;
|
|
19
|
+
|
|
20
|
+
throw new Error("casper pubkey signature not know");
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function numberToBin(num: number) {
|
|
24
|
+
let binStr = (num >>> 0).toString(2);
|
|
25
|
+
while (binStr.length < 8) {
|
|
26
|
+
binStr = "0" + binStr;
|
|
27
|
+
}
|
|
28
|
+
return binStr.split("").reverse().join("");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function bytesToBitsString(buf: Buffer | Uint8Array) {
|
|
32
|
+
const bitsArray: string[] = [];
|
|
33
|
+
|
|
34
|
+
for (const num of buf) {
|
|
35
|
+
const bin = numberToBin(num);
|
|
36
|
+
bitsArray.push(bin);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return bitsArray.join("");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the bytes encoded as hexadecimal with mixed-case based checksums following a scheme
|
|
44
|
+
* similar to [EIP-55](https://eips.ethereum.org/EIPS/eip-55).
|
|
45
|
+
*/
|
|
46
|
+
export function casperAddressEncode(inputBytes: Buffer): string {
|
|
47
|
+
const context = blake2bInit(CASPER_CHECKSUM_HEX_LEN);
|
|
48
|
+
blake2bUpdate(context, inputBytes);
|
|
49
|
+
const blakeHash = blake2bFinal(context);
|
|
50
|
+
|
|
51
|
+
const nibbles = inputBytes
|
|
52
|
+
.toString("hex")
|
|
53
|
+
.split("")
|
|
54
|
+
.map(v => parseInt(v, 16));
|
|
55
|
+
|
|
56
|
+
const bitsArray = bytesToBitsString(blakeHash);
|
|
57
|
+
|
|
58
|
+
const res: Array<number | string> = [];
|
|
59
|
+
|
|
60
|
+
let steamIndex = -1;
|
|
61
|
+
for (const num of nibbles) {
|
|
62
|
+
if (num < 10) res.push(num);
|
|
63
|
+
else {
|
|
64
|
+
steamIndex += 1;
|
|
65
|
+
if (parseInt(bitsArray[steamIndex], 10)) res.push(num.toString(16).toUpperCase());
|
|
66
|
+
else res.push(num.toString(16).toLowerCase());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return res.join("");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Decodes a mixed-case hexadecimal string
|
|
74
|
+
// Checksum hex encoding for casper docs: https://docs.casperlabs.io/design/checksummed-hex/
|
|
75
|
+
function casperAddressDecode(inputString: string): string {
|
|
76
|
+
if (Buffer.from(inputString, "hex").length > CASPER_SMALL_BYTES_COUNT) return inputString;
|
|
77
|
+
|
|
78
|
+
if (inputString.toLowerCase() === inputString) return inputString;
|
|
79
|
+
if (inputString.toUpperCase() === inputString) return inputString;
|
|
80
|
+
|
|
81
|
+
const encoded = casperAddressEncode(Buffer.from(inputString, "hex"));
|
|
82
|
+
|
|
83
|
+
for (let i = 0; i < encoded.length; i++) {
|
|
84
|
+
if (encoded.charAt(i) !== inputString.charAt(i))
|
|
85
|
+
throw Error("Checksum invalid, decoding failed.");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return inputString;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function isAddressValid(address: string): boolean {
|
|
92
|
+
try {
|
|
93
|
+
const pubKey = getPublicKeyFromCasperAddress(address);
|
|
94
|
+
new CLPublicKey(Buffer.from(pubKey, "hex"), getPubKeySignature(address));
|
|
95
|
+
casperAddressDecode(pubKey);
|
|
96
|
+
return true;
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function getPublicKeyFromCasperAddress(address: string): string {
|
|
103
|
+
if (address.length !== 68) throw new InvalidAddress("Invalid address size, expected 34 bytes");
|
|
104
|
+
return address.substring(2);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function casperAddressFromPubKey(pubkey: Buffer): string {
|
|
108
|
+
const checksumed = casperAddressEncode(pubkey);
|
|
109
|
+
|
|
110
|
+
return `02${checksumed}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function casperPubKeyToAccountHash(pubKey: string): string {
|
|
114
|
+
const clPubKey = new CLPublicKey(
|
|
115
|
+
Buffer.from(pubKey.substring(2), "hex"),
|
|
116
|
+
getPubKeySignature(pubKey),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return casperAddressEncode(Buffer.from(clPubKey.toAccountRawHashStr(), "hex"));
|
|
120
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { CASPER_MAX_TRANSFER_ID } from "../../consts";
|
|
3
|
+
|
|
4
|
+
export function isTransferIdValid(id?: string): boolean {
|
|
5
|
+
if (!id || !id.length) return true;
|
|
6
|
+
if (/^\d+$/.test(id) && new BigNumber(id).lt(new BigNumber(CASPER_MAX_TRANSFER_ID))) return true;
|
|
7
|
+
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
2
|
+
import { InvalidAddress } from "@ledgerhq/errors";
|
|
3
|
+
import { log } from "@ledgerhq/logs";
|
|
4
|
+
import { Unit } from "@ledgerhq/types-cryptoassets";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
import { CLPublicKey, DeployUtil } from "casper-js-sdk";
|
|
7
|
+
import { encodeOperationId } from "../../../../operation";
|
|
8
|
+
import { CASPER_NETWORK } from "../../consts";
|
|
9
|
+
import {
|
|
10
|
+
casperAddressEncode,
|
|
11
|
+
casperPubKeyToAccountHash,
|
|
12
|
+
getPubKeySignature,
|
|
13
|
+
getPublicKeyFromCasperAddress,
|
|
14
|
+
isAddressValid,
|
|
15
|
+
} from "./addresses";
|
|
16
|
+
import { ITxnHistoryData } from "../../api/types";
|
|
17
|
+
import { getEstimatedFees } from "./fee";
|
|
18
|
+
import { CasperOperation } from "../../types";
|
|
19
|
+
|
|
20
|
+
export const getUnit = (): Unit => getCryptoCurrencyById("casper").units[0];
|
|
21
|
+
|
|
22
|
+
export function mapTxToOps(
|
|
23
|
+
accountId: string,
|
|
24
|
+
addressHash: string,
|
|
25
|
+
fees = getEstimatedFees(),
|
|
26
|
+
): (tx: ITxnHistoryData) => CasperOperation[] {
|
|
27
|
+
return (tx: ITxnHistoryData): CasperOperation[] => {
|
|
28
|
+
const ops: CasperOperation[] = [];
|
|
29
|
+
const { timestamp, caller_public_key, args: txArgs, deploy_hash, error_message } = tx;
|
|
30
|
+
const fromAccount = casperPubKeyToAccountHash(caller_public_key);
|
|
31
|
+
const toAccount = txArgs.target.parsed;
|
|
32
|
+
|
|
33
|
+
const date = new Date(timestamp);
|
|
34
|
+
const value = new BigNumber(txArgs.amount.parsed);
|
|
35
|
+
const feeToUse = fees;
|
|
36
|
+
|
|
37
|
+
const isSending = addressHash.toLowerCase() === fromAccount.toLowerCase();
|
|
38
|
+
const isReceiving = addressHash.toLowerCase() === toAccount.toLowerCase();
|
|
39
|
+
|
|
40
|
+
if (isSending) {
|
|
41
|
+
ops.push({
|
|
42
|
+
id: encodeOperationId(accountId, deploy_hash, "OUT"),
|
|
43
|
+
hash: deploy_hash,
|
|
44
|
+
type: "OUT",
|
|
45
|
+
value: value.plus(feeToUse),
|
|
46
|
+
fee: feeToUse,
|
|
47
|
+
blockHeight: 1,
|
|
48
|
+
hasFailed: error_message ? true : false,
|
|
49
|
+
blockHash: null,
|
|
50
|
+
accountId,
|
|
51
|
+
senders: [fromAccount],
|
|
52
|
+
recipients: [toAccount],
|
|
53
|
+
date,
|
|
54
|
+
extra: {
|
|
55
|
+
transferId: txArgs.id.parsed?.toString(),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (isReceiving) {
|
|
61
|
+
ops.push({
|
|
62
|
+
id: encodeOperationId(accountId, deploy_hash, "IN"),
|
|
63
|
+
hash: deploy_hash,
|
|
64
|
+
type: "IN",
|
|
65
|
+
value,
|
|
66
|
+
fee: feeToUse,
|
|
67
|
+
blockHeight: 1,
|
|
68
|
+
blockHash: null,
|
|
69
|
+
hasFailed: error_message ? true : false,
|
|
70
|
+
accountId,
|
|
71
|
+
senders: [fromAccount],
|
|
72
|
+
recipients: [toAccount],
|
|
73
|
+
date,
|
|
74
|
+
extra: {
|
|
75
|
+
transferId: txArgs.id.parsed?.toString(),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return ops;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const createNewDeploy = (
|
|
85
|
+
sender: string,
|
|
86
|
+
recipient: string,
|
|
87
|
+
amount: BigNumber,
|
|
88
|
+
fees: BigNumber,
|
|
89
|
+
transferId?: string,
|
|
90
|
+
network = CASPER_NETWORK,
|
|
91
|
+
): DeployUtil.Deploy => {
|
|
92
|
+
log("debug", `Creating new Deploy: ${sender}, ${recipient}, ${network}`);
|
|
93
|
+
|
|
94
|
+
if (recipient && !isAddressValid(recipient)) {
|
|
95
|
+
throw InvalidAddress(`Invalid recipient Address ${recipient}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const deployParams = new DeployUtil.DeployParams(
|
|
99
|
+
new CLPublicKey(Buffer.from(getPublicKeyFromCasperAddress(sender), "hex"), 2),
|
|
100
|
+
network,
|
|
101
|
+
);
|
|
102
|
+
const recipientBuff = Buffer.from(getPublicKeyFromCasperAddress(recipient), "hex");
|
|
103
|
+
|
|
104
|
+
const session = DeployUtil.ExecutableDeployItem.newTransferWithOptionalTransferId(
|
|
105
|
+
amount?.toNumber() ?? 0,
|
|
106
|
+
new CLPublicKey(recipientBuff, getPubKeySignature(recipient ?? sender)),
|
|
107
|
+
undefined,
|
|
108
|
+
transferId,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const payment = DeployUtil.standardPayment(fees.toString());
|
|
112
|
+
const deploy = DeployUtil.makeDeploy(deployParams, session, payment);
|
|
113
|
+
const txnRaw = DeployUtil.deployToJson(deploy);
|
|
114
|
+
const txnFromRaw = DeployUtil.deployFromJson(txnRaw).unwrap();
|
|
115
|
+
|
|
116
|
+
return txnFromRaw;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export function deployHashToString(hash: Uint8Array, toLowerCase?: boolean): string {
|
|
120
|
+
const str = casperAddressEncode(Buffer.from(hash));
|
|
121
|
+
|
|
122
|
+
if (toLowerCase) return str.toLowerCase();
|
|
123
|
+
return str;
|
|
124
|
+
}
|