@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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { Operation, OperationRaw, SubAccount } from "@ledgerhq/types-live";
|
|
3
|
+
|
|
4
|
+
export type ExtractExtraFn = (
|
|
5
|
+
extra: Record<string, any>
|
|
6
|
+
) => Record<string, any>;
|
|
7
|
+
|
|
8
|
+
export const toOperationRaw = (
|
|
9
|
+
{
|
|
10
|
+
date,
|
|
11
|
+
value,
|
|
12
|
+
fee,
|
|
13
|
+
subOperations,
|
|
14
|
+
internalOperations,
|
|
15
|
+
nftOperations,
|
|
16
|
+
extra,
|
|
17
|
+
id,
|
|
18
|
+
hash,
|
|
19
|
+
type,
|
|
20
|
+
senders,
|
|
21
|
+
recipients,
|
|
22
|
+
blockHeight,
|
|
23
|
+
blockHash,
|
|
24
|
+
transactionSequenceNumber,
|
|
25
|
+
accountId,
|
|
26
|
+
hasFailed,
|
|
27
|
+
contract,
|
|
28
|
+
operator,
|
|
29
|
+
standard,
|
|
30
|
+
tokenId,
|
|
31
|
+
transactionRaw,
|
|
32
|
+
}: Operation,
|
|
33
|
+
preserveSubOperation?: boolean
|
|
34
|
+
): OperationRaw => {
|
|
35
|
+
const copy: OperationRaw = {
|
|
36
|
+
id,
|
|
37
|
+
hash,
|
|
38
|
+
type,
|
|
39
|
+
senders,
|
|
40
|
+
recipients,
|
|
41
|
+
accountId,
|
|
42
|
+
blockHash,
|
|
43
|
+
blockHeight,
|
|
44
|
+
extra,
|
|
45
|
+
date: date.toISOString(),
|
|
46
|
+
value: value.toFixed(),
|
|
47
|
+
fee: fee.toString(),
|
|
48
|
+
contract,
|
|
49
|
+
operator,
|
|
50
|
+
standard,
|
|
51
|
+
tokenId,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (transactionSequenceNumber !== undefined) {
|
|
55
|
+
copy.transactionSequenceNumber = transactionSequenceNumber;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (hasFailed !== undefined) {
|
|
59
|
+
copy.hasFailed = hasFailed;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (subOperations && preserveSubOperation) {
|
|
63
|
+
copy.subOperations = subOperations.map((o: Operation) => toOperationRaw(o));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (internalOperations) {
|
|
67
|
+
copy.internalOperations = internalOperations.map((o: Operation) =>
|
|
68
|
+
toOperationRaw(o)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (nftOperations) {
|
|
73
|
+
copy.nftOperations = nftOperations.map((o: Operation) => toOperationRaw(o));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (transactionRaw !== undefined) {
|
|
77
|
+
copy.transactionRaw = transactionRaw;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return copy;
|
|
81
|
+
};
|
|
82
|
+
export const inferSubOperations = (
|
|
83
|
+
txHash: string,
|
|
84
|
+
subAccounts: SubAccount[]
|
|
85
|
+
): Operation[] => {
|
|
86
|
+
const all: Operation[] = [];
|
|
87
|
+
|
|
88
|
+
for (let i = 0; i < subAccounts.length; i++) {
|
|
89
|
+
const ta = subAccounts[i];
|
|
90
|
+
|
|
91
|
+
for (let j = 0; j < ta.operations.length; j++) {
|
|
92
|
+
const op = ta.operations[j];
|
|
93
|
+
|
|
94
|
+
if (op.hash === txHash) {
|
|
95
|
+
all.push(op);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (let j = 0; j < ta.pendingOperations.length; j++) {
|
|
100
|
+
const op = ta.pendingOperations[j];
|
|
101
|
+
|
|
102
|
+
if (op.hash === txHash) {
|
|
103
|
+
all.push(op);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return all;
|
|
109
|
+
};
|
|
110
|
+
export const fromOperationRaw = (
|
|
111
|
+
{
|
|
112
|
+
date,
|
|
113
|
+
value,
|
|
114
|
+
fee,
|
|
115
|
+
extra,
|
|
116
|
+
subOperations,
|
|
117
|
+
internalOperations,
|
|
118
|
+
nftOperations,
|
|
119
|
+
id,
|
|
120
|
+
hash,
|
|
121
|
+
type,
|
|
122
|
+
senders,
|
|
123
|
+
recipients,
|
|
124
|
+
blockHeight,
|
|
125
|
+
blockHash,
|
|
126
|
+
transactionSequenceNumber,
|
|
127
|
+
hasFailed,
|
|
128
|
+
contract,
|
|
129
|
+
operator,
|
|
130
|
+
standard,
|
|
131
|
+
tokenId,
|
|
132
|
+
transactionRaw,
|
|
133
|
+
}: OperationRaw,
|
|
134
|
+
accountId: string,
|
|
135
|
+
subAccounts?: SubAccount[] | null | undefined
|
|
136
|
+
): Operation => {
|
|
137
|
+
const res: Operation = {
|
|
138
|
+
id,
|
|
139
|
+
hash,
|
|
140
|
+
type,
|
|
141
|
+
senders,
|
|
142
|
+
recipients,
|
|
143
|
+
accountId,
|
|
144
|
+
blockHash,
|
|
145
|
+
blockHeight,
|
|
146
|
+
date: new Date(date),
|
|
147
|
+
value: new BigNumber(value),
|
|
148
|
+
fee: new BigNumber(fee),
|
|
149
|
+
extra,
|
|
150
|
+
contract,
|
|
151
|
+
operator,
|
|
152
|
+
standard,
|
|
153
|
+
tokenId,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (transactionSequenceNumber !== undefined) {
|
|
157
|
+
res.transactionSequenceNumber = transactionSequenceNumber;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (hasFailed !== undefined) {
|
|
161
|
+
res.hasFailed = hasFailed;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (subAccounts) {
|
|
165
|
+
res.subOperations = inferSubOperations(hash, subAccounts);
|
|
166
|
+
} else if (subOperations) {
|
|
167
|
+
res.subOperations = subOperations.map((o: OperationRaw) =>
|
|
168
|
+
fromOperationRaw(o, o.accountId)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (internalOperations) {
|
|
173
|
+
res.internalOperations = internalOperations.map((o: OperationRaw) =>
|
|
174
|
+
fromOperationRaw(o, o.accountId)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (nftOperations) {
|
|
179
|
+
res.nftOperations = nftOperations.map((o: OperationRaw) =>
|
|
180
|
+
fromOperationRaw(o, o.accountId)
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (transactionRaw !== undefined) {
|
|
185
|
+
res.transactionRaw = transactionRaw;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return res;
|
|
189
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountNotSupported,
|
|
3
|
+
CurrencyNotSupported,
|
|
4
|
+
UnavailableTezosOriginatedAccountReceive,
|
|
5
|
+
} from "@ledgerhq/errors";
|
|
6
|
+
import { getEnv } from "../env";
|
|
7
|
+
import { decodeAccountId } from "./accountId";
|
|
8
|
+
import {
|
|
9
|
+
getAllDerivationModes,
|
|
10
|
+
getDerivationModesForCurrency,
|
|
11
|
+
} from "../derivation";
|
|
12
|
+
import { isCurrencySupported } from "../currencies";
|
|
13
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
14
|
+
import type { Account, AccountLike } from "@ledgerhq/types-live";
|
|
15
|
+
import type { DerivationMode } from "../derivation";
|
|
16
|
+
|
|
17
|
+
export const shouldShowNewAccount = (
|
|
18
|
+
currency: CryptoCurrency,
|
|
19
|
+
derivationMode: DerivationMode
|
|
20
|
+
): boolean => {
|
|
21
|
+
const modes = getDerivationModesForCurrency(currency);
|
|
22
|
+
// last mode is always creatable by convention
|
|
23
|
+
if (modes[modes.length - 1] === derivationMode) return true;
|
|
24
|
+
// legacy is only available with flag SHOW_LEGACY_NEW_ACCOUNT
|
|
25
|
+
if (
|
|
26
|
+
derivationMode === "" &&
|
|
27
|
+
(!!getEnv("SHOW_LEGACY_NEW_ACCOUNT") || currency.family === "bitcoin")
|
|
28
|
+
)
|
|
29
|
+
return true;
|
|
30
|
+
// native segwit being not yet supported everywhere, segwit is always available for creation
|
|
31
|
+
if (
|
|
32
|
+
derivationMode === "segwit" ||
|
|
33
|
+
(currency.family === "bitcoin" &&
|
|
34
|
+
(derivationMode === "native_segwit" || derivationMode === "taproot"))
|
|
35
|
+
)
|
|
36
|
+
return true;
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
export const getReceiveFlowError = (
|
|
40
|
+
account: AccountLike,
|
|
41
|
+
parentAccount: Account | null | undefined
|
|
42
|
+
): Error | null | undefined => {
|
|
43
|
+
if (parentAccount && parentAccount.currency.id === "tezos") {
|
|
44
|
+
return new UnavailableTezosOriginatedAccountReceive("");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export function canBeMigrated(account: Account): boolean {
|
|
48
|
+
try {
|
|
49
|
+
const { version } = decodeAccountId(account.id);
|
|
50
|
+
|
|
51
|
+
if (getEnv("MOCK")) {
|
|
52
|
+
return version === "0";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return false;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// attempt to find an account in scanned accounts that satisfy a migration
|
|
61
|
+
export function findAccountMigration(
|
|
62
|
+
account: Account,
|
|
63
|
+
scannedAccounts: Account[]
|
|
64
|
+
): Account | null | undefined {
|
|
65
|
+
if (!canBeMigrated(account)) return;
|
|
66
|
+
|
|
67
|
+
if (getEnv("MOCK")) {
|
|
68
|
+
return scannedAccounts.find(
|
|
69
|
+
(a) =>
|
|
70
|
+
a.id !== account.id && // a migration assume an id changes
|
|
71
|
+
a.currency === account.currency &&
|
|
72
|
+
a.freshAddress === account.freshAddress
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function checkAccountSupported(
|
|
77
|
+
account: Account
|
|
78
|
+
): Error | null | undefined {
|
|
79
|
+
if (
|
|
80
|
+
!getAllDerivationModes().includes(account.derivationMode as DerivationMode)
|
|
81
|
+
) {
|
|
82
|
+
return new AccountNotSupported(
|
|
83
|
+
"derivation not supported " + account.derivationMode,
|
|
84
|
+
{
|
|
85
|
+
reason: account.derivationMode,
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!isCurrencySupported(account.currency)) {
|
|
91
|
+
const currencyName = account.currency.name;
|
|
92
|
+
return new CurrencyNotSupported("currency not supported: " + currencyName, {
|
|
93
|
+
currencyName,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import "./test-helpers/staticTime";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
import flatMap from "lodash/flatMap";
|
|
4
|
+
import {
|
|
5
|
+
getCryptoCurrencyById,
|
|
6
|
+
getTokenById,
|
|
7
|
+
setSupportedCurrencies,
|
|
8
|
+
} from "./currencies";
|
|
9
|
+
import {
|
|
10
|
+
groupAccountOperationsByDay,
|
|
11
|
+
groupAccountsOperationsByDay,
|
|
12
|
+
shortAddressPreview,
|
|
13
|
+
accountWithMandatoryTokens,
|
|
14
|
+
withoutToken,
|
|
15
|
+
} from "./account";
|
|
16
|
+
import { genAccount } from "./mocks/account";
|
|
17
|
+
import { Operation } from "@ledgerhq/types-live";
|
|
18
|
+
import { SubAccount } from "@ledgerhq/types-live";
|
|
19
|
+
|
|
20
|
+
setSupportedCurrencies(["ethereum", "ethereum_classic", "tron"]);
|
|
21
|
+
|
|
22
|
+
describe("groupAccountOperationsByDay", () => {
|
|
23
|
+
test("basic", () => {
|
|
24
|
+
const account = genAccount("seed_7", {
|
|
25
|
+
operationsSize: 20,
|
|
26
|
+
});
|
|
27
|
+
const res1 = groupAccountOperationsByDay(account, {
|
|
28
|
+
count: 10,
|
|
29
|
+
});
|
|
30
|
+
expect(res1.completed).toBe(false);
|
|
31
|
+
expect(res1).toMatchSnapshot();
|
|
32
|
+
const res2 = groupAccountOperationsByDay(account, {
|
|
33
|
+
count: Infinity,
|
|
34
|
+
});
|
|
35
|
+
expect(res2.completed).toBe(true);
|
|
36
|
+
expect(
|
|
37
|
+
// $FlowFixMe
|
|
38
|
+
flatMap(res2.sections, (s) => s.data).slice(0, 10)
|
|
39
|
+
).toMatchObject(
|
|
40
|
+
// $FlowFixMe
|
|
41
|
+
flatMap(res1.sections, (s) => s.data)
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
test("basic 2", () => {
|
|
45
|
+
const accounts = Array(10)
|
|
46
|
+
.fill(null)
|
|
47
|
+
.map((_, i) => genAccount("gaobd" + i));
|
|
48
|
+
const res1 = groupAccountsOperationsByDay(accounts, {
|
|
49
|
+
count: 100,
|
|
50
|
+
});
|
|
51
|
+
expect(res1.completed).toBe(false);
|
|
52
|
+
expect(res1).toMatchSnapshot();
|
|
53
|
+
const res2 = groupAccountsOperationsByDay(accounts, {
|
|
54
|
+
count: Infinity,
|
|
55
|
+
});
|
|
56
|
+
expect(res2.completed).toBe(true);
|
|
57
|
+
expect(
|
|
58
|
+
// $FlowFixMe
|
|
59
|
+
flatMap(res2.sections, (s) => s.data).slice(0, 100)
|
|
60
|
+
).toMatchObject(
|
|
61
|
+
// $FlowFixMe
|
|
62
|
+
flatMap(res1.sections, (s) => s.data)
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
test("filterOperation", () => {
|
|
66
|
+
const account = genAccount("seed_7");
|
|
67
|
+
account.pendingOperations = account.operations.splice(0, 2);
|
|
68
|
+
const res1 = groupAccountOperationsByDay(account, {
|
|
69
|
+
count: 10,
|
|
70
|
+
filterOperation: () => false,
|
|
71
|
+
});
|
|
72
|
+
expect(res1.sections.length).toBe(0);
|
|
73
|
+
expect(res1.completed).toBe(true);
|
|
74
|
+
const res2 = groupAccountOperationsByDay(account, {
|
|
75
|
+
count: 10,
|
|
76
|
+
filterOperation: () => true,
|
|
77
|
+
});
|
|
78
|
+
expect(res2).toEqual(
|
|
79
|
+
groupAccountOperationsByDay(account, {
|
|
80
|
+
count: 10,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
const res3 = groupAccountOperationsByDay(account, {
|
|
84
|
+
count: 10,
|
|
85
|
+
filterOperation: (op, acc) => {
|
|
86
|
+
expect(acc).toBe(account);
|
|
87
|
+
return op.type === "OUT";
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
expect(res3).toEqual(
|
|
91
|
+
groupAccountOperationsByDay(
|
|
92
|
+
{
|
|
93
|
+
...account,
|
|
94
|
+
operations: account.operations.filter((op) => op.type === "OUT"),
|
|
95
|
+
pendingOperations: account.pendingOperations.filter(
|
|
96
|
+
(op) => op.type === "OUT"
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
count: 10,
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
test("provide at least the requested count even if some op yield nothing", () => {
|
|
106
|
+
const ethAccount = genAccount("eth_1", {
|
|
107
|
+
currency: getCryptoCurrencyById("ethereum"),
|
|
108
|
+
operationsSize: 300,
|
|
109
|
+
});
|
|
110
|
+
ethAccount.operations = Array(50)
|
|
111
|
+
.fill({
|
|
112
|
+
...ethAccount.operations[0],
|
|
113
|
+
value: new BigNumber(0),
|
|
114
|
+
type: "NONE",
|
|
115
|
+
})
|
|
116
|
+
.concat(ethAccount.operations);
|
|
117
|
+
const res1 = groupAccountOperationsByDay(ethAccount, {
|
|
118
|
+
count: 100,
|
|
119
|
+
});
|
|
120
|
+
expect(res1.completed).toBe(false);
|
|
121
|
+
expect(
|
|
122
|
+
res1.sections.reduce((acc, s) => acc.concat(s.data), <Operation[]>[])
|
|
123
|
+
.length
|
|
124
|
+
).toBeGreaterThanOrEqual(100);
|
|
125
|
+
});
|
|
126
|
+
test("to dedup", () => {
|
|
127
|
+
const account = genAccount("seed_8");
|
|
128
|
+
account.pendingOperations = account.operations.slice(0, 3);
|
|
129
|
+
const accountClone = genAccount("seed_8");
|
|
130
|
+
const res1 = groupAccountOperationsByDay(account, {
|
|
131
|
+
count: 100,
|
|
132
|
+
});
|
|
133
|
+
const res2 = groupAccountOperationsByDay(accountClone, {
|
|
134
|
+
count: 100,
|
|
135
|
+
});
|
|
136
|
+
expect(res1).toMatchObject(res2);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
test("shortAddressPreview", () => {
|
|
140
|
+
expect(
|
|
141
|
+
shortAddressPreview("0x112233445566778899001234567890aAbBcCdDeEfF")
|
|
142
|
+
).toBe("0x112233...cCdDeEfF");
|
|
143
|
+
expect(
|
|
144
|
+
shortAddressPreview("0x112233445566778899001234567890aAbBcCdDeEfF", 30)
|
|
145
|
+
).toBe("0x11223344556...0aAbBcCdDeEfF");
|
|
146
|
+
});
|
|
147
|
+
test("accountWithMandatoryTokens ethereum", () => {
|
|
148
|
+
const currency = getCryptoCurrencyById("ethereum");
|
|
149
|
+
const account = genAccount("", {
|
|
150
|
+
currency,
|
|
151
|
+
subAccountsCount: 5,
|
|
152
|
+
});
|
|
153
|
+
const enhance = accountWithMandatoryTokens(account, [
|
|
154
|
+
getTokenById("ethereum/erc20/0x_project"),
|
|
155
|
+
]);
|
|
156
|
+
const doubleEnhance = accountWithMandatoryTokens(enhance, [
|
|
157
|
+
getTokenById("ethereum/erc20/0x_project"),
|
|
158
|
+
]);
|
|
159
|
+
expect(doubleEnhance).toEqual(enhance);
|
|
160
|
+
expect({ ...enhance, subAccounts: [] }).toMatchObject({
|
|
161
|
+
...account,
|
|
162
|
+
subAccounts: [],
|
|
163
|
+
});
|
|
164
|
+
expect((enhance.subAccounts || []).map((a) => a.id)).toMatchSnapshot();
|
|
165
|
+
});
|
|
166
|
+
test("withoutToken ethereum", () => {
|
|
167
|
+
const isTokenAccount = (account: SubAccount, tokenId: string) =>
|
|
168
|
+
account.type === "TokenAccount" && account.token.id === tokenId;
|
|
169
|
+
|
|
170
|
+
const tokenIds = [
|
|
171
|
+
"ethereum/erc20/0x_project",
|
|
172
|
+
"ethereum/erc20/leo_token",
|
|
173
|
+
"ethereum/erc20/cro",
|
|
174
|
+
"ethereum/erc20/huobitoken",
|
|
175
|
+
];
|
|
176
|
+
const currency = getCryptoCurrencyById("ethereum");
|
|
177
|
+
const account = genAccount("", {
|
|
178
|
+
currency,
|
|
179
|
+
subAccountsCount: 0,
|
|
180
|
+
});
|
|
181
|
+
//Enhance the account with some tokens
|
|
182
|
+
const enhance = accountWithMandatoryTokens(
|
|
183
|
+
account,
|
|
184
|
+
tokenIds.map(getTokenById)
|
|
185
|
+
);
|
|
186
|
+
//Get a version of that account without all the tokens
|
|
187
|
+
let demote = enhance;
|
|
188
|
+
|
|
189
|
+
for (const tokenId of tokenIds) {
|
|
190
|
+
demote = withoutToken(demote, tokenId);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const saTokens = enhance.subAccounts || [];
|
|
194
|
+
const saNoTokens = demote.subAccounts || [];
|
|
195
|
+
|
|
196
|
+
//See if we have added/removed them correctly
|
|
197
|
+
for (const tokenId of tokenIds) {
|
|
198
|
+
expect(saTokens.find((a) => isTokenAccount(a, tokenId))).toBeTruthy();
|
|
199
|
+
expect(saNoTokens.find((a) => isTokenAccount(a, tokenId))).toBeFalsy();
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
test("withoutToken tron", () => {
|
|
203
|
+
const isTokenAccount = (account: SubAccount, tokenId: string) =>
|
|
204
|
+
account.type === "TokenAccount" && account.token.id === tokenId;
|
|
205
|
+
|
|
206
|
+
const tokenIds = [
|
|
207
|
+
"tron/trc10/1002000",
|
|
208
|
+
"tron/trc10/1002398",
|
|
209
|
+
"tron/trc10/1000226",
|
|
210
|
+
"tron/trc20/TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
|
|
211
|
+
];
|
|
212
|
+
const currency = getCryptoCurrencyById("tron");
|
|
213
|
+
const account = genAccount("", {
|
|
214
|
+
currency,
|
|
215
|
+
subAccountsCount: 0,
|
|
216
|
+
});
|
|
217
|
+
//Enhance the account with some tokens
|
|
218
|
+
const enhance = accountWithMandatoryTokens(
|
|
219
|
+
account,
|
|
220
|
+
tokenIds.map(getTokenById)
|
|
221
|
+
);
|
|
222
|
+
//Get a version of that account without all the tokens
|
|
223
|
+
let demote = enhance;
|
|
224
|
+
|
|
225
|
+
for (const tokenId of tokenIds) {
|
|
226
|
+
demote = withoutToken(demote, tokenId);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const saTokens = enhance.subAccounts || [];
|
|
230
|
+
const saNoTokens = demote.subAccounts || [];
|
|
231
|
+
|
|
232
|
+
//See if we have added/removed them correctly
|
|
233
|
+
for (const tokenId of tokenIds) {
|
|
234
|
+
expect(saTokens.find((a) => isTokenAccount(a, tokenId))).toBeTruthy();
|
|
235
|
+
expect(saNoTokens.find((a) => isTokenAccount(a, tokenId))).toBeFalsy();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { botTest, getContext } from "./bot-test-context";
|
|
2
|
+
import { formatError } from "./formatters";
|
|
3
|
+
|
|
4
|
+
describe("test the botTest context itself", () => {
|
|
5
|
+
test("botTest", () => {
|
|
6
|
+
const f = () => {
|
|
7
|
+
try {
|
|
8
|
+
botTest("CTX", () => expect(true).toEqual(false));
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return getContext(e);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
expect(f()).toEqual("CTX");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("double botTest", () => {
|
|
17
|
+
const f = () => {
|
|
18
|
+
try {
|
|
19
|
+
botTest("1", () => botTest("2", () => expect(true).toEqual(false)));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return getContext(e);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
expect(f()).toEqual("1 > 2");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("formatError", () => {
|
|
28
|
+
const f = () => {
|
|
29
|
+
try {
|
|
30
|
+
botTest("CTX", () => expect(true).toEqual(false));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return formatError(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
expect(f()?.slice(0, 8)).toEqual("TEST CTX");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type EnhancedError = Error & {
|
|
2
|
+
_bot_context?: string[];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
// This provides a botTest("description", () => {}) helper in order to give context in bot expect tests
|
|
6
|
+
export function botTest(description: string, f: () => void): void {
|
|
7
|
+
try {
|
|
8
|
+
f();
|
|
9
|
+
} catch (e) {
|
|
10
|
+
if (e instanceof Error) {
|
|
11
|
+
const err = e as EnhancedError;
|
|
12
|
+
err._bot_context = [description].concat(err._bot_context || []);
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// retrieve the text context of a given error that was thrown from inside a botTest(...)
|
|
20
|
+
export function getContext(error: any): string | undefined {
|
|
21
|
+
if (error instanceof Error) {
|
|
22
|
+
return ((error as EnhancedError)._bot_context || []).join(" > ");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getContext } from "./bot-test-context";
|
|
2
|
+
|
|
3
|
+
export function formatError(e: unknown, longform = false): string {
|
|
4
|
+
let out = "";
|
|
5
|
+
if (!e || typeof e !== "object") {
|
|
6
|
+
out = String(e);
|
|
7
|
+
} else if (e instanceof Error) {
|
|
8
|
+
const ctx = getContext(e);
|
|
9
|
+
if (ctx) out += `TEST ${ctx}\n`;
|
|
10
|
+
out += String(e);
|
|
11
|
+
} else {
|
|
12
|
+
try {
|
|
13
|
+
out = "raw object: " + JSON.stringify(e);
|
|
14
|
+
} catch (_e) {
|
|
15
|
+
out = String(e);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (longform) {
|
|
19
|
+
return out.slice(0, 500);
|
|
20
|
+
}
|
|
21
|
+
return out.replace(/[`]/g, "").replace(/\n/g, " ").slice(0, 200);
|
|
22
|
+
}
|