@ton/appkit 0.0.5-alpha.0 → 0.0.5-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
import { TonConnectUI } from '@tonconnect/ui';
|
|
10
10
|
import type { TonConnectUiCreateOptions } from '@tonconnect/ui';
|
|
11
11
|
|
|
12
|
-
import type { Network } from '../../../types/network';
|
|
13
12
|
import { TonConnectWalletAdapter } from '../adapters/ton-connect-wallet-adapter';
|
|
14
13
|
import { CONNECTOR_EVENTS, NETWORKS_EVENTS } from '../../../core/app-kit';
|
|
15
14
|
import type { Connector, ConnectorMetadata } from '../../../types/connector';
|
|
16
15
|
import type { WalletInterface } from '../../../types/wallet';
|
|
17
|
-
import type { AppKitEmitter } from '../../../core/app-kit';
|
|
18
16
|
import { TONCONNECT_DEFAULT_CONNECTOR_ID } from '../constants/id';
|
|
19
|
-
import
|
|
17
|
+
import { createConnector } from '../../../types/connector';
|
|
20
18
|
|
|
21
19
|
export interface TonConnectConnectorConfig {
|
|
22
20
|
id?: string;
|
|
@@ -25,84 +23,121 @@ export interface TonConnectConnectorConfig {
|
|
|
25
23
|
tonConnectUI?: TonConnectUI;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly tonConnectUI: TonConnectUI;
|
|
33
|
-
|
|
34
|
-
private emitter: AppKitEmitter | null = null;
|
|
35
|
-
private unsubscribeTonConnect: (() => void) | null = null;
|
|
36
|
-
|
|
37
|
-
constructor(config: TonConnectConnectorConfig) {
|
|
38
|
-
if (config.tonConnectOptions && config.tonConnectUI) {
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
|
-
console.warn(
|
|
41
|
-
'TonConnectConnector: both tonConnectOptions and tonConnectUI are provided, using tonConnectUI',
|
|
42
|
-
);
|
|
43
|
-
}
|
|
26
|
+
export type TonConnectConnector = Connector & {
|
|
27
|
+
type: 'tonconnect';
|
|
28
|
+
tonConnectUI: TonConnectUI | null;
|
|
29
|
+
};
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
}
|
|
31
|
+
export const createTonConnectConnector = (config: TonConnectConnectorConfig) => {
|
|
32
|
+
return createConnector(({ eventEmitter, networkManager, ssr }): TonConnectConnector => {
|
|
33
|
+
let originalTonConnectUI: TonConnectUI | null = null;
|
|
34
|
+
let unsubscribeTonConnect: (() => void) | null = null;
|
|
35
|
+
|
|
36
|
+
const id = config.id ?? TONCONNECT_DEFAULT_CONNECTOR_ID;
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
function getTonConnectUI() {
|
|
39
|
+
if (originalTonConnectUI) {
|
|
40
|
+
return originalTonConnectUI;
|
|
41
|
+
}
|
|
56
42
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
if (ssr && typeof window === 'undefined') {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
60
46
|
|
|
61
|
-
if
|
|
62
|
-
|
|
47
|
+
// check if we have pre-defined UI
|
|
48
|
+
if (config.tonConnectUI) {
|
|
49
|
+
originalTonConnectUI = config.tonConnectUI;
|
|
63
50
|
} else {
|
|
64
|
-
|
|
51
|
+
originalTonConnectUI = new TonConnectUI(config.tonConnectOptions);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setupListeners();
|
|
55
|
+
|
|
56
|
+
// restore connection
|
|
57
|
+
if (originalTonConnectUI) {
|
|
58
|
+
originalTonConnectUI.connector.restoreConnection();
|
|
65
59
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
60
|
+
|
|
61
|
+
return originalTonConnectUI;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getConnectedWallets(): WalletInterface[] {
|
|
65
|
+
const ui = getTonConnectUI();
|
|
66
|
+
|
|
67
|
+
if (ui && ui.connected && ui.wallet) {
|
|
68
|
+
const wallet = ui.wallet;
|
|
69
|
+
|
|
70
|
+
return [
|
|
71
|
+
new TonConnectWalletAdapter({
|
|
72
|
+
connectorId: id,
|
|
73
|
+
tonConnectWallet: wallet,
|
|
74
|
+
tonConnectUI: ui,
|
|
75
|
+
}),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function setupListeners() {
|
|
83
|
+
if (!originalTonConnectUI || unsubscribeTonConnect) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
unsubscribeTonConnect = originalTonConnectUI.onStatusChange((wallet) => {
|
|
88
|
+
const wallets = getConnectedWallets();
|
|
89
|
+
|
|
90
|
+
if (wallet) {
|
|
91
|
+
eventEmitter.emit(CONNECTOR_EVENTS.CONNECTED, { wallets, connectorId: id }, id);
|
|
92
|
+
} else {
|
|
93
|
+
eventEmitter.emit(CONNECTOR_EVENTS.DISCONNECTED, { connectorId: id }, id);
|
|
94
|
+
}
|
|
101
95
|
});
|
|
102
96
|
|
|
103
|
-
|
|
97
|
+
// Set default network and subscribe to changes
|
|
98
|
+
originalTonConnectUI.setConnectionNetwork(networkManager.getDefaultNetwork()?.chainId);
|
|
99
|
+
eventEmitter.on(NETWORKS_EVENTS.DEFAULT_CHANGED, ({ payload }) => {
|
|
100
|
+
if (originalTonConnectUI) {
|
|
101
|
+
originalTonConnectUI.setConnectionNetwork(payload.network?.chainId);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
return {
|
|
107
|
+
id,
|
|
108
|
+
type: 'tonconnect',
|
|
109
|
+
metadata: {
|
|
110
|
+
name: 'TonConnect',
|
|
111
|
+
iconUrl: 'https://avatars.githubusercontent.com/u/113980577',
|
|
112
|
+
...config.metadata,
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
get tonConnectUI() {
|
|
116
|
+
return getTonConnectUI();
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
getConnectedWallets,
|
|
120
|
+
|
|
121
|
+
async connectWallet(): Promise<void> {
|
|
122
|
+
const ui = getTonConnectUI();
|
|
123
|
+
|
|
124
|
+
if (ui) {
|
|
125
|
+
await ui.openModal();
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
async disconnectWallet(): Promise<void> {
|
|
130
|
+
const ui = getTonConnectUI();
|
|
131
|
+
|
|
132
|
+
if (ui) {
|
|
133
|
+
await ui.disconnect();
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
destroy() {
|
|
138
|
+
unsubscribeTonConnect?.();
|
|
139
|
+
originalTonConnectUI = null;
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
};
|
|
@@ -26,6 +26,9 @@ export { TonConnectWalletAdapter } from './adapters/ton-connect-wallet-adapter';
|
|
|
26
26
|
export type { TonConnectWalletAdapterConfig } from './adapters/ton-connect-wallet-adapter';
|
|
27
27
|
|
|
28
28
|
// Connector exports
|
|
29
|
-
export {
|
|
29
|
+
export {
|
|
30
|
+
createTonConnectConnector,
|
|
31
|
+
type TonConnectConnectorConfig,
|
|
32
|
+
type TonConnectConnector,
|
|
33
|
+
} from './connectors/ton-connect-connector';
|
|
30
34
|
export { TONCONNECT_DEFAULT_CONNECTOR_ID } from './constants/id';
|
|
31
|
-
export type { TonConnectConnectorConfig } from './connectors/ton-connect-connector';
|
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SwapManager } from '@ton/walletkit';
|
|
10
|
-
import type {
|
|
9
|
+
import { SwapManager, StreamingManager } from '@ton/walletkit';
|
|
10
|
+
import type { ProviderInput, SwapProviderInterface, StakingProviderInterface } from '@ton/walletkit';
|
|
11
11
|
|
|
12
|
-
import
|
|
13
|
-
import type { Connector } from '../../../types/connector';
|
|
14
|
-
import {
|
|
12
|
+
import { StakingManager } from '../../../staking';
|
|
13
|
+
import type { Connector, ConnectorFactoryContext, ConnectorInput } from '../../../types/connector';
|
|
14
|
+
import { EventEmitter } from '../../emitter';
|
|
15
15
|
import { CONNECTOR_EVENTS, WALLETS_EVENTS } from '../constants/events';
|
|
16
16
|
import type { AppKitEmitter, AppKitEvents } from '../types/events';
|
|
17
17
|
import type { WalletInterface } from '../../../types/wallet';
|
|
18
18
|
import { WalletsManager } from '../../wallets-manager';
|
|
19
19
|
import { AppKitNetworkManager } from '../../network';
|
|
20
20
|
import { Network } from '../../../types/network';
|
|
21
|
+
import type { AppKitConfig } from '../types/config';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Central hub for wallet management.
|
|
@@ -28,14 +29,16 @@ export class AppKit {
|
|
|
28
29
|
readonly connectors: Connector[] = [];
|
|
29
30
|
readonly walletsManager: WalletsManager;
|
|
30
31
|
readonly swapManager: SwapManager;
|
|
32
|
+
readonly stakingManager: StakingManager;
|
|
31
33
|
|
|
32
34
|
readonly networkManager: AppKitNetworkManager;
|
|
35
|
+
readonly streamingManager: StreamingManager;
|
|
33
36
|
readonly config: AppKitConfig;
|
|
34
37
|
|
|
35
38
|
constructor(config: AppKitConfig) {
|
|
36
39
|
this.config = config;
|
|
37
40
|
|
|
38
|
-
this.emitter = new
|
|
41
|
+
this.emitter = new EventEmitter<AppKitEvents>();
|
|
39
42
|
this.emitter.on(CONNECTOR_EVENTS.CONNECTED, this.updateWalletsFromConnectors.bind(this));
|
|
40
43
|
this.emitter.on(CONNECTOR_EVENTS.DISCONNECTED, this.updateWalletsFromConnectors.bind(this));
|
|
41
44
|
|
|
@@ -46,25 +49,33 @@ export class AppKit {
|
|
|
46
49
|
|
|
47
50
|
this.networkManager = new AppKitNetworkManager({ networks }, this.emitter);
|
|
48
51
|
this.walletsManager = new WalletsManager(this.emitter);
|
|
49
|
-
|
|
52
|
+
|
|
53
|
+
this.swapManager = new SwapManager(() => this.createFactoryContext());
|
|
54
|
+
this.stakingManager = new StakingManager(() => this.createFactoryContext());
|
|
55
|
+
this.streamingManager = new StreamingManager(() => this.createFactoryContext());
|
|
50
56
|
|
|
51
57
|
if (config.connectors) {
|
|
52
|
-
config.connectors.forEach((
|
|
53
|
-
this.addConnector(
|
|
58
|
+
config.connectors.forEach((input) => {
|
|
59
|
+
this.addConnector(input);
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
if (config.providers) {
|
|
58
|
-
config.providers.forEach((
|
|
59
|
-
this.registerProvider(
|
|
64
|
+
config.providers.forEach((input) => {
|
|
65
|
+
this.registerProvider(input);
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
createFactoryContext(): ConnectorFactoryContext {
|
|
71
|
+
return { eventEmitter: this.emitter, networkManager: this.networkManager, ssr: this.config?.ssr };
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
/**
|
|
65
75
|
* Add a wallet connector
|
|
66
76
|
*/
|
|
67
|
-
addConnector(
|
|
77
|
+
addConnector(input: ConnectorInput): () => void {
|
|
78
|
+
const connector = typeof input === 'function' ? input(this.createFactoryContext()) : input;
|
|
68
79
|
const id = connector.id;
|
|
69
80
|
const oldConnector = this.connectors.find((c) => c.id === id);
|
|
70
81
|
|
|
@@ -73,7 +84,6 @@ export class AppKit {
|
|
|
73
84
|
}
|
|
74
85
|
|
|
75
86
|
this.connectors.push(connector);
|
|
76
|
-
connector.initialize(this.emitter, this.networkManager);
|
|
77
87
|
|
|
78
88
|
return () => {
|
|
79
89
|
this.removeConnector(connector);
|
|
@@ -96,10 +106,14 @@ export class AppKit {
|
|
|
96
106
|
/**
|
|
97
107
|
* Add a provider
|
|
98
108
|
*/
|
|
99
|
-
registerProvider(
|
|
109
|
+
registerProvider(input: ProviderInput): void {
|
|
110
|
+
const provider = typeof input === 'function' ? input(this.createFactoryContext()) : input;
|
|
100
111
|
switch (provider.type) {
|
|
101
112
|
case 'swap':
|
|
102
|
-
this.swapManager.registerProvider(provider);
|
|
113
|
+
this.swapManager.registerProvider(provider as SwapProviderInterface);
|
|
114
|
+
break;
|
|
115
|
+
case 'staking':
|
|
116
|
+
this.stakingManager.registerProvider(provider as StakingProviderInterface);
|
|
103
117
|
break;
|
|
104
118
|
default:
|
|
105
119
|
throw new Error('Unknown provider type');
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { NetworkAdapters } from '@ton/walletkit';
|
|
9
|
+
import type { NetworkAdapters, ProviderInput } from '@ton/walletkit';
|
|
10
10
|
|
|
11
|
-
import type {
|
|
12
|
-
import type { Provider } from '../../../types/provider';
|
|
11
|
+
import type { ConnectorInput } from '../../../types/connector';
|
|
13
12
|
import type { Network } from '../../../types/network';
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -25,6 +24,11 @@ export interface AppKitConfig {
|
|
|
25
24
|
*/
|
|
26
25
|
networks?: NetworkAdapters;
|
|
27
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Wallet connectors
|
|
29
|
+
*/
|
|
30
|
+
connectors?: ConnectorInput[];
|
|
31
|
+
|
|
28
32
|
/**
|
|
29
33
|
* Default network for wallet connections.
|
|
30
34
|
* If set, connectors (e.g. TonConnect) will enforce this network when connecting.
|
|
@@ -32,6 +36,10 @@ export interface AppKitConfig {
|
|
|
32
36
|
*/
|
|
33
37
|
defaultNetwork?: Network;
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
providers?: ProviderInput[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Enable server-side rendering support
|
|
43
|
+
*/
|
|
44
|
+
ssr?: boolean;
|
|
37
45
|
}
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
import type { Emitter } from '../../emitter';
|
|
9
|
+
import type { SharedKitEvents } from '../../emitter';
|
|
11
10
|
import type { CONNECTOR_EVENTS, WALLETS_EVENTS, PLUGIN_EVENTS, NETWORKS_EVENTS } from '../constants/events';
|
|
11
|
+
import type { Network } from '../../../types/network';
|
|
12
|
+
import type { EventEmitter } from '../../emitter';
|
|
12
13
|
import type { WalletInterface } from '../../../types/wallet';
|
|
13
14
|
|
|
14
15
|
export interface WalletConnectedPayload {
|
|
@@ -29,7 +30,7 @@ export interface DefaultNetworkChangedPayload {
|
|
|
29
30
|
network: Network | undefined;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
export
|
|
33
|
+
export type AppKitEvents = {
|
|
33
34
|
// Connector events
|
|
34
35
|
[CONNECTOR_EVENTS.CONNECTED]: WalletConnectedPayload;
|
|
35
36
|
[CONNECTOR_EVENTS.DISCONNECTED]: WalletDisconnectedPayload;
|
|
@@ -44,6 +45,6 @@ export interface AppKitEvents {
|
|
|
44
45
|
|
|
45
46
|
// Plugin events
|
|
46
47
|
[PLUGIN_EVENTS.REGISTERED]: PluginRegisteredPayload;
|
|
47
|
-
}
|
|
48
|
+
} & SharedKitEvents;
|
|
48
49
|
|
|
49
|
-
export type AppKitEmitter =
|
|
50
|
+
export type AppKitEmitter = EventEmitter<AppKitEvents>;
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
* Events Feature
|
|
11
11
|
* Provides Emitter implementation
|
|
12
12
|
*/
|
|
13
|
-
export {
|
|
13
|
+
export { EventEmitter } from '@ton/walletkit';
|
|
14
14
|
|
|
15
|
-
export type { EventPayload,
|
|
15
|
+
export type { EventPayload, KitEvent, EventListener, SharedKitEvents } from '@ton/walletkit';
|
|
@@ -0,0 +1,30 @@
|
|
|
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 {
|
|
10
|
+
StreamingManager,
|
|
11
|
+
TonCenterStreamingProvider,
|
|
12
|
+
createTonCenterStreamingProvider,
|
|
13
|
+
TonApiStreamingProvider,
|
|
14
|
+
createTonApiStreamingProvider,
|
|
15
|
+
} from '@ton/walletkit';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
StreamingProvider,
|
|
19
|
+
StreamingProviderFactory,
|
|
20
|
+
StreamingAPI,
|
|
21
|
+
TonCenterStreamingProviderConfig,
|
|
22
|
+
TonApiStreamingProviderConfig,
|
|
23
|
+
BalanceUpdate,
|
|
24
|
+
TransactionsUpdate,
|
|
25
|
+
Transaction,
|
|
26
|
+
JettonUpdate,
|
|
27
|
+
StreamingUpdate,
|
|
28
|
+
StreamingWatchType,
|
|
29
|
+
StreamingEvents,
|
|
30
|
+
} from '@ton/walletkit';
|
package/src/index.ts
CHANGED
|
@@ -29,9 +29,11 @@
|
|
|
29
29
|
export * from './core/app-kit';
|
|
30
30
|
export * from './core/emitter';
|
|
31
31
|
export * from './core/network';
|
|
32
|
+
export * from './core/streaming';
|
|
32
33
|
export * from './connectors/tonconnect';
|
|
33
34
|
|
|
34
35
|
export * from './swap';
|
|
36
|
+
export * from './staking';
|
|
35
37
|
|
|
36
38
|
// Actions
|
|
37
39
|
export * from './actions';
|
|
@@ -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 { getBalanceByAddress } from '../../actions/balances/get-balance-by-address';
|
|
11
13
|
import type { GetBalanceByAddressOptions } from '../../actions/balances/get-balance-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, sleep } from '../../utils';
|
|
15
17
|
import type { GetBalanceByAddressReturnType } from '../../actions/balances/get-balance-by-address';
|
|
18
|
+
import type { BalanceUpdate } from '../../core/streaming';
|
|
19
|
+
import type { Network } from '../../types/network';
|
|
16
20
|
|
|
17
21
|
export type GetBalanceErrorType = Error;
|
|
18
22
|
|
|
@@ -25,8 +29,11 @@ export type GetBalanceByAddressQueryConfig<selectData = GetBalanceByAddressData>
|
|
|
25
29
|
|
|
26
30
|
export const getBalanceByAddressQueryOptions = <selectData = GetBalanceByAddressData>(
|
|
27
31
|
appKit: AppKit,
|
|
28
|
-
|
|
32
|
+
initialOptions: GetBalanceByAddressQueryConfig<selectData> = {},
|
|
29
33
|
): GetBalanceByAddressQueryOptions<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)),
|
|
@@ -56,3 +63,23 @@ export type GetBalanceByAddressQueryOptions<selectData = GetBalanceByAddressData
|
|
|
56
63
|
selectData,
|
|
57
64
|
GetBalanceByAddressQueryKey
|
|
58
65
|
>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Update the TanStack Query cache for an address balance.
|
|
69
|
+
*/
|
|
70
|
+
export const handleBalanceUpdate = (
|
|
71
|
+
queryClient: QueryClient,
|
|
72
|
+
{ address, network }: { address: string; network: Network },
|
|
73
|
+
update: BalanceUpdate,
|
|
74
|
+
) => {
|
|
75
|
+
if (update.status === 'finalized') {
|
|
76
|
+
const queryKey = getBalanceByAddressQueryKey({ address, network });
|
|
77
|
+
queryClient.setQueryData(queryKey, update.balance);
|
|
78
|
+
sleep(5000).then(() => queryClient.invalidateQueries({ queryKey }));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (update.status === 'invalidated') {
|
|
82
|
+
const queryKey = getBalanceByAddressQueryKey({ address, network });
|
|
83
|
+
queryClient.invalidateQueries({ queryKey });
|
|
84
|
+
}
|
|
85
|
+
};
|
package/src/queries/index.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// Balances
|
|
10
10
|
export {
|
|
11
11
|
getBalanceByAddressQueryOptions,
|
|
12
|
+
handleBalanceUpdate,
|
|
12
13
|
type GetBalanceByAddressData,
|
|
13
14
|
type GetBalanceErrorType,
|
|
14
15
|
type GetBalanceByAddressQueryConfig,
|
|
@@ -51,12 +52,14 @@ export {
|
|
|
51
52
|
} from './jettons/get-jetton-wallet-address';
|
|
52
53
|
export {
|
|
53
54
|
getJettonBalanceByAddressQueryOptions,
|
|
55
|
+
handleJettonBalanceUpdate,
|
|
54
56
|
type GetJettonBalanceByAddressQueryConfig,
|
|
55
57
|
type GetJettonBalanceByAddressData,
|
|
56
58
|
type GetJettonBalanceErrorType,
|
|
57
59
|
} from './jettons/get-jetton-balance-by-address';
|
|
58
60
|
export {
|
|
59
61
|
getJettonsByAddressQueryOptions,
|
|
62
|
+
handleJettonsUpdate,
|
|
60
63
|
type GetJettonsByAddressData,
|
|
61
64
|
type GetJettonsErrorType,
|
|
62
65
|
type GetJettonsByAddressQueryConfig,
|
|
@@ -162,6 +165,42 @@ export {
|
|
|
162
165
|
type BuildSwapTransactionVariables,
|
|
163
166
|
} from './swap/build-swap-transaction';
|
|
164
167
|
|
|
168
|
+
// Staking
|
|
169
|
+
export {
|
|
170
|
+
getStakingProvidersQueryOptions,
|
|
171
|
+
type GetStakingProvidersData,
|
|
172
|
+
type GetStakingProvidersErrorType,
|
|
173
|
+
type GetStakingProvidersQueryConfig,
|
|
174
|
+
} from './staking/get-staking-providers';
|
|
175
|
+
export {
|
|
176
|
+
getStakingQuoteQueryOptions,
|
|
177
|
+
type GetStakingQuoteQueryConfig,
|
|
178
|
+
type GetStakingQuoteQueryOptions,
|
|
179
|
+
type GetStakingQuoteData,
|
|
180
|
+
type GetStakingQuoteErrorType,
|
|
181
|
+
type GetStakingQuoteQueryFnData,
|
|
182
|
+
type GetStakingQuoteQueryKey,
|
|
183
|
+
} from './staking/get-staking-quote';
|
|
184
|
+
export {
|
|
185
|
+
getStakedBalanceQueryOptions,
|
|
186
|
+
type GetStakedBalanceQueryConfig,
|
|
187
|
+
type GetStakedBalanceData,
|
|
188
|
+
type GetStakedBalanceErrorType,
|
|
189
|
+
} from './staking/get-staked-balance';
|
|
190
|
+
export {
|
|
191
|
+
getStakingProviderInfoQueryOptions,
|
|
192
|
+
type GetStakingProviderInfoQueryConfig,
|
|
193
|
+
type GetStakingProviderInfoData,
|
|
194
|
+
type GetStakingProviderInfoErrorType,
|
|
195
|
+
} from './staking/get-staking-provider-info';
|
|
196
|
+
export {
|
|
197
|
+
buildStakeTransactionMutationOptions,
|
|
198
|
+
type BuildStakeTransactionData,
|
|
199
|
+
type BuildStakeTransactionErrorType,
|
|
200
|
+
type BuildStakeTransactionMutationOptions,
|
|
201
|
+
type BuildStakeTransactionVariables,
|
|
202
|
+
} from './staking/build-stake-transaction';
|
|
203
|
+
|
|
165
204
|
// Transaction
|
|
166
205
|
export {
|
|
167
206
|
transferTonMutationOptions,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import type { QueryClient } from '@tanstack/query-core';
|
|
9
10
|
import type { TokenAmount } from '@ton/walletkit';
|
|
10
11
|
|
|
11
12
|
import type { AppKit } from '../../core/app-kit';
|
|
@@ -13,7 +14,9 @@ import { getJettonBalance } from '../../actions/jettons/get-jetton-balance';
|
|
|
13
14
|
import type { GetJettonBalanceOptions as GetJettonBalanceParameters } from '../../actions/jettons/get-jetton-balance';
|
|
14
15
|
import type { QueryOptions, QueryParameter } from '../../types/query';
|
|
15
16
|
import type { Compute, ExactPartial } from '../../types/utils';
|
|
16
|
-
import { filterQueryOptions } from '../../utils';
|
|
17
|
+
import { filterQueryOptions, resolveNetwork, sleep } from '../../utils';
|
|
18
|
+
import type { JettonUpdate } from '../../core/streaming';
|
|
19
|
+
import type { Network } from '../../types/network';
|
|
17
20
|
|
|
18
21
|
export type GetJettonBalanceErrorType = Error;
|
|
19
22
|
|
|
@@ -31,8 +34,11 @@ export type GetJettonBalanceByAddressQueryConfig<selectData = GetJettonBalanceBy
|
|
|
31
34
|
|
|
32
35
|
export const getJettonBalanceByAddressQueryOptions = <selectData = GetJettonBalanceByAddressData>(
|
|
33
36
|
appKit: AppKit,
|
|
34
|
-
|
|
37
|
+
initialOptions: GetJettonBalanceByAddressQueryConfig<selectData> = {},
|
|
35
38
|
): GetJettonBalanceByAddressQueryOptions<selectData> => {
|
|
39
|
+
const network = resolveNetwork(appKit, initialOptions.network);
|
|
40
|
+
const options = { ...initialOptions, network };
|
|
41
|
+
|
|
36
42
|
return {
|
|
37
43
|
...options.query,
|
|
38
44
|
enabled: Boolean(options.jettonAddress && options.ownerAddress && (options.query?.enabled ?? true)),
|
|
@@ -67,3 +73,31 @@ export type GetJettonBalanceByAddressQueryOptions<selectData = GetJettonBalanceB
|
|
|
67
73
|
selectData,
|
|
68
74
|
GetJettonBalanceByAddressQueryKey
|
|
69
75
|
>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Update the TanStack Query cache for an owner jetton balance.
|
|
79
|
+
*/
|
|
80
|
+
export const handleJettonBalanceUpdate = (
|
|
81
|
+
queryClient: QueryClient,
|
|
82
|
+
{ ownerAddress, jettonAddress, network }: { ownerAddress: string; jettonAddress: string; network: Network },
|
|
83
|
+
update: JettonUpdate,
|
|
84
|
+
) => {
|
|
85
|
+
if (update.status === 'finalized') {
|
|
86
|
+
const queryKey = getJettonBalanceByAddressQueryKey({
|
|
87
|
+
ownerAddress,
|
|
88
|
+
jettonAddress,
|
|
89
|
+
network,
|
|
90
|
+
});
|
|
91
|
+
queryClient.setQueryData(queryKey, update.balance);
|
|
92
|
+
sleep(5000).then(() => queryClient.invalidateQueries({ queryKey }));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (update.status === 'invalidated') {
|
|
96
|
+
const queryKey = getJettonBalanceByAddressQueryKey({
|
|
97
|
+
ownerAddress,
|
|
98
|
+
jettonAddress,
|
|
99
|
+
network,
|
|
100
|
+
});
|
|
101
|
+
queryClient.invalidateQueries({ queryKey });
|
|
102
|
+
}
|
|
103
|
+
};
|
|
@@ -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 } from '../../utils';
|
|
15
|
+
import { filterQueryOptions, resolveNetwork } from '../../utils';
|
|
16
16
|
|
|
17
17
|
export type GetJettonInfoErrorType = Error;
|
|
18
18
|
|
|
@@ -21,8 +21,11 @@ export type GetJettonInfoQueryConfig<selectData = GetJettonInfoData> = Compute<E
|
|
|
21
21
|
|
|
22
22
|
export const getJettonInfoQueryOptions = <selectData = GetJettonInfoData>(
|
|
23
23
|
appKit: AppKit,
|
|
24
|
-
|
|
24
|
+
initialOptions: GetJettonInfoQueryConfig<selectData> = {},
|
|
25
25
|
): GetJettonInfoQueryOptions<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.address && (options.query?.enabled ?? true)),
|