@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
package/src/actions/index.ts
CHANGED
|
@@ -12,7 +12,13 @@ export {
|
|
|
12
12
|
type GetBalanceByAddressOptions,
|
|
13
13
|
type GetBalanceByAddressReturnType,
|
|
14
14
|
} from './balances/get-balance-by-address';
|
|
15
|
+
export {
|
|
16
|
+
watchBalanceByAddress,
|
|
17
|
+
type WatchBalanceByAddressOptions,
|
|
18
|
+
type WatchBalanceByAddressReturnType,
|
|
19
|
+
} from './balances/watch-balance-by-address';
|
|
15
20
|
export { getBalance, type GetBalanceOptions, type GetBalanceReturnType } from './balances/get-balance';
|
|
21
|
+
export { watchBalance, type WatchBalanceOptions, type WatchBalanceReturnType } from './balances/watch-balance';
|
|
16
22
|
|
|
17
23
|
// Connectors
|
|
18
24
|
export { addConnector, type AddConnectorParameters, type AddConnectorReturnType } from './connectors/add-connector';
|
|
@@ -52,7 +58,13 @@ export {
|
|
|
52
58
|
type GetJettonsByAddressOptions,
|
|
53
59
|
type GetJettonsByAddressReturnType,
|
|
54
60
|
} from './jettons/get-jettons-by-address';
|
|
61
|
+
export {
|
|
62
|
+
watchJettonsByAddress,
|
|
63
|
+
type WatchJettonsByAddressOptions,
|
|
64
|
+
type WatchJettonsByAddressReturnType,
|
|
65
|
+
} from './jettons/watch-jettons-by-address';
|
|
55
66
|
export { getJettons, type GetJettonsOptions, type GetJettonsReturnType } from './jettons/get-jettons';
|
|
67
|
+
export { watchJettons, type WatchJettonsOptions, type WatchJettonsReturnType } from './jettons/watch-jettons';
|
|
56
68
|
export {
|
|
57
69
|
createTransferJettonTransaction,
|
|
58
70
|
type CreateTransferJettonTransactionParameters,
|
|
@@ -67,6 +79,7 @@ export {
|
|
|
67
79
|
// Network
|
|
68
80
|
export { getNetworks, type GetNetworksReturnType } from './network/get-networks';
|
|
69
81
|
export { getNetwork, type GetNetworkReturnType } from './network/get-network';
|
|
82
|
+
export { getApiClient, type GetApiClientOptions, type GetApiClientReturnType } from './network/get-api-client';
|
|
70
83
|
export { watchNetworks, type WatchNetworksParameters, type WatchNetworksReturnType } from './network/watch-networks';
|
|
71
84
|
export { getBlockNumber, type GetBlockNumberOptions, type GetBlockNumberReturnType } from './network/get-block-number';
|
|
72
85
|
export { getDefaultNetwork, type GetDefaultNetworkReturnType } from './network/get-default-network';
|
|
@@ -80,6 +93,7 @@ export {
|
|
|
80
93
|
type WatchDefaultNetworkParameters,
|
|
81
94
|
type WatchDefaultNetworkReturnType,
|
|
82
95
|
} from './network/watch-default-network';
|
|
96
|
+
export { hasStreamingProvider, type HasStreamingProviderReturnType } from './network/has-streaming-provider';
|
|
83
97
|
|
|
84
98
|
// NFT
|
|
85
99
|
export {
|
|
@@ -108,6 +122,30 @@ export {
|
|
|
108
122
|
type BuildSwapTransactionReturnType,
|
|
109
123
|
} from './swap/build-swap-transaction';
|
|
110
124
|
|
|
125
|
+
// Staking
|
|
126
|
+
export { getStakingManager, type GetStakingManagerReturnType } from './staking/get-staking-manager';
|
|
127
|
+
export { getStakingProviders, type GetStakingProvidersReturnType } from './staking/get-staking-providers';
|
|
128
|
+
export {
|
|
129
|
+
getStakingQuote,
|
|
130
|
+
type GetStakingQuoteOptions,
|
|
131
|
+
type GetStakingQuoteReturnType,
|
|
132
|
+
} from './staking/get-staking-quote';
|
|
133
|
+
export {
|
|
134
|
+
buildStakeTransaction,
|
|
135
|
+
type BuildStakeTransactionOptions,
|
|
136
|
+
type BuildStakeTransactionReturnType,
|
|
137
|
+
} from './staking/build-stake-transaction';
|
|
138
|
+
export {
|
|
139
|
+
getStakedBalance,
|
|
140
|
+
type GetStakedBalanceOptions,
|
|
141
|
+
type GetStakedBalanceReturnType,
|
|
142
|
+
} from './staking/get-staked-balance';
|
|
143
|
+
export {
|
|
144
|
+
getStakingProviderInfo,
|
|
145
|
+
type GetStakingProviderInfoOptions,
|
|
146
|
+
type GetStakingProviderInfoReturnType,
|
|
147
|
+
} from './staking/get-staking-provider-info';
|
|
148
|
+
|
|
111
149
|
// Transactions
|
|
112
150
|
export {
|
|
113
151
|
sendTransaction,
|
|
@@ -121,6 +159,16 @@ export {
|
|
|
121
159
|
type GetTransactionStatusReturnType,
|
|
122
160
|
type GetTransactionStatusErrorType,
|
|
123
161
|
} from './transaction/get-transaction-status';
|
|
162
|
+
export {
|
|
163
|
+
watchTransactionsByAddress,
|
|
164
|
+
type WatchTransactionsByAddressOptions,
|
|
165
|
+
type WatchTransactionsByAddressReturnType,
|
|
166
|
+
} from './transaction/watch-transactions-by-address';
|
|
167
|
+
export {
|
|
168
|
+
watchTransactions,
|
|
169
|
+
type WatchTransactionsOptions,
|
|
170
|
+
type WatchTransactionsReturnType,
|
|
171
|
+
} from './transaction/watch-transactions';
|
|
124
172
|
export {
|
|
125
173
|
createTransferNftTransaction,
|
|
126
174
|
type CreateTransferNftTransactionParameters,
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { Address } from '@ton/core';
|
|
10
|
+
import type { JettonUpdate, Network } from '@ton/walletkit';
|
|
11
|
+
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
import { resolveNetwork } from '../../utils/network/resolve-network';
|
|
14
|
+
|
|
15
|
+
export interface WatchJettonsByAddressOptions {
|
|
16
|
+
address: string | Address;
|
|
17
|
+
onChange: (update: JettonUpdate) => void;
|
|
18
|
+
network?: Network;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type WatchJettonsByAddressReturnType = () => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Watch jetton updates by owner address.
|
|
25
|
+
*/
|
|
26
|
+
export const watchJettonsByAddress = (
|
|
27
|
+
appKit: AppKit,
|
|
28
|
+
options: WatchJettonsByAddressOptions,
|
|
29
|
+
): WatchJettonsByAddressReturnType => {
|
|
30
|
+
const { address, network, onChange } = options;
|
|
31
|
+
const addressString = Address.isAddress(address) ? address.toString() : Address.parse(address).toString();
|
|
32
|
+
const resolvedNetwork = resolveNetwork(appKit, network);
|
|
33
|
+
|
|
34
|
+
return appKit.streamingManager.watchJettons(resolvedNetwork, addressString, onChange);
|
|
35
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { JettonUpdate, Network } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
import { WALLETS_EVENTS } from '../../core/app-kit';
|
|
13
|
+
import { getSelectedWallet } from '../wallets/get-selected-wallet';
|
|
14
|
+
import { watchJettonsByAddress } from './watch-jettons-by-address';
|
|
15
|
+
|
|
16
|
+
export interface WatchJettonsOptions {
|
|
17
|
+
onChange: (update: JettonUpdate) => void;
|
|
18
|
+
network?: Network;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type WatchJettonsReturnType = () => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Watch jetton updates for the selected wallet.
|
|
25
|
+
*/
|
|
26
|
+
export const watchJettons = (appKit: AppKit, options: WatchJettonsOptions): WatchJettonsReturnType => {
|
|
27
|
+
const { network, onChange } = options;
|
|
28
|
+
let unsubscribe: (() => void) | null = null;
|
|
29
|
+
|
|
30
|
+
const updateSubscription = () => {
|
|
31
|
+
if (unsubscribe) {
|
|
32
|
+
unsubscribe();
|
|
33
|
+
unsubscribe = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const selectedWallet = getSelectedWallet(appKit);
|
|
37
|
+
if (selectedWallet) {
|
|
38
|
+
unsubscribe = watchJettonsByAddress(appKit, {
|
|
39
|
+
address: selectedWallet.getAddress(),
|
|
40
|
+
network: network ?? selectedWallet.getNetwork(),
|
|
41
|
+
onChange,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const offSelection = appKit.emitter.on(WALLETS_EVENTS.SELECTION_CHANGED, updateSubscription);
|
|
47
|
+
const offUpdate = appKit.emitter.on(WALLETS_EVENTS.UPDATED, updateSubscription);
|
|
48
|
+
|
|
49
|
+
updateSubscription();
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
if (unsubscribe) unsubscribe();
|
|
53
|
+
offSelection();
|
|
54
|
+
offUpdate();
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { Network } from '../../types/network';
|
|
10
|
+
import type { AppKit } from '../../core/app-kit';
|
|
11
|
+
import type { ApiClient } from '../../core/network';
|
|
12
|
+
|
|
13
|
+
export type GetApiClientReturnType = ApiClient;
|
|
14
|
+
|
|
15
|
+
export type GetApiClientOptions = { network: Network };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get API client for a network
|
|
19
|
+
*/
|
|
20
|
+
export const getApiClient = (appKit: AppKit, options: GetApiClientOptions): GetApiClientReturnType => {
|
|
21
|
+
return appKit.networkManager.getClient(options.network);
|
|
22
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AppKit } from '../../core/app-kit/services/app-kit';
|
|
10
|
+
import type { Network } from '../../types/network';
|
|
11
|
+
|
|
12
|
+
export type HasStreamingProviderReturnType = boolean;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Check if a streaming provider is registered for a specific network.
|
|
16
|
+
*/
|
|
17
|
+
export const hasStreamingProvider = (appKit: AppKit, network: Network): HasStreamingProviderReturnType => {
|
|
18
|
+
return appKit.streamingManager.hasProvider(network);
|
|
19
|
+
};
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { ProviderInput } from '@ton/walletkit';
|
|
10
|
+
|
|
10
11
|
import type { AppKit } from '../../core/app-kit';
|
|
11
12
|
|
|
12
|
-
export type RegisterProviderOptions =
|
|
13
|
+
export type RegisterProviderOptions = ProviderInput;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Register provider
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { StakeParams } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import type { TransactionRequest } from '../../types/transaction';
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
|
|
14
|
+
export type BuildStakeTransactionOptions = StakeParams & {
|
|
15
|
+
providerId?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type BuildStakeTransactionReturnType = Promise<TransactionRequest>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Build stake transaction
|
|
22
|
+
*/
|
|
23
|
+
export const buildStakeTransaction = async (
|
|
24
|
+
appKit: AppKit,
|
|
25
|
+
options: BuildStakeTransactionOptions,
|
|
26
|
+
): BuildStakeTransactionReturnType => {
|
|
27
|
+
return appKit.stakingManager.buildStakeTransaction(options, options.providerId);
|
|
28
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { StakingBalance, UserFriendlyAddress, Network } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
import { resolveNetwork } from '../../utils';
|
|
13
|
+
|
|
14
|
+
export type GetStakedBalanceOptions = {
|
|
15
|
+
userAddress: UserFriendlyAddress;
|
|
16
|
+
network?: Network;
|
|
17
|
+
providerId?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type GetStakedBalanceReturnType = Promise<StakingBalance>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get staked balance
|
|
24
|
+
*/
|
|
25
|
+
export const getStakedBalance = async (
|
|
26
|
+
appKit: AppKit,
|
|
27
|
+
options: GetStakedBalanceOptions,
|
|
28
|
+
): GetStakedBalanceReturnType => {
|
|
29
|
+
return appKit.stakingManager.getStakedBalance(
|
|
30
|
+
options.userAddress,
|
|
31
|
+
resolveNetwork(appKit, options.network),
|
|
32
|
+
options.providerId,
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { StakingManager } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
|
|
13
|
+
export type GetStakingManagerReturnType = StakingManager;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get staking manager instance
|
|
17
|
+
*/
|
|
18
|
+
export const getStakingManager = (appKit: AppKit): GetStakingManagerReturnType => {
|
|
19
|
+
return appKit.stakingManager;
|
|
20
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { StakingProviderInfo, Network } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import { resolveNetwork } from '../../utils';
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
|
|
14
|
+
export type GetStakingProviderInfoOptions = {
|
|
15
|
+
network?: Network;
|
|
16
|
+
providerId?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type GetStakingProviderInfoReturnType = Promise<StakingProviderInfo>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get staking provider info
|
|
23
|
+
*/
|
|
24
|
+
export const getStakingProviderInfo = async (
|
|
25
|
+
appKit: AppKit,
|
|
26
|
+
options: GetStakingProviderInfoOptions = {},
|
|
27
|
+
): GetStakingProviderInfoReturnType => {
|
|
28
|
+
return appKit.stakingManager.getStakingProviderInfo(resolveNetwork(appKit, options.network), options.providerId);
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AppKit } from '../../core/app-kit';
|
|
10
|
+
|
|
11
|
+
export type GetStakingProvidersReturnType = string[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get available staking provider IDs
|
|
15
|
+
*/
|
|
16
|
+
export const getStakingProviders = (appKit: AppKit): GetStakingProvidersReturnType => {
|
|
17
|
+
return appKit.stakingManager.getRegisteredProviders();
|
|
18
|
+
};
|
|
@@ -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
|
+
import type { StakingQuote, StakingQuoteParams } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
import { resolveNetwork } from '../../utils';
|
|
13
|
+
|
|
14
|
+
export type GetStakingQuoteOptions = StakingQuoteParams & {
|
|
15
|
+
providerId?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type GetStakingQuoteReturnType = Promise<StakingQuote>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get staking quote
|
|
22
|
+
*/
|
|
23
|
+
export const getStakingQuote = async (appKit: AppKit, options: GetStakingQuoteOptions): GetStakingQuoteReturnType => {
|
|
24
|
+
const optionsWithNetwork = {
|
|
25
|
+
...options,
|
|
26
|
+
network: resolveNetwork(appKit, options.network),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return appKit.stakingManager.getQuote(optionsWithNetwork, options.providerId);
|
|
30
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { Address } from '@ton/core';
|
|
10
|
+
import type { TransactionsUpdate, Network } from '@ton/walletkit';
|
|
11
|
+
|
|
12
|
+
import type { AppKit } from '../../core/app-kit';
|
|
13
|
+
import { resolveNetwork } from '../../utils/network/resolve-network';
|
|
14
|
+
|
|
15
|
+
export interface WatchTransactionsByAddressOptions {
|
|
16
|
+
address: string | Address;
|
|
17
|
+
onChange: (update: TransactionsUpdate) => void;
|
|
18
|
+
network?: Network;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type WatchTransactionsByAddressReturnType = () => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Watch transactions by address.
|
|
25
|
+
*/
|
|
26
|
+
export const watchTransactionsByAddress = (
|
|
27
|
+
appKit: AppKit,
|
|
28
|
+
options: WatchTransactionsByAddressOptions,
|
|
29
|
+
): WatchTransactionsByAddressReturnType => {
|
|
30
|
+
const { address, network, onChange } = options;
|
|
31
|
+
const addressString = Address.isAddress(address) ? address.toString() : Address.parse(address).toString();
|
|
32
|
+
const resolvedNetwork = resolveNetwork(appKit, network);
|
|
33
|
+
|
|
34
|
+
return appKit.streamingManager.watchTransactions(resolvedNetwork, addressString, onChange);
|
|
35
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { TransactionsUpdate, Network } from '@ton/walletkit';
|
|
10
|
+
|
|
11
|
+
import type { AppKit } from '../../core/app-kit';
|
|
12
|
+
import { WALLETS_EVENTS } from '../../core/app-kit';
|
|
13
|
+
import { getSelectedWallet } from '../wallets/get-selected-wallet';
|
|
14
|
+
import { watchTransactionsByAddress } from './watch-transactions-by-address';
|
|
15
|
+
|
|
16
|
+
export interface WatchTransactionsOptions {
|
|
17
|
+
onChange: (update: TransactionsUpdate) => void;
|
|
18
|
+
network?: Network;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type WatchTransactionsReturnType = () => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Watch transactions for the selected wallet.
|
|
25
|
+
*/
|
|
26
|
+
export const watchTransactions = (appKit: AppKit, options: WatchTransactionsOptions): WatchTransactionsReturnType => {
|
|
27
|
+
const { network, onChange } = options;
|
|
28
|
+
let unsubscribe: (() => void) | null = null;
|
|
29
|
+
|
|
30
|
+
const updateSubscription = () => {
|
|
31
|
+
if (unsubscribe) {
|
|
32
|
+
unsubscribe();
|
|
33
|
+
unsubscribe = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const selectedWallet = getSelectedWallet(appKit);
|
|
37
|
+
if (selectedWallet) {
|
|
38
|
+
unsubscribe = watchTransactionsByAddress(appKit, {
|
|
39
|
+
address: selectedWallet.getAddress(),
|
|
40
|
+
network: network ?? selectedWallet.getNetwork(),
|
|
41
|
+
onChange,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const offSelection = appKit.emitter.on(WALLETS_EVENTS.SELECTION_CHANGED, updateSubscription);
|
|
47
|
+
const offUpdate = appKit.emitter.on(WALLETS_EVENTS.UPDATED, updateSubscription);
|
|
48
|
+
|
|
49
|
+
updateSubscription();
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
if (unsubscribe) unsubscribe();
|
|
53
|
+
offSelection();
|
|
54
|
+
offUpdate();
|
|
55
|
+
};
|
|
56
|
+
};
|