@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,114 @@
|
|
|
1
|
+
import querystring from "querystring";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
import { findCryptoCurrencyByScheme } from "@ledgerhq/cryptoassets";
|
|
4
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
|
+
// see https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
|
|
6
|
+
type Data = {
|
|
7
|
+
address: string;
|
|
8
|
+
currency?: CryptoCurrency;
|
|
9
|
+
amount?: BigNumber;
|
|
10
|
+
// IN SATOSHI !! not in actual 'real' value
|
|
11
|
+
// ... any other field specific to a coin that will be put in query
|
|
12
|
+
userGasLimit?: BigNumber;
|
|
13
|
+
gasPrice?: BigNumber;
|
|
14
|
+
};
|
|
15
|
+
export function encodeURIScheme(data: Data): string {
|
|
16
|
+
const { currency, address, amount, ...specificFields } = data;
|
|
17
|
+
const query: Record<string, any> = { ...specificFields };
|
|
18
|
+
if (!currency) return address;
|
|
19
|
+
|
|
20
|
+
if (amount) {
|
|
21
|
+
const { magnitude } = currency.units[0];
|
|
22
|
+
query.amount = amount.div(new BigNumber(10).pow(magnitude)).toNumber();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const queryStr = querystring.stringify(query);
|
|
26
|
+
return currency.scheme + ":" + address + (queryStr ? "?" + queryStr : "");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const convertedValue = (value: any, currency: CryptoCurrency) => {
|
|
30
|
+
const float = new BigNumber(value);
|
|
31
|
+
|
|
32
|
+
if (!float.isNaN() && float.gt(0)) {
|
|
33
|
+
const { magnitude } = currency.units[0];
|
|
34
|
+
return float.times(new BigNumber(10).pow(magnitude));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function decodeURIScheme(str: string): Data {
|
|
39
|
+
const m = str.match(/(([a-zA-Z]+):)?([^?]+)(\?(.+))?/);
|
|
40
|
+
|
|
41
|
+
if (!m) {
|
|
42
|
+
// as a fallback we'll fallback str to be an address
|
|
43
|
+
return {
|
|
44
|
+
address: str,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const [, , scheme, address, , queryStr] = m;
|
|
49
|
+
const query: Record<string, any> = queryStr
|
|
50
|
+
? querystring.parse(queryStr)
|
|
51
|
+
: {};
|
|
52
|
+
const currency = findCryptoCurrencyByScheme(scheme);
|
|
53
|
+
|
|
54
|
+
if (!currency) {
|
|
55
|
+
return {
|
|
56
|
+
address,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const data: Data = {
|
|
61
|
+
currency,
|
|
62
|
+
address,
|
|
63
|
+
};
|
|
64
|
+
const { amount, ...specificFields } = { ...query } as Partial<{
|
|
65
|
+
amount: any;
|
|
66
|
+
value: any;
|
|
67
|
+
gas: any;
|
|
68
|
+
gasPrice: any;
|
|
69
|
+
}>;
|
|
70
|
+
|
|
71
|
+
if (currency.id === "ethereum") {
|
|
72
|
+
if (specificFields.value) {
|
|
73
|
+
data.amount = new BigNumber(specificFields.value);
|
|
74
|
+
|
|
75
|
+
if (data.amount.isNegative()) {
|
|
76
|
+
data.amount = new BigNumber(0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
delete specificFields.value;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (specificFields.gas) {
|
|
83
|
+
data.userGasLimit = new BigNumber(specificFields.gas);
|
|
84
|
+
|
|
85
|
+
if (data.userGasLimit.isNegative()) {
|
|
86
|
+
data.userGasLimit = new BigNumber(0);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
delete specificFields.gas;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (specificFields.gasPrice) {
|
|
93
|
+
data.gasPrice = new BigNumber(specificFields.gasPrice);
|
|
94
|
+
|
|
95
|
+
if (data.gasPrice.isNegative()) {
|
|
96
|
+
data.gasPrice = new BigNumber(0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
delete specificFields.gasPrice;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Object.assign(data, specificFields);
|
|
104
|
+
|
|
105
|
+
if (amount) {
|
|
106
|
+
const cValue = convertedValue(amount, currency);
|
|
107
|
+
|
|
108
|
+
if (cValue) {
|
|
109
|
+
data.amount = cValue;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return data;
|
|
114
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// remove the extra decimals that can't be represented in unit
|
|
2
|
+
// this function will preserve the string characters
|
|
3
|
+
// for instance EUR 1230.00234 will be transformed to EUR 1230.00
|
|
4
|
+
// NB this function parse a subset of formats because it it locale independent.
|
|
5
|
+
// make sure you have at least following options set on the formatter:
|
|
6
|
+
|
|
7
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
8
|
+
|
|
9
|
+
// - useGrouping: true
|
|
10
|
+
export const chopCurrencyUnitDecimals = (
|
|
11
|
+
unit: Unit,
|
|
12
|
+
valueString: string
|
|
13
|
+
): string => {
|
|
14
|
+
let str = "";
|
|
15
|
+
let decimals = -1;
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < valueString.length; i++) {
|
|
18
|
+
const c = valueString[i];
|
|
19
|
+
|
|
20
|
+
if (decimals >= 0 && /[0-9]/.test(c)) {
|
|
21
|
+
decimals++;
|
|
22
|
+
|
|
23
|
+
if (decimals > unit.magnitude) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
} else if (c === "," || c === ".") {
|
|
27
|
+
decimals = 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
str += c;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return str;
|
|
34
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { prefixFormat, suffixFormat } from "./localeUtility";
|
|
3
|
+
import { toLocaleString } from "./BigNumberToLocaleString";
|
|
4
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
5
|
+
const nonBreakableSpace = " ";
|
|
6
|
+
const defaultFormatOptions = {
|
|
7
|
+
locale: "en-EN",
|
|
8
|
+
// show the currency code
|
|
9
|
+
showCode: false,
|
|
10
|
+
// always show the sign, even if it's a positive value
|
|
11
|
+
alwaysShowSign: false,
|
|
12
|
+
// override showAllDigits of the unit
|
|
13
|
+
showAllDigits: false,
|
|
14
|
+
// disable the feature that only show significant digits
|
|
15
|
+
// and removes the negligible extra digits.
|
|
16
|
+
// (rounding is dynamically applied based on the value. higher value means more rounding)
|
|
17
|
+
disableRounding: false,
|
|
18
|
+
// enable or not the thousands grouping (e.g; 1,234.00)
|
|
19
|
+
useGrouping: true,
|
|
20
|
+
// this allow to increase the number of digits displayed
|
|
21
|
+
// even if the currency don't allow more than this (sub-cent)
|
|
22
|
+
// a value of 1 can display USD 0.006 for instance. 2 can display USD 0.0065
|
|
23
|
+
// NB even if you set 3, USD 4.50 will be display as USD 4.50 , not 4.5000 (extra zeros are not displayed)
|
|
24
|
+
subMagnitude: 0,
|
|
25
|
+
// discrete mode will hide amounts
|
|
26
|
+
discreet: false,
|
|
27
|
+
joinFragmentsSeparator: "",
|
|
28
|
+
// Increase the significant digits. Ex: For a value of 1.121212 BTC, dynamicSignificantDigits of 4 => 1.121 / dynamicSignificantDigits of 6 => 1.12121
|
|
29
|
+
dynamicSignificantDigits: 6,
|
|
30
|
+
staticSignificantDigits: 8,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type formatCurrencyUnitOptions = Partial<typeof defaultFormatOptions>;
|
|
34
|
+
|
|
35
|
+
type FormatFragment =
|
|
36
|
+
| {
|
|
37
|
+
kind: "value";
|
|
38
|
+
value: string;
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
kind: "sign";
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
kind: "code";
|
|
46
|
+
value: string;
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
kind: "separator";
|
|
50
|
+
value: string;
|
|
51
|
+
};
|
|
52
|
+
type FormatFragmentTypes = "value" | "sign" | "code" | "separator";
|
|
53
|
+
export function formatCurrencyUnitFragment(
|
|
54
|
+
unit: Unit,
|
|
55
|
+
value: BigNumber,
|
|
56
|
+
_options?: formatCurrencyUnitOptions
|
|
57
|
+
): FormatFragment[] {
|
|
58
|
+
if (!BigNumber.isBigNumber(value)) {
|
|
59
|
+
console.warn("formatCurrencyUnit called with value=", value);
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (value.isNaN()) {
|
|
64
|
+
console.warn("formatCurrencyUnit called with NaN value!");
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!value.isFinite()) {
|
|
69
|
+
console.warn("formatCurrencyUnit called with infinite value=", value);
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const options: Record<
|
|
74
|
+
string,
|
|
75
|
+
formatCurrencyUnitOptions[keyof formatCurrencyUnitOptions]
|
|
76
|
+
> = {};
|
|
77
|
+
|
|
78
|
+
if (_options) {
|
|
79
|
+
let k: keyof formatCurrencyUnitOptions;
|
|
80
|
+
for (k in _options) {
|
|
81
|
+
// sanitize the undefined value
|
|
82
|
+
const value = _options[k];
|
|
83
|
+
if (value !== undefined) {
|
|
84
|
+
options[k] = value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const {
|
|
90
|
+
showCode,
|
|
91
|
+
alwaysShowSign,
|
|
92
|
+
showAllDigits,
|
|
93
|
+
locale,
|
|
94
|
+
disableRounding,
|
|
95
|
+
useGrouping,
|
|
96
|
+
subMagnitude,
|
|
97
|
+
discreet,
|
|
98
|
+
dynamicSignificantDigits,
|
|
99
|
+
staticSignificantDigits,
|
|
100
|
+
} = { ...defaultFormatOptions, ...unit, ...options };
|
|
101
|
+
const { magnitude, code } = unit;
|
|
102
|
+
const floatValue = value.div(new BigNumber(10).pow(magnitude));
|
|
103
|
+
const floatValueAbs = floatValue.abs();
|
|
104
|
+
const minimumFractionDigits = showAllDigits ? magnitude : 0;
|
|
105
|
+
const maximumFractionDigits = disableRounding
|
|
106
|
+
? magnitude + subMagnitude
|
|
107
|
+
: Math.max(
|
|
108
|
+
minimumFractionDigits,
|
|
109
|
+
Math.max(
|
|
110
|
+
0, // dynamic max number of digits based on the value itself. to only show significant part
|
|
111
|
+
Math.min(
|
|
112
|
+
dynamicSignificantDigits -
|
|
113
|
+
Math.ceil(Math.log10(floatValueAbs.toNumber())),
|
|
114
|
+
magnitude + subMagnitude,
|
|
115
|
+
staticSignificantDigits
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
const fragValueByKind = {
|
|
120
|
+
sign:
|
|
121
|
+
alwaysShowSign || floatValue.isNegative()
|
|
122
|
+
? floatValue.isNegative()
|
|
123
|
+
? "-"
|
|
124
|
+
: "+"
|
|
125
|
+
: null,
|
|
126
|
+
code: showCode ? code : null,
|
|
127
|
+
value: discreet
|
|
128
|
+
? "***"
|
|
129
|
+
: toLocaleString(floatValueAbs, locale, {
|
|
130
|
+
maximumFractionDigits,
|
|
131
|
+
minimumFractionDigits,
|
|
132
|
+
useGrouping,
|
|
133
|
+
}),
|
|
134
|
+
separator: nonBreakableSpace,
|
|
135
|
+
};
|
|
136
|
+
const frags: FormatFragment[] = [];
|
|
137
|
+
let nonSepIndex = -1;
|
|
138
|
+
let sepConsumed = true;
|
|
139
|
+
(unit.prefixCode ? prefixFormat : suffixFormat).forEach((kind) => {
|
|
140
|
+
const v = fragValueByKind[kind];
|
|
141
|
+
if (!v) return;
|
|
142
|
+
const isSep = kind === "separator";
|
|
143
|
+
if (sepConsumed && isSep) return;
|
|
144
|
+
sepConsumed = isSep;
|
|
145
|
+
if (!isSep) nonSepIndex = frags.length;
|
|
146
|
+
frags.push({
|
|
147
|
+
kind: kind as FormatFragmentTypes,
|
|
148
|
+
value: v,
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
frags.splice(nonSepIndex + 1); // remove extra space at the end
|
|
152
|
+
|
|
153
|
+
return frags;
|
|
154
|
+
}
|
|
155
|
+
// simplification of formatCurrencyUnitFragment if no fragmented styles is needed
|
|
156
|
+
export function formatCurrencyUnit(
|
|
157
|
+
unit: Unit,
|
|
158
|
+
value: BigNumber,
|
|
159
|
+
options?: formatCurrencyUnitOptions
|
|
160
|
+
): string {
|
|
161
|
+
const joinFragmentsSeparator =
|
|
162
|
+
(options && options.joinFragmentsSeparator) ||
|
|
163
|
+
defaultFormatOptions.joinFragmentsSeparator;
|
|
164
|
+
return formatCurrencyUnitFragment(unit, value, options)
|
|
165
|
+
.map((f) => f.value)
|
|
166
|
+
.join(joinFragmentsSeparator);
|
|
167
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import numeral from "numeral";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
import { formatCurrencyUnit } from "./formatCurrencyUnit";
|
|
4
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This will format in a very concise way a valid, typically to be used on axis.
|
|
8
|
+
* For instance 15k 20k ,...
|
|
9
|
+
*/
|
|
10
|
+
export function formatShort(unit: Unit, value: BigNumber): string {
|
|
11
|
+
const { magnitude } = unit;
|
|
12
|
+
const floatValue = value.div(new BigNumber(10).pow(magnitude));
|
|
13
|
+
|
|
14
|
+
if (floatValue.isZero()) {
|
|
15
|
+
return "0";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (new BigNumber(-1).isLessThan(floatValue) && floatValue.isLessThan(1)) {
|
|
19
|
+
// numeral have issues with low values, fallback on formatCurrencyUnit
|
|
20
|
+
return formatCurrencyUnit(unit, value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return numeral(floatValue.toNumber()).format("0[.]0a");
|
|
24
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { encodeURIScheme, decodeURIScheme } from "./CurrencyURIScheme";
|
|
2
|
+
import { sanitizeValueString } from "./sanitizeValueString";
|
|
3
|
+
import {
|
|
4
|
+
listFiatCurrencies,
|
|
5
|
+
findFiatCurrencyByTicker,
|
|
6
|
+
getFiatCurrencyByTicker,
|
|
7
|
+
hasFiatCurrencyTicker,
|
|
8
|
+
listCryptoCurrencies,
|
|
9
|
+
getCryptoCurrencyById,
|
|
10
|
+
hasCryptoCurrencyId,
|
|
11
|
+
findCryptoCurrency,
|
|
12
|
+
findCryptoCurrencyById,
|
|
13
|
+
findCryptoCurrencyByScheme,
|
|
14
|
+
findCryptoCurrencyByKeyword,
|
|
15
|
+
findCryptoCurrencyByTicker,
|
|
16
|
+
listTokens,
|
|
17
|
+
listTokensForCryptoCurrency,
|
|
18
|
+
listTokenTypesForCryptoCurrency,
|
|
19
|
+
findTokenByTicker,
|
|
20
|
+
findTokenById,
|
|
21
|
+
findTokenByAddress,
|
|
22
|
+
hasTokenId,
|
|
23
|
+
findCompoundToken,
|
|
24
|
+
getAbandonSeedAddress,
|
|
25
|
+
getTokenById,
|
|
26
|
+
addTokens,
|
|
27
|
+
} from "@ledgerhq/cryptoassets";
|
|
28
|
+
export * from "./support";
|
|
29
|
+
import { parseCurrencyUnit } from "./parseCurrencyUnit";
|
|
30
|
+
import { chopCurrencyUnitDecimals } from "./chopCurrencyUnitDecimals";
|
|
31
|
+
import {
|
|
32
|
+
formatCurrencyUnit,
|
|
33
|
+
formatCurrencyUnitFragment,
|
|
34
|
+
} from "./formatCurrencyUnit";
|
|
35
|
+
import { formatShort } from "./formatShort";
|
|
36
|
+
import { valueFromUnit } from "./valueFromUnit";
|
|
37
|
+
import type { Currency } from "@ledgerhq/types-cryptoassets";
|
|
38
|
+
|
|
39
|
+
const findCurrencyByTicker = (ticker: string): Currency | null | undefined =>
|
|
40
|
+
findCryptoCurrencyByTicker(ticker) ||
|
|
41
|
+
findFiatCurrencyByTicker(ticker) ||
|
|
42
|
+
findTokenByTicker(ticker);
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
listFiatCurrencies,
|
|
46
|
+
listCryptoCurrencies,
|
|
47
|
+
getFiatCurrencyByTicker,
|
|
48
|
+
findCurrencyByTicker,
|
|
49
|
+
findCryptoCurrency,
|
|
50
|
+
findCryptoCurrencyById,
|
|
51
|
+
findCryptoCurrencyByTicker,
|
|
52
|
+
findCryptoCurrencyByScheme,
|
|
53
|
+
findCryptoCurrencyByKeyword,
|
|
54
|
+
findFiatCurrencyByTicker,
|
|
55
|
+
hasFiatCurrencyTicker,
|
|
56
|
+
listTokensForCryptoCurrency,
|
|
57
|
+
listTokenTypesForCryptoCurrency,
|
|
58
|
+
findTokenByAddress,
|
|
59
|
+
findTokenByTicker,
|
|
60
|
+
findTokenById,
|
|
61
|
+
hasTokenId,
|
|
62
|
+
getTokenById,
|
|
63
|
+
getAbandonSeedAddress,
|
|
64
|
+
parseCurrencyUnit,
|
|
65
|
+
chopCurrencyUnitDecimals,
|
|
66
|
+
formatCurrencyUnit,
|
|
67
|
+
formatCurrencyUnitFragment,
|
|
68
|
+
formatShort,
|
|
69
|
+
getCryptoCurrencyById,
|
|
70
|
+
hasCryptoCurrencyId,
|
|
71
|
+
encodeURIScheme,
|
|
72
|
+
decodeURIScheme,
|
|
73
|
+
valueFromUnit,
|
|
74
|
+
sanitizeValueString,
|
|
75
|
+
findCompoundToken,
|
|
76
|
+
listTokens,
|
|
77
|
+
addTokens,
|
|
78
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import memoize from "lodash/memoize";
|
|
2
|
+
const options = {
|
|
3
|
+
style: "currency",
|
|
4
|
+
currency: "USD",
|
|
5
|
+
};
|
|
6
|
+
const localeNotAvailable = (1.2).toLocaleString("en", options) !== "$1.20";
|
|
7
|
+
|
|
8
|
+
const getFallback = (locale: string) =>
|
|
9
|
+
staticFallback[Object.keys(staticFallback).includes(locale) ? locale : "en"];
|
|
10
|
+
|
|
11
|
+
const staticFallback: Record<string, [string, string]> = {
|
|
12
|
+
en: ["-$1.00", "10,000.2"],
|
|
13
|
+
es: ["-1,00 US$", "10.000,2"],
|
|
14
|
+
fr: ["-1,00 $US", "10 000,2"],
|
|
15
|
+
ja: ["-US$1.00", "10,000.2"],
|
|
16
|
+
ko: ["-US$1.00", "10,000.2"],
|
|
17
|
+
ru: ["-1,00 $", "10 000,2"],
|
|
18
|
+
zh: ["-US$1.00", "10,000.2"],
|
|
19
|
+
};
|
|
20
|
+
export const prefixFormat = ["sign", "code", "value"] as const;
|
|
21
|
+
export const suffixFormat = ["sign", "value", "separator", "code"] as const;
|
|
22
|
+
// returns decimal and thousands separator
|
|
23
|
+
// FIXME: rename thousands to group
|
|
24
|
+
export type GetSeparators = (locale: string) => {
|
|
25
|
+
decimal: string | null | undefined;
|
|
26
|
+
thousands: string | null | undefined;
|
|
27
|
+
};
|
|
28
|
+
export const getSeparators: GetSeparators = memoize((locale) => {
|
|
29
|
+
const res = localeNotAvailable
|
|
30
|
+
? getFallback(locale)[1]
|
|
31
|
+
: (10000.2).toLocaleString(locale);
|
|
32
|
+
let decimal;
|
|
33
|
+
let thousands;
|
|
34
|
+
|
|
35
|
+
for (let i = 0; i < res.length; i++) {
|
|
36
|
+
const c = res[i];
|
|
37
|
+
if (/[0-9]/.test(c)) continue;
|
|
38
|
+
|
|
39
|
+
if (!thousands) {
|
|
40
|
+
thousands = c;
|
|
41
|
+
} else {
|
|
42
|
+
decimal = c;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
decimal,
|
|
48
|
+
thousands,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
// parse a value that was formatted with formatCurrencyUnit
|
|
4
|
+
// NB this function parse a subset of formats because it it locale independant.
|
|
5
|
+
// make sure you have at least following options set on the formatter:
|
|
6
|
+
// - useGrouping: true
|
|
7
|
+
// - showCode: false
|
|
8
|
+
export const parseCurrencyUnit = (
|
|
9
|
+
unit: Unit,
|
|
10
|
+
valueString: string
|
|
11
|
+
): BigNumber => {
|
|
12
|
+
const str = valueString.replace(/,/g, ".");
|
|
13
|
+
const value = new BigNumber(str);
|
|
14
|
+
if (value.isNaN()) return new BigNumber(0);
|
|
15
|
+
return value.times(new BigNumber(10).pow(unit.magnitude)).integerValue();
|
|
16
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { getSeparators } from "./localeUtility";
|
|
3
|
+
const numbers = "0123456789";
|
|
4
|
+
export const sanitizeValueString = (
|
|
5
|
+
unit: Unit,
|
|
6
|
+
valueString: string,
|
|
7
|
+
locale?: string
|
|
8
|
+
): {
|
|
9
|
+
display: string;
|
|
10
|
+
value: string;
|
|
11
|
+
} => {
|
|
12
|
+
const s = getSeparators(locale || "en-US");
|
|
13
|
+
const dot = s.decimal || ".";
|
|
14
|
+
let display = "";
|
|
15
|
+
let value = "";
|
|
16
|
+
let decimals = -1;
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < valueString.length; i++) {
|
|
19
|
+
const c = valueString[i];
|
|
20
|
+
|
|
21
|
+
if (numbers.indexOf(c) !== -1) {
|
|
22
|
+
if (decimals >= 0) {
|
|
23
|
+
decimals++;
|
|
24
|
+
if (decimals > unit.magnitude) break;
|
|
25
|
+
value = value === "0" ? c : value + c;
|
|
26
|
+
display += c;
|
|
27
|
+
} else if (value !== "0") {
|
|
28
|
+
value += c;
|
|
29
|
+
display += c;
|
|
30
|
+
} else {
|
|
31
|
+
value = c;
|
|
32
|
+
display = c;
|
|
33
|
+
}
|
|
34
|
+
} else if (decimals === -1 && (c === "," || c === ".")) {
|
|
35
|
+
if (unit.magnitude === 0) {
|
|
36
|
+
// in this specific case, we will never allow commas
|
|
37
|
+
return {
|
|
38
|
+
display,
|
|
39
|
+
value,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (i === 0) display = "0";
|
|
44
|
+
decimals = 0;
|
|
45
|
+
display += dot;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (let i = Math.max(0, decimals); i < unit.magnitude; ++i) {
|
|
50
|
+
value += "0";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!value) value = "0";
|
|
54
|
+
return {
|
|
55
|
+
display,
|
|
56
|
+
value,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFiatCurrencyByTicker,
|
|
3
|
+
getCryptoCurrencyById,
|
|
4
|
+
hasCryptoCurrencyId,
|
|
5
|
+
} from "@ledgerhq/cryptoassets";
|
|
6
|
+
import {
|
|
7
|
+
CryptoCurrency,
|
|
8
|
+
CryptoCurrencyId,
|
|
9
|
+
FiatCurrency,
|
|
10
|
+
} from "@ledgerhq/types-cryptoassets";
|
|
11
|
+
import { getEnv } from "../env";
|
|
12
|
+
|
|
13
|
+
// set by user side effect to precise which currencies are considered supported (typically by live)
|
|
14
|
+
let userSupportedCurrencies: CryptoCurrency[] = [];
|
|
15
|
+
let userSupportedFiats: FiatCurrency[] = [];
|
|
16
|
+
// Current list was established with what our API really supports
|
|
17
|
+
// to update the list,
|
|
18
|
+
// 1. $ ledger-live countervalues --format supportedFiats --fiats
|
|
19
|
+
// 2. copy & paste the output
|
|
20
|
+
setSupportedFiats([
|
|
21
|
+
"AED",
|
|
22
|
+
"AUD",
|
|
23
|
+
"BGN",
|
|
24
|
+
"BHD",
|
|
25
|
+
"BRL",
|
|
26
|
+
"CAD",
|
|
27
|
+
"CHF",
|
|
28
|
+
"CLP",
|
|
29
|
+
"CNY",
|
|
30
|
+
"CRC",
|
|
31
|
+
"CZK",
|
|
32
|
+
"DKK",
|
|
33
|
+
"EUR",
|
|
34
|
+
"GBP",
|
|
35
|
+
"GHS",
|
|
36
|
+
"HKD",
|
|
37
|
+
"HRK",
|
|
38
|
+
"HUF",
|
|
39
|
+
"IDR",
|
|
40
|
+
"ILS",
|
|
41
|
+
"INR",
|
|
42
|
+
"IRR",
|
|
43
|
+
"JPY",
|
|
44
|
+
"KES",
|
|
45
|
+
"KHR",
|
|
46
|
+
"KRW",
|
|
47
|
+
"MUR",
|
|
48
|
+
"MXN",
|
|
49
|
+
"MYR",
|
|
50
|
+
"NGN",
|
|
51
|
+
"NOK",
|
|
52
|
+
"NZD",
|
|
53
|
+
"PHP",
|
|
54
|
+
"PKR",
|
|
55
|
+
"PLN",
|
|
56
|
+
"RON",
|
|
57
|
+
"RUB",
|
|
58
|
+
"SEK",
|
|
59
|
+
"SGD",
|
|
60
|
+
"THB",
|
|
61
|
+
"TRY",
|
|
62
|
+
"TZS",
|
|
63
|
+
"UAH",
|
|
64
|
+
"UGX",
|
|
65
|
+
"USD",
|
|
66
|
+
"VES",
|
|
67
|
+
"VND",
|
|
68
|
+
"VUV",
|
|
69
|
+
"ZAR",
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
export function isFiatSupported(fiat: FiatCurrency) {
|
|
73
|
+
return userSupportedFiats.includes(fiat);
|
|
74
|
+
}
|
|
75
|
+
export function setSupportedFiats(ids: string[]) {
|
|
76
|
+
userSupportedFiats = ids.map(getFiatCurrencyByTicker);
|
|
77
|
+
}
|
|
78
|
+
export function listSupportedFiats(): FiatCurrency[] {
|
|
79
|
+
return userSupportedFiats;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function setSupportedCurrencies(ids: CryptoCurrencyId[]) {
|
|
83
|
+
userSupportedCurrencies = Array.from(new Set(ids)) // Make sure to remove duplicates
|
|
84
|
+
.map((id) => getCryptoCurrencyById(id));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getExperimentalSupports() {
|
|
88
|
+
return getEnv("EXPERIMENTAL_CURRENCIES")
|
|
89
|
+
.split(",")
|
|
90
|
+
.filter(
|
|
91
|
+
(id: string) =>
|
|
92
|
+
hasCryptoCurrencyId(id) &&
|
|
93
|
+
!userSupportedCurrencies.find((c) => c.id === id)
|
|
94
|
+
)
|
|
95
|
+
.map(getCryptoCurrencyById);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function listSupportedCurrencies(): CryptoCurrency[] {
|
|
99
|
+
const experimentals = getExperimentalSupports();
|
|
100
|
+
return experimentals.length === 0
|
|
101
|
+
? userSupportedCurrencies
|
|
102
|
+
: userSupportedCurrencies.concat(experimentals);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function isCurrencySupported(currency: CryptoCurrency): boolean {
|
|
106
|
+
return listSupportedCurrencies().includes(currency);
|
|
107
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* convert a value in a given unit to a normalized value
|
|
6
|
+
* For instance, for 1 BTC, valueFromUnit(1, btcUnit) returns 100000000
|
|
7
|
+
* @memberof countervalue
|
|
8
|
+
*/
|
|
9
|
+
export const valueFromUnit = (valueInUnit: BigNumber, unit: Unit) =>
|
|
10
|
+
valueInUnit.times(new BigNumber(10).pow(unit.magnitude));
|