@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,63 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import Transport from "@ledgerhq/hw-transport";
|
|
3
|
+
import { DerivationMode } from "../derivation";
|
|
4
|
+
import { Resolver } from "./getAddressWrapper";
|
|
5
|
+
import type { Result } from "../derivation";
|
|
6
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
7
|
+
import type { Account, AccountBridge, CurrencyBridge, Operation, ProtoNFT, SyncConfig } from "@ledgerhq/types-live";
|
|
8
|
+
type IterateResult = ({ transport, index, derivationsCache, derivationScheme, derivationMode, currency, }: {
|
|
9
|
+
transport: Transport;
|
|
10
|
+
index: number;
|
|
11
|
+
derivationsCache: Record<string, Result>;
|
|
12
|
+
derivationScheme: string;
|
|
13
|
+
derivationMode: DerivationMode;
|
|
14
|
+
currency: CryptoCurrency;
|
|
15
|
+
}) => Promise<Result | null>;
|
|
16
|
+
export type IterateResultBuilder = ({ result, // derivation on the "root" of the derivation
|
|
17
|
+
derivationMode, // identify the current derivation scheme
|
|
18
|
+
derivationScheme, }: {
|
|
19
|
+
result: Result;
|
|
20
|
+
derivationMode: DerivationMode;
|
|
21
|
+
derivationScheme: string;
|
|
22
|
+
}) => Promise<IterateResult>;
|
|
23
|
+
export type AccountShapeInfo = {
|
|
24
|
+
currency: CryptoCurrency;
|
|
25
|
+
address: string;
|
|
26
|
+
index: number;
|
|
27
|
+
initialAccount?: Account;
|
|
28
|
+
derivationPath: string;
|
|
29
|
+
derivationMode: DerivationMode;
|
|
30
|
+
transport?: Transport;
|
|
31
|
+
rest?: any;
|
|
32
|
+
};
|
|
33
|
+
export type GetAccountShape = (arg0: AccountShapeInfo, arg1: SyncConfig) => Promise<Partial<Account>>;
|
|
34
|
+
export declare const sameOp: (a: Operation, b: Operation) => boolean;
|
|
35
|
+
export declare function mergeOps(// existing operations. sorted (newer to older). deduped.
|
|
36
|
+
existing: Operation[], // new fetched operations. not sorted. not deduped. time is allowed to overlap inside existing.
|
|
37
|
+
newFetched: Operation[]): Operation[];
|
|
38
|
+
export declare const mergeNfts: (oldNfts: ProtoNFT[], newNfts: ProtoNFT[]) => ProtoNFT[];
|
|
39
|
+
export declare const makeSync: ({ getAccountShape, postSync, shouldMergeOps, }: {
|
|
40
|
+
getAccountShape: GetAccountShape;
|
|
41
|
+
postSync?: ((initial: Account, synced: Account) => Account) | undefined;
|
|
42
|
+
shouldMergeOps?: boolean | undefined;
|
|
43
|
+
}) => AccountBridge<any>["sync"];
|
|
44
|
+
export type DeviceCommunication = (deviceId: string) => <T>(job: (transport: Transport) => Observable<T>) => Observable<T>;
|
|
45
|
+
export declare const makeScanAccounts: ({ getAccountShape, deviceCommunication, buildIterateResult, getAddressFn, }: {
|
|
46
|
+
getAccountShape: GetAccountShape;
|
|
47
|
+
deviceCommunication: DeviceCommunication;
|
|
48
|
+
buildIterateResult?: IterateResultBuilder | undefined;
|
|
49
|
+
getAddressFn: Resolver;
|
|
50
|
+
}) => CurrencyBridge["scanAccounts"];
|
|
51
|
+
export declare function makeAccountBridgeReceive(getAddressFn: Resolver, deviceCommunication: DeviceCommunication, { injectGetAddressParams, }?: {
|
|
52
|
+
injectGetAddressParams?: (account: Account) => any;
|
|
53
|
+
}): (account: Account, option: {
|
|
54
|
+
verify?: boolean;
|
|
55
|
+
deviceId: string;
|
|
56
|
+
subAccountId?: string;
|
|
57
|
+
freshAddressIndex?: number;
|
|
58
|
+
}) => Observable<{
|
|
59
|
+
address: string;
|
|
60
|
+
path: string;
|
|
61
|
+
}>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=jsHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsHelpers.d.ts","sourceRoot":"","sources":["../../src/bridge/jsHelpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
var __values = (this && this.__values) || function(o) {
|
|
61
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
62
|
+
if (m) return m.call(o);
|
|
63
|
+
if (o && typeof o.length === "number") return {
|
|
64
|
+
next: function () {
|
|
65
|
+
if (o && i >= o.length) o = void 0;
|
|
66
|
+
return { value: o && o[i++], done: !o };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
70
|
+
};
|
|
71
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
72
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
73
|
+
};
|
|
74
|
+
exports.__esModule = true;
|
|
75
|
+
exports.makeAccountBridgeReceive = exports.makeScanAccounts = exports.makeSync = exports.mergeNfts = exports.mergeOps = exports.sameOp = void 0;
|
|
76
|
+
var isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
77
|
+
var bignumber_js_1 = require("bignumber.js");
|
|
78
|
+
var rxjs_1 = require("rxjs");
|
|
79
|
+
var logs_1 = require("@ledgerhq/logs");
|
|
80
|
+
var errors_1 = require("@ledgerhq/errors");
|
|
81
|
+
var derivation_1 = require("../derivation");
|
|
82
|
+
var account_1 = require("../account");
|
|
83
|
+
var errors_2 = require("../errors");
|
|
84
|
+
var getAddressWrapper_1 = __importDefault(require("./getAddressWrapper"));
|
|
85
|
+
// compare that two dates are roughly the same date in order to update the case it would have drastically changed
|
|
86
|
+
var sameDate = function (a, b) {
|
|
87
|
+
return Math.abs(a.getTime() - b.getTime()) < 1000 * 60 * 30;
|
|
88
|
+
};
|
|
89
|
+
// an operation is relatively immutable, however we saw that sometimes it can temporarily change due to reorg,..
|
|
90
|
+
var sameOp = function (a, b) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return a === b ||
|
|
93
|
+
(a.id === b.id && // hash, accountId, type are in id
|
|
94
|
+
(a.fee ? a.fee.isEqualTo(b.fee) : a.fee === b.fee) &&
|
|
95
|
+
(a.value ? a.value.isEqualTo(b.value) : a.value === b.value) &&
|
|
96
|
+
((_a = a.nftOperations) === null || _a === void 0 ? void 0 : _a.length) === ((_b = b.nftOperations) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
97
|
+
sameDate(a.date, b.date) &&
|
|
98
|
+
a.blockHeight === b.blockHeight &&
|
|
99
|
+
(0, isEqual_1["default"])(a.senders, b.senders) &&
|
|
100
|
+
(0, isEqual_1["default"])(a.recipients, b.recipients));
|
|
101
|
+
};
|
|
102
|
+
exports.sameOp = sameOp;
|
|
103
|
+
// efficiently prepend newFetched operations to existing operations
|
|
104
|
+
function mergeOps(// existing operations. sorted (newer to older). deduped.
|
|
105
|
+
existing, // new fetched operations. not sorted. not deduped. time is allowed to overlap inside existing.
|
|
106
|
+
newFetched) {
|
|
107
|
+
var e_1, _a, e_2, _b;
|
|
108
|
+
// there is new fetched
|
|
109
|
+
if (newFetched.length === 0)
|
|
110
|
+
return existing;
|
|
111
|
+
// efficient lookup map of id.
|
|
112
|
+
var existingIds = {};
|
|
113
|
+
try {
|
|
114
|
+
for (var existing_1 = __values(existing), existing_1_1 = existing_1.next(); !existing_1_1.done; existing_1_1 = existing_1.next()) {
|
|
115
|
+
var o = existing_1_1.value;
|
|
116
|
+
existingIds[o.id] = o;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
120
|
+
finally {
|
|
121
|
+
try {
|
|
122
|
+
if (existing_1_1 && !existing_1_1.done && (_a = existing_1["return"])) _a.call(existing_1);
|
|
123
|
+
}
|
|
124
|
+
finally { if (e_1) throw e_1.error; }
|
|
125
|
+
}
|
|
126
|
+
// only keep the newFetched that are not in existing. this array will be mutated
|
|
127
|
+
var newOps = newFetched
|
|
128
|
+
.filter(function (o) { return !existingIds[o.id] || !(0, exports.sameOp)(existingIds[o.id], o); })
|
|
129
|
+
.sort(function (a, b) { return b.date.valueOf() - a.date.valueOf(); });
|
|
130
|
+
// Deduplicate new ops to guarantee operations don't have dups
|
|
131
|
+
var newOpsIds = {};
|
|
132
|
+
newOps.forEach(function (op) {
|
|
133
|
+
newOpsIds[op.id] = op;
|
|
134
|
+
});
|
|
135
|
+
newOps = Object.values(newOpsIds);
|
|
136
|
+
// return existing when there is no real new operations
|
|
137
|
+
if (newOps.length === 0)
|
|
138
|
+
return existing;
|
|
139
|
+
// edge case, existing can be empty. return the sorted list.
|
|
140
|
+
if (existing.length === 0)
|
|
141
|
+
return newOps;
|
|
142
|
+
// building up merging the ops
|
|
143
|
+
var all = [];
|
|
144
|
+
try {
|
|
145
|
+
for (var existing_2 = __values(existing), existing_2_1 = existing_2.next(); !existing_2_1.done; existing_2_1 = existing_2.next()) {
|
|
146
|
+
var o = existing_2_1.value;
|
|
147
|
+
// prepend all the new ops that have higher date
|
|
148
|
+
while (newOps.length > 0 && newOps[0].date >= o.date) {
|
|
149
|
+
all.push(newOps.shift());
|
|
150
|
+
}
|
|
151
|
+
if (!newOpsIds[o.id]) {
|
|
152
|
+
all.push(o);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
157
|
+
finally {
|
|
158
|
+
try {
|
|
159
|
+
if (existing_2_1 && !existing_2_1.done && (_b = existing_2["return"])) _b.call(existing_2);
|
|
160
|
+
}
|
|
161
|
+
finally { if (e_2) throw e_2.error; }
|
|
162
|
+
}
|
|
163
|
+
return all;
|
|
164
|
+
}
|
|
165
|
+
exports.mergeOps = mergeOps;
|
|
166
|
+
var mergeNfts = function (oldNfts, newNfts) {
|
|
167
|
+
// Getting a map of id => NFT
|
|
168
|
+
var newNftsPerId = {};
|
|
169
|
+
newNfts.forEach(function (n) {
|
|
170
|
+
newNftsPerId[n.id] = n;
|
|
171
|
+
});
|
|
172
|
+
// copying the argument to avoid mutating it
|
|
173
|
+
var nfts = oldNfts.slice();
|
|
174
|
+
for (var i = 0; i < nfts.length; i++) {
|
|
175
|
+
var nft = nfts[i];
|
|
176
|
+
// The NFTs are the same, do don't anything
|
|
177
|
+
if (!newNftsPerId[nft.id]) {
|
|
178
|
+
nfts.splice(i, 1);
|
|
179
|
+
i--;
|
|
180
|
+
}
|
|
181
|
+
else if (!(0, isEqual_1["default"])(nft, newNftsPerId[nft.id])) {
|
|
182
|
+
// Use the new NFT instead
|
|
183
|
+
nfts[i] = newNftsPerId[nft.id];
|
|
184
|
+
}
|
|
185
|
+
// Delete it from the newNfts to keep only the un-added ones at the end
|
|
186
|
+
delete newNftsPerId[nft.id];
|
|
187
|
+
}
|
|
188
|
+
// Prepending newNfts to respect nfts's newest to oldest order
|
|
189
|
+
return Object.values(newNftsPerId).concat(nfts);
|
|
190
|
+
};
|
|
191
|
+
exports.mergeNfts = mergeNfts;
|
|
192
|
+
var makeSync = function (_a) {
|
|
193
|
+
var getAccountShape = _a.getAccountShape, _b = _a.postSync, postSync = _b === void 0 ? function (_, a) { return a; } : _b, _c = _a.shouldMergeOps, shouldMergeOps = _c === void 0 ? true : _c;
|
|
194
|
+
return function (initial, syncConfig) {
|
|
195
|
+
return rxjs_1.Observable.create(function (o) {
|
|
196
|
+
function main() {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
var accountId, needClear, freshAddressPath, shape_1, updater, e_3;
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
switch (_a.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
accountId = (0, account_1.encodeAccountId)({
|
|
203
|
+
type: "js",
|
|
204
|
+
version: "2",
|
|
205
|
+
currencyId: initial.currency.id,
|
|
206
|
+
xpubOrAddress: initial.xpub || initial.freshAddress,
|
|
207
|
+
derivationMode: initial.derivationMode
|
|
208
|
+
});
|
|
209
|
+
needClear = initial.id !== accountId;
|
|
210
|
+
_a.label = 1;
|
|
211
|
+
case 1:
|
|
212
|
+
_a.trys.push([1, 3, , 4]);
|
|
213
|
+
freshAddressPath = (0, derivation_1.getSeedIdentifierDerivation)(initial.currency, initial.derivationMode);
|
|
214
|
+
return [4 /*yield*/, getAccountShape({
|
|
215
|
+
currency: initial.currency,
|
|
216
|
+
index: initial.index,
|
|
217
|
+
address: initial.freshAddress,
|
|
218
|
+
derivationPath: freshAddressPath,
|
|
219
|
+
derivationMode: initial.derivationMode,
|
|
220
|
+
initialAccount: needClear ? (0, account_1.clearAccount)(initial) : initial
|
|
221
|
+
}, syncConfig)];
|
|
222
|
+
case 2:
|
|
223
|
+
shape_1 = _a.sent();
|
|
224
|
+
updater = function (acc) {
|
|
225
|
+
var a = acc; // a is a immutable version of Account, based on acc
|
|
226
|
+
if (needClear) {
|
|
227
|
+
a = (0, account_1.clearAccount)(acc);
|
|
228
|
+
}
|
|
229
|
+
// FIXME reconsider doing mergeOps here. work is redundant for impl like eth
|
|
230
|
+
var operations = shouldMergeOps
|
|
231
|
+
? mergeOps(a.operations, shape_1.operations || [])
|
|
232
|
+
: shape_1.operations || [];
|
|
233
|
+
a = postSync(a, __assign(__assign(__assign(__assign({}, a), { id: accountId, spendableBalance: shape_1.balance || a.balance, operationsCount: shape_1.operationsCount || operations.length, lastSyncDate: new Date(), creationDate: operations.length > 0
|
|
234
|
+
? operations[operations.length - 1].date
|
|
235
|
+
: new Date() }), shape_1), { operations: operations, pendingOperations: a.pendingOperations.filter(function (op) {
|
|
236
|
+
return (0, account_1.shouldRetainPendingOperation)(a, op);
|
|
237
|
+
}) }));
|
|
238
|
+
a = (0, account_1.recalculateAccountBalanceHistories)(a, acc);
|
|
239
|
+
if (!a.used) {
|
|
240
|
+
a.used = !(0, account_1.isAccountEmpty)(a);
|
|
241
|
+
}
|
|
242
|
+
return a;
|
|
243
|
+
};
|
|
244
|
+
o.next(updater);
|
|
245
|
+
o.complete();
|
|
246
|
+
return [3 /*break*/, 4];
|
|
247
|
+
case 3:
|
|
248
|
+
e_3 = _a.sent();
|
|
249
|
+
o.error(e_3);
|
|
250
|
+
return [3 /*break*/, 4];
|
|
251
|
+
case 4: return [2 /*return*/];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
main();
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
exports.makeSync = makeSync;
|
|
261
|
+
var defaultIterateResultBuilder = function (getAddressFn) { return function () {
|
|
262
|
+
return Promise.resolve(function (_a) {
|
|
263
|
+
var transport = _a.transport, index = _a.index, derivationsCache = _a.derivationsCache, derivationScheme = _a.derivationScheme, derivationMode = _a.derivationMode, currency = _a.currency;
|
|
264
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
265
|
+
var freshAddressPath, res;
|
|
266
|
+
return __generator(this, function (_b) {
|
|
267
|
+
switch (_b.label) {
|
|
268
|
+
case 0:
|
|
269
|
+
freshAddressPath = (0, derivation_1.runDerivationScheme)(derivationScheme, currency, {
|
|
270
|
+
account: index
|
|
271
|
+
});
|
|
272
|
+
res = derivationsCache[freshAddressPath];
|
|
273
|
+
if (!!res) return [3 /*break*/, 2];
|
|
274
|
+
return [4 /*yield*/, (0, getAddressWrapper_1["default"])(getAddressFn)(transport, {
|
|
275
|
+
currency: currency,
|
|
276
|
+
path: freshAddressPath,
|
|
277
|
+
derivationMode: derivationMode
|
|
278
|
+
})];
|
|
279
|
+
case 1:
|
|
280
|
+
res = _b.sent();
|
|
281
|
+
derivationsCache[freshAddressPath] = res;
|
|
282
|
+
_b.label = 2;
|
|
283
|
+
case 2: return [2 /*return*/, res];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}; };
|
|
289
|
+
var makeScanAccounts = function (_a) {
|
|
290
|
+
var getAccountShape = _a.getAccountShape, deviceCommunication = _a.deviceCommunication, buildIterateResult = _a.buildIterateResult, getAddressFn = _a.getAddressFn;
|
|
291
|
+
return function (_a) {
|
|
292
|
+
var currency = _a.currency, deviceId = _a.deviceId, syncConfig = _a.syncConfig;
|
|
293
|
+
return deviceCommunication(deviceId)(function (transport) {
|
|
294
|
+
return rxjs_1.Observable.create(function (o) {
|
|
295
|
+
var finished = false;
|
|
296
|
+
var unsubscribe = function () {
|
|
297
|
+
finished = true;
|
|
298
|
+
};
|
|
299
|
+
var derivationsCache = {};
|
|
300
|
+
function stepAccount(index, res, derivationMode, seedIdentifier, transport) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
302
|
+
var address, freshAddressPath, rest, accountShape, freshAddress, operations, operationsCount, creationDate, balance, spendableBalance, initialAccount, account, showNewAccount;
|
|
303
|
+
return __generator(this, function (_a) {
|
|
304
|
+
switch (_a.label) {
|
|
305
|
+
case 0:
|
|
306
|
+
if (finished)
|
|
307
|
+
return [2 /*return*/];
|
|
308
|
+
address = res.address, freshAddressPath = res.path, rest = __rest(res, ["address", "path"]);
|
|
309
|
+
return [4 /*yield*/, getAccountShape({
|
|
310
|
+
transport: transport,
|
|
311
|
+
currency: currency,
|
|
312
|
+
index: index,
|
|
313
|
+
address: address,
|
|
314
|
+
derivationPath: freshAddressPath,
|
|
315
|
+
derivationMode: derivationMode,
|
|
316
|
+
rest: rest
|
|
317
|
+
}, syncConfig)];
|
|
318
|
+
case 1:
|
|
319
|
+
accountShape = _a.sent();
|
|
320
|
+
if (finished)
|
|
321
|
+
return [2 /*return*/];
|
|
322
|
+
freshAddress = address;
|
|
323
|
+
operations = accountShape.operations || [];
|
|
324
|
+
operationsCount = accountShape.operationsCount || operations.length;
|
|
325
|
+
creationDate = operations.length > 0
|
|
326
|
+
? operations[operations.length - 1].date
|
|
327
|
+
: new Date();
|
|
328
|
+
balance = accountShape.balance || new bignumber_js_1.BigNumber(0);
|
|
329
|
+
spendableBalance = accountShape.spendableBalance || new bignumber_js_1.BigNumber(0);
|
|
330
|
+
if (!accountShape.id)
|
|
331
|
+
throw new Error("account ID must be provided");
|
|
332
|
+
if (balance.isNaN())
|
|
333
|
+
throw new Error("invalid balance NaN");
|
|
334
|
+
initialAccount = {
|
|
335
|
+
type: "Account",
|
|
336
|
+
id: accountShape.id,
|
|
337
|
+
seedIdentifier: seedIdentifier,
|
|
338
|
+
freshAddress: freshAddress,
|
|
339
|
+
freshAddressPath: freshAddressPath,
|
|
340
|
+
freshAddresses: [
|
|
341
|
+
{
|
|
342
|
+
address: freshAddress,
|
|
343
|
+
derivationPath: freshAddressPath
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
derivationMode: derivationMode,
|
|
347
|
+
name: "",
|
|
348
|
+
starred: false,
|
|
349
|
+
used: false,
|
|
350
|
+
index: index,
|
|
351
|
+
currency: currency,
|
|
352
|
+
operationsCount: operationsCount,
|
|
353
|
+
operations: [],
|
|
354
|
+
swapHistory: [],
|
|
355
|
+
pendingOperations: [],
|
|
356
|
+
unit: currency.units[0],
|
|
357
|
+
lastSyncDate: new Date(),
|
|
358
|
+
creationDate: creationDate,
|
|
359
|
+
// overrides
|
|
360
|
+
balance: balance,
|
|
361
|
+
spendableBalance: spendableBalance,
|
|
362
|
+
blockHeight: 0,
|
|
363
|
+
balanceHistoryCache: account_1.emptyHistoryCache
|
|
364
|
+
};
|
|
365
|
+
account = __assign(__assign({}, initialAccount), accountShape);
|
|
366
|
+
if (account.balanceHistoryCache === account_1.emptyHistoryCache) {
|
|
367
|
+
account.balanceHistoryCache =
|
|
368
|
+
(0, account_1.generateHistoryFromOperations)(account);
|
|
369
|
+
}
|
|
370
|
+
if (!account.used) {
|
|
371
|
+
account.used = !(0, account_1.isAccountEmpty)(account);
|
|
372
|
+
}
|
|
373
|
+
// Bitcoin needs to compute the freshAddressPath itself,
|
|
374
|
+
// so we update it afterwards
|
|
375
|
+
if (account === null || account === void 0 ? void 0 : account.freshAddressPath) {
|
|
376
|
+
res.address = account.freshAddress;
|
|
377
|
+
derivationsCache[account.freshAddressPath] = res;
|
|
378
|
+
}
|
|
379
|
+
(0, logs_1.log)("scanAccounts", "derivationsCache", res);
|
|
380
|
+
(0, logs_1.log)("scanAccounts", "scanning ".concat(currency.id, " at ").concat(freshAddressPath, ": ").concat(res.address, " resulted of ").concat(account
|
|
381
|
+
? "Account with ".concat(account.operations.length, " txs")
|
|
382
|
+
: "no account"));
|
|
383
|
+
if (!account)
|
|
384
|
+
return [2 /*return*/];
|
|
385
|
+
account.name = !account.used
|
|
386
|
+
? (0, account_1.getNewAccountPlaceholderName)({
|
|
387
|
+
currency: currency,
|
|
388
|
+
index: index,
|
|
389
|
+
derivationMode: derivationMode
|
|
390
|
+
})
|
|
391
|
+
: (0, account_1.getAccountPlaceholderName)({
|
|
392
|
+
currency: currency,
|
|
393
|
+
index: index,
|
|
394
|
+
derivationMode: derivationMode
|
|
395
|
+
});
|
|
396
|
+
showNewAccount = (0, account_1.shouldShowNewAccount)(currency, derivationMode);
|
|
397
|
+
if (account.used || showNewAccount) {
|
|
398
|
+
(0, logs_1.log)("debug", "Emit 'discovered' event for a new account found. AccountUsed: ".concat(account.used, " - showNewAccount: ").concat(showNewAccount));
|
|
399
|
+
o.next({
|
|
400
|
+
type: "discovered",
|
|
401
|
+
account: account
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
return [2 /*return*/, account];
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
if (buildIterateResult === undefined) {
|
|
410
|
+
buildIterateResult = defaultIterateResultBuilder(getAddressFn);
|
|
411
|
+
}
|
|
412
|
+
function main() {
|
|
413
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
414
|
+
var derivationModes, derivationModes_1, derivationModes_1_1, derivationMode, path, result, e_4, seedIdentifier, emptyCount, mandatoryEmptyAccountSkip, derivationScheme, stopAt, startsAt, iterateResult, index, res, account, e_5_1, e_6;
|
|
415
|
+
var e_5, _a;
|
|
416
|
+
return __generator(this, function (_b) {
|
|
417
|
+
switch (_b.label) {
|
|
418
|
+
case 0:
|
|
419
|
+
_b.trys.push([0, 17, , 18]);
|
|
420
|
+
derivationModes = (0, derivation_1.getDerivationModesForCurrency)(currency);
|
|
421
|
+
_b.label = 1;
|
|
422
|
+
case 1:
|
|
423
|
+
_b.trys.push([1, 14, 15, 16]);
|
|
424
|
+
derivationModes_1 = __values(derivationModes), derivationModes_1_1 = derivationModes_1.next();
|
|
425
|
+
_b.label = 2;
|
|
426
|
+
case 2:
|
|
427
|
+
if (!!derivationModes_1_1.done) return [3 /*break*/, 13];
|
|
428
|
+
derivationMode = derivationModes_1_1.value;
|
|
429
|
+
if (finished)
|
|
430
|
+
return [3 /*break*/, 13];
|
|
431
|
+
path = (0, derivation_1.getSeedIdentifierDerivation)(currency, derivationMode);
|
|
432
|
+
(0, logs_1.log)("scanAccounts", "scanning ".concat(currency.id, " on derivationMode=").concat(derivationMode));
|
|
433
|
+
result = derivationsCache[path];
|
|
434
|
+
if (!!result) return [3 /*break*/, 6];
|
|
435
|
+
_b.label = 3;
|
|
436
|
+
case 3:
|
|
437
|
+
_b.trys.push([3, 5, , 6]);
|
|
438
|
+
return [4 /*yield*/, getAddressFn(transport, {
|
|
439
|
+
currency: currency,
|
|
440
|
+
path: path,
|
|
441
|
+
derivationMode: derivationMode
|
|
442
|
+
})];
|
|
443
|
+
case 4:
|
|
444
|
+
result = _b.sent();
|
|
445
|
+
derivationsCache[path] = result;
|
|
446
|
+
return [3 /*break*/, 6];
|
|
447
|
+
case 5:
|
|
448
|
+
e_4 = _b.sent();
|
|
449
|
+
if (e_4 instanceof errors_2.UnsupportedDerivation) {
|
|
450
|
+
(0, logs_1.log)("scanAccounts", "ignore derivationMode=" + derivationMode);
|
|
451
|
+
return [3 /*break*/, 12];
|
|
452
|
+
}
|
|
453
|
+
throw e_4;
|
|
454
|
+
case 6:
|
|
455
|
+
if (!result)
|
|
456
|
+
return [3 /*break*/, 12];
|
|
457
|
+
seedIdentifier = result.publicKey;
|
|
458
|
+
emptyCount = 0;
|
|
459
|
+
mandatoryEmptyAccountSkip = (0, derivation_1.getMandatoryEmptyAccountSkip)(derivationMode);
|
|
460
|
+
derivationScheme = (0, derivation_1.getDerivationScheme)({
|
|
461
|
+
derivationMode: derivationMode,
|
|
462
|
+
currency: currency
|
|
463
|
+
});
|
|
464
|
+
stopAt = (0, derivation_1.isIterableDerivationMode)(derivationMode)
|
|
465
|
+
? 255
|
|
466
|
+
: 1;
|
|
467
|
+
startsAt = (0, derivation_1.getDerivationModeStartsAt)(derivationMode);
|
|
468
|
+
(0, logs_1.log)("debug", "start scanning account process. MandatoryEmptyAccountSkip ".concat(mandatoryEmptyAccountSkip, " / StartsAt: ").concat(startsAt, " - StopAt: ").concat(stopAt));
|
|
469
|
+
return [4 /*yield*/, buildIterateResult({
|
|
470
|
+
result: result,
|
|
471
|
+
derivationMode: derivationMode,
|
|
472
|
+
derivationScheme: derivationScheme
|
|
473
|
+
})];
|
|
474
|
+
case 7:
|
|
475
|
+
iterateResult = _b.sent();
|
|
476
|
+
index = startsAt;
|
|
477
|
+
_b.label = 8;
|
|
478
|
+
case 8:
|
|
479
|
+
if (!(index < stopAt)) return [3 /*break*/, 12];
|
|
480
|
+
(0, logs_1.log)("debug", "start to scan a new account. Index: ".concat(index));
|
|
481
|
+
if (finished) {
|
|
482
|
+
(0, logs_1.log)("debug", "new account scanning process has been finished");
|
|
483
|
+
return [3 /*break*/, 12];
|
|
484
|
+
}
|
|
485
|
+
if (!(0, derivation_1.derivationModeSupportsIndex)(derivationMode, index))
|
|
486
|
+
return [3 /*break*/, 11];
|
|
487
|
+
return [4 /*yield*/, iterateResult({
|
|
488
|
+
transport: transport,
|
|
489
|
+
index: index,
|
|
490
|
+
derivationsCache: derivationsCache,
|
|
491
|
+
derivationMode: derivationMode,
|
|
492
|
+
derivationScheme: derivationScheme,
|
|
493
|
+
currency: currency
|
|
494
|
+
})];
|
|
495
|
+
case 9:
|
|
496
|
+
res = _b.sent();
|
|
497
|
+
if (!res)
|
|
498
|
+
return [3 /*break*/, 12];
|
|
499
|
+
return [4 /*yield*/, stepAccount(index, res, derivationMode, seedIdentifier, transport)];
|
|
500
|
+
case 10:
|
|
501
|
+
account = _b.sent();
|
|
502
|
+
if (account && !account.used) {
|
|
503
|
+
if (emptyCount >= mandatoryEmptyAccountSkip)
|
|
504
|
+
return [3 /*break*/, 12];
|
|
505
|
+
emptyCount++;
|
|
506
|
+
}
|
|
507
|
+
_b.label = 11;
|
|
508
|
+
case 11:
|
|
509
|
+
index++;
|
|
510
|
+
return [3 /*break*/, 8];
|
|
511
|
+
case 12:
|
|
512
|
+
derivationModes_1_1 = derivationModes_1.next();
|
|
513
|
+
return [3 /*break*/, 2];
|
|
514
|
+
case 13: return [3 /*break*/, 16];
|
|
515
|
+
case 14:
|
|
516
|
+
e_5_1 = _b.sent();
|
|
517
|
+
e_5 = { error: e_5_1 };
|
|
518
|
+
return [3 /*break*/, 16];
|
|
519
|
+
case 15:
|
|
520
|
+
try {
|
|
521
|
+
if (derivationModes_1_1 && !derivationModes_1_1.done && (_a = derivationModes_1["return"])) _a.call(derivationModes_1);
|
|
522
|
+
}
|
|
523
|
+
finally { if (e_5) throw e_5.error; }
|
|
524
|
+
return [7 /*endfinally*/];
|
|
525
|
+
case 16:
|
|
526
|
+
o.complete();
|
|
527
|
+
return [3 /*break*/, 18];
|
|
528
|
+
case 17:
|
|
529
|
+
e_6 = _b.sent();
|
|
530
|
+
o.error(e_6);
|
|
531
|
+
return [3 /*break*/, 18];
|
|
532
|
+
case 18: return [2 /*return*/];
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
main();
|
|
538
|
+
return unsubscribe;
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
exports.makeScanAccounts = makeScanAccounts;
|
|
544
|
+
function makeAccountBridgeReceive(getAddressFn, deviceCommunication, _a) {
|
|
545
|
+
var _b = _a === void 0 ? {} : _a, injectGetAddressParams = _b.injectGetAddressParams;
|
|
546
|
+
return function (account, _a) {
|
|
547
|
+
var verify = _a.verify, deviceId = _a.deviceId, freshAddressIndex = _a.freshAddressIndex;
|
|
548
|
+
var freshAddress;
|
|
549
|
+
if (freshAddressIndex !== undefined && freshAddressIndex !== null) {
|
|
550
|
+
freshAddress = account.freshAddresses[freshAddressIndex];
|
|
551
|
+
if (freshAddress === undefined) {
|
|
552
|
+
throw new errors_2.FreshAddressIndexInvalid();
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
var arg = __assign({ verify: verify, currency: account.currency, derivationMode: account.derivationMode, path: freshAddress
|
|
556
|
+
? freshAddress.derivationPath
|
|
557
|
+
: account.freshAddressPath }, (injectGetAddressParams && injectGetAddressParams(account)));
|
|
558
|
+
return deviceCommunication(deviceId)(function (transport) {
|
|
559
|
+
return (0, rxjs_1.from)(getAddressFn(transport, arg).then(function (r) {
|
|
560
|
+
var accountAddress = freshAddress
|
|
561
|
+
? freshAddress.address
|
|
562
|
+
: account.freshAddress;
|
|
563
|
+
if (r.address !== accountAddress) {
|
|
564
|
+
throw new errors_1.WrongDeviceForAccount("WrongDeviceForAccount ".concat(account.name), {
|
|
565
|
+
accountName: account.name
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
return r;
|
|
569
|
+
}));
|
|
570
|
+
});
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
exports.makeAccountBridgeReceive = makeAccountBridgeReceive;
|
|
574
|
+
//# sourceMappingURL=jsHelpers.js.map
|