@imtbl/checkout-widgets 2.0.0-alpha.9 → 2.0.0
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/browser/{AddTokensWidget-DF8aiUpz.js → AddTokensWidget-C32-7Pge.js} +16 -396
- package/dist/browser/{BridgeWidget-DIU9Cxmn.js → BridgeWidget-DHmmZrLe.js} +23 -23
- package/dist/browser/{CommerceWidget-CKAKFkix.js → CommerceWidget-DinG6S2H.js} +161 -161
- package/dist/browser/{FeesBreakdown-BgEzlEIT.js → FeesBreakdown-CVvm1-Ei.js} +1 -1
- package/dist/browser/{OnRampWidget-Bve5vLzE.js → OnRampWidget-B54_6G-f.js} +5 -5
- package/dist/browser/{SaleWidget-CKWdID6Y.js → SaleWidget-Cuen5aW7.js} +53 -53
- package/dist/browser/{SpendingCapHero-HDVNFS4r.js → SpendingCapHero-DQtmoqNL.js} +1 -1
- package/dist/browser/SwapWidget-j_nEgqk4.js +1907 -0
- package/dist/browser/{TokenImage-DU_Cg9yk.js → TokenImage-Bc62Xkzv.js} +1 -1
- package/dist/browser/{TopUpView-DbE6wlUQ.js → TopUpView-Q4_Glu5-.js} +4 -4
- package/dist/browser/{WalletApproveHero-BKgdFRbV.js → WalletApproveHero-B6YvvCmA.js} +25 -5
- package/dist/browser/{WalletWidget-D370JeUN.js → WalletWidget-B0Up4Cre.js} +14 -14
- package/dist/browser/{auto-track-gJcTpwWh.js → auto-track-CaL-84Ic.js} +1 -1
- package/dist/browser/{index-BzdV0KgJ.js → index-BI7vXlHL.js} +1 -1
- package/dist/browser/{index-DeP8dLpv.js → index-BVzeDoH7.js} +1 -1
- package/dist/browser/{index-CcF1_qRd.js → index-BtnAkpe9.js} +1 -1
- package/dist/browser/{index-BB_EeO8_.js → index-CBO9u-8Q.js} +1 -12
- package/dist/browser/{index-C_yzaB0L.js → index-Cl7BUGHV.js} +2 -2
- package/dist/browser/{index-Q-a_-G_9.js → index-Hh-ME3UA.js} +1 -1
- package/dist/browser/{index-CSHKiSiI.js → index-JHffH8Bm.js} +1 -1
- package/dist/browser/{index-Bizu61HY.js → index-Skcajiao.js} +14521 -50813
- package/dist/browser/index.cdn.js +3262 -39764
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-oUBivosK.js → index.umd-C0PZl9Xk.js} +1 -1
- package/dist/browser/{useInterval-D7lTeYwU.js → useInterval-D2CM0YwW.js} +1 -1
- package/dist/types/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptions.d.ts +2 -1
- package/dist/types/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptionsDrawer.d.ts +2 -1
- package/dist/types/widgets/swap/GeoblockLoader.d.ts +1 -1
- package/dist/types/widgets/swap/SwapWidget.d.ts +1 -1
- package/dist/types/widgets/swap/SwapWidgetRoot.d.ts +0 -2
- package/package.json +13 -14
- package/rollup.config.js +42 -23
- package/src/components/CoinSelector/CoinSelector.tsx +63 -16
- package/src/lib/metrics.ts +4 -3
- package/src/locales/en.json +2 -1
- package/src/locales/ja.json +2 -1
- package/src/locales/ko.json +1 -0
- package/src/locales/zh.json +2 -1
- package/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/FiatOption.tsx +0 -1
- package/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptions.tsx +18 -1
- package/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptionsDrawer.tsx +8 -1
- package/src/widgets/purchase/views/Purchase.tsx +2 -0
- package/src/widgets/swap/GeoblockLoader.tsx +3 -1
- package/src/widgets/swap/SwapWidget.tsx +216 -153
- package/src/widgets/swap/SwapWidgetRoot.tsx +17 -80
- package/src/widgets/swap/components/SwapForm.tsx +66 -4
- package/dist/browser/SwapWidget-CPcceA1Y.js +0 -1738
- package/tsup.config.js +0 -58
package/dist/browser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { dW as WidgetsFactory } from './index-Skcajiao.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as reactExports,
|
|
1
|
+
import { r as reactExports, dp as useBrowserLayoutEffect } from './index-Skcajiao.js';
|
|
2
2
|
|
|
3
3
|
// Inspired by https://usehooks-ts.com/react-hook/use-interval
|
|
4
4
|
function useInterval(callback, delay) {
|
|
@@ -8,6 +8,7 @@ export interface OptionsProps {
|
|
|
8
8
|
onCardClick: (type: FiatOptionType) => void;
|
|
9
9
|
onRouteClick: (route: RouteData, index: number) => void;
|
|
10
10
|
onDirectCryptoPayClick: (route: DirectCryptoPayData, index: number) => void;
|
|
11
|
+
onChangeWalletClick: () => void;
|
|
11
12
|
routes?: RouteData[];
|
|
12
13
|
size?: MenuItemSize;
|
|
13
14
|
showOnrampOption?: boolean;
|
|
@@ -17,4 +18,4 @@ export interface OptionsProps {
|
|
|
17
18
|
selectedRouteType: SquidRouteOptionType | DirectCryptoPayOptionType | undefined;
|
|
18
19
|
directCryptoPayRoutes?: DirectCryptoPayData[];
|
|
19
20
|
}
|
|
20
|
-
export declare function RouteOptions({ checkout, routes, chains, onCardClick, onRouteClick, onDirectCryptoPayClick, size, showOnrampOption, showDirectCryptoPayOption, insufficientBalance, selectedIndex, selectedRouteType, directCryptoPayRoutes, }: OptionsProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function RouteOptions({ checkout, routes, chains, onCardClick, onRouteClick, onDirectCryptoPayClick, onChangeWalletClick, size, showOnrampOption, showDirectCryptoPayOption, insufficientBalance, selectedIndex, selectedRouteType, directCryptoPayRoutes, }: OptionsProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/types/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptionsDrawer.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type OptionsDrawerProps = {
|
|
|
10
10
|
onRouteClick: (route: RouteData) => void;
|
|
11
11
|
onCardClick: (type: FiatOptionType) => void;
|
|
12
12
|
onDirectCryptoPayClick: (route: DirectCryptoPayData) => void;
|
|
13
|
+
onChangeWalletClick: () => void;
|
|
13
14
|
showOnrampOption?: boolean;
|
|
14
15
|
showDirectCryptoPayOption?: boolean;
|
|
15
16
|
showSwapOption?: boolean;
|
|
@@ -17,5 +18,5 @@ type OptionsDrawerProps = {
|
|
|
17
18
|
insufficientBalance?: boolean;
|
|
18
19
|
directCryptoPayRoutes?: DirectCryptoPayData[];
|
|
19
20
|
};
|
|
20
|
-
export declare function RouteOptionsDrawer({ checkout, routes, chains, visible, onClose, onRouteClick, onCardClick, onDirectCryptoPayClick, showOnrampOption, showDirectCryptoPayOption, showSwapOption, showBridgeOption, insufficientBalance, directCryptoPayRoutes, }: OptionsDrawerProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function RouteOptionsDrawer({ checkout, routes, chains, visible, onClose, onRouteClick, onCardClick, onDirectCryptoPayClick, onChangeWalletClick, showOnrampOption, showDirectCryptoPayOption, showSwapOption, showBridgeOption, insufficientBalance, directCryptoPayRoutes, }: OptionsDrawerProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -2,7 +2,7 @@ import { Checkout } from '@imtbl/checkout-sdk';
|
|
|
2
2
|
type GeoblockLoaderParams = {
|
|
3
3
|
widget: React.ReactNode;
|
|
4
4
|
serviceUnavailableView: React.ReactNode;
|
|
5
|
-
checkout
|
|
5
|
+
checkout?: Checkout;
|
|
6
6
|
};
|
|
7
7
|
export declare function GeoblockLoader({ widget, serviceUnavailableView, checkout, }: GeoblockLoaderParams): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -3,4 +3,4 @@ import { StrongCheckoutWidgetsConfig } from '../../lib/withDefaultWidgetConfig';
|
|
|
3
3
|
export type SwapWidgetInputs = SwapWidgetParams & {
|
|
4
4
|
config: StrongCheckoutWidgetsConfig;
|
|
5
5
|
};
|
|
6
|
-
export default function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProceed, direction, showBackButton, }: SwapWidgetInputs): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProceed, direction, showBackButton, walletProviderName, }: SwapWidgetInputs): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,5 @@ export declare class Swap extends Base<WidgetType.SWAP> {
|
|
|
4
4
|
protected eventTopic: IMTBLWidgetEvents;
|
|
5
5
|
protected getValidatedProperties({ config }: WidgetProperties<WidgetType.SWAP>): WidgetProperties<WidgetType.SWAP>;
|
|
6
6
|
protected getValidatedParameters(params: SwapWidgetParams): SwapWidgetParams;
|
|
7
|
-
private isNotPassport;
|
|
8
|
-
private topUpOptions;
|
|
9
7
|
protected render(): void;
|
|
10
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/checkout-widgets",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"browserslist": {
|
|
5
5
|
"production": [
|
|
6
6
|
">0.2%",
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
"@0xsquid/sdk": "^2.8.25",
|
|
18
18
|
"@biom3/design-tokens": "^0.4.5",
|
|
19
19
|
"@biom3/react": "^0.29.4",
|
|
20
|
-
"@
|
|
21
|
-
"@imtbl/
|
|
22
|
-
"@imtbl/
|
|
23
|
-
"@imtbl/
|
|
24
|
-
"@imtbl/
|
|
25
|
-
"@imtbl/
|
|
20
|
+
"@emotion/react": "^11.11.3",
|
|
21
|
+
"@imtbl/bridge-sdk": "2.0.0",
|
|
22
|
+
"@imtbl/checkout-sdk": "2.0.0",
|
|
23
|
+
"@imtbl/config": "2.0.0",
|
|
24
|
+
"@imtbl/cryptofiat": "2.0.0",
|
|
25
|
+
"@imtbl/dex-sdk": "2.0.0",
|
|
26
|
+
"@imtbl/passport": "2.0.0",
|
|
26
27
|
"@imtbl/react-analytics": "0.3.2-alpha",
|
|
27
28
|
"@rive-app/react-canvas-lite": "^4.9.0",
|
|
28
29
|
"@walletconnect/ethereum-provider": "^2.11.1",
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
"@rollup/plugin-json": "^6.1.0",
|
|
50
51
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
51
52
|
"@rollup/plugin-replace": "^5.0.7",
|
|
52
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
53
53
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
54
54
|
"@segment/analytics-next": "^1.53.2",
|
|
55
55
|
"@svgr/webpack": "^8.0.1",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"@types/react": "^18.3.5",
|
|
64
64
|
"@types/react-dom": "^18.3.0",
|
|
65
65
|
"@types/uuid": "^8.3.4",
|
|
66
|
-
"esbuild-plugins-node-modules-polyfill": "^1.6.7",
|
|
67
66
|
"eslint": "^8.40.0",
|
|
68
67
|
"jest": "^29.4.3",
|
|
69
68
|
"jest-environment-jsdom": "^29.4.3",
|
|
@@ -71,10 +70,9 @@
|
|
|
71
70
|
"rimraf": "^6.0.1",
|
|
72
71
|
"rollup": "^4.22.4",
|
|
73
72
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
74
|
-
"terser": "^5.34.1",
|
|
75
73
|
"ts-jest": "^29.1.0",
|
|
76
|
-
"tsup": "8.3.0",
|
|
77
74
|
"typescript": "^5.6.2",
|
|
75
|
+
"unplugin-swc": "^1.5.1",
|
|
78
76
|
"web-vitals": "^2.1.4"
|
|
79
77
|
},
|
|
80
78
|
"exports": {
|
|
@@ -101,15 +99,16 @@
|
|
|
101
99
|
"type": "module",
|
|
102
100
|
"types": "./dist/types/index.d.ts",
|
|
103
101
|
"scripts": {
|
|
104
|
-
"build": "rollup --config rollup.config.js && pnpm typegen",
|
|
105
|
-
"transpile": "
|
|
102
|
+
"build": "NODE_ENV=production rollup --config rollup.config.js && pnpm typegen",
|
|
103
|
+
"transpile": "rollup --config rollup.config.js",
|
|
106
104
|
"typegen": "tsc --customConditions default --emitDeclarationOnly --outDir dist/types",
|
|
105
|
+
"pack:root": "pnpm pack --pack-destination $(dirname $(pnpm root -w))",
|
|
107
106
|
"build:local": "pnpm build && mkdir -p ../widgets-sample-app/public/lib/js && cp dist/browser/*.js ../widgets-sample-app/public/lib/js/",
|
|
108
107
|
"lint": "eslint ./src --ext .ts,.jsx,.tsx --max-warnings=0",
|
|
109
108
|
"lint:fix": "eslint ./src --ext .ts,.jsx,.tsx --max-warnings=0 --fix",
|
|
110
109
|
"prepare:examplewidgets": "pnpm --filter @examples/commerce-widget-nextjs exec mkdir -p tests/utils/local-widgets-js/ && cp ./dist/browser/*.js $(pnpm --filter @examples/commerce-widget-nextjs exec pwd)/tests/utils/local-widgets-js/",
|
|
111
110
|
"prepare:testwidgets": "pnpm --filter @tests/checkout-widgets-nextjs exec mkdir -p tests/utils/local-widgets-js/ && cp ./dist/browser/*.js $(pnpm --filter @tests/checkout-widgets-nextjs exec pwd)/tests/utils/local-widgets-js/",
|
|
112
|
-
"start": "NODE_ENV=development
|
|
111
|
+
"start": "NODE_ENV=development rollup --config rollup.config.js --watch",
|
|
113
112
|
"test": "jest test --passWithNoTests",
|
|
114
113
|
"test:watch": "jest test --passWithNoTests --watch",
|
|
115
114
|
"typecheck": "tsc --customConditions default --customConditions \"default\" --noEmit"
|
package/rollup.config.js
CHANGED
|
@@ -1,29 +1,46 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import typescript from '@rollup/plugin-typescript';
|
|
3
2
|
import commonjs from '@rollup/plugin-commonjs';
|
|
4
3
|
import resolve from '@rollup/plugin-node-resolve';
|
|
5
4
|
import json from '@rollup/plugin-json';
|
|
6
5
|
import replace from '@rollup/plugin-replace';
|
|
7
6
|
import nodePolyfills from 'rollup-plugin-polyfill-node';
|
|
8
|
-
import
|
|
7
|
+
import swc from 'unplugin-swc'
|
|
9
8
|
|
|
10
9
|
const PRODUCTION = 'production';
|
|
11
10
|
|
|
11
|
+
const isProduction = process.env.NODE_ENV === PRODUCTION
|
|
12
|
+
|
|
13
|
+
const defaultPlugins = [
|
|
14
|
+
json(),
|
|
15
|
+
replace({
|
|
16
|
+
preventAssignment: true,
|
|
17
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || PRODUCTION),
|
|
18
|
+
}),
|
|
19
|
+
isProduction ? typescript({customConditions: ["default"], declaration: false, outDir: 'dist/browser'})
|
|
20
|
+
: swc.rollup({ jsc: {
|
|
21
|
+
transform: { react: { development: true, runtime: 'automatic' }},
|
|
22
|
+
} }),
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
const productionPlugins = [
|
|
26
|
+
resolve({
|
|
27
|
+
browser: true,
|
|
28
|
+
dedupe: ['react', 'react-dom'],
|
|
29
|
+
exportConditions: ['default']
|
|
30
|
+
}),
|
|
31
|
+
nodePolyfills(),
|
|
32
|
+
commonjs(),
|
|
33
|
+
|
|
34
|
+
]
|
|
35
|
+
|
|
12
36
|
const getPlugins = () => {
|
|
37
|
+
if (process.env.NODE_ENV !== PRODUCTION) {
|
|
38
|
+
return defaultPlugins;
|
|
39
|
+
}
|
|
40
|
+
|
|
13
41
|
return [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
preventAssignment: true,
|
|
17
|
-
'process.env.NODE_ENV': PRODUCTION,
|
|
18
|
-
}),
|
|
19
|
-
typescript({customConditions: ["default"], declaration: false, outDir: 'dist/browser'}),
|
|
20
|
-
resolve({
|
|
21
|
-
browser: true,
|
|
22
|
-
dedupe: ['react', 'react-dom'],
|
|
23
|
-
exportConditions: ['default']
|
|
24
|
-
}),
|
|
25
|
-
nodePolyfills(),
|
|
26
|
-
commonjs(),
|
|
42
|
+
...defaultPlugins,
|
|
43
|
+
...productionPlugins
|
|
27
44
|
];
|
|
28
45
|
}
|
|
29
46
|
|
|
@@ -36,22 +53,24 @@ export default [
|
|
|
36
53
|
output: {
|
|
37
54
|
dir: 'dist/browser',
|
|
38
55
|
format: 'es',
|
|
56
|
+
inlineDynamicImports: !isProduction
|
|
39
57
|
},
|
|
40
58
|
plugins: [
|
|
41
59
|
...getPlugins(),
|
|
42
60
|
]
|
|
43
61
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
...(process.env.NODE_ENV === PRODUCTION ? [
|
|
63
|
+
{
|
|
64
|
+
input: 'src/index.ts',
|
|
65
|
+
output: {
|
|
66
|
+
file: 'dist/browser/index.cdn.js',
|
|
67
|
+
format: 'umd',
|
|
68
|
+
name: 'ImmutableCheckoutWidgets',
|
|
69
|
+
inlineDynamicImports: true
|
|
51
70
|
},
|
|
52
71
|
context: 'window',
|
|
53
72
|
plugins: [
|
|
54
73
|
...getPlugins(),
|
|
55
74
|
]
|
|
56
|
-
}
|
|
75
|
+
}] : []),
|
|
57
76
|
]
|
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
Drawer,
|
|
4
4
|
Box,
|
|
5
5
|
MenuItem,
|
|
6
|
+
TextInput,
|
|
6
7
|
} from '@biom3/react';
|
|
7
8
|
import { useTranslation } from 'react-i18next';
|
|
9
|
+
import { useMemo, useState } from 'react';
|
|
8
10
|
import { CoinSelectorOption, CoinSelectorOptionProps } from './CoinSelectorOption';
|
|
9
11
|
import { selectOptionsContainerStyles, selectOptionsLoadingIconStyles } from './CoinSelectorStyles';
|
|
10
12
|
|
|
@@ -18,12 +20,38 @@ type CoinSelectorProps = {
|
|
|
18
20
|
visible?: boolean;
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
const filterOptions = (filterBy: string, options: CoinSelectorOptionProps[]) => {
|
|
24
|
+
const filterByLower = filterBy.toLowerCase();
|
|
25
|
+
return options.filter((option) => option.name.toLowerCase().includes(filterByLower)
|
|
26
|
+
|| option.symbol.toLowerCase().includes(filterByLower)
|
|
27
|
+
|| option.id.toLowerCase().endsWith(filterByLower));
|
|
28
|
+
};
|
|
29
|
+
|
|
21
30
|
export function CoinSelector({
|
|
22
31
|
heading, options, defaultTokenImage, optionsLoading, children, onCloseDrawer, visible,
|
|
23
32
|
}: CoinSelectorProps) {
|
|
24
33
|
const { t } = useTranslation();
|
|
34
|
+
|
|
35
|
+
const [searchValue, setSearchValue] = useState<string>('');
|
|
36
|
+
|
|
37
|
+
const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
38
|
+
setSearchValue(event.target.value);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const filteredOptions = useMemo(() => {
|
|
42
|
+
if (!searchValue) {
|
|
43
|
+
return options;
|
|
44
|
+
}
|
|
45
|
+
return filterOptions(searchValue, options);
|
|
46
|
+
}, [options, searchValue, filterOptions]);
|
|
47
|
+
|
|
48
|
+
const handleCloseDrawer = () => {
|
|
49
|
+
setSearchValue('');
|
|
50
|
+
onCloseDrawer?.();
|
|
51
|
+
};
|
|
52
|
+
|
|
25
53
|
return (
|
|
26
|
-
<Drawer headerBarTitle={heading} size="full" onCloseDrawer={
|
|
54
|
+
<Drawer headerBarTitle={heading} size="full" onCloseDrawer={handleCloseDrawer} visible={visible}>
|
|
27
55
|
<Drawer.Target>
|
|
28
56
|
{children}
|
|
29
57
|
</Drawer.Target>
|
|
@@ -41,21 +69,40 @@ export function CoinSelector({
|
|
|
41
69
|
{t('drawers.coinSelector.noCoins')}
|
|
42
70
|
</Body>
|
|
43
71
|
)}
|
|
44
|
-
{!optionsLoading
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
{/* Add a search box when !optionsLoading */}
|
|
73
|
+
{!optionsLoading ? (
|
|
74
|
+
<>
|
|
75
|
+
<TextInput
|
|
76
|
+
sx={{ marginBottom: 'base.spacing.x4', minWidth: '100%' }}
|
|
77
|
+
testId="search-text"
|
|
78
|
+
onChange={(event) => handleOnChange(event)}
|
|
79
|
+
sizeVariant="large"
|
|
80
|
+
value={searchValue}
|
|
81
|
+
inputMode="search"
|
|
82
|
+
placeholder="name/symbol/contract address"
|
|
83
|
+
onClearValue={() => setSearchValue('')}
|
|
84
|
+
hideClearValueButton={false}
|
|
85
|
+
autoFocus
|
|
86
|
+
>
|
|
87
|
+
<TextInput.Icon icon="Search" />
|
|
88
|
+
</TextInput>
|
|
89
|
+
{filteredOptions.map(({
|
|
90
|
+
onClick, icon, name, symbol, balance, id, testId,
|
|
91
|
+
}) => (
|
|
92
|
+
<CoinSelectorOption
|
|
93
|
+
id={id}
|
|
94
|
+
testId={testId}
|
|
95
|
+
key={`${symbol}-${name}`}
|
|
96
|
+
onClick={onClick}
|
|
97
|
+
icon={icon}
|
|
98
|
+
name={name}
|
|
99
|
+
symbol={symbol}
|
|
100
|
+
balance={balance}
|
|
101
|
+
defaultTokenImage={defaultTokenImage}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</>
|
|
105
|
+
) : null}
|
|
59
106
|
</Box>
|
|
60
107
|
</Drawer.Content>
|
|
61
108
|
</Drawer>
|
package/src/lib/metrics.ts
CHANGED
|
@@ -10,9 +10,10 @@ export const withMetrics = <T>(
|
|
|
10
10
|
return fn(flow);
|
|
11
11
|
} catch (error) {
|
|
12
12
|
if (error instanceof Error) {
|
|
13
|
-
trackError('commerce', flowName, error);
|
|
13
|
+
trackError('commerce', flowName, error, { flowId: flow.details.flowId });
|
|
14
|
+
} else {
|
|
15
|
+
flow.addEvent('errored');
|
|
14
16
|
}
|
|
15
|
-
flow.addEvent('errored');
|
|
16
17
|
throw error;
|
|
17
18
|
} finally {
|
|
18
19
|
flow.addEvent('End');
|
|
@@ -33,7 +34,7 @@ export const withMetricsAsync = async <T>(
|
|
|
33
34
|
return await fn(flow);
|
|
34
35
|
} catch (error:any) {
|
|
35
36
|
if (error instanceof Error) {
|
|
36
|
-
trackError('commerce', flowName, error);
|
|
37
|
+
trackError('commerce', flowName, error, { flowId: flow.details.flowId });
|
|
37
38
|
}
|
|
38
39
|
if (errorType && errorType(error)) {
|
|
39
40
|
flow.addEvent(`errored_${errorType(error)}`);
|
package/src/locales/en.json
CHANGED
|
@@ -909,7 +909,7 @@
|
|
|
909
909
|
"drawer": {
|
|
910
910
|
"options": {
|
|
911
911
|
"heading": "Pay from",
|
|
912
|
-
"moreOptionsDividerText": "
|
|
912
|
+
"moreOptionsDividerText": "Other ways to Pay",
|
|
913
913
|
"loadingText1": "Finding the best value",
|
|
914
914
|
"loadingText2": "across all chains",
|
|
915
915
|
"noRoutes": {
|
|
@@ -921,6 +921,7 @@
|
|
|
921
921
|
"caption": "Swap tokens on this network.",
|
|
922
922
|
"disabledCaption": "Currently not available."
|
|
923
923
|
},
|
|
924
|
+
"changeWallet": "Choose another wallet",
|
|
924
925
|
"debit": {
|
|
925
926
|
"heading": "Debit Card",
|
|
926
927
|
"caption": "",
|
package/src/locales/ja.json
CHANGED
|
@@ -892,7 +892,7 @@
|
|
|
892
892
|
"drawer": {
|
|
893
893
|
"options": {
|
|
894
894
|
"heading": "支払い元",
|
|
895
|
-
"moreOptionsDividerText": "
|
|
895
|
+
"moreOptionsDividerText": "その他の支払い方法",
|
|
896
896
|
"loadingText1": "最適な価値を検索中",
|
|
897
897
|
"loadingText2": "すべてのチェーンを横断",
|
|
898
898
|
"noRoutes": {
|
|
@@ -904,6 +904,7 @@
|
|
|
904
904
|
"caption": "このネットワークでトークンを交換します。",
|
|
905
905
|
"disabledCaption": "現在利用できません。"
|
|
906
906
|
},
|
|
907
|
+
"changeWallet": "別のウォレットを選択",
|
|
907
908
|
"debit": {
|
|
908
909
|
"heading": "デビットカード",
|
|
909
910
|
"caption": "",
|
package/src/locales/ko.json
CHANGED
package/src/locales/zh.json
CHANGED
|
@@ -889,7 +889,7 @@
|
|
|
889
889
|
"drawer": {
|
|
890
890
|
"options": {
|
|
891
891
|
"heading": "支付来源",
|
|
892
|
-
"moreOptionsDividerText": "
|
|
892
|
+
"moreOptionsDividerText": "其他支付方式",
|
|
893
893
|
"loadingText1": "寻找最佳价值",
|
|
894
894
|
"loadingText2": "跨所有链",
|
|
895
895
|
"noRoutes": {
|
|
@@ -901,6 +901,7 @@
|
|
|
901
901
|
"caption": "在此网络上交换代币。",
|
|
902
902
|
"disabledCaption": "当前不可用。"
|
|
903
903
|
},
|
|
904
|
+
"changeWallet": "选择另一个钱包",
|
|
904
905
|
"debit": {
|
|
905
906
|
"heading": "借记卡",
|
|
906
907
|
"caption": "",
|
|
@@ -25,6 +25,7 @@ export interface OptionsProps {
|
|
|
25
25
|
onCardClick: (type: FiatOptionType) => void;
|
|
26
26
|
onRouteClick: (route: RouteData, index: number) => void;
|
|
27
27
|
onDirectCryptoPayClick: (route: DirectCryptoPayData, index: number) => void;
|
|
28
|
+
onChangeWalletClick: () => void;
|
|
28
29
|
routes?: RouteData[];
|
|
29
30
|
size?: MenuItemSize;
|
|
30
31
|
showOnrampOption?: boolean;
|
|
@@ -42,6 +43,7 @@ export function RouteOptions({
|
|
|
42
43
|
onCardClick,
|
|
43
44
|
onRouteClick,
|
|
44
45
|
onDirectCryptoPayClick,
|
|
46
|
+
onChangeWalletClick,
|
|
45
47
|
size,
|
|
46
48
|
showOnrampOption,
|
|
47
49
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -137,11 +139,26 @@ export function RouteOptions({
|
|
|
137
139
|
|
|
138
140
|
{!routes?.length && !insufficientBalance && renderLoading()}
|
|
139
141
|
|
|
140
|
-
{showOnrampOption && (
|
|
142
|
+
{showOnrampOption && (routes?.length || insufficientBalance) && (
|
|
141
143
|
<>
|
|
142
144
|
<Divider size="xSmall" sx={{ my: 'base.spacing.x2' }}>
|
|
143
145
|
{t('views.PURCHASE.drawer.options.moreOptionsDividerText')}
|
|
144
146
|
</Divider>
|
|
147
|
+
<MenuItem
|
|
148
|
+
emphasized
|
|
149
|
+
onClick={onChangeWalletClick}
|
|
150
|
+
size="small"
|
|
151
|
+
>
|
|
152
|
+
<MenuItem.FramedIcon
|
|
153
|
+
icon="Wallet"
|
|
154
|
+
variant="bold"
|
|
155
|
+
emphasized={false}
|
|
156
|
+
/>
|
|
157
|
+
<MenuItem.Label>
|
|
158
|
+
{t('views.PURCHASE.drawer.options.changeWallet')}
|
|
159
|
+
</MenuItem.Label>
|
|
160
|
+
</MenuItem>
|
|
161
|
+
|
|
145
162
|
{defaultFiatOptions.map((type, idx) => (
|
|
146
163
|
<FiatOption
|
|
147
164
|
key={`fiat-option-${type}`}
|
|
@@ -25,6 +25,7 @@ type OptionsDrawerProps = {
|
|
|
25
25
|
onRouteClick: (route: RouteData) => void;
|
|
26
26
|
onCardClick: (type: FiatOptionType) => void;
|
|
27
27
|
onDirectCryptoPayClick: (route: DirectCryptoPayData) => void;
|
|
28
|
+
onChangeWalletClick: () => void;
|
|
28
29
|
showOnrampOption?: boolean;
|
|
29
30
|
showDirectCryptoPayOption?: boolean;
|
|
30
31
|
showSwapOption?: boolean;
|
|
@@ -42,6 +43,7 @@ export function RouteOptionsDrawer({
|
|
|
42
43
|
onRouteClick,
|
|
43
44
|
onCardClick,
|
|
44
45
|
onDirectCryptoPayClick,
|
|
46
|
+
onChangeWalletClick,
|
|
45
47
|
showOnrampOption,
|
|
46
48
|
showDirectCryptoPayOption,
|
|
47
49
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -77,6 +79,11 @@ export function RouteOptionsDrawer({
|
|
|
77
79
|
onDirectCryptoPayClick(route);
|
|
78
80
|
};
|
|
79
81
|
|
|
82
|
+
const handleOnChangeWalletClick = () => {
|
|
83
|
+
onClose();
|
|
84
|
+
onChangeWalletClick();
|
|
85
|
+
};
|
|
86
|
+
|
|
80
87
|
useEffect(() => {
|
|
81
88
|
if (!visible) {
|
|
82
89
|
return;
|
|
@@ -132,7 +139,6 @@ export function RouteOptionsDrawer({
|
|
|
132
139
|
sx={{ c: 'inherit', fontSize: 'inherit' }}
|
|
133
140
|
/>
|
|
134
141
|
</MenuItem.Caption>
|
|
135
|
-
|
|
136
142
|
<MenuItem.StatefulButtCon icon="ChevronExpand" onClick={onClose} />
|
|
137
143
|
</MenuItem>
|
|
138
144
|
<RouteOptions
|
|
@@ -143,6 +149,7 @@ export function RouteOptionsDrawer({
|
|
|
143
149
|
onCardClick={onCardClick}
|
|
144
150
|
onRouteClick={handleOnRouteClick}
|
|
145
151
|
onDirectCryptoPayClick={handleOnDirectCryptoPayClick}
|
|
152
|
+
onChangeWalletClick={handleOnChangeWalletClick}
|
|
146
153
|
showOnrampOption={showOnrampOption}
|
|
147
154
|
showDirectCryptoPayOption={showDirectCryptoPayOption}
|
|
148
155
|
insufficientBalance={insufficientBalance}
|
|
@@ -693,12 +693,14 @@ export function Purchase({
|
|
|
693
693
|
chains={chains}
|
|
694
694
|
showSwapOption={showSwapOption}
|
|
695
695
|
showBridgeOption={showBridgeOption}
|
|
696
|
+
showOnrampOption={shouldShowOnRampOption}
|
|
696
697
|
showDirectCryptoPayOption
|
|
697
698
|
visible={showOptionsDrawer}
|
|
698
699
|
onClose={() => setShowOptionsDrawer(false)}
|
|
699
700
|
onCardClick={handlePayWithCardClick}
|
|
700
701
|
onRouteClick={handleRouteClick}
|
|
701
702
|
onDirectCryptoPayClick={handleDirectCryptoPayClick}
|
|
703
|
+
onChangeWalletClick={() => setShowPayWithWalletDrawer(true)}
|
|
702
704
|
insufficientBalance={insufficientBalance}
|
|
703
705
|
directCryptoPayRoutes={directCryptoPayRoutes}
|
|
704
706
|
/>
|
|
@@ -9,7 +9,7 @@ import { useHandover } from '../../lib/hooks/useHandover';
|
|
|
9
9
|
type GeoblockLoaderParams = {
|
|
10
10
|
widget: React.ReactNode;
|
|
11
11
|
serviceUnavailableView: React.ReactNode;
|
|
12
|
-
checkout
|
|
12
|
+
checkout?: Checkout,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export function GeoblockLoader({
|
|
@@ -23,6 +23,8 @@ export function GeoblockLoader({
|
|
|
23
23
|
const [available, setAvailable] = useState(false);
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
26
|
+
if (!checkout) return;
|
|
27
|
+
|
|
26
28
|
(async () => {
|
|
27
29
|
try {
|
|
28
30
|
showLoader({ text: t('views.LOADING_VIEW.text') });
|