@ton/appkit 0.0.5-alpha.3 → 1.0.0-alpha.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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +132 -0
- package/dist/cjs/actions/index.d.ts +8 -0
- package/dist/cjs/actions/index.d.ts.map +1 -1
- package/dist/cjs/actions/index.js +18 -2
- package/dist/cjs/actions/jettons/create-transfer-jetton-transaction.d.ts +1 -1
- package/dist/cjs/actions/jettons/create-transfer-jetton-transaction.d.ts.map +1 -1
- package/dist/cjs/actions/jettons/create-transfer-jetton-transaction.js +17 -5
- package/dist/cjs/actions/jettons/get-jetton-balance.d.ts +1 -1
- package/dist/cjs/actions/jettons/get-jetton-balance.d.ts.map +1 -1
- package/dist/cjs/actions/jettons/get-jetton-balance.js +8 -3
- package/dist/cjs/actions/jettons/get-jetton-info.d.ts.map +1 -1
- package/dist/cjs/actions/jettons/get-jetton-info.js +15 -6
- package/dist/cjs/actions/jettons/get-jetton-wallet-address.d.ts +1 -1
- package/dist/cjs/actions/jettons/get-jetton-wallet-address.d.ts.map +1 -1
- package/dist/cjs/actions/jettons/get-jetton-wallet-address.js +15 -4
- package/dist/cjs/actions/nft/get-nft.d.ts +1 -1
- package/dist/cjs/actions/nft/get-nft.d.ts.map +1 -1
- package/dist/cjs/actions/staking/get-staking-provider-metadata.d.ts +19 -0
- package/dist/cjs/actions/staking/get-staking-provider-metadata.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staking-provider-metadata.js +18 -0
- package/dist/cjs/actions/staking/get-staking-provider.d.ts +21 -0
- package/dist/cjs/actions/staking/get-staking-provider.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staking-provider.js +17 -0
- package/dist/cjs/actions/staking/get-staking-providers.d.ts +3 -2
- package/dist/cjs/actions/staking/get-staking-providers.d.ts.map +1 -1
- package/dist/cjs/actions/staking/get-staking-providers.js +2 -2
- package/dist/cjs/actions/staking/set-default-staking-provider.d.ts +18 -0
- package/dist/cjs/actions/staking/set-default-staking-provider.d.ts.map +1 -0
- package/dist/cjs/actions/staking/set-default-staking-provider.js +18 -0
- package/dist/cjs/actions/staking/watch-staking-providers.d.ts +17 -0
- package/dist/cjs/actions/staking/watch-staking-providers.d.ts.map +1 -0
- package/dist/cjs/actions/staking/watch-staking-providers.js +28 -0
- package/dist/cjs/actions/swap/get-swap-provider.d.ts +15 -0
- package/dist/cjs/actions/swap/get-swap-provider.d.ts.map +1 -0
- package/dist/cjs/actions/swap/get-swap-provider.js +14 -0
- package/dist/cjs/actions/swap/get-swap-providers.d.ts +15 -0
- package/dist/cjs/actions/swap/get-swap-providers.d.ts.map +1 -0
- package/dist/cjs/actions/swap/get-swap-providers.js +17 -0
- package/dist/cjs/actions/swap/get-swap-quote.d.ts.map +1 -1
- package/dist/cjs/actions/swap/get-swap-quote.js +6 -1
- package/dist/cjs/actions/swap/set-default-swap-provider.d.ts +18 -0
- package/dist/cjs/actions/swap/set-default-swap-provider.d.ts.map +1 -0
- package/dist/cjs/actions/swap/set-default-swap-provider.js +18 -0
- package/dist/cjs/actions/swap/watch-swap-providers.d.ts +17 -0
- package/dist/cjs/actions/swap/watch-swap-providers.d.ts.map +1 -0
- package/dist/cjs/actions/swap/watch-swap-providers.js +29 -0
- package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.js +2 -2
- package/dist/cjs/core/app-kit/constants/events.d.ts +0 -6
- package/dist/cjs/core/app-kit/constants/events.d.ts.map +1 -1
- package/dist/cjs/core/app-kit/constants/events.js +1 -7
- package/dist/cjs/core/app-kit/index.d.ts +2 -2
- package/dist/cjs/core/app-kit/index.d.ts.map +1 -1
- package/dist/cjs/core/app-kit/index.js +1 -2
- package/dist/cjs/core/app-kit/services/app-kit.d.ts +3 -1
- package/dist/cjs/core/app-kit/services/app-kit.d.ts.map +1 -1
- package/dist/cjs/core/app-kit/services/app-kit.js +4 -2
- package/dist/cjs/core/app-kit/types/config.d.ts +4 -2
- package/dist/cjs/core/app-kit/types/config.d.ts.map +1 -1
- package/dist/cjs/core/app-kit/types/events.d.ts +2 -7
- package/dist/cjs/core/app-kit/types/events.d.ts.map +1 -1
- package/dist/cjs/core/cache/adapters/lru-app-kit-cache.d.ts +20 -0
- package/dist/cjs/core/cache/adapters/lru-app-kit-cache.d.ts.map +1 -0
- package/dist/cjs/core/cache/adapters/lru-app-kit-cache.js +32 -0
- package/dist/cjs/core/cache/adapters/lru-app-kit-cache.test.d.ts +9 -0
- package/dist/cjs/core/cache/adapters/lru-app-kit-cache.test.d.ts.map +1 -0
- package/dist/cjs/core/cache/adapters/lru-app-kit-cache.test.js +68 -0
- package/dist/cjs/core/cache/index.d.ts +11 -0
- package/dist/cjs/core/cache/index.d.ts.map +1 -0
- package/dist/cjs/core/cache/index.js +14 -0
- package/dist/cjs/core/cache/types/app-kit-cache.d.ts +14 -0
- package/dist/cjs/core/cache/types/app-kit-cache.d.ts.map +1 -0
- package/dist/cjs/core/cache/types/app-kit-cache.js +9 -0
- package/dist/cjs/core/cache/utils/get-cache-key.d.ts +9 -0
- package/dist/cjs/core/cache/utils/get-cache-key.d.ts.map +1 -0
- package/dist/cjs/core/cache/utils/get-cache-key.js +12 -0
- package/dist/cjs/core/cache/utils/get-cache-key.test.d.ts +9 -0
- package/dist/cjs/core/cache/utils/get-cache-key.test.d.ts.map +1 -0
- package/dist/cjs/core/cache/utils/get-cache-key.test.js +30 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/queries/balances/get-balance-by-address.d.ts.map +1 -1
- package/dist/cjs/queries/balances/get-balance-by-address.js +9 -3
- package/dist/cjs/queries/index.d.ts +0 -1
- package/dist/cjs/queries/index.d.ts.map +1 -1
- package/dist/cjs/queries/index.js +1 -3
- package/dist/cjs/queries/jettons/get-jetton-balance-by-address.d.ts.map +1 -1
- package/dist/cjs/queries/jettons/get-jetton-balance-by-address.js +11 -11
- package/dist/cjs/queries/jettons/get-jetton-info.d.ts.map +1 -1
- package/dist/cjs/queries/jettons/get-jetton-info.js +5 -1
- package/dist/cjs/queries/jettons/get-jetton-wallet-address.d.ts.map +1 -1
- package/dist/cjs/queries/jettons/get-jetton-wallet-address.js +6 -1
- package/dist/cjs/queries/jettons/get-jettons-by-address.d.ts.map +1 -1
- package/dist/cjs/queries/jettons/get-jettons-by-address.js +9 -3
- package/dist/cjs/queries/nft/get-nft.d.ts +1 -1
- package/dist/cjs/queries/nft/get-nft.d.ts.map +1 -1
- package/dist/cjs/queries/nft/get-nft.js +5 -1
- package/dist/cjs/queries/nft/get-nfts-by-address.d.ts.map +1 -1
- package/dist/cjs/queries/nft/get-nfts-by-address.js +5 -1
- package/dist/cjs/queries/staking/get-staked-balance.d.ts +1 -1
- package/dist/cjs/queries/staking/get-staked-balance.d.ts.map +1 -1
- package/dist/cjs/queries/staking/get-staked-balance.js +7 -1
- package/dist/cjs/queries/staking/get-staking-provider-info.d.ts +1 -1
- package/dist/cjs/queries/staking/get-staking-provider-info.d.ts.map +1 -1
- package/dist/cjs/queries/staking/get-staking-provider-info.js +3 -1
- package/dist/cjs/queries/staking/get-staking-quote.d.ts +1 -1
- package/dist/cjs/queries/staking/get-staking-quote.d.ts.map +1 -1
- package/dist/cjs/queries/staking/get-staking-quote.js +8 -2
- package/dist/cjs/queries/swap/get-swap-quote.d.ts.map +1 -1
- package/dist/cjs/queries/swap/get-swap-quote.js +1 -1
- package/dist/cjs/staking/index.d.ts +2 -2
- package/dist/cjs/staking/index.d.ts.map +1 -1
- package/dist/cjs/staking/index.js +3 -1
- package/dist/cjs/swap/index.d.ts +2 -1
- package/dist/cjs/swap/index.d.ts.map +1 -1
- package/dist/cjs/swap/index.js +6 -0
- package/dist/cjs/types/connector.d.ts +0 -1
- package/dist/cjs/types/connector.d.ts.map +1 -1
- package/dist/cjs/types/primitives.d.ts +1 -1
- package/dist/cjs/types/primitives.d.ts.map +1 -1
- package/dist/cjs/utils/address/is-valid-address.d.ts +11 -0
- package/dist/cjs/utils/address/is-valid-address.d.ts.map +1 -0
- package/dist/cjs/utils/address/is-valid-address.js +38 -0
- package/dist/cjs/utils/address/to-bounceble-address.d.ts +11 -0
- package/dist/cjs/utils/address/to-bounceble-address.d.ts.map +1 -0
- package/dist/cjs/utils/address/to-bounceble-address.js +36 -0
- package/dist/cjs/utils/address/to-non-bounceble-address.d.ts +11 -0
- package/dist/cjs/utils/address/to-non-bounceble-address.d.ts.map +1 -0
- package/dist/cjs/utils/address/to-non-bounceble-address.js +36 -0
- package/dist/cjs/utils/amount/calc-fiat-value.d.ts +13 -0
- package/dist/cjs/utils/amount/calc-fiat-value.d.ts.map +1 -0
- package/dist/cjs/utils/amount/calc-fiat-value.js +22 -0
- package/dist/cjs/utils/amount/calc-fiat-value.test.d.ts +9 -0
- package/dist/cjs/utils/amount/calc-fiat-value.test.d.ts.map +1 -0
- package/dist/cjs/utils/amount/calc-fiat-value.test.js +39 -0
- package/dist/cjs/utils/amount/format-large-value.d.ts +9 -0
- package/dist/cjs/utils/amount/format-large-value.d.ts.map +1 -0
- package/dist/cjs/utils/amount/format-large-value.js +40 -0
- package/dist/cjs/utils/amount/format-large-value.test.d.ts +9 -0
- package/dist/cjs/utils/amount/format-large-value.test.d.ts.map +1 -0
- package/dist/cjs/utils/amount/format-large-value.test.js +43 -0
- package/dist/cjs/utils/amount/truncate-decimals.d.ts +9 -0
- package/dist/cjs/utils/amount/truncate-decimals.d.ts.map +1 -0
- package/dist/cjs/utils/amount/truncate-decimals.js +59 -0
- package/dist/cjs/utils/amount/truncate-decimals.test.d.ts +9 -0
- package/dist/cjs/utils/amount/truncate-decimals.test.d.ts.map +1 -0
- package/dist/cjs/utils/amount/truncate-decimals.test.js +83 -0
- package/dist/cjs/utils/balance/calc-max-spendable.d.ts +33 -0
- package/dist/cjs/utils/balance/calc-max-spendable.d.ts.map +1 -0
- package/dist/cjs/utils/balance/calc-max-spendable.js +29 -0
- package/dist/cjs/utils/balance/calc-max-spendable.test.d.ts +9 -0
- package/dist/cjs/utils/balance/calc-max-spendable.test.d.ts.map +1 -0
- package/dist/cjs/utils/balance/calc-max-spendable.test.js +38 -0
- package/dist/cjs/utils/balance/get-ton-shortfall.d.ts +58 -0
- package/dist/cjs/utils/balance/get-ton-shortfall.d.ts.map +1 -0
- package/dist/cjs/utils/balance/get-ton-shortfall.js +46 -0
- package/dist/cjs/utils/balance/get-ton-shortfall.test.d.ts +9 -0
- package/dist/cjs/utils/balance/get-ton-shortfall.test.d.ts.map +1 -0
- package/dist/cjs/utils/balance/get-ton-shortfall.test.js +133 -0
- package/dist/cjs/utils/functions/debounce.d.ts +80 -0
- package/dist/cjs/utils/functions/debounce.d.ts.map +1 -0
- package/dist/cjs/utils/functions/debounce.js +107 -0
- package/dist/cjs/utils/index.d.ts +10 -0
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +10 -0
- package/dist/cjs/utils/jetton/jetton-info.d.ts +2 -1
- package/dist/cjs/utils/jetton/jetton-info.d.ts.map +1 -1
- package/dist/cjs/utils/jetton/jetton-info.js +11 -1
- package/dist/cjs/utils/jetton/jetton-info.test.d.ts +9 -0
- package/dist/cjs/utils/jetton/jetton-info.test.d.ts.map +1 -0
- package/dist/cjs/utils/jetton/jetton-info.test.js +54 -0
- package/dist/cjs/utils/predicate/is-number.d.ts +9 -0
- package/dist/cjs/utils/predicate/is-number.d.ts.map +1 -0
- package/dist/cjs/utils/predicate/is-number.js +20 -0
- package/dist/cjs/utils/predicate/is-string.d.ts +1 -1
- package/dist/cjs/utils/predicate/is-string.d.ts.map +1 -1
- package/dist/cjs/utils/predicate/is-string.js +4 -3
- package/dist/esm/actions/index.d.ts +8 -0
- package/dist/esm/actions/index.d.ts.map +1 -1
- package/dist/esm/actions/index.js +8 -0
- package/dist/esm/actions/jettons/create-transfer-jetton-transaction.d.ts +1 -1
- package/dist/esm/actions/jettons/create-transfer-jetton-transaction.d.ts.map +1 -1
- package/dist/esm/actions/jettons/create-transfer-jetton-transaction.js +17 -5
- package/dist/esm/actions/jettons/get-jetton-balance.d.ts +1 -1
- package/dist/esm/actions/jettons/get-jetton-balance.d.ts.map +1 -1
- package/dist/esm/actions/jettons/get-jetton-balance.js +7 -2
- package/dist/esm/actions/jettons/get-jetton-info.d.ts.map +1 -1
- package/dist/esm/actions/jettons/get-jetton-info.js +15 -6
- package/dist/esm/actions/jettons/get-jetton-wallet-address.d.ts +1 -1
- package/dist/esm/actions/jettons/get-jetton-wallet-address.d.ts.map +1 -1
- package/dist/esm/actions/jettons/get-jetton-wallet-address.js +15 -4
- package/dist/esm/actions/nft/get-nft.d.ts +1 -1
- package/dist/esm/actions/nft/get-nft.d.ts.map +1 -1
- package/dist/esm/actions/staking/get-staking-provider-metadata.d.ts +19 -0
- package/dist/esm/actions/staking/get-staking-provider-metadata.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staking-provider-metadata.js +14 -0
- package/dist/esm/actions/staking/get-staking-provider.d.ts +21 -0
- package/dist/esm/actions/staking/get-staking-provider.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staking-provider.js +13 -0
- package/dist/esm/actions/staking/get-staking-providers.d.ts +3 -2
- package/dist/esm/actions/staking/get-staking-providers.d.ts.map +1 -1
- package/dist/esm/actions/staking/get-staking-providers.js +2 -2
- package/dist/esm/actions/staking/set-default-staking-provider.d.ts +18 -0
- package/dist/esm/actions/staking/set-default-staking-provider.d.ts.map +1 -0
- package/dist/esm/actions/staking/set-default-staking-provider.js +14 -0
- package/dist/esm/actions/staking/watch-staking-providers.d.ts +17 -0
- package/dist/esm/actions/staking/watch-staking-providers.d.ts.map +1 -0
- package/dist/esm/actions/staking/watch-staking-providers.js +24 -0
- package/dist/esm/actions/swap/get-swap-provider.d.ts +15 -0
- package/dist/esm/actions/swap/get-swap-provider.d.ts.map +1 -0
- package/dist/esm/actions/swap/get-swap-provider.js +10 -0
- package/dist/esm/actions/swap/get-swap-providers.d.ts +15 -0
- package/dist/esm/actions/swap/get-swap-providers.d.ts.map +1 -0
- package/dist/esm/actions/swap/get-swap-providers.js +13 -0
- package/dist/esm/actions/swap/get-swap-quote.d.ts.map +1 -1
- package/dist/esm/actions/swap/get-swap-quote.js +6 -1
- package/dist/esm/actions/swap/set-default-swap-provider.d.ts +18 -0
- package/dist/esm/actions/swap/set-default-swap-provider.d.ts.map +1 -0
- package/dist/esm/actions/swap/set-default-swap-provider.js +14 -0
- package/dist/esm/actions/swap/watch-swap-providers.d.ts +17 -0
- package/dist/esm/actions/swap/watch-swap-providers.d.ts.map +1 -0
- package/dist/esm/actions/swap/watch-swap-providers.js +25 -0
- package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.js +2 -2
- package/dist/esm/core/app-kit/constants/events.d.ts +0 -6
- package/dist/esm/core/app-kit/constants/events.d.ts.map +1 -1
- package/dist/esm/core/app-kit/constants/events.js +0 -6
- package/dist/esm/core/app-kit/index.d.ts +2 -2
- package/dist/esm/core/app-kit/index.d.ts.map +1 -1
- package/dist/esm/core/app-kit/index.js +1 -1
- package/dist/esm/core/app-kit/services/app-kit.d.ts +3 -1
- package/dist/esm/core/app-kit/services/app-kit.d.ts.map +1 -1
- package/dist/esm/core/app-kit/services/app-kit.js +4 -2
- package/dist/esm/core/app-kit/types/config.d.ts +4 -2
- package/dist/esm/core/app-kit/types/config.d.ts.map +1 -1
- package/dist/esm/core/app-kit/types/events.d.ts +2 -7
- package/dist/esm/core/app-kit/types/events.d.ts.map +1 -1
- package/dist/esm/core/cache/adapters/lru-app-kit-cache.d.ts +20 -0
- package/dist/esm/core/cache/adapters/lru-app-kit-cache.d.ts.map +1 -0
- package/dist/esm/core/cache/adapters/lru-app-kit-cache.js +28 -0
- package/dist/esm/core/cache/adapters/lru-app-kit-cache.test.d.ts +9 -0
- package/dist/esm/core/cache/adapters/lru-app-kit-cache.test.d.ts.map +1 -0
- package/dist/esm/core/cache/adapters/lru-app-kit-cache.test.js +66 -0
- package/dist/esm/core/cache/index.d.ts +11 -0
- package/dist/esm/core/cache/index.d.ts.map +1 -0
- package/dist/esm/core/cache/index.js +9 -0
- package/dist/esm/core/cache/types/app-kit-cache.d.ts +14 -0
- package/dist/esm/core/cache/types/app-kit-cache.d.ts.map +1 -0
- package/dist/esm/core/cache/types/app-kit-cache.js +8 -0
- package/dist/esm/core/cache/utils/get-cache-key.d.ts +9 -0
- package/dist/esm/core/cache/utils/get-cache-key.d.ts.map +1 -0
- package/dist/esm/core/cache/utils/get-cache-key.js +8 -0
- package/dist/esm/core/cache/utils/get-cache-key.test.d.ts +9 -0
- package/dist/esm/core/cache/utils/get-cache-key.test.d.ts.map +1 -0
- package/dist/esm/core/cache/utils/get-cache-key.test.js +28 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/queries/balances/get-balance-by-address.d.ts.map +1 -1
- package/dist/esm/queries/balances/get-balance-by-address.js +10 -4
- package/dist/esm/queries/index.d.ts +0 -1
- package/dist/esm/queries/index.d.ts.map +1 -1
- package/dist/esm/queries/index.js +0 -1
- package/dist/esm/queries/jettons/get-jetton-balance-by-address.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jetton-balance-by-address.js +12 -12
- package/dist/esm/queries/jettons/get-jetton-info.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jetton-info.js +6 -2
- package/dist/esm/queries/jettons/get-jetton-wallet-address.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jetton-wallet-address.js +7 -2
- package/dist/esm/queries/jettons/get-jettons-by-address.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jettons-by-address.js +10 -4
- package/dist/esm/queries/nft/get-nft.d.ts +1 -1
- package/dist/esm/queries/nft/get-nft.d.ts.map +1 -1
- package/dist/esm/queries/nft/get-nft.js +6 -2
- package/dist/esm/queries/nft/get-nfts-by-address.d.ts.map +1 -1
- package/dist/esm/queries/nft/get-nfts-by-address.js +6 -2
- package/dist/esm/queries/staking/get-staked-balance.d.ts +1 -1
- package/dist/esm/queries/staking/get-staked-balance.d.ts.map +1 -1
- package/dist/esm/queries/staking/get-staked-balance.js +8 -2
- package/dist/esm/queries/staking/get-staking-provider-info.d.ts +1 -1
- package/dist/esm/queries/staking/get-staking-provider-info.d.ts.map +1 -1
- package/dist/esm/queries/staking/get-staking-provider-info.js +4 -2
- package/dist/esm/queries/staking/get-staking-quote.d.ts +1 -1
- package/dist/esm/queries/staking/get-staking-quote.d.ts.map +1 -1
- package/dist/esm/queries/staking/get-staking-quote.js +9 -3
- package/dist/esm/queries/swap/get-swap-quote.d.ts.map +1 -1
- package/dist/esm/queries/swap/get-swap-quote.js +1 -1
- package/dist/esm/staking/index.d.ts +2 -2
- package/dist/esm/staking/index.d.ts.map +1 -1
- package/dist/esm/staking/index.js +1 -1
- package/dist/esm/swap/index.d.ts +2 -1
- package/dist/esm/swap/index.d.ts.map +1 -1
- package/dist/esm/swap/index.js +1 -1
- package/dist/esm/types/connector.d.ts +0 -1
- package/dist/esm/types/connector.d.ts.map +1 -1
- package/dist/esm/types/primitives.d.ts +1 -1
- package/dist/esm/types/primitives.d.ts.map +1 -1
- package/dist/esm/utils/address/is-valid-address.d.ts +11 -0
- package/dist/esm/utils/address/is-valid-address.d.ts.map +1 -0
- package/dist/esm/utils/address/is-valid-address.js +33 -0
- package/dist/esm/utils/address/to-bounceble-address.d.ts +11 -0
- package/dist/esm/utils/address/to-bounceble-address.d.ts.map +1 -0
- package/dist/esm/utils/address/to-bounceble-address.js +31 -0
- package/dist/esm/utils/address/to-non-bounceble-address.d.ts +11 -0
- package/dist/esm/utils/address/to-non-bounceble-address.d.ts.map +1 -0
- package/dist/esm/utils/address/to-non-bounceble-address.js +31 -0
- package/dist/esm/utils/amount/calc-fiat-value.d.ts +13 -0
- package/dist/esm/utils/amount/calc-fiat-value.d.ts.map +1 -0
- package/dist/esm/utils/amount/calc-fiat-value.js +19 -0
- package/dist/esm/utils/amount/calc-fiat-value.test.d.ts +9 -0
- package/dist/esm/utils/amount/calc-fiat-value.test.d.ts.map +1 -0
- package/dist/esm/utils/amount/calc-fiat-value.test.js +37 -0
- package/dist/esm/utils/amount/format-large-value.d.ts +9 -0
- package/dist/esm/utils/amount/format-large-value.d.ts.map +1 -0
- package/dist/esm/utils/amount/format-large-value.js +36 -0
- package/dist/esm/utils/amount/format-large-value.test.d.ts +9 -0
- package/dist/esm/utils/amount/format-large-value.test.d.ts.map +1 -0
- package/dist/esm/utils/amount/format-large-value.test.js +41 -0
- package/dist/esm/utils/amount/truncate-decimals.d.ts +9 -0
- package/dist/esm/utils/amount/truncate-decimals.d.ts.map +1 -0
- package/dist/esm/utils/amount/truncate-decimals.js +55 -0
- package/dist/esm/utils/amount/truncate-decimals.test.d.ts +9 -0
- package/dist/esm/utils/amount/truncate-decimals.test.d.ts.map +1 -0
- package/dist/esm/utils/amount/truncate-decimals.test.js +81 -0
- package/dist/esm/utils/balance/calc-max-spendable.d.ts +33 -0
- package/dist/esm/utils/balance/calc-max-spendable.d.ts.map +1 -0
- package/dist/esm/utils/balance/calc-max-spendable.js +25 -0
- package/dist/esm/utils/balance/calc-max-spendable.test.d.ts +9 -0
- package/dist/esm/utils/balance/calc-max-spendable.test.d.ts.map +1 -0
- package/dist/esm/utils/balance/calc-max-spendable.test.js +36 -0
- package/dist/esm/utils/balance/get-ton-shortfall.d.ts +58 -0
- package/dist/esm/utils/balance/get-ton-shortfall.d.ts.map +1 -0
- package/dist/esm/utils/balance/get-ton-shortfall.js +42 -0
- package/dist/esm/utils/balance/get-ton-shortfall.test.d.ts +9 -0
- package/dist/esm/utils/balance/get-ton-shortfall.test.d.ts.map +1 -0
- package/dist/esm/utils/balance/get-ton-shortfall.test.js +131 -0
- package/dist/esm/utils/functions/debounce.d.ts +80 -0
- package/dist/esm/utils/functions/debounce.d.ts.map +1 -0
- package/dist/esm/utils/functions/debounce.js +103 -0
- package/dist/esm/utils/index.d.ts +10 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +10 -0
- package/dist/esm/utils/jetton/jetton-info.d.ts +2 -1
- package/dist/esm/utils/jetton/jetton-info.d.ts.map +1 -1
- package/dist/esm/utils/jetton/jetton-info.js +9 -0
- package/dist/esm/utils/jetton/jetton-info.test.d.ts +9 -0
- package/dist/esm/utils/jetton/jetton-info.test.d.ts.map +1 -0
- package/dist/esm/utils/jetton/jetton-info.test.js +52 -0
- package/dist/esm/utils/predicate/is-number.d.ts +9 -0
- package/dist/esm/utils/predicate/is-number.d.ts.map +1 -0
- package/dist/esm/utils/predicate/is-number.js +16 -0
- package/dist/esm/utils/predicate/is-string.d.ts +1 -1
- package/dist/esm/utils/predicate/is-string.d.ts.map +1 -1
- package/dist/esm/utils/predicate/is-string.js +2 -2
- package/docs/actions.md +57 -9
- package/docs/swap.md +4 -4
- package/package.json +4 -3
- package/src/actions/index.ts +32 -0
- package/src/actions/jettons/create-transfer-jetton-transaction.ts +22 -6
- package/src/actions/jettons/get-jetton-balance.ts +10 -3
- package/src/actions/jettons/get-jetton-info.ts +18 -6
- package/src/actions/jettons/get-jetton-wallet-address.ts +19 -5
- package/src/actions/nft/get-nft.ts +1 -1
- package/src/actions/staking/get-staking-provider-metadata.ts +32 -0
- package/src/actions/staking/get-staking-provider.ts +30 -0
- package/src/actions/staking/get-staking-providers.ts +5 -3
- package/src/actions/staking/set-default-staking-provider.ts +26 -0
- package/src/actions/staking/watch-staking-providers.ts +39 -0
- package/src/actions/swap/get-swap-provider.ts +21 -0
- package/src/actions/swap/get-swap-providers.ts +20 -0
- package/src/actions/swap/get-swap-quote.ts +7 -1
- package/src/actions/swap/set-default-swap-provider.ts +26 -0
- package/src/actions/swap/watch-swap-providers.ts +38 -0
- package/src/connectors/tonconnect/connectors/ton-connect-connector.ts +2 -2
- package/src/core/app-kit/constants/events.ts +0 -7
- package/src/core/app-kit/index.ts +1 -2
- package/src/core/app-kit/services/app-kit.ts +7 -3
- package/src/core/app-kit/types/config.ts +4 -2
- package/src/core/app-kit/types/events.ts +2 -10
- package/src/core/cache/adapters/lru-app-kit-cache.test.ts +77 -0
- package/src/core/cache/adapters/lru-app-kit-cache.ts +38 -0
- package/src/core/cache/index.ts +12 -0
- package/src/core/cache/types/app-kit-cache.ts +14 -0
- package/src/core/cache/utils/get-cache-key.test.ts +34 -0
- package/src/core/cache/utils/get-cache-key.ts +12 -0
- package/src/index.ts +1 -0
- package/src/queries/balances/get-balance-by-address.ts +11 -4
- package/src/queries/index.ts +0 -6
- package/src/queries/jettons/get-jetton-balance-by-address.ts +13 -12
- package/src/queries/jettons/get-jetton-info.ts +6 -2
- package/src/queries/jettons/get-jetton-wallet-address.ts +7 -2
- package/src/queries/jettons/get-jettons-by-address.ts +18 -4
- package/src/queries/nft/get-nft.ts +7 -3
- package/src/queries/nft/get-nfts-by-address.ts +6 -2
- package/src/queries/staking/get-staked-balance.ts +10 -3
- package/src/queries/staking/get-staking-provider-info.ts +5 -2
- package/src/queries/staking/get-staking-quote.ts +13 -4
- package/src/queries/swap/get-swap-quote.ts +3 -1
- package/src/staking/index.ts +10 -1
- package/src/swap/index.ts +2 -4
- package/src/types/connector.ts +0 -1
- package/src/types/primitives.ts +1 -1
- package/src/utils/address/is-valid-address.ts +40 -0
- package/src/utils/address/to-bounceble-address.ts +35 -0
- package/src/utils/address/to-non-bounceble-address.ts +35 -0
- package/src/utils/amount/calc-fiat-value.test.ts +46 -0
- package/src/utils/amount/calc-fiat-value.ts +18 -0
- package/src/utils/amount/format-large-value.test.ts +50 -0
- package/src/utils/amount/format-large-value.ts +43 -0
- package/src/utils/amount/truncate-decimals.test.ts +97 -0
- package/src/utils/amount/truncate-decimals.ts +56 -0
- package/src/utils/balance/calc-max-spendable.test.ts +46 -0
- package/src/utils/balance/calc-max-spendable.ts +44 -0
- package/src/utils/balance/get-ton-shortfall.test.ts +148 -0
- package/src/utils/balance/get-ton-shortfall.ts +82 -0
- package/src/utils/functions/debounce.ts +169 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/jetton/jetton-info.test.ts +65 -0
- package/src/utils/jetton/jetton-info.ts +12 -1
- package/src/utils/predicate/is-number.ts +19 -0
- package/src/utils/predicate/is-string.ts +2 -2
- package/dist/cjs/queries/staking/get-staking-providers.d.ts +0 -20
- package/dist/cjs/queries/staking/get-staking-providers.d.ts.map +0 -1
- package/dist/cjs/queries/staking/get-staking-providers.js +0 -25
- package/dist/esm/queries/staking/get-staking-providers.d.ts +0 -20
- package/dist/esm/queries/staking/get-staking-providers.d.ts.map +0 -1
- package/dist/esm/queries/staking/get-staking-providers.js +0 -20
- package/src/queries/staking/get-staking-providers.ts +0 -52
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AppKit } from '../../core/app-kit';
|
|
10
|
+
|
|
11
|
+
export interface SetDefaultSwapProviderParameters {
|
|
12
|
+
providerId: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type SetDefaultSwapProviderReturnType = void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Set the default swap provider.
|
|
19
|
+
* Subsequent quote and swap-transaction calls will use this provider when none is specified.
|
|
20
|
+
*/
|
|
21
|
+
export const setDefaultSwapProvider = (
|
|
22
|
+
appKit: AppKit,
|
|
23
|
+
parameters: SetDefaultSwapProviderParameters,
|
|
24
|
+
): SetDefaultSwapProviderReturnType => {
|
|
25
|
+
appKit.swapManager.setDefaultProvider(parameters.providerId);
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AppKit } from '../../core/app-kit';
|
|
10
|
+
|
|
11
|
+
export interface WatchSwapProvidersParameters {
|
|
12
|
+
onChange: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type WatchSwapProvidersReturnType = () => void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Watch for new swap providers registration
|
|
19
|
+
*/
|
|
20
|
+
export const watchSwapProviders = (
|
|
21
|
+
appKit: AppKit,
|
|
22
|
+
parameters: WatchSwapProvidersParameters,
|
|
23
|
+
): WatchSwapProvidersReturnType => {
|
|
24
|
+
const { onChange } = parameters;
|
|
25
|
+
|
|
26
|
+
const unsubscribeRegistered = appKit.emitter.on('provider:registered', (event) => {
|
|
27
|
+
if (event.payload.type === 'swap') onChange();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const unsubscribeDefaultChanged = appKit.emitter.on('provider:default-changed', (event) => {
|
|
31
|
+
if (event.payload.type === 'swap') onChange();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
unsubscribeRegistered();
|
|
36
|
+
unsubscribeDefaultChanged();
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -29,7 +29,7 @@ export type TonConnectConnector = Connector & {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export const createTonConnectConnector = (config: TonConnectConnectorConfig) => {
|
|
32
|
-
return createConnector(({ eventEmitter, networkManager
|
|
32
|
+
return createConnector(({ eventEmitter, networkManager }): TonConnectConnector => {
|
|
33
33
|
let originalTonConnectUI: TonConnectUI | null = null;
|
|
34
34
|
let unsubscribeTonConnect: (() => void) | null = null;
|
|
35
35
|
|
|
@@ -40,7 +40,7 @@ export const createTonConnectConnector = (config: TonConnectConnectorConfig) =>
|
|
|
40
40
|
return originalTonConnectUI;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
if (
|
|
43
|
+
if (typeof window === 'undefined') {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export { AppKit } from './services/app-kit';
|
|
10
|
-
export { CONNECTOR_EVENTS, WALLETS_EVENTS,
|
|
10
|
+
export { CONNECTOR_EVENTS, WALLETS_EVENTS, NETWORKS_EVENTS } from './constants/events';
|
|
11
11
|
|
|
12
12
|
export type { AppKitConfig } from './types/config';
|
|
13
13
|
export type {
|
|
@@ -15,6 +15,5 @@ export type {
|
|
|
15
15
|
AppKitEvents,
|
|
16
16
|
WalletConnectedPayload,
|
|
17
17
|
WalletDisconnectedPayload,
|
|
18
|
-
PluginRegisteredPayload,
|
|
19
18
|
DefaultNetworkChangedPayload,
|
|
20
19
|
} from './types/events';
|
|
@@ -9,16 +9,18 @@
|
|
|
9
9
|
import { SwapManager, StreamingManager } from '@ton/walletkit';
|
|
10
10
|
import type { ProviderInput, SwapProviderInterface, StakingProviderInterface } from '@ton/walletkit';
|
|
11
11
|
|
|
12
|
+
import type { AppKitConfig } from '../types/config';
|
|
13
|
+
import { CONNECTOR_EVENTS, WALLETS_EVENTS } from '../constants/events';
|
|
12
14
|
import { StakingManager } from '../../../staking';
|
|
13
15
|
import type { Connector, ConnectorFactoryContext, ConnectorInput } from '../../../types/connector';
|
|
14
16
|
import { EventEmitter } from '../../emitter';
|
|
15
|
-
import { CONNECTOR_EVENTS, WALLETS_EVENTS } from '../constants/events';
|
|
16
17
|
import type { AppKitEmitter, AppKitEvents } from '../types/events';
|
|
17
18
|
import type { WalletInterface } from '../../../types/wallet';
|
|
18
19
|
import { WalletsManager } from '../../wallets-manager';
|
|
19
20
|
import { AppKitNetworkManager } from '../../network';
|
|
20
21
|
import { Network } from '../../../types/network';
|
|
21
|
-
import type {
|
|
22
|
+
import type { AppKitCache } from '../../cache';
|
|
23
|
+
import { LruAppKitCache } from '../../cache';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Central hub for wallet management.
|
|
@@ -34,9 +36,11 @@ export class AppKit {
|
|
|
34
36
|
readonly networkManager: AppKitNetworkManager;
|
|
35
37
|
readonly streamingManager: StreamingManager;
|
|
36
38
|
readonly config: AppKitConfig;
|
|
39
|
+
readonly cache: AppKitCache;
|
|
37
40
|
|
|
38
41
|
constructor(config: AppKitConfig) {
|
|
39
42
|
this.config = config;
|
|
43
|
+
this.cache = config.cache ?? new LruAppKitCache();
|
|
40
44
|
|
|
41
45
|
this.emitter = new EventEmitter<AppKitEvents>();
|
|
42
46
|
this.emitter.on(CONNECTOR_EVENTS.CONNECTED, this.updateWalletsFromConnectors.bind(this));
|
|
@@ -68,7 +72,7 @@ export class AppKit {
|
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
createFactoryContext(): ConnectorFactoryContext {
|
|
71
|
-
return { eventEmitter: this.emitter, networkManager: this.networkManager
|
|
75
|
+
return { eventEmitter: this.emitter, networkManager: this.networkManager };
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
/**
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { NetworkAdapters, ProviderInput } from '@ton/walletkit';
|
|
10
10
|
|
|
11
|
+
import type { AppKitCache } from '../../cache';
|
|
11
12
|
import type { ConnectorInput } from '../../../types/connector';
|
|
12
13
|
import type { Network } from '../../../types/network';
|
|
13
14
|
|
|
@@ -39,7 +40,8 @@ export interface AppKitConfig {
|
|
|
39
40
|
providers?: ProviderInput[];
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Custom cache implementation.
|
|
44
|
+
* Defaults to an LRU cache with a 10-minute TTL and a maximum of 1000 entries.
|
|
43
45
|
*/
|
|
44
|
-
|
|
46
|
+
cache?: AppKitCache;
|
|
45
47
|
}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { SharedKitEvents } from '../../emitter';
|
|
10
|
-
import type { CONNECTOR_EVENTS, WALLETS_EVENTS, PLUGIN_EVENTS, NETWORKS_EVENTS } from '../constants/events';
|
|
11
9
|
import type { Network } from '../../../types/network';
|
|
10
|
+
import type { CONNECTOR_EVENTS, WALLETS_EVENTS, NETWORKS_EVENTS } from '../constants/events';
|
|
11
|
+
import type { SharedKitEvents } from '../../emitter';
|
|
12
12
|
import type { EventEmitter } from '../../emitter';
|
|
13
13
|
import type { WalletInterface } from '../../../types/wallet';
|
|
14
14
|
|
|
@@ -21,11 +21,6 @@ export interface WalletDisconnectedPayload {
|
|
|
21
21
|
connectorId: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export interface PluginRegisteredPayload {
|
|
25
|
-
pluginId: string;
|
|
26
|
-
pluginType: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
export interface DefaultNetworkChangedPayload {
|
|
30
25
|
network: Network | undefined;
|
|
31
26
|
}
|
|
@@ -42,9 +37,6 @@ export type AppKitEvents = {
|
|
|
42
37
|
// Networks events
|
|
43
38
|
[NETWORKS_EVENTS.UPDATED]: Record<string, never>;
|
|
44
39
|
[NETWORKS_EVENTS.DEFAULT_CHANGED]: DefaultNetworkChangedPayload;
|
|
45
|
-
|
|
46
|
-
// Plugin events
|
|
47
|
-
[PLUGIN_EVENTS.REGISTERED]: PluginRegisteredPayload;
|
|
48
40
|
} & SharedKitEvents;
|
|
49
41
|
|
|
50
42
|
export type AppKitEmitter = EventEmitter<AppKitEvents>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, expect, it } from 'vitest';
|
|
10
|
+
|
|
11
|
+
import { LruAppKitCache } from './lru-app-kit-cache';
|
|
12
|
+
|
|
13
|
+
describe('LruAppKitCache', () => {
|
|
14
|
+
it('should return undefined for a missing key', async () => {
|
|
15
|
+
const cache = new LruAppKitCache();
|
|
16
|
+
expect(await cache.get('missing')).toBeUndefined();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should store and retrieve a value', async () => {
|
|
20
|
+
const cache = new LruAppKitCache();
|
|
21
|
+
await cache.set('key', 'value');
|
|
22
|
+
expect(await cache.get('key')).toBe('value');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should store and retrieve null', async () => {
|
|
26
|
+
const cache = new LruAppKitCache();
|
|
27
|
+
await cache.set('key', null);
|
|
28
|
+
expect(await cache.get('key')).toBeNull();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should store and retrieve an object', async () => {
|
|
32
|
+
const cache = new LruAppKitCache();
|
|
33
|
+
const obj = { address: 'EQabc', name: 'Test', decimals: 6 };
|
|
34
|
+
await cache.set('key', obj);
|
|
35
|
+
expect(await cache.get('key')).toEqual(obj);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should overwrite an existing value', async () => {
|
|
39
|
+
const cache = new LruAppKitCache();
|
|
40
|
+
await cache.set('key', 'first');
|
|
41
|
+
await cache.set('key', 'second');
|
|
42
|
+
expect(await cache.get('key')).toBe('second');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should remove a key', async () => {
|
|
46
|
+
const cache = new LruAppKitCache();
|
|
47
|
+
await cache.set('key', 'value');
|
|
48
|
+
await cache.remove('key');
|
|
49
|
+
expect(await cache.get('key')).toBeUndefined();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should clear all keys', async () => {
|
|
53
|
+
const cache = new LruAppKitCache();
|
|
54
|
+
await cache.set('a', 1);
|
|
55
|
+
await cache.set('b', 2);
|
|
56
|
+
await cache.clear();
|
|
57
|
+
expect(await cache.get('a')).toBeUndefined();
|
|
58
|
+
expect(await cache.get('b')).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should evict entries when max is exceeded', async () => {
|
|
62
|
+
const cache = new LruAppKitCache({ max: 2 });
|
|
63
|
+
await cache.set('a', 1);
|
|
64
|
+
await cache.set('b', 2);
|
|
65
|
+
await cache.set('c', 3);
|
|
66
|
+
expect(await cache.get('a')).toBeUndefined();
|
|
67
|
+
expect(await cache.get('b')).toBe(2);
|
|
68
|
+
expect(await cache.get('c')).toBe(3);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should expire entries after ttl', async () => {
|
|
72
|
+
const cache = new LruAppKitCache({ ttl: 10 });
|
|
73
|
+
await cache.set('key', 'value');
|
|
74
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
75
|
+
expect(await cache.get('key')).toBeUndefined();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { LRUCache } from 'lru-cache';
|
|
10
|
+
|
|
11
|
+
import type { AppKitCache } from '../types/app-kit-cache';
|
|
12
|
+
|
|
13
|
+
export class LruAppKitCache implements AppKitCache {
|
|
14
|
+
private readonly cache: LRUCache<string, { value: unknown }>;
|
|
15
|
+
|
|
16
|
+
constructor(options?: { max?: number; ttl?: number }) {
|
|
17
|
+
this.cache = new LRUCache({
|
|
18
|
+
max: options?.max ?? 1000,
|
|
19
|
+
ttl: options?.ttl ?? 1000 * 60 * 10,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async get<T = unknown>(key: string): Promise<T | undefined> {
|
|
24
|
+
return this.cache.get(key)?.value as T | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async set(key: string, value: unknown): Promise<void> {
|
|
28
|
+
this.cache.set(key, { value });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async remove(key: string): Promise<void> {
|
|
32
|
+
this.cache.delete(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async clear(): Promise<void> {
|
|
36
|
+
this.cache.clear();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { LruAppKitCache } from './adapters/lru-app-kit-cache';
|
|
10
|
+
export { getCacheKey } from './utils/get-cache-key';
|
|
11
|
+
|
|
12
|
+
export type { AppKitCache } from './types/app-kit-cache';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface AppKitCache {
|
|
10
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
11
|
+
set(key: string, value: unknown): Promise<void>;
|
|
12
|
+
remove(key: string): Promise<void>;
|
|
13
|
+
clear(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, expect, it } from 'vitest';
|
|
10
|
+
|
|
11
|
+
import { getCacheKey } from './get-cache-key';
|
|
12
|
+
|
|
13
|
+
describe('getCacheKey', () => {
|
|
14
|
+
it('should build a key with a single param', () => {
|
|
15
|
+
const key = getCacheKey('jetton-info');
|
|
16
|
+
expect(key('EQabc')).toBe('jetton-info:EQabc');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should build a key with multiple params', () => {
|
|
20
|
+
const key = getCacheKey('jetton-info');
|
|
21
|
+
expect(key('mainnet', 'EQabc')).toBe('jetton-info:mainnet:EQabc');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should build a key with no params', () => {
|
|
25
|
+
const key = getCacheKey('jetton-info');
|
|
26
|
+
expect(key()).toBe('jetton-info:');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should scope keys independently per prefix', () => {
|
|
30
|
+
const infoKey = getCacheKey('jetton-info');
|
|
31
|
+
const walletKey = getCacheKey('jetton-wallet');
|
|
32
|
+
expect(infoKey('EQabc')).not.toBe(walletKey('EQabc'));
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const getCacheKey =
|
|
10
|
+
(prefix: string) =>
|
|
11
|
+
(...params: string[]): string =>
|
|
12
|
+
`${prefix}:${params.join(':')}`;
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { getBalanceByAddress } from '../../actions/balances/get-balance-by-addre
|
|
|
13
13
|
import type { GetBalanceByAddressOptions } from '../../actions/balances/get-balance-by-address';
|
|
14
14
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
15
15
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
16
|
-
import { filterQueryOptions, resolveNetwork, sleep } from '../../utils';
|
|
16
|
+
import { filterQueryOptions, resolveNetwork, sleep, tryToBounceableAddress } from '../../utils';
|
|
17
17
|
import type { GetBalanceByAddressReturnType } from '../../actions/balances/get-balance-by-address';
|
|
18
18
|
import type { BalanceUpdate } from '../../core/streaming';
|
|
19
19
|
import type { Network } from '../../types/network';
|
|
@@ -32,7 +32,11 @@ export const getBalanceByAddressQueryOptions = <selectData = GetBalanceByAddress
|
|
|
32
32
|
initialOptions: GetBalanceByAddressQueryConfig<selectData> = {},
|
|
33
33
|
): GetBalanceByAddressQueryOptions<selectData> => {
|
|
34
34
|
const network = resolveNetwork(appKit, initialOptions.network);
|
|
35
|
-
const options = {
|
|
35
|
+
const options = {
|
|
36
|
+
...initialOptions,
|
|
37
|
+
network,
|
|
38
|
+
address: tryToBounceableAddress(initialOptions.address) ?? initialOptions.address,
|
|
39
|
+
};
|
|
36
40
|
|
|
37
41
|
return {
|
|
38
42
|
...options.query,
|
|
@@ -72,14 +76,17 @@ export const handleBalanceUpdate = (
|
|
|
72
76
|
{ address, network }: { address: string; network: Network },
|
|
73
77
|
update: BalanceUpdate,
|
|
74
78
|
) => {
|
|
79
|
+
const queryKey = getBalanceByAddressQueryKey({
|
|
80
|
+
address: tryToBounceableAddress(address) ?? address,
|
|
81
|
+
network,
|
|
82
|
+
});
|
|
83
|
+
|
|
75
84
|
if (update.status === 'finalized') {
|
|
76
|
-
const queryKey = getBalanceByAddressQueryKey({ address, network });
|
|
77
85
|
queryClient.setQueryData(queryKey, update.balance);
|
|
78
86
|
sleep(5000).then(() => queryClient.invalidateQueries({ queryKey }));
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
if (update.status === 'invalidated') {
|
|
82
|
-
const queryKey = getBalanceByAddressQueryKey({ address, network });
|
|
83
90
|
queryClient.invalidateQueries({ queryKey });
|
|
84
91
|
}
|
|
85
92
|
};
|
package/src/queries/index.ts
CHANGED
|
@@ -166,12 +166,6 @@ export {
|
|
|
166
166
|
} from './swap/build-swap-transaction';
|
|
167
167
|
|
|
168
168
|
// Staking
|
|
169
|
-
export {
|
|
170
|
-
getStakingProvidersQueryOptions,
|
|
171
|
-
type GetStakingProvidersData,
|
|
172
|
-
type GetStakingProvidersErrorType,
|
|
173
|
-
type GetStakingProvidersQueryConfig,
|
|
174
|
-
} from './staking/get-staking-providers';
|
|
175
169
|
export {
|
|
176
170
|
getStakingQuoteQueryOptions,
|
|
177
171
|
type GetStakingQuoteQueryConfig,
|
|
@@ -14,7 +14,7 @@ import { getJettonBalance } from '../../actions/jettons/get-jetton-balance';
|
|
|
14
14
|
import type { GetJettonBalanceOptions as GetJettonBalanceParameters } from '../../actions/jettons/get-jetton-balance';
|
|
15
15
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
16
16
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
17
|
-
import { filterQueryOptions, resolveNetwork, sleep } from '../../utils';
|
|
17
|
+
import { filterQueryOptions, resolveNetwork, sleep, tryToBounceableAddress } from '../../utils';
|
|
18
18
|
import type { JettonUpdate } from '../../core/streaming';
|
|
19
19
|
import type { Network } from '../../types/network';
|
|
20
20
|
|
|
@@ -37,7 +37,12 @@ export const getJettonBalanceByAddressQueryOptions = <selectData = GetJettonBala
|
|
|
37
37
|
initialOptions: GetJettonBalanceByAddressQueryConfig<selectData> = {},
|
|
38
38
|
): GetJettonBalanceByAddressQueryOptions<selectData> => {
|
|
39
39
|
const network = resolveNetwork(appKit, initialOptions.network);
|
|
40
|
-
const options = {
|
|
40
|
+
const options = {
|
|
41
|
+
...initialOptions,
|
|
42
|
+
network,
|
|
43
|
+
jettonAddress: tryToBounceableAddress(initialOptions.jettonAddress) ?? initialOptions.jettonAddress,
|
|
44
|
+
ownerAddress: tryToBounceableAddress(initialOptions.ownerAddress) ?? initialOptions.ownerAddress,
|
|
45
|
+
};
|
|
41
46
|
|
|
42
47
|
return {
|
|
43
48
|
...options.query,
|
|
@@ -82,22 +87,18 @@ export const handleJettonBalanceUpdate = (
|
|
|
82
87
|
{ ownerAddress, jettonAddress, network }: { ownerAddress: string; jettonAddress: string; network: Network },
|
|
83
88
|
update: JettonUpdate,
|
|
84
89
|
) => {
|
|
90
|
+
const queryKey = getJettonBalanceByAddressQueryKey({
|
|
91
|
+
ownerAddress: tryToBounceableAddress(ownerAddress) ?? ownerAddress,
|
|
92
|
+
jettonAddress: tryToBounceableAddress(jettonAddress) ?? jettonAddress,
|
|
93
|
+
network,
|
|
94
|
+
});
|
|
95
|
+
|
|
85
96
|
if (update.status === 'finalized') {
|
|
86
|
-
const queryKey = getJettonBalanceByAddressQueryKey({
|
|
87
|
-
ownerAddress,
|
|
88
|
-
jettonAddress,
|
|
89
|
-
network,
|
|
90
|
-
});
|
|
91
97
|
queryClient.setQueryData(queryKey, update.balance);
|
|
92
98
|
sleep(5000).then(() => queryClient.invalidateQueries({ queryKey }));
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
if (update.status === 'invalidated') {
|
|
96
|
-
const queryKey = getJettonBalanceByAddressQueryKey({
|
|
97
|
-
ownerAddress,
|
|
98
|
-
jettonAddress,
|
|
99
|
-
network,
|
|
100
|
-
});
|
|
101
102
|
queryClient.invalidateQueries({ queryKey });
|
|
102
103
|
}
|
|
103
104
|
};
|
|
@@ -12,7 +12,7 @@ import type { GetJettonInfoOptions } from '../../actions/jettons/get-jetton-info
|
|
|
12
12
|
import type { GetJettonInfoReturnType } from '../../actions/jettons/get-jetton-info';
|
|
13
13
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
14
14
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
15
|
-
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
15
|
+
import { filterQueryOptions, resolveNetwork, tryToBounceableAddress } from '../../utils';
|
|
16
16
|
|
|
17
17
|
export type GetJettonInfoErrorType = Error;
|
|
18
18
|
|
|
@@ -24,7 +24,11 @@ export const getJettonInfoQueryOptions = <selectData = GetJettonInfoData>(
|
|
|
24
24
|
initialOptions: GetJettonInfoQueryConfig<selectData> = {},
|
|
25
25
|
): GetJettonInfoQueryOptions<selectData> => {
|
|
26
26
|
const network = resolveNetwork(appKit, initialOptions.network);
|
|
27
|
-
const options = {
|
|
27
|
+
const options = {
|
|
28
|
+
...initialOptions,
|
|
29
|
+
network,
|
|
30
|
+
address: tryToBounceableAddress(initialOptions.address) ?? initialOptions.address,
|
|
31
|
+
};
|
|
28
32
|
|
|
29
33
|
return {
|
|
30
34
|
...options.query,
|
|
@@ -13,7 +13,7 @@ import { getJettonWalletAddress } from '../../actions/jettons/get-jetton-wallet-
|
|
|
13
13
|
import type { GetJettonWalletAddressOptions as GetJettonWalletAddressParameters } from '../../actions/jettons/get-jetton-wallet-address';
|
|
14
14
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
15
15
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
16
|
-
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
16
|
+
import { filterQueryOptions, resolveNetwork, tryToBounceableAddress } from '../../utils';
|
|
17
17
|
|
|
18
18
|
export type GetJettonWalletAddressErrorType = Error;
|
|
19
19
|
|
|
@@ -32,7 +32,12 @@ export const getJettonWalletAddressQueryOptions = <selectData = GetJettonWalletA
|
|
|
32
32
|
initialOptions: GetJettonWalletAddressQueryConfig<selectData> = {},
|
|
33
33
|
): GetJettonWalletAddressQueryOptions<selectData> => {
|
|
34
34
|
const network = resolveNetwork(appKit, initialOptions.network);
|
|
35
|
-
const options = {
|
|
35
|
+
const options = {
|
|
36
|
+
...initialOptions,
|
|
37
|
+
network,
|
|
38
|
+
jettonAddress: tryToBounceableAddress(initialOptions.jettonAddress) ?? initialOptions.jettonAddress,
|
|
39
|
+
ownerAddress: tryToBounceableAddress(initialOptions.ownerAddress) ?? initialOptions.ownerAddress,
|
|
40
|
+
};
|
|
36
41
|
|
|
37
42
|
return {
|
|
38
43
|
...options.query,
|
|
@@ -13,7 +13,14 @@ import { getJettonsByAddress } from '../../actions/jettons/get-jettons-by-addres
|
|
|
13
13
|
import type { GetJettonsByAddressOptions } from '../../actions/jettons/get-jettons-by-address';
|
|
14
14
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
15
15
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
filterQueryOptions,
|
|
18
|
+
resolveNetwork,
|
|
19
|
+
compareAddress,
|
|
20
|
+
formatUnits,
|
|
21
|
+
sleep,
|
|
22
|
+
tryToBounceableAddress,
|
|
23
|
+
} from '../../utils';
|
|
17
24
|
import type { GetJettonsByAddressReturnType } from '../../actions/jettons/get-jettons-by-address';
|
|
18
25
|
import type { JettonUpdate } from '../../core/streaming';
|
|
19
26
|
import type { Network } from '../../types/network';
|
|
@@ -32,7 +39,11 @@ export const getJettonsByAddressQueryOptions = <selectData = GetJettonsByAddress
|
|
|
32
39
|
initialOptions: GetJettonsByAddressQueryConfig<selectData> = {},
|
|
33
40
|
): GetJettonsByAddressQueryOptions<selectData> => {
|
|
34
41
|
const network = resolveNetwork(appKit, initialOptions.network);
|
|
35
|
-
const options = {
|
|
42
|
+
const options = {
|
|
43
|
+
...initialOptions,
|
|
44
|
+
network,
|
|
45
|
+
address: tryToBounceableAddress(initialOptions.address) ?? initialOptions.address,
|
|
46
|
+
};
|
|
36
47
|
|
|
37
48
|
return {
|
|
38
49
|
...options.query,
|
|
@@ -73,8 +84,12 @@ export const handleJettonsUpdate = (
|
|
|
73
84
|
{ address, network }: { address: string; network: Network },
|
|
74
85
|
update: JettonUpdate,
|
|
75
86
|
) => {
|
|
87
|
+
const queryKey = getJettonsByAddressQueryKey({
|
|
88
|
+
address: tryToBounceableAddress(address) ?? address,
|
|
89
|
+
network,
|
|
90
|
+
});
|
|
91
|
+
|
|
76
92
|
if (update.status === 'finalized') {
|
|
77
|
-
const queryKey = getJettonsByAddressQueryKey({ address, network });
|
|
78
93
|
const currentData = queryClient.getQueryData(queryKey) as GetJettonsByAddressData | undefined;
|
|
79
94
|
|
|
80
95
|
if (currentData?.jettons) {
|
|
@@ -99,7 +114,6 @@ export const handleJettonsUpdate = (
|
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
if (update.status === 'invalidated') {
|
|
102
|
-
const queryKey = getJettonsByAddressQueryKey({ address, network });
|
|
103
117
|
queryClient.invalidateQueries({ queryKey });
|
|
104
118
|
}
|
|
105
119
|
};
|
|
@@ -13,7 +13,7 @@ import { getNft } from '../../actions/nft/get-nft';
|
|
|
13
13
|
import type { GetNftOptions as GetNftParameters } from '../../actions/nft/get-nft';
|
|
14
14
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
15
15
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
16
|
-
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
16
|
+
import { filterQueryOptions, resolveNetwork, tryToBounceableAddress } from '../../utils';
|
|
17
17
|
|
|
18
18
|
export type GetNftErrorType = Error;
|
|
19
19
|
|
|
@@ -25,7 +25,11 @@ export const getNftQueryOptions = <selectData = GetNftData>(
|
|
|
25
25
|
initialOptions: GetNftQueryConfig<selectData> = {},
|
|
26
26
|
): GetNftQueryOptions<selectData> => {
|
|
27
27
|
const network = resolveNetwork(appKit, initialOptions.network);
|
|
28
|
-
const options = {
|
|
28
|
+
const options = {
|
|
29
|
+
...initialOptions,
|
|
30
|
+
network,
|
|
31
|
+
address: tryToBounceableAddress(initialOptions.address) ?? initialOptions.address,
|
|
32
|
+
};
|
|
29
33
|
|
|
30
34
|
return {
|
|
31
35
|
...options.query,
|
|
@@ -41,7 +45,7 @@ export const getNftQueryOptions = <selectData = GetNftData>(
|
|
|
41
45
|
};
|
|
42
46
|
};
|
|
43
47
|
|
|
44
|
-
export type GetNftQueryFnData = Compute<NFT |
|
|
48
|
+
export type GetNftQueryFnData = Compute<NFT | undefined>;
|
|
45
49
|
|
|
46
50
|
export type GetNftData = GetNftQueryFnData;
|
|
47
51
|
|