@ledgerhq/coin-framework 0.0.2-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/account/accountId.d.ts +16 -0
- package/lib/account/accountId.d.ts.map +1 -0
- package/lib/account/accountId.js +85 -0
- package/lib/account/accountId.js.map +1 -0
- package/lib/account/accountName.d.ts +14 -0
- package/lib/account/accountName.d.ts.map +1 -0
- package/lib/account/accountName.js +17 -0
- package/lib/account/accountName.js.map +1 -0
- package/lib/account/addAccounts.d.ts +35 -0
- package/lib/account/addAccounts.d.ts.map +1 -0
- package/lib/account/addAccounts.js +209 -0
- package/lib/account/addAccounts.js.map +1 -0
- package/lib/account/balanceHistoryCache.d.ts +25 -0
- package/lib/account/balanceHistoryCache.d.ts.map +1 -0
- package/lib/account/balanceHistoryCache.js +115 -0
- package/lib/account/balanceHistoryCache.js.map +1 -0
- package/lib/account/groupOperations.d.ts +17 -0
- package/lib/account/groupOperations.d.ts.map +1 -0
- package/lib/account/groupOperations.js +127 -0
- package/lib/account/groupOperations.js.map +1 -0
- package/lib/account/helpers.d.ts +44 -0
- package/lib/account/helpers.d.ts.map +1 -0
- package/lib/account/helpers.js +333 -0
- package/lib/account/helpers.js.map +1 -0
- package/lib/account/helpers.test.d.ts +2 -0
- package/lib/account/helpers.test.d.ts.map +1 -0
- package/lib/account/helpers.test.js +366 -0
- package/lib/account/helpers.test.js.map +1 -0
- package/lib/account/index.d.ts +11 -0
- package/lib/account/index.d.ts.map +1 -0
- package/lib/account/index.js +27 -0
- package/lib/account/index.js.map +1 -0
- package/lib/account/ordering.d.ts +10 -0
- package/lib/account/ordering.d.ts.map +1 -0
- package/lib/account/ordering.js +110 -0
- package/lib/account/ordering.js.map +1 -0
- package/lib/account/pending.d.ts +33 -0
- package/lib/account/pending.d.ts.map +1 -0
- package/lib/account/pending.js +64 -0
- package/lib/account/pending.js.map +1 -0
- package/lib/account/serialization.d.ts +6 -0
- package/lib/account/serialization.d.ts.map +1 -0
- package/lib/account/serialization.js +118 -0
- package/lib/account/serialization.js.map +1 -0
- package/lib/account/support.d.ts +9 -0
- package/lib/account/support.d.ts.map +1 -0
- package/lib/account/support.js +72 -0
- package/lib/account/support.js.map +1 -0
- package/lib/account.test.d.ts +2 -0
- package/lib/account.test.d.ts.map +1 -0
- package/lib/account.test.js +257 -0
- package/lib/account.test.js.map +1 -0
- 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/formatters.d.ts +2 -0
- package/lib/bot/formatters.d.ts.map +1 -0
- package/lib/bot/formatters.js +31 -0
- package/lib/bot/formatters.js.map +1 -0
- package/lib/bot/specs.d.ts +50 -0
- package/lib/bot/specs.d.ts.map +1 -0
- package/lib/bot/specs.js +204 -0
- package/lib/bot/specs.js.map +1 -0
- package/lib/bot/types.d.ts +178 -0
- package/lib/bot/types.d.ts.map +1 -0
- package/lib/bot/types.js +3 -0
- package/lib/bot/types.js.map +1 -0
- package/lib/bridge/getAddressWrapper.d.ts +6 -0
- package/lib/bridge/getAddressWrapper.d.ts.map +1 -0
- package/lib/bridge/getAddressWrapper.js +27 -0
- package/lib/bridge/getAddressWrapper.js.map +1 -0
- package/lib/bridge/jsHelpers.d.ts +63 -0
- package/lib/bridge/jsHelpers.d.ts.map +1 -0
- package/lib/bridge/jsHelpers.js +574 -0
- package/lib/bridge/jsHelpers.js.map +1 -0
- package/lib/cache.d.ts +10 -0
- package/lib/cache.d.ts.map +1 -0
- package/lib/cache.js +100 -0
- package/lib/cache.js.map +1 -0
- package/lib/cross.d.ts +42 -0
- package/lib/cross.d.ts.map +1 -0
- package/lib/cross.js +254 -0
- package/lib/cross.js.map +1 -0
- package/lib/cross.test.d.ts +2 -0
- package/lib/cross.test.d.ts.map +1 -0
- package/lib/cross.test.js +99 -0
- package/lib/cross.test.js.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.d.ts +8 -0
- package/lib/currencies/BigNumberToLocaleString.d.ts.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.js +65 -0
- package/lib/currencies/BigNumberToLocaleString.js.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.test.d.ts +2 -0
- package/lib/currencies/BigNumberToLocaleString.test.d.ts.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.test.js +108 -0
- package/lib/currencies/BigNumberToLocaleString.test.js.map +1 -0
- package/lib/currencies/CurrencyURIScheme.d.ts +13 -0
- package/lib/currencies/CurrencyURIScheme.d.ts.map +1 -0
- package/lib/currencies/CurrencyURIScheme.js +124 -0
- package/lib/currencies/CurrencyURIScheme.js.map +1 -0
- package/lib/currencies/chopCurrencyUnitDecimals.d.ts +3 -0
- package/lib/currencies/chopCurrencyUnitDecimals.d.ts.map +1 -0
- package/lib/currencies/chopCurrencyUnitDecimals.js +29 -0
- package/lib/currencies/chopCurrencyUnitDecimals.js.map +1 -0
- package/lib/currencies/formatCurrencyUnit.d.ts +33 -0
- package/lib/currencies/formatCurrencyUnit.d.ts.map +1 -0
- package/lib/currencies/formatCurrencyUnit.js +126 -0
- package/lib/currencies/formatCurrencyUnit.js.map +1 -0
- package/lib/currencies/formatShort.d.ts +8 -0
- package/lib/currencies/formatShort.d.ts.map +1 -0
- package/lib/currencies/formatShort.js +27 -0
- package/lib/currencies/formatShort.js.map +1 -0
- package/lib/currencies/index.d.ts +13 -0
- package/lib/currencies/index.d.ts.map +1 -0
- package/lib/currencies/index.js +65 -0
- package/lib/currencies/index.js.map +1 -0
- package/lib/currencies/localeUtility.d.ts +8 -0
- package/lib/currencies/localeUtility.d.ts.map +1 -0
- package/lib/currencies/localeUtility.js +49 -0
- package/lib/currencies/localeUtility.js.map +1 -0
- package/lib/currencies/parseCurrencyUnit.d.ts +4 -0
- package/lib/currencies/parseCurrencyUnit.d.ts.map +1 -0
- package/lib/currencies/parseCurrencyUnit.js +18 -0
- package/lib/currencies/parseCurrencyUnit.js.map +1 -0
- package/lib/currencies/sanitizeValueString.d.ts +6 -0
- package/lib/currencies/sanitizeValueString.d.ts.map +1 -0
- package/lib/currencies/sanitizeValueString.js +56 -0
- package/lib/currencies/sanitizeValueString.js.map +1 -0
- package/lib/currencies/support.d.ts +8 -0
- package/lib/currencies/support.d.ts.map +1 -0
- package/lib/currencies/support.js +101 -0
- package/lib/currencies/support.js.map +1 -0
- package/lib/currencies/valueFromUnit.d.ts +9 -0
- package/lib/currencies/valueFromUnit.d.ts.map +1 -0
- package/lib/currencies/valueFromUnit.js +14 -0
- package/lib/currencies/valueFromUnit.js.map +1 -0
- package/lib/derivation.d.ts +232 -0
- package/lib/derivation.d.ts.map +1 -0
- package/lib/derivation.js +501 -0
- package/lib/derivation.js.map +1 -0
- package/lib/env.d.ts +30 -0
- package/lib/env.d.ts.map +1 -0
- package/lib/env.js +783 -0
- package/lib/env.js.map +1 -0
- package/lib/errors.d.ts +7 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +7 -0
- package/lib/errors.js.map +1 -0
- package/lib/errors.test.d.ts +2 -0
- package/lib/errors.test.d.ts.map +1 -0
- package/lib/errors.test.js +20 -0
- package/lib/errors.test.js.map +1 -0
- package/lib/mocks/account.d.ts +25 -0
- package/lib/mocks/account.d.ts.map +1 -0
- package/lib/mocks/account.js +368 -0
- package/lib/mocks/account.js.map +1 -0
- package/lib/mocks/fixtures/nfts.d.ts +27 -0
- package/lib/mocks/fixtures/nfts.d.ts.map +1 -0
- package/lib/mocks/fixtures/nfts.js +398 -0
- package/lib/mocks/fixtures/nfts.js.map +1 -0
- package/lib/mocks/fixtures/nfts.test.d.ts +2 -0
- package/lib/mocks/fixtures/nfts.test.d.ts.map +1 -0
- package/lib/mocks/fixtures/nfts.test.js +20 -0
- package/lib/mocks/fixtures/nfts.test.js.map +1 -0
- package/lib/mocks/helpers.d.ts +15 -0
- package/lib/mocks/helpers.d.ts.map +1 -0
- package/lib/mocks/helpers.js +32 -0
- package/lib/mocks/helpers.js.map +1 -0
- package/lib/network.d.ts +5 -0
- package/lib/network.d.ts.map +1 -0
- package/lib/network.js +125 -0
- package/lib/network.js.map +1 -0
- package/lib/nft/nftId.d.ts +8 -0
- package/lib/nft/nftId.d.ts.map +1 -0
- package/lib/nft/nftId.js +34 -0
- package/lib/nft/nftId.js.map +1 -0
- package/lib/operation.d.ts +24 -0
- package/lib/operation.d.ts.map +1 -0
- package/lib/operation.js +183 -0
- package/lib/operation.js.map +1 -0
- package/lib/promise.d.ts +21 -0
- package/lib/promise.d.ts.map +1 -0
- package/lib/promise.js +187 -0
- package/lib/promise.js.map +1 -0
- package/lib/promise.test.d.ts +2 -0
- package/lib/promise.test.d.ts.map +1 -0
- package/lib/promise.test.js +72 -0
- package/lib/promise.test.js.map +1 -0
- package/lib/rangeDates.d.ts +29 -0
- package/lib/rangeDates.d.ts.map +1 -0
- package/lib/rangeDates.js +94 -0
- package/lib/rangeDates.js.map +1 -0
- package/lib/rangeDates.test.d.ts +2 -0
- package/lib/rangeDates.test.d.ts.map +1 -0
- package/lib/rangeDates.test.js +51 -0
- package/lib/rangeDates.test.js.map +1 -0
- package/lib/test-helpers/staticTime.d.ts +2 -0
- package/lib/test-helpers/staticTime.d.ts.map +1 -0
- package/lib/test-helpers/staticTime.js +10 -0
- package/lib/test-helpers/staticTime.js.map +1 -0
- package/lib/transaction/common.d.ts +26 -0
- package/lib/transaction/common.d.ts.map +1 -0
- package/lib/transaction/common.js +123 -0
- package/lib/transaction/common.js.map +1 -0
- package/lib-es/account/accountId.d.ts +16 -0
- package/lib-es/account/accountId.d.ts.map +1 -0
- package/lib-es/account/accountId.js +74 -0
- package/lib-es/account/accountId.js.map +1 -0
- package/lib-es/account/accountName.d.ts +14 -0
- package/lib-es/account/accountName.d.ts.map +1 -0
- package/lib-es/account/accountName.js +12 -0
- package/lib-es/account/accountName.js.map +1 -0
- package/lib-es/account/addAccounts.d.ts +35 -0
- package/lib-es/account/addAccounts.d.ts.map +1 -0
- package/lib-es/account/addAccounts.js +200 -0
- package/lib-es/account/addAccounts.js.map +1 -0
- package/lib-es/account/balanceHistoryCache.d.ts +25 -0
- package/lib-es/account/balanceHistoryCache.d.ts.map +1 -0
- package/lib-es/account/balanceHistoryCache.js +109 -0
- package/lib-es/account/balanceHistoryCache.js.map +1 -0
- package/lib-es/account/groupOperations.d.ts +17 -0
- package/lib-es/account/groupOperations.d.ts.map +1 -0
- package/lib-es/account/groupOperations.js +122 -0
- package/lib-es/account/groupOperations.js.map +1 -0
- package/lib-es/account/helpers.d.ts +44 -0
- package/lib-es/account/helpers.d.ts.map +1 -0
- package/lib-es/account/helpers.js +303 -0
- package/lib-es/account/helpers.js.map +1 -0
- package/lib-es/account/helpers.test.d.ts +2 -0
- package/lib-es/account/helpers.test.d.ts.map +1 -0
- package/lib-es/account/helpers.test.js +361 -0
- package/lib-es/account/helpers.test.js.map +1 -0
- package/lib-es/account/index.d.ts +11 -0
- package/lib-es/account/index.d.ts.map +1 -0
- package/lib-es/account/index.js +11 -0
- package/lib-es/account/index.js.map +1 -0
- package/lib-es/account/ordering.d.ts +10 -0
- package/lib-es/account/ordering.d.ts.map +1 -0
- package/lib-es/account/ordering.js +103 -0
- package/lib-es/account/ordering.js.map +1 -0
- package/lib-es/account/pending.d.ts +33 -0
- package/lib-es/account/pending.d.ts.map +1 -0
- package/lib-es/account/pending.js +59 -0
- package/lib-es/account/pending.js.map +1 -0
- package/lib-es/account/serialization.d.ts +6 -0
- package/lib-es/account/serialization.d.ts.map +1 -0
- package/lib-es/account/serialization.js +112 -0
- package/lib-es/account/serialization.js.map +1 -0
- package/lib-es/account/support.d.ts +9 -0
- package/lib-es/account/support.d.ts.map +1 -0
- package/lib-es/account/support.js +64 -0
- package/lib-es/account/support.js.map +1 -0
- package/lib-es/account.test.d.ts +2 -0
- package/lib-es/account.test.d.ts.map +1 -0
- package/lib-es/account.test.js +252 -0
- package/lib-es/account.test.js.map +1 -0
- package/lib-es/bot/bot-test-context.d.ts +3 -0
- package/lib-es/bot/bot-test-context.d.ts.map +1 -0
- package/lib-es/bot/bot-test-context.js +21 -0
- package/lib-es/bot/bot-test-context.js.map +1 -0
- package/lib-es/bot/bot-test-context.test.d.ts +2 -0
- package/lib-es/bot/bot-test-context.test.d.ts.map +1 -0
- package/lib-es/bot/bot-test-context.test.js +39 -0
- package/lib-es/bot/bot-test-context.test.js.map +1 -0
- package/lib-es/bot/formatters.d.ts +2 -0
- package/lib-es/bot/formatters.d.ts.map +1 -0
- package/lib-es/bot/formatters.js +27 -0
- package/lib-es/bot/formatters.js.map +1 -0
- package/lib-es/bot/specs.d.ts +50 -0
- package/lib-es/bot/specs.d.ts.map +1 -0
- package/lib-es/bot/specs.js +193 -0
- package/lib-es/bot/specs.js.map +1 -0
- package/lib-es/bot/types.d.ts +178 -0
- package/lib-es/bot/types.d.ts.map +1 -0
- package/lib-es/bot/types.js +2 -0
- package/lib-es/bot/types.js.map +1 -0
- package/lib-es/bridge/getAddressWrapper.d.ts +6 -0
- package/lib-es/bridge/getAddressWrapper.d.ts.map +1 -0
- package/lib-es/bridge/getAddressWrapper.js +25 -0
- package/lib-es/bridge/getAddressWrapper.js.map +1 -0
- package/lib-es/bridge/jsHelpers.d.ts +63 -0
- package/lib-es/bridge/jsHelpers.d.ts.map +1 -0
- package/lib-es/bridge/jsHelpers.js +562 -0
- package/lib-es/bridge/jsHelpers.js.map +1 -0
- package/lib-es/cache.d.ts +10 -0
- package/lib-es/cache.d.ts.map +1 -0
- package/lib-es/cache.js +93 -0
- package/lib-es/cache.js.map +1 -0
- package/lib-es/cross.d.ts +42 -0
- package/lib-es/cross.d.ts.map +1 -0
- package/lib-es/cross.js +244 -0
- package/lib-es/cross.js.map +1 -0
- package/lib-es/cross.test.d.ts +2 -0
- package/lib-es/cross.test.d.ts.map +1 -0
- package/lib-es/cross.test.js +97 -0
- package/lib-es/cross.test.js.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.d.ts +8 -0
- package/lib-es/currencies/BigNumberToLocaleString.d.ts.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.js +61 -0
- package/lib-es/currencies/BigNumberToLocaleString.js.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.d.ts +2 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.d.ts.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.js +106 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.js.map +1 -0
- package/lib-es/currencies/CurrencyURIScheme.d.ts +13 -0
- package/lib-es/currencies/CurrencyURIScheme.d.ts.map +1 -0
- package/lib-es/currencies/CurrencyURIScheme.js +116 -0
- package/lib-es/currencies/CurrencyURIScheme.js.map +1 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.d.ts +3 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.d.ts.map +1 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.js +25 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.js.map +1 -0
- package/lib-es/currencies/formatCurrencyUnit.d.ts +33 -0
- package/lib-es/currencies/formatCurrencyUnit.d.ts.map +1 -0
- package/lib-es/currencies/formatCurrencyUnit.js +121 -0
- package/lib-es/currencies/formatCurrencyUnit.js.map +1 -0
- package/lib-es/currencies/formatShort.d.ts +8 -0
- package/lib-es/currencies/formatShort.d.ts.map +1 -0
- package/lib-es/currencies/formatShort.js +20 -0
- package/lib-es/currencies/formatShort.js.map +1 -0
- package/lib-es/currencies/index.d.ts +13 -0
- package/lib-es/currencies/index.d.ts.map +1 -0
- package/lib-es/currencies/index.js +16 -0
- package/lib-es/currencies/index.js.map +1 -0
- package/lib-es/currencies/localeUtility.d.ts +8 -0
- package/lib-es/currencies/localeUtility.d.ts.map +1 -0
- package/lib-es/currencies/localeUtility.js +43 -0
- package/lib-es/currencies/localeUtility.js.map +1 -0
- package/lib-es/currencies/parseCurrencyUnit.d.ts +4 -0
- package/lib-es/currencies/parseCurrencyUnit.d.ts.map +1 -0
- package/lib-es/currencies/parseCurrencyUnit.js +14 -0
- package/lib-es/currencies/parseCurrencyUnit.js.map +1 -0
- package/lib-es/currencies/sanitizeValueString.d.ts +6 -0
- package/lib-es/currencies/sanitizeValueString.d.ts.map +1 -0
- package/lib-es/currencies/sanitizeValueString.js +52 -0
- package/lib-es/currencies/sanitizeValueString.js.map +1 -0
- package/lib-es/currencies/support.d.ts +8 -0
- package/lib-es/currencies/support.d.ts.map +1 -0
- package/lib-es/currencies/support.js +92 -0
- package/lib-es/currencies/support.js.map +1 -0
- package/lib-es/currencies/valueFromUnit.d.ts +9 -0
- package/lib-es/currencies/valueFromUnit.d.ts.map +1 -0
- package/lib-es/currencies/valueFromUnit.js +10 -0
- package/lib-es/currencies/valueFromUnit.js.map +1 -0
- package/lib-es/derivation.d.ts +232 -0
- package/lib-es/derivation.d.ts.map +1 -0
- package/lib-es/derivation.js +473 -0
- package/lib-es/derivation.js.map +1 -0
- package/lib-es/env.d.ts +30 -0
- package/lib-es/env.d.ts.map +1 -0
- package/lib-es/env.js +768 -0
- package/lib-es/env.js.map +1 -0
- package/lib-es/errors.d.ts +7 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +4 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/errors.test.d.ts +2 -0
- package/lib-es/errors.test.d.ts.map +1 -0
- package/lib-es/errors.test.js +18 -0
- package/lib-es/errors.test.js.map +1 -0
- package/lib-es/mocks/account.d.ts +25 -0
- package/lib-es/mocks/account.d.ts.map +1 -0
- package/lib-es/mocks/account.js +358 -0
- package/lib-es/mocks/account.js.map +1 -0
- package/lib-es/mocks/fixtures/nfts.d.ts +27 -0
- package/lib-es/mocks/fixtures/nfts.d.ts.map +1 -0
- package/lib-es/mocks/fixtures/nfts.js +390 -0
- package/lib-es/mocks/fixtures/nfts.js.map +1 -0
- package/lib-es/mocks/fixtures/nfts.test.d.ts +2 -0
- package/lib-es/mocks/fixtures/nfts.test.d.ts.map +1 -0
- package/lib-es/mocks/fixtures/nfts.test.js +18 -0
- package/lib-es/mocks/fixtures/nfts.test.js.map +1 -0
- package/lib-es/mocks/helpers.d.ts +15 -0
- package/lib-es/mocks/helpers.d.ts.map +1 -0
- package/lib-es/mocks/helpers.js +26 -0
- package/lib-es/mocks/helpers.js.map +1 -0
- package/lib-es/network.d.ts +5 -0
- package/lib-es/network.d.ts.map +1 -0
- package/lib-es/network.js +118 -0
- package/lib-es/network.js.map +1 -0
- package/lib-es/nft/nftId.d.ts +8 -0
- package/lib-es/nft/nftId.d.ts.map +1 -0
- package/lib-es/nft/nftId.js +29 -0
- package/lib-es/nft/nftId.js.map +1 -0
- package/lib-es/operation.d.ts +24 -0
- package/lib-es/operation.d.ts.map +1 -0
- package/lib-es/operation.js +168 -0
- package/lib-es/operation.js.map +1 -0
- package/lib-es/promise.d.ts +21 -0
- package/lib-es/promise.d.ts.map +1 -0
- package/lib-es/promise.js +179 -0
- package/lib-es/promise.js.map +1 -0
- package/lib-es/promise.test.d.ts +2 -0
- package/lib-es/promise.test.d.ts.map +1 -0
- package/lib-es/promise.test.js +70 -0
- package/lib-es/promise.test.js.map +1 -0
- package/lib-es/rangeDates.d.ts +29 -0
- package/lib-es/rangeDates.d.ts.map +1 -0
- package/lib-es/rangeDates.js +84 -0
- package/lib-es/rangeDates.js.map +1 -0
- package/lib-es/rangeDates.test.d.ts +2 -0
- package/lib-es/rangeDates.test.d.ts.map +1 -0
- package/lib-es/rangeDates.test.js +49 -0
- package/lib-es/rangeDates.test.js.map +1 -0
- package/lib-es/test-helpers/staticTime.d.ts +2 -0
- package/lib-es/test-helpers/staticTime.d.ts.map +1 -0
- package/lib-es/test-helpers/staticTime.js +5 -0
- package/lib-es/test-helpers/staticTime.js.map +1 -0
- package/lib-es/transaction/common.d.ts +26 -0
- package/lib-es/transaction/common.d.ts.map +1 -0
- package/lib-es/transaction/common.js +115 -0
- package/lib-es/transaction/common.js.map +1 -0
- package/package.json +113 -0
- package/src/__snapshots__/account.test.ts.snap +2065 -0
- package/src/__snapshots__/cross.test.ts.snap +57 -0
- package/src/account/accountId.ts +93 -0
- package/src/account/accountName.ts +25 -0
- package/src/account/addAccounts.ts +236 -0
- package/src/account/balanceHistoryCache.ts +146 -0
- package/src/account/groupOperations.ts +164 -0
- package/src/account/helpers.test.ts +441 -0
- package/src/account/helpers.ts +380 -0
- package/src/account/index.ts +10 -0
- package/src/account/ordering.ts +109 -0
- package/src/account/pending.ts +66 -0
- package/src/account/serialization.ts +189 -0
- package/src/account/support.ts +96 -0
- package/src/account.test.ts +237 -0
- package/src/bot/bot-test-context.test.ts +37 -0
- package/src/bot/bot-test-context.ts +24 -0
- package/src/bot/formatters.ts +22 -0
- package/src/bot/specs.ts +275 -0
- package/src/bot/types.ts +224 -0
- package/src/bridge/getAddressWrapper.ts +40 -0
- package/src/bridge/jsHelpers.ts +645 -0
- package/src/cache.ts +65 -0
- package/src/cross.test.ts +112 -0
- package/src/cross.ts +366 -0
- package/src/currencies/BigNumberToLocaleString.test.ts +155 -0
- package/src/currencies/BigNumberToLocaleString.ts +80 -0
- package/src/currencies/CurrencyURIScheme.ts +114 -0
- package/src/currencies/chopCurrencyUnitDecimals.ts +34 -0
- package/src/currencies/formatCurrencyUnit.ts +167 -0
- package/src/currencies/formatShort.ts +24 -0
- package/src/currencies/index.ts +78 -0
- package/src/currencies/localeUtility.ts +50 -0
- package/src/currencies/parseCurrencyUnit.ts +16 -0
- package/src/currencies/sanitizeValueString.ts +58 -0
- package/src/currencies/support.ts +107 -0
- package/src/currencies/valueFromUnit.ts +10 -0
- package/src/derivation.ts +595 -0
- package/src/env.ts +790 -0
- package/src/errors.test.ts +21 -0
- package/src/errors.ts +9 -0
- package/src/mocks/account.ts +476 -0
- package/src/mocks/fixtures/nfts.test.ts +25 -0
- package/src/mocks/fixtures/nfts.ts +432 -0
- package/src/mocks/helpers.ts +38 -0
- package/src/network.ts +135 -0
- package/src/nft/nftId.ts +26 -0
- package/src/operation.ts +212 -0
- package/src/promise.test.ts +20 -0
- package/src/promise.ts +101 -0
- package/src/rangeDates.test.ts +66 -0
- package/src/rangeDates.ts +96 -0
- package/src/test-helpers/staticTime.ts +4 -0
- package/src/transaction/common.ts +157 -0
package/src/bot/specs.ts
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// helpers for spec
|
|
2
|
+
import invariant from "invariant";
|
|
3
|
+
import { log } from "@ledgerhq/logs";
|
|
4
|
+
import expect from "expect";
|
|
5
|
+
import sample from "lodash/sample";
|
|
6
|
+
import { isAccountEmpty } from "../account";
|
|
7
|
+
import type {
|
|
8
|
+
DeviceAction,
|
|
9
|
+
DeviceActionArg,
|
|
10
|
+
TransactionDestinationTestInput,
|
|
11
|
+
} from "./types";
|
|
12
|
+
import { Account, TransactionCommon } from "@ledgerhq/types-live";
|
|
13
|
+
import { botTest } from "./bot-test-context";
|
|
14
|
+
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
15
|
+
import BigNumber from "bignumber.js";
|
|
16
|
+
|
|
17
|
+
export { botTest };
|
|
18
|
+
|
|
19
|
+
const stepValueTransformDefault = (s: string) => s.trim();
|
|
20
|
+
|
|
21
|
+
// TODO should weight the choice to favorize accounts with small amounts
|
|
22
|
+
export function pickSiblings(siblings: Account[], maxAccount = 5): Account {
|
|
23
|
+
const withoutEmpties = siblings.filter((a) => a.used);
|
|
24
|
+
|
|
25
|
+
if (withoutEmpties.length >= maxAccount) {
|
|
26
|
+
// we are no longer creating accounts
|
|
27
|
+
const maybeAccount = sample(withoutEmpties);
|
|
28
|
+
if (!maybeAccount) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"at least one non-empty sibling account exists. maxAccount=" +
|
|
31
|
+
maxAccount
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return maybeAccount;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// we are only keeping empty account that have smaller index to favorize creation of non created derivation modes
|
|
38
|
+
let empties = siblings.filter(isAccountEmpty);
|
|
39
|
+
empties.sort((a, b) => a.index - b.index);
|
|
40
|
+
|
|
41
|
+
if (empties.length > 0) {
|
|
42
|
+
empties = empties.filter((e) => e.index === empties[0].index);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const maybeAccount = sample(withoutEmpties.concat(empties));
|
|
46
|
+
if (!maybeAccount) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
"at least one sibling account exists. maxAccount=" + maxAccount
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return maybeAccount;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type State<T extends TransactionCommon> = {
|
|
55
|
+
finalState: boolean;
|
|
56
|
+
stepTitle: string;
|
|
57
|
+
stepValue: string;
|
|
58
|
+
acc: Array<{
|
|
59
|
+
title: string;
|
|
60
|
+
value: string;
|
|
61
|
+
}>;
|
|
62
|
+
currentStep: Step<T> | null | undefined;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export enum SpeculosButton {
|
|
66
|
+
LEFT = "Ll",
|
|
67
|
+
RIGHT = "Rr",
|
|
68
|
+
BOTH = "LRlr",
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type Step<T extends TransactionCommon> = {
|
|
72
|
+
title: string;
|
|
73
|
+
stepValueTransform?: (s: string) => string;
|
|
74
|
+
expectedValue?: (
|
|
75
|
+
arg0: DeviceActionArg<T, State<T>>,
|
|
76
|
+
acc: Array<{
|
|
77
|
+
title: string;
|
|
78
|
+
value: string;
|
|
79
|
+
}>
|
|
80
|
+
) => string;
|
|
81
|
+
ignoreAssertionFailure?: boolean;
|
|
82
|
+
trimValue?: boolean;
|
|
83
|
+
button?: SpeculosButton;
|
|
84
|
+
// action to apply in term of button press
|
|
85
|
+
final?: boolean; // tells if there is no step after that and action should terminate all further action (hack to do deboncing)
|
|
86
|
+
maxY?: number; // check if text is bellow a certains Y coordinate on the screen, it happened that two text have the same content but different positions
|
|
87
|
+
};
|
|
88
|
+
type FlowDesc<T extends TransactionCommon> = {
|
|
89
|
+
steps: Array<Step<T>>;
|
|
90
|
+
fallback?: (arg0: DeviceActionArg<T, State<T>>) => Step<T> | null | undefined;
|
|
91
|
+
};
|
|
92
|
+
// generalized logic of device actions
|
|
93
|
+
export function deviceActionFlow<T extends TransactionCommon>(
|
|
94
|
+
description: FlowDesc<T>
|
|
95
|
+
): DeviceAction<T, State<T>> {
|
|
96
|
+
return (arg: DeviceActionArg<T, State<T>>) => {
|
|
97
|
+
invariant(
|
|
98
|
+
arg.appCandidate.model === "nanoS",
|
|
99
|
+
"FIXME: stepper logic is only implemented for Nano S"
|
|
100
|
+
);
|
|
101
|
+
const { transport, event, state, disableStrictStepValueValidation } = arg;
|
|
102
|
+
let { finalState, stepTitle, stepValue, acc, currentStep } = state || {
|
|
103
|
+
finalState: false,
|
|
104
|
+
stepTitle: "",
|
|
105
|
+
stepValue: "",
|
|
106
|
+
acc: [],
|
|
107
|
+
currentStep: null,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
function runStep(step: Step<T>) {
|
|
111
|
+
const { final, title, button } = step;
|
|
112
|
+
|
|
113
|
+
if (stepValue && step.title !== stepTitle) {
|
|
114
|
+
// there were accumulated text and we are on new step, we need to release it and compare to expected
|
|
115
|
+
if (currentStep && currentStep.expectedValue) {
|
|
116
|
+
const { expectedValue, ignoreAssertionFailure } = currentStep;
|
|
117
|
+
const stepValueTransform =
|
|
118
|
+
currentStep.stepValueTransform || stepValueTransformDefault;
|
|
119
|
+
|
|
120
|
+
if (!ignoreAssertionFailure && !disableStrictStepValueValidation) {
|
|
121
|
+
botTest("deviceAction confirm step '" + stepTitle + "'", () =>
|
|
122
|
+
expect({
|
|
123
|
+
[stepTitle]: stepValueTransform(stepValue),
|
|
124
|
+
}).toMatchObject({
|
|
125
|
+
[stepTitle]: expectedValue(arg, acc).trim(),
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
acc = acc.concat({
|
|
132
|
+
title: stepTitle,
|
|
133
|
+
value: stepValue,
|
|
134
|
+
});
|
|
135
|
+
// a new step reset back the value for the next
|
|
136
|
+
stepValue = "";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (button) {
|
|
140
|
+
// some step trigger navigation action
|
|
141
|
+
transport.button(button);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// text is the title of the step. we assume screen event starts / ends.
|
|
145
|
+
stepTitle = title;
|
|
146
|
+
currentStep = step;
|
|
147
|
+
|
|
148
|
+
if (final) {
|
|
149
|
+
finalState = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!finalState) {
|
|
154
|
+
let possibleKnownStep: Step<T> | null | undefined =
|
|
155
|
+
description.steps.find((s) => {
|
|
156
|
+
if (s.maxY) {
|
|
157
|
+
return event.text.startsWith(s.title) && event.y < s.maxY;
|
|
158
|
+
}
|
|
159
|
+
return event.text.startsWith(s.title);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// if there is a fallback provided, we will run it to try to detect another possible known step
|
|
163
|
+
if (!possibleKnownStep && description.fallback) {
|
|
164
|
+
possibleKnownStep = description.fallback(arg);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (possibleKnownStep) {
|
|
168
|
+
// a step title was recognized. run it as a new step
|
|
169
|
+
runStep(possibleKnownStep);
|
|
170
|
+
} else if (currentStep) {
|
|
171
|
+
// there is a current ongoing step so we need to accumulate all text we see
|
|
172
|
+
let { text } = event;
|
|
173
|
+
if (currentStep.trimValue) text = text.trim();
|
|
174
|
+
stepValue += text;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
log("bot/flow", `'${event.text}' ~> ${stepTitle}: ${stepValue}`);
|
|
179
|
+
return {
|
|
180
|
+
finalState,
|
|
181
|
+
stepTitle,
|
|
182
|
+
stepValue,
|
|
183
|
+
acc,
|
|
184
|
+
currentStep,
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type DeviceAmountFormatOptions = {
|
|
190
|
+
// the ticker of the coin is AFTER the amount on the device (e.g. "600.1 USDT")
|
|
191
|
+
postfixCode: boolean;
|
|
192
|
+
// the device shows "42" as "42.0"
|
|
193
|
+
forceFloating: boolean;
|
|
194
|
+
// device don't even display the code (unit ticker)
|
|
195
|
+
hideCode: boolean;
|
|
196
|
+
// force the visibility of all digits of the amount
|
|
197
|
+
showAllDigits: boolean;
|
|
198
|
+
};
|
|
199
|
+
const defaultFormatOptions: DeviceAmountFormatOptions = {
|
|
200
|
+
postfixCode: false,
|
|
201
|
+
forceFloating: false,
|
|
202
|
+
hideCode: false,
|
|
203
|
+
showAllDigits: false,
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const sep = " ";
|
|
207
|
+
export function formatDeviceAmount(
|
|
208
|
+
currency: CryptoCurrency | TokenCurrency,
|
|
209
|
+
value: BigNumber,
|
|
210
|
+
options: Partial<DeviceAmountFormatOptions> = defaultFormatOptions
|
|
211
|
+
): string {
|
|
212
|
+
const [unit] = currency.units;
|
|
213
|
+
let code = unit.code;
|
|
214
|
+
if (currency.type === "CryptoCurrency") {
|
|
215
|
+
const { deviceTicker } = currency;
|
|
216
|
+
if (deviceTicker) code = deviceTicker;
|
|
217
|
+
}
|
|
218
|
+
const fValue = value.div(new BigNumber(10).pow(unit.magnitude));
|
|
219
|
+
let v = options.showAllDigits
|
|
220
|
+
? fValue.toFixed(unit.magnitude)
|
|
221
|
+
: fValue.toString(10);
|
|
222
|
+
if (options.forceFloating) {
|
|
223
|
+
if (!v.includes(".")) {
|
|
224
|
+
// if the value is pure integer, in the app it will automatically add an .0
|
|
225
|
+
v += ".0";
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (options.hideCode) return v;
|
|
229
|
+
return options.postfixCode ? v + sep + code : code + sep + v;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// this function throw if the portion of undelegated funds is smaller than the threshold
|
|
233
|
+
// where threshold is a value from 0.0 to 1.0, percentage of the total amount of funds
|
|
234
|
+
// Usage: put these in your spec, on the mutation transaction functions that intend to do more "delegations"
|
|
235
|
+
export function expectSiblingsHaveSpendablePartGreaterThan(
|
|
236
|
+
siblings: Account[],
|
|
237
|
+
threshold: number
|
|
238
|
+
): void {
|
|
239
|
+
const spendableTotal = siblings.reduce(
|
|
240
|
+
(acc, a) => acc.plus(a.spendableBalance),
|
|
241
|
+
new BigNumber(0)
|
|
242
|
+
);
|
|
243
|
+
const total = siblings.reduce(
|
|
244
|
+
(acc, a) => acc.plus(a.balance),
|
|
245
|
+
new BigNumber(0)
|
|
246
|
+
);
|
|
247
|
+
invariant(
|
|
248
|
+
spendableTotal.div(total).gt(threshold),
|
|
249
|
+
"the spendable part of accounts is sufficient (threshold: %s)",
|
|
250
|
+
threshold
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export const genericTestDestination = <T>({
|
|
255
|
+
destination,
|
|
256
|
+
operation,
|
|
257
|
+
destinationBeforeTransaction,
|
|
258
|
+
sendingOperation,
|
|
259
|
+
}: TransactionDestinationTestInput<T>): void => {
|
|
260
|
+
const amount = sendingOperation.value.minus(sendingOperation.fee);
|
|
261
|
+
botTest("account balance increased with transaction amount", () =>
|
|
262
|
+
expect(destination.balance.toString()).toBe(
|
|
263
|
+
destinationBeforeTransaction.balance.plus(amount).toString()
|
|
264
|
+
)
|
|
265
|
+
);
|
|
266
|
+
botTest("operation amount is consistent with sendingOperation", () =>
|
|
267
|
+
expect({
|
|
268
|
+
type: operation.type,
|
|
269
|
+
amount: operation.value.toString(),
|
|
270
|
+
}).toMatchObject({
|
|
271
|
+
type: "IN",
|
|
272
|
+
amount: amount.toString(),
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
};
|
package/src/bot/types.ts
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import Transport from "@ledgerhq/hw-transport";
|
|
3
|
+
import type { DeviceModelId } from "@ledgerhq/devices";
|
|
4
|
+
import {
|
|
5
|
+
Account,
|
|
6
|
+
AccountBridge,
|
|
7
|
+
AccountRaw,
|
|
8
|
+
Operation,
|
|
9
|
+
SignedOperation,
|
|
10
|
+
SignOperationEvent,
|
|
11
|
+
TransactionCommon,
|
|
12
|
+
TransactionStatusCommon,
|
|
13
|
+
} from "@ledgerhq/types-live";
|
|
14
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
15
|
+
|
|
16
|
+
// Type coming from live-common/src/load/speculos.ts
|
|
17
|
+
export type AppCandidate = {
|
|
18
|
+
path: string;
|
|
19
|
+
model: DeviceModelId;
|
|
20
|
+
firmware: string;
|
|
21
|
+
appName: string;
|
|
22
|
+
appVersion: string;
|
|
23
|
+
};
|
|
24
|
+
export type DeviceActionEvent = {
|
|
25
|
+
text: string;
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
export type TransactionTestInput<T> = {
|
|
30
|
+
account: Account;
|
|
31
|
+
accountBeforeTransaction: Account;
|
|
32
|
+
transaction: T;
|
|
33
|
+
status: TransactionStatusCommon;
|
|
34
|
+
optimisticOperation: Operation;
|
|
35
|
+
operation: Operation;
|
|
36
|
+
};
|
|
37
|
+
export type TransactionDestinationTestInput<T> = {
|
|
38
|
+
sendingAccount: Account;
|
|
39
|
+
sendingOperation: Operation;
|
|
40
|
+
destinationBeforeTransaction: Account;
|
|
41
|
+
operation: Operation;
|
|
42
|
+
destination: Account;
|
|
43
|
+
transaction: T;
|
|
44
|
+
status: TransactionStatusCommon;
|
|
45
|
+
};
|
|
46
|
+
export type DeviceActionArg<T extends TransactionCommon, S> = {
|
|
47
|
+
appCandidate: AppCandidate;
|
|
48
|
+
account: Account;
|
|
49
|
+
transaction: T;
|
|
50
|
+
status: TransactionStatusCommon;
|
|
51
|
+
transport: Transport & {
|
|
52
|
+
button: (arg0: string) => void;
|
|
53
|
+
};
|
|
54
|
+
event: DeviceActionEvent;
|
|
55
|
+
state: S;
|
|
56
|
+
disableStrictStepValueValidation?: boolean;
|
|
57
|
+
};
|
|
58
|
+
export type DeviceAction<T extends TransactionCommon, S> = (
|
|
59
|
+
arg0: DeviceActionArg<T, S>
|
|
60
|
+
) => S | null | undefined;
|
|
61
|
+
export type TransactionArg<T extends TransactionCommon> = {
|
|
62
|
+
appCandidate: AppCandidate;
|
|
63
|
+
account: Account;
|
|
64
|
+
siblings: Account[];
|
|
65
|
+
bridge: AccountBridge<T>;
|
|
66
|
+
maxSpendable: BigNumber;
|
|
67
|
+
preloadedData: any;
|
|
68
|
+
};
|
|
69
|
+
export type TransactionRes<T extends TransactionCommon> = {
|
|
70
|
+
transaction: T;
|
|
71
|
+
updates: Array<Partial<T> | null | undefined>;
|
|
72
|
+
destination?: Account;
|
|
73
|
+
};
|
|
74
|
+
export type MutationSpec<T extends TransactionCommon> = {
|
|
75
|
+
// Name what this mutation is doing
|
|
76
|
+
name: string;
|
|
77
|
+
// The maximum number of times to execute this mutation for a given test run
|
|
78
|
+
maxRun: number;
|
|
79
|
+
// Express the transaction to be done
|
|
80
|
+
// it returns either a transaction T, or an array with T and a list of patch to apply to it
|
|
81
|
+
transaction: (arg: TransactionArg<T>) => TransactionRes<T>;
|
|
82
|
+
// if there is a status errors/warnings of the defined transaction, this function, if define, can try to recover from it
|
|
83
|
+
recoverBadTransactionStatus?: (arg0: {
|
|
84
|
+
transaction: T;
|
|
85
|
+
status: TransactionStatusCommon;
|
|
86
|
+
account: Account;
|
|
87
|
+
bridge: AccountBridge<T>;
|
|
88
|
+
}) => T | null | undefined;
|
|
89
|
+
// express what are the status warnings to express on a given transaction
|
|
90
|
+
expectStatusWarnings?: (arg0: {
|
|
91
|
+
transaction: T;
|
|
92
|
+
status: TransactionStatusCommon;
|
|
93
|
+
account: Account;
|
|
94
|
+
bridge: AccountBridge<T>;
|
|
95
|
+
}) => { [_: string]: Error } | undefined;
|
|
96
|
+
// Express the device actions to do (buttons,..) and validate the device screen. overrides genericDeviceAction
|
|
97
|
+
deviceAction?: DeviceAction<T, any>;
|
|
98
|
+
// how much time to wait in maximum to reach the final state
|
|
99
|
+
testTimeout?: number;
|
|
100
|
+
// Implement a test that runs after the operation is applied to the account
|
|
101
|
+
test?: (input: TransactionTestInput<T>) => void;
|
|
102
|
+
// Implement a second test that allows to test the effect of the transaction on the DESTINATION account (matched by recipient)
|
|
103
|
+
testDestination?: (input: TransactionDestinationTestInput<T>) => void;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type AppSpec<T extends TransactionCommon> = {
|
|
107
|
+
// allows to disable completely spec from running
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
// an arbitrary name to identify the bot spec
|
|
110
|
+
name: string;
|
|
111
|
+
// which crypto currency will the bot scan accounts with
|
|
112
|
+
currency: CryptoCurrency;
|
|
113
|
+
// how much time in ms does the test need to wait the operation to appear
|
|
114
|
+
testTimeout?: number;
|
|
115
|
+
// how much should we retry scan accounts if an error occurs
|
|
116
|
+
scanAccountsRetries?: number;
|
|
117
|
+
// if define, will run the mutations {multipleRuns} times in order to cover 2 txs in the same run and detect possible issues at the "second tx time"
|
|
118
|
+
multipleRuns?: number;
|
|
119
|
+
// define the frequency of exporting/importing back the account to simulate mobile export
|
|
120
|
+
crossAccountFrequency?: number;
|
|
121
|
+
// if the nano app depends on an app, name of this app
|
|
122
|
+
dependency?: string;
|
|
123
|
+
// a query to select one nano app. the most up to date version is selected when fields aren't set.
|
|
124
|
+
appQuery: {
|
|
125
|
+
model?: DeviceModelId;
|
|
126
|
+
appName?: string;
|
|
127
|
+
firmware?: string;
|
|
128
|
+
appVersion?: string;
|
|
129
|
+
};
|
|
130
|
+
// all the possible scenarios of these spec to consider doing transactions with
|
|
131
|
+
mutations: MutationSpec<T>[];
|
|
132
|
+
// can implement generic invariants for a mutation transaction to be possible
|
|
133
|
+
transactionCheck?: (arg: TransactionArg<T>) => void;
|
|
134
|
+
// Implement a test that also runs on each mutation after the operation is applied to the account
|
|
135
|
+
// this allows to verify the effect of the transaction is correctly applied on the account
|
|
136
|
+
test?: (arg0: TransactionTestInput<T>) => void;
|
|
137
|
+
// Express the device actions to do (buttons,..) and validate the device screen
|
|
138
|
+
genericDeviceAction: DeviceAction<T, any>;
|
|
139
|
+
// typically for 'botTransfer' we need to be able to override the preferred way to transfer a sub account
|
|
140
|
+
genericDeviceActionForSubAccountTransfers?: DeviceAction<T, any>;
|
|
141
|
+
// indicates to the engine what's the generally minimal amount we use to opt out from doing a transaction
|
|
142
|
+
// NB: at the moment it's purely informative and help inferring good "hints", but we could eventually automate it
|
|
143
|
+
minViableAmount?: BigNumber;
|
|
144
|
+
// global timeout to consider the run due date for the spec. (since a seed could have theorically an infinite amount of accounts and mutation could take a lot of time to validate transactions, we need a way to limit the run time)
|
|
145
|
+
skipMutationsTimeout?: number;
|
|
146
|
+
// do not expect an account to always be found (Hedera case)
|
|
147
|
+
allowEmptyAccounts?: boolean;
|
|
148
|
+
};
|
|
149
|
+
export type SpecReport<T extends TransactionCommon> = {
|
|
150
|
+
spec: AppSpec<T>;
|
|
151
|
+
appPath?: string;
|
|
152
|
+
scanDuration?: number;
|
|
153
|
+
preloadDuration?: number;
|
|
154
|
+
accountsBefore?: Account[];
|
|
155
|
+
accountsAfter?: Account[];
|
|
156
|
+
mutations?: MutationReport<T>[];
|
|
157
|
+
fatalError?: Error;
|
|
158
|
+
// express hints for the spec developers on things that could be improved
|
|
159
|
+
hintWarnings: string[];
|
|
160
|
+
skipMutationsTimeoutReached: boolean;
|
|
161
|
+
};
|
|
162
|
+
export type MutationReport<T extends TransactionCommon> = {
|
|
163
|
+
resyncAccountsDuration: number;
|
|
164
|
+
spec: AppSpec<T>;
|
|
165
|
+
appCandidate: AppCandidate;
|
|
166
|
+
account?: Account;
|
|
167
|
+
maxSpendable?: BigNumber;
|
|
168
|
+
unavailableMutationReasons?: Array<{
|
|
169
|
+
error: Error;
|
|
170
|
+
mutation: MutationSpec<T>;
|
|
171
|
+
}>;
|
|
172
|
+
mutation?: MutationSpec<T>;
|
|
173
|
+
mutationTime?: number;
|
|
174
|
+
destination?: Account;
|
|
175
|
+
transaction?: T;
|
|
176
|
+
status?: TransactionStatusCommon;
|
|
177
|
+
statusTime?: number;
|
|
178
|
+
recoveredFromTransactionStatus?: {
|
|
179
|
+
transaction: T;
|
|
180
|
+
status: TransactionStatusCommon;
|
|
181
|
+
};
|
|
182
|
+
latestSignOperationEvent?: SignOperationEvent;
|
|
183
|
+
signedOperation?: SignedOperation;
|
|
184
|
+
signedTime?: number;
|
|
185
|
+
optimisticOperation?: Operation;
|
|
186
|
+
broadcastedTime?: number;
|
|
187
|
+
operation?: Operation;
|
|
188
|
+
confirmedTime?: number;
|
|
189
|
+
finalAccount?: Account;
|
|
190
|
+
testDuration?: number;
|
|
191
|
+
destinationConfirmedTime?: number;
|
|
192
|
+
finalDestination?: Account;
|
|
193
|
+
finalDestinationOperation?: Operation;
|
|
194
|
+
testDestinationDuration?: number;
|
|
195
|
+
error?: Error;
|
|
196
|
+
errorTime?: number;
|
|
197
|
+
hintWarnings: string[];
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type MinimalSerializedMutationReport = {
|
|
201
|
+
appCandidate: AppCandidate;
|
|
202
|
+
mutationName: string | undefined;
|
|
203
|
+
accountId: string | undefined;
|
|
204
|
+
destinationId: string | undefined;
|
|
205
|
+
operationId: string | undefined;
|
|
206
|
+
error: string | undefined;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type MinimalSerializedSpecReport = {
|
|
210
|
+
// spec.name
|
|
211
|
+
specName: string;
|
|
212
|
+
// minified version of accounts (we remove transactions from them)
|
|
213
|
+
accounts: AccountRaw[] | undefined;
|
|
214
|
+
fatalError: string | undefined;
|
|
215
|
+
mutations: MinimalSerializedMutationReport[] | undefined;
|
|
216
|
+
existingMutationNames: string[];
|
|
217
|
+
hintWarnings: string[];
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export type MinimalSerializedReport = {
|
|
221
|
+
results: Array<MinimalSerializedSpecReport>;
|
|
222
|
+
environment: string | undefined;
|
|
223
|
+
seedHash: string;
|
|
224
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Transport from "@ledgerhq/hw-transport";
|
|
2
|
+
import {
|
|
3
|
+
DeviceAppVerifyNotSupported,
|
|
4
|
+
UserRefusedAddress,
|
|
5
|
+
} from "@ledgerhq/errors";
|
|
6
|
+
import { log } from "@ledgerhq/logs";
|
|
7
|
+
import type { Result, GetAddressOptions } from "../derivation";
|
|
8
|
+
|
|
9
|
+
export type Resolver = (
|
|
10
|
+
transport: Transport,
|
|
11
|
+
addressOpt: GetAddressOptions
|
|
12
|
+
) => Promise<Result>;
|
|
13
|
+
|
|
14
|
+
const getAddressWrapper =
|
|
15
|
+
(getAddressFn: Resolver) =>
|
|
16
|
+
(transport: Transport, opts: GetAddressOptions) => {
|
|
17
|
+
const { currency, path, verify } = opts;
|
|
18
|
+
return getAddressFn(transport, opts)
|
|
19
|
+
.then((result) => {
|
|
20
|
+
log("hw", `getAddress ${currency.id} on ${path}`, result);
|
|
21
|
+
return result;
|
|
22
|
+
})
|
|
23
|
+
.catch((e) => {
|
|
24
|
+
log("hw", `getAddress ${currency.id} on ${path} FAILED ${String(e)}`);
|
|
25
|
+
|
|
26
|
+
if (e && e.name === "TransportStatusError") {
|
|
27
|
+
if (e.statusCode === 0x6b00 && verify) {
|
|
28
|
+
throw new DeviceAppVerifyNotSupported();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (e.statusCode === 0x6985 || e.statusCode === 0x5501) {
|
|
32
|
+
throw new UserRefusedAddress();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw e;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default getAddressWrapper;
|