@ledgerhq/coin-framework 0.0.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/account/accountId.d.ts +16 -0
- package/lib/account/accountId.d.ts.map +1 -0
- package/lib/account/accountId.js +85 -0
- package/lib/account/accountId.js.map +1 -0
- package/lib/account/accountName.d.ts +14 -0
- package/lib/account/accountName.d.ts.map +1 -0
- package/lib/account/accountName.js +17 -0
- package/lib/account/accountName.js.map +1 -0
- package/lib/account/addAccounts.d.ts +35 -0
- package/lib/account/addAccounts.d.ts.map +1 -0
- package/lib/account/addAccounts.js +209 -0
- package/lib/account/addAccounts.js.map +1 -0
- package/lib/account/balanceHistoryCache.d.ts +25 -0
- package/lib/account/balanceHistoryCache.d.ts.map +1 -0
- package/lib/account/balanceHistoryCache.js +115 -0
- package/lib/account/balanceHistoryCache.js.map +1 -0
- package/lib/account/groupOperations.d.ts +17 -0
- package/lib/account/groupOperations.d.ts.map +1 -0
- package/lib/account/groupOperations.js +127 -0
- package/lib/account/groupOperations.js.map +1 -0
- package/lib/account/helpers.d.ts +44 -0
- package/lib/account/helpers.d.ts.map +1 -0
- package/lib/account/helpers.js +333 -0
- package/lib/account/helpers.js.map +1 -0
- package/lib/account/helpers.test.d.ts +2 -0
- package/lib/account/helpers.test.d.ts.map +1 -0
- package/lib/account/helpers.test.js +366 -0
- package/lib/account/helpers.test.js.map +1 -0
- package/lib/account/index.d.ts +11 -0
- package/lib/account/index.d.ts.map +1 -0
- package/lib/account/index.js +27 -0
- package/lib/account/index.js.map +1 -0
- package/lib/account/ordering.d.ts +10 -0
- package/lib/account/ordering.d.ts.map +1 -0
- package/lib/account/ordering.js +110 -0
- package/lib/account/ordering.js.map +1 -0
- package/lib/account/pending.d.ts +33 -0
- package/lib/account/pending.d.ts.map +1 -0
- package/lib/account/pending.js +64 -0
- package/lib/account/pending.js.map +1 -0
- package/lib/account/serialization.d.ts +6 -0
- package/lib/account/serialization.d.ts.map +1 -0
- package/lib/account/serialization.js +118 -0
- package/lib/account/serialization.js.map +1 -0
- package/lib/account/support.d.ts +9 -0
- package/lib/account/support.d.ts.map +1 -0
- package/lib/account/support.js +72 -0
- package/lib/account/support.js.map +1 -0
- package/lib/account.test.d.ts +2 -0
- package/lib/account.test.d.ts.map +1 -0
- package/lib/account.test.js +257 -0
- package/lib/account.test.js.map +1 -0
- package/lib/bot/bot-test-context.d.ts +3 -0
- package/lib/bot/bot-test-context.d.ts.map +1 -0
- package/lib/bot/bot-test-context.js +26 -0
- package/lib/bot/bot-test-context.js.map +1 -0
- package/lib/bot/bot-test-context.test.d.ts +2 -0
- package/lib/bot/bot-test-context.test.d.ts.map +1 -0
- package/lib/bot/bot-test-context.test.js +41 -0
- package/lib/bot/bot-test-context.test.js.map +1 -0
- package/lib/bot/formatters.d.ts +2 -0
- package/lib/bot/formatters.d.ts.map +1 -0
- package/lib/bot/formatters.js +31 -0
- package/lib/bot/formatters.js.map +1 -0
- package/lib/bot/specs.d.ts +50 -0
- package/lib/bot/specs.d.ts.map +1 -0
- package/lib/bot/specs.js +204 -0
- package/lib/bot/specs.js.map +1 -0
- package/lib/bot/types.d.ts +178 -0
- package/lib/bot/types.d.ts.map +1 -0
- package/lib/bot/types.js +3 -0
- package/lib/bot/types.js.map +1 -0
- package/lib/bridge/getAddressWrapper.d.ts +6 -0
- package/lib/bridge/getAddressWrapper.d.ts.map +1 -0
- package/lib/bridge/getAddressWrapper.js +27 -0
- package/lib/bridge/getAddressWrapper.js.map +1 -0
- package/lib/bridge/jsHelpers.d.ts +63 -0
- package/lib/bridge/jsHelpers.d.ts.map +1 -0
- package/lib/bridge/jsHelpers.js +574 -0
- package/lib/bridge/jsHelpers.js.map +1 -0
- package/lib/cache.d.ts +10 -0
- package/lib/cache.d.ts.map +1 -0
- package/lib/cache.js +100 -0
- package/lib/cache.js.map +1 -0
- package/lib/cross.d.ts +42 -0
- package/lib/cross.d.ts.map +1 -0
- package/lib/cross.js +254 -0
- package/lib/cross.js.map +1 -0
- package/lib/cross.test.d.ts +2 -0
- package/lib/cross.test.d.ts.map +1 -0
- package/lib/cross.test.js +99 -0
- package/lib/cross.test.js.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.d.ts +8 -0
- package/lib/currencies/BigNumberToLocaleString.d.ts.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.js +65 -0
- package/lib/currencies/BigNumberToLocaleString.js.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.test.d.ts +2 -0
- package/lib/currencies/BigNumberToLocaleString.test.d.ts.map +1 -0
- package/lib/currencies/BigNumberToLocaleString.test.js +108 -0
- package/lib/currencies/BigNumberToLocaleString.test.js.map +1 -0
- package/lib/currencies/CurrencyURIScheme.d.ts +13 -0
- package/lib/currencies/CurrencyURIScheme.d.ts.map +1 -0
- package/lib/currencies/CurrencyURIScheme.js +124 -0
- package/lib/currencies/CurrencyURIScheme.js.map +1 -0
- package/lib/currencies/chopCurrencyUnitDecimals.d.ts +3 -0
- package/lib/currencies/chopCurrencyUnitDecimals.d.ts.map +1 -0
- package/lib/currencies/chopCurrencyUnitDecimals.js +29 -0
- package/lib/currencies/chopCurrencyUnitDecimals.js.map +1 -0
- package/lib/currencies/formatCurrencyUnit.d.ts +33 -0
- package/lib/currencies/formatCurrencyUnit.d.ts.map +1 -0
- package/lib/currencies/formatCurrencyUnit.js +126 -0
- package/lib/currencies/formatCurrencyUnit.js.map +1 -0
- package/lib/currencies/formatShort.d.ts +8 -0
- package/lib/currencies/formatShort.d.ts.map +1 -0
- package/lib/currencies/formatShort.js +27 -0
- package/lib/currencies/formatShort.js.map +1 -0
- package/lib/currencies/index.d.ts +13 -0
- package/lib/currencies/index.d.ts.map +1 -0
- package/lib/currencies/index.js +65 -0
- package/lib/currencies/index.js.map +1 -0
- package/lib/currencies/localeUtility.d.ts +8 -0
- package/lib/currencies/localeUtility.d.ts.map +1 -0
- package/lib/currencies/localeUtility.js +49 -0
- package/lib/currencies/localeUtility.js.map +1 -0
- package/lib/currencies/parseCurrencyUnit.d.ts +4 -0
- package/lib/currencies/parseCurrencyUnit.d.ts.map +1 -0
- package/lib/currencies/parseCurrencyUnit.js +18 -0
- package/lib/currencies/parseCurrencyUnit.js.map +1 -0
- package/lib/currencies/sanitizeValueString.d.ts +6 -0
- package/lib/currencies/sanitizeValueString.d.ts.map +1 -0
- package/lib/currencies/sanitizeValueString.js +56 -0
- package/lib/currencies/sanitizeValueString.js.map +1 -0
- package/lib/currencies/support.d.ts +8 -0
- package/lib/currencies/support.d.ts.map +1 -0
- package/lib/currencies/support.js +101 -0
- package/lib/currencies/support.js.map +1 -0
- package/lib/currencies/valueFromUnit.d.ts +9 -0
- package/lib/currencies/valueFromUnit.d.ts.map +1 -0
- package/lib/currencies/valueFromUnit.js +14 -0
- package/lib/currencies/valueFromUnit.js.map +1 -0
- package/lib/derivation.d.ts +232 -0
- package/lib/derivation.d.ts.map +1 -0
- package/lib/derivation.js +501 -0
- package/lib/derivation.js.map +1 -0
- package/lib/env.d.ts +30 -0
- package/lib/env.d.ts.map +1 -0
- package/lib/env.js +783 -0
- package/lib/env.js.map +1 -0
- package/lib/errors.d.ts +7 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +7 -0
- package/lib/errors.js.map +1 -0
- package/lib/errors.test.d.ts +2 -0
- package/lib/errors.test.d.ts.map +1 -0
- package/lib/errors.test.js +20 -0
- package/lib/errors.test.js.map +1 -0
- package/lib/mocks/account.d.ts +25 -0
- package/lib/mocks/account.d.ts.map +1 -0
- package/lib/mocks/account.js +368 -0
- package/lib/mocks/account.js.map +1 -0
- package/lib/mocks/fixtures/nfts.d.ts +27 -0
- package/lib/mocks/fixtures/nfts.d.ts.map +1 -0
- package/lib/mocks/fixtures/nfts.js +398 -0
- package/lib/mocks/fixtures/nfts.js.map +1 -0
- package/lib/mocks/fixtures/nfts.test.d.ts +2 -0
- package/lib/mocks/fixtures/nfts.test.d.ts.map +1 -0
- package/lib/mocks/fixtures/nfts.test.js +20 -0
- package/lib/mocks/fixtures/nfts.test.js.map +1 -0
- package/lib/mocks/helpers.d.ts +15 -0
- package/lib/mocks/helpers.d.ts.map +1 -0
- package/lib/mocks/helpers.js +32 -0
- package/lib/mocks/helpers.js.map +1 -0
- package/lib/network.d.ts +5 -0
- package/lib/network.d.ts.map +1 -0
- package/lib/network.js +125 -0
- package/lib/network.js.map +1 -0
- package/lib/nft/nftId.d.ts +8 -0
- package/lib/nft/nftId.d.ts.map +1 -0
- package/lib/nft/nftId.js +34 -0
- package/lib/nft/nftId.js.map +1 -0
- package/lib/operation.d.ts +24 -0
- package/lib/operation.d.ts.map +1 -0
- package/lib/operation.js +183 -0
- package/lib/operation.js.map +1 -0
- package/lib/promise.d.ts +21 -0
- package/lib/promise.d.ts.map +1 -0
- package/lib/promise.js +187 -0
- package/lib/promise.js.map +1 -0
- package/lib/promise.test.d.ts +2 -0
- package/lib/promise.test.d.ts.map +1 -0
- package/lib/promise.test.js +72 -0
- package/lib/promise.test.js.map +1 -0
- package/lib/rangeDates.d.ts +29 -0
- package/lib/rangeDates.d.ts.map +1 -0
- package/lib/rangeDates.js +94 -0
- package/lib/rangeDates.js.map +1 -0
- package/lib/rangeDates.test.d.ts +2 -0
- package/lib/rangeDates.test.d.ts.map +1 -0
- package/lib/rangeDates.test.js +51 -0
- package/lib/rangeDates.test.js.map +1 -0
- package/lib/test-helpers/staticTime.d.ts +2 -0
- package/lib/test-helpers/staticTime.d.ts.map +1 -0
- package/lib/test-helpers/staticTime.js +10 -0
- package/lib/test-helpers/staticTime.js.map +1 -0
- package/lib/transaction/common.d.ts +26 -0
- package/lib/transaction/common.d.ts.map +1 -0
- package/lib/transaction/common.js +123 -0
- package/lib/transaction/common.js.map +1 -0
- package/lib-es/account/accountId.d.ts +16 -0
- package/lib-es/account/accountId.d.ts.map +1 -0
- package/lib-es/account/accountId.js +74 -0
- package/lib-es/account/accountId.js.map +1 -0
- package/lib-es/account/accountName.d.ts +14 -0
- package/lib-es/account/accountName.d.ts.map +1 -0
- package/lib-es/account/accountName.js +12 -0
- package/lib-es/account/accountName.js.map +1 -0
- package/lib-es/account/addAccounts.d.ts +35 -0
- package/lib-es/account/addAccounts.d.ts.map +1 -0
- package/lib-es/account/addAccounts.js +200 -0
- package/lib-es/account/addAccounts.js.map +1 -0
- package/lib-es/account/balanceHistoryCache.d.ts +25 -0
- package/lib-es/account/balanceHistoryCache.d.ts.map +1 -0
- package/lib-es/account/balanceHistoryCache.js +109 -0
- package/lib-es/account/balanceHistoryCache.js.map +1 -0
- package/lib-es/account/groupOperations.d.ts +17 -0
- package/lib-es/account/groupOperations.d.ts.map +1 -0
- package/lib-es/account/groupOperations.js +122 -0
- package/lib-es/account/groupOperations.js.map +1 -0
- package/lib-es/account/helpers.d.ts +44 -0
- package/lib-es/account/helpers.d.ts.map +1 -0
- package/lib-es/account/helpers.js +303 -0
- package/lib-es/account/helpers.js.map +1 -0
- package/lib-es/account/helpers.test.d.ts +2 -0
- package/lib-es/account/helpers.test.d.ts.map +1 -0
- package/lib-es/account/helpers.test.js +361 -0
- package/lib-es/account/helpers.test.js.map +1 -0
- package/lib-es/account/index.d.ts +11 -0
- package/lib-es/account/index.d.ts.map +1 -0
- package/lib-es/account/index.js +11 -0
- package/lib-es/account/index.js.map +1 -0
- package/lib-es/account/ordering.d.ts +10 -0
- package/lib-es/account/ordering.d.ts.map +1 -0
- package/lib-es/account/ordering.js +103 -0
- package/lib-es/account/ordering.js.map +1 -0
- package/lib-es/account/pending.d.ts +33 -0
- package/lib-es/account/pending.d.ts.map +1 -0
- package/lib-es/account/pending.js +59 -0
- package/lib-es/account/pending.js.map +1 -0
- package/lib-es/account/serialization.d.ts +6 -0
- package/lib-es/account/serialization.d.ts.map +1 -0
- package/lib-es/account/serialization.js +112 -0
- package/lib-es/account/serialization.js.map +1 -0
- package/lib-es/account/support.d.ts +9 -0
- package/lib-es/account/support.d.ts.map +1 -0
- package/lib-es/account/support.js +64 -0
- package/lib-es/account/support.js.map +1 -0
- package/lib-es/account.test.d.ts +2 -0
- package/lib-es/account.test.d.ts.map +1 -0
- package/lib-es/account.test.js +252 -0
- package/lib-es/account.test.js.map +1 -0
- package/lib-es/bot/bot-test-context.d.ts +3 -0
- package/lib-es/bot/bot-test-context.d.ts.map +1 -0
- package/lib-es/bot/bot-test-context.js +21 -0
- package/lib-es/bot/bot-test-context.js.map +1 -0
- package/lib-es/bot/bot-test-context.test.d.ts +2 -0
- package/lib-es/bot/bot-test-context.test.d.ts.map +1 -0
- package/lib-es/bot/bot-test-context.test.js +39 -0
- package/lib-es/bot/bot-test-context.test.js.map +1 -0
- package/lib-es/bot/formatters.d.ts +2 -0
- package/lib-es/bot/formatters.d.ts.map +1 -0
- package/lib-es/bot/formatters.js +27 -0
- package/lib-es/bot/formatters.js.map +1 -0
- package/lib-es/bot/specs.d.ts +50 -0
- package/lib-es/bot/specs.d.ts.map +1 -0
- package/lib-es/bot/specs.js +193 -0
- package/lib-es/bot/specs.js.map +1 -0
- package/lib-es/bot/types.d.ts +178 -0
- package/lib-es/bot/types.d.ts.map +1 -0
- package/lib-es/bot/types.js +2 -0
- package/lib-es/bot/types.js.map +1 -0
- package/lib-es/bridge/getAddressWrapper.d.ts +6 -0
- package/lib-es/bridge/getAddressWrapper.d.ts.map +1 -0
- package/lib-es/bridge/getAddressWrapper.js +25 -0
- package/lib-es/bridge/getAddressWrapper.js.map +1 -0
- package/lib-es/bridge/jsHelpers.d.ts +63 -0
- package/lib-es/bridge/jsHelpers.d.ts.map +1 -0
- package/lib-es/bridge/jsHelpers.js +562 -0
- package/lib-es/bridge/jsHelpers.js.map +1 -0
- package/lib-es/cache.d.ts +10 -0
- package/lib-es/cache.d.ts.map +1 -0
- package/lib-es/cache.js +93 -0
- package/lib-es/cache.js.map +1 -0
- package/lib-es/cross.d.ts +42 -0
- package/lib-es/cross.d.ts.map +1 -0
- package/lib-es/cross.js +244 -0
- package/lib-es/cross.js.map +1 -0
- package/lib-es/cross.test.d.ts +2 -0
- package/lib-es/cross.test.d.ts.map +1 -0
- package/lib-es/cross.test.js +97 -0
- package/lib-es/cross.test.js.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.d.ts +8 -0
- package/lib-es/currencies/BigNumberToLocaleString.d.ts.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.js +61 -0
- package/lib-es/currencies/BigNumberToLocaleString.js.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.d.ts +2 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.d.ts.map +1 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.js +106 -0
- package/lib-es/currencies/BigNumberToLocaleString.test.js.map +1 -0
- package/lib-es/currencies/CurrencyURIScheme.d.ts +13 -0
- package/lib-es/currencies/CurrencyURIScheme.d.ts.map +1 -0
- package/lib-es/currencies/CurrencyURIScheme.js +116 -0
- package/lib-es/currencies/CurrencyURIScheme.js.map +1 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.d.ts +3 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.d.ts.map +1 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.js +25 -0
- package/lib-es/currencies/chopCurrencyUnitDecimals.js.map +1 -0
- package/lib-es/currencies/formatCurrencyUnit.d.ts +33 -0
- package/lib-es/currencies/formatCurrencyUnit.d.ts.map +1 -0
- package/lib-es/currencies/formatCurrencyUnit.js +121 -0
- package/lib-es/currencies/formatCurrencyUnit.js.map +1 -0
- package/lib-es/currencies/formatShort.d.ts +8 -0
- package/lib-es/currencies/formatShort.d.ts.map +1 -0
- package/lib-es/currencies/formatShort.js +20 -0
- package/lib-es/currencies/formatShort.js.map +1 -0
- package/lib-es/currencies/index.d.ts +13 -0
- package/lib-es/currencies/index.d.ts.map +1 -0
- package/lib-es/currencies/index.js +16 -0
- package/lib-es/currencies/index.js.map +1 -0
- package/lib-es/currencies/localeUtility.d.ts +8 -0
- package/lib-es/currencies/localeUtility.d.ts.map +1 -0
- package/lib-es/currencies/localeUtility.js +43 -0
- package/lib-es/currencies/localeUtility.js.map +1 -0
- package/lib-es/currencies/parseCurrencyUnit.d.ts +4 -0
- package/lib-es/currencies/parseCurrencyUnit.d.ts.map +1 -0
- package/lib-es/currencies/parseCurrencyUnit.js +14 -0
- package/lib-es/currencies/parseCurrencyUnit.js.map +1 -0
- package/lib-es/currencies/sanitizeValueString.d.ts +6 -0
- package/lib-es/currencies/sanitizeValueString.d.ts.map +1 -0
- package/lib-es/currencies/sanitizeValueString.js +52 -0
- package/lib-es/currencies/sanitizeValueString.js.map +1 -0
- package/lib-es/currencies/support.d.ts +8 -0
- package/lib-es/currencies/support.d.ts.map +1 -0
- package/lib-es/currencies/support.js +92 -0
- package/lib-es/currencies/support.js.map +1 -0
- package/lib-es/currencies/valueFromUnit.d.ts +9 -0
- package/lib-es/currencies/valueFromUnit.d.ts.map +1 -0
- package/lib-es/currencies/valueFromUnit.js +10 -0
- package/lib-es/currencies/valueFromUnit.js.map +1 -0
- package/lib-es/derivation.d.ts +232 -0
- package/lib-es/derivation.d.ts.map +1 -0
- package/lib-es/derivation.js +473 -0
- package/lib-es/derivation.js.map +1 -0
- package/lib-es/env.d.ts +30 -0
- package/lib-es/env.d.ts.map +1 -0
- package/lib-es/env.js +768 -0
- package/lib-es/env.js.map +1 -0
- package/lib-es/errors.d.ts +7 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +4 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/errors.test.d.ts +2 -0
- package/lib-es/errors.test.d.ts.map +1 -0
- package/lib-es/errors.test.js +18 -0
- package/lib-es/errors.test.js.map +1 -0
- package/lib-es/mocks/account.d.ts +25 -0
- package/lib-es/mocks/account.d.ts.map +1 -0
- package/lib-es/mocks/account.js +358 -0
- package/lib-es/mocks/account.js.map +1 -0
- package/lib-es/mocks/fixtures/nfts.d.ts +27 -0
- package/lib-es/mocks/fixtures/nfts.d.ts.map +1 -0
- package/lib-es/mocks/fixtures/nfts.js +390 -0
- package/lib-es/mocks/fixtures/nfts.js.map +1 -0
- package/lib-es/mocks/fixtures/nfts.test.d.ts +2 -0
- package/lib-es/mocks/fixtures/nfts.test.d.ts.map +1 -0
- package/lib-es/mocks/fixtures/nfts.test.js +18 -0
- package/lib-es/mocks/fixtures/nfts.test.js.map +1 -0
- package/lib-es/mocks/helpers.d.ts +15 -0
- package/lib-es/mocks/helpers.d.ts.map +1 -0
- package/lib-es/mocks/helpers.js +26 -0
- package/lib-es/mocks/helpers.js.map +1 -0
- package/lib-es/network.d.ts +5 -0
- package/lib-es/network.d.ts.map +1 -0
- package/lib-es/network.js +118 -0
- package/lib-es/network.js.map +1 -0
- package/lib-es/nft/nftId.d.ts +8 -0
- package/lib-es/nft/nftId.d.ts.map +1 -0
- package/lib-es/nft/nftId.js +29 -0
- package/lib-es/nft/nftId.js.map +1 -0
- package/lib-es/operation.d.ts +24 -0
- package/lib-es/operation.d.ts.map +1 -0
- package/lib-es/operation.js +168 -0
- package/lib-es/operation.js.map +1 -0
- package/lib-es/promise.d.ts +21 -0
- package/lib-es/promise.d.ts.map +1 -0
- package/lib-es/promise.js +179 -0
- package/lib-es/promise.js.map +1 -0
- package/lib-es/promise.test.d.ts +2 -0
- package/lib-es/promise.test.d.ts.map +1 -0
- package/lib-es/promise.test.js +70 -0
- package/lib-es/promise.test.js.map +1 -0
- package/lib-es/rangeDates.d.ts +29 -0
- package/lib-es/rangeDates.d.ts.map +1 -0
- package/lib-es/rangeDates.js +84 -0
- package/lib-es/rangeDates.js.map +1 -0
- package/lib-es/rangeDates.test.d.ts +2 -0
- package/lib-es/rangeDates.test.d.ts.map +1 -0
- package/lib-es/rangeDates.test.js +49 -0
- package/lib-es/rangeDates.test.js.map +1 -0
- package/lib-es/test-helpers/staticTime.d.ts +2 -0
- package/lib-es/test-helpers/staticTime.d.ts.map +1 -0
- package/lib-es/test-helpers/staticTime.js +5 -0
- package/lib-es/test-helpers/staticTime.js.map +1 -0
- package/lib-es/transaction/common.d.ts +26 -0
- package/lib-es/transaction/common.d.ts.map +1 -0
- package/lib-es/transaction/common.js +115 -0
- package/lib-es/transaction/common.js.map +1 -0
- package/package.json +113 -0
- package/src/__snapshots__/account.test.ts.snap +2065 -0
- package/src/__snapshots__/cross.test.ts.snap +57 -0
- package/src/account/accountId.ts +93 -0
- package/src/account/accountName.ts +25 -0
- package/src/account/addAccounts.ts +236 -0
- package/src/account/balanceHistoryCache.ts +146 -0
- package/src/account/groupOperations.ts +164 -0
- package/src/account/helpers.test.ts +441 -0
- package/src/account/helpers.ts +380 -0
- package/src/account/index.ts +10 -0
- package/src/account/ordering.ts +109 -0
- package/src/account/pending.ts +66 -0
- package/src/account/serialization.ts +189 -0
- package/src/account/support.ts +96 -0
- package/src/account.test.ts +237 -0
- package/src/bot/bot-test-context.test.ts +37 -0
- package/src/bot/bot-test-context.ts +24 -0
- package/src/bot/formatters.ts +22 -0
- package/src/bot/specs.ts +275 -0
- package/src/bot/types.ts +224 -0
- package/src/bridge/getAddressWrapper.ts +40 -0
- package/src/bridge/jsHelpers.ts +645 -0
- package/src/cache.ts +65 -0
- package/src/cross.test.ts +112 -0
- package/src/cross.ts +366 -0
- package/src/currencies/BigNumberToLocaleString.test.ts +155 -0
- package/src/currencies/BigNumberToLocaleString.ts +80 -0
- package/src/currencies/CurrencyURIScheme.ts +114 -0
- package/src/currencies/chopCurrencyUnitDecimals.ts +34 -0
- package/src/currencies/formatCurrencyUnit.ts +167 -0
- package/src/currencies/formatShort.ts +24 -0
- package/src/currencies/index.ts +78 -0
- package/src/currencies/localeUtility.ts +50 -0
- package/src/currencies/parseCurrencyUnit.ts +16 -0
- package/src/currencies/sanitizeValueString.ts +58 -0
- package/src/currencies/support.ts +107 -0
- package/src/currencies/valueFromUnit.ts +10 -0
- package/src/derivation.ts +595 -0
- package/src/env.ts +790 -0
- package/src/errors.test.ts +21 -0
- package/src/errors.ts +9 -0
- package/src/mocks/account.ts +476 -0
- package/src/mocks/fixtures/nfts.test.ts +25 -0
- package/src/mocks/fixtures/nfts.ts +432 -0
- package/src/mocks/helpers.ts +38 -0
- package/src/network.ts +135 -0
- package/src/nft/nftId.ts +26 -0
- package/src/operation.ts +212 -0
- package/src/promise.test.ts +20 -0
- package/src/promise.ts +101 -0
- package/src/rangeDates.test.ts +66 -0
- package/src/rangeDates.ts +96 -0
- package/src/test-helpers/staticTime.ts +4 -0
- package/src/transaction/common.ts +157 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import invariant from "invariant";
|
|
2
|
+
import { Observable, defer, of, range, empty } from "rxjs";
|
|
3
|
+
import {
|
|
4
|
+
catchError,
|
|
5
|
+
switchMap,
|
|
6
|
+
concatMap,
|
|
7
|
+
takeWhile,
|
|
8
|
+
map,
|
|
9
|
+
} from "rxjs/operators";
|
|
10
|
+
import { log } from "@ledgerhq/logs";
|
|
11
|
+
import { TransportStatusError, UserRefusedAddress } from "@ledgerhq/errors";
|
|
12
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
13
|
+
import { getCryptoCurrencyById } from "./currencies";
|
|
14
|
+
import { getEnv } from "./env";
|
|
15
|
+
import type { CryptoCurrencyIds } from "@ledgerhq/types-live";
|
|
16
|
+
export type ModeSpec = {
|
|
17
|
+
mandatoryEmptyAccountSkip?: number;
|
|
18
|
+
isNonIterable?: boolean;
|
|
19
|
+
startsAt?: number;
|
|
20
|
+
overridesDerivation?: string;
|
|
21
|
+
isSegwit?: boolean;
|
|
22
|
+
isNativeSegwit?: boolean;
|
|
23
|
+
isTaproot?: boolean;
|
|
24
|
+
// TODO drop
|
|
25
|
+
isUnsplit?: boolean;
|
|
26
|
+
// TODO drop
|
|
27
|
+
skipFirst?: true;
|
|
28
|
+
overridesCoinType?: number;
|
|
29
|
+
// force a given cointype
|
|
30
|
+
purpose?: number;
|
|
31
|
+
isInvalid?: boolean;
|
|
32
|
+
// invalid means it's not a path we ever supported. some users fall into this and we support scanning for them in SCAN_FOR_INVALID_PATHS is set.
|
|
33
|
+
tag?: string;
|
|
34
|
+
addressFormat?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// FIXME: DerivationMode SHOULD BE IN LIVE-TYPES ?
|
|
38
|
+
// IN LIVE-TYPES DerivationMode = string which does not work
|
|
39
|
+
export type DerivationMode = keyof typeof modes;
|
|
40
|
+
|
|
41
|
+
export type Result = {
|
|
42
|
+
address: string;
|
|
43
|
+
path: string;
|
|
44
|
+
publicKey: string;
|
|
45
|
+
chainCode?: string;
|
|
46
|
+
};
|
|
47
|
+
export type GetAddressOptions = {
|
|
48
|
+
currency: CryptoCurrency;
|
|
49
|
+
path: string;
|
|
50
|
+
derivationMode: DerivationMode;
|
|
51
|
+
verify?: boolean;
|
|
52
|
+
askChainCode?: boolean;
|
|
53
|
+
forceFormat?: string;
|
|
54
|
+
devicePath?: string;
|
|
55
|
+
segwit?: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const modes = Object.freeze({
|
|
59
|
+
// this is "default" by convention
|
|
60
|
+
"": {},
|
|
61
|
+
// MEW legacy derivation
|
|
62
|
+
ethM: {
|
|
63
|
+
mandatoryEmptyAccountSkip: 10,
|
|
64
|
+
overridesDerivation: "44'/60'/0'/<account>",
|
|
65
|
+
tag: "legacy",
|
|
66
|
+
},
|
|
67
|
+
// MetaMask style
|
|
68
|
+
ethMM: {
|
|
69
|
+
overridesDerivation: "44'/60'/0'/0/<account>",
|
|
70
|
+
skipFirst: true,
|
|
71
|
+
// already included in the normal bip44,
|
|
72
|
+
tag: "metamask",
|
|
73
|
+
},
|
|
74
|
+
// Deprecated and should no longer be used.
|
|
75
|
+
bch_on_bitcoin_segwit: {
|
|
76
|
+
overridesCoinType: 0,
|
|
77
|
+
isInvalid: true,
|
|
78
|
+
isSegwit: true,
|
|
79
|
+
purpose: 49,
|
|
80
|
+
addressFormat: "p2sh",
|
|
81
|
+
},
|
|
82
|
+
// many users have wrongly sent BTC on BCH paths
|
|
83
|
+
legacy_on_bch: {
|
|
84
|
+
overridesCoinType: 145,
|
|
85
|
+
isInvalid: true,
|
|
86
|
+
},
|
|
87
|
+
// chrome app and LL wrongly used to derivate vertcoin on 128
|
|
88
|
+
vertcoin_128: {
|
|
89
|
+
tag: "legacy",
|
|
90
|
+
overridesCoinType: 128,
|
|
91
|
+
},
|
|
92
|
+
vertcoin_128_segwit: {
|
|
93
|
+
tag: "legacy",
|
|
94
|
+
overridesCoinType: 128,
|
|
95
|
+
isSegwit: true,
|
|
96
|
+
purpose: 49,
|
|
97
|
+
addressFormat: "p2sh",
|
|
98
|
+
},
|
|
99
|
+
// MEW legacy derivation for eth
|
|
100
|
+
etcM: {
|
|
101
|
+
mandatoryEmptyAccountSkip: 10,
|
|
102
|
+
overridesDerivation: "44'/60'/160720'/0'/<account>",
|
|
103
|
+
tag: "legacy",
|
|
104
|
+
},
|
|
105
|
+
aeternity: {
|
|
106
|
+
overridesDerivation: "<account>",
|
|
107
|
+
},
|
|
108
|
+
// default derivation of tezbox offerred to users
|
|
109
|
+
tezbox: {
|
|
110
|
+
overridesDerivation: "44'/1729'/<account>'/0'",
|
|
111
|
+
},
|
|
112
|
+
tezosbip44h: {
|
|
113
|
+
tag: "galleon",
|
|
114
|
+
overridesDerivation: "44'/1729'/<account>'/0'/0'",
|
|
115
|
+
},
|
|
116
|
+
galleonL: {
|
|
117
|
+
tag: "legacy",
|
|
118
|
+
startsAt: 1,
|
|
119
|
+
overridesDerivation: "44'/1729'/0'/0'/<account>'",
|
|
120
|
+
},
|
|
121
|
+
tezboxL: {
|
|
122
|
+
tag: "legacy",
|
|
123
|
+
startsAt: 1,
|
|
124
|
+
overridesDerivation: "44'/1729'/0'/<account>'",
|
|
125
|
+
},
|
|
126
|
+
taproot: {
|
|
127
|
+
purpose: 86,
|
|
128
|
+
addressFormat: "bech32m",
|
|
129
|
+
tag: "taproot",
|
|
130
|
+
isSegwit: true,
|
|
131
|
+
isTaproot: true,
|
|
132
|
+
},
|
|
133
|
+
native_segwit: {
|
|
134
|
+
purpose: 84,
|
|
135
|
+
addressFormat: "bech32",
|
|
136
|
+
tag: "native segwit",
|
|
137
|
+
isSegwit: true,
|
|
138
|
+
isNativeSegwit: true,
|
|
139
|
+
},
|
|
140
|
+
segwit: {
|
|
141
|
+
isSegwit: true,
|
|
142
|
+
purpose: 49,
|
|
143
|
+
tag: "segwit",
|
|
144
|
+
addressFormat: "p2sh",
|
|
145
|
+
},
|
|
146
|
+
segwit_on_legacy: {
|
|
147
|
+
isSegwit: true,
|
|
148
|
+
purpose: 44,
|
|
149
|
+
addressFormat: "p2sh",
|
|
150
|
+
isInvalid: true,
|
|
151
|
+
},
|
|
152
|
+
legacy_on_segwit: {
|
|
153
|
+
purpose: 49,
|
|
154
|
+
isInvalid: true,
|
|
155
|
+
},
|
|
156
|
+
legacy_on_native_segwit: {
|
|
157
|
+
purpose: 84,
|
|
158
|
+
isInvalid: true,
|
|
159
|
+
},
|
|
160
|
+
segwit_unsplit: {
|
|
161
|
+
isSegwit: true,
|
|
162
|
+
purpose: 49,
|
|
163
|
+
addressFormat: "p2sh",
|
|
164
|
+
isUnsplit: true,
|
|
165
|
+
tag: "segwit unsplit",
|
|
166
|
+
},
|
|
167
|
+
sep5: {
|
|
168
|
+
overridesDerivation: "44'/148'/<account>'",
|
|
169
|
+
},
|
|
170
|
+
unsplit: {
|
|
171
|
+
isUnsplit: true,
|
|
172
|
+
tag: "unsplit",
|
|
173
|
+
},
|
|
174
|
+
polkadotbip44: {
|
|
175
|
+
overridesDerivation: "44'/354'/<account>'/0'/<address>'",
|
|
176
|
+
},
|
|
177
|
+
gliflegacy: {
|
|
178
|
+
overridesDerivation: "44'/1'/0'/0/<account>",
|
|
179
|
+
tag: "legacy",
|
|
180
|
+
},
|
|
181
|
+
glif: {
|
|
182
|
+
overridesDerivation: "44'/461'/0'/0/<account>",
|
|
183
|
+
startsAt: 1,
|
|
184
|
+
tag: "third-party",
|
|
185
|
+
},
|
|
186
|
+
solanaMain: {
|
|
187
|
+
isNonIterable: true,
|
|
188
|
+
overridesDerivation: "44'/501'",
|
|
189
|
+
},
|
|
190
|
+
solanaSub: {
|
|
191
|
+
overridesDerivation: "44'/501'/<account>'",
|
|
192
|
+
},
|
|
193
|
+
hederaBip44: {
|
|
194
|
+
overridesDerivation: "44/3030",
|
|
195
|
+
},
|
|
196
|
+
cardano: {
|
|
197
|
+
purpose: 1852,
|
|
198
|
+
overridesDerivation: "1852'/1815'/<account>'/<node>/<address>",
|
|
199
|
+
},
|
|
200
|
+
nearbip44h: {
|
|
201
|
+
overridesDerivation: "44'/397'/0'/0'/<account>'",
|
|
202
|
+
mandatoryEmptyAccountSkip: 1,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
modes as Record<DerivationMode, ModeSpec>; // eslint-disable-line
|
|
206
|
+
|
|
207
|
+
// FIXME: CryptoCurrencyConfig was a flowtype we could not easily convert to ts so it has been deleted
|
|
208
|
+
// previous types: Partial<CryptoCurrencyConfig<DerivationMode[]>>
|
|
209
|
+
const legacyDerivations: Record<CryptoCurrencyIds, DerivationMode[]> = {
|
|
210
|
+
aeternity: ["aeternity"],
|
|
211
|
+
bitcoin_cash: [],
|
|
212
|
+
bitcoin: ["legacy_on_bch"],
|
|
213
|
+
vertcoin: ["vertcoin_128", "vertcoin_128_segwit"],
|
|
214
|
+
ethereum_classic: ["etcM"],
|
|
215
|
+
tezos: ["galleonL", "tezboxL", "tezosbip44h", "tezbox"],
|
|
216
|
+
stellar: ["sep5"],
|
|
217
|
+
polkadot: ["polkadotbip44"],
|
|
218
|
+
hedera: ["hederaBip44"],
|
|
219
|
+
filecoin: ["gliflegacy", "glif"],
|
|
220
|
+
cardano: ["cardano"],
|
|
221
|
+
cardano_testnet: ["cardano"],
|
|
222
|
+
near: ["nearbip44h"],
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const legacyDerivationsPerFamily: Record<string, DerivationMode[]> = {
|
|
226
|
+
ethereum: ["ethM", "ethMM"],
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const asDerivationMode = (derivationMode: string): DerivationMode => {
|
|
230
|
+
invariant(
|
|
231
|
+
derivationMode in modes,
|
|
232
|
+
"not a derivationMode. Got: '%s'",
|
|
233
|
+
derivationMode
|
|
234
|
+
);
|
|
235
|
+
return derivationMode as DerivationMode;
|
|
236
|
+
};
|
|
237
|
+
export const getAllDerivationModes = (): DerivationMode[] =>
|
|
238
|
+
Object.keys(modes) as DerivationMode[];
|
|
239
|
+
export const getMandatoryEmptyAccountSkip = (
|
|
240
|
+
derivationMode: DerivationMode
|
|
241
|
+
): number =>
|
|
242
|
+
(modes[derivationMode] as { mandatoryEmptyAccountSkip: number })
|
|
243
|
+
.mandatoryEmptyAccountSkip || 0;
|
|
244
|
+
export const isInvalidDerivationMode = (
|
|
245
|
+
derivationMode: DerivationMode
|
|
246
|
+
): boolean =>
|
|
247
|
+
(modes[derivationMode] as { isInvalid: boolean }).isInvalid || false;
|
|
248
|
+
export const isSegwitDerivationMode = (
|
|
249
|
+
derivationMode: DerivationMode
|
|
250
|
+
): boolean =>
|
|
251
|
+
(modes[derivationMode] as { isSegwit: boolean }).isSegwit || false;
|
|
252
|
+
export const isNativeSegwitDerivationMode = (
|
|
253
|
+
derivationMode: DerivationMode
|
|
254
|
+
): boolean =>
|
|
255
|
+
(modes[derivationMode] as { isNativeSegwit: boolean }).isNativeSegwit ||
|
|
256
|
+
false;
|
|
257
|
+
export const isTaprootDerivationMode = (
|
|
258
|
+
derivationMode: DerivationMode
|
|
259
|
+
): boolean =>
|
|
260
|
+
(modes[derivationMode] as { isTaproot: boolean }).isTaproot || false;
|
|
261
|
+
|
|
262
|
+
export const isUnsplitDerivationMode = (
|
|
263
|
+
derivationMode: DerivationMode
|
|
264
|
+
): boolean =>
|
|
265
|
+
(modes[derivationMode] as { isUnsplit: boolean }).isUnsplit || false;
|
|
266
|
+
export const isIterableDerivationMode = (
|
|
267
|
+
derivationMode: DerivationMode
|
|
268
|
+
): boolean =>
|
|
269
|
+
!(modes[derivationMode] as { isNonIterable: boolean }).isNonIterable;
|
|
270
|
+
export const getDerivationModeStartsAt = (
|
|
271
|
+
derivationMode: DerivationMode
|
|
272
|
+
): number => (modes[derivationMode] as { startsAt: number }).startsAt || 0;
|
|
273
|
+
export const getPurposeDerivationMode = (
|
|
274
|
+
derivationMode: DerivationMode
|
|
275
|
+
): number => (modes[derivationMode] as { purpose: number }).purpose || 44;
|
|
276
|
+
export const getTagDerivationMode = (
|
|
277
|
+
currency: CryptoCurrency,
|
|
278
|
+
derivationMode: DerivationMode
|
|
279
|
+
): string | null | undefined => {
|
|
280
|
+
const mode = modes[derivationMode] as { tag: any; isInvalid: any };
|
|
281
|
+
|
|
282
|
+
if (mode.tag) {
|
|
283
|
+
return mode.tag;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (mode.isInvalid) {
|
|
287
|
+
return "custom";
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (currency.supportsSegwit && !isSegwitDerivationMode(derivationMode)) {
|
|
291
|
+
return "legacy";
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return null;
|
|
295
|
+
};
|
|
296
|
+
export const getAddressFormatDerivationMode = (
|
|
297
|
+
derivationMode: DerivationMode
|
|
298
|
+
): string =>
|
|
299
|
+
(modes[derivationMode] as { addressFormat: string }).addressFormat ||
|
|
300
|
+
"legacy";
|
|
301
|
+
export const derivationModeSupportsIndex = (
|
|
302
|
+
derivationMode: DerivationMode,
|
|
303
|
+
index: number
|
|
304
|
+
): boolean => {
|
|
305
|
+
const mode = modes[derivationMode];
|
|
306
|
+
if ((mode as { skipFirst: boolean }).skipFirst && index === 0) return false;
|
|
307
|
+
return true;
|
|
308
|
+
};
|
|
309
|
+
const currencyForceCoinType = {
|
|
310
|
+
vertcoin: true,
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* return a ledger-lib-core compatible DerivationScheme format
|
|
315
|
+
* for a given currency and derivationMode (you can pass an Account because same shape)
|
|
316
|
+
*/
|
|
317
|
+
export const getDerivationScheme = ({
|
|
318
|
+
derivationMode,
|
|
319
|
+
currency,
|
|
320
|
+
}: {
|
|
321
|
+
derivationMode: DerivationMode;
|
|
322
|
+
currency: CryptoCurrency;
|
|
323
|
+
}): string => {
|
|
324
|
+
const { overridesDerivation, overridesCoinType } = modes[derivationMode] as {
|
|
325
|
+
overridesDerivation: string;
|
|
326
|
+
overridesCoinType: string;
|
|
327
|
+
};
|
|
328
|
+
if (overridesDerivation) return overridesDerivation;
|
|
329
|
+
const splitFrom =
|
|
330
|
+
isUnsplitDerivationMode(derivationMode) && currency.forkedFrom;
|
|
331
|
+
const coinType = splitFrom
|
|
332
|
+
? getCryptoCurrencyById(splitFrom).coinType
|
|
333
|
+
: typeof overridesCoinType === "number"
|
|
334
|
+
? overridesCoinType
|
|
335
|
+
: currencyForceCoinType
|
|
336
|
+
? currency.coinType
|
|
337
|
+
: "<coin_type>";
|
|
338
|
+
const purpose = getPurposeDerivationMode(derivationMode);
|
|
339
|
+
return `${purpose}'/${coinType}'/<account>'/<node>/<address>`;
|
|
340
|
+
};
|
|
341
|
+
// Execute a derivation scheme
|
|
342
|
+
export const runDerivationScheme = (
|
|
343
|
+
derivationScheme: string,
|
|
344
|
+
{
|
|
345
|
+
coinType,
|
|
346
|
+
}: {
|
|
347
|
+
coinType: number;
|
|
348
|
+
},
|
|
349
|
+
opts: {
|
|
350
|
+
account?: number | string;
|
|
351
|
+
node?: number | string;
|
|
352
|
+
address?: number | string;
|
|
353
|
+
} = {}
|
|
354
|
+
) =>
|
|
355
|
+
derivationScheme
|
|
356
|
+
.replace("<coin_type>", String(coinType))
|
|
357
|
+
.replace("<account>", String(opts.account || 0))
|
|
358
|
+
.replace("<node>", String(opts.node || 0))
|
|
359
|
+
.replace("<address>", String(opts.address || 0));
|
|
360
|
+
// execute the derivation on the account part of the scheme
|
|
361
|
+
export const runAccountDerivationScheme = (
|
|
362
|
+
scheme: string,
|
|
363
|
+
currency: {
|
|
364
|
+
coinType: number;
|
|
365
|
+
},
|
|
366
|
+
opts: {
|
|
367
|
+
account?: number | string;
|
|
368
|
+
} = {}
|
|
369
|
+
) =>
|
|
370
|
+
runDerivationScheme(scheme, currency, {
|
|
371
|
+
...opts,
|
|
372
|
+
address: "_",
|
|
373
|
+
node: "_",
|
|
374
|
+
}).replace(/[_/]+$/, "");
|
|
375
|
+
const disableBIP44: Record<string, boolean> = {
|
|
376
|
+
aeternity: true,
|
|
377
|
+
tezos: true,
|
|
378
|
+
// current workaround, device app does not seem to support bip44
|
|
379
|
+
stellar: true,
|
|
380
|
+
polkadot: true,
|
|
381
|
+
solana: true,
|
|
382
|
+
hedera: true,
|
|
383
|
+
cardano: true,
|
|
384
|
+
cardano_testnet: true,
|
|
385
|
+
near: true,
|
|
386
|
+
};
|
|
387
|
+
type SeedInfo = {
|
|
388
|
+
purpose: number;
|
|
389
|
+
coinType: number;
|
|
390
|
+
};
|
|
391
|
+
type SeedPathFn = (info: SeedInfo) => string;
|
|
392
|
+
const seedIdentifierPath: Record<string, SeedPathFn> = {
|
|
393
|
+
neo: ({ purpose, coinType }) => `${purpose}'/${coinType}'/0'/0/0`,
|
|
394
|
+
filecoin: ({ purpose, coinType }) => `${purpose}'/${coinType}'/0'/0/0`,
|
|
395
|
+
solana: ({ purpose, coinType }) => `${purpose}'/${coinType}'`,
|
|
396
|
+
hedera: ({ purpose, coinType }) => `${purpose}/${coinType}`,
|
|
397
|
+
cardano: ({ purpose, coinType }) => `${purpose}'/${coinType}'/0'/0/0`,
|
|
398
|
+
cardano_testnet: ({ purpose, coinType }) => `${purpose}'/${coinType}'/0'/0/0`,
|
|
399
|
+
near: ({ purpose, coinType }) => `${purpose}'/${coinType}'/0'/0'/0'`,
|
|
400
|
+
_: ({ purpose, coinType }) => `${purpose}'/${coinType}'/0'`,
|
|
401
|
+
};
|
|
402
|
+
export const getSeedIdentifierDerivation = (
|
|
403
|
+
currency: CryptoCurrency,
|
|
404
|
+
derivationMode: DerivationMode
|
|
405
|
+
): string => {
|
|
406
|
+
const unsplitFork = isUnsplitDerivationMode(derivationMode)
|
|
407
|
+
? currency.forkedFrom
|
|
408
|
+
: null;
|
|
409
|
+
const purpose = getPurposeDerivationMode(derivationMode);
|
|
410
|
+
const { coinType } = unsplitFork
|
|
411
|
+
? getCryptoCurrencyById(unsplitFork)
|
|
412
|
+
: currency;
|
|
413
|
+
const f = seedIdentifierPath[currency.id] || seedIdentifierPath._;
|
|
414
|
+
return f({
|
|
415
|
+
purpose,
|
|
416
|
+
coinType,
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
// return an array of ways to derivate, by convention the latest is the standard one.
|
|
420
|
+
export const getDerivationModesForCurrency = (
|
|
421
|
+
currency: CryptoCurrency
|
|
422
|
+
): DerivationMode[] => {
|
|
423
|
+
let all: DerivationMode[] = [];
|
|
424
|
+
if (currency.family in legacyDerivationsPerFamily) {
|
|
425
|
+
all = all.concat(legacyDerivationsPerFamily[currency.family]);
|
|
426
|
+
}
|
|
427
|
+
if (currency.id in legacyDerivations) {
|
|
428
|
+
all = all.concat(legacyDerivations[currency.id]);
|
|
429
|
+
}
|
|
430
|
+
if (currency.forkedFrom) {
|
|
431
|
+
all.push("unsplit");
|
|
432
|
+
|
|
433
|
+
if (currency.supportsSegwit) {
|
|
434
|
+
all.push("segwit_unsplit");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (currency.supportsSegwit) {
|
|
439
|
+
all.push("segwit_on_legacy");
|
|
440
|
+
all.push("legacy_on_segwit");
|
|
441
|
+
all.push("legacy_on_native_segwit");
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (currency.supportsNativeSegwit) {
|
|
445
|
+
all.push("native_segwit");
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// taproot logic. FIXME should move per family
|
|
449
|
+
if (currency.family === "bitcoin") {
|
|
450
|
+
if (currency.id === "bitcoin" || currency.id === "bitcoin_testnet") {
|
|
451
|
+
all.push("taproot");
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (currency.supportsSegwit) {
|
|
456
|
+
all.push("segwit");
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (!disableBIP44[currency.id]) {
|
|
460
|
+
all.push("");
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (currency.family === "solana") {
|
|
464
|
+
all.push("solanaMain", "solanaSub");
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (!getEnv("SCAN_FOR_INVALID_PATHS")) {
|
|
468
|
+
return all.filter((a) => !isInvalidDerivationMode(a));
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return all;
|
|
472
|
+
};
|
|
473
|
+
const preferredList: DerivationMode[] = [
|
|
474
|
+
"native_segwit",
|
|
475
|
+
"taproot",
|
|
476
|
+
"segwit",
|
|
477
|
+
"",
|
|
478
|
+
];
|
|
479
|
+
// null => no settings
|
|
480
|
+
// [ .. ]
|
|
481
|
+
export const getPreferredNewAccountScheme = (
|
|
482
|
+
currency: CryptoCurrency
|
|
483
|
+
): DerivationMode[] | null | undefined => {
|
|
484
|
+
if (currency.family !== "bitcoin") return null;
|
|
485
|
+
const derivationsModes = getDerivationModesForCurrency(currency);
|
|
486
|
+
const list = preferredList.filter((p) =>
|
|
487
|
+
derivationsModes.includes(p as DerivationMode)
|
|
488
|
+
);
|
|
489
|
+
if (list.length === 1) return null;
|
|
490
|
+
return list as DerivationMode[];
|
|
491
|
+
};
|
|
492
|
+
export const getDefaultPreferredNewAccountScheme = (
|
|
493
|
+
currency: CryptoCurrency
|
|
494
|
+
): DerivationMode | null | undefined => {
|
|
495
|
+
const list = getPreferredNewAccountScheme(currency);
|
|
496
|
+
return list && list[0];
|
|
497
|
+
};
|
|
498
|
+
export type StepAddressInput = {
|
|
499
|
+
index: number;
|
|
500
|
+
parentDerivation: Result;
|
|
501
|
+
accountDerivation: Result;
|
|
502
|
+
derivationMode: DerivationMode;
|
|
503
|
+
shouldSkipEmpty: boolean;
|
|
504
|
+
seedIdentifier: string;
|
|
505
|
+
};
|
|
506
|
+
export type WalletDerivationInput<R> = {
|
|
507
|
+
currency: CryptoCurrency;
|
|
508
|
+
derivationMode: DerivationMode;
|
|
509
|
+
derivateAddress: (arg0: GetAddressOptions) => Observable<Result>;
|
|
510
|
+
stepAddress: (arg0: StepAddressInput) => Observable<{
|
|
511
|
+
result?: R;
|
|
512
|
+
complete?: boolean;
|
|
513
|
+
}>;
|
|
514
|
+
shouldDerivesOnAccount?: boolean;
|
|
515
|
+
};
|
|
516
|
+
export function walletDerivation<R>({
|
|
517
|
+
currency,
|
|
518
|
+
derivationMode,
|
|
519
|
+
derivateAddress,
|
|
520
|
+
stepAddress,
|
|
521
|
+
shouldDerivesOnAccount,
|
|
522
|
+
}: WalletDerivationInput<R>): Observable<R> {
|
|
523
|
+
const path = getSeedIdentifierDerivation(currency, derivationMode);
|
|
524
|
+
return defer(() =>
|
|
525
|
+
derivateAddress({
|
|
526
|
+
currency,
|
|
527
|
+
path,
|
|
528
|
+
derivationMode,
|
|
529
|
+
}).pipe(
|
|
530
|
+
catchError((e) => {
|
|
531
|
+
if (
|
|
532
|
+
e instanceof TransportStatusError ||
|
|
533
|
+
e instanceof UserRefusedAddress
|
|
534
|
+
) {
|
|
535
|
+
log("scanAccounts", "ignore derivationMode=" + derivationMode);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return empty();
|
|
539
|
+
})
|
|
540
|
+
)
|
|
541
|
+
).pipe(
|
|
542
|
+
switchMap((parentDerivation) => {
|
|
543
|
+
const seedIdentifier = parentDerivation.publicKey;
|
|
544
|
+
const emptyCount = 0;
|
|
545
|
+
const mandatoryEmptyAccountSkip =
|
|
546
|
+
getMandatoryEmptyAccountSkip(derivationMode);
|
|
547
|
+
const derivationScheme = getDerivationScheme({
|
|
548
|
+
derivationMode,
|
|
549
|
+
currency,
|
|
550
|
+
});
|
|
551
|
+
const stopAt = isIterableDerivationMode(derivationMode) ? 255 : 1;
|
|
552
|
+
const startsAt = getDerivationModeStartsAt(derivationMode);
|
|
553
|
+
return range(startsAt, stopAt - startsAt).pipe(
|
|
554
|
+
// derivate addresses/xpubs
|
|
555
|
+
concatMap((index) => {
|
|
556
|
+
if (!derivationModeSupportsIndex(derivationMode, index)) {
|
|
557
|
+
return empty();
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const path = shouldDerivesOnAccount
|
|
561
|
+
? runAccountDerivationScheme(derivationScheme, currency, {
|
|
562
|
+
account: index,
|
|
563
|
+
})
|
|
564
|
+
: runDerivationScheme(derivationScheme, currency, {
|
|
565
|
+
account: index,
|
|
566
|
+
});
|
|
567
|
+
return derivateAddress({
|
|
568
|
+
currency,
|
|
569
|
+
path,
|
|
570
|
+
derivationMode,
|
|
571
|
+
}).pipe(
|
|
572
|
+
map((accountDerivation) => ({
|
|
573
|
+
parentDerivation,
|
|
574
|
+
accountDerivation,
|
|
575
|
+
index,
|
|
576
|
+
}))
|
|
577
|
+
);
|
|
578
|
+
}), // do action with these derivations (e.g. synchronize)
|
|
579
|
+
concatMap(({ parentDerivation, accountDerivation, index }) =>
|
|
580
|
+
stepAddress({
|
|
581
|
+
index,
|
|
582
|
+
parentDerivation,
|
|
583
|
+
accountDerivation,
|
|
584
|
+
derivationMode,
|
|
585
|
+
shouldSkipEmpty: emptyCount < mandatoryEmptyAccountSkip,
|
|
586
|
+
seedIdentifier,
|
|
587
|
+
})
|
|
588
|
+
), // take until the list is complete (based on criteria defined by stepAddress)
|
|
589
|
+
// $FlowFixMe
|
|
590
|
+
takeWhile((r) => !r.complete, true), // emit just the results
|
|
591
|
+
concatMap(({ result }) => (result ? of(result) : empty()))
|
|
592
|
+
);
|
|
593
|
+
})
|
|
594
|
+
);
|
|
595
|
+
}
|