@ton/appkit 0.0.5-alpha.1 → 0.0.5-alpha.3
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 +18 -0
- package/CLAUDE.md +10 -0
- package/README.md +1 -1
- package/dist/cjs/actions/balances/watch-balance-by-address.d.ts +21 -0
- package/dist/cjs/actions/balances/watch-balance-by-address.d.ts.map +1 -0
- package/dist/cjs/actions/balances/watch-balance-by-address.js +22 -0
- package/dist/cjs/actions/balances/watch-balance.d.ts +19 -0
- package/dist/cjs/actions/balances/watch-balance.d.ts.map +1 -0
- package/dist/cjs/actions/balances/watch-balance.js +44 -0
- package/dist/cjs/actions/connectors/add-connector.d.ts +3 -3
- package/dist/cjs/actions/connectors/add-connector.d.ts.map +1 -1
- package/dist/cjs/actions/connectors/add-connector.js +2 -2
- package/dist/cjs/actions/index.d.ts +14 -0
- package/dist/cjs/actions/index.d.ts.map +1 -1
- package/dist/cjs/actions/index.js +31 -1
- package/dist/cjs/actions/jettons/watch-jettons-by-address.d.ts +21 -0
- package/dist/cjs/actions/jettons/watch-jettons-by-address.d.ts.map +1 -0
- package/dist/cjs/actions/jettons/watch-jettons-by-address.js +22 -0
- package/dist/cjs/actions/jettons/watch-jettons.d.ts +19 -0
- package/dist/cjs/actions/jettons/watch-jettons.d.ts.map +1 -0
- package/dist/cjs/actions/jettons/watch-jettons.js +44 -0
- package/dist/cjs/actions/network/get-api-client.d.ts +19 -0
- package/dist/cjs/actions/network/get-api-client.d.ts.map +1 -0
- package/dist/cjs/actions/network/get-api-client.js +17 -0
- package/dist/cjs/actions/network/has-streaming-provider.d.ts +15 -0
- package/dist/cjs/actions/network/has-streaming-provider.d.ts.map +1 -0
- package/dist/cjs/actions/network/has-streaming-provider.js +17 -0
- package/dist/cjs/actions/providers/register-provider.d.ts +2 -2
- package/dist/cjs/actions/providers/register-provider.d.ts.map +1 -1
- package/dist/cjs/actions/staking/build-stake-transaction.d.ts +19 -0
- package/dist/cjs/actions/staking/build-stake-transaction.d.ts.map +1 -0
- package/dist/cjs/actions/staking/build-stake-transaction.js +17 -0
- package/dist/cjs/actions/staking/get-staked-balance.d.ts +20 -0
- package/dist/cjs/actions/staking/get-staked-balance.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staked-balance.js +18 -0
- package/dist/cjs/actions/staking/get-staking-manager.d.ts +15 -0
- package/dist/cjs/actions/staking/get-staking-manager.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staking-manager.js +17 -0
- package/dist/cjs/actions/staking/get-staking-provider-info.d.ts +19 -0
- package/dist/cjs/actions/staking/get-staking-provider-info.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staking-provider-info.js +18 -0
- package/dist/cjs/actions/staking/get-staking-providers.d.ts +14 -0
- package/dist/cjs/actions/staking/get-staking-providers.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staking-providers.js +17 -0
- package/dist/cjs/actions/staking/get-staking-quote.d.ts +18 -0
- package/dist/cjs/actions/staking/get-staking-quote.d.ts.map +1 -0
- package/dist/cjs/actions/staking/get-staking-quote.js +22 -0
- package/dist/cjs/actions/transaction/watch-transactions-by-address.d.ts +21 -0
- package/dist/cjs/actions/transaction/watch-transactions-by-address.d.ts.map +1 -0
- package/dist/cjs/actions/transaction/watch-transactions-by-address.js +22 -0
- package/dist/cjs/actions/transaction/watch-transactions.d.ts +19 -0
- package/dist/cjs/actions/transaction/watch-transactions.d.ts.map +1 -0
- package/dist/cjs/actions/transaction/watch-transactions.js +44 -0
- package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.d.ts +5 -18
- package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.d.ts.map +1 -1
- package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.js +90 -59
- package/dist/cjs/connectors/tonconnect/index.d.ts +1 -2
- package/dist/cjs/connectors/tonconnect/index.d.ts.map +1 -1
- package/dist/cjs/connectors/tonconnect/index.js +2 -2
- package/dist/cjs/core/app-kit/services/app-kit.d.ts +10 -6
- package/dist/cjs/core/app-kit/services/app-kit.d.ts.map +1 -1
- package/dist/cjs/core/app-kit/services/app-kit.js +19 -9
- package/dist/cjs/core/app-kit/types/config.d.ts +11 -5
- package/dist/cjs/core/app-kit/types/config.d.ts.map +1 -1
- package/dist/cjs/core/app-kit/types/events.d.ts +6 -5
- package/dist/cjs/core/app-kit/types/events.d.ts.map +1 -1
- package/dist/cjs/core/emitter/index.d.ts +2 -2
- package/dist/cjs/core/emitter/index.d.ts.map +1 -1
- package/dist/cjs/core/emitter/index.js +3 -3
- package/dist/cjs/core/streaming/index.d.ts +10 -0
- package/dist/cjs/core/streaming/index.d.ts.map +1 -0
- package/dist/cjs/core/streaming/index.js +16 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/queries/balances/get-balance-by-address.d.ts +11 -1
- package/dist/cjs/queries/balances/get-balance-by-address.d.ts.map +1 -1
- package/dist/cjs/queries/balances/get-balance-by-address.js +19 -2
- package/dist/cjs/queries/index.d.ts +8 -3
- package/dist/cjs/queries/index.d.ts.map +1 -1
- package/dist/cjs/queries/index.js +15 -1
- package/dist/cjs/queries/jettons/get-jetton-balance-by-address.d.ts +12 -1
- 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 +27 -2
- package/dist/cjs/queries/jettons/get-jetton-info.d.ts +1 -1
- package/dist/cjs/queries/jettons/get-jetton-info.d.ts.map +1 -1
- package/dist/cjs/queries/jettons/get-jetton-info.js +3 -1
- package/dist/cjs/queries/jettons/get-jetton-wallet-address.d.ts +1 -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 +3 -1
- package/dist/cjs/queries/jettons/get-jettons-by-address.d.ts +11 -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 +34 -2
- package/dist/cjs/queries/network/get-block-number.d.ts +1 -1
- package/dist/cjs/queries/network/get-block-number.d.ts.map +1 -1
- package/dist/cjs/queries/network/get-block-number.js +3 -1
- 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 +3 -1
- package/dist/cjs/queries/nft/get-nfts-by-address.d.ts +1 -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 +3 -1
- package/dist/cjs/queries/staking/build-stake-transaction.d.ts +21 -0
- package/dist/cjs/queries/staking/build-stake-transaction.d.ts.map +1 -0
- package/dist/cjs/queries/staking/build-stake-transaction.js +21 -0
- package/dist/cjs/queries/staking/get-staked-balance.d.ts +21 -0
- package/dist/cjs/queries/staking/get-staked-balance.d.ts.map +1 -0
- package/dist/cjs/queries/staking/get-staked-balance.js +31 -0
- package/dist/cjs/queries/staking/get-staking-provider-info.d.ts +24 -0
- package/dist/cjs/queries/staking/get-staking-provider-info.d.ts.map +1 -0
- package/dist/cjs/queries/staking/get-staking-provider-info.js +27 -0
- package/dist/cjs/queries/staking/get-staking-providers.d.ts +20 -0
- package/dist/cjs/queries/staking/get-staking-providers.d.ts.map +1 -0
- package/dist/cjs/queries/staking/get-staking-providers.js +25 -0
- package/dist/cjs/queries/staking/get-staking-quote.d.ts +21 -0
- package/dist/cjs/queries/staking/get-staking-quote.d.ts.map +1 -0
- package/dist/cjs/queries/staking/get-staking-quote.js +31 -0
- package/dist/{esm/core/emitter/types/events.js → cjs/queries/streaming-updates.test.d.ts} +1 -0
- package/dist/cjs/queries/streaming-updates.test.d.ts.map +1 -0
- package/dist/cjs/queries/streaming-updates.test.js +87 -0
- package/dist/cjs/queries/swap/get-swap-quote.d.ts +1 -1
- package/dist/cjs/queries/swap/get-swap-quote.d.ts.map +1 -1
- package/dist/cjs/queries/swap/get-swap-quote.js +3 -1
- package/dist/cjs/queries/transaction/get-transaction-status.d.ts +1 -1
- package/dist/cjs/queries/transaction/get-transaction-status.d.ts.map +1 -1
- package/dist/cjs/queries/transaction/get-transaction-status.js +4 -1
- package/dist/cjs/staking/index.d.ts +10 -0
- package/dist/cjs/staking/index.d.ts.map +1 -0
- package/dist/cjs/staking/index.js +15 -0
- package/dist/cjs/staking/tonstakers/index.d.ts +9 -0
- package/dist/cjs/staking/tonstakers/index.d.ts.map +1 -0
- package/dist/cjs/staking/tonstakers/index.js +24 -0
- package/dist/cjs/types/connector.d.ts +15 -3
- package/dist/cjs/types/connector.d.ts.map +1 -1
- package/dist/cjs/types/connector.js +5 -0
- package/dist/cjs/types/provider.d.ts +2 -2
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/utils/index.d.ts +1 -1
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +2 -1
- package/dist/esm/actions/balances/watch-balance-by-address.d.ts +21 -0
- package/dist/esm/actions/balances/watch-balance-by-address.d.ts.map +1 -0
- package/dist/esm/actions/balances/watch-balance-by-address.js +18 -0
- package/dist/esm/actions/balances/watch-balance.d.ts +19 -0
- package/dist/esm/actions/balances/watch-balance.d.ts.map +1 -0
- package/dist/esm/actions/balances/watch-balance.js +40 -0
- package/dist/esm/actions/connectors/add-connector.d.ts +3 -3
- package/dist/esm/actions/connectors/add-connector.d.ts.map +1 -1
- package/dist/esm/actions/connectors/add-connector.js +2 -2
- package/dist/esm/actions/index.d.ts +14 -0
- package/dist/esm/actions/index.d.ts.map +1 -1
- package/dist/esm/actions/index.js +15 -0
- package/dist/esm/actions/jettons/watch-jettons-by-address.d.ts +21 -0
- package/dist/esm/actions/jettons/watch-jettons-by-address.d.ts.map +1 -0
- package/dist/esm/actions/jettons/watch-jettons-by-address.js +18 -0
- package/dist/esm/actions/jettons/watch-jettons.d.ts +19 -0
- package/dist/esm/actions/jettons/watch-jettons.d.ts.map +1 -0
- package/dist/esm/actions/jettons/watch-jettons.js +40 -0
- package/dist/esm/actions/network/get-api-client.d.ts +19 -0
- package/dist/esm/actions/network/get-api-client.d.ts.map +1 -0
- package/dist/esm/actions/network/get-api-client.js +13 -0
- package/dist/esm/actions/network/has-streaming-provider.d.ts +15 -0
- package/dist/esm/actions/network/has-streaming-provider.d.ts.map +1 -0
- package/dist/esm/actions/network/has-streaming-provider.js +13 -0
- package/dist/esm/actions/providers/register-provider.d.ts +2 -2
- package/dist/esm/actions/providers/register-provider.d.ts.map +1 -1
- package/dist/esm/actions/staking/build-stake-transaction.d.ts +19 -0
- package/dist/esm/actions/staking/build-stake-transaction.d.ts.map +1 -0
- package/dist/esm/actions/staking/build-stake-transaction.js +13 -0
- package/dist/esm/actions/staking/get-staked-balance.d.ts +20 -0
- package/dist/esm/actions/staking/get-staked-balance.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staked-balance.js +14 -0
- package/dist/esm/actions/staking/get-staking-manager.d.ts +15 -0
- package/dist/esm/actions/staking/get-staking-manager.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staking-manager.js +13 -0
- package/dist/esm/actions/staking/get-staking-provider-info.d.ts +19 -0
- package/dist/esm/actions/staking/get-staking-provider-info.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staking-provider-info.js +14 -0
- package/dist/esm/actions/staking/get-staking-providers.d.ts +14 -0
- package/dist/esm/actions/staking/get-staking-providers.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staking-providers.js +13 -0
- package/dist/esm/actions/staking/get-staking-quote.d.ts +18 -0
- package/dist/esm/actions/staking/get-staking-quote.d.ts.map +1 -0
- package/dist/esm/actions/staking/get-staking-quote.js +18 -0
- package/dist/esm/actions/transaction/watch-transactions-by-address.d.ts +21 -0
- package/dist/esm/actions/transaction/watch-transactions-by-address.d.ts.map +1 -0
- package/dist/esm/actions/transaction/watch-transactions-by-address.js +18 -0
- package/dist/esm/actions/transaction/watch-transactions.d.ts +19 -0
- package/dist/esm/actions/transaction/watch-transactions.d.ts.map +1 -0
- package/dist/esm/actions/transaction/watch-transactions.js +40 -0
- package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.d.ts +5 -18
- package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.d.ts.map +1 -1
- package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.js +88 -57
- package/dist/esm/connectors/tonconnect/index.d.ts +1 -2
- package/dist/esm/connectors/tonconnect/index.d.ts.map +1 -1
- package/dist/esm/connectors/tonconnect/index.js +1 -1
- package/dist/esm/core/app-kit/services/app-kit.d.ts +10 -6
- package/dist/esm/core/app-kit/services/app-kit.d.ts.map +1 -1
- package/dist/esm/core/app-kit/services/app-kit.js +21 -11
- package/dist/esm/core/app-kit/types/config.d.ts +11 -5
- package/dist/esm/core/app-kit/types/config.d.ts.map +1 -1
- package/dist/esm/core/app-kit/types/events.d.ts +6 -5
- package/dist/esm/core/app-kit/types/events.d.ts.map +1 -1
- package/dist/esm/core/emitter/index.d.ts +2 -2
- package/dist/esm/core/emitter/index.d.ts.map +1 -1
- package/dist/esm/core/emitter/index.js +1 -1
- package/dist/esm/core/streaming/index.d.ts +10 -0
- package/dist/esm/core/streaming/index.d.ts.map +1 -0
- package/dist/esm/core/streaming/index.js +8 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/queries/balances/get-balance-by-address.d.ts +11 -1
- package/dist/esm/queries/balances/get-balance-by-address.d.ts.map +1 -1
- package/dist/esm/queries/balances/get-balance-by-address.js +18 -2
- package/dist/esm/queries/index.d.ts +8 -3
- package/dist/esm/queries/index.d.ts.map +1 -1
- package/dist/esm/queries/index.js +9 -3
- package/dist/esm/queries/jettons/get-jetton-balance-by-address.d.ts +12 -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 +26 -2
- package/dist/esm/queries/jettons/get-jetton-info.d.ts +1 -1
- package/dist/esm/queries/jettons/get-jetton-info.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jetton-info.js +4 -2
- package/dist/esm/queries/jettons/get-jetton-wallet-address.d.ts +1 -1
- package/dist/esm/queries/jettons/get-jetton-wallet-address.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jetton-wallet-address.js +4 -2
- package/dist/esm/queries/jettons/get-jettons-by-address.d.ts +11 -1
- package/dist/esm/queries/jettons/get-jettons-by-address.d.ts.map +1 -1
- package/dist/esm/queries/jettons/get-jettons-by-address.js +33 -2
- package/dist/esm/queries/network/get-block-number.d.ts +1 -1
- package/dist/esm/queries/network/get-block-number.d.ts.map +1 -1
- package/dist/esm/queries/network/get-block-number.js +4 -2
- 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 +4 -2
- package/dist/esm/queries/nft/get-nfts-by-address.d.ts +1 -1
- package/dist/esm/queries/nft/get-nfts-by-address.d.ts.map +1 -1
- package/dist/esm/queries/nft/get-nfts-by-address.js +4 -2
- package/dist/esm/queries/staking/build-stake-transaction.d.ts +21 -0
- package/dist/esm/queries/staking/build-stake-transaction.d.ts.map +1 -0
- package/dist/esm/queries/staking/build-stake-transaction.js +17 -0
- package/dist/esm/queries/staking/get-staked-balance.d.ts +21 -0
- package/dist/esm/queries/staking/get-staked-balance.d.ts.map +1 -0
- package/dist/esm/queries/staking/get-staked-balance.js +26 -0
- package/dist/esm/queries/staking/get-staking-provider-info.d.ts +24 -0
- package/dist/esm/queries/staking/get-staking-provider-info.d.ts.map +1 -0
- package/dist/esm/queries/staking/get-staking-provider-info.js +22 -0
- package/dist/esm/queries/staking/get-staking-providers.d.ts +20 -0
- package/dist/esm/queries/staking/get-staking-providers.d.ts.map +1 -0
- package/dist/esm/queries/staking/get-staking-providers.js +20 -0
- package/dist/esm/queries/staking/get-staking-quote.d.ts +21 -0
- package/dist/esm/queries/staking/get-staking-quote.d.ts.map +1 -0
- package/dist/esm/queries/staking/get-staking-quote.js +26 -0
- package/dist/{cjs/core/emitter/types/events.js → esm/queries/streaming-updates.test.d.ts} +2 -2
- package/dist/esm/queries/streaming-updates.test.d.ts.map +1 -0
- package/dist/esm/queries/streaming-updates.test.js +85 -0
- package/dist/esm/queries/swap/get-swap-quote.d.ts +1 -1
- package/dist/esm/queries/swap/get-swap-quote.d.ts.map +1 -1
- package/dist/esm/queries/swap/get-swap-quote.js +4 -2
- package/dist/esm/queries/transaction/get-transaction-status.d.ts +1 -1
- package/dist/esm/queries/transaction/get-transaction-status.d.ts.map +1 -1
- package/dist/esm/queries/transaction/get-transaction-status.js +4 -1
- package/dist/esm/staking/index.d.ts +10 -0
- package/dist/esm/staking/index.d.ts.map +1 -0
- package/dist/esm/staking/index.js +8 -0
- package/dist/esm/staking/tonstakers/index.d.ts +9 -0
- package/dist/esm/staking/tonstakers/index.d.ts.map +1 -0
- package/dist/esm/staking/tonstakers/index.js +8 -0
- package/dist/esm/types/connector.d.ts +15 -3
- package/dist/esm/types/connector.d.ts.map +1 -1
- package/dist/esm/types/connector.js +4 -1
- package/dist/esm/types/provider.d.ts +2 -2
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/docs/actions.md +112 -5
- package/docs/connectors.md +4 -4
- package/docs/staking.md +58 -0
- package/package.json +23 -10
- package/src/actions/balances/watch-balance-by-address.ts +35 -0
- package/src/actions/balances/watch-balance.ts +56 -0
- package/src/actions/connectors/add-connector.ts +4 -4
- package/src/actions/index.ts +48 -0
- package/src/actions/jettons/watch-jettons-by-address.ts +35 -0
- package/src/actions/jettons/watch-jettons.ts +56 -0
- package/src/actions/network/get-api-client.ts +22 -0
- package/src/actions/network/has-streaming-provider.ts +19 -0
- package/src/actions/providers/register-provider.ts +3 -2
- package/src/actions/staking/build-stake-transaction.ts +28 -0
- package/src/actions/staking/get-staked-balance.ts +34 -0
- package/src/actions/staking/get-staking-manager.ts +20 -0
- package/src/actions/staking/get-staking-provider-info.ts +29 -0
- package/src/actions/staking/get-staking-providers.ts +18 -0
- package/src/actions/staking/get-staking-quote.ts +30 -0
- package/src/actions/transaction/watch-transactions-by-address.ts +35 -0
- package/src/actions/transaction/watch-transactions.ts +56 -0
- package/src/connectors/tonconnect/connectors/ton-connect-connector.ts +109 -74
- package/src/connectors/tonconnect/index.ts +5 -2
- package/src/core/app-kit/services/app-kit.ts +29 -15
- package/src/core/app-kit/types/config.ts +13 -5
- package/src/core/app-kit/types/events.ts +6 -5
- package/src/core/emitter/index.ts +2 -2
- package/src/core/streaming/index.ts +30 -0
- package/src/index.ts +2 -0
- package/src/queries/balances/get-balance-by-address.ts +29 -2
- package/src/queries/index.ts +39 -0
- package/src/queries/jettons/get-jetton-balance-by-address.ts +36 -2
- package/src/queries/jettons/get-jetton-info.ts +5 -2
- package/src/queries/jettons/get-jetton-wallet-address.ts +5 -2
- package/src/queries/jettons/get-jettons-by-address.ts +48 -2
- package/src/queries/network/get-block-number.ts +5 -2
- package/src/queries/nft/get-nft.ts +5 -2
- package/src/queries/nft/get-nfts-by-address.ts +5 -2
- package/src/queries/staking/build-stake-transaction.ts +79 -0
- package/src/queries/staking/get-staked-balance.ts +60 -0
- package/src/queries/staking/get-staking-provider-info.ts +63 -0
- package/src/queries/staking/get-staking-providers.ts +52 -0
- package/src/queries/staking/get-staking-quote.ts +60 -0
- package/src/queries/streaming-updates.test.ts +104 -0
- package/src/queries/swap/get-swap-quote.ts +5 -2
- package/src/queries/transaction/get-transaction-status.ts +5 -1
- package/src/staking/index.ts +21 -0
- package/src/staking/tonstakers/index.ts +9 -0
- package/src/types/connector.ts +21 -4
- package/src/types/provider.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/dist/cjs/core/emitter/services/emitter.d.ts +0 -18
- package/dist/cjs/core/emitter/services/emitter.d.ts.map +0 -1
- package/dist/cjs/core/emitter/services/emitter.js +0 -47
- package/dist/cjs/core/emitter/types/events.d.ts +0 -16
- package/dist/cjs/core/emitter/types/events.d.ts.map +0 -1
- package/dist/esm/core/emitter/services/emitter.d.ts +0 -18
- package/dist/esm/core/emitter/services/emitter.d.ts.map +0 -1
- package/dist/esm/core/emitter/services/emitter.js +0 -43
- package/dist/esm/core/emitter/types/events.d.ts +0 -16
- package/dist/esm/core/emitter/types/events.d.ts.map +0 -1
- package/src/core/emitter/services/emitter.ts +0 -53
- package/src/core/emitter/types/events.ts +0 -18
|
@@ -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 } from '../../utils';
|
|
16
|
+
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
17
17
|
|
|
18
18
|
export type GetJettonWalletAddressErrorType = Error;
|
|
19
19
|
|
|
@@ -29,8 +29,11 @@ export type GetJettonWalletAddressQueryConfig<selectData = GetJettonWalletAddres
|
|
|
29
29
|
|
|
30
30
|
export const getJettonWalletAddressQueryOptions = <selectData = GetJettonWalletAddressData>(
|
|
31
31
|
appKit: AppKit,
|
|
32
|
-
|
|
32
|
+
initialOptions: GetJettonWalletAddressQueryConfig<selectData> = {},
|
|
33
33
|
): GetJettonWalletAddressQueryOptions<selectData> => {
|
|
34
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
35
|
+
const options = { ...initialOptions, network };
|
|
36
|
+
|
|
34
37
|
return {
|
|
35
38
|
...options.query,
|
|
36
39
|
enabled: Boolean(options.jettonAddress && options.ownerAddress && (options.query?.enabled ?? true)),
|
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import type { QueryClient } from '@tanstack/query-core';
|
|
10
|
+
|
|
9
11
|
import type { AppKit } from '../../core/app-kit';
|
|
10
12
|
import { getJettonsByAddress } from '../../actions/jettons/get-jettons-by-address';
|
|
11
13
|
import type { GetJettonsByAddressOptions } from '../../actions/jettons/get-jettons-by-address';
|
|
12
14
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
13
15
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
14
|
-
import { filterQueryOptions } from '../../utils';
|
|
16
|
+
import { filterQueryOptions, resolveNetwork, compareAddress, formatUnits, sleep } from '../../utils';
|
|
15
17
|
import type { GetJettonsByAddressReturnType } from '../../actions/jettons/get-jettons-by-address';
|
|
18
|
+
import type { JettonUpdate } from '../../core/streaming';
|
|
19
|
+
import type { Network } from '../../types/network';
|
|
16
20
|
|
|
17
21
|
export type GetJettonsErrorType = Error;
|
|
18
22
|
|
|
@@ -25,8 +29,11 @@ export type GetJettonsByAddressQueryConfig<selectData = GetJettonsByAddressData>
|
|
|
25
29
|
|
|
26
30
|
export const getJettonsByAddressQueryOptions = <selectData = GetJettonsByAddressData>(
|
|
27
31
|
appKit: AppKit,
|
|
28
|
-
|
|
32
|
+
initialOptions: GetJettonsByAddressQueryConfig<selectData> = {},
|
|
29
33
|
): GetJettonsByAddressQueryOptions<selectData> => {
|
|
34
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
35
|
+
const options = { ...initialOptions, network };
|
|
36
|
+
|
|
30
37
|
return {
|
|
31
38
|
...options.query,
|
|
32
39
|
enabled: Boolean(options.address && (options.query?.enabled ?? true)),
|
|
@@ -57,3 +64,42 @@ export type GetJettonsByAddressQueryOptions<selectData = GetJettonsByAddressData
|
|
|
57
64
|
selectData,
|
|
58
65
|
GetJettonsByAddressQueryKey
|
|
59
66
|
>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Update the TanStack Query cache for an address jettons list.
|
|
70
|
+
*/
|
|
71
|
+
export const handleJettonsUpdate = (
|
|
72
|
+
queryClient: QueryClient,
|
|
73
|
+
{ address, network }: { address: string; network: Network },
|
|
74
|
+
update: JettonUpdate,
|
|
75
|
+
) => {
|
|
76
|
+
if (update.status === 'finalized') {
|
|
77
|
+
const queryKey = getJettonsByAddressQueryKey({ address, network });
|
|
78
|
+
const currentData = queryClient.getQueryData(queryKey) as GetJettonsByAddressData | undefined;
|
|
79
|
+
|
|
80
|
+
if (currentData?.jettons) {
|
|
81
|
+
const jetton = currentData.jettons.find((j) => compareAddress(j.address, update.masterAddress));
|
|
82
|
+
const decimals = jetton?.decimalsNumber ?? update.decimals;
|
|
83
|
+
|
|
84
|
+
if (jetton && decimals) {
|
|
85
|
+
const updatedJetton = {
|
|
86
|
+
...jetton,
|
|
87
|
+
balance: formatUnits(update.rawBalance, decimals),
|
|
88
|
+
};
|
|
89
|
+
const newJettons = currentData.jettons.map((j) =>
|
|
90
|
+
compareAddress(j.address, update.masterAddress) ? updatedJetton : j,
|
|
91
|
+
);
|
|
92
|
+
queryClient.setQueryData(queryKey, {
|
|
93
|
+
...currentData,
|
|
94
|
+
jettons: newJettons,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
sleep(5000).then(() => queryClient.invalidateQueries({ queryKey }));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (update.status === 'invalidated') {
|
|
102
|
+
const queryKey = getJettonsByAddressQueryKey({ address, network });
|
|
103
|
+
queryClient.invalidateQueries({ queryKey });
|
|
104
|
+
}
|
|
105
|
+
};
|
|
@@ -11,7 +11,7 @@ import { getBlockNumber } from '../../actions/network/get-block-number';
|
|
|
11
11
|
import type { GetBlockNumberOptions } from '../../actions/network/get-block-number';
|
|
12
12
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
13
13
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
14
|
-
import { filterQueryOptions } from '../../utils';
|
|
14
|
+
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
15
15
|
import type { GetBlockNumberReturnType } from '../../actions/network/get-block-number';
|
|
16
16
|
|
|
17
17
|
export type GetBlockNumberErrorType = Error;
|
|
@@ -23,8 +23,11 @@ export type GetBlockNumberQueryConfig<selectData = GetBlockNumberData> = Compute
|
|
|
23
23
|
|
|
24
24
|
export const getBlockNumberQueryOptions = <selectData = GetBlockNumberData>(
|
|
25
25
|
appKit: AppKit,
|
|
26
|
-
|
|
26
|
+
initialOptions: GetBlockNumberQueryConfig<selectData> = {},
|
|
27
27
|
): GetBlockNumberQueryOptions<selectData> => {
|
|
28
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
29
|
+
const options = { ...initialOptions, network };
|
|
30
|
+
|
|
28
31
|
return {
|
|
29
32
|
...options.query,
|
|
30
33
|
gcTime: 0,
|
|
@@ -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 } from '../../utils';
|
|
16
|
+
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
17
17
|
|
|
18
18
|
export type GetNftErrorType = Error;
|
|
19
19
|
|
|
@@ -22,8 +22,11 @@ export type GetNftQueryConfig<selectData = GetNftData> = Compute<ExactPartial<Ge
|
|
|
22
22
|
|
|
23
23
|
export const getNftQueryOptions = <selectData = GetNftData>(
|
|
24
24
|
appKit: AppKit,
|
|
25
|
-
|
|
25
|
+
initialOptions: GetNftQueryConfig<selectData> = {},
|
|
26
26
|
): GetNftQueryOptions<selectData> => {
|
|
27
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
28
|
+
const options = { ...initialOptions, network };
|
|
29
|
+
|
|
27
30
|
return {
|
|
28
31
|
...options.query,
|
|
29
32
|
enabled: Boolean(options.address && (options.query?.enabled ?? true)),
|
|
@@ -11,7 +11,7 @@ import { getNftsByAddress } from '../../actions/nft/get-nfts-by-address';
|
|
|
11
11
|
import type { GetNftsByAddressOptions } from '../../actions/nft/get-nfts-by-address';
|
|
12
12
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
13
13
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
14
|
-
import { filterQueryOptions } from '../../utils';
|
|
14
|
+
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
15
15
|
import type { GetNftsByAddressReturnType } from '../../actions/nft/get-nfts-by-address';
|
|
16
16
|
|
|
17
17
|
export type GetNFTsErrorType = Error;
|
|
@@ -25,8 +25,11 @@ export type GetNFTsByAddressQueryConfig<selectData = GetNFTsByAddressData> = Com
|
|
|
25
25
|
|
|
26
26
|
export const getNFTsByAddressQueryOptions = <selectData = GetNFTsByAddressData>(
|
|
27
27
|
appKit: AppKit,
|
|
28
|
-
|
|
28
|
+
initialOptions: GetNFTsByAddressQueryConfig<selectData> = {},
|
|
29
29
|
): GetNFTsByAddressQueryOptions<selectData> => {
|
|
30
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
31
|
+
const options = { ...initialOptions, network };
|
|
32
|
+
|
|
30
33
|
return {
|
|
31
34
|
...options.query,
|
|
32
35
|
enabled: Boolean(options.address && (options.query?.enabled ?? true)),
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { MutateOptions, MutationOptions } from '@tanstack/query-core';
|
|
10
|
+
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
import type { MutationParameter } from '../../types/query';
|
|
13
|
+
import type { Compute } from '../../types/utils';
|
|
14
|
+
import { buildStakeTransaction } from '../../actions/staking/build-stake-transaction';
|
|
15
|
+
import type {
|
|
16
|
+
BuildStakeTransactionOptions,
|
|
17
|
+
BuildStakeTransactionReturnType,
|
|
18
|
+
} from '../../actions/staking/build-stake-transaction';
|
|
19
|
+
|
|
20
|
+
export type BuildStakeTransactionMutationOptions<context = unknown> = MutationParameter<
|
|
21
|
+
BuildStakeTransactionData,
|
|
22
|
+
BuildStakeTransactionErrorType,
|
|
23
|
+
BuildStakeTransactionVariables,
|
|
24
|
+
context
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export const buildStakeTransactionMutationOptions = <context = unknown>(
|
|
28
|
+
appKit: AppKit,
|
|
29
|
+
options: BuildStakeTransactionMutationOptions<context> = {},
|
|
30
|
+
): BuildStakeTransactionMutationConfig<context> => {
|
|
31
|
+
return {
|
|
32
|
+
...options.mutation,
|
|
33
|
+
mutationFn(variables) {
|
|
34
|
+
return buildStakeTransaction(appKit, variables);
|
|
35
|
+
},
|
|
36
|
+
mutationKey: ['buildStakeTransaction'],
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type BuildStakeTransactionMutationConfig<context = unknown> = MutationOptions<
|
|
41
|
+
BuildStakeTransactionData,
|
|
42
|
+
BuildStakeTransactionErrorType,
|
|
43
|
+
BuildStakeTransactionVariables,
|
|
44
|
+
context
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
|
+
export type BuildStakeTransactionData = Compute<Awaited<BuildStakeTransactionReturnType>>;
|
|
48
|
+
|
|
49
|
+
export type BuildStakeTransactionErrorType = Error;
|
|
50
|
+
|
|
51
|
+
export type BuildStakeTransactionVariables = BuildStakeTransactionOptions;
|
|
52
|
+
|
|
53
|
+
export type BuildStakeTransactionMutate<context = unknown> = (
|
|
54
|
+
variables: BuildStakeTransactionVariables,
|
|
55
|
+
options?:
|
|
56
|
+
| Compute<
|
|
57
|
+
MutateOptions<
|
|
58
|
+
BuildStakeTransactionData,
|
|
59
|
+
BuildStakeTransactionErrorType,
|
|
60
|
+
Compute<BuildStakeTransactionVariables>,
|
|
61
|
+
context
|
|
62
|
+
>
|
|
63
|
+
>
|
|
64
|
+
| undefined,
|
|
65
|
+
) => void;
|
|
66
|
+
|
|
67
|
+
export type BuildStakeTransactionMutateAsync<context = unknown> = (
|
|
68
|
+
variables: BuildStakeTransactionVariables,
|
|
69
|
+
options?:
|
|
70
|
+
| Compute<
|
|
71
|
+
MutateOptions<
|
|
72
|
+
BuildStakeTransactionData,
|
|
73
|
+
BuildStakeTransactionErrorType,
|
|
74
|
+
Compute<BuildStakeTransactionVariables>,
|
|
75
|
+
context
|
|
76
|
+
>
|
|
77
|
+
>
|
|
78
|
+
| undefined,
|
|
79
|
+
) => Promise<BuildStakeTransactionData>;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { getStakedBalance } from '../../actions/staking/get-staked-balance';
|
|
10
|
+
import type { GetStakedBalanceOptions } from '../../actions/staking/get-staked-balance';
|
|
11
|
+
import type { GetStakedBalanceReturnType } from '../../actions/staking/get-staked-balance';
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
14
|
+
import type { Compute, ExactPartial } from '../../types/utils';
|
|
15
|
+
import { filterQueryOptions } from '../../utils';
|
|
16
|
+
|
|
17
|
+
export type GetStakedBalanceErrorType = Error;
|
|
18
|
+
|
|
19
|
+
export type GetStakedBalanceQueryConfig<selectData = GetStakedBalanceData> = Compute<
|
|
20
|
+
ExactPartial<GetStakedBalanceOptions>
|
|
21
|
+
> &
|
|
22
|
+
QueryParameter<GetStakedBalanceQueryFnData, GetStakedBalanceErrorType, selectData, GetStakedBalanceQueryKey>;
|
|
23
|
+
|
|
24
|
+
export const getStakedBalanceQueryOptions = <selectData = GetStakedBalanceData>(
|
|
25
|
+
appKit: AppKit,
|
|
26
|
+
options: GetStakedBalanceQueryConfig<selectData> = {},
|
|
27
|
+
): GetStakedBalanceQueryOptions<selectData> => {
|
|
28
|
+
return {
|
|
29
|
+
...options.query,
|
|
30
|
+
enabled: Boolean(options.userAddress && (options.query?.enabled ?? true)),
|
|
31
|
+
queryFn: async (context) => {
|
|
32
|
+
const [, parameters] = context.queryKey as [string, GetStakedBalanceOptions];
|
|
33
|
+
if (!parameters.userAddress) {
|
|
34
|
+
throw new Error('userAddress is required');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return getStakedBalance(appKit, parameters);
|
|
38
|
+
},
|
|
39
|
+
queryKey: getStakedBalanceQueryKey(options),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type GetStakedBalanceQueryFnData = Compute<Awaited<GetStakedBalanceReturnType>>;
|
|
44
|
+
|
|
45
|
+
export type GetStakedBalanceData = GetStakedBalanceQueryFnData;
|
|
46
|
+
|
|
47
|
+
export const getStakedBalanceQueryKey = (
|
|
48
|
+
options: Compute<ExactPartial<GetStakedBalanceOptions>> = {},
|
|
49
|
+
): GetStakedBalanceQueryKey => {
|
|
50
|
+
return ['stakedBalance', filterQueryOptions(options as unknown as Record<string, unknown>)] as const;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type GetStakedBalanceQueryKey = readonly ['stakedBalance', Compute<ExactPartial<GetStakedBalanceOptions>>];
|
|
54
|
+
|
|
55
|
+
export type GetStakedBalanceQueryOptions<selectData = GetStakedBalanceData> = QueryOptions<
|
|
56
|
+
GetStakedBalanceQueryFnData,
|
|
57
|
+
GetStakedBalanceErrorType,
|
|
58
|
+
selectData,
|
|
59
|
+
GetStakedBalanceQueryKey
|
|
60
|
+
>;
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { getStakingProviderInfo } from '../../actions/staking/get-staking-provider-info';
|
|
10
|
+
import type { GetStakingProviderInfoOptions } from '../../actions/staking/get-staking-provider-info';
|
|
11
|
+
import type { GetStakingProviderInfoReturnType } from '../../actions/staking/get-staking-provider-info';
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
14
|
+
import type { Compute, ExactPartial } from '../../types/utils';
|
|
15
|
+
import { filterQueryOptions } from '../../utils';
|
|
16
|
+
|
|
17
|
+
export type GetStakingProviderInfoErrorType = Error;
|
|
18
|
+
|
|
19
|
+
export type GetStakingProviderInfoQueryConfig<selectData = GetStakingProviderInfoData> = Compute<
|
|
20
|
+
ExactPartial<GetStakingProviderInfoOptions>
|
|
21
|
+
> &
|
|
22
|
+
QueryParameter<
|
|
23
|
+
GetStakingProviderInfoQueryFnData,
|
|
24
|
+
GetStakingProviderInfoErrorType,
|
|
25
|
+
selectData,
|
|
26
|
+
GetStakingProviderInfoQueryKey
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
export const getStakingProviderInfoQueryOptions = <selectData = GetStakingProviderInfoData>(
|
|
30
|
+
appKit: AppKit,
|
|
31
|
+
options: GetStakingProviderInfoQueryConfig<selectData> = {},
|
|
32
|
+
): GetStakingProviderInfoQueryOptions<selectData> => {
|
|
33
|
+
return {
|
|
34
|
+
...options.query,
|
|
35
|
+
queryFn: async (context) => {
|
|
36
|
+
const [, parameters] = context.queryKey as [string, GetStakingProviderInfoOptions];
|
|
37
|
+
return getStakingProviderInfo(appKit, parameters);
|
|
38
|
+
},
|
|
39
|
+
queryKey: getStakingProviderInfoQueryKey(options),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type GetStakingProviderInfoQueryFnData = Compute<Awaited<GetStakingProviderInfoReturnType>>;
|
|
44
|
+
|
|
45
|
+
export type GetStakingProviderInfoData = GetStakingProviderInfoQueryFnData;
|
|
46
|
+
|
|
47
|
+
export const getStakingProviderInfoQueryKey = (
|
|
48
|
+
options: Compute<ExactPartial<GetStakingProviderInfoOptions>> = {},
|
|
49
|
+
): GetStakingProviderInfoQueryKey => {
|
|
50
|
+
return ['stakingProviderInfo', filterQueryOptions(options as unknown as Record<string, unknown>)] as const;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type GetStakingProviderInfoQueryKey = readonly [
|
|
54
|
+
'stakingProviderInfo',
|
|
55
|
+
Compute<ExactPartial<GetStakingProviderInfoOptions>>,
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export type GetStakingProviderInfoQueryOptions<selectData = GetStakingProviderInfoData> = QueryOptions<
|
|
59
|
+
GetStakingProviderInfoQueryFnData,
|
|
60
|
+
GetStakingProviderInfoErrorType,
|
|
61
|
+
selectData,
|
|
62
|
+
GetStakingProviderInfoQueryKey
|
|
63
|
+
>;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { getStakingProviders } from '../../actions/staking/get-staking-providers';
|
|
10
|
+
import type { GetStakingProvidersReturnType } from '../../actions/staking/get-staking-providers';
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
13
|
+
import type { Compute } from '../../types/utils';
|
|
14
|
+
|
|
15
|
+
export type GetStakingProvidersErrorType = Error;
|
|
16
|
+
|
|
17
|
+
export type GetStakingProvidersQueryConfig<selectData = GetStakingProvidersData> = QueryParameter<
|
|
18
|
+
GetStakingProvidersQueryFnData,
|
|
19
|
+
GetStakingProvidersErrorType,
|
|
20
|
+
selectData,
|
|
21
|
+
GetStakingProvidersQueryKey
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export const getStakingProvidersQueryOptions = <selectData = GetStakingProvidersData>(
|
|
25
|
+
appKit: AppKit,
|
|
26
|
+
options: GetStakingProvidersQueryConfig<selectData> = {},
|
|
27
|
+
): GetStakingProvidersQueryOptions<selectData> => {
|
|
28
|
+
return {
|
|
29
|
+
...options.query,
|
|
30
|
+
queryFn: async () => {
|
|
31
|
+
return getStakingProviders(appKit);
|
|
32
|
+
},
|
|
33
|
+
queryKey: getStakingProvidersQueryKey(),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type GetStakingProvidersQueryFnData = Compute<Awaited<GetStakingProvidersReturnType>>;
|
|
38
|
+
|
|
39
|
+
export type GetStakingProvidersData = GetStakingProvidersQueryFnData;
|
|
40
|
+
|
|
41
|
+
export const getStakingProvidersQueryKey = (): GetStakingProvidersQueryKey => {
|
|
42
|
+
return ['stakingProviders'] as const;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type GetStakingProvidersQueryKey = readonly ['stakingProviders'];
|
|
46
|
+
|
|
47
|
+
export type GetStakingProvidersQueryOptions<selectData = GetStakingProvidersData> = QueryOptions<
|
|
48
|
+
GetStakingProvidersQueryFnData,
|
|
49
|
+
GetStakingProvidersErrorType,
|
|
50
|
+
selectData,
|
|
51
|
+
GetStakingProvidersQueryKey
|
|
52
|
+
>;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { getStakingQuote } from '../../actions/staking/get-staking-quote';
|
|
10
|
+
import type { GetStakingQuoteOptions } from '../../actions/staking/get-staking-quote';
|
|
11
|
+
import type { GetStakingQuoteReturnType } from '../../actions/staking/get-staking-quote';
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
14
|
+
import type { Compute, ExactPartial } from '../../types/utils';
|
|
15
|
+
import { filterQueryOptions } from '../../utils';
|
|
16
|
+
|
|
17
|
+
export type GetStakingQuoteErrorType = Error;
|
|
18
|
+
|
|
19
|
+
export type GetStakingQuoteQueryConfig<selectData = GetStakingQuoteData> = Compute<
|
|
20
|
+
ExactPartial<GetStakingQuoteOptions>
|
|
21
|
+
> &
|
|
22
|
+
QueryParameter<GetStakingQuoteQueryFnData, GetStakingQuoteErrorType, selectData, GetStakingQuoteQueryKey>;
|
|
23
|
+
|
|
24
|
+
export const getStakingQuoteQueryOptions = <selectData = GetStakingQuoteData>(
|
|
25
|
+
appKit: AppKit,
|
|
26
|
+
options: GetStakingQuoteQueryConfig<selectData> = {},
|
|
27
|
+
): GetStakingQuoteQueryOptions<selectData> => {
|
|
28
|
+
return {
|
|
29
|
+
...options.query,
|
|
30
|
+
enabled: Boolean(options.amount && options.direction && (options.query?.enabled ?? true)),
|
|
31
|
+
queryFn: async (context) => {
|
|
32
|
+
const [, parameters] = context.queryKey as [string, GetStakingQuoteOptions];
|
|
33
|
+
if (!parameters.amount || !parameters.direction) {
|
|
34
|
+
throw new Error('amount and direction are required');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return getStakingQuote(appKit, parameters);
|
|
38
|
+
},
|
|
39
|
+
queryKey: getStakingQuoteQueryKey(options),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type GetStakingQuoteQueryFnData = Compute<Awaited<GetStakingQuoteReturnType>>;
|
|
44
|
+
|
|
45
|
+
export type GetStakingQuoteData = GetStakingQuoteQueryFnData;
|
|
46
|
+
|
|
47
|
+
export const getStakingQuoteQueryKey = (
|
|
48
|
+
options: Compute<ExactPartial<GetStakingQuoteOptions>> = {},
|
|
49
|
+
): GetStakingQuoteQueryKey => {
|
|
50
|
+
return ['stakingQuote', filterQueryOptions(options as unknown as Record<string, unknown>)] as const;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type GetStakingQuoteQueryKey = readonly ['stakingQuote', Compute<ExactPartial<GetStakingQuoteOptions>>];
|
|
54
|
+
|
|
55
|
+
export type GetStakingQuoteQueryOptions<selectData = GetStakingQuoteData> = QueryOptions<
|
|
56
|
+
GetStakingQuoteQueryFnData,
|
|
57
|
+
GetStakingQuoteErrorType,
|
|
58
|
+
selectData,
|
|
59
|
+
GetStakingQuoteQueryKey
|
|
60
|
+
>;
|
|
@@ -0,0 +1,104 @@
|
|
|
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, it, expect, vi, beforeEach } from 'vitest';
|
|
10
|
+
import type { QueryClient } from '@tanstack/query-core';
|
|
11
|
+
|
|
12
|
+
import { handleBalanceUpdate } from './balances/get-balance-by-address';
|
|
13
|
+
import { handleJettonBalanceUpdate } from './jettons/get-jetton-balance-by-address';
|
|
14
|
+
import { handleJettonsUpdate } from './jettons/get-jettons-by-address';
|
|
15
|
+
import { Network } from '../types/network';
|
|
16
|
+
import type { BalanceUpdate, JettonUpdate } from '../core/streaming';
|
|
17
|
+
|
|
18
|
+
describe('Streaming Updates Handlers', () => {
|
|
19
|
+
let queryClient: QueryClient;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
queryClient = {
|
|
23
|
+
setQueryData: vi.fn(),
|
|
24
|
+
invalidateQueries: vi.fn(),
|
|
25
|
+
getQueryData: vi.fn(),
|
|
26
|
+
} as unknown as QueryClient;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const network = Network.mainnet();
|
|
30
|
+
|
|
31
|
+
describe('handleBalanceUpdate', () => {
|
|
32
|
+
it('should invalidate query immediately on invalidated status', () => {
|
|
33
|
+
const address = 'EQD...';
|
|
34
|
+
const update: BalanceUpdate = {
|
|
35
|
+
type: 'balance',
|
|
36
|
+
address,
|
|
37
|
+
balance: '100',
|
|
38
|
+
rawBalance: '100000000',
|
|
39
|
+
status: 'invalidated',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
handleBalanceUpdate(queryClient, { address, network }, update);
|
|
43
|
+
|
|
44
|
+
expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
|
|
45
|
+
queryKey: expect.arrayContaining(['balance']),
|
|
46
|
+
});
|
|
47
|
+
expect(queryClient.setQueryData).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should update data on finalized status', () => {
|
|
51
|
+
const address = 'EQD...';
|
|
52
|
+
const update: BalanceUpdate = {
|
|
53
|
+
type: 'balance',
|
|
54
|
+
address,
|
|
55
|
+
balance: '100',
|
|
56
|
+
rawBalance: '100000000',
|
|
57
|
+
status: 'finalized',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
handleBalanceUpdate(queryClient, { address, network }, update);
|
|
61
|
+
|
|
62
|
+
expect(queryClient.setQueryData).toHaveBeenCalled();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('handleJettonBalanceUpdate', () => {
|
|
67
|
+
it('should invalidate query immediately on invalidated status', () => {
|
|
68
|
+
const ownerAddress = 'EQO...';
|
|
69
|
+
const jettonAddress = 'EQJ...';
|
|
70
|
+
const update: JettonUpdate = {
|
|
71
|
+
type: 'jettons',
|
|
72
|
+
ownerAddress,
|
|
73
|
+
masterAddress: jettonAddress,
|
|
74
|
+
walletAddress: jettonAddress,
|
|
75
|
+
rawBalance: '50',
|
|
76
|
+
status: 'invalidated',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
handleJettonBalanceUpdate(queryClient, { ownerAddress, jettonAddress, network }, update);
|
|
80
|
+
|
|
81
|
+
expect(queryClient.invalidateQueries).toHaveBeenCalled();
|
|
82
|
+
expect(queryClient.setQueryData).not.toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('handleJettonsUpdate', () => {
|
|
87
|
+
it('should invalidate query immediately on invalidated status', () => {
|
|
88
|
+
const address = 'EQA...';
|
|
89
|
+
const update: JettonUpdate = {
|
|
90
|
+
type: 'jettons',
|
|
91
|
+
ownerAddress: address,
|
|
92
|
+
masterAddress: address,
|
|
93
|
+
walletAddress: address,
|
|
94
|
+
rawBalance: '0',
|
|
95
|
+
status: 'invalidated',
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
handleJettonsUpdate(queryClient, { address, network }, update);
|
|
99
|
+
|
|
100
|
+
expect(queryClient.invalidateQueries).toHaveBeenCalled();
|
|
101
|
+
expect(queryClient.setQueryData).not.toHaveBeenCalled();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -12,7 +12,7 @@ import type { GetSwapQuoteReturnType } from '../../actions/swap/get-swap-quote';
|
|
|
12
12
|
import type { AppKit } from '../../core/app-kit';
|
|
13
13
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
14
14
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
15
|
-
import { filterQueryOptions } from '../../utils';
|
|
15
|
+
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
16
16
|
|
|
17
17
|
export type GetSwapQuoteErrorType = Error;
|
|
18
18
|
|
|
@@ -21,8 +21,11 @@ export type GetSwapQuoteQueryConfig<selectData = GetSwapQuoteData> = Compute<Exa
|
|
|
21
21
|
|
|
22
22
|
export const getSwapQuoteQueryOptions = <selectData = GetSwapQuoteData>(
|
|
23
23
|
appKit: AppKit,
|
|
24
|
-
|
|
24
|
+
initialOptions: GetSwapQuoteQueryConfig<selectData> = {},
|
|
25
25
|
): GetSwapQuoteQueryOptions<selectData> => {
|
|
26
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
27
|
+
const options = { ...initialOptions, network };
|
|
28
|
+
|
|
26
29
|
return {
|
|
27
30
|
...options.query,
|
|
28
31
|
enabled: Boolean(options.amount && options.from && options.to && (options.query?.enabled ?? true)),
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
import type { AppKit } from '../../core/app-kit';
|
|
16
16
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
17
17
|
import type { Compute } from '../../types/utils';
|
|
18
|
+
import { resolveNetwork } from '../../utils';
|
|
18
19
|
|
|
19
20
|
export type { GetTransactionStatusErrorType, GetTransactionStatusParameters, GetTransactionStatusReturnType };
|
|
20
21
|
|
|
@@ -38,8 +39,11 @@ export type GetTransactionStatusQueryOptions<selectData = GetTransactionStatusDa
|
|
|
38
39
|
|
|
39
40
|
export const getTransactionStatusQueryOptions = <selectData = GetTransactionStatusData>(
|
|
40
41
|
appKit: AppKit,
|
|
41
|
-
|
|
42
|
+
initialOptions: GetTransactionStatusParameters & GetTransactionStatusQueryConfig<selectData>,
|
|
42
43
|
): GetTransactionStatusQueryOptions<selectData> => {
|
|
44
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
45
|
+
const options = { ...initialOptions, network };
|
|
46
|
+
|
|
43
47
|
return {
|
|
44
48
|
...options.query,
|
|
45
49
|
queryFn: () => {
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { StakingProvider, UnstakeMode, StakingError, StakingManager } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
UnstakeModes,
|
|
13
|
+
StakeParams,
|
|
14
|
+
StakingAPI,
|
|
15
|
+
StakingQuote,
|
|
16
|
+
StakingQuoteParams,
|
|
17
|
+
StakingBalance,
|
|
18
|
+
StakingProviderInfo,
|
|
19
|
+
StakingProviderInterface,
|
|
20
|
+
StakingQuoteDirection,
|
|
21
|
+
} from '@ton/walletkit';
|