@ton/appkit-react 0.0.2 → 0.0.4

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.
Files changed (100) hide show
  1. package/dist/esm/features/network/hooks/use-default-network.js +28 -0
  2. package/dist/esm/features/network/hooks/use-default-network.js.map +1 -0
  3. package/dist/esm/features/network/hooks/use-networks.js +10 -3
  4. package/dist/esm/features/network/hooks/use-networks.js.map +1 -1
  5. package/dist/esm/features/network/index.js +1 -0
  6. package/dist/esm/features/network/index.js.map +1 -1
  7. package/dist/esm/features/nft/hooks/use-nfts-by-address.js +1 -1
  8. package/dist/esm/features/nft/hooks/use-nfts.js +2 -2
  9. package/dist/esm/features/transaction/components/transaction-progress/index.js +10 -0
  10. package/dist/esm/features/transaction/components/transaction-progress/index.js.map +1 -0
  11. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-icons.js +14 -0
  12. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-icons.js.map +1 -0
  13. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-provider.js +42 -0
  14. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-provider.js.map +1 -0
  15. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress.js +44 -0
  16. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress.js.map +1 -0
  17. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress.module.css +44 -0
  18. package/dist/esm/features/transaction/hooks/use-transaction-status.js +35 -0
  19. package/dist/esm/features/transaction/hooks/use-transaction-status.js.map +1 -0
  20. package/dist/esm/features/transaction/index.js +2 -0
  21. package/dist/esm/features/transaction/index.js.map +1 -1
  22. package/dist/esm/locales/en.js +5 -0
  23. package/dist/esm/locales/en.js.map +1 -1
  24. package/dist/esm/styles/index.css +1 -0
  25. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  26. package/dist/types/features/network/hooks/use-default-network.d.ts +17 -0
  27. package/dist/types/features/network/hooks/use-default-network.d.ts.map +1 -0
  28. package/dist/types/features/network/hooks/use-networks.d.ts.map +1 -1
  29. package/dist/types/features/network/index.d.ts +1 -0
  30. package/dist/types/features/network/index.d.ts.map +1 -1
  31. package/dist/types/features/nft/hooks/use-nfts-by-address.d.ts +1 -1
  32. package/dist/types/features/transaction/components/transaction-progress/index.d.ts +10 -0
  33. package/dist/types/features/transaction/components/transaction-progress/index.d.ts.map +1 -0
  34. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-icons.d.ts +15 -0
  35. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-icons.d.ts.map +1 -0
  36. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-provider.d.ts +23 -0
  37. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-provider.d.ts.map +1 -0
  38. package/dist/types/features/transaction/components/transaction-progress/transaction-progress.d.ts +32 -0
  39. package/dist/types/features/transaction/components/transaction-progress/transaction-progress.d.ts.map +1 -0
  40. package/dist/types/features/transaction/hooks/use-transaction-status.d.ts +33 -0
  41. package/dist/types/features/transaction/hooks/use-transaction-status.d.ts.map +1 -0
  42. package/dist/types/features/transaction/index.d.ts +2 -0
  43. package/dist/types/features/transaction/index.d.ts.map +1 -1
  44. package/dist/types/libs/i18n.d.ts +5 -0
  45. package/dist/types/libs/i18n.d.ts.map +1 -1
  46. package/dist/types/locales/en.d.ts +5 -0
  47. package/dist/types/locales/en.d.ts.map +1 -1
  48. package/package.json +14 -7
  49. package/src/features/network/hooks/use-default-network.ts +47 -0
  50. package/src/features/network/hooks/use-networks.ts +14 -3
  51. package/src/features/network/index.ts +1 -0
  52. package/src/features/nft/hooks/use-nfts-by-address.ts +1 -1
  53. package/src/features/nft/hooks/use-nfts.ts +2 -2
  54. package/src/features/transaction/components/transaction-progress/index.ts +10 -0
  55. package/src/features/transaction/components/transaction-progress/transaction-progress-icons.tsx +80 -0
  56. package/src/features/transaction/components/transaction-progress/transaction-progress-provider.tsx +60 -0
  57. package/src/features/transaction/components/transaction-progress/transaction-progress.tsx +97 -0
  58. package/src/features/transaction/hooks/use-transaction-status.ts +55 -0
  59. package/src/features/transaction/index.ts +2 -0
  60. package/src/locales/en.ts +5 -0
  61. package/dist/esm/components/block/block.stories.js +0 -27
  62. package/dist/esm/components/block/block.stories.js.map +0 -1
  63. package/dist/esm/components/button/button.stories.js +0 -30
  64. package/dist/esm/components/button/button.stories.js.map +0 -1
  65. package/dist/esm/components/circle-icon/circle-icon.stories.js +0 -56
  66. package/dist/esm/components/circle-icon/circle-icon.stories.js.map +0 -1
  67. package/dist/esm/components/ton-icon/ton-icon.stories.js +0 -56
  68. package/dist/esm/components/ton-icon/ton-icon.stories.js.map +0 -1
  69. package/dist/esm/features/balances/components/balance-badge/balance-badge.stories.js +0 -23
  70. package/dist/esm/features/balances/components/balance-badge/balance-badge.stories.js.map +0 -1
  71. package/dist/esm/features/balances/components/currency-item/currency-item.stories.js +0 -61
  72. package/dist/esm/features/balances/components/currency-item/currency-item.stories.js.map +0 -1
  73. package/dist/esm/features/balances/components/send-jetton-button/send-jetton-button.stories.js +0 -41
  74. package/dist/esm/features/balances/components/send-jetton-button/send-jetton-button.stories.js.map +0 -1
  75. package/dist/esm/features/balances/components/send-ton-button/send-ton-button.stories.js +0 -36
  76. package/dist/esm/features/balances/components/send-ton-button/send-ton-button.stories.js.map +0 -1
  77. package/dist/esm/features/nft/components/nft-item/nft-item.stories.js +0 -52
  78. package/dist/esm/features/nft/components/nft-item/nft-item.stories.js.map +0 -1
  79. package/dist/esm/features/transaction/components/transaction/transaction.stories.js +0 -47
  80. package/dist/esm/features/transaction/components/transaction/transaction.stories.js.map +0 -1
  81. package/dist/types/components/block/block.stories.d.ts +0 -15
  82. package/dist/types/components/block/block.stories.d.ts.map +0 -1
  83. package/dist/types/components/button/button.stories.d.ts +0 -16
  84. package/dist/types/components/button/button.stories.d.ts.map +0 -1
  85. package/dist/types/components/circle-icon/circle-icon.stories.d.ts +0 -18
  86. package/dist/types/components/circle-icon/circle-icon.stories.d.ts.map +0 -1
  87. package/dist/types/components/ton-icon/ton-icon.stories.d.ts +0 -20
  88. package/dist/types/components/ton-icon/ton-icon.stories.d.ts.map +0 -1
  89. package/dist/types/features/balances/components/balance-badge/balance-badge.stories.d.ts +0 -16
  90. package/dist/types/features/balances/components/balance-badge/balance-badge.stories.d.ts.map +0 -1
  91. package/dist/types/features/balances/components/currency-item/currency-item.stories.d.ts +0 -19
  92. package/dist/types/features/balances/components/currency-item/currency-item.stories.d.ts.map +0 -1
  93. package/dist/types/features/balances/components/send-jetton-button/send-jetton-button.stories.d.ts +0 -22
  94. package/dist/types/features/balances/components/send-jetton-button/send-jetton-button.stories.d.ts.map +0 -1
  95. package/dist/types/features/balances/components/send-ton-button/send-ton-button.stories.d.ts +0 -21
  96. package/dist/types/features/balances/components/send-ton-button/send-ton-button.stories.d.ts.map +0 -1
  97. package/dist/types/features/nft/components/nft-item/nft-item.stories.d.ts +0 -25
  98. package/dist/types/features/nft/components/nft-item/nft-item.stories.d.ts.map +0 -1
  99. package/dist/types/features/transaction/components/transaction/transaction.stories.d.ts +0 -23
  100. package/dist/types/features/transaction/components/transaction/transaction.stories.d.ts.map +0 -1
@@ -0,0 +1,17 @@
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 type { GetDefaultNetworkReturnType, Network } from '@ton/appkit';
9
+ export type UseDefaultNetworkReturnType = [
10
+ network: GetDefaultNetworkReturnType,
11
+ setNetwork: (network: Network | undefined) => void
12
+ ];
13
+ /**
14
+ * Hook to get and set the default network for wallet connections.
15
+ */
16
+ export declare const useDefaultNetwork: () => UseDefaultNetworkReturnType;
17
+ //# sourceMappingURL=use-default-network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-default-network.d.ts","sourceRoot":"","sources":["../../../../../src/features/network/hooks/use-default-network.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,2BAA2B,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,MAAM,2BAA2B,GAAG;IACtC,OAAO,EAAE,2BAA2B;IACpC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,KAAK,IAAI;CACrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAO,2BAwBpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-networks.d.ts","sourceRoot":"","sources":["../../../../../src/features/network/hooks/use-networks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIzD,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,qBAe9B,CAAC"}
1
+ {"version":3,"file":"use-networks.d.ts","sourceRoot":"","sources":["../../../../../src/features/network/hooks/use-networks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIzD,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,qBA0B9B,CAAC"}
@@ -7,4 +7,5 @@
7
7
  */
8
8
  export { useNetworks, type UseNetworksReturnType } from './hooks/use-networks';
9
9
  export { useNetwork, type UseNetworkReturnType } from './hooks/use-network';
10
+ export { useDefaultNetwork, type UseDefaultNetworkReturnType } from './hooks/use-default-network';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/network/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/network/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,KAAK,2BAA2B,EAAE,MAAM,6BAA6B,CAAC"}
@@ -12,5 +12,5 @@ export type UseNFTsByAddressReturnType<selectData = GetNFTsData> = UseQueryRetur
12
12
  /**
13
13
  * Hook to get NFTs
14
14
  */
15
- export declare const useNFTsByAddress: <selectData = GetNFTsData>(parameters?: UseNFTsByAddressParameters<selectData>) => UseNFTsByAddressReturnType<selectData>;
15
+ export declare const useNftsByAddress: <selectData = GetNFTsData>(parameters?: UseNFTsByAddressParameters<selectData>) => UseNFTsByAddressReturnType<selectData>;
16
16
  //# sourceMappingURL=use-nfts-by-address.d.ts.map
@@ -0,0 +1,10 @@
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 * from './transaction-progress';
9
+ export * from './transaction-progress-provider';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-progress/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,15 @@
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 type { ComponentProps, FC } from 'react';
9
+ import type { TransactionStatus } from '@ton/appkit';
10
+ export interface TransactionProgressIconsProps extends ComponentProps<'svg'> {
11
+ status: TransactionStatus;
12
+ isError: boolean;
13
+ }
14
+ export declare const TransactionProgressIcon: FC<TransactionProgressIconsProps>;
15
+ //# sourceMappingURL=transaction-progress-icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-progress-icons.d.ts","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-progress/transaction-progress-icons.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,MAAM,WAAW,6BAA8B,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CACpB;AAwDD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,6BAA6B,CAMrE,CAAC"}
@@ -0,0 +1,23 @@
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 type { ReactNode } from 'react';
9
+ import type { GetTransactionStatusReturnType } from '@ton/appkit';
10
+ import type { GetTransactionStatusErrorType } from '@ton/appkit/queries';
11
+ export interface TransactionProgressContextValue extends GetTransactionStatusReturnType {
12
+ isFetching: boolean;
13
+ error: GetTransactionStatusErrorType | null;
14
+ boc: string;
15
+ }
16
+ export declare const TransactionProgressContext: import("react").Context<TransactionProgressContextValue | undefined>;
17
+ export declare const useTransactionProgressContext: () => TransactionProgressContextValue;
18
+ export interface TransactionProgressProviderProps {
19
+ boc: string;
20
+ children: ReactNode;
21
+ }
22
+ export declare const TransactionProgressProvider: ({ boc, children }: TransactionProgressProviderProps) => import("react/jsx-runtime").JSX.Element;
23
+ //# sourceMappingURL=transaction-progress-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-progress-provider.d.ts","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-progress/transaction-progress-provider.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAIzE,MAAM,WAAW,+BAAgC,SAAQ,8BAA8B;IACnF,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,0BAA0B,sEAAwE,CAAC;AAEhH,eAAO,MAAM,6BAA6B,uCAMzC,CAAC;AAEF,MAAM,WAAW,gCAAgC;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,2BAA2B,GAAI,mBAAmB,gCAAgC,4CAuB9F,CAAC"}
@@ -0,0 +1,32 @@
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 type { FC, ReactNode, ComponentProps } from 'react';
9
+ import type { TransactionProgressContextValue } from './transaction-progress-provider';
10
+ export interface TransactionProgressTexts {
11
+ pending: string;
12
+ completed: string;
13
+ failed: string;
14
+ }
15
+ export interface TransactionProgressRenderProps extends TransactionProgressContextValue {
16
+ texts: TransactionProgressTexts;
17
+ }
18
+ export interface TransactionProgressProps extends Omit<ComponentProps<'div'>, 'children'> {
19
+ /** BOC of the transaction to strictly track status */
20
+ boc: string;
21
+ /** Render props function for full control over rendering */
22
+ children?: (props: TransactionProgressRenderProps) => ReactNode;
23
+ /** Allows targeting specific internal elements for styling */
24
+ classNames?: {
25
+ container?: string;
26
+ icon?: string;
27
+ message?: string;
28
+ };
29
+ }
30
+ export declare const TransactionProgressContent: FC<Omit<TransactionProgressProps, 'boc'>>;
31
+ export declare const TransactionProgress: FC<TransactionProgressProps>;
32
+ //# sourceMappingURL=transaction-progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-progress.d.ts","sourceRoot":"","sources":["../../../../../../src/features/transaction/components/transaction-progress/transaction-progress.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAK3D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAIvF,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,8BAA+B,SAAQ,+BAA+B;IACnF,KAAK,EAAE,wBAAwB,CAAC;CACnC;AAED,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACrF,sDAAsD;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,SAAS,CAAC;IAChE,8DAA8D;IAC9D,UAAU,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACL;AAED,eAAO,MAAM,0BAA0B,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,CA+ChF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAM5D,CAAC"}
@@ -0,0 +1,33 @@
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 type { GetTransactionStatusData, GetTransactionStatusErrorType, GetTransactionStatusParameters, GetTransactionStatusQueryConfig } from '@ton/appkit/queries';
9
+ import type { UseQueryReturnType } from '../../../libs/query';
10
+ export type UseTransactionStatusParameters<selectData = GetTransactionStatusData> = GetTransactionStatusParameters & GetTransactionStatusQueryConfig<selectData>;
11
+ export type UseTransactionStatusReturnType<selectData = GetTransactionStatusData> = UseQueryReturnType<selectData, GetTransactionStatusErrorType>;
12
+ /**
13
+ * Hook to get the status of a transaction trace by BOC.
14
+ *
15
+ * This hook polls the toncenter API to track the progress of a transaction trace.
16
+ * It is useful for tracking complex operations like swaps or multi-step flows.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const { data: status } = useTransactionStatus({
21
+ * boc: 'te6cc...',
22
+ * query: {
23
+ * refetchInterval: 2000, // Poll every 2 seconds
24
+ * }
25
+ * });
26
+ *
27
+ * if (status?.status === 'pending') {
28
+ * console.log(`Progress: ${status.completedMessages}/${status.totalMessages}`);
29
+ * }
30
+ * ```
31
+ */
32
+ export declare const useTransactionStatus: <selectData = GetTransactionStatusData>(parameters: UseTransactionStatusParameters<selectData>) => UseTransactionStatusReturnType<selectData>;
33
+ //# sourceMappingURL=use-transaction-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-transaction-status.d.ts","sourceRoot":"","sources":["../../../../../src/features/transaction/hooks/use-transaction-status.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACR,wBAAwB,EACxB,6BAA6B,EAC7B,8BAA8B,EAC9B,+BAA+B,EAClC,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,MAAM,MAAM,8BAA8B,CAAC,UAAU,GAAG,wBAAwB,IAAI,8BAA8B,GAC9G,+BAA+B,CAAC,UAAU,CAAC,CAAC;AAEhD,MAAM,MAAM,8BAA8B,CAAC,UAAU,GAAG,wBAAwB,IAAI,kBAAkB,CAClG,UAAU,EACV,6BAA6B,CAChC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,GAAG,wBAAwB,EACtE,YAAY,8BAA8B,CAAC,UAAU,CAAC,KACvD,8BAA8B,CAAC,UAAU,CAI3C,CAAC"}
@@ -7,5 +7,7 @@
7
7
  */
8
8
  export * from './hooks/use-send-transaction';
9
9
  export * from './hooks/use-transfer-ton';
10
+ export * from './hooks/use-transaction-status';
10
11
  export * from './components/transaction';
12
+ export * from './components/transaction-progress';
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/transaction/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/transaction/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC"}
@@ -17,6 +17,11 @@ export declare const i18n: rosetta.Rosetta<{
17
17
  readonly transaction: {
18
18
  readonly sendTransaction: "Send Transaction";
19
19
  readonly processing: "Processing...";
20
+ readonly status: {
21
+ readonly pending: "Processing...";
22
+ readonly completed: "Success";
23
+ readonly failed: "Failed";
24
+ };
20
25
  };
21
26
  readonly balances: {
22
27
  readonly sendTon: "Send {{ amount }} TON";
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/libs/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,MAAM,eAAe,CAAC;AAE/B,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;EAAkB,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,CAAC;AACd,eAAO,MAAM,eAAe,OAAO,CAAC;AAIpC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC;AAC/B,MAAM,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/libs/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,MAAM,eAAe,CAAC;AAE/B,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;EAAkB,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,CAAC;AACd,eAAO,MAAM,eAAe,OAAO,CAAC;AAIpC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC;AAC/B,MAAM,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC"}
@@ -15,6 +15,11 @@ declare const _default: {
15
15
  readonly transaction: {
16
16
  readonly sendTransaction: "Send Transaction";
17
17
  readonly processing: "Processing...";
18
+ readonly status: {
19
+ readonly pending: "Processing...";
20
+ readonly completed: "Success";
21
+ readonly failed: "Failed";
22
+ };
18
23
  };
19
24
  readonly balances: {
20
25
  readonly sendTon: "Send {{ amount }} TON";
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/locales/en.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;AAEH,wBA0BW"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/locales/en.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wBA+BW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton/appkit-react",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,11 +25,18 @@
25
25
  },
26
26
  "./styles.css": "./dist/esm/styles/index.css"
27
27
  },
28
+ "typesVersions": {
29
+ "*": {
30
+ "styles.css": [
31
+ "./dist/esm/styles/index.css"
32
+ ]
33
+ }
34
+ },
28
35
  "dependencies": {
29
36
  "clsx": "2.1.1",
30
37
  "radix-ui": "^1.4.3",
31
38
  "rosetta": "1.1.0",
32
- "@ton/appkit": "0.0.1"
39
+ "@ton/appkit": "0.0.3"
33
40
  },
34
41
  "devDependencies": {
35
42
  "@storybook/addon-docs": "10.2.8",
@@ -40,10 +47,10 @@
40
47
  "@tonconnect/ui-react": "2.4.1",
41
48
  "@types/react": "19.2.8",
42
49
  "@types/react-dom": "19.2.3",
50
+ "copyfiles": "2.4.1",
43
51
  "react": "19.2.3",
44
52
  "react-dom": "19.2.3",
45
53
  "storybook": "10.2.8",
46
- "tsup": "^8.5.1",
47
54
  "typescript": "^5.9.2",
48
55
  "vite": "^7.3.1",
49
56
  "vite-plugin-node-polyfills": "^0.25.0"
@@ -67,10 +74,10 @@
67
74
  "*.css"
68
75
  ],
69
76
  "scripts": {
70
- "build": "pnpm run build:esm+types && pnpm run copy:css",
71
- "build:esm+types": "tsc --project tsconfig.build.json --outDir dist/esm --declarationDir dist/types",
72
- "copy:css": "rsync -zarv --include='*/' --include='*.css' --exclude='*' src/ dist/esm/",
73
- "dev": "tsup --watch",
77
+ "build": "pnpm run build:esm && pnpm run copy:css",
78
+ "build:esm": "tsc --project tsconfig.build.json --outDir dist/esm --declarationDir dist/types",
79
+ "dev": "pnpm run copy:css && pnpm run build:esm --watch",
80
+ "copy:css": "copyfiles -u 1 \"src/**/*.css\" dist/esm",
74
81
  "clean": "git clean -xdf .turbo dist node_modules",
75
82
  "typecheck": "tsc --noEmit",
76
83
  "storybook": "storybook dev -p 6006",
@@ -0,0 +1,47 @@
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 { useSyncExternalStore, useCallback } from 'react';
10
+ import { getDefaultNetwork, setDefaultNetwork, watchDefaultNetwork } from '@ton/appkit';
11
+ import type { GetDefaultNetworkReturnType, Network } from '@ton/appkit';
12
+
13
+ import { useAppKit } from '../../../hooks/use-app-kit';
14
+
15
+ export type UseDefaultNetworkReturnType = [
16
+ network: GetDefaultNetworkReturnType,
17
+ setNetwork: (network: Network | undefined) => void,
18
+ ];
19
+
20
+ /**
21
+ * Hook to get and set the default network for wallet connections.
22
+ */
23
+ export const useDefaultNetwork = (): UseDefaultNetworkReturnType => {
24
+ const appKit = useAppKit();
25
+
26
+ const subscribe = useCallback(
27
+ (onChange: () => void) => {
28
+ return watchDefaultNetwork(appKit, { onChange });
29
+ },
30
+ [appKit],
31
+ );
32
+
33
+ const getSnapshot = useCallback(() => {
34
+ return getDefaultNetwork(appKit);
35
+ }, [appKit]);
36
+
37
+ const network = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
38
+
39
+ const setNetwork = useCallback(
40
+ (newNetwork: Network | undefined) => {
41
+ setDefaultNetwork(appKit, { network: newNetwork });
42
+ },
43
+ [appKit],
44
+ );
45
+
46
+ return [network, setNetwork];
47
+ };
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { useSyncExternalStore, useCallback } from 'react';
9
+ import { useSyncExternalStore, useCallback, useRef } from 'react';
10
10
  import { getNetworks, watchNetworks } from '@ton/appkit';
11
11
  import type { GetNetworksReturnType } from '@ton/appkit';
12
12
 
@@ -19,6 +19,7 @@ export type UseNetworksReturnType = GetNetworksReturnType;
19
19
  */
20
20
  export const useNetworks = (): UseNetworksReturnType => {
21
21
  const appKit = useAppKit();
22
+ const cachedRef = useRef<GetNetworksReturnType>([]);
22
23
 
23
24
  const subscribe = useCallback(
24
25
  (onChange: () => void) => {
@@ -28,8 +29,18 @@ export const useNetworks = (): UseNetworksReturnType => {
28
29
  );
29
30
 
30
31
  const getSnapshot = useCallback(() => {
31
- return getNetworks(appKit);
32
+ const networks = getNetworks(appKit);
33
+
34
+ if (
35
+ networks.length === cachedRef.current.length &&
36
+ networks.every((n, i) => n.chainId === cachedRef.current[i]?.chainId)
37
+ ) {
38
+ return cachedRef.current;
39
+ }
40
+
41
+ cachedRef.current = networks;
42
+ return networks;
32
43
  }, [appKit]);
33
44
 
34
- return useSyncExternalStore(subscribe, getSnapshot, () => []);
45
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
35
46
  };
@@ -9,3 +9,4 @@
9
9
  // Hooks
10
10
  export { useNetworks, type UseNetworksReturnType } from './hooks/use-networks';
11
11
  export { useNetwork, type UseNetworkReturnType } from './hooks/use-network';
12
+ export { useDefaultNetwork, type UseDefaultNetworkReturnType } from './hooks/use-default-network';
@@ -20,7 +20,7 @@ export type UseNFTsByAddressReturnType<selectData = GetNFTsData> = UseQueryRetur
20
20
  /**
21
21
  * Hook to get NFTs
22
22
  */
23
- export const useNFTsByAddress = <selectData = GetNFTsData>(
23
+ export const useNftsByAddress = <selectData = GetNFTsData>(
24
24
  parameters: UseNFTsByAddressParameters<selectData> = {},
25
25
  ): UseNFTsByAddressReturnType<selectData> => {
26
26
  const appKit = useAppKit();
@@ -9,7 +9,7 @@
9
9
  import type { GetNFTsData } from '@ton/appkit/queries';
10
10
 
11
11
  import { useAddress } from '../../wallets/hooks/use-address';
12
- import { useNFTsByAddress } from './use-nfts-by-address';
12
+ import { useNftsByAddress } from './use-nfts-by-address';
13
13
  import type { UseNFTsByAddressParameters, UseNFTsByAddressReturnType } from './use-nfts-by-address';
14
14
 
15
15
  export type UseNFTsParameters<selectData = GetNFTsData> = UseNFTsByAddressParameters<selectData>;
@@ -24,5 +24,5 @@ export const useNfts = <selectData = GetNFTsData>(
24
24
  ): UseNFTsReturnType<selectData> => {
25
25
  const address = useAddress();
26
26
 
27
- return useNFTsByAddress({ ...parameters, address });
27
+ return useNftsByAddress({ ...parameters, address });
28
28
  };
@@ -0,0 +1,10 @@
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 * from './transaction-progress';
10
+ export * from './transaction-progress-provider';
@@ -0,0 +1,80 @@
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 { ComponentProps, FC } from 'react';
10
+ import clsx from 'clsx';
11
+ import type { TransactionStatus } from '@ton/appkit';
12
+
13
+ import styles from './transaction-progress.module.css';
14
+
15
+ export interface TransactionProgressIconsProps extends ComponentProps<'svg'> {
16
+ status: TransactionStatus;
17
+ isError: boolean;
18
+ }
19
+
20
+ const SpinnerIcon: FC<ComponentProps<'svg'>> = ({ className }) => (
21
+ <svg
22
+ className={clsx(styles.spinner, className)}
23
+ xmlns="http://www.w3.org/2000/svg"
24
+ width="48"
25
+ height="48"
26
+ viewBox="0 0 24 24"
27
+ fill="none"
28
+ stroke="currentColor"
29
+ strokeWidth="2"
30
+ strokeLinecap="round"
31
+ strokeLinejoin="round"
32
+ >
33
+ <path d="M21 12a9 9 0 1 1-6.219-8.56" />
34
+ </svg>
35
+ );
36
+
37
+ const SuccessIcon: FC<ComponentProps<'svg'>> = ({ className }) => (
38
+ <svg
39
+ className={clsx(styles.success, className)}
40
+ xmlns="http://www.w3.org/2000/svg"
41
+ width="48"
42
+ height="48"
43
+ viewBox="0 0 24 24"
44
+ fill="none"
45
+ stroke="currentColor"
46
+ strokeWidth="2"
47
+ strokeLinecap="round"
48
+ strokeLinejoin="round"
49
+ >
50
+ <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
51
+ <polyline points="22 4 12 14.01 9 11.01" />
52
+ </svg>
53
+ );
54
+
55
+ const FailedIcon: FC<ComponentProps<'svg'>> = ({ className }) => (
56
+ <svg
57
+ className={clsx(styles.failed, className)}
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ width="48"
60
+ height="48"
61
+ viewBox="0 0 24 24"
62
+ fill="none"
63
+ stroke="currentColor"
64
+ strokeWidth="2"
65
+ strokeLinecap="round"
66
+ strokeLinejoin="round"
67
+ >
68
+ <circle cx="12" cy="12" r="10" />
69
+ <line x1="15" y1="9" x2="9" y2="15" />
70
+ <line x1="9" y1="9" x2="15" y2="15" />
71
+ </svg>
72
+ );
73
+
74
+ export const TransactionProgressIcon: FC<TransactionProgressIconsProps> = ({ status, isError, ...props }) => {
75
+ if (status === 'completed') return <SuccessIcon {...props} />;
76
+
77
+ if (status === 'failed' || isError) return <FailedIcon {...props} />;
78
+
79
+ return <SpinnerIcon {...props} />;
80
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { createContext, useContext } from 'react';
10
+ import type { ReactNode } from 'react';
11
+ import type { GetTransactionStatusReturnType } from '@ton/appkit';
12
+ import type { GetTransactionStatusErrorType } from '@ton/appkit/queries';
13
+
14
+ import { useTransactionStatus } from '../../hooks/use-transaction-status';
15
+
16
+ export interface TransactionProgressContextValue extends GetTransactionStatusReturnType {
17
+ isFetching: boolean;
18
+ error: GetTransactionStatusErrorType | null;
19
+ boc: string;
20
+ }
21
+
22
+ export const TransactionProgressContext = createContext<TransactionProgressContextValue | undefined>(undefined);
23
+
24
+ export const useTransactionProgressContext = () => {
25
+ const context = useContext(TransactionProgressContext);
26
+ if (!context) {
27
+ throw new Error('useTransactionProgressContext must be used within a TransactionProgressProvider');
28
+ }
29
+ return context;
30
+ };
31
+
32
+ export interface TransactionProgressProviderProps {
33
+ boc: string;
34
+ children: ReactNode;
35
+ }
36
+
37
+ export const TransactionProgressProvider = ({ boc, children }: TransactionProgressProviderProps) => {
38
+ const { data, isFetching, error } = useTransactionStatus({
39
+ boc,
40
+ query: {
41
+ refetchInterval: (query) => {
42
+ const status = query.state.data?.status;
43
+ if (status === 'completed' || status === 'failed') return false;
44
+ return 2000;
45
+ },
46
+ },
47
+ });
48
+
49
+ const value: TransactionProgressContextValue = {
50
+ status: data?.status ?? 'pending',
51
+ totalMessages: data?.totalMessages ?? 0,
52
+ pendingMessages: data?.pendingMessages ?? 0,
53
+ onchainMessages: data?.onchainMessages ?? 0,
54
+ isFetching,
55
+ error,
56
+ boc,
57
+ };
58
+
59
+ return <TransactionProgressContext.Provider value={value}>{children}</TransactionProgressContext.Provider>;
60
+ };