@ledgerhq/coin-framework 0.0.2
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 +773 -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 +758 -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 +780 -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,21 @@
|
|
|
1
|
+
import { UnsupportedDerivation } from "./errors";
|
|
2
|
+
|
|
3
|
+
function functionA() {
|
|
4
|
+
throw new UnsupportedDerivation();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
describe("custom errors", () => {
|
|
8
|
+
test("error instanceof", () => {
|
|
9
|
+
try {
|
|
10
|
+
functionA();
|
|
11
|
+
} catch (e: any) {
|
|
12
|
+
expect(e).toBeInstanceOf(UnsupportedDerivation);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("promise error instanceof", () => {
|
|
17
|
+
expect(Promise.reject(new UnsupportedDerivation())).rejects.toBeInstanceOf(
|
|
18
|
+
UnsupportedDerivation
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
});
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import Prando from "prando";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
import {
|
|
4
|
+
listCryptoCurrencies,
|
|
5
|
+
listTokensForCryptoCurrency,
|
|
6
|
+
findCompoundToken,
|
|
7
|
+
} from "../currencies";
|
|
8
|
+
import { getOperationAmountNumber } from "../operation";
|
|
9
|
+
import {
|
|
10
|
+
inferSubOperations,
|
|
11
|
+
isAccountEmpty,
|
|
12
|
+
emptyHistoryCache,
|
|
13
|
+
generateHistoryFromOperations,
|
|
14
|
+
} from "../account";
|
|
15
|
+
import { getDerivationScheme, runDerivationScheme } from "../derivation";
|
|
16
|
+
import { genHex, genAddress } from "./helpers";
|
|
17
|
+
import type {
|
|
18
|
+
Account,
|
|
19
|
+
AccountLike,
|
|
20
|
+
Operation,
|
|
21
|
+
TokenAccount,
|
|
22
|
+
} from "@ledgerhq/types-live";
|
|
23
|
+
import type {
|
|
24
|
+
CryptoCurrency,
|
|
25
|
+
TokenCurrency,
|
|
26
|
+
} from "@ledgerhq/types-cryptoassets";
|
|
27
|
+
import { createFixtureNFT, genNFTOperation } from "./fixtures/nfts";
|
|
28
|
+
|
|
29
|
+
export function ensureNoNegative(operations: Operation[]) {
|
|
30
|
+
let total = new BigNumber(0);
|
|
31
|
+
|
|
32
|
+
for (let i = operations.length - 1; i >= 0; i--) {
|
|
33
|
+
const op = operations[i];
|
|
34
|
+
const amount = getOperationAmountNumber(op);
|
|
35
|
+
|
|
36
|
+
if (total.plus(amount).isNegative()) {
|
|
37
|
+
if (op.type === "IN") {
|
|
38
|
+
op.type = "OUT";
|
|
39
|
+
} else if (op.type === "OUT") {
|
|
40
|
+
op.type = "IN";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
total = total.plus(getOperationAmountNumber(op));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return total;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const hardcodedMarketcap = [
|
|
51
|
+
"bitcoin",
|
|
52
|
+
"ethereum",
|
|
53
|
+
"ripple",
|
|
54
|
+
"bitcoin_cash",
|
|
55
|
+
"litecoin",
|
|
56
|
+
"ethereum/erc20/usd_tether__erc20_",
|
|
57
|
+
"bsc",
|
|
58
|
+
"eos",
|
|
59
|
+
"stellar",
|
|
60
|
+
"monero",
|
|
61
|
+
"cardano",
|
|
62
|
+
"ethereum/erc20/leo_token",
|
|
63
|
+
"tron",
|
|
64
|
+
"dash",
|
|
65
|
+
"ethereum_classic",
|
|
66
|
+
"tezos",
|
|
67
|
+
"iota",
|
|
68
|
+
"ethereum/erc20/link_chainlink",
|
|
69
|
+
"neo",
|
|
70
|
+
"ethereum/erc20/makerdao",
|
|
71
|
+
"ethereum/erc20/usd__coin",
|
|
72
|
+
"ontology",
|
|
73
|
+
"ethereum/erc20/cro",
|
|
74
|
+
"zcash",
|
|
75
|
+
"dogecoin",
|
|
76
|
+
"decred",
|
|
77
|
+
"vechain",
|
|
78
|
+
"ethereum/erc20/bat",
|
|
79
|
+
"qtum",
|
|
80
|
+
"ethereum/erc20/huobitoken",
|
|
81
|
+
"bitcoin_gold",
|
|
82
|
+
"ethereum/erc20/paxos_standard__pax_",
|
|
83
|
+
"ethereum/erc20/trueusd",
|
|
84
|
+
"ethereum/erc20/omg",
|
|
85
|
+
"lisk",
|
|
86
|
+
"nano",
|
|
87
|
+
"waves",
|
|
88
|
+
"ethereum/erc20/holotoken",
|
|
89
|
+
"ethereum/erc20/icon",
|
|
90
|
+
"digibyte",
|
|
91
|
+
"ethereum/erc20/0x_project",
|
|
92
|
+
"ethereum/erc20/iostoken",
|
|
93
|
+
"ethereum/erc20/pundi_x_token",
|
|
94
|
+
"ethereum/erc20/augur",
|
|
95
|
+
"ethereum/erc20/aurora",
|
|
96
|
+
"komodo",
|
|
97
|
+
"ethereum/erc20/quant",
|
|
98
|
+
"ethereum/erc20/bytom",
|
|
99
|
+
"ethereum/erc20/dai_stablecoin_v1_0",
|
|
100
|
+
"ethereum/erc20/dai_stablecoin_v2_0",
|
|
101
|
+
"ethereum/erc20/egretia_token",
|
|
102
|
+
"aeternity",
|
|
103
|
+
"ethereum/erc20/golem",
|
|
104
|
+
"ethereum/erc20/republic_protocol",
|
|
105
|
+
"ethereum/erc20/status_network_token",
|
|
106
|
+
"ethereum/erc20/crypto_com",
|
|
107
|
+
"ethereum/erc20/enjin",
|
|
108
|
+
"ethereum/erc20/walton",
|
|
109
|
+
"ethereum/erc20/gxc",
|
|
110
|
+
"zcoin",
|
|
111
|
+
"ethereum/erc20/synthetix_network_token",
|
|
112
|
+
"stratis",
|
|
113
|
+
"ethereum/erc20/wax",
|
|
114
|
+
"ethereum/erc20/nexo",
|
|
115
|
+
"ethereum/erc20/elf_token",
|
|
116
|
+
"factom",
|
|
117
|
+
"wanchain",
|
|
118
|
+
"ethereum/erc20/pchain",
|
|
119
|
+
"zencash",
|
|
120
|
+
"ethereum/erc20/stasis_eurs_token",
|
|
121
|
+
"ethereum/erc20/revian",
|
|
122
|
+
"ethereum/erc20/odem_token",
|
|
123
|
+
"ethereum/erc20/nuls",
|
|
124
|
+
"ethereum/erc20/decentraland_mana",
|
|
125
|
+
"ethereum/erc20/nebula",
|
|
126
|
+
"ethereum/erc20/qash",
|
|
127
|
+
"ethereum/erc20/dent",
|
|
128
|
+
"ethereum/erc20/digix_dao",
|
|
129
|
+
"tomo",
|
|
130
|
+
"ethereum/erc20/lrc",
|
|
131
|
+
"ethereum/erc20/crypteriumtoken",
|
|
132
|
+
"ethereum/erc20/santiment",
|
|
133
|
+
"ethereum/erc20/matic",
|
|
134
|
+
"ethereum/erc20/kyber_network",
|
|
135
|
+
"ethereum/erc20/loom",
|
|
136
|
+
"ethereum/erc20/digitexfutures",
|
|
137
|
+
"ethereum/erc20/populous",
|
|
138
|
+
"ethereum/erc20/fusion",
|
|
139
|
+
"ethereum/erc20/enigma",
|
|
140
|
+
"ethereum/erc20/orbs",
|
|
141
|
+
"ethereum/erc20/quarkchain_token",
|
|
142
|
+
"ethereum/erc20/fetch",
|
|
143
|
+
"aion",
|
|
144
|
+
"ethereum/erc20/bix_token",
|
|
145
|
+
"ark",
|
|
146
|
+
"ethereum/erc20/menlo_one",
|
|
147
|
+
"ethereum/erc20/xmax",
|
|
148
|
+
"ethereum/erc20/bancor",
|
|
149
|
+
"ethereum/erc20/bread",
|
|
150
|
+
"ethereum/erc20/powerledger",
|
|
151
|
+
"ethereum/erc20/telcoin",
|
|
152
|
+
"tron/trc10/1002000",
|
|
153
|
+
"tron/trc10/1002398",
|
|
154
|
+
"tron/trc10/1000226",
|
|
155
|
+
"tron/trc10/1002517",
|
|
156
|
+
"tron/trc10/1002544",
|
|
157
|
+
"tron/trc10/1002573",
|
|
158
|
+
"tron/trc10/1002597",
|
|
159
|
+
"tron/trc10/1002672",
|
|
160
|
+
"tron/trc10/1002736",
|
|
161
|
+
"tron/trc10/1002798",
|
|
162
|
+
"tron/trc10/1002578",
|
|
163
|
+
"tron/trc10/1002845",
|
|
164
|
+
"tron/trc10/1002775",
|
|
165
|
+
"tron/trc10/1002858",
|
|
166
|
+
"tron/trc10/1002876",
|
|
167
|
+
"tron/trc20/TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
|
|
168
|
+
"algorand/asa/438840",
|
|
169
|
+
"algorand/asa/438839",
|
|
170
|
+
"algorand/asa/438838",
|
|
171
|
+
"algorand/asa/438837",
|
|
172
|
+
"algorand/asa/438836",
|
|
173
|
+
"algorand/asa/438833",
|
|
174
|
+
"algorand/asa/438832",
|
|
175
|
+
"algorand/asa/438831",
|
|
176
|
+
"algorand/asa/438828",
|
|
177
|
+
"algorand/asa/312769",
|
|
178
|
+
"algorand/asa/163650",
|
|
179
|
+
];
|
|
180
|
+
// for the mock generation we need to adjust to the actual market price of things, we want to avoid having things < 0.01 EUR
|
|
181
|
+
const currencyIdApproxMarketPrice: Record<string, number> = {
|
|
182
|
+
bitcoin: 0.0073059,
|
|
183
|
+
ethereum: 5.7033e-14,
|
|
184
|
+
ethereum_classic: 1.4857e-15,
|
|
185
|
+
bitcoin_cash: 0.0011739,
|
|
186
|
+
bitcoin_gold: 0.00005004,
|
|
187
|
+
litecoin: 0.00011728,
|
|
188
|
+
ripple: 0.000057633,
|
|
189
|
+
dogecoin: 4.9e-9,
|
|
190
|
+
dash: 0.0003367,
|
|
191
|
+
peercoin: 0.000226,
|
|
192
|
+
zcash: 0.000205798,
|
|
193
|
+
};
|
|
194
|
+
// mock only use subset of cryptocurrencies to not affect tests when adding coins
|
|
195
|
+
const currencies = listCryptoCurrencies().filter(
|
|
196
|
+
(c) => currencyIdApproxMarketPrice[c.id]
|
|
197
|
+
);
|
|
198
|
+
// TODO fix the mock to never generate negative balance...
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @memberof mock/account
|
|
202
|
+
*/
|
|
203
|
+
export function genOperation(
|
|
204
|
+
superAccount: Account,
|
|
205
|
+
account: AccountLike,
|
|
206
|
+
ops: any,
|
|
207
|
+
rng: Prando
|
|
208
|
+
): Operation {
|
|
209
|
+
const ticker =
|
|
210
|
+
account.type === "TokenAccount"
|
|
211
|
+
? account.token.ticker
|
|
212
|
+
: account.currency.ticker;
|
|
213
|
+
const lastOp = ops[ops.length - 1];
|
|
214
|
+
const date = new Date(
|
|
215
|
+
(lastOp ? lastOp.date : Date.now()) -
|
|
216
|
+
rng.nextInt(0, 100000000 * rng.next() * rng.next())
|
|
217
|
+
);
|
|
218
|
+
const address = genAddress(superAccount.currency, rng);
|
|
219
|
+
const type = rng.next() < 0.3 ? "OUT" : "IN";
|
|
220
|
+
const divider =
|
|
221
|
+
(account.type === "Account" &&
|
|
222
|
+
currencyIdApproxMarketPrice[account.currency.id]) ||
|
|
223
|
+
currencyIdApproxMarketPrice.bitcoin;
|
|
224
|
+
const value = new BigNumber(
|
|
225
|
+
Math.floor(rng.nextInt(0, 100000 * rng.next() * rng.next()) / divider)
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (Number.isNaN(value)) {
|
|
229
|
+
throw new Error("invalid amount generated for " + ticker);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const hash = genHex(64, rng);
|
|
233
|
+
const op: Operation = {
|
|
234
|
+
id: String(`mock_op_${ops.length}_${account.id}`),
|
|
235
|
+
hash,
|
|
236
|
+
type,
|
|
237
|
+
value,
|
|
238
|
+
fee: new BigNumber(Math.round(value.toNumber() * 0.01)),
|
|
239
|
+
senders: [type !== "IN" ? genAddress(superAccount.currency, rng) : address],
|
|
240
|
+
recipients: [
|
|
241
|
+
type === "IN" ? genAddress(superAccount.currency, rng) : address,
|
|
242
|
+
],
|
|
243
|
+
blockHash: genHex(64, rng),
|
|
244
|
+
blockHeight:
|
|
245
|
+
superAccount.blockHeight -
|
|
246
|
+
Math.floor((Date.now() - (date as any)) / 900000),
|
|
247
|
+
accountId: account.id,
|
|
248
|
+
date,
|
|
249
|
+
extra: {},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
if (account.type === "Account") {
|
|
253
|
+
const { subAccounts } = account;
|
|
254
|
+
|
|
255
|
+
if (subAccounts) {
|
|
256
|
+
// TODO make sure tokenAccounts sometimes reuse an existing op hash from main account
|
|
257
|
+
op.subOperations = inferSubOperations(hash, subAccounts);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return op;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @param id is a number or a string, used as an account identifier and as a seed for the generation.
|
|
266
|
+
* @memberof mock/account
|
|
267
|
+
*/
|
|
268
|
+
export type GenAccountOptions = {
|
|
269
|
+
operationsSize?: number;
|
|
270
|
+
currency?: CryptoCurrency;
|
|
271
|
+
subAccountsCount?: number;
|
|
272
|
+
swapHistorySize?: number;
|
|
273
|
+
withNft?: boolean;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export function genTokenAccount(
|
|
277
|
+
index: number,
|
|
278
|
+
account: Account,
|
|
279
|
+
token: TokenCurrency
|
|
280
|
+
): TokenAccount {
|
|
281
|
+
const rng = new Prando(account.id + "|" + index);
|
|
282
|
+
const tokenAccount: TokenAccount = {
|
|
283
|
+
type: "TokenAccount",
|
|
284
|
+
starred: false,
|
|
285
|
+
id: account.id + "|" + index,
|
|
286
|
+
parentId: account.id,
|
|
287
|
+
token,
|
|
288
|
+
operationsCount: 0,
|
|
289
|
+
operations: [],
|
|
290
|
+
pendingOperations: [],
|
|
291
|
+
balance: new BigNumber(0),
|
|
292
|
+
spendableBalance: new BigNumber(0),
|
|
293
|
+
creationDate: new Date(),
|
|
294
|
+
swapHistory: [],
|
|
295
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
296
|
+
};
|
|
297
|
+
const operationsSize = rng.nextInt(1, 200);
|
|
298
|
+
tokenAccount.operations = Array(operationsSize)
|
|
299
|
+
.fill(null)
|
|
300
|
+
.reduce((ops: Operation[]) => {
|
|
301
|
+
const op = genOperation(account, tokenAccount, ops, rng);
|
|
302
|
+
return ops.concat(op);
|
|
303
|
+
}, []);
|
|
304
|
+
tokenAccount.operationsCount = tokenAccount.operations.length;
|
|
305
|
+
tokenAccount.spendableBalance = tokenAccount.balance = ensureNoNegative(
|
|
306
|
+
tokenAccount.operations
|
|
307
|
+
);
|
|
308
|
+
tokenAccount.creationDate =
|
|
309
|
+
tokenAccount.operations.length > 0
|
|
310
|
+
? tokenAccount.operations[tokenAccount.operations.length - 1].date
|
|
311
|
+
: new Date();
|
|
312
|
+
tokenAccount.balanceHistoryCache =
|
|
313
|
+
generateHistoryFromOperations(tokenAccount);
|
|
314
|
+
return tokenAccount;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
type GenAccountEnhanceOperations = (
|
|
318
|
+
account: Account,
|
|
319
|
+
currency: CryptoCurrency,
|
|
320
|
+
rng: Prando
|
|
321
|
+
) => void;
|
|
322
|
+
|
|
323
|
+
export function genAccount(
|
|
324
|
+
id: number | string,
|
|
325
|
+
opts: GenAccountOptions = {},
|
|
326
|
+
completeResources?: (
|
|
327
|
+
account: Account,
|
|
328
|
+
currency: CryptoCurrency,
|
|
329
|
+
address: string
|
|
330
|
+
) => void,
|
|
331
|
+
genAccountEnhanceOperations?: GenAccountEnhanceOperations
|
|
332
|
+
): Account {
|
|
333
|
+
const rng = new Prando(id);
|
|
334
|
+
const currency = opts.currency || rng.nextArrayItem(currencies);
|
|
335
|
+
const operationsSize = opts.operationsSize ?? rng.nextInt(1, 200);
|
|
336
|
+
const swapHistorySize = opts.swapHistorySize || 0;
|
|
337
|
+
const withNft = opts.withNft ?? false;
|
|
338
|
+
const address = genAddress(currency, rng);
|
|
339
|
+
const derivationPath = runDerivationScheme(
|
|
340
|
+
getDerivationScheme({
|
|
341
|
+
currency,
|
|
342
|
+
derivationMode: "",
|
|
343
|
+
}),
|
|
344
|
+
currency
|
|
345
|
+
);
|
|
346
|
+
const freshAddress = {
|
|
347
|
+
address,
|
|
348
|
+
derivationPath,
|
|
349
|
+
};
|
|
350
|
+
// nb Make the third (ethereum_classic, dogecoin) account originally migratable
|
|
351
|
+
const outdated =
|
|
352
|
+
["ethereum_classic", "dogecoin"].includes(currency.id) &&
|
|
353
|
+
`${id}`.endsWith("_2");
|
|
354
|
+
const accountId = `mock:${outdated ? 0 : 1}:${currency.id}:${id}:`;
|
|
355
|
+
const account: Account = {
|
|
356
|
+
type: "Account",
|
|
357
|
+
id: accountId,
|
|
358
|
+
seedIdentifier: "mock",
|
|
359
|
+
derivationMode: "",
|
|
360
|
+
xpub: genHex(64, rng),
|
|
361
|
+
index: 1,
|
|
362
|
+
freshAddress: address,
|
|
363
|
+
freshAddressPath: derivationPath,
|
|
364
|
+
freshAddresses: [freshAddress],
|
|
365
|
+
name: rng.nextString(rng.nextInt(4, 34)),
|
|
366
|
+
starred: false,
|
|
367
|
+
used: false,
|
|
368
|
+
balance: new BigNumber(0),
|
|
369
|
+
spendableBalance: new BigNumber(0),
|
|
370
|
+
blockHeight: rng.nextInt(100000, 200000),
|
|
371
|
+
currency,
|
|
372
|
+
unit: rng.nextArrayItem(currency.units),
|
|
373
|
+
operationsCount: 0,
|
|
374
|
+
operations: [],
|
|
375
|
+
pendingOperations: [],
|
|
376
|
+
lastSyncDate: new Date(),
|
|
377
|
+
creationDate: new Date(),
|
|
378
|
+
swapHistory: Array(swapHistorySize)
|
|
379
|
+
.fill(null)
|
|
380
|
+
.map((_, i) => ({
|
|
381
|
+
provider: "changelly",
|
|
382
|
+
swapId: `swap-id-${i}`,
|
|
383
|
+
status: "finished",
|
|
384
|
+
receiverAccountId: "receiver-id",
|
|
385
|
+
operationId: "operation-id",
|
|
386
|
+
tokenId: "token-id",
|
|
387
|
+
fromAmount: new BigNumber("1000"),
|
|
388
|
+
toAmount: new BigNumber("2000"),
|
|
389
|
+
})),
|
|
390
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
391
|
+
...(withNft && {
|
|
392
|
+
nfts: Array(10)
|
|
393
|
+
.fill(null)
|
|
394
|
+
.map(() => createFixtureNFT(accountId, currency)),
|
|
395
|
+
}),
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
if (
|
|
399
|
+
[
|
|
400
|
+
"ethereum",
|
|
401
|
+
"ethereum_ropsten",
|
|
402
|
+
"ethereum_goerli",
|
|
403
|
+
"tron",
|
|
404
|
+
"algorand",
|
|
405
|
+
].includes(currency.id)
|
|
406
|
+
) {
|
|
407
|
+
const tokenCount =
|
|
408
|
+
typeof opts.subAccountsCount === "number"
|
|
409
|
+
? opts.subAccountsCount
|
|
410
|
+
: rng.nextInt(0, 8);
|
|
411
|
+
const all = listTokensForCryptoCurrency(account.currency).filter((t) =>
|
|
412
|
+
hardcodedMarketcap.includes(t.id)
|
|
413
|
+
);
|
|
414
|
+
const compoundReadyTokens = all.filter(findCompoundToken);
|
|
415
|
+
const notCompoundReadyTokens = all.filter((a) => !findCompoundToken(a));
|
|
416
|
+
// favorize the generation of compound tokens
|
|
417
|
+
const tokens = compoundReadyTokens
|
|
418
|
+
.concat(
|
|
419
|
+
// from random index
|
|
420
|
+
notCompoundReadyTokens.slice(
|
|
421
|
+
rng.nextInt(Math.floor(notCompoundReadyTokens.length / 2))
|
|
422
|
+
)
|
|
423
|
+
)
|
|
424
|
+
.slice(0, tokenCount);
|
|
425
|
+
account.subAccounts = tokens.map((token, i) =>
|
|
426
|
+
genTokenAccount(i, account, token)
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
completeResources?.(account, currency, address);
|
|
431
|
+
|
|
432
|
+
account.operations = Array(operationsSize)
|
|
433
|
+
.fill(null)
|
|
434
|
+
.reduce((ops: Operation[]) => {
|
|
435
|
+
const op = genOperation(account, account, ops, rng);
|
|
436
|
+
return ops.concat(op);
|
|
437
|
+
}, []);
|
|
438
|
+
|
|
439
|
+
if (withNft) {
|
|
440
|
+
const nftOperations = Array(5)
|
|
441
|
+
.fill(null)
|
|
442
|
+
.reduce((ops: Operation[]) => {
|
|
443
|
+
const index = Math.floor(Math.random() * (5 - 0 + 1) + 0);
|
|
444
|
+
|
|
445
|
+
if (account.nfts && account.nfts[index]) {
|
|
446
|
+
const { tokenId, contract, standard } = account.nfts[index];
|
|
447
|
+
const op = genNFTOperation(
|
|
448
|
+
account,
|
|
449
|
+
account,
|
|
450
|
+
ops,
|
|
451
|
+
rng,
|
|
452
|
+
contract,
|
|
453
|
+
standard,
|
|
454
|
+
tokenId
|
|
455
|
+
);
|
|
456
|
+
return ops.concat(op);
|
|
457
|
+
}
|
|
458
|
+
}, []);
|
|
459
|
+
|
|
460
|
+
account.operations = account.operations.concat(nftOperations);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
account.creationDate =
|
|
464
|
+
account.operations.length > 0
|
|
465
|
+
? account.operations[account.operations.length - 1].date
|
|
466
|
+
: new Date();
|
|
467
|
+
account.operationsCount = account.operations.length;
|
|
468
|
+
account.spendableBalance = account.balance = ensureNoNegative(
|
|
469
|
+
account.operations
|
|
470
|
+
);
|
|
471
|
+
account.used = !isAccountEmpty(account);
|
|
472
|
+
if (genAccountEnhanceOperations)
|
|
473
|
+
genAccountEnhanceOperations(account, currency, rng);
|
|
474
|
+
account.balanceHistoryCache = generateHistoryFromOperations(account);
|
|
475
|
+
return account;
|
|
476
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getCryptoCurrencyById } from "../../currencies";
|
|
2
|
+
import { createFixtureNFT, NFTs, NFTs_POLYGON } from "./nfts";
|
|
3
|
+
|
|
4
|
+
const POL = getCryptoCurrencyById("polygon");
|
|
5
|
+
describe("nfts fixtures", () => {
|
|
6
|
+
it("createFixtureNFT", () => {
|
|
7
|
+
const FIXTURE = createFixtureNFT("account-mock");
|
|
8
|
+
expect(FIXTURE.currencyId).toEqual("ethereum");
|
|
9
|
+
expect(FIXTURE.amount).not.toBeUndefined();
|
|
10
|
+
expect(FIXTURE.contract).not.toBeUndefined();
|
|
11
|
+
expect(FIXTURE.tokenId).not.toBeUndefined();
|
|
12
|
+
expect(FIXTURE.id).toContain("account-mock");
|
|
13
|
+
|
|
14
|
+
expect(
|
|
15
|
+
NFTs.map((nft) => nft.tokenId).includes(FIXTURE.tokenId)
|
|
16
|
+
).toBeTruthy();
|
|
17
|
+
|
|
18
|
+
const FIXTURE_POL = createFixtureNFT("account-mock-pol", POL);
|
|
19
|
+
expect(FIXTURE_POL.currencyId).toEqual("polygon");
|
|
20
|
+
|
|
21
|
+
expect(
|
|
22
|
+
NFTs_POLYGON.map((nft) => nft.tokenId).includes(FIXTURE_POL.tokenId)
|
|
23
|
+
).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|