@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,164 @@
|
|
|
1
|
+
import { flattenAccounts } from "./helpers";
|
|
2
|
+
import { flattenOperationWithInternalsAndNfts } from "../operation";
|
|
3
|
+
import type {
|
|
4
|
+
AccountLike,
|
|
5
|
+
AccountLikeArray,
|
|
6
|
+
DailyOperations,
|
|
7
|
+
Operation,
|
|
8
|
+
} from "@ledgerhq/types-live";
|
|
9
|
+
|
|
10
|
+
function startOfDay(t: Date) {
|
|
11
|
+
return new Date(t.getFullYear(), t.getMonth(), t.getDate());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const emptyDailyOperations = {
|
|
15
|
+
sections: [],
|
|
16
|
+
completed: true,
|
|
17
|
+
};
|
|
18
|
+
type GroupOpsByDayOpts = {
|
|
19
|
+
count: number;
|
|
20
|
+
withSubAccounts?: boolean;
|
|
21
|
+
filterOperation?: (arg0: Operation, arg1: AccountLike) => boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const hasStableOperation = (account: AccountLike, hash: string) =>
|
|
25
|
+
account.operations.some((op) => op.hash === hash);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @memberof account
|
|
29
|
+
*/
|
|
30
|
+
export function groupAccountsOperationsByDay(
|
|
31
|
+
inputAccounts: AccountLikeArray,
|
|
32
|
+
{ count, withSubAccounts, filterOperation }: GroupOpsByDayOpts
|
|
33
|
+
): DailyOperations {
|
|
34
|
+
const accounts = withSubAccounts
|
|
35
|
+
? flattenAccounts(inputAccounts)
|
|
36
|
+
: inputAccounts;
|
|
37
|
+
// Track indexes of account.operations[] for each account
|
|
38
|
+
const indexes: number[] = Array(accounts.length).fill(0);
|
|
39
|
+
// Track indexes of account.pendingOperations[] for each account
|
|
40
|
+
const indexesPending: number[] = Array(accounts.length).fill(0);
|
|
41
|
+
|
|
42
|
+
// Returns the next most recent operation from the account with current indexes
|
|
43
|
+
function getNext():
|
|
44
|
+
| {
|
|
45
|
+
ops: Operation[];
|
|
46
|
+
date: Date;
|
|
47
|
+
}
|
|
48
|
+
| null
|
|
49
|
+
| undefined {
|
|
50
|
+
let bestOp: Operation | null | undefined;
|
|
51
|
+
let bestOpInfo = {
|
|
52
|
+
accountI: 0,
|
|
53
|
+
fromPending: false,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
for (let i = 0; i < accounts.length; i++) {
|
|
57
|
+
const account = accounts[i];
|
|
58
|
+
// look in operations
|
|
59
|
+
let op = account.operations[indexes[i]];
|
|
60
|
+
|
|
61
|
+
if (filterOperation) {
|
|
62
|
+
// skip operation we want to filter out
|
|
63
|
+
while (op && !filterOperation(op, account)) {
|
|
64
|
+
op = account.operations[++indexes[i]];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (op && (!bestOp || op.date > bestOp.date)) {
|
|
69
|
+
bestOp = op;
|
|
70
|
+
bestOpInfo = {
|
|
71
|
+
accountI: i,
|
|
72
|
+
fromPending: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// look in pending operations
|
|
77
|
+
let opP = account.pendingOperations[indexesPending[i]];
|
|
78
|
+
|
|
79
|
+
while (
|
|
80
|
+
opP && // skip all pending operations that are already in operations
|
|
81
|
+
(hasStableOperation(account, opP.hash) || // but also if we want to filter it
|
|
82
|
+
(filterOperation && !filterOperation(opP, account)))
|
|
83
|
+
) {
|
|
84
|
+
opP = account.pendingOperations[++indexesPending[i]];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (opP && (!bestOp || opP.date > bestOp.date)) {
|
|
88
|
+
bestOp = opP;
|
|
89
|
+
bestOpInfo = {
|
|
90
|
+
accountI: i,
|
|
91
|
+
fromPending: true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (bestOp) {
|
|
97
|
+
if (bestOpInfo.fromPending) {
|
|
98
|
+
indexesPending[bestOpInfo.accountI]++;
|
|
99
|
+
} else {
|
|
100
|
+
indexes[bestOpInfo.accountI]++;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ops = flattenOperationWithInternalsAndNfts(bestOp);
|
|
104
|
+
return {
|
|
105
|
+
ops,
|
|
106
|
+
date: bestOp.date,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let next = getNext();
|
|
112
|
+
if (!next) return emptyDailyOperations;
|
|
113
|
+
const sections: Array<{
|
|
114
|
+
day: Date;
|
|
115
|
+
data: Operation[];
|
|
116
|
+
}> = [];
|
|
117
|
+
let totalOperations = 0;
|
|
118
|
+
let day = startOfDay(next.date);
|
|
119
|
+
let data: Operation[] = [];
|
|
120
|
+
|
|
121
|
+
while (totalOperations < count && next) {
|
|
122
|
+
if (next.date < day) {
|
|
123
|
+
if (data.length > 0) {
|
|
124
|
+
const slicedData = data.slice(0, count - totalOperations);
|
|
125
|
+
sections.push({
|
|
126
|
+
day,
|
|
127
|
+
data: slicedData,
|
|
128
|
+
});
|
|
129
|
+
totalOperations += slicedData.length;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
day = startOfDay(next.date);
|
|
133
|
+
data = next.ops;
|
|
134
|
+
} else {
|
|
135
|
+
data = data.concat(next.ops);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
next = getNext();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (data.length > 0 && totalOperations < count) {
|
|
142
|
+
sections.push({
|
|
143
|
+
day,
|
|
144
|
+
data,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
sections,
|
|
150
|
+
completed: !next,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Return a list of `{count}` operations grouped by day.
|
|
156
|
+
* @memberof account
|
|
157
|
+
*/
|
|
158
|
+
export function groupAccountOperationsByDay(
|
|
159
|
+
account: AccountLike,
|
|
160
|
+
arg: GroupOpsByDayOpts
|
|
161
|
+
): DailyOperations {
|
|
162
|
+
const accounts: AccountLike[] = [account];
|
|
163
|
+
return groupAccountsOperationsByDay(accounts, arg);
|
|
164
|
+
}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CryptoCurrency,
|
|
3
|
+
TokenCurrency,
|
|
4
|
+
Unit,
|
|
5
|
+
} from "@ledgerhq/types-cryptoassets";
|
|
6
|
+
import {
|
|
7
|
+
Account,
|
|
8
|
+
ChildAccount,
|
|
9
|
+
Operation,
|
|
10
|
+
SubAccount,
|
|
11
|
+
TokenAccount,
|
|
12
|
+
} from "@ledgerhq/types-live";
|
|
13
|
+
import BigNumber from "bignumber.js";
|
|
14
|
+
import {
|
|
15
|
+
areAllOperationsLoaded,
|
|
16
|
+
emptyHistoryCache,
|
|
17
|
+
getAccountCurrency,
|
|
18
|
+
getAccountName,
|
|
19
|
+
getAccountSpendableBalance,
|
|
20
|
+
getAccountUnit,
|
|
21
|
+
} from ".";
|
|
22
|
+
import {
|
|
23
|
+
isAccountEmpty,
|
|
24
|
+
isAccountBalanceSignificant,
|
|
25
|
+
clearAccount,
|
|
26
|
+
} from "./helpers";
|
|
27
|
+
|
|
28
|
+
const mockAccount = {} as Account;
|
|
29
|
+
const childAccount = {
|
|
30
|
+
...mockAccount,
|
|
31
|
+
type: "ChildAccount",
|
|
32
|
+
parentId: "sampleId",
|
|
33
|
+
address: "sampleAddress",
|
|
34
|
+
} as ChildAccount;
|
|
35
|
+
const tokenAccount = {
|
|
36
|
+
...mockAccount,
|
|
37
|
+
type: "TokenAccount",
|
|
38
|
+
token: {} as TokenCurrency,
|
|
39
|
+
parentId: "sampleId",
|
|
40
|
+
} as TokenAccount;
|
|
41
|
+
|
|
42
|
+
describe(getAccountCurrency.name, () => {
|
|
43
|
+
describe("given an Account", () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
mockAccount.type = "Account";
|
|
46
|
+
});
|
|
47
|
+
it("should return the currency", () => {
|
|
48
|
+
const sampleCurrency = { family: "bitcoin" } as CryptoCurrency;
|
|
49
|
+
mockAccount.currency = sampleCurrency;
|
|
50
|
+
expect(getAccountCurrency(mockAccount)).toEqual(sampleCurrency);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("given a ChildAccount", () => {
|
|
55
|
+
it("should return the currency", () => {
|
|
56
|
+
const sampleCurrency = { family: "bitcoin" } as CryptoCurrency;
|
|
57
|
+
childAccount.currency = sampleCurrency;
|
|
58
|
+
expect(getAccountCurrency(childAccount)).toEqual(sampleCurrency);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("given a TokenAccount", () => {
|
|
63
|
+
it("should return the token currency", () => {
|
|
64
|
+
const sampleToken = { id: "tokenId" } as TokenCurrency;
|
|
65
|
+
tokenAccount.token = sampleToken;
|
|
66
|
+
expect(getAccountCurrency(tokenAccount)).toEqual(sampleToken);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("given an unknown type Account", () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
(mockAccount as any).type = "DefinitelyNotAStandardAccount";
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should throw an error", () => {
|
|
76
|
+
expect(() => getAccountCurrency(mockAccount)).toThrow(Error);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should display the account type in the error message", () => {
|
|
80
|
+
expect.assertions(1);
|
|
81
|
+
try {
|
|
82
|
+
getAccountCurrency(mockAccount);
|
|
83
|
+
} catch (e: unknown) {
|
|
84
|
+
expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe(getAccountUnit.name, () => {
|
|
91
|
+
describe("given an Account", () => {
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
mockAccount.type = "Account";
|
|
94
|
+
});
|
|
95
|
+
it("should return the unit", () => {
|
|
96
|
+
const sampleUnit = { name: "unit" } as Unit;
|
|
97
|
+
mockAccount.unit = sampleUnit;
|
|
98
|
+
expect(getAccountUnit(mockAccount)).toEqual(sampleUnit);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("given a ChildAccount", () => {
|
|
103
|
+
it("should return the currency unit", () => {
|
|
104
|
+
const sampleUnit = { name: "unit" } as Unit;
|
|
105
|
+
childAccount.currency = { units: [sampleUnit] } as CryptoCurrency;
|
|
106
|
+
expect(getAccountUnit(childAccount)).toEqual(sampleUnit);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe("given a TokenAccount", () => {
|
|
111
|
+
it("should return the token unit", () => {
|
|
112
|
+
const sampleUnit = { name: "unit" } as Unit;
|
|
113
|
+
tokenAccount.token = { units: [sampleUnit] } as TokenCurrency;
|
|
114
|
+
expect(getAccountUnit(tokenAccount)).toEqual(sampleUnit);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("given an unknown type Account", () => {
|
|
119
|
+
beforeEach(() => {
|
|
120
|
+
(mockAccount as any).type = "DefinitelyNotAStandardAccount";
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("should throw an error", () => {
|
|
124
|
+
expect(() => getAccountUnit(mockAccount)).toThrow(Error);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("should display the account type in the error message", () => {
|
|
128
|
+
expect.assertions(1);
|
|
129
|
+
try {
|
|
130
|
+
getAccountUnit(mockAccount);
|
|
131
|
+
} catch (e: unknown) {
|
|
132
|
+
expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe(getAccountName.name, () => {
|
|
139
|
+
describe("given an Account", () => {
|
|
140
|
+
beforeEach(() => {
|
|
141
|
+
mockAccount.type = "Account";
|
|
142
|
+
});
|
|
143
|
+
it("should return the account name", () => {
|
|
144
|
+
const sampleAccountName = "SampleAccountName";
|
|
145
|
+
mockAccount.name = sampleAccountName;
|
|
146
|
+
expect(getAccountName(mockAccount)).toEqual(sampleAccountName);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe("given a ChildAccount", () => {
|
|
151
|
+
it("should return the account name", () => {
|
|
152
|
+
const sampleAccountName = "SampleAccountName";
|
|
153
|
+
childAccount.name = sampleAccountName;
|
|
154
|
+
expect(getAccountName(childAccount)).toEqual(sampleAccountName);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe("given a TokenAccount", () => {
|
|
159
|
+
it("should return the token account name", () => {
|
|
160
|
+
const sampleAccountName = "SampleAccountName";
|
|
161
|
+
tokenAccount.token = { name: sampleAccountName } as TokenCurrency;
|
|
162
|
+
expect(getAccountName(tokenAccount)).toEqual(sampleAccountName);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe("given an unknown type Account", () => {
|
|
167
|
+
beforeEach(() => {
|
|
168
|
+
(mockAccount as any).type = "DefinitelyNotAStandardAccount";
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("should throw an error", () => {
|
|
172
|
+
expect(() => getAccountName(mockAccount)).toThrow(Error);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("should display the account type in the error message", () => {
|
|
176
|
+
expect.assertions(1);
|
|
177
|
+
try {
|
|
178
|
+
getAccountName(mockAccount);
|
|
179
|
+
} catch (e: unknown) {
|
|
180
|
+
expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe(getAccountSpendableBalance.name, () => {
|
|
187
|
+
describe("given an Account", () => {
|
|
188
|
+
beforeEach(() => {
|
|
189
|
+
mockAccount.type = "Account";
|
|
190
|
+
});
|
|
191
|
+
it("should return the account spendable balance", () => {
|
|
192
|
+
const sampleAccountBalance = new BigNumber(10);
|
|
193
|
+
mockAccount.spendableBalance = sampleAccountBalance;
|
|
194
|
+
expect(getAccountSpendableBalance(mockAccount)).toEqual(
|
|
195
|
+
sampleAccountBalance
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe("given a ChildAccount", () => {
|
|
201
|
+
it("should return the account balance", () => {
|
|
202
|
+
const sampleAccountBalance = new BigNumber(10);
|
|
203
|
+
childAccount.balance = sampleAccountBalance;
|
|
204
|
+
expect(getAccountSpendableBalance(childAccount)).toEqual(
|
|
205
|
+
sampleAccountBalance
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe("given a TokenAccount", () => {
|
|
211
|
+
it("should return the token account spendable balance", () => {
|
|
212
|
+
const sampleAccountBalance = new BigNumber(10);
|
|
213
|
+
tokenAccount.spendableBalance = sampleAccountBalance;
|
|
214
|
+
expect(getAccountSpendableBalance(tokenAccount)).toEqual(
|
|
215
|
+
sampleAccountBalance
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe("given an unknown type Account", () => {
|
|
221
|
+
beforeEach(() => {
|
|
222
|
+
(mockAccount as any).type = "DefinitelyNotAStandardAccount";
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("should throw an error", () => {
|
|
226
|
+
expect(() => getAccountSpendableBalance(mockAccount)).toThrow(Error);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("should display the account type in the error message", () => {
|
|
230
|
+
expect.assertions(1);
|
|
231
|
+
try {
|
|
232
|
+
getAccountSpendableBalance(mockAccount);
|
|
233
|
+
} catch (e: unknown) {
|
|
234
|
+
expect((e as Error).message.includes(mockAccount.type)).toEqual(true);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe(isAccountEmpty.name, () => {
|
|
241
|
+
describe("given an account", () => {
|
|
242
|
+
beforeEach(() => {
|
|
243
|
+
mockAccount.type = "Account";
|
|
244
|
+
mockAccount.currency = { family: "ethereum" } as CryptoCurrency;
|
|
245
|
+
});
|
|
246
|
+
describe("when account has no subaccounts", () => {
|
|
247
|
+
beforeEach(() => {
|
|
248
|
+
mockAccount.subAccounts = [];
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe("and balance is zero", () => {
|
|
252
|
+
beforeEach(() => {
|
|
253
|
+
mockAccount.balance = new BigNumber(0);
|
|
254
|
+
});
|
|
255
|
+
it("should return true if operationsCount is 0", () => {
|
|
256
|
+
mockAccount.operationsCount = 0;
|
|
257
|
+
expect(isAccountEmpty(mockAccount)).toEqual(true);
|
|
258
|
+
});
|
|
259
|
+
it("should return false if operationsCount is higher than 0", () => {
|
|
260
|
+
mockAccount.operationsCount = 1;
|
|
261
|
+
expect(isAccountEmpty(mockAccount)).toEqual(false);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe("and balance is higher than 0", () => {
|
|
266
|
+
beforeEach(() => {
|
|
267
|
+
mockAccount.balance = new BigNumber(42);
|
|
268
|
+
});
|
|
269
|
+
it("should return false if operationsCount is 0", () => {
|
|
270
|
+
mockAccount.operationsCount = 0;
|
|
271
|
+
expect(isAccountEmpty(mockAccount)).toEqual(false);
|
|
272
|
+
});
|
|
273
|
+
it("should return false if operationsCount is higher than 0", () => {
|
|
274
|
+
mockAccount.operationsCount = 1;
|
|
275
|
+
expect(isAccountEmpty(mockAccount)).toEqual(false);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
describe("when account has subaccounts", () => {
|
|
280
|
+
beforeEach(() => {
|
|
281
|
+
mockAccount.subAccounts = [{} as SubAccount];
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it("should return false", () => {
|
|
285
|
+
expect(isAccountEmpty(mockAccount)).toEqual(false);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
describe(areAllOperationsLoaded.name, () => {
|
|
292
|
+
describe("given an account with subAccounts", () => {
|
|
293
|
+
beforeEach(() => {
|
|
294
|
+
mockAccount.type = "Account";
|
|
295
|
+
mockAccount.operations = [];
|
|
296
|
+
mockAccount.operationsCount = 0;
|
|
297
|
+
mockAccount.subAccounts = [
|
|
298
|
+
{
|
|
299
|
+
operations: [],
|
|
300
|
+
operationsCount: 0,
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
operations: [{} as Operation],
|
|
304
|
+
operationsCount: 1,
|
|
305
|
+
},
|
|
306
|
+
] as SubAccount[];
|
|
307
|
+
});
|
|
308
|
+
describe("when sub account operation aren't loaded", () => {
|
|
309
|
+
beforeEach(() => {
|
|
310
|
+
(mockAccount.subAccounts as SubAccount[])[1].operations = [];
|
|
311
|
+
});
|
|
312
|
+
it("should return false", () => {
|
|
313
|
+
expect(areAllOperationsLoaded(mockAccount)).toEqual(false);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
describe("when sub account operation are loaded", () => {
|
|
318
|
+
it("should return true", () => {
|
|
319
|
+
expect(areAllOperationsLoaded(mockAccount)).toEqual(true);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
describe("given an account without subAccounts", () => {
|
|
324
|
+
describe("when operations count is different from operations length", () => {
|
|
325
|
+
beforeEach(() => {
|
|
326
|
+
childAccount.operationsCount = 2;
|
|
327
|
+
childAccount.operations = [{} as Operation];
|
|
328
|
+
});
|
|
329
|
+
it("should return false", () => {
|
|
330
|
+
expect(areAllOperationsLoaded(childAccount)).toEqual(false);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
describe("when operations count is same as operations length", () => {
|
|
335
|
+
beforeEach(() => {
|
|
336
|
+
childAccount.operationsCount = 1;
|
|
337
|
+
childAccount.operations = [{} as Operation];
|
|
338
|
+
});
|
|
339
|
+
it("should return true", () => {
|
|
340
|
+
expect(areAllOperationsLoaded(childAccount)).toEqual(true);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
describe(isAccountBalanceSignificant.name, () => {
|
|
347
|
+
describe("when balance is low", () => {
|
|
348
|
+
beforeEach(() => {
|
|
349
|
+
mockAccount.balance = new BigNumber(10);
|
|
350
|
+
});
|
|
351
|
+
it("should return false", () => {
|
|
352
|
+
expect(isAccountBalanceSignificant(mockAccount)).toEqual(false);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
describe("when balance is high", () => {
|
|
356
|
+
beforeEach(() => {
|
|
357
|
+
mockAccount.balance = new BigNumber(101);
|
|
358
|
+
});
|
|
359
|
+
it("should return true", () => {
|
|
360
|
+
expect(isAccountBalanceSignificant(mockAccount)).toEqual(true);
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
describe(clearAccount.name, () => {
|
|
366
|
+
describe("given a TokenAccount", () => {
|
|
367
|
+
const tokenAccount = {
|
|
368
|
+
...mockAccount,
|
|
369
|
+
token: {} as TokenCurrency,
|
|
370
|
+
parentId: "sampleId",
|
|
371
|
+
type: "TokenAccount",
|
|
372
|
+
} as TokenAccount;
|
|
373
|
+
|
|
374
|
+
it("should clear operations", () => {
|
|
375
|
+
const clearedAccount = clearAccount(tokenAccount);
|
|
376
|
+
expect(clearedAccount.operations.length).toEqual(0);
|
|
377
|
+
expect(clearedAccount.pendingOperations.length).toEqual(0);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("should clear balanceHistory", () => {
|
|
381
|
+
const clearedAccount = clearAccount(tokenAccount);
|
|
382
|
+
expect(clearedAccount.balanceHistoryCache).toEqual(emptyHistoryCache);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe("given a ChildAccount", () => {
|
|
387
|
+
const childAccount = {
|
|
388
|
+
...mockAccount,
|
|
389
|
+
type: "ChildAccount",
|
|
390
|
+
parentId: "sampleId",
|
|
391
|
+
address: "sampleAddress",
|
|
392
|
+
} as ChildAccount;
|
|
393
|
+
|
|
394
|
+
it("should clear operations", () => {
|
|
395
|
+
const clearedAccount = clearAccount(childAccount);
|
|
396
|
+
expect(clearedAccount.operations.length).toEqual(0);
|
|
397
|
+
expect(clearedAccount.pendingOperations.length).toEqual(0);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it("should clear balanceHistory", () => {
|
|
401
|
+
const clearedAccount = clearAccount(childAccount);
|
|
402
|
+
expect(clearedAccount.balanceHistoryCache).toEqual(emptyHistoryCache);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
describe("given an Account", () => {
|
|
407
|
+
const ethereumCurrency = {
|
|
408
|
+
family: "ethereum",
|
|
409
|
+
} as CryptoCurrency;
|
|
410
|
+
const withSubAccounts = {
|
|
411
|
+
...mockAccount,
|
|
412
|
+
subAccounts: [
|
|
413
|
+
{
|
|
414
|
+
currency: ethereumCurrency,
|
|
415
|
+
} as SubAccount,
|
|
416
|
+
],
|
|
417
|
+
currency: ethereumCurrency,
|
|
418
|
+
};
|
|
419
|
+
it("should clear operations", () => {
|
|
420
|
+
const clearedAccount = clearAccount(withSubAccounts);
|
|
421
|
+
expect(clearedAccount.operations.length).toEqual(0);
|
|
422
|
+
expect(clearedAccount.pendingOperations.length).toEqual(0);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it("should clear balanceHistory", () => {
|
|
426
|
+
const clearedAccount = clearAccount(withSubAccounts);
|
|
427
|
+
expect(clearedAccount.balanceHistoryCache).toEqual(emptyHistoryCache);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it("should reset lastSyncDate", () => {
|
|
431
|
+
const clearedAccount = clearAccount(withSubAccounts);
|
|
432
|
+
expect(clearedAccount.lastSyncDate).toEqual(new Date(0));
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it("should delete nfts attribute", () => {
|
|
436
|
+
withSubAccounts.nfts = [];
|
|
437
|
+
const clearedAccount = clearAccount(withSubAccounts);
|
|
438
|
+
expect(Object.keys(clearedAccount).indexOf("nfts")).toEqual(-1);
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
});
|