@ton/appkit-react 0.0.2 → 0.0.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.
Files changed (81) hide show
  1. package/dist/esm/features/transaction/components/transaction-progress/index.js +10 -0
  2. package/dist/esm/features/transaction/components/transaction-progress/index.js.map +1 -0
  3. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-icons.js +14 -0
  4. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-icons.js.map +1 -0
  5. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-provider.js +42 -0
  6. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress-provider.js.map +1 -0
  7. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress.js +44 -0
  8. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress.js.map +1 -0
  9. package/dist/esm/features/transaction/components/transaction-progress/transaction-progress.module.css +44 -0
  10. package/dist/esm/features/transaction/hooks/use-transaction-status.js +35 -0
  11. package/dist/esm/features/transaction/hooks/use-transaction-status.js.map +1 -0
  12. package/dist/esm/features/transaction/index.js +2 -0
  13. package/dist/esm/features/transaction/index.js.map +1 -1
  14. package/dist/esm/locales/en.js +5 -0
  15. package/dist/esm/locales/en.js.map +1 -1
  16. package/dist/esm/styles/index.css +1 -0
  17. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  18. package/dist/types/features/transaction/components/transaction-progress/index.d.ts +10 -0
  19. package/dist/types/features/transaction/components/transaction-progress/index.d.ts.map +1 -0
  20. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-icons.d.ts +15 -0
  21. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-icons.d.ts.map +1 -0
  22. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-provider.d.ts +23 -0
  23. package/dist/types/features/transaction/components/transaction-progress/transaction-progress-provider.d.ts.map +1 -0
  24. package/dist/types/features/transaction/components/transaction-progress/transaction-progress.d.ts +32 -0
  25. package/dist/types/features/transaction/components/transaction-progress/transaction-progress.d.ts.map +1 -0
  26. package/dist/types/features/transaction/hooks/use-transaction-status.d.ts +33 -0
  27. package/dist/types/features/transaction/hooks/use-transaction-status.d.ts.map +1 -0
  28. package/dist/types/features/transaction/index.d.ts +2 -0
  29. package/dist/types/features/transaction/index.d.ts.map +1 -1
  30. package/dist/types/libs/i18n.d.ts +5 -0
  31. package/dist/types/libs/i18n.d.ts.map +1 -1
  32. package/dist/types/locales/en.d.ts +5 -0
  33. package/dist/types/locales/en.d.ts.map +1 -1
  34. package/package.json +14 -7
  35. package/src/features/transaction/components/transaction-progress/index.ts +10 -0
  36. package/src/features/transaction/components/transaction-progress/transaction-progress-icons.tsx +80 -0
  37. package/src/features/transaction/components/transaction-progress/transaction-progress-provider.tsx +60 -0
  38. package/src/features/transaction/components/transaction-progress/transaction-progress.tsx +97 -0
  39. package/src/features/transaction/hooks/use-transaction-status.ts +55 -0
  40. package/src/features/transaction/index.ts +2 -0
  41. package/src/locales/en.ts +5 -0
  42. package/dist/esm/components/block/block.stories.js +0 -27
  43. package/dist/esm/components/block/block.stories.js.map +0 -1
  44. package/dist/esm/components/button/button.stories.js +0 -30
  45. package/dist/esm/components/button/button.stories.js.map +0 -1
  46. package/dist/esm/components/circle-icon/circle-icon.stories.js +0 -56
  47. package/dist/esm/components/circle-icon/circle-icon.stories.js.map +0 -1
  48. package/dist/esm/components/ton-icon/ton-icon.stories.js +0 -56
  49. package/dist/esm/components/ton-icon/ton-icon.stories.js.map +0 -1
  50. package/dist/esm/features/balances/components/balance-badge/balance-badge.stories.js +0 -23
  51. package/dist/esm/features/balances/components/balance-badge/balance-badge.stories.js.map +0 -1
  52. package/dist/esm/features/balances/components/currency-item/currency-item.stories.js +0 -61
  53. package/dist/esm/features/balances/components/currency-item/currency-item.stories.js.map +0 -1
  54. package/dist/esm/features/balances/components/send-jetton-button/send-jetton-button.stories.js +0 -41
  55. package/dist/esm/features/balances/components/send-jetton-button/send-jetton-button.stories.js.map +0 -1
  56. package/dist/esm/features/balances/components/send-ton-button/send-ton-button.stories.js +0 -36
  57. package/dist/esm/features/balances/components/send-ton-button/send-ton-button.stories.js.map +0 -1
  58. package/dist/esm/features/nft/components/nft-item/nft-item.stories.js +0 -52
  59. package/dist/esm/features/nft/components/nft-item/nft-item.stories.js.map +0 -1
  60. package/dist/esm/features/transaction/components/transaction/transaction.stories.js +0 -47
  61. package/dist/esm/features/transaction/components/transaction/transaction.stories.js.map +0 -1
  62. package/dist/types/components/block/block.stories.d.ts +0 -15
  63. package/dist/types/components/block/block.stories.d.ts.map +0 -1
  64. package/dist/types/components/button/button.stories.d.ts +0 -16
  65. package/dist/types/components/button/button.stories.d.ts.map +0 -1
  66. package/dist/types/components/circle-icon/circle-icon.stories.d.ts +0 -18
  67. package/dist/types/components/circle-icon/circle-icon.stories.d.ts.map +0 -1
  68. package/dist/types/components/ton-icon/ton-icon.stories.d.ts +0 -20
  69. package/dist/types/components/ton-icon/ton-icon.stories.d.ts.map +0 -1
  70. package/dist/types/features/balances/components/balance-badge/balance-badge.stories.d.ts +0 -16
  71. package/dist/types/features/balances/components/balance-badge/balance-badge.stories.d.ts.map +0 -1
  72. package/dist/types/features/balances/components/currency-item/currency-item.stories.d.ts +0 -19
  73. package/dist/types/features/balances/components/currency-item/currency-item.stories.d.ts.map +0 -1
  74. package/dist/types/features/balances/components/send-jetton-button/send-jetton-button.stories.d.ts +0 -22
  75. package/dist/types/features/balances/components/send-jetton-button/send-jetton-button.stories.d.ts.map +0 -1
  76. package/dist/types/features/balances/components/send-ton-button/send-ton-button.stories.d.ts +0 -21
  77. package/dist/types/features/balances/components/send-ton-button/send-ton-button.stories.d.ts.map +0 -1
  78. package/dist/types/features/nft/components/nft-item/nft-item.stories.d.ts +0 -25
  79. package/dist/types/features/nft/components/nft-item/nft-item.stories.d.ts.map +0 -1
  80. package/dist/types/features/transaction/components/transaction/transaction.stories.d.ts +0 -23
  81. package/dist/types/features/transaction/components/transaction/transaction.stories.d.ts.map +0 -1
@@ -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.3",
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.2"
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,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
+ };
@@ -0,0 +1,97 @@
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 { useMemo } from 'react';
10
+ import type { FC, ReactNode, ComponentProps } from 'react';
11
+ import { clsx } from 'clsx';
12
+
13
+ import { useI18n } from '../../../../hooks/use-i18n';
14
+ import { TransactionProgressProvider, useTransactionProgressContext } from './transaction-progress-provider';
15
+ import type { TransactionProgressContextValue } from './transaction-progress-provider';
16
+ import { TransactionProgressIcon } from './transaction-progress-icons';
17
+ import styles from './transaction-progress.module.css';
18
+
19
+ export interface TransactionProgressTexts {
20
+ pending: string;
21
+ completed: string;
22
+ failed: string;
23
+ }
24
+
25
+ export interface TransactionProgressRenderProps extends TransactionProgressContextValue {
26
+ texts: TransactionProgressTexts;
27
+ }
28
+
29
+ export interface TransactionProgressProps extends Omit<ComponentProps<'div'>, 'children'> {
30
+ /** BOC of the transaction to strictly track status */
31
+ boc: string;
32
+ /** Render props function for full control over rendering */
33
+ children?: (props: TransactionProgressRenderProps) => ReactNode;
34
+ /** Allows targeting specific internal elements for styling */
35
+ classNames?: {
36
+ container?: string;
37
+ icon?: string;
38
+ message?: string;
39
+ };
40
+ }
41
+
42
+ export const TransactionProgressContent: FC<Omit<TransactionProgressProps, 'boc'>> = ({
43
+ children,
44
+ className,
45
+ classNames = {},
46
+ ...props
47
+ }) => {
48
+ const context = useTransactionProgressContext();
49
+ const { status, onchainMessages, totalMessages, error } = context;
50
+ const { t } = useI18n();
51
+
52
+ const texts = useMemo(
53
+ () => ({
54
+ pending: t('transaction.status.pending'),
55
+ completed: t('transaction.status.completed'),
56
+ failed: t('transaction.status.failed'),
57
+ }),
58
+ [t],
59
+ );
60
+
61
+ if (children) {
62
+ return <>{children({ ...context, texts })}</>;
63
+ }
64
+
65
+ const isPending = status === 'pending' && !error;
66
+ const isCompleted = status === 'completed';
67
+ const isFailed = status === 'failed' || !!error;
68
+
69
+ let messageText = texts.pending;
70
+ if (isCompleted) messageText = texts.completed;
71
+ if (isFailed) messageText = texts.failed;
72
+
73
+ let progressText = null;
74
+ if (isPending && totalMessages > 0) {
75
+ progressText = `(${onchainMessages} / ${totalMessages})`;
76
+ }
77
+
78
+ return (
79
+ <div className={clsx(styles.container, className, classNames.container)} {...props}>
80
+ <div className={clsx(styles.iconContainer, classNames.icon)}>
81
+ <TransactionProgressIcon status={status} isError={!!error} />
82
+ </div>
83
+
84
+ <div className={clsx(styles.message, classNames.message)}>
85
+ {messageText} {progressText}
86
+ </div>
87
+ </div>
88
+ );
89
+ };
90
+
91
+ export const TransactionProgress: FC<TransactionProgressProps> = ({ boc, ...rest }) => {
92
+ return (
93
+ <TransactionProgressProvider boc={boc}>
94
+ <TransactionProgressContent {...rest} />
95
+ </TransactionProgressProvider>
96
+ );
97
+ };
@@ -0,0 +1,55 @@
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 {
10
+ GetTransactionStatusData,
11
+ GetTransactionStatusErrorType,
12
+ GetTransactionStatusParameters,
13
+ GetTransactionStatusQueryConfig,
14
+ } from '@ton/appkit/queries';
15
+ import { getTransactionStatusQueryOptions } from '@ton/appkit/queries';
16
+
17
+ import { useQuery } from '../../../libs/query';
18
+ import type { UseQueryReturnType } from '../../../libs/query';
19
+ import { useAppKit } from '../../../hooks/use-app-kit';
20
+
21
+ export type UseTransactionStatusParameters<selectData = GetTransactionStatusData> = GetTransactionStatusParameters &
22
+ GetTransactionStatusQueryConfig<selectData>;
23
+
24
+ export type UseTransactionStatusReturnType<selectData = GetTransactionStatusData> = UseQueryReturnType<
25
+ selectData,
26
+ GetTransactionStatusErrorType
27
+ >;
28
+
29
+ /**
30
+ * Hook to get the status of a transaction trace by BOC.
31
+ *
32
+ * This hook polls the toncenter API to track the progress of a transaction trace.
33
+ * It is useful for tracking complex operations like swaps or multi-step flows.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const { data: status } = useTransactionStatus({
38
+ * boc: 'te6cc...',
39
+ * query: {
40
+ * refetchInterval: 2000, // Poll every 2 seconds
41
+ * }
42
+ * });
43
+ *
44
+ * if (status?.status === 'pending') {
45
+ * console.log(`Progress: ${status.completedMessages}/${status.totalMessages}`);
46
+ * }
47
+ * ```
48
+ */
49
+ export const useTransactionStatus = <selectData = GetTransactionStatusData>(
50
+ parameters: UseTransactionStatusParameters<selectData>,
51
+ ): UseTransactionStatusReturnType<selectData> => {
52
+ const appKit = useAppKit();
53
+
54
+ return useQuery(getTransactionStatusQueryOptions(appKit, parameters));
55
+ };
@@ -8,5 +8,7 @@
8
8
 
9
9
  export * from './hooks/use-send-transaction';
10
10
  export * from './hooks/use-transfer-ton';
11
+ export * from './hooks/use-transaction-status';
11
12
 
12
13
  export * from './components/transaction';
14
+ export * from './components/transaction-progress';
package/src/locales/en.ts CHANGED
@@ -19,6 +19,11 @@ export default {
19
19
  transaction: {
20
20
  sendTransaction: 'Send Transaction',
21
21
  processing: 'Processing...',
22
+ status: {
23
+ pending: 'Processing...',
24
+ completed: 'Success',
25
+ failed: 'Failed',
26
+ },
22
27
  },
23
28
 
24
29
  // Balances
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Block } from './block';
3
- const meta = {
4
- title: 'Private/Components/Block',
5
- component: Block,
6
- tags: ['autodocs'],
7
- argTypes: {
8
- direction: {
9
- control: 'radio',
10
- options: ['row', 'column'],
11
- },
12
- },
13
- };
14
- export default meta;
15
- export const Column = {
16
- args: {
17
- direction: 'column',
18
- children: (_jsxs(_Fragment, { children: [_jsx("div", { style: { padding: '8px', background: '#0098EB', color: 'white' }, children: "Item 1" }), _jsx("div", { style: { padding: '8px', background: '#0098EB', color: 'white' }, children: "Item 2" }), _jsx("div", { style: { padding: '8px', background: '#0098EB', color: 'white' }, children: "Item 3" })] })),
19
- },
20
- };
21
- export const Row = {
22
- args: {
23
- direction: 'row',
24
- children: (_jsxs(_Fragment, { children: [_jsx("div", { style: { padding: '8px', background: '#0098EB', color: 'white' }, children: "Item 1" }), _jsx("div", { style: { padding: '8px', background: '#0098EB', color: 'white' }, children: "Item 2" }), _jsx("div", { style: { padding: '8px', background: '#0098EB', color: 'white' }, children: "Item 3" })] })),
25
- },
26
- };
27
- //# sourceMappingURL=block.stories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"block.stories.js","sourceRoot":"","sources":["../../../../src/components/block/block.stories.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,IAAI,GAAuB;IAC7B,KAAK,EAAE,0BAA0B;IACjC,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACN,SAAS,EAAE;YACP,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;SAC7B;KACJ;CACJ,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,MAAM,GAAU;IACzB,IAAI,EAAE;QACF,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,CACN,8BACI,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAc,EACnF,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAc,EACnF,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAc,IACpF,CACN;KACJ;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAU;IACtB,IAAI,EAAE;QACF,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,CACN,8BACI,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAc,EACnF,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAc,EACnF,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAc,IACpF,CACN;KACJ;CACJ,CAAC"}
@@ -1,30 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button } from './button';
3
- const meta = {
4
- title: 'Public/Components/Button',
5
- component: Button,
6
- tags: ['autodocs'],
7
- argTypes: {
8
- disabled: {
9
- control: 'boolean',
10
- },
11
- },
12
- };
13
- export default meta;
14
- export const Default = {
15
- args: {
16
- children: 'Click me',
17
- },
18
- };
19
- export const Disabled = {
20
- args: {
21
- children: 'Disabled Button',
22
- disabled: true,
23
- },
24
- };
25
- export const WithIcon = {
26
- args: {
27
- children: (_jsxs(_Fragment, { children: [_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 5V19M5 12H19", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), "Add Item"] })),
28
- },
29
- };
30
- //# sourceMappingURL=button.stories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"button.stories.js","sourceRoot":"","sources":["../../../../src/components/button/button.stories.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,IAAI,GAAwB;IAC9B,KAAK,EAAE,0BAA0B;IACjC,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACN,QAAQ,EAAE;YACN,OAAO,EAAE,SAAS;SACrB;KACJ;CACJ,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,OAAO,GAAU;IAC1B,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU;KACvB;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC3B,IAAI,EAAE;QACF,QAAQ,EAAE,iBAAiB;QAC3B,QAAQ,EAAE,IAAI;KACjB;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC3B,IAAI,EAAE;QACF,QAAQ,EAAE,CACN,8BACI,cAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,4BAA4B,YAC1F,eACI,CAAC,EAAC,kBAAkB,EACpB,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACxB,GACA,gBAEP,CACN;KACJ;CACJ,CAAC"}