@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
|
@@ -11,3 +11,4 @@ interface TokenListItemProps extends React.ComponentProps<"button"> {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function TokenListItem({ icon, chainIcon, symbol, name, balance, price, usdValue, disabled, isLoadingBalance, ...props }: TokenListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
14
|
+
//# sourceMappingURL=token-list-item.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export type TokenWithBalance = Token & {
|
|
|
4
4
|
};
|
|
5
5
|
export declare function sortTokensByBalance(tokens: TokenWithBalance[]): TokenWithBalance[];
|
|
6
6
|
export declare function filterTokensByChain(tokens: TokenWithBalance[], chainId: string | null): TokenWithBalance[];
|
|
7
|
+
//# sourceMappingURL=assets-service.d.ts.map
|
|
@@ -8,3 +8,4 @@ export interface DayGroup {
|
|
|
8
8
|
export declare function toFormattedTx(tx: SquidTransaction, sourceChain: ChainData | undefined): FormattedTx;
|
|
9
9
|
export declare function pendingSwapToFormattedTx(pending: SwapTransactionHistory, findToken: (address?: string, chainId?: string) => Token | undefined, findChain: (chainId: string | undefined) => ChainData | undefined): FormattedTx;
|
|
10
10
|
export declare function groupAndSortByDay(txs: FormattedTx[]): DayGroup[];
|
|
11
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -10,3 +10,4 @@ interface WidgetNavigationState {
|
|
|
10
10
|
export declare const selectCurrentView: (state: WidgetNavigationState) => WidgetView;
|
|
11
11
|
export declare const useRouter: import("zustand").UseBoundStore<import("zustand").StoreApi<WidgetNavigationState>>;
|
|
12
12
|
export {};
|
|
13
|
+
//# sourceMappingURL=useRouter.d.ts.map
|
package/dist/types/types.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export declare function matchesDestinationToken(toToken: {
|
|
|
8
8
|
chainId: string;
|
|
9
9
|
}, destinationToken: DepositConfig["destinationToken"]): boolean;
|
|
10
10
|
export declare function isPaymentTx(tx: SquidTransaction, paymentAmount: string, destinationTokenDecimals: number): boolean;
|
|
11
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -7,3 +7,4 @@ interface WalletListItemProps extends React.ComponentProps<"button"> {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function WalletListItem({ wallet, isConnecting, showAsMultiChain, parentProps, ...props }: WalletListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
10
|
+
//# sourceMappingURL=wallet-list-item.d.ts.map
|
|
@@ -8,3 +8,4 @@ interface AmountInputProps extends NumericInputProps {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function AmountInput({ balance, token, onAmountChange, forcedAmount, maxUsdDecimals, formatIfVerySmall, inputModeButton, debounceInput, allowMaxButton, readOnly, errorMessage, loading, forcedUsdDisplay, }: AmountInputProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
11
|
+
//# sourceMappingURL=amount-input.d.ts.map
|
|
@@ -2,3 +2,4 @@ import type { FormattedTx } from "../../services/wallet-history/types";
|
|
|
2
2
|
type Props = FormattedTx;
|
|
3
3
|
export declare function ActivityListItem({ fromAmount, fromToken, fromChain, toAmount, toToken, timestamp, status, explorer, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export {};
|
|
5
|
+
//# sourceMappingURL=activity-list-item.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsquid/deposit-widget",
|
|
3
3
|
"description": "Squid deposit widget",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1-beta.1",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/cjs/index.cjs",
|
|
13
13
|
"module": "dist/index.esm.js",
|
|
14
|
-
"types": "dist/index.d.ts",
|
|
14
|
+
"types": "dist/types/index.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./dist/index.d.ts",
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
18
|
"import": "./dist/index.esm.js",
|
|
19
19
|
"require": "./dist/cjs/index.cjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist",
|
|
24
|
-
"src"
|
|
25
|
-
],
|
|
26
22
|
"publishConfig": {
|
|
27
23
|
"access": "public"
|
|
28
24
|
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/**/*.d.ts.map"
|
|
28
|
+
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "yarn build-css && rollup -c",
|
|
31
31
|
"build-css": "tailwindcss -i ./src/tailwind.css -o ./src/compiled-tailwind.css",
|
package/src/DepositWidget.tsx
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
SquidProvider,
|
|
4
|
-
useAllConnectedWalletBalances,
|
|
5
|
-
useAllTransactionsStatus,
|
|
6
|
-
useSwap,
|
|
7
|
-
} from "@0xsquid/react-hooks";
|
|
8
|
-
import { darkTheme, lightTheme, ThemeProvider } from "@0xsquid/ui";
|
|
9
|
-
import type { Theme, ThemeType } from "@0xsquid/ui";
|
|
10
|
-
import compiledCss from "./compiled-tailwind.css";
|
|
11
|
-
import { selectCurrentView, useRouter } from "./store/useRouter";
|
|
12
|
-
import { ViewTransition } from "./components/ViewTransition";
|
|
13
|
-
import { renderView } from "./views/render-view";
|
|
14
|
-
import { useAutoSelectToken } from "./hooks/use-auto-select-token";
|
|
15
|
-
import { useDepositStore, usePaymentAmount } from "./store/use-deposit-store";
|
|
16
|
-
import type { DepositConfig } from "./types";
|
|
17
|
-
|
|
18
|
-
interface DepositWidgetProps {
|
|
19
|
-
config: DepositConfig;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function DepositWidget({
|
|
23
|
-
config,
|
|
24
|
-
}: DepositWidgetProps): React.ReactElement {
|
|
25
|
-
const { theme, themeType } = config;
|
|
26
|
-
return (
|
|
27
|
-
<SquidProvider
|
|
28
|
-
config={{ integratorId: config.integrator.id, apiUrl: config.apiUrl }}
|
|
29
|
-
placeholder={
|
|
30
|
-
<WidgetLayout theme={theme} themeType={themeType}>
|
|
31
|
-
<WidgetSkeleton />
|
|
32
|
-
</WidgetLayout>
|
|
33
|
-
}
|
|
34
|
-
>
|
|
35
|
-
<WidgetLayout theme={theme} themeType={themeType}>
|
|
36
|
-
<DepositWidgetContent config={config} />
|
|
37
|
-
</WidgetLayout>
|
|
38
|
-
</SquidProvider>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function DepositWidgetContent({
|
|
43
|
-
config,
|
|
44
|
-
}: {
|
|
45
|
-
config: DepositConfig;
|
|
46
|
-
}): React.ReactElement {
|
|
47
|
-
const currentView = useRouter(selectCurrentView);
|
|
48
|
-
const setConfig = useDepositStore((s) => s.setConfig);
|
|
49
|
-
const { onSwapChange, toAmountChanged, fromAmountChanged } = useSwap();
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
setConfig(config);
|
|
53
|
-
}, [config, setConfig]);
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
onSwapChange({
|
|
57
|
-
toChainId: config.destinationToken.chainId,
|
|
58
|
-
toTokenAddress: config.destinationToken.address,
|
|
59
|
-
destinationAddress: { address: config.destinationAddress },
|
|
60
|
-
});
|
|
61
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
-
}, [
|
|
63
|
-
config.destinationAddress,
|
|
64
|
-
config.destinationToken.chainId,
|
|
65
|
-
config.destinationToken.address,
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
const paymentAmount = usePaymentAmount();
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (paymentAmount) {
|
|
71
|
-
fromAmountChanged("");
|
|
72
|
-
toAmountChanged(paymentAmount);
|
|
73
|
-
} else {
|
|
74
|
-
toAmountChanged("");
|
|
75
|
-
fromAmountChanged("");
|
|
76
|
-
}
|
|
77
|
-
}, [paymentAmount, toAmountChanged, fromAmountChanged]);
|
|
78
|
-
|
|
79
|
-
useAutoSelectToken();
|
|
80
|
-
useAllConnectedWalletBalances(); // Pre-warm balance cache
|
|
81
|
-
// Polls /v2/status for pending txs — also what registers them with Squid's backend for /history/wallet
|
|
82
|
-
useAllTransactionsStatus({ enabled: true });
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<ViewTransition viewId={currentView.id}>
|
|
86
|
-
{renderView(currentView)}
|
|
87
|
-
</ViewTransition>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
interface WidgetLayoutProps {
|
|
92
|
-
theme?: Theme;
|
|
93
|
-
themeType?: ThemeType;
|
|
94
|
-
children: React.ReactNode;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function WidgetLayout({
|
|
98
|
-
theme,
|
|
99
|
-
themeType,
|
|
100
|
-
children,
|
|
101
|
-
}: WidgetLayoutProps): React.ReactElement {
|
|
102
|
-
const mergedTheme = useMemo<Theme>(() => {
|
|
103
|
-
const base = themeType === "dark" ? darkTheme : lightTheme;
|
|
104
|
-
const merged = { ...base.color, ...theme?.color };
|
|
105
|
-
return {
|
|
106
|
-
...base,
|
|
107
|
-
...theme,
|
|
108
|
-
fontFamily: {
|
|
109
|
-
...base.fontFamily,
|
|
110
|
-
"squid-main": '"DMSansVariable", sans-serif',
|
|
111
|
-
// Integrator override wins.
|
|
112
|
-
...theme?.fontFamily,
|
|
113
|
-
},
|
|
114
|
-
color: {
|
|
115
|
-
...merged,
|
|
116
|
-
"animation-bg": merged["grey-900"],
|
|
117
|
-
"animation-text": merged["animation-bg"] ?? merged["grey-900"],
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
}, [theme, themeType]);
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<ThemeProvider theme={mergedTheme} themeType={themeType}>
|
|
124
|
-
<style
|
|
125
|
-
id="squid-deposit-widget-inline-style"
|
|
126
|
-
dangerouslySetInnerHTML={{ __html: compiledCss }}
|
|
127
|
-
/>
|
|
128
|
-
<div className="squid-style-container--preflight tw-bg-grey-900 tw-text-grey-100 tw-flex tw-w-widget-card tw-h-widget-card tw-flex-col tw-items-center tw-shrink-0 tw-rounded-3xl tw-border tw-border-grey-900 dark:tw-shadow-widget-card-dark tw-shadow-widget-card-light tw-font-medium">
|
|
129
|
-
{children}
|
|
130
|
-
</div>
|
|
131
|
-
</ThemeProvider>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function WidgetSkeleton(): React.ReactElement {
|
|
136
|
-
return (
|
|
137
|
-
<div className="tw-flex tw-flex-col tw-flex-1 tw-w-full tw-animate-pulse">
|
|
138
|
-
{/* Connect-wallet content: logo + heading + description */}
|
|
139
|
-
<div className="tw-flex tw-pt-3 tw-pb-8 tw-px-4 tw-flex-col tw-justify-end tw-items-center tw-gap-4 tw-flex-1">
|
|
140
|
-
<div className="tw-w-32 tw-h-32 tw-rounded-full tw-bg-grey-800" />
|
|
141
|
-
|
|
142
|
-
<div className="tw-flex tw-pt-2 tw-pb-4 tw-flex-col tw-items-center tw-gap-4">
|
|
143
|
-
<div className="tw-h-6 tw-w-48 tw-rounded tw-bg-grey-800" />
|
|
144
|
-
<div className="tw-flex tw-flex-col tw-items-center tw-gap-2">
|
|
145
|
-
<div className="tw-h-4 tw-w-56 tw-rounded tw-bg-grey-800" />
|
|
146
|
-
<div className="tw-h-4 tw-w-40 tw-rounded tw-bg-grey-800" />
|
|
147
|
-
</div>
|
|
148
|
-
<div className="tw-h-4 tw-w-20 tw-rounded tw-bg-grey-800" />
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
|
|
152
|
-
{/* CTA button */}
|
|
153
|
-
<div className="tw-px-4 tw-pb-4">
|
|
154
|
-
<div className="tw-h-12 tw-w-full tw-rounded-full tw-bg-grey-800" />
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|