@0xsquid/deposit-widget 0.1.0 → 0.1.1-beta.1
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/dist/types/DepositWidget.d.ts +1 -0
- package/dist/types/components/ViewTransition.d.ts +1 -0
- package/dist/types/components/shared/buttons/button.d.ts +1 -0
- package/dist/types/components/shared/icons/types.d.ts +1 -0
- package/dist/types/components/shared/icons/user-round.d.ts +1 -0
- package/dist/types/components/shared/navigation/base-navbar.d.ts +1 -0
- package/dist/types/components/shared/navigation/sub-navbar.d.ts +1 -0
- package/dist/types/components/token-badge-icon.d.ts +1 -0
- package/dist/types/components/token-list-item.d.ts +1 -0
- package/dist/types/components/view-container.d.ts +1 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/hooks/ui/useMainCTAButtonState.d.ts +1 -0
- package/dist/types/hooks/use-auto-select-token.d.ts +1 -0
- package/dist/types/hooks/use-deposit-route.d.ts +1 -0
- package/dist/types/hooks/use-token-selection.d.ts +1 -0
- package/dist/types/hooks/use-transaction-history.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/services/assets-service.d.ts +1 -0
- package/dist/types/services/wallet-history/format.d.ts +1 -0
- package/dist/types/services/wallet-history/format.test.d.ts +1 -0
- package/dist/types/services/wallet-history/get-main-explorer-url.d.ts +1 -0
- package/dist/types/services/wallet-history/get-wallet-history.d.ts +1 -0
- package/dist/types/services/wallet-history/types.d.ts +1 -0
- package/dist/types/services/wallet-history/validation.d.ts +1 -0
- package/dist/types/store/use-deposit-store.d.ts +1 -0
- package/dist/types/store/use-input-mode.d.ts +1 -0
- package/dist/types/store/useRouter.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils/format-date.d.ts +1 -0
- package/dist/types/utils/format-date.test.d.ts +1 -0
- package/dist/types/utils/transaction.d.ts +1 -0
- package/dist/types/views/connect-wallet/connect-wallet-view.d.ts +1 -0
- package/dist/types/views/connect-wallet/wallet-list-item.d.ts +1 -0
- package/dist/types/views/main/amount-input.d.ts +1 -0
- package/dist/types/views/main/connect-prompt.d.ts +1 -0
- package/dist/types/views/main/deposit-amount-input.d.ts +1 -0
- package/dist/types/views/main/deposit-form.d.ts +1 -0
- package/dist/types/views/main/main-cta-button.d.ts +1 -0
- package/dist/types/views/main/main-view.d.ts +1 -0
- package/dist/types/views/main/navbar/actions.d.ts +1 -0
- package/dist/types/views/main/navbar/icon.d.ts +1 -0
- package/dist/types/views/main/navbar/navbar.d.ts +1 -0
- package/dist/types/views/main/navbar/title.d.ts +1 -0
- package/dist/types/views/main/recipient/account.d.ts +1 -0
- package/dist/types/views/main/recipient/recipient.d.ts +1 -0
- package/dist/types/views/main/token-selector.d.ts +1 -0
- package/dist/types/views/qr-code.d.ts +1 -0
- package/dist/types/views/render-view.d.ts +1 -0
- package/dist/types/views/select-chain/chain-type-meta.d.ts +1 -0
- package/dist/types/views/select-chain/select-chain-view.d.ts +1 -0
- package/dist/types/views/select-token.d.ts +1 -0
- package/dist/types/views/transaction-history/activity-list-item.d.ts +1 -0
- package/dist/types/views/transaction-history/transaction-history-view.d.ts +1 -0
- package/dist/types/views/transaction-progress/helpers.d.ts +1 -0
- package/dist/types/views/transaction-progress/transaction-progress-view.d.ts +1 -0
- package/dist/types/views/transaction-progress/use-transaction-progress.d.ts +1 -0
- package/package.json +7 -7
- package/src/DepositWidget.tsx +0 -158
- package/src/compiled-tailwind.css +0 -6100
- package/src/components/ViewTransition.tsx +0 -81
- package/src/components/shared/buttons/button.tsx +0 -17
- package/src/components/shared/icons/types.ts +0 -3
- package/src/components/shared/icons/user-round.tsx +0 -21
- package/src/components/shared/navigation/base-navbar.tsx +0 -15
- package/src/components/shared/navigation/sub-navbar.tsx +0 -46
- package/src/components/token-badge-icon.tsx +0 -31
- package/src/components/token-list-item.tsx +0 -84
- package/src/components/view-container.tsx +0 -16
- package/src/constants.ts +0 -1
- package/src/css.d.ts +0 -4
- package/src/fonts/DMSans-Variable.woff2 +0 -0
- package/src/hooks/ui/useMainCTAButtonState.ts +0 -143
- package/src/hooks/use-auto-select-token.ts +0 -65
- package/src/hooks/use-deposit-route.ts +0 -58
- package/src/hooks/use-token-selection.ts +0 -17
- package/src/hooks/use-transaction-history.ts +0 -198
- package/src/index.ts +0 -3
- package/src/services/assets-service.ts +0 -21
- package/src/services/wallet-history/format.test.ts +0 -63
- package/src/services/wallet-history/format.ts +0 -128
- package/src/services/wallet-history/get-main-explorer-url.ts +0 -74
- package/src/services/wallet-history/get-wallet-history.ts +0 -24
- package/src/services/wallet-history/types.ts +0 -66
- package/src/services/wallet-history/validation.ts +0 -60
- package/src/store/use-deposit-store.ts +0 -20
- package/src/store/use-input-mode.ts +0 -10
- package/src/store/useRouter.ts +0 -49
- package/src/tailwind.css +0 -16
- package/src/types.ts +0 -39
- package/src/utils/format-date.test.ts +0 -32
- package/src/utils/format-date.ts +0 -25
- package/src/utils/transaction.ts +0 -39
- package/src/views/connect-wallet/connect-wallet-view.tsx +0 -147
- package/src/views/connect-wallet/wallet-list-item.tsx +0 -69
- package/src/views/main/amount-input.tsx +0 -272
- package/src/views/main/connect-prompt.tsx +0 -47
- package/src/views/main/deposit-amount-input.tsx +0 -42
- package/src/views/main/deposit-form.tsx +0 -13
- package/src/views/main/main-cta-button.tsx +0 -14
- package/src/views/main/main-view.tsx +0 -24
- package/src/views/main/navbar/actions.tsx +0 -25
- package/src/views/main/navbar/icon.tsx +0 -11
- package/src/views/main/navbar/navbar.tsx +0 -16
- package/src/views/main/navbar/title.tsx +0 -64
- package/src/views/main/recipient/account.tsx +0 -81
- package/src/views/main/recipient/recipient.tsx +0 -64
- package/src/views/main/token-selector.tsx +0 -77
- package/src/views/qr-code.tsx +0 -14
- package/src/views/render-view.tsx +0 -28
- package/src/views/select-chain/chain-type-meta.ts +0 -37
- package/src/views/select-chain/select-chain-view.tsx +0 -97
- package/src/views/select-token.tsx +0 -227
- package/src/views/transaction-history/activity-list-item.tsx +0 -87
- package/src/views/transaction-history/transaction-history-view.tsx +0 -58
- package/src/views/transaction-progress/helpers.tsx +0 -93
- package/src/views/transaction-progress/transaction-progress-view.tsx +0 -217
- package/src/views/transaction-progress/use-transaction-progress.ts +0 -112
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
getBridgeType,
|
|
4
|
-
simplifyRouteAction,
|
|
5
|
-
TransactionErrorType,
|
|
6
|
-
TransactionStatus,
|
|
7
|
-
useEstimate,
|
|
8
|
-
useSwap,
|
|
9
|
-
useSwapTransactionStatus,
|
|
10
|
-
useTransactionStore,
|
|
11
|
-
} from "@0xsquid/react-hooks";
|
|
12
|
-
import { useDepositRoute } from "../../hooks/use-deposit-route";
|
|
13
|
-
import { getMainExplorerUrl } from "../../services/wallet-history/get-main-explorer-url";
|
|
14
|
-
import { useDepositStore } from "../../store/use-deposit-store";
|
|
15
|
-
|
|
16
|
-
export enum DepositStatus {
|
|
17
|
-
CONFIRMING,
|
|
18
|
-
PROCESSING,
|
|
19
|
-
COMPLETED,
|
|
20
|
-
PARTIAL_SUCCESS,
|
|
21
|
-
REJECTED,
|
|
22
|
-
FAILED,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function useTransactionProgress() {
|
|
26
|
-
const currentTransaction = useTransactionStore(
|
|
27
|
-
(state) => state.currentTransaction,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const { routeData } = useDepositRoute();
|
|
31
|
-
const { fromChain } = useSwap();
|
|
32
|
-
const { estimatedRouteDuration } = useEstimate(routeData);
|
|
33
|
-
const config = useDepositStore((s) => s.config);
|
|
34
|
-
|
|
35
|
-
const { latestStatus, transactionStatusQuery } = useSwapTransactionStatus({
|
|
36
|
-
transaction: {
|
|
37
|
-
fromAddress: currentTransaction?.fromAddress ?? "",
|
|
38
|
-
fromChain: currentTransaction?.fromChain?.chainId ?? "",
|
|
39
|
-
toChain: currentTransaction?.toChain?.chainId ?? "",
|
|
40
|
-
transactionId: currentTransaction?.transactionId ?? "",
|
|
41
|
-
status: currentTransaction?.status ?? TransactionStatus.PENDING,
|
|
42
|
-
bridgeType: getBridgeType(routeData?.estimate.actions),
|
|
43
|
-
actions: routeData?.estimate.actions,
|
|
44
|
-
transactionIdForStatus: currentTransaction?.transactionIdForStatus,
|
|
45
|
-
quoteId: currentTransaction?.quoteId,
|
|
46
|
-
depositTxVerificationSignature:
|
|
47
|
-
currentTransaction?.depositTxVerificationSignature,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const status = useMemo<DepositStatus>(() => {
|
|
52
|
-
if (currentTransaction === undefined) {
|
|
53
|
-
return DepositStatus.CONFIRMING;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
currentTransaction.error?.type === TransactionErrorType.REJECTED_BY_USER
|
|
58
|
-
) {
|
|
59
|
-
return DepositStatus.REJECTED;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (currentTransaction.sourceStatus === "error") {
|
|
63
|
-
return DepositStatus.FAILED;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (latestStatus === TransactionStatus.SUCCESS) {
|
|
67
|
-
return DepositStatus.COMPLETED;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
latestStatus === TransactionStatus.PARTIAL_SUCCESS ||
|
|
72
|
-
latestStatus === TransactionStatus.REFUNDED
|
|
73
|
-
) {
|
|
74
|
-
return DepositStatus.PARTIAL_SUCCESS;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (latestStatus === TransactionStatus.ERROR) {
|
|
78
|
-
return DepositStatus.FAILED;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
latestStatus === TransactionStatus.ONGOING ||
|
|
83
|
-
latestStatus === TransactionStatus.INITIAL_LOADING ||
|
|
84
|
-
latestStatus === TransactionStatus.PENDING
|
|
85
|
-
) {
|
|
86
|
-
return DepositStatus.PROCESSING;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return DepositStatus.CONFIRMING;
|
|
90
|
-
}, [currentTransaction, latestStatus]);
|
|
91
|
-
|
|
92
|
-
const explorerLink = getMainExplorerUrl({
|
|
93
|
-
routeType: currentTransaction?.routeType,
|
|
94
|
-
transactionId: currentTransaction?.transactionId,
|
|
95
|
-
sourceTxExplorerUrl: currentTransaction?.sourceTxExplorerUrl,
|
|
96
|
-
statusResponse: transactionStatusQuery.data,
|
|
97
|
-
actions: routeData?.estimate.actions?.map(simplifyRouteAction),
|
|
98
|
-
sourceChain: fromChain,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
status,
|
|
103
|
-
explorerLink,
|
|
104
|
-
estimatedTime: estimatedRouteDuration
|
|
105
|
-
? `~${estimatedRouteDuration.format()}`
|
|
106
|
-
: undefined,
|
|
107
|
-
recipient: {
|
|
108
|
-
name: config?.integrator.name ?? "Recipient",
|
|
109
|
-
address: config?.destinationAddress ?? "",
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
}
|