@ton/appkit-react 0.0.6-alpha.1 → 0.0.6-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/README.md +65 -2
- package/dist/esm/features/balances/components/send-jetton-button/send-jetton-button.js +2 -2
- package/dist/esm/features/balances/components/send-jetton-button/send-jetton-button.js.map +1 -1
- package/dist/esm/features/balances/components/send-ton-button/send-ton-button.js +2 -2
- package/dist/esm/features/balances/components/send-ton-button/send-ton-button.js.map +1 -1
- package/dist/esm/features/balances/hooks/use-watch-balance-by-address.js +43 -0
- package/dist/esm/features/balances/hooks/use-watch-balance-by-address.js.map +1 -0
- package/dist/esm/features/balances/hooks/use-watch-balance.js +20 -0
- package/dist/esm/features/balances/hooks/use-watch-balance.js.map +1 -0
- package/dist/esm/features/balances/index.js +2 -0
- package/dist/esm/features/balances/index.js.map +1 -1
- package/dist/esm/features/jettons/hooks/use-watch-jettons-by-address.js +49 -0
- package/dist/esm/features/jettons/hooks/use-watch-jettons-by-address.js.map +1 -0
- package/dist/esm/features/jettons/hooks/use-watch-jettons.js +20 -0
- package/dist/esm/features/jettons/hooks/use-watch-jettons.js.map +1 -0
- package/dist/esm/features/jettons/index.js +2 -0
- package/dist/esm/features/jettons/index.js.map +1 -1
- package/dist/esm/features/staking/hooks/use-build-stake-transaction.js +18 -0
- package/dist/esm/features/staking/hooks/use-build-stake-transaction.js.map +1 -0
- package/dist/esm/features/staking/hooks/use-staked-balance.js +18 -0
- package/dist/esm/features/staking/hooks/use-staked-balance.js.map +1 -0
- package/dist/esm/features/staking/hooks/use-staking-provider-info.js +18 -0
- package/dist/esm/features/staking/hooks/use-staking-provider-info.js.map +1 -0
- package/dist/esm/features/staking/hooks/use-staking-providers.js +18 -0
- package/dist/esm/features/staking/hooks/use-staking-providers.js.map +1 -0
- package/dist/esm/features/staking/hooks/use-staking-quote.js +18 -0
- package/dist/esm/features/staking/hooks/use-staking-quote.js.map +1 -0
- package/dist/esm/features/staking/index.js +14 -0
- package/dist/esm/features/staking/index.js.map +1 -0
- package/dist/esm/features/transaction/components/transaction/index.js +1 -1
- package/dist/esm/features/transaction/components/transaction/index.js.map +1 -1
- package/dist/esm/features/transaction/components/transaction/{transaction.js → send.js} +6 -6
- package/dist/esm/features/transaction/components/transaction/send.js.map +1 -0
- package/dist/esm/features/transaction/components/transaction-provider/index.js +1 -1
- package/dist/esm/features/transaction/components/transaction-provider/index.js.map +1 -1
- package/dist/esm/features/transaction/components/transaction-provider/{transaction-provider.js → send-provider.js} +6 -6
- package/dist/esm/features/transaction/components/transaction-provider/send-provider.js.map +1 -0
- package/dist/esm/features/transaction/hooks/use-watch-transactions-by-address.js +43 -0
- package/dist/esm/features/transaction/hooks/use-watch-transactions-by-address.js.map +1 -0
- package/dist/esm/features/transaction/hooks/use-watch-transactions.js +19 -0
- package/dist/esm/features/transaction/hooks/use-watch-transactions.js.map +1 -0
- package/dist/esm/features/transaction/index.js +2 -0
- package/dist/esm/features/transaction/index.js.map +1 -1
- package/dist/esm/features/wallets/hooks/use-connected-wallets.js +1 -1
- package/dist/esm/features/wallets/hooks/use-connected-wallets.js.map +1 -1
- package/dist/esm/features/wallets/hooks/use-connector-by-id.js +1 -1
- package/dist/esm/features/wallets/hooks/use-connector-by-id.js.map +1 -1
- package/dist/esm/features/wallets/hooks/use-connectors.js +1 -1
- package/dist/esm/features/wallets/hooks/use-connectors.js.map +1 -1
- package/dist/esm/features/wallets/hooks/use-selected-wallet.js +1 -1
- package/dist/esm/features/wallets/hooks/use-selected-wallet.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tonconnect/tonconnect-bridge.js +3 -3
- package/dist/esm/tonconnect/tonconnect-bridge.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/features/balances/components/send-jetton-button/send-jetton-button.d.ts +2 -2
- package/dist/types/features/balances/components/send-jetton-button/send-jetton-button.d.ts.map +1 -1
- package/dist/types/features/balances/components/send-ton-button/send-ton-button.d.ts +2 -2
- package/dist/types/features/balances/components/send-ton-button/send-ton-button.d.ts.map +1 -1
- package/dist/types/features/balances/hooks/use-watch-balance-by-address.d.ts +15 -0
- package/dist/types/features/balances/hooks/use-watch-balance-by-address.d.ts.map +1 -0
- package/dist/types/features/balances/hooks/use-watch-balance.d.ts +15 -0
- package/dist/types/features/balances/hooks/use-watch-balance.d.ts.map +1 -0
- package/dist/types/features/balances/index.d.ts +2 -0
- package/dist/types/features/balances/index.d.ts.map +1 -1
- package/dist/types/features/jettons/hooks/use-watch-jettons-by-address.d.ts +15 -0
- package/dist/types/features/jettons/hooks/use-watch-jettons-by-address.d.ts.map +1 -0
- package/dist/types/features/jettons/hooks/use-watch-jettons.d.ts +15 -0
- package/dist/types/features/jettons/hooks/use-watch-jettons.d.ts.map +1 -0
- package/dist/types/features/jettons/index.d.ts +2 -0
- package/dist/types/features/jettons/index.d.ts.map +1 -1
- package/dist/types/features/staking/hooks/use-build-stake-transaction.d.ts +15 -0
- package/dist/types/features/staking/hooks/use-build-stake-transaction.d.ts.map +1 -0
- package/dist/types/features/staking/hooks/use-staked-balance.d.ts +16 -0
- package/dist/types/features/staking/hooks/use-staked-balance.d.ts.map +1 -0
- package/dist/types/features/staking/hooks/use-staking-provider-info.d.ts +16 -0
- package/dist/types/features/staking/hooks/use-staking-provider-info.d.ts.map +1 -0
- package/dist/types/features/staking/hooks/use-staking-providers.d.ts +16 -0
- package/dist/types/features/staking/hooks/use-staking-providers.d.ts.map +1 -0
- package/dist/types/features/staking/hooks/use-staking-quote.d.ts +16 -0
- package/dist/types/features/staking/hooks/use-staking-quote.d.ts.map +1 -0
- package/dist/types/features/staking/index.d.ts +14 -0
- package/dist/types/features/staking/index.d.ts.map +1 -0
- package/dist/types/features/transaction/components/transaction/index.d.ts +2 -2
- package/dist/types/features/transaction/components/transaction/index.d.ts.map +1 -1
- package/dist/types/features/transaction/components/transaction/{transaction.d.ts → send.d.ts} +7 -7
- package/dist/types/features/transaction/components/transaction/send.d.ts.map +1 -0
- package/dist/types/features/transaction/components/transaction-provider/index.d.ts +2 -2
- package/dist/types/features/transaction/components/transaction-provider/index.d.ts.map +1 -1
- package/dist/types/features/transaction/components/transaction-provider/{transaction-provider.d.ts → send-provider.d.ts} +8 -8
- package/dist/types/features/transaction/components/transaction-provider/send-provider.d.ts.map +1 -0
- package/dist/types/features/transaction/hooks/use-watch-transactions-by-address.d.ts +14 -0
- package/dist/types/features/transaction/hooks/use-watch-transactions-by-address.d.ts.map +1 -0
- package/dist/types/features/transaction/hooks/use-watch-transactions.d.ts +16 -0
- package/dist/types/features/transaction/hooks/use-watch-transactions.d.ts.map +1 -0
- package/dist/types/features/transaction/index.d.ts +2 -0
- package/dist/types/features/transaction/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tonconnect/tonconnect-bridge.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/features/balances/components/send-jetton-button/send-jetton-button.tsx +4 -4
- package/src/features/balances/components/send-ton-button/send-ton-button.tsx +4 -4
- package/src/features/balances/hooks/use-watch-balance-by-address.ts +54 -0
- package/src/features/balances/hooks/use-watch-balance.ts +25 -0
- package/src/features/balances/index.ts +2 -0
- package/src/features/jettons/hooks/use-watch-jettons-by-address.ts +66 -0
- package/src/features/jettons/hooks/use-watch-jettons.ts +26 -0
- package/src/features/jettons/index.ts +2 -0
- package/src/features/staking/hooks/use-build-stake-transaction.ts +33 -0
- package/src/features/staking/hooks/use-staked-balance.ts +30 -0
- package/src/features/staking/hooks/use-staking-provider-info.ts +35 -0
- package/src/features/staking/hooks/use-staking-providers.ts +35 -0
- package/src/features/staking/hooks/use-staking-quote.ts +30 -0
- package/src/features/staking/index.ts +31 -0
- package/src/features/transaction/components/transaction/index.ts +2 -2
- package/src/features/transaction/components/transaction/{transaction.tsx → send.tsx} +15 -15
- package/src/features/transaction/components/transaction-provider/index.ts +2 -2
- package/src/features/transaction/components/transaction-provider/{transaction-provider.tsx → send-provider.tsx} +9 -15
- package/src/features/transaction/hooks/use-watch-transactions-by-address.ts +55 -0
- package/src/features/transaction/hooks/use-watch-transactions.ts +27 -0
- package/src/features/transaction/index.ts +2 -0
- package/src/features/wallets/hooks/use-connected-wallets.ts +1 -1
- package/src/features/wallets/hooks/use-connector-by-id.ts +1 -1
- package/src/features/wallets/hooks/use-connectors.ts +1 -1
- package/src/features/wallets/hooks/use-selected-wallet.ts +1 -1
- package/src/index.ts +1 -0
- package/src/tonconnect/tonconnect-bridge.tsx +6 -3
- package/dist/esm/features/transaction/components/transaction/transaction.js.map +0 -1
- package/dist/esm/features/transaction/components/transaction-provider/transaction-provider.js.map +0 -1
- package/dist/types/features/transaction/components/transaction/transaction.d.ts.map +0 -1
- package/dist/types/features/transaction/components/transaction-provider/transaction-provider.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ React components and hooks for AppKit.
|
|
|
13
13
|
- [Initialization](#initialization)
|
|
14
14
|
- [Basic Usage](#basic-usage)
|
|
15
15
|
- [Swap](#swap)
|
|
16
|
+
- [Staking](#staking)
|
|
16
17
|
- [Creating a Swap Provider](./docs/creating-swap-provider.md): Implement your own swap provider for any DEX or protocol.
|
|
17
18
|
- [Hooks](./docs/hooks.md): React hooks for wallet connection, state, and data fetching.
|
|
18
19
|
- [Components](./docs/components.md): UI components for AppKit.
|
|
@@ -41,7 +42,7 @@ Initialize `QueryClient` and `AppKit`, then wrap your application in `QueryClien
|
|
|
41
42
|
|
|
42
43
|
```tsx
|
|
43
44
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
44
|
-
import { AppKit, Network,
|
|
45
|
+
import { AppKit, Network, createTonConnectConnector } from '@ton/appkit';
|
|
45
46
|
import { AppKitProvider } from '@ton/appkit-react';
|
|
46
47
|
import type { FC } from 'react';
|
|
47
48
|
|
|
@@ -75,7 +76,7 @@ const appKit = new AppKit({
|
|
|
75
76
|
// },
|
|
76
77
|
},
|
|
77
78
|
connectors: [
|
|
78
|
-
|
|
79
|
+
createTonConnectConnector({
|
|
79
80
|
tonConnectOptions: {
|
|
80
81
|
manifestUrl: 'https://tonconnect-sdk-demo-dapp.vercel.app/tonconnect-manifest.json',
|
|
81
82
|
},
|
|
@@ -153,6 +154,40 @@ export const Balance = () => {
|
|
|
153
154
|
|
|
154
155
|
> See [Hooks Documentation](./docs/hooks.md) for all available hooks and [Components Documentation](./docs/components.md) for UI components.
|
|
155
156
|
|
|
157
|
+
## Send Transaction
|
|
158
|
+
|
|
159
|
+
Use the `Send` component to trigger a transaction from a button. It handles the entire send flow.
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
return (
|
|
163
|
+
<Send
|
|
164
|
+
request={{
|
|
165
|
+
messages: [
|
|
166
|
+
{
|
|
167
|
+
address: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c', // Recipient address
|
|
168
|
+
amount: '100000000', // 0.1 TON in nanotons (raw format)
|
|
169
|
+
payload: beginCell()
|
|
170
|
+
.storeUint(0, 32)
|
|
171
|
+
.storeStringTail('Hello')
|
|
172
|
+
.endCell()
|
|
173
|
+
.toBoc()
|
|
174
|
+
.toString('base64') as Base64String,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
}}
|
|
178
|
+
text="Send Transaction"
|
|
179
|
+
onSuccess={(result: SendTransactionReturnType) => {
|
|
180
|
+
console.log('Transaction sent:', result);
|
|
181
|
+
}}
|
|
182
|
+
onError={(error: Error) => {
|
|
183
|
+
console.error('Transaction failed:', error);
|
|
184
|
+
}}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
For a custom UI, use `SendProvider` with `useSendContext` — see [Components Documentation](./docs/components.md#sendprovider).
|
|
190
|
+
|
|
156
191
|
## Swap
|
|
157
192
|
|
|
158
193
|
AppKit uses a provider-based architecture for swaps. Any DEX or protocol can implement a swap provider by extending the `SwapProvider` class — AppKit handles routing, hooks, and transaction building through a unified interface.
|
|
@@ -199,6 +234,34 @@ Use `useSwapQuote` to get a quote and `useBuildSwapTransaction` to build the tra
|
|
|
199
234
|
|
|
200
235
|
See [Swap Hooks](./docs/hooks.md#swap) for usage examples.
|
|
201
236
|
|
|
237
|
+
## Staking
|
|
238
|
+
|
|
239
|
+
AppKit supports staking through various providers (e.g., Tonstakers). The staking functionality is integrated into the core action and hook system.
|
|
240
|
+
|
|
241
|
+
### Hooks
|
|
242
|
+
|
|
243
|
+
Use `useStakingQuote` to get a staking/unstaking quote and `useBuildStakeTransaction` or `useBuildUnstakeTransaction` to build the transaction.
|
|
244
|
+
|
|
245
|
+
[Read more about Staking](https://github.com/ton-connect/kit/tree/main/packages/appkit/docs/staking.md)
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
const { data: quote } = useStakingQuote({
|
|
249
|
+
amount: '1000000000',
|
|
250
|
+
direction: 'stake',
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const { data: balance } = useStakedBalance({
|
|
254
|
+
userAddress: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c',
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<div>
|
|
259
|
+
<div>Staking Quote: {quote?.amountOut}</div>
|
|
260
|
+
<div>Staked Balance: {balance?.stakedBalance}</div>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
```
|
|
264
|
+
|
|
202
265
|
## Migration from TonConnect UI
|
|
203
266
|
|
|
204
267
|
`AppKitProvider` automatically bridges TonConnect if a `TonConnectConnector` is configured, so `@tonconnect/ui-react` hooks (like `useTonAddress`, `useTonWallet`, etc.) work out of the box inside `AppKitProvider`.
|
|
@@ -10,7 +10,7 @@ import { useCallback, useMemo } from 'react';
|
|
|
10
10
|
import { createTransferJettonTransaction, formatUnits, parseUnits } from '@ton/appkit';
|
|
11
11
|
import { useI18n } from '../../../../hooks/use-i18n';
|
|
12
12
|
import { useAppKit } from '../../../../hooks/use-app-kit';
|
|
13
|
-
import {
|
|
13
|
+
import { Send } from '../../../transaction';
|
|
14
14
|
export const SendJettonButton = ({ recipientAddress, amount, comment, jetton, ...props }) => {
|
|
15
15
|
const appKit = useAppKit();
|
|
16
16
|
const { t } = useI18n();
|
|
@@ -38,6 +38,6 @@ export const SendJettonButton = ({ recipientAddress, amount, comment, jetton, ..
|
|
|
38
38
|
}
|
|
39
39
|
return t('balances.sendJetton', { symbol: jetton.symbol, amount });
|
|
40
40
|
}, [t, amount, jetton]);
|
|
41
|
-
return (_jsx(
|
|
41
|
+
return (_jsx(Send, { request: createTransferTransaction, text: text, disabled: !recipientAddress || !amount || !jetton.address || !jetton.decimals, ...props }));
|
|
42
42
|
};
|
|
43
43
|
//# sourceMappingURL=send-jetton-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-jetton-button.js","sourceRoot":"","sources":["../../../../../../src/features/balances/components/send-jetton-button/send-jetton-button.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"send-jetton-button.js","sourceRoot":"","sources":["../../../../../../src/features/balances/components/send-jetton-button/send-jetton-button.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAa5C,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EACxD,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACX,EAAE,EAAE;IACD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAExB,MAAM,yBAAyB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,+BAA+B,CAAC,MAAM,EAAE;YAC3C,aAAa,EAAE,MAAM,CAAC,OAAO;YAC7B,gBAAgB;YAChB,MAAM;YACN,OAAO;YACP,cAAc,EAAE,MAAM,CAAC,QAAQ;SAClC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAExD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;QACtB,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,CAAC,+BAA+B,EAAE;gBACtC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;gBACpF,MAAM,EAAE,MAAM,CAAC,MAAM;aACxB,CAAC,CAAC;QACP,CAAC;QAED,OAAO,CAAC,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAExB,OAAO,CACH,KAAC,IAAI,IACD,OAAO,EAAE,yBAAyB,EAClC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,CAAC,gBAAgB,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,KACzE,KAAK,GACX,CACL,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { useCallback } from 'react';
|
|
|
10
10
|
import { createTransferTonTransaction } from '@ton/appkit';
|
|
11
11
|
import { useI18n } from '../../../../hooks/use-i18n';
|
|
12
12
|
import { useAppKit } from '../../../../hooks/use-app-kit';
|
|
13
|
-
import {
|
|
13
|
+
import { Send } from '../../../transaction';
|
|
14
14
|
export const SendTonButton = ({ recipientAddress, amount, comment, ...props }) => {
|
|
15
15
|
const appKit = useAppKit();
|
|
16
16
|
const { t } = useI18n();
|
|
@@ -21,6 +21,6 @@ export const SendTonButton = ({ recipientAddress, amount, comment, ...props }) =
|
|
|
21
21
|
comment,
|
|
22
22
|
});
|
|
23
23
|
}, [appKit, recipientAddress, amount, comment]);
|
|
24
|
-
return (_jsx(
|
|
24
|
+
return (_jsx(Send, { request: createTransferTransaction, disabled: !recipientAddress || !amount, text: t('balances.sendTon', { amount }), ...props }));
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=send-ton-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-ton-button.js","sourceRoot":"","sources":["../../../../../../src/features/balances/components/send-ton-button/send-ton-button.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"send-ton-button.js","sourceRoot":"","sources":["../../../../../../src/features/balances/components/send-ton-button/send-ton-button.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAQ5C,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACrG,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAExB,MAAM,yBAAyB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACrD,OAAO,4BAA4B,CAAC,MAAM,EAAE;YACxC,gBAAgB;YAChB,MAAM;YACN,OAAO;SACV,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEhD,OAAO,CACH,KAAC,IAAI,IACD,OAAO,EAAE,yBAAyB,EAClC,QAAQ,EAAE,CAAC,gBAAgB,IAAI,CAAC,MAAM,EACtC,IAAI,EAAE,CAAC,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC,KACnC,KAAK,GACX,CACL,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
10
|
+
import { watchBalanceByAddress, hasStreamingProvider, resolveNetwork } from '@ton/appkit';
|
|
11
|
+
import { handleBalanceUpdate } from '@ton/appkit/queries';
|
|
12
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
13
|
+
/**
|
|
14
|
+
* Hook to watch balance of a specific address in real-time.
|
|
15
|
+
* Automatically updates the TanStack Query cache for `useBalanceByAddress`.
|
|
16
|
+
*/
|
|
17
|
+
export const useWatchBalanceByAddress = (parameters) => {
|
|
18
|
+
const { address, network, onChange } = parameters;
|
|
19
|
+
const appKit = useAppKit();
|
|
20
|
+
const queryClient = useQueryClient();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!address)
|
|
23
|
+
return;
|
|
24
|
+
const resolvedNetwork = resolveNetwork(appKit, network);
|
|
25
|
+
if (!resolvedNetwork || !hasStreamingProvider(appKit, resolvedNetwork)) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.warn(resolvedNetwork
|
|
28
|
+
? `No streaming provider available for network: ${resolvedNetwork?.chainId}`
|
|
29
|
+
: 'No network provided');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const addressString = address.toString();
|
|
33
|
+
return watchBalanceByAddress(appKit, {
|
|
34
|
+
address,
|
|
35
|
+
network: resolvedNetwork,
|
|
36
|
+
onChange: (balance) => {
|
|
37
|
+
onChange?.(balance);
|
|
38
|
+
handleBalanceUpdate(queryClient, { address: addressString, network: resolvedNetwork }, balance);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}, [address, network, appKit, queryClient, onChange]);
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=use-watch-balance-by-address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-watch-balance-by-address.js","sourceRoot":"","sources":["../../../../../src/features/balances/hooks/use-watch-balance-by-address.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIvD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,UAA8C,EAAQ,EAAE;IAC7F,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC;IAClD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,eAAe,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC;YACrE,sCAAsC;YACtC,OAAO,CAAC,IAAI,CACR,eAAe;gBACX,CAAC,CAAC,gDAAgD,eAAe,EAAE,OAAO,EAAE;gBAC5E,CAAC,CAAC,qBAAqB,CAC9B,CAAC;YAEF,OAAO;QACX,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEzC,OAAO,qBAAqB,CAAC,MAAM,EAAE;YACjC,OAAO;YACP,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE;gBAClB,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC;gBACpB,mBAAmB,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;YACpG,CAAC;SACJ,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -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
|
+
import { useAddress } from '../../wallets/hooks/use-address';
|
|
9
|
+
import { useNetwork } from '../../network/hooks/use-network';
|
|
10
|
+
import { useWatchBalanceByAddress } from './use-watch-balance-by-address';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to watch balance of the currently selected wallet in real-time.
|
|
13
|
+
* Automatically updates the TanStack Query cache for `useBalance`.
|
|
14
|
+
*/
|
|
15
|
+
export const useWatchBalance = (parameters = {}) => {
|
|
16
|
+
const address = useAddress();
|
|
17
|
+
const network = useNetwork();
|
|
18
|
+
useWatchBalanceByAddress({ ...parameters, address, network });
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=use-watch-balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-watch-balance.js","sourceRoot":"","sources":["../../../../../src/features/balances/hooks/use-watch-balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAK1E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,aAAwC,EAAE,EAAQ,EAAE;IAChF,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,wBAAwB,CAAC,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC"}
|
|
@@ -11,4 +11,6 @@ export * from './components/send-ton-button';
|
|
|
11
11
|
export * from './components/send-jetton-button';
|
|
12
12
|
export * from './hooks/use-balance';
|
|
13
13
|
export * from './hooks/use-balance-by-address';
|
|
14
|
+
export * from './hooks/use-watch-balance';
|
|
15
|
+
export * from './hooks/use-watch-balance-by-address';
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/balances/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/balances/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
10
|
+
import { watchJettonsByAddress, hasStreamingProvider, resolveNetwork } from '@ton/appkit';
|
|
11
|
+
import { handleJettonBalanceUpdate, handleJettonsUpdate } from '@ton/appkit/queries';
|
|
12
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
13
|
+
/**
|
|
14
|
+
* Hook to watch jetton updates for a specific address in real-time.
|
|
15
|
+
* Automatically updates TanStack Query caches for jetton balances.
|
|
16
|
+
*/
|
|
17
|
+
export const useWatchJettonsByAddress = (parameters) => {
|
|
18
|
+
const { address, network } = parameters;
|
|
19
|
+
const appKit = useAppKit();
|
|
20
|
+
const queryClient = useQueryClient();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!address)
|
|
23
|
+
return;
|
|
24
|
+
const resolvedNetwork = resolveNetwork(appKit, network);
|
|
25
|
+
if (!resolvedNetwork || !hasStreamingProvider(appKit, resolvedNetwork)) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.warn(resolvedNetwork
|
|
28
|
+
? `No streaming provider available for network: ${resolvedNetwork?.chainId}`
|
|
29
|
+
: 'No network provided');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const addressString = address.toString();
|
|
33
|
+
return watchJettonsByAddress(appKit, {
|
|
34
|
+
...parameters,
|
|
35
|
+
address,
|
|
36
|
+
network: resolvedNetwork,
|
|
37
|
+
onChange: (update) => {
|
|
38
|
+
parameters.onChange?.(update);
|
|
39
|
+
handleJettonsUpdate(queryClient, { address: addressString, network: resolvedNetwork }, update);
|
|
40
|
+
handleJettonBalanceUpdate(queryClient, {
|
|
41
|
+
ownerAddress: addressString,
|
|
42
|
+
jettonAddress: update.masterAddress,
|
|
43
|
+
network: resolvedNetwork,
|
|
44
|
+
}, update);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}, [address, network, appKit, queryClient, parameters]);
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=use-watch-jettons-by-address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-watch-jettons-by-address.js","sourceRoot":"","sources":["../../../../../src/features/jettons/hooks/use-watch-jettons-by-address.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1F,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIvD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,UAA8C,EAAQ,EAAE;IAC7F,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IACxC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,eAAe,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC;YACrE,sCAAsC;YACtC,OAAO,CAAC,IAAI,CACR,eAAe;gBACX,CAAC,CAAC,gDAAgD,eAAe,EAAE,OAAO,EAAE;gBAC5E,CAAC,CAAC,qBAAqB,CAC9B,CAAC;YAEF,OAAO;QACX,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEzC,OAAO,qBAAqB,CAAC,MAAM,EAAE;YACjC,GAAG,UAAU;YACb,OAAO;YACP,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,CAAC,MAAoB,EAAE,EAAE;gBAC/B,UAAU,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;gBAE9B,mBAAmB,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,MAAM,CAAC,CAAC;gBAE/F,yBAAyB,CACrB,WAAW,EACX;oBACI,YAAY,EAAE,aAAa;oBAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;oBACnC,OAAO,EAAE,eAAe;iBAC3B,EACD,MAAM,CACT,CAAC;YACN,CAAC;SACJ,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC"}
|
|
@@ -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
|
+
import { useAddress } from '../../wallets/hooks/use-address';
|
|
9
|
+
import { useNetwork } from '../../network/hooks/use-network';
|
|
10
|
+
import { useWatchJettonsByAddress } from './use-watch-jettons-by-address';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to watch jetton updates of the currently selected wallet in real-time.
|
|
13
|
+
* Automatically updates TanStack Query caches for jetton balances.
|
|
14
|
+
*/
|
|
15
|
+
export const useWatchJettons = (parameters = {}) => {
|
|
16
|
+
const address = useAddress();
|
|
17
|
+
const network = useNetwork();
|
|
18
|
+
useWatchJettonsByAddress({ ...parameters, address, network });
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=use-watch-jettons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-watch-jettons.js","sourceRoot":"","sources":["../../../../../src/features/jettons/hooks/use-watch-jettons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAI1E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,aAAwC,EAAE,EAAQ,EAAE;IAChF,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,wBAAwB,CAAC,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC"}
|
|
@@ -10,5 +10,7 @@ export * from './hooks/use-jetton-wallet-address';
|
|
|
10
10
|
export * from './hooks/use-jetton-balance-by-address';
|
|
11
11
|
export * from './hooks/use-jettons';
|
|
12
12
|
export * from './hooks/use-jettons-by-address';
|
|
13
|
+
export * from './hooks/use-watch-jettons-by-address';
|
|
13
14
|
export * from './hooks/use-transfer-jetton';
|
|
15
|
+
export * from './hooks/use-watch-jettons';
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/jettons/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/jettons/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC"}
|
|
@@ -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
|
+
import { buildStakeTransactionMutationOptions } from '@ton/appkit/queries';
|
|
9
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
10
|
+
import { useMutation } from '../../../libs/query';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to build stake transaction
|
|
13
|
+
*/
|
|
14
|
+
export const useBuildStakeTransaction = () => {
|
|
15
|
+
const appKit = useAppKit();
|
|
16
|
+
return useMutation(buildStakeTransactionMutationOptions(appKit));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=use-build-stake-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-build-stake-transaction.js","sourceRoot":"","sources":["../../../../../src/features/staking/hooks/use-build-stake-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,oCAAoC,EAAE,MAAM,qBAAqB,CAAC;AAO3E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AASlD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAmE,EAAE;IACzG,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,WAAW,CAAC,oCAAoC,CAAU,MAAM,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -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
|
+
import { getStakedBalanceQueryOptions } from '@ton/appkit/queries';
|
|
9
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
10
|
+
import { useQuery } from '../../../libs/query';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to get user's staked balance
|
|
13
|
+
*/
|
|
14
|
+
export const useStakedBalance = (parameters = {}) => {
|
|
15
|
+
const appKit = useAppKit();
|
|
16
|
+
return useQuery(getStakedBalanceQueryOptions(appKit, parameters));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=use-staked-balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-staked-balance.js","sourceRoot":"","sources":["../../../../../src/features/staking/hooks/use-staked-balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC5B,aAAqD,EAAE,EACjB,EAAE;IACxC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,QAAQ,CAAC,4BAA4B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AACtE,CAAC,CAAC"}
|
|
@@ -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
|
+
import { getStakingProviderInfoQueryOptions } from '@ton/appkit/queries';
|
|
9
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
10
|
+
import { useQuery } from '../../../libs/query';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to get staking provider information
|
|
13
|
+
*/
|
|
14
|
+
export const useStakingProviderInfo = (parameters = {}) => {
|
|
15
|
+
const appKit = useAppKit();
|
|
16
|
+
return useQuery(getStakingProviderInfoQueryOptions(appKit, parameters));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=use-staking-provider-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-staking-provider-info.js","sourceRoot":"","sources":["../../../../../src/features/staking/hooks/use-staking-provider-info.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAOzE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAU/C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,aAA2D,EAAE,EACjB,EAAE;IAC9C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,QAAQ,CAAC,kCAAkC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC5E,CAAC,CAAC"}
|
|
@@ -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
|
+
import { getStakingProvidersQueryOptions } from '@ton/appkit/queries';
|
|
9
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
10
|
+
import { useQuery } from '../../../libs/query';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to get available staking provider IDs
|
|
13
|
+
*/
|
|
14
|
+
export const useStakingProviders = (parameters = {}) => {
|
|
15
|
+
const appKit = useAppKit();
|
|
16
|
+
return useQuery(getStakingProvidersQueryOptions(appKit, parameters));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=use-staking-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-staking-providers.js","sourceRoot":"","sources":["../../../../../src/features/staking/hooks/use-staking-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAOtE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAU/C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAC/B,aAAwD,EAAE,EACjB,EAAE;IAC3C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,QAAQ,CAAC,+BAA+B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AACzE,CAAC,CAAC"}
|
|
@@ -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
|
+
import { getStakingQuoteQueryOptions } from '@ton/appkit/queries';
|
|
9
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
10
|
+
import { useQuery } from '../../../libs/query';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to get staking/unstaking quote
|
|
13
|
+
*/
|
|
14
|
+
export const useStakingQuote = (parameters = {}) => {
|
|
15
|
+
const appKit = useAppKit();
|
|
16
|
+
return useQuery(getStakingQuoteQueryOptions(appKit, parameters));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=use-staking-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-staking-quote.js","sourceRoot":"","sources":["../../../../../src/features/staking/hooks/use-staking-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,aAAoD,EAAE,EACjB,EAAE;IACvC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,QAAQ,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) TonTech.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export { UnstakeMode } from '@ton/appkit';
|
|
9
|
+
export { useStakingProviders, } from './hooks/use-staking-providers';
|
|
10
|
+
export { useStakingQuote, } from './hooks/use-staking-quote';
|
|
11
|
+
export { useStakedBalance, } from './hooks/use-staked-balance';
|
|
12
|
+
export { useStakingProviderInfo, } from './hooks/use-staking-provider-info';
|
|
13
|
+
export { useBuildStakeTransaction } from './hooks/use-build-stake-transaction';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/staking/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAC;AAE7D,OAAO,EACH,mBAAmB,GAGtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,eAAe,GAGlB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,gBAAgB,GAGnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,sBAAsB,GAGzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAA2C,MAAM,qCAAqC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -7,11 +7,11 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import { useCallback, useMemo } from 'react';
|
|
10
|
-
import {
|
|
10
|
+
import { SendProvider, useSendContext } from '../transaction-provider';
|
|
11
11
|
import { useI18n } from '../../../../hooks/use-i18n';
|
|
12
12
|
import { Button } from '../../../../components/button';
|
|
13
|
-
const
|
|
14
|
-
const { isLoading, onSubmit, disabled } =
|
|
13
|
+
const SendContent = ({ text, children, ...props }) => {
|
|
14
|
+
const { isLoading, onSubmit, disabled } = useSendContext();
|
|
15
15
|
const { t } = useI18n();
|
|
16
16
|
const isDisabled = disabled || isLoading;
|
|
17
17
|
const handleSubmit = useCallback(() => {
|
|
@@ -35,7 +35,7 @@ const TransactionContent = ({ text, children, ...props }) => {
|
|
|
35
35
|
}
|
|
36
36
|
return (_jsx(Button, { onClick: handleSubmit, disabled: isDisabled, ...props, children: buttonText }));
|
|
37
37
|
};
|
|
38
|
-
export const
|
|
39
|
-
return (_jsx(
|
|
38
|
+
export const Send = ({ request, children, className, onError, onSuccess, disabled = false, text, ...props }) => {
|
|
39
|
+
return (_jsx(SendProvider, { request: request, onError: onError, onSuccess: onSuccess, disabled: disabled, children: _jsx(SendContent, { className: className, text: text, ...props, children: children }) }));
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=
|
|
41
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction/send.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAI7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAiCvD,MAAM,WAAW,GAAyB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACvE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IAC3D,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAExB,MAAM,UAAU,GAAG,QAAQ,IAAI,SAAS,CAAC;IAEzC,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,QAAQ,EAAE,CAAC;QACf,CAAC;IACL,CAAC,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,CAAC,CAAC,wBAAwB,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,CAAC,6BAA6B,CAAC,CAAC;IACpD,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzB,IAAI,QAAQ,EAAE,CAAC;QACX,OAAO,CACH,4BACK,QAAQ,CAAC;gBACN,SAAS;gBACT,QAAQ,EAAE,YAAY;gBACtB,QAAQ,EAAE,UAAU;gBACpB,IAAI,EAAE,UAAU;aACnB,CAAC,GACH,CACN,CAAC;IACN,CAAC;IAED,OAAO,CACH,KAAC,MAAM,IAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,KAAM,KAAK,YACzD,UAAU,GACN,CACZ,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAkB,CAAC,EAChC,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,GAAG,KAAK,EACX,EAAE,EAAE;IACD,OAAO,CACH,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,YACtF,KAAC,WAAW,IAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,KAAM,KAAK,YACnD,QAAQ,GACC,GACH,CAClB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
8
|
+
export { SendProvider, useSendContext, SendContext } from './send-provider';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-provider/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-provider/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -8,17 +8,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
8
8
|
*/
|
|
9
9
|
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
10
10
|
import { useSendTransaction } from '../../hooks/use-send-transaction';
|
|
11
|
-
export const
|
|
11
|
+
export const SendContext = createContext({
|
|
12
12
|
onSubmit: () => {
|
|
13
13
|
throw new Error('onSubmit is not defined');
|
|
14
14
|
},
|
|
15
15
|
isLoading: false,
|
|
16
16
|
});
|
|
17
|
-
export function
|
|
18
|
-
const context = useContext(
|
|
17
|
+
export function useSendContext() {
|
|
18
|
+
const context = useContext(SendContext);
|
|
19
19
|
return context;
|
|
20
20
|
}
|
|
21
|
-
export const
|
|
21
|
+
export const SendProvider = ({ children, request, onError, onSuccess, disabled = false }) => {
|
|
22
22
|
const [receipt, setReceipt] = useState(null);
|
|
23
23
|
const [isPreparing, setIsPreparing] = useState(false);
|
|
24
24
|
const { mutateAsync: sendTransaction, isPending, error: mutationError, } = useSendTransaction({
|
|
@@ -59,6 +59,6 @@ export const TransactionProvider = ({ children, request, onError, onSuccess, dis
|
|
|
59
59
|
receipt,
|
|
60
60
|
disabled,
|
|
61
61
|
}), [mutationError, isPreparing, isPending, handleSubmit, receipt, disabled]);
|
|
62
|
-
return _jsx(
|
|
62
|
+
return _jsx(SendContext.Provider, { value: value, children: children });
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=
|
|
64
|
+
//# sourceMappingURL=send-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-provider.js","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-provider/send-provider.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAgBtE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAkB;IACtD,QAAQ,EAAE,GAAG,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IACD,SAAS,EAAE,KAAK;CACnB,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAExC,OAAO,OAAO,CAAC;AACnB,CAAC;AAaD,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK,EAAE,EAAE,EAAE;IAC/G,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAmC,IAAI,CAAC,CAAC;IAC/E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtD,MAAM,EACF,WAAW,EAAE,eAAe,EAC5B,SAAS,EACT,KAAK,EAAE,aAAa,GACvB,GAAG,kBAAkB,CAAC;QACnB,QAAQ,EAAE;YACN,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,UAAU,CAAC,IAAI,CAAC,CAAC;gBACjB,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACb,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;SACJ;KACJ,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACxC,IAAI,QAAQ,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;YACvC,OAAO;QACX,CAAC;QAED,cAAc,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,CAAC;YACD,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC;YAE3F,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACtB,OAAO;YACX,CAAC;YAED,MAAM,eAAe,CAAC,kBAAkB,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5D,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;gBAAS,CAAC;YACP,cAAc,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC,EAAE,CAAC,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAE1E,MAAM,KAAK,GAAG,OAAO,CACjB,GAAG,EAAE,CAAC,CAAC;QACH,KAAK,EAAE,aAAa;QACpB,SAAS,EAAE,WAAW,IAAI,SAAS;QACnC,QAAQ,EAAE,YAAY;QACtB,OAAO;QACP,QAAQ;KACX,CAAC,EACF,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC,CAC3E,CAAC;IAEF,OAAO,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AACjF,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { watchTransactionsByAddress, hasStreamingProvider, resolveNetwork } from '@ton/appkit';
|
|
10
|
+
import { useAppKit } from '../../../hooks/use-app-kit';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to watch transactions for a specific address in real-time.
|
|
13
|
+
*/
|
|
14
|
+
export const useWatchTransactionsByAddress = (parameters) => {
|
|
15
|
+
const { address, network } = parameters;
|
|
16
|
+
const appKit = useAppKit();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!address)
|
|
19
|
+
return;
|
|
20
|
+
const resolvedNetwork = resolveNetwork(appKit, network);
|
|
21
|
+
if (!resolvedNetwork || !hasStreamingProvider(appKit, resolvedNetwork)) {
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.warn(resolvedNetwork
|
|
24
|
+
? `No streaming provider available for network: ${resolvedNetwork?.chainId}`
|
|
25
|
+
: 'No network provided');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!parameters.onChange) {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.warn('No onChange callback provided for watchTransactionsByAddress');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return watchTransactionsByAddress(appKit, {
|
|
34
|
+
...parameters,
|
|
35
|
+
address,
|
|
36
|
+
network: resolvedNetwork,
|
|
37
|
+
onChange: (update) => {
|
|
38
|
+
parameters.onChange?.(update);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}, [address, network, appKit, parameters]);
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=use-watch-transactions-by-address.js.map
|