@imtbl/sdk 1.62.0 → 1.63.0-alpha.10
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/{blockchain_data-sxvR7yJA.js → blockchain_data-CAvjIRIV.js} +2 -2
- package/dist/blockchain_data.js +3 -3
- package/dist/browser/checkout/{AddFundsWidget-ZVSgslAw.js → AddTokensWidget-_RYa4euh.js} +190 -183
- package/dist/browser/checkout/{BridgeWidget-Cdho2hYD.js → BridgeWidget-BCC7YXWj.js} +9 -8
- package/dist/browser/checkout/{CommerceWidget-BzipzAPM.js → CommerceWidget-B4QxFLZq.js} +29 -28
- package/dist/browser/checkout/CryptoFiatProvider-b0KhVg3Y.js +224 -0
- package/dist/browser/checkout/{EllipsizedText-CvkYzx6o.js → EllipsizedText-CF9lzi6c.js} +1 -1
- package/dist/browser/checkout/{FeesBreakdown-2gL4cI-R.js → FeesBreakdown-BGnZxcX5.js} +1 -1
- package/dist/browser/checkout/{HandoverContent-Bl4qmdQg.js → HandoverContent-CESizLWk.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-QJuXcGjQ.js → OnRampWidget-BrGpM6Vn.js} +3 -3
- package/dist/browser/checkout/{SaleWidget-edWOlmfl.js → SaleWidget-iuigaIZp.js} +15 -26
- package/dist/browser/checkout/{SpendingCapHero-CqFT2_-Q.js → SpendingCapHero-B3sb2Wt1.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-gFL-1ypc.js → SwapWidget-CdXf4YYP.js} +9 -8
- package/dist/browser/checkout/{TopUpView-BQBIv4KK.js → TopUpView-Bg-huhcb.js} +6 -239
- package/dist/browser/checkout/{WalletApproveHero-CLTmvRwO.js → WalletApproveHero-DW6Uw6rT.js} +3 -3
- package/dist/browser/checkout/{WalletWidget-DqzlgTAL.js → WalletWidget-ChYjXfAy.js} +17 -32
- package/dist/browser/checkout/{auto-track-B_DVujaR.js → auto-track-CgS-wbin.js} +1 -1
- package/dist/browser/checkout/{index-DvBzy5DX.js → index-BjLYItcm.js} +72 -69
- package/dist/browser/checkout/{index-DitiTTnr.js → index-BqJ9Usxu.js} +1 -1
- package/dist/browser/checkout/{index-DYTK3G7G.js → index-C4anNRY5.js} +2 -2
- package/dist/browser/checkout/{index-B_wChk6v.js → index-CshBDuS0.js} +1 -1
- package/dist/browser/checkout/{index-CRuWUFZW.js → index-D6TVOnc2.js} +1 -1
- package/dist/browser/checkout/{index-BVEcFW11.js → index-DoYS_inI.js} +1 -1
- package/dist/browser/checkout/{index-yoSSDRdd.js → index-LCMExv1j.js} +1 -1
- package/dist/browser/checkout/{index-CgtLpuEZ.js → index-bNCjF_qE.js} +1 -1
- package/dist/browser/checkout/{index-BGasM3FI.js → index-qYOj-RwR.js} +1 -1
- package/dist/browser/checkout/{index.umd-5W8TJb-e.js → index.umd-CL6Tp5Ej.js} +1 -1
- package/dist/browser/checkout/{retry-Bd7qMg0v.js → retry-GJcGp5Sw.js} +1 -1
- package/dist/browser/checkout/sdk.js +15 -15
- package/dist/browser/checkout/{useInterval-DI0ddcnq.js → useInterval-BfG2xnz-.js} +1 -1
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +267 -296
- package/dist/{checkout-C12Br7lr.js → checkout-GzXHS6tQ.js} +22 -22
- package/dist/checkout.d.ts +50 -50
- package/dist/checkout.js +5 -5
- package/dist/{config-BR83WwI2.js → config-D--8q9Ky.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-DeyLbhnj.js → index-CS6nfOqN.js} +1 -1
- package/dist/{index-B12uBW7v.js → index-CTG8gj6p.js} +1 -1
- package/dist/{index-oQTMj48l.js → index-CUn7Zo3y.js} +1 -1
- package/dist/{index-o82oWSK6.js → index-CY5IMe_m.js} +1 -1
- package/dist/{index-CA86ogWz.js → index-D7sVu0uD.js} +3 -3
- package/dist/{index-B3-R16ZI.js → index-Papo4AAa.js} +4 -4
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +93 -23
- package/dist/index.d.ts +63 -63
- package/dist/index.js +14 -14
- package/dist/{minting_backend-BZNiHRmU.js → minting_backend-Clnkogn9.js} +3 -3
- package/dist/minting_backend.js +5 -5
- package/dist/{orderbook-B1Tjr_q4.js → orderbook-CZN-dE1t.js} +1 -1
- package/dist/orderbook.js +2 -2
- package/dist/{passport-BSNhvk09.js → passport-pc8TWhS9.js} +73 -3
- package/dist/passport.js +4 -4
- package/dist/{webhook-2lD6l4rk.js → webhook-r7AuAOkP.js} +1 -1
- package/dist/webhook.js +2 -2
- package/dist/{x-BuvtdpOp.js → x-LQ1vUAJM.js} +3 -3
- package/dist/x.js +4 -4
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as _objectWithoutProperties, x as useTheme, y as useForwardLocalDomRef, z as useGetSubcomponentChild, A as useSplitApartChildrenAndSubComponents, r as reactExports, D as merge$2, F as useResizeObserver, q as jsxs, j as jsx, G as SmartClone, H as Box, J as isChildSubcomponent, K as flattenChildren, M as Body, N as useTheme$1, Q as Icon, R as ButtCon, T as Button, U as _defineProperty, X as isDualVariantIcon, Y as _slicedToArray, Z as isNumberWithinTotal, $ as getStartingSize, a0 as BaseClickable, a1 as ClassNames, a2 as _toConsumableArray, a3 as isError, a4 as Badge, a5 as FramedIcon, a6 as FramedImage, a7 as FramedLogo, a8 as Stack, a9 as hFlex, aa as usePrevious, ab as useBrowserEffect, ac as getHeadingTextStyles, ad as vFlex, ae as centerFlexChildren, af as FormControlLabel, ag as FormControlValidation, ah as FormControlCaption, I as IMTBLWidgetEvents, ai as
|
|
2
|
-
import { f as formatUnits, p as parseUnits } from './index-
|
|
3
|
-
import { E as EllipsizedText, C as Contract } from './EllipsizedText-
|
|
4
|
-
import { r as retry, T as TokenImage } from './retry-
|
|
5
|
-
import { H as HandoverContent } from './HandoverContent-
|
|
6
|
-
import { F as FeesBreakdown } from './FeesBreakdown-
|
|
1
|
+
import { _ as _objectWithoutProperties, x as useTheme, y as useForwardLocalDomRef, z as useGetSubcomponentChild, A as useSplitApartChildrenAndSubComponents, r as reactExports, D as merge$2, F as useResizeObserver, q as jsxs, j as jsx, G as SmartClone, H as Box, J as isChildSubcomponent, K as flattenChildren, M as Body, N as useTheme$1, Q as Icon, R as ButtCon, T as Button, U as _defineProperty, X as isDualVariantIcon, Y as _slicedToArray, Z as isNumberWithinTotal, $ as getStartingSize, a0 as BaseClickable, a1 as ClassNames, a2 as _toConsumableArray, a3 as isError, a4 as Badge, a5 as FramedIcon, a6 as FramedImage, a7 as FramedLogo, a8 as Stack, a9 as hFlex, aa as usePrevious, ab as useBrowserEffect, ac as getHeadingTextStyles, ad as vFlex, ae as centerFlexChildren, af as FormControlLabel, ag as FormControlValidation, ah as FormControlCaption, I as IMTBLWidgetEvents, ai as AddTokensEventType, aj as getDefaultExportFromCjs, ak as commonjsGlobal, l as useTranslation, al as MenuItem, am as tokenValueFormat, an as DEFAULT_TOKEN_FORMATTING_DECIMALS, ao as BigNumber, ap as getRemoteVideo, aq as FramedVideo, ar as motion, as as listItemVariants, at as Divider, au as Fragment, av as listVariants, aw as useProvidersContext, ax as Drawer, ay as useAnalytics, az as UserJourney, aA as isPassportProvider, aB as Heading, aC as WalletDrawer, aD as UnableToConnectDrawer, aE as ChangedYourMindDrawer, aF as WalletProviderRdns, aG as getProviderSlugFromRdns, aH as Web3Provider, aI as connectEIP6963Provider, aJ as identifyUser, aK as ConnectEIP6963ProviderError, aL as ProvidersContextActions, aM as ViewContext, V as ViewActions, o as SharedViews, k as ChainId, aN as commonjsRequire, aO as getRemoteImage, aP as useHandover, aQ as HandoverTarget, aR as EventTargetContext, aS as getRemoteRive, aT as Trans, aU as Link, aV as useInjectedProviders, aW as getDefaultTokenImage, aX as OverflowDrawerMenu, aY as SimpleLayout, aZ as TokenFilterTypes, h as getL2ChainId, a_ as isNativeToken, a$ as getTokenImageByAddress, b0 as orchestrationEvents, b1 as requireSecp256k1$1, b2 as requireLib_commonjs, b3 as require$$0$2, b4 as bech32$2, b5 as bnExports$1, b6 as require$$0$3, b7 as getAugmentedNamespace, b8 as require$$0$4, b9 as minimalisticAssert, ba as require$$2, bb as hash$6, bc as MaxUint256, bd as merge$3, be as SvgIcon, bf as WalletWarningHero, bg as Environment, bh as t, bi as PriceDisplay, L as LoadingView, bj as viewReducer, bk as initialViewState, bl as isValidAddress, bm as amountInputValidation, bn as CloudImage, E as ErrorView, bo as ServiceUnavailableErrorView, bp as ServiceType } from './index-BjLYItcm.js';
|
|
2
|
+
import { f as formatUnits, p as parseUnits } from './index-CshBDuS0.js';
|
|
3
|
+
import { E as EllipsizedText, C as Contract } from './EllipsizedText-CF9lzi6c.js';
|
|
4
|
+
import { r as retry, T as TokenImage } from './retry-GJcGp5Sw.js';
|
|
5
|
+
import { H as HandoverContent } from './HandoverContent-CESizLWk.js';
|
|
6
|
+
import { F as FeesBreakdown } from './FeesBreakdown-BGnZxcX5.js';
|
|
7
7
|
|
|
8
8
|
var bannerSx = {
|
|
9
9
|
d: "flex",
|
|
@@ -1045,10 +1045,10 @@ HeroFormControl.Caption = FormControlCaption;
|
|
|
1045
1045
|
HeroFormControl.inputs = SUPPORTED_INPUT_COMPONENTS_MAP;
|
|
1046
1046
|
|
|
1047
1047
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1048
|
-
function
|
|
1049
|
-
const closeWidgetEvent = new CustomEvent(IMTBLWidgetEvents.
|
|
1048
|
+
function sendAddTokensCloseEvent(eventTarget) {
|
|
1049
|
+
const closeWidgetEvent = new CustomEvent(IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, {
|
|
1050
1050
|
detail: {
|
|
1051
|
-
type:
|
|
1051
|
+
type: AddTokensEventType.CLOSE_WIDGET,
|
|
1052
1052
|
data: {},
|
|
1053
1053
|
},
|
|
1054
1054
|
});
|
|
@@ -1059,9 +1059,9 @@ function sendAddFundsCloseEvent(eventTarget) {
|
|
|
1059
1059
|
eventTarget.dispatchEvent(closeWidgetEvent);
|
|
1060
1060
|
}
|
|
1061
1061
|
function sendConnectProviderSuccessEvent(eventTarget, providerType, provider, providerInfo) {
|
|
1062
|
-
const successEvent = new CustomEvent(IMTBLWidgetEvents.
|
|
1062
|
+
const successEvent = new CustomEvent(IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, {
|
|
1063
1063
|
detail: {
|
|
1064
|
-
type:
|
|
1064
|
+
type: AddTokensEventType.CONNECT_SUCCESS,
|
|
1065
1065
|
data: {
|
|
1066
1066
|
provider,
|
|
1067
1067
|
providerType,
|
|
@@ -1075,7 +1075,7 @@ function sendConnectProviderSuccessEvent(eventTarget, providerType, provider, pr
|
|
|
1075
1075
|
eventTarget.dispatchEvent(successEvent);
|
|
1076
1076
|
}
|
|
1077
1077
|
|
|
1078
|
-
const
|
|
1078
|
+
const initialAddTokensState = {
|
|
1079
1079
|
allowedTokens: null,
|
|
1080
1080
|
squid: null,
|
|
1081
1081
|
chains: null,
|
|
@@ -1087,73 +1087,73 @@ const initialAddFundsState = {
|
|
|
1087
1087
|
selectedAmount: '',
|
|
1088
1088
|
isSwapAvailable: false,
|
|
1089
1089
|
};
|
|
1090
|
-
var
|
|
1091
|
-
(function (
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
})(
|
|
1090
|
+
var AddTokensActions;
|
|
1091
|
+
(function (AddTokensActions) {
|
|
1092
|
+
AddTokensActions["SET_ALLOWED_TOKENS"] = "SET_ALLOWED_TOKENS";
|
|
1093
|
+
AddTokensActions["SET_SQUID"] = "SET_SQUID";
|
|
1094
|
+
AddTokensActions["SET_CHAINS"] = "SET_CHAINS";
|
|
1095
|
+
AddTokensActions["SET_BALANCES"] = "SET_BALANCES";
|
|
1096
|
+
AddTokensActions["SET_TOKENS"] = "SET_TOKENS";
|
|
1097
|
+
AddTokensActions["SET_ROUTES"] = "SET_ROUTES";
|
|
1098
|
+
AddTokensActions["SET_SELECTED_ROUTE_DATA"] = "SET_SELECTED_ROUTE_DATA";
|
|
1099
|
+
AddTokensActions["SET_SELECTED_TOKEN"] = "SET_SELECTED_TOKEN";
|
|
1100
|
+
AddTokensActions["SET_SELECTED_AMOUNT"] = "SET_SELECTED_AMOUNT";
|
|
1101
|
+
AddTokensActions["SET_IS_SWAP_AVAILABLE"] = "SET_IS_SWAP_AVAILABLE";
|
|
1102
|
+
})(AddTokensActions || (AddTokensActions = {}));
|
|
1103
1103
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
|
|
1104
|
+
const AddTokensContext = reactExports.createContext({
|
|
1105
|
+
addTokensState: initialAddTokensState,
|
|
1106
|
+
addTokensDispatch: () => { },
|
|
1107
1107
|
});
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1108
|
+
AddTokensContext.displayName = 'AddTokensContext';
|
|
1109
|
+
const addTokensReducer = (state, action) => {
|
|
1110
1110
|
switch (action.payload.type) {
|
|
1111
|
-
case
|
|
1111
|
+
case AddTokensActions.SET_ALLOWED_TOKENS:
|
|
1112
1112
|
return {
|
|
1113
1113
|
...state,
|
|
1114
1114
|
allowedTokens: action.payload.allowedTokens,
|
|
1115
1115
|
};
|
|
1116
|
-
case
|
|
1116
|
+
case AddTokensActions.SET_SQUID:
|
|
1117
1117
|
return {
|
|
1118
1118
|
...state,
|
|
1119
1119
|
squid: action.payload.squid,
|
|
1120
1120
|
};
|
|
1121
|
-
case
|
|
1121
|
+
case AddTokensActions.SET_CHAINS:
|
|
1122
1122
|
return {
|
|
1123
1123
|
...state,
|
|
1124
1124
|
chains: action.payload.chains,
|
|
1125
1125
|
};
|
|
1126
|
-
case
|
|
1126
|
+
case AddTokensActions.SET_BALANCES:
|
|
1127
1127
|
return {
|
|
1128
1128
|
...state,
|
|
1129
1129
|
balances: action.payload.balances,
|
|
1130
1130
|
};
|
|
1131
|
-
case
|
|
1131
|
+
case AddTokensActions.SET_TOKENS:
|
|
1132
1132
|
return {
|
|
1133
1133
|
...state,
|
|
1134
1134
|
tokens: action.payload.tokens,
|
|
1135
1135
|
};
|
|
1136
|
-
case
|
|
1136
|
+
case AddTokensActions.SET_ROUTES:
|
|
1137
1137
|
return {
|
|
1138
1138
|
...state,
|
|
1139
1139
|
routes: action.payload.routes,
|
|
1140
1140
|
};
|
|
1141
|
-
case
|
|
1141
|
+
case AddTokensActions.SET_SELECTED_ROUTE_DATA:
|
|
1142
1142
|
return {
|
|
1143
1143
|
...state,
|
|
1144
1144
|
selectedRouteData: action.payload.selectedRouteData,
|
|
1145
1145
|
};
|
|
1146
|
-
case
|
|
1146
|
+
case AddTokensActions.SET_SELECTED_TOKEN:
|
|
1147
1147
|
return {
|
|
1148
1148
|
...state,
|
|
1149
1149
|
selectedToken: action.payload.selectedToken,
|
|
1150
1150
|
};
|
|
1151
|
-
case
|
|
1151
|
+
case AddTokensActions.SET_SELECTED_AMOUNT:
|
|
1152
1152
|
return {
|
|
1153
1153
|
...state,
|
|
1154
1154
|
selectedAmount: action.payload.selectedAmount,
|
|
1155
1155
|
};
|
|
1156
|
-
case
|
|
1156
|
+
case AddTokensActions.SET_IS_SWAP_AVAILABLE:
|
|
1157
1157
|
return {
|
|
1158
1158
|
...state,
|
|
1159
1159
|
isSwapAvailable: action.payload.isSwapAvailable,
|
|
@@ -1163,12 +1163,12 @@ const addFundsReducer = (state, action) => {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
};
|
|
1165
1165
|
|
|
1166
|
-
var
|
|
1167
|
-
(function (
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
})(
|
|
1166
|
+
var AddTokensWidgetViews;
|
|
1167
|
+
(function (AddTokensWidgetViews) {
|
|
1168
|
+
AddTokensWidgetViews["ADD_TOKENS"] = "ADD_TOKENS";
|
|
1169
|
+
AddTokensWidgetViews["REVIEW"] = "REVIEW";
|
|
1170
|
+
AddTokensWidgetViews["GEO_BLOCK_ERROR"] = "GEO_BLOCK_ERROR";
|
|
1171
|
+
})(AddTokensWidgetViews || (AddTokensWidgetViews = {}));
|
|
1172
1172
|
|
|
1173
1173
|
/**
|
|
1174
1174
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -1563,20 +1563,20 @@ var RiveStateMachineInput;
|
|
|
1563
1563
|
RiveStateMachineInput[RiveStateMachineInput["COMPLETED"] = 3] = "COMPLETED";
|
|
1564
1564
|
RiveStateMachineInput[RiveStateMachineInput["ERROR"] = 4] = "ERROR";
|
|
1565
1565
|
})(RiveStateMachineInput || (RiveStateMachineInput = {}));
|
|
1566
|
-
var
|
|
1567
|
-
(function (
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
})(
|
|
1566
|
+
var AddTokensErrorTypes;
|
|
1567
|
+
(function (AddTokensErrorTypes) {
|
|
1568
|
+
AddTokensErrorTypes["DEFAULT"] = "DEFAULT_ERROR";
|
|
1569
|
+
AddTokensErrorTypes["INVALID_PARAMETERS"] = "INVALID_PARAMETERS";
|
|
1570
|
+
AddTokensErrorTypes["SERVICE_BREAKDOWN"] = "SERVICE_BREAKDOWN";
|
|
1571
|
+
AddTokensErrorTypes["TRANSACTION_FAILED"] = "TRANSACTION_FAILED";
|
|
1572
|
+
AddTokensErrorTypes["UNRECOGNISED_CHAIN"] = "UNRECOGNISED_CHAIN";
|
|
1573
|
+
AddTokensErrorTypes["PROVIDER_ERROR"] = "PROVIDER_ERROR";
|
|
1574
|
+
AddTokensErrorTypes["WALLET_FAILED"] = "WALLET_FAILED";
|
|
1575
|
+
AddTokensErrorTypes["WALLET_REJECTED"] = "WALLET_REJECTED";
|
|
1576
|
+
AddTokensErrorTypes["WALLET_REJECTED_NO_FUNDS"] = "WALLET_REJECTED_NO_FUNDS";
|
|
1577
|
+
AddTokensErrorTypes["WALLET_POPUP_BLOCKED"] = "WALLET_POPUP_BLOCKED";
|
|
1578
|
+
AddTokensErrorTypes["ENVIRONMENT_ERROR"] = "ENVIRONMENT_ERROR";
|
|
1579
|
+
})(AddTokensErrorTypes || (AddTokensErrorTypes = {}));
|
|
1580
1580
|
|
|
1581
1581
|
function FiatOption({ type, onClick, disabled = false, size = 'small', rc = jsx("span", {}), }) {
|
|
1582
1582
|
const { t } = useTranslation();
|
|
@@ -1594,7 +1594,7 @@ function FiatOption({ type, onClick, disabled = false, size = 'small', rc = jsx(
|
|
|
1594
1594
|
size,
|
|
1595
1595
|
rc,
|
|
1596
1596
|
};
|
|
1597
|
-
return (jsxs(MenuItem, { ...menuItemProps, children: [jsx(MenuItem.FramedIcon, { icon: icon[type], variant: "bold", emphasized: false }), jsx(MenuItem.Label, { children: t(`views.
|
|
1597
|
+
return (jsxs(MenuItem, { ...menuItemProps, children: [jsx(MenuItem.FramedIcon, { icon: icon[type], variant: "bold", emphasized: false }), jsx(MenuItem.Label, { children: t(`views.ADD_TOKENS.drawer.options.${type}.heading`) }), jsx(MenuItem.Caption, { children: t(`views.ADD_TOKENS.drawer.options.${type}.${disabled ? 'disabledCaption' : 'caption'}`) }), !disabled && jsx(MenuItem.IntentIcon, {})] }));
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
1600
|
function getDurationFormatted(estimatedRouteDuration) {
|
|
@@ -1695,6 +1695,7 @@ function getRouteAndTokenBalances(routeData) {
|
|
|
1695
1695
|
}
|
|
1696
1696
|
|
|
1697
1697
|
function RouteOption({ routeData, onClick, chains, disabled = false, isFastest = false, size = 'small', rc = jsx("span", {}), selected = false, }) {
|
|
1698
|
+
const { t } = useTranslation();
|
|
1698
1699
|
const { fromToken } = routeData.amountData;
|
|
1699
1700
|
const { estimate } = routeData.route.route;
|
|
1700
1701
|
const chain = chains?.find((c) => c.id === fromToken.chainId);
|
|
@@ -1712,7 +1713,7 @@ function RouteOption({ routeData, onClick, chains, disabled = false, isFastest =
|
|
|
1712
1713
|
size,
|
|
1713
1714
|
onClick: disabled ? undefined : handleClick,
|
|
1714
1715
|
};
|
|
1715
|
-
return (jsxs(MenuItem, { ...menuItemProps, children: [jsx(MenuItem.Label, { children: fromToken.name }), chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall" }), jsx(MenuItem.FramedImage, { circularFrame: true, use: jsx("img", { src: fromToken.iconUrl, alt: fromToken.name }) })] })), jsx(MenuItem.Caption, { children: `Balance
|
|
1716
|
+
return (jsxs(MenuItem, { ...menuItemProps, children: [jsx(MenuItem.Label, { children: fromToken.name }), chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall" }), jsx(MenuItem.FramedImage, { circularFrame: true, use: jsx("img", { src: fromToken.iconUrl, alt: fromToken.name }) })] })), jsx(MenuItem.Caption, { children: `Balance ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${routeBalanceUsd}` }), jsx(MenuItem.PriceDisplay, { price: fromAmount, children: jsx(MenuItem.PriceDisplay.Caption, { children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${fromAmountUsd}` }) }), jsxs(MenuItem.BottomSlot, { children: [jsx(MenuItem.BottomSlot.Divider, {}), jsxs(Stack, { rc: jsx("span", {}), direction: "row", justifyContent: "space-between", sx: {
|
|
1716
1717
|
w: '100%',
|
|
1717
1718
|
}, children: [jsxs(Body, { sx: {
|
|
1718
1719
|
...hFlex,
|
|
@@ -1722,7 +1723,7 @@ function RouteOption({ routeData, onClick, chains, disabled = false, isFastest =
|
|
|
1722
1723
|
}, size: "xSmall", children: [jsx(Icon, { icon: "Countdown", sx: {
|
|
1723
1724
|
w: 'base.icon.size.200',
|
|
1724
1725
|
fill: 'base.color.text.body.secondary',
|
|
1725
|
-
}, variant: "bold" }), estimatedDurationFormatted] }), jsxs(Body, { size: "xSmall", sx: { ...hFlex, ...centerFlexChildren }, children: [isFastest && (jsx(Badge, { badgeContent: "Fastest", variant: "emphasis", sx: { mr: 'base.spacing.x2' } })), `Fee
|
|
1726
|
+
}, variant: "bold" }), estimatedDurationFormatted] }), jsxs(Body, { size: "xSmall", sx: { ...hFlex, ...centerFlexChildren }, children: [isFastest && (jsx(Badge, { badgeContent: "Fastest", variant: "emphasis", sx: { mr: 'base.spacing.x2' } })), `Fee ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${getFormattedAmounts(totalFeesUsd)}`] })] })] })] }));
|
|
1726
1727
|
}
|
|
1727
1728
|
|
|
1728
1729
|
const defaultFiatOptions = [
|
|
@@ -1754,7 +1755,7 @@ function OptionsDrawer({ checkout, routes, visible, onClose, onRouteClick, onCar
|
|
|
1754
1755
|
showSwapOption,
|
|
1755
1756
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1756
1757
|
showBridgeOption, insufficientBalance, }) {
|
|
1757
|
-
const {
|
|
1758
|
+
const { addTokensState: { chains }, } = reactExports.useContext(AddTokensContext);
|
|
1758
1759
|
const { providersState: { fromProviderInfo, fromAddress }, } = useProvidersContext();
|
|
1759
1760
|
const selectedRouteIndex = reactExports.useRef(0);
|
|
1760
1761
|
const handleOnRouteClick = (route, index) => {
|
|
@@ -2424,12 +2425,13 @@ const sortRoutesByFastestTime = (routes) => {
|
|
|
2424
2425
|
const BASE_SLIPPAGE = 0.02;
|
|
2425
2426
|
const useRoutes = () => {
|
|
2426
2427
|
const latestRequestIdRef = reactExports.useRef(0);
|
|
2427
|
-
const {
|
|
2428
|
+
const { addTokensDispatch } = reactExports.useContext(AddTokensContext);
|
|
2429
|
+
const { providersState: { toProvider, }, } = useProvidersContext();
|
|
2428
2430
|
const { track } = useAnalytics();
|
|
2429
2431
|
const setRoutes = (routes) => {
|
|
2430
|
-
|
|
2432
|
+
addTokensDispatch({
|
|
2431
2433
|
payload: {
|
|
2432
|
-
type:
|
|
2434
|
+
type: AddTokensActions.SET_ROUTES,
|
|
2433
2435
|
routes,
|
|
2434
2436
|
},
|
|
2435
2437
|
});
|
|
@@ -2495,6 +2497,7 @@ const useRoutes = () => {
|
|
|
2495
2497
|
toAddress,
|
|
2496
2498
|
quoteOnly,
|
|
2497
2499
|
enableBoost: true,
|
|
2500
|
+
receiveGasOnDestination: !isPassportProvider(toProvider),
|
|
2498
2501
|
}), {
|
|
2499
2502
|
retryIntervalMs: 1000,
|
|
2500
2503
|
retries: 5,
|
|
@@ -2526,7 +2529,7 @@ const useRoutes = () => {
|
|
|
2526
2529
|
return { route: newRoute };
|
|
2527
2530
|
}
|
|
2528
2531
|
track({
|
|
2529
|
-
userJourney: UserJourney.
|
|
2532
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
2530
2533
|
screen: 'Routes',
|
|
2531
2534
|
action: 'Failed',
|
|
2532
2535
|
extras: {
|
|
@@ -2618,6 +2621,7 @@ function SelectedRouteOptionContainer({ children, onClick, selected, }) {
|
|
|
2618
2621
|
}, rc: jsx("span", { ...(onClick ? { onClick } : {}) }), children: children }));
|
|
2619
2622
|
}
|
|
2620
2623
|
function SelectedRouteOption({ checkout, routeData, chains, loading = false, withSelectedWallet = false, withSelectedToken = false, withSelectedAmount = false, insufficientBalance = false, showOnrampOption = false, onClick, }) {
|
|
2624
|
+
const { t } = useTranslation();
|
|
2621
2625
|
const { fromToken } = routeData?.amountData ?? {};
|
|
2622
2626
|
const chain = chains?.find((c) => c.id === fromToken?.chainId);
|
|
2623
2627
|
const { routeBalanceUsd, fromAmount, fromAmountUsd } = reactExports.useMemo(() => getRouteAndTokenBalances(routeData), [routeData]);
|
|
@@ -2654,7 +2658,7 @@ function SelectedRouteOption({ checkout, routeData, chains, loading = false, wit
|
|
|
2654
2658
|
}
|
|
2655
2659
|
return (jsxs(SelectedRouteOptionContainer, { onClick: handleOnClick, selected: withSelectedWallet, children: [jsx(MenuItem.FramedIcon, { icon: icon, variant: "bold", circularFrame: true, emphasized: false }), jsx(MenuItem.Caption, { children: copy })] }));
|
|
2656
2660
|
}
|
|
2657
|
-
return (jsxs(SelectedRouteOptionContainer, { onClick: handleOnClick, selected: withSelectedWallet, children: [chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall", sx: { bottom: 'base.spacing.x2', right: 'base.spacing.x2' } }), jsx(MenuItem.FramedImage, { circularFrame: true, padded: true, use: jsx("img", { src: fromToken?.iconUrl, alt: fromToken?.name }) })] })), jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { w: '100%' }, children: [jsxs(Stack, { gap: "0px", children: [jsx(MenuItem.Label, { children: fromToken?.name }), jsx(MenuItem.Caption, { children: `Balance
|
|
2661
|
+
return (jsxs(SelectedRouteOptionContainer, { onClick: handleOnClick, selected: withSelectedWallet, children: [chain && (jsxs(Sticker, { position: { x: 'right', y: 'bottom' }, children: [jsx(Sticker.FramedImage, { use: jsx("img", { src: chain.iconUrl, alt: chain.name }), size: "xSmall", sx: { bottom: 'base.spacing.x2', right: 'base.spacing.x2' } }), jsx(MenuItem.FramedImage, { circularFrame: true, padded: true, use: jsx("img", { src: fromToken?.iconUrl, alt: fromToken?.name }) })] })), jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { w: '100%' }, children: [jsxs(Stack, { gap: "0px", children: [jsx(MenuItem.Label, { children: fromToken?.name }), jsx(MenuItem.Caption, { children: `Balance ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${routeBalanceUsd}` })] }), jsx(MenuItem.PriceDisplay, { price: fromAmount, children: jsx(MenuItem.PriceDisplay.Caption, { children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${fromAmountUsd}` }) })] })] }));
|
|
2658
2662
|
}
|
|
2659
2663
|
|
|
2660
2664
|
const disabledStyles = {
|
|
@@ -2871,7 +2875,7 @@ function PayWithWalletDrawer({ visible, onClose, onConnect, onPayWithCard, walle
|
|
|
2871
2875
|
onPayWithCard?.();
|
|
2872
2876
|
}, children: [jsx(MenuItem.FramedIcon, { icon: "BankCard", variant: "bold", emphasized: false }), jsx(MenuItem.Label, { children: "Pay with Card" })] }));
|
|
2873
2877
|
}, [onClose, onPayWithCard]);
|
|
2874
|
-
return (jsx(ConnectWalletDrawer, { heading: insufficientBalance ? 'Choose another option' : '
|
|
2878
|
+
return (jsx(ConnectWalletDrawer, { heading: insufficientBalance ? 'Choose another option' : 'Send from', visible: visible, onClose: onClose, providerType: "from", walletOptions: walletOptions, disabledOptions: disabledOptions, bottomSlot: payWithCardItem, onConnect: handleOnConnect, onError: handleOnError }));
|
|
2875
2879
|
}
|
|
2876
2880
|
|
|
2877
2881
|
function convertToUsd(tokens, amount, token) {
|
|
@@ -5722,30 +5726,30 @@ var localforage = {exports: {}};
|
|
|
5722
5726
|
var localforageExports = localforage.exports;
|
|
5723
5727
|
var localForage = /*@__PURE__*/getDefaultExportFromCjs(localforageExports);
|
|
5724
5728
|
|
|
5725
|
-
const
|
|
5726
|
-
name: '
|
|
5729
|
+
const addTokensOnboardingCache = localForage.createInstance({
|
|
5730
|
+
name: 'AddTokens Onboarding State',
|
|
5727
5731
|
version: 1.0,
|
|
5728
5732
|
storeName: 'Internal state',
|
|
5729
|
-
description: 'A small IndexDB for storage of state relating to the
|
|
5733
|
+
description: 'A small IndexDB for storage of state relating to the AddTokens Onboarding Drawer',
|
|
5730
5734
|
});
|
|
5731
5735
|
const SEEN_ONBOARDING_KEY = 'seen-onboarding';
|
|
5732
5736
|
async function getCacheItem(key) {
|
|
5733
|
-
const data = await
|
|
5737
|
+
const data = await addTokensOnboardingCache.getItem(key);
|
|
5734
5738
|
if (!data)
|
|
5735
5739
|
return null;
|
|
5736
5740
|
const { value } = data;
|
|
5737
5741
|
return value;
|
|
5738
5742
|
}
|
|
5739
5743
|
async function setCacheItem(key, value) {
|
|
5740
|
-
return
|
|
5744
|
+
return addTokensOnboardingCache.setItem(key, {
|
|
5741
5745
|
value,
|
|
5742
5746
|
});
|
|
5743
5747
|
}
|
|
5744
5748
|
|
|
5745
5749
|
const HERO_IMAGES = [
|
|
5746
|
-
'/add-
|
|
5747
|
-
'/add-
|
|
5748
|
-
'/add-
|
|
5750
|
+
'/add-tokens-onboarding-1.svg',
|
|
5751
|
+
'/add-tokens-onboarding-2.svg',
|
|
5752
|
+
'/add-tokens-onboarding-3.svg',
|
|
5749
5753
|
];
|
|
5750
5754
|
function OnboardingDrawer({ environment }) {
|
|
5751
5755
|
const { t } = useTranslation();
|
|
@@ -5780,11 +5784,11 @@ function OnboardingDrawer({ environment }) {
|
|
|
5780
5784
|
alignItems: 'center',
|
|
5781
5785
|
textAlign: 'center',
|
|
5782
5786
|
px: 'base.spacing.x6',
|
|
5783
|
-
}, children: [jsx(Box, { rc: jsx("img", { src: src, alt: HERO_IMAGES[screenIndex - 1] }), sx: { userSelect: 'none' } }), jsx(Divider, { size: "xSmall", textAlign: "center", sx: { mt: 'base.spacing.x6', mb: 'base.spacing.x4' }, children: t(`views.
|
|
5787
|
+
}, children: [jsx(Box, { rc: jsx("img", { src: src, alt: HERO_IMAGES[screenIndex - 1] }), sx: { userSelect: 'none' } }), jsx(Divider, { size: "xSmall", textAlign: "center", sx: { mt: 'base.spacing.x6', mb: 'base.spacing.x4' }, children: t(`views.ADD_TOKENS.onboarding.screen${screenIndex}.caption`) }), jsx(Heading, { size: "small", sx: {
|
|
5784
5788
|
// @NOTE: this preserves newlines inside any strings, which
|
|
5785
5789
|
// come out of the translation layer
|
|
5786
5790
|
whiteSpace: 'pre-line',
|
|
5787
|
-
}, children: t(`views.
|
|
5791
|
+
}, children: t(`views.ADD_TOKENS.onboarding.screen${screenIndex}.title`) }), jsx(OnboardingPagination, { disabled: true, size: "small", currentPage: screenIndex, totalPages: 3, sx: { mt: 'base.spacing.x11', mb: 'base.spacing.x8' } }), jsx(Button, { variant: screenIndex === 3 ? 'primary' : 'tertiary', onClick: handleCtaOnClick, size: "large", sx: { alignSelf: 'stretch' }, children: t(`views.ADD_TOKENS.onboarding.screen${screenIndex}.buttonText`) })] }) }));
|
|
5788
5792
|
}
|
|
5789
5793
|
|
|
5790
5794
|
const useError = (environment) => {
|
|
@@ -5795,94 +5799,94 @@ const useError = (environment) => {
|
|
|
5795
5799
|
});
|
|
5796
5800
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
5797
5801
|
const closeWidget = () => {
|
|
5798
|
-
|
|
5802
|
+
sendAddTokensCloseEvent(eventTarget);
|
|
5799
5803
|
};
|
|
5800
|
-
const
|
|
5804
|
+
const goBackToAddTokensView = () => {
|
|
5801
5805
|
closeHandover();
|
|
5802
5806
|
viewDispatch({
|
|
5803
5807
|
payload: {
|
|
5804
5808
|
type: ViewActions.UPDATE_VIEW,
|
|
5805
5809
|
view: {
|
|
5806
|
-
type:
|
|
5810
|
+
type: AddTokensWidgetViews.ADD_TOKENS,
|
|
5807
5811
|
},
|
|
5808
5812
|
},
|
|
5809
5813
|
});
|
|
5810
5814
|
};
|
|
5811
5815
|
const errorConfig = {
|
|
5812
|
-
[
|
|
5816
|
+
[AddTokensErrorTypes.DEFAULT]: {
|
|
5813
5817
|
headingText: 'Sorry, something went wrong. Please try again later.',
|
|
5814
5818
|
secondaryButtonText: 'Close',
|
|
5815
5819
|
onSecondaryButtonClick: closeWidget,
|
|
5816
5820
|
},
|
|
5817
|
-
[
|
|
5821
|
+
[AddTokensErrorTypes.INVALID_PARAMETERS]: {
|
|
5818
5822
|
headingText: 'Invalid parameters',
|
|
5819
5823
|
subHeadingText: 'The widget parameters provided are invalid. Please check again.',
|
|
5820
5824
|
secondaryButtonText: 'Close',
|
|
5821
5825
|
onSecondaryButtonClick: closeWidget,
|
|
5822
5826
|
},
|
|
5823
|
-
[
|
|
5827
|
+
[AddTokensErrorTypes.SERVICE_BREAKDOWN]: {
|
|
5824
5828
|
headingText: 'Our system is currently down',
|
|
5825
5829
|
subHeadingText: 'We are currently experiencing technical difficulties. Please try again later.',
|
|
5826
5830
|
secondaryButtonText: 'Close',
|
|
5827
5831
|
onSecondaryButtonClick: closeWidget,
|
|
5828
5832
|
},
|
|
5829
|
-
[
|
|
5833
|
+
[AddTokensErrorTypes.TRANSACTION_FAILED]: {
|
|
5830
5834
|
headingText: 'Transaction failed',
|
|
5831
5835
|
subHeadingText: 'The transaction failed. Please try again.',
|
|
5832
5836
|
primaryButtonText: 'Retry',
|
|
5833
|
-
onPrimaryButtonClick:
|
|
5837
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5834
5838
|
secondaryButtonText: 'Close',
|
|
5835
5839
|
onSecondaryButtonClick: closeWidget,
|
|
5836
5840
|
},
|
|
5837
|
-
[
|
|
5841
|
+
[AddTokensErrorTypes.UNRECOGNISED_CHAIN]: {
|
|
5838
5842
|
headingText: 'Unrecognised chain',
|
|
5839
5843
|
subHeadingText: 'Please add the chain to your account and try again.',
|
|
5840
5844
|
primaryButtonText: 'Retry',
|
|
5841
|
-
onPrimaryButtonClick:
|
|
5845
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5842
5846
|
secondaryButtonText: 'Close',
|
|
5843
5847
|
onSecondaryButtonClick: closeWidget,
|
|
5844
5848
|
},
|
|
5845
|
-
[
|
|
5849
|
+
[AddTokensErrorTypes.PROVIDER_ERROR]: {
|
|
5846
5850
|
headingText: 'Wallet cannot be found',
|
|
5847
5851
|
subHeadingText: 'Please try to connect your wallet and try again.',
|
|
5848
5852
|
primaryButtonText: 'Retry',
|
|
5849
|
-
onPrimaryButtonClick:
|
|
5853
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5850
5854
|
secondaryButtonText: 'Close',
|
|
5851
5855
|
onSecondaryButtonClick: closeWidget,
|
|
5852
5856
|
},
|
|
5853
|
-
[
|
|
5857
|
+
[AddTokensErrorTypes.WALLET_FAILED]: {
|
|
5854
5858
|
headingText: 'Transaction failed',
|
|
5855
5859
|
subHeadingText: 'The transaction failed. Please try again.',
|
|
5856
5860
|
primaryButtonText: 'Retry',
|
|
5857
|
-
onPrimaryButtonClick:
|
|
5861
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5858
5862
|
secondaryButtonText: 'Close',
|
|
5859
|
-
onSecondaryButtonClick:
|
|
5863
|
+
onSecondaryButtonClick: goBackToAddTokensView,
|
|
5860
5864
|
},
|
|
5861
|
-
[
|
|
5865
|
+
[AddTokensErrorTypes.WALLET_REJECTED]: {
|
|
5862
5866
|
headingText: 'Transaction rejected',
|
|
5863
5867
|
subHeadingText: "You'll need to approve the transaction in your wallet to proceed.",
|
|
5864
5868
|
primaryButtonText: 'Retry',
|
|
5865
|
-
onPrimaryButtonClick:
|
|
5869
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5866
5870
|
secondaryButtonText: 'Close',
|
|
5867
5871
|
onSecondaryButtonClick: closeWidget,
|
|
5868
5872
|
},
|
|
5869
|
-
[
|
|
5873
|
+
[AddTokensErrorTypes.WALLET_REJECTED_NO_FUNDS]: {
|
|
5870
5874
|
headingText: 'Insufficient funds',
|
|
5871
5875
|
subHeadingText: 'You do not have enough funds to complete the transaction.',
|
|
5872
5876
|
primaryButtonText: 'Retry',
|
|
5873
|
-
onPrimaryButtonClick:
|
|
5877
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5874
5878
|
secondaryButtonText: 'Close',
|
|
5875
5879
|
onSecondaryButtonClick: closeWidget,
|
|
5876
5880
|
},
|
|
5877
|
-
[
|
|
5881
|
+
[AddTokensErrorTypes.WALLET_POPUP_BLOCKED]: {
|
|
5878
5882
|
headingText: "Browser's popup blocked",
|
|
5879
5883
|
subHeadingText: 'Please allow pop-ups in your browser to proceed.',
|
|
5880
5884
|
primaryButtonText: 'Retry',
|
|
5881
|
-
onPrimaryButtonClick:
|
|
5885
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5882
5886
|
secondaryButtonText: 'Close',
|
|
5883
|
-
onSecondaryButtonClick:
|
|
5887
|
+
onSecondaryButtonClick: goBackToAddTokensView,
|
|
5884
5888
|
},
|
|
5885
|
-
[
|
|
5889
|
+
[AddTokensErrorTypes.ENVIRONMENT_ERROR]: {
|
|
5886
5890
|
headingText: 'Unsupported environment',
|
|
5887
5891
|
subHeadingText: 'This is only supported in production environment.',
|
|
5888
5892
|
secondaryButtonText: 'Close',
|
|
@@ -5892,7 +5896,7 @@ const useError = (environment) => {
|
|
|
5892
5896
|
const getErrorConfig = (errorType) => errorConfig[errorType];
|
|
5893
5897
|
const showErrorHandover = (errorType, data) => {
|
|
5894
5898
|
page({
|
|
5895
|
-
userJourney: UserJourney.
|
|
5899
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5896
5900
|
screen: 'Error',
|
|
5897
5901
|
extras: {
|
|
5898
5902
|
errorType,
|
|
@@ -5915,17 +5919,18 @@ function SquidFooter() {
|
|
|
5915
5919
|
return (jsx(Body, { size: "xSmall", sx: {
|
|
5916
5920
|
textAlign: 'center',
|
|
5917
5921
|
color: 'base.color.text.body.secondary',
|
|
5918
|
-
}, children: jsx(Trans, { i18nKey: t('views.
|
|
5922
|
+
}, children: jsx(Trans, { i18nKey: t('views.ADD_TOKENS.footer.body'), components: {
|
|
5919
5923
|
squidLink: jsx(Link, { size: "xSmall", rc: jsx("a", { target: "_blank", href: " https://app.squidrouter.com", rel: "noreferrer" }) }),
|
|
5920
5924
|
} }) }));
|
|
5921
5925
|
}
|
|
5922
5926
|
|
|
5923
|
-
function
|
|
5927
|
+
function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOption = true, showSwapOption = true, showBridgeOption = true, onCloseButtonClick, showBackButton, onBackButtonClick, }) {
|
|
5924
5928
|
const { fetchRoutesWithRateLimit, resetRoutes } = useRoutes();
|
|
5925
5929
|
const { showErrorHandover } = useError(config.environment);
|
|
5926
|
-
const {
|
|
5930
|
+
const { addTokensState: { squid, chains, balances, tokens, selectedAmount, routes, selectedRouteData, selectedToken, isSwapAvailable, }, addTokensDispatch, } = reactExports.useContext(AddTokensContext);
|
|
5927
5931
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
5928
5932
|
const { track, page } = useAnalytics();
|
|
5933
|
+
const { t } = useTranslation();
|
|
5929
5934
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
5930
5935
|
const [showOptionsDrawer, setShowOptionsDrawer] = reactExports.useState(false);
|
|
5931
5936
|
const [showPayWithDrawer, setShowPayWithDrawer] = reactExports.useState(false);
|
|
@@ -5938,7 +5943,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5938
5943
|
const selectedAmountUsd = reactExports.useMemo(() => convertToUsd(tokens, inputValue, selectedToken), [tokens, inputValue, selectedToken]);
|
|
5939
5944
|
const setSelectedAmount = reactExports.useMemo(() => debounce$2((value) => {
|
|
5940
5945
|
track({
|
|
5941
|
-
userJourney: UserJourney.
|
|
5946
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5942
5947
|
screen: 'InputScreen',
|
|
5943
5948
|
control: 'AmountInput',
|
|
5944
5949
|
controlType: 'TextInput',
|
|
@@ -5946,16 +5951,16 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5946
5951
|
toAmount: value,
|
|
5947
5952
|
},
|
|
5948
5953
|
});
|
|
5949
|
-
|
|
5954
|
+
addTokensDispatch({
|
|
5950
5955
|
payload: {
|
|
5951
|
-
type:
|
|
5956
|
+
type: AddTokensActions.SET_SELECTED_AMOUNT,
|
|
5952
5957
|
selectedAmount: value,
|
|
5953
5958
|
},
|
|
5954
5959
|
});
|
|
5955
5960
|
}, 2500), []);
|
|
5956
5961
|
const setSelectedToken = (token) => {
|
|
5957
5962
|
track({
|
|
5958
|
-
userJourney: UserJourney.
|
|
5963
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5959
5964
|
screen: 'InputScreen',
|
|
5960
5965
|
control: 'TokensMenu',
|
|
5961
5966
|
controlType: 'MenuItem',
|
|
@@ -5963,9 +5968,9 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5963
5968
|
tokenAddress: token?.address,
|
|
5964
5969
|
},
|
|
5965
5970
|
});
|
|
5966
|
-
|
|
5971
|
+
addTokensDispatch({
|
|
5967
5972
|
payload: {
|
|
5968
|
-
type:
|
|
5973
|
+
type: AddTokensActions.SET_SELECTED_TOKEN,
|
|
5969
5974
|
selectedToken: token,
|
|
5970
5975
|
},
|
|
5971
5976
|
});
|
|
@@ -5973,7 +5978,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5973
5978
|
const setSelectedRouteData = (route) => {
|
|
5974
5979
|
if (route) {
|
|
5975
5980
|
track({
|
|
5976
|
-
userJourney: UserJourney.
|
|
5981
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5977
5982
|
screen: 'InputScreen',
|
|
5978
5983
|
control: 'RoutesMenu',
|
|
5979
5984
|
controlType: 'MenuItem',
|
|
@@ -5987,9 +5992,9 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5987
5992
|
},
|
|
5988
5993
|
});
|
|
5989
5994
|
}
|
|
5990
|
-
|
|
5995
|
+
addTokensDispatch({
|
|
5991
5996
|
payload: {
|
|
5992
|
-
type:
|
|
5997
|
+
type: AddTokensActions.SET_SELECTED_ROUTE_DATA,
|
|
5993
5998
|
selectedRouteData: route,
|
|
5994
5999
|
},
|
|
5995
6000
|
});
|
|
@@ -6020,7 +6025,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6020
6025
|
}), [providers]);
|
|
6021
6026
|
reactExports.useEffect(() => {
|
|
6022
6027
|
page({
|
|
6023
|
-
userJourney: UserJourney.
|
|
6028
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6024
6029
|
screen: 'InputScreen',
|
|
6025
6030
|
extras: {
|
|
6026
6031
|
toAmount,
|
|
@@ -6086,21 +6091,21 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6086
6091
|
});
|
|
6087
6092
|
setAllowedTokens(updatedTokens);
|
|
6088
6093
|
if (toTokenAddress) {
|
|
6089
|
-
const
|
|
6090
|
-
if (
|
|
6091
|
-
setSelectedToken(
|
|
6094
|
+
const preselectedToken = updatedTokens.find((token) => token.address?.toLowerCase() === toTokenAddress.toLowerCase());
|
|
6095
|
+
if (preselectedToken) {
|
|
6096
|
+
setSelectedToken(preselectedToken);
|
|
6092
6097
|
}
|
|
6093
6098
|
}
|
|
6094
|
-
|
|
6099
|
+
addTokensDispatch({
|
|
6095
6100
|
payload: {
|
|
6096
|
-
type:
|
|
6101
|
+
type: AddTokensActions.SET_ALLOWED_TOKENS,
|
|
6097
6102
|
allowedTokens: tokenResponse.tokens,
|
|
6098
6103
|
},
|
|
6099
6104
|
});
|
|
6100
6105
|
}
|
|
6101
6106
|
}
|
|
6102
6107
|
catch (error) {
|
|
6103
|
-
showErrorHandover(
|
|
6108
|
+
showErrorHandover(AddTokensErrorTypes.SERVICE_BREAKDOWN, { error });
|
|
6104
6109
|
}
|
|
6105
6110
|
};
|
|
6106
6111
|
fetchTokens();
|
|
@@ -6119,7 +6124,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6119
6124
|
}
|
|
6120
6125
|
}
|
|
6121
6126
|
catch (error) {
|
|
6122
|
-
showErrorHandover(
|
|
6127
|
+
showErrorHandover(AddTokensErrorTypes.SERVICE_BREAKDOWN, { error });
|
|
6123
6128
|
}
|
|
6124
6129
|
};
|
|
6125
6130
|
fetchOnRampTokens();
|
|
@@ -6130,7 +6135,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6130
6135
|
}, []);
|
|
6131
6136
|
const handleCardClick = () => {
|
|
6132
6137
|
track({
|
|
6133
|
-
userJourney: UserJourney.
|
|
6138
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6134
6139
|
screen: 'InputScreen',
|
|
6135
6140
|
control: 'PayWithCardMenu',
|
|
6136
6141
|
controlType: 'MenuItem',
|
|
@@ -6144,7 +6149,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6144
6149
|
amount: selectedAmount ?? '',
|
|
6145
6150
|
showBackButton: true,
|
|
6146
6151
|
};
|
|
6147
|
-
orchestrationEvents.sendRequestOnrampEvent(eventTarget, IMTBLWidgetEvents.
|
|
6152
|
+
orchestrationEvents.sendRequestOnrampEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, data);
|
|
6148
6153
|
};
|
|
6149
6154
|
const handleRouteClick = (route) => {
|
|
6150
6155
|
setShowOptionsDrawer(false);
|
|
@@ -6156,7 +6161,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6156
6161
|
if (!selectedRouteData || !selectedToken?.address)
|
|
6157
6162
|
return;
|
|
6158
6163
|
track({
|
|
6159
|
-
userJourney: UserJourney.
|
|
6164
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6160
6165
|
screen: 'InputScreen',
|
|
6161
6166
|
control: 'RoutesMenu',
|
|
6162
6167
|
controlType: 'MenuItem',
|
|
@@ -6173,7 +6178,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6173
6178
|
payload: {
|
|
6174
6179
|
type: ViewActions.UPDATE_VIEW,
|
|
6175
6180
|
view: {
|
|
6176
|
-
type:
|
|
6181
|
+
type: AddTokensWidgetViews.REVIEW,
|
|
6177
6182
|
data: {
|
|
6178
6183
|
balance: selectedRouteData.amountData.balance,
|
|
6179
6184
|
toChainId: ChainId.IMTBL_ZKEVM_MAINNET.toString(),
|
|
@@ -6187,8 +6192,8 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6187
6192
|
};
|
|
6188
6193
|
const shouldShowOnRampOption = reactExports.useMemo(() => {
|
|
6189
6194
|
if (showOnrampOption && selectedToken) {
|
|
6190
|
-
const
|
|
6191
|
-
return !!
|
|
6195
|
+
const isAllowedToken = onRampAllowedTokens.find((token) => token.address?.toLowerCase() === selectedToken.address?.toLowerCase());
|
|
6196
|
+
return !!isAllowedToken;
|
|
6192
6197
|
}
|
|
6193
6198
|
return false;
|
|
6194
6199
|
}, [selectedToken, onRampAllowedTokens, showOnrampOption]);
|
|
@@ -6205,7 +6210,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6205
6210
|
const readyToReview = routeInputsReady && !!toAddress && !!selectedRouteData && !loading;
|
|
6206
6211
|
const handleWalletConnected = (providerType, provider, providerInfo) => {
|
|
6207
6212
|
track({
|
|
6208
|
-
userJourney: UserJourney.
|
|
6213
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6209
6214
|
screen: 'InputScreen',
|
|
6210
6215
|
control: 'WalletsMenu',
|
|
6211
6216
|
controlType: 'MenuItem',
|
|
@@ -6240,14 +6245,15 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6240
6245
|
boxShadow: ({ base }) => `0 0 0 ${base.border.size[200]} ${base.color.text.body.primary}`,
|
|
6241
6246
|
},
|
|
6242
6247
|
} })),
|
|
6243
|
-
}), children: tokenChoiceOptions }), showInitialEmptyState ? (jsx(Body, { children: "Add Token" })) : (jsxs(HeroFormControl, { validationStatus: inputValue === '0' ? 'error' : 'success', children: [jsxs(HeroFormControl.Label, { children: ["Add", ' ', selectedToken.symbol] }), jsx(HeroTextInput, { testId: "add-
|
|
6248
|
+
}), children: tokenChoiceOptions }), showInitialEmptyState ? (jsx(Body, { children: "Add Token" })) : (jsxs(HeroFormControl, { validationStatus: inputValue === '0' ? 'error' : 'success', children: [jsxs(HeroFormControl.Label, { children: ["Add", ' ', selectedToken.symbol] }), jsx(HeroTextInput, { testId: "add-tokens-amount-input", type: "number", value: inputValue, onChange: (value) => handleOnAmountInputChange(value), placeholder: "0", maxTextSize: "xLarge" }), jsx(HeroFormControl.Caption, { children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')}
|
|
6249
|
+
$${getFormattedNumberWithDecimalPlaces(selectedAmountUsd)}` })] }))] }), jsxs(Stack, { testId: "bottomSection", sx: {
|
|
6244
6250
|
alignSelf: 'stretch',
|
|
6245
6251
|
p: 'base.spacing.x3',
|
|
6246
6252
|
pb: 'base.spacing.x5',
|
|
6247
6253
|
bg: 'base.color.neutral.800',
|
|
6248
6254
|
bradtl: 'base.borderRadius.x8',
|
|
6249
6255
|
bradtr: 'base.borderRadius.x8',
|
|
6250
|
-
}, gap: "base.spacing.x4", children: [jsxs(Stack, { gap: "0px", children: [jsxs(SelectedWallet, { label: "
|
|
6256
|
+
}, gap: "base.spacing.x4", children: [jsxs(Stack, { gap: "0px", children: [jsxs(SelectedWallet, { label: "Send from", providerInfo: {
|
|
6251
6257
|
...fromProviderInfo,
|
|
6252
6258
|
address: fromAddress,
|
|
6253
6259
|
}, onClick: (event) => {
|
|
@@ -6261,7 +6267,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6261
6267
|
} }) }), jsx(SelectedWallet, { label: "Deliver to", providerInfo: {
|
|
6262
6268
|
...toProviderInfo,
|
|
6263
6269
|
address: toAddress,
|
|
6264
|
-
}, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx(Button, { testId: "add-
|
|
6270
|
+
}, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx(Button, { testId: "add-tokens-button", size: "large", variant: readyToReview ? 'primary' : 'secondary', disabled: !readyToReview, onClick: handleReviewClick, sx: { opacity: readyToReview ? 1 : 0.5 }, children: "Review" }), jsx(SquidFooter, {}), jsx(PayWithWalletDrawer, { visible: showPayWithDrawer, walletOptions: walletOptions, onClose: () => setShowPayWithDrawer(false), onPayWithCard: handleCardClick, onConnect: handleWalletConnected, insufficientBalance: insufficientBalance, showOnRampOption: shouldShowOnRampOption }), jsx(OptionsDrawer, { checkout: checkout, routes: routes, showOnrampOption: shouldShowOnRampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, visible: showOptionsDrawer, onClose: () => setShowOptionsDrawer(false), onCardClick: handleCardClick, onRouteClick: handleRouteClick, insufficientBalance: insufficientBalance }), jsx(DeliverToWalletDrawer, { visible: showDeliverToDrawer, walletOptions: walletOptions, onClose: () => setShowDeliverToDrawer(false) }), jsx(OnboardingDrawer, { environment: checkout?.config.environment })] })] }) }));
|
|
6265
6271
|
}
|
|
6266
6272
|
|
|
6267
6273
|
var dist$2 = {};
|
|
@@ -173356,24 +173362,24 @@ const useExecute = (environment) => {
|
|
|
173356
173362
|
const { showErrorHandover } = useError(environment);
|
|
173357
173363
|
const handleTransactionError = (err) => {
|
|
173358
173364
|
const reason = `${err?.reason || err?.message || ''}`.toLowerCase();
|
|
173359
|
-
let errorType =
|
|
173365
|
+
let errorType = AddTokensErrorTypes.WALLET_FAILED;
|
|
173360
173366
|
if (reason.includes('failed') && reason.includes('open confirmation')) {
|
|
173361
|
-
errorType =
|
|
173367
|
+
errorType = AddTokensErrorTypes.WALLET_POPUP_BLOCKED;
|
|
173362
173368
|
}
|
|
173363
173369
|
if (reason.includes('rejected') && reason.includes('user')) {
|
|
173364
|
-
errorType =
|
|
173370
|
+
errorType = AddTokensErrorTypes.WALLET_REJECTED;
|
|
173365
173371
|
}
|
|
173366
173372
|
if (reason.includes('failed to submit')
|
|
173367
173373
|
&& reason.includes('highest gas limit')) {
|
|
173368
|
-
errorType =
|
|
173374
|
+
errorType = AddTokensErrorTypes.WALLET_REJECTED_NO_FUNDS;
|
|
173369
173375
|
}
|
|
173370
173376
|
if (reason.includes('status failed')
|
|
173371
173377
|
|| reason.includes('transaction failed')) {
|
|
173372
|
-
errorType =
|
|
173378
|
+
errorType = AddTokensErrorTypes.TRANSACTION_FAILED;
|
|
173373
173379
|
}
|
|
173374
173380
|
if (reason.includes('unrecognized chain')
|
|
173375
173381
|
|| reason.includes('unrecognized chain')) {
|
|
173376
|
-
errorType =
|
|
173382
|
+
errorType = AddTokensErrorTypes.UNRECOGNISED_CHAIN;
|
|
173377
173383
|
}
|
|
173378
173384
|
const error = {
|
|
173379
173385
|
type: errorType,
|
|
@@ -173429,7 +173435,7 @@ const useExecute = (environment) => {
|
|
|
173429
173435
|
return MaxUint256; // no approval is needed for native tokens
|
|
173430
173436
|
}
|
|
173431
173437
|
catch (error) {
|
|
173432
|
-
showErrorHandover(
|
|
173438
|
+
showErrorHandover(AddTokensErrorTypes.DEFAULT, { error });
|
|
173433
173439
|
return undefined;
|
|
173434
173440
|
}
|
|
173435
173441
|
};
|
|
@@ -173493,10 +173499,11 @@ function SquidIcon({ sx = {}, className, }) {
|
|
|
173493
173499
|
}
|
|
173494
173500
|
|
|
173495
173501
|
function RouteFees({ visible, onClose, routeData, totalAmount, totalFiatAmount, }) {
|
|
173502
|
+
const { t } = useTranslation();
|
|
173496
173503
|
const feeCosts = reactExports.useMemo(() => routeData?.route.estimate.feeCosts.map((fee) => ({
|
|
173497
173504
|
label: fee.name,
|
|
173498
173505
|
amount: getFormattedNumber(fee.amount, fee.token.decimals),
|
|
173499
|
-
fiatAmount:
|
|
173506
|
+
fiatAmount: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')}${getFormattedAmounts(fee.amountUsd)}`,
|
|
173500
173507
|
token: {
|
|
173501
173508
|
name: fee.token.name,
|
|
173502
173509
|
symbol: fee.token.symbol,
|
|
@@ -173509,7 +173516,7 @@ function RouteFees({ visible, onClose, routeData, totalAmount, totalFiatAmount,
|
|
|
173509
173516
|
const gasCosts = reactExports.useMemo(() => routeData?.route.estimate.gasCosts.map((fee) => ({
|
|
173510
173517
|
label: 'Gas (transaction)',
|
|
173511
173518
|
amount: getFormattedNumber(fee.amount, fee.token.decimals),
|
|
173512
|
-
fiatAmount:
|
|
173519
|
+
fiatAmount: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')}${getFormattedAmounts(fee.amountUsd)}`,
|
|
173513
173520
|
token: {
|
|
173514
173521
|
name: fee.token.name,
|
|
173515
173522
|
symbol: fee.token.symbol,
|
|
@@ -173578,7 +173585,7 @@ const dividerSx = {
|
|
|
173578
173585
|
function Review({ data, showBackButton = false, onBackButtonClick, onCloseButtonClick, }) {
|
|
173579
173586
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
173580
173587
|
const { track, page } = useAnalytics();
|
|
173581
|
-
const {
|
|
173588
|
+
const { addTokensState: { squid, chains, tokens }, } = reactExports.useContext(AddTokensContext);
|
|
173582
173589
|
const { providersState: { checkout, fromProvider, fromAddress, toAddress, }, } = useProvidersContext();
|
|
173583
173590
|
const [route, setRoute] = reactExports.useState();
|
|
173584
173591
|
const [proceedDisabled, setProceedDisabled] = reactExports.useState(true);
|
|
@@ -173592,7 +173599,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173592
173599
|
const { checkProviderChain, getAllowance, approve, execute, } = useExecute(checkout?.config.environment || Environment.SANDBOX);
|
|
173593
173600
|
reactExports.useEffect(() => {
|
|
173594
173601
|
page({
|
|
173595
|
-
userJourney: UserJourney.
|
|
173602
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
173596
173603
|
screen: 'Review',
|
|
173597
173604
|
extras: {
|
|
173598
173605
|
toAmount: data.toAmount,
|
|
@@ -173628,7 +173635,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173628
173635
|
alignItems: 'center',
|
|
173629
173636
|
c: 'base.color.text.body.secondary',
|
|
173630
173637
|
cursor: 'pointer',
|
|
173631
|
-
}, children: ["Included fees", `
|
|
173638
|
+
}, children: ["Included fees", ` ${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${getFormattedAmounts(totalFeesUsd)}`, jsx(Icon, { icon: "ChevronExpand", sx: { ml: 'base.spacing.x2', w: 'base.icon.size.200' } })] }));
|
|
173632
173639
|
}
|
|
173633
173640
|
return (jsx(Body, { size: "small", sx: {
|
|
173634
173641
|
...hFlex,
|
|
@@ -173653,7 +173660,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173653
173660
|
currentFromAddress = await fromProvider.getSigner().getAddress();
|
|
173654
173661
|
}
|
|
173655
173662
|
catch (error) {
|
|
173656
|
-
showErrorHandover(
|
|
173663
|
+
showErrorHandover(AddTokensErrorTypes.PROVIDER_ERROR, { error });
|
|
173657
173664
|
return;
|
|
173658
173665
|
}
|
|
173659
173666
|
if (currentFromAddress !== fromAddress) {
|
|
@@ -173682,7 +173689,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173682
173689
|
const executeTxnReceipt = await execute(squid, changeableProvider, route);
|
|
173683
173690
|
if (executeTxnReceipt) {
|
|
173684
173691
|
track({
|
|
173685
|
-
userJourney: UserJourney.
|
|
173692
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
173686
173693
|
screen: 'FundsAdded',
|
|
173687
173694
|
action: 'Succeeded',
|
|
173688
173695
|
extras: {
|
|
@@ -173708,7 +173715,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173708
173715
|
const formattedDuration = route
|
|
173709
173716
|
? getDurationFormatted(route.route.estimate.estimatedRouteDuration)
|
|
173710
173717
|
: '';
|
|
173711
|
-
return (jsxs(SimpleLayout, { header: (jsxs(Stack, { rc: jsx("header", {}), direction: "row", sx: {
|
|
173718
|
+
return (jsxs(SimpleLayout, { containerSx: { bg: 'transparent' }, header: (jsxs(Stack, { rc: jsx("header", {}), direction: "row", sx: {
|
|
173712
173719
|
pt: 'base.spacing.x4',
|
|
173713
173720
|
px: 'base.spacing.x5',
|
|
173714
173721
|
h: 'base.spacing.x18',
|
|
@@ -173725,7 +173732,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173725
173732
|
fontSize: 'inherit',
|
|
173726
173733
|
lineHeight: 'inherit',
|
|
173727
173734
|
c: 'inherit',
|
|
173728
|
-
} })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route.route.estimate.fromAmount, route.route.estimate.fromToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children:
|
|
173735
|
+
} })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route.route.estimate.fromAmount, route.route.estimate.fromToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${route?.route.estimate.fromAmountUSD ?? ''}` }) })] }), jsx(Stack, { sx: {
|
|
173729
173736
|
pos: 'relative',
|
|
173730
173737
|
w: 'base.spacing.x16',
|
|
173731
173738
|
ml: 'base.spacing.x7',
|
|
@@ -173753,7 +173760,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173753
173760
|
fontSize: 'inherit',
|
|
173754
173761
|
lineHeight: 'inherit',
|
|
173755
173762
|
c: 'inherit',
|
|
173756
|
-
} })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route?.route.estimate.toAmount, route?.route.estimate.toToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children:
|
|
173763
|
+
} })] })] }), jsx(PriceDisplay, { price: getFormattedNumber(route?.route.estimate.toAmount, route?.route.estimate.toToken.decimals), sx: { flexShrink: 0, alignSelf: 'flex-start' }, children: jsx(PriceDisplay.Caption, { size: "small", children: `${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${route?.route.estimate.toAmountUSD ?? ''}` }) })] }), jsx(Stack, { sx: {
|
|
173757
173764
|
pos: 'relative',
|
|
173758
173765
|
w: 'base.spacing.x16',
|
|
173759
173766
|
ml: 'base.spacing.x7',
|
|
@@ -173763,13 +173770,13 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173763
173770
|
top: '-8px',
|
|
173764
173771
|
h: 'base.spacing.x5',
|
|
173765
173772
|
},
|
|
173766
|
-
} }), jsxs(Stack, { direction: "row", gap: "base.spacing.x6", sx: { py: 'base.spacing.x5', px: 'base.spacing.x7' }, alignItems: "center", children: [jsx(Stack, { direction: "row", sx: { w: 'base.spacing.x12' }, justifyContent: "center", children: jsx(FramedIcon, { icon: "Countdown", variant: "bold", size: "medium", circularFrame: true }) }), jsx(Body, { size: "small", sx: { flex: 1, c: 'base.color.text.body.secondary' }, children: formattedDuration }), routeFees] })] }), jsx(Button, { size: "large", onClick: handleTransaction, disabled: proceedDisabled, sx: { mx: 'base.spacing.x3' }, children: proceedDisabled ? 'Processing' : 'Proceed' }), jsx(SquidFooter, {})] })), !route && !showAddressMissmatchDrawer && jsx(LoadingView, { loadingText: "Securing quote" })] }), jsx(RouteFees, { routeData: route, visible: showFeeBreakdown, onClose: () => setShowFeeBreakdown(false), totalAmount: totalFees, totalFiatAmount: totalFeesUsd }), jsx(AddressMissmatchDrawer, { visible: showAddressMissmatchDrawer, onClick: () => {
|
|
173773
|
+
} }), jsxs(Stack, { direction: "row", gap: "base.spacing.x6", sx: { py: 'base.spacing.x5', px: 'base.spacing.x7' }, alignItems: "center", children: [jsx(Stack, { direction: "row", sx: { w: 'base.spacing.x12' }, justifyContent: "center", children: jsx(FramedIcon, { icon: "Countdown", variant: "bold", size: "medium", circularFrame: true }) }), jsx(Body, { size: "small", sx: { flex: 1, c: 'base.color.text.body.secondary' }, children: formattedDuration }), routeFees] })] }), jsx(Button, { size: "large", onClick: handleTransaction, disabled: proceedDisabled, sx: { mx: 'base.spacing.x3' }, children: proceedDisabled ? 'Processing' : 'Proceed' }), jsx(SquidFooter, {})] })), !route && !showAddressMissmatchDrawer && (jsx(LoadingView, { loadingText: "Securing quote", containerSx: { bg: 'transparent' } }))] }), jsx(RouteFees, { routeData: route, visible: showFeeBreakdown, onClose: () => setShowFeeBreakdown(false), totalAmount: totalFees, totalFiatAmount: totalFeesUsd }), jsx(AddressMissmatchDrawer, { visible: showAddressMissmatchDrawer, onClick: () => {
|
|
173767
173774
|
setShowAddressMissmatchDrawer(false);
|
|
173768
173775
|
viewDispatch({
|
|
173769
173776
|
payload: {
|
|
173770
173777
|
type: ViewActions.UPDATE_VIEW,
|
|
173771
173778
|
view: {
|
|
173772
|
-
type:
|
|
173779
|
+
type: AddTokensWidgetViews.ADD_TOKENS,
|
|
173773
173780
|
},
|
|
173774
173781
|
},
|
|
173775
173782
|
});
|
|
@@ -173853,13 +173860,13 @@ const useTokens = (checkout) => {
|
|
|
173853
173860
|
return tokens;
|
|
173854
173861
|
};
|
|
173855
173862
|
|
|
173856
|
-
function
|
|
173863
|
+
function AddTokensWidget({ showOnrampOption = true, showSwapOption = true, showBridgeOption = true, toTokenAddress, toAmount, showBackButton, config, }) {
|
|
173857
173864
|
const fetchingBalances = reactExports.useRef(false);
|
|
173858
173865
|
const { base: { colorMode } } = useTheme();
|
|
173859
173866
|
const [viewState, viewDispatch] = reactExports.useReducer(viewReducer, {
|
|
173860
173867
|
...initialViewState,
|
|
173861
|
-
view: { type:
|
|
173862
|
-
history: [{ type:
|
|
173868
|
+
view: { type: AddTokensWidgetViews.ADD_TOKENS },
|
|
173869
|
+
history: [{ type: AddTokensWidgetViews.ADD_TOKENS }],
|
|
173863
173870
|
});
|
|
173864
173871
|
const { t } = useTranslation();
|
|
173865
173872
|
const { page } = useAnalytics();
|
|
@@ -173867,28 +173874,28 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173867
173874
|
viewState,
|
|
173868
173875
|
viewDispatch,
|
|
173869
173876
|
}), [viewState, viewReducer]);
|
|
173870
|
-
const [
|
|
173877
|
+
const [addTokensState, addTokensDispatch] = reactExports.useReducer(addTokensReducer, initialAddTokensState);
|
|
173871
173878
|
const { providersState: { checkout, fromProvider }, } = useProvidersContext();
|
|
173872
|
-
const { squid, chains } =
|
|
173873
|
-
const
|
|
173874
|
-
|
|
173875
|
-
|
|
173876
|
-
}), [
|
|
173879
|
+
const { squid, chains } = addTokensState;
|
|
173880
|
+
const addTokensReducerValues = reactExports.useMemo(() => ({
|
|
173881
|
+
addTokensState,
|
|
173882
|
+
addTokensDispatch,
|
|
173883
|
+
}), [addTokensState, addTokensDispatch]);
|
|
173877
173884
|
const squidSdk = useSquid(checkout);
|
|
173878
173885
|
const tokensResponse = useTokens(checkout);
|
|
173879
173886
|
const { showErrorHandover } = useError(checkout.config.environment);
|
|
173880
173887
|
reactExports.useEffect(() => {
|
|
173881
173888
|
if (config.environment !== Environment.PRODUCTION) {
|
|
173882
|
-
showErrorHandover(
|
|
173889
|
+
showErrorHandover(AddTokensErrorTypes.ENVIRONMENT_ERROR);
|
|
173883
173890
|
}
|
|
173884
173891
|
}, [config]);
|
|
173885
173892
|
reactExports.useEffect(() => {
|
|
173886
173893
|
if (!checkout)
|
|
173887
173894
|
return;
|
|
173888
173895
|
(async () => {
|
|
173889
|
-
|
|
173896
|
+
addTokensDispatch({
|
|
173890
173897
|
payload: {
|
|
173891
|
-
type:
|
|
173898
|
+
type: AddTokensActions.SET_IS_SWAP_AVAILABLE,
|
|
173892
173899
|
isSwapAvailable: await checkout.isSwapAvailable(),
|
|
173893
173900
|
},
|
|
173894
173901
|
});
|
|
@@ -173898,15 +173905,15 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173898
173905
|
const isInvalidToTokenAddress = toTokenAddress && !isValidAddress(toTokenAddress);
|
|
173899
173906
|
const isInvalidToAmount = toAmount && !amountInputValidation(toAmount);
|
|
173900
173907
|
if (isInvalidToTokenAddress || isInvalidToAmount) {
|
|
173901
|
-
showErrorHandover(
|
|
173908
|
+
showErrorHandover(AddTokensErrorTypes.INVALID_PARAMETERS);
|
|
173902
173909
|
}
|
|
173903
173910
|
}, [toTokenAddress, toAmount]);
|
|
173904
173911
|
reactExports.useEffect(() => {
|
|
173905
173912
|
(async () => {
|
|
173906
173913
|
const chainsResponse = await fetchChains();
|
|
173907
|
-
|
|
173914
|
+
addTokensDispatch({
|
|
173908
173915
|
payload: {
|
|
173909
|
-
type:
|
|
173916
|
+
type: AddTokensActions.SET_CHAINS,
|
|
173910
173917
|
chains: chainsResponse,
|
|
173911
173918
|
},
|
|
173912
173919
|
});
|
|
@@ -173920,9 +173927,9 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173920
173927
|
fetchingBalances.current = true;
|
|
173921
173928
|
const evmChains = chains.filter((chain) => chain.type === 'evm');
|
|
173922
173929
|
const balances = await fetchBalances(squid, evmChains, fromProvider);
|
|
173923
|
-
|
|
173930
|
+
addTokensDispatch({
|
|
173924
173931
|
payload: {
|
|
173925
|
-
type:
|
|
173932
|
+
type: AddTokensActions.SET_BALANCES,
|
|
173926
173933
|
balances,
|
|
173927
173934
|
},
|
|
173928
173935
|
});
|
|
@@ -173935,9 +173942,9 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173935
173942
|
reactExports.useEffect(() => {
|
|
173936
173943
|
if (!squidSdk)
|
|
173937
173944
|
return;
|
|
173938
|
-
|
|
173945
|
+
addTokensDispatch({
|
|
173939
173946
|
payload: {
|
|
173940
|
-
type:
|
|
173947
|
+
type: AddTokensActions.SET_SQUID,
|
|
173941
173948
|
squid: squidSdk,
|
|
173942
173949
|
},
|
|
173943
173950
|
});
|
|
@@ -173945,9 +173952,9 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173945
173952
|
reactExports.useEffect(() => {
|
|
173946
173953
|
if (!tokensResponse)
|
|
173947
173954
|
return;
|
|
173948
|
-
|
|
173955
|
+
addTokensDispatch({
|
|
173949
173956
|
payload: {
|
|
173950
|
-
type:
|
|
173957
|
+
type: AddTokensActions.SET_TOKENS,
|
|
173951
173958
|
tokens: tokensResponse,
|
|
173952
173959
|
},
|
|
173953
173960
|
});
|
|
@@ -173957,31 +173964,31 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173957
173964
|
viewDispatch({
|
|
173958
173965
|
payload: {
|
|
173959
173966
|
type: ViewActions.UPDATE_VIEW,
|
|
173960
|
-
view: { type:
|
|
173967
|
+
view: { type: AddTokensWidgetViews.ADD_TOKENS },
|
|
173961
173968
|
},
|
|
173962
173969
|
});
|
|
173963
173970
|
};
|
|
173964
|
-
return (jsx(ViewContext.Provider, { value: viewReducerValues, children: jsx(
|
|
173971
|
+
return (jsx(ViewContext.Provider, { value: viewReducerValues, children: jsx(AddTokensContext.Provider, { value: addTokensReducerValues, children: jsxs(Stack, { sx: { pos: 'relative' }, children: [jsx(CloudImage, { use: (jsx("img", { src: getRemoteImage(config.environment, `/add-tokens-bg-texture-${colorMode}.webp`), alt: "blurry bg texture" })), sx: {
|
|
173965
173972
|
pos: 'absolute',
|
|
173966
173973
|
h: '100%',
|
|
173967
173974
|
w: '100%',
|
|
173968
173975
|
objectFit: 'cover',
|
|
173969
173976
|
objectPosition: 'center',
|
|
173970
|
-
} }), viewState.view.type ===
|
|
173971
|
-
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.
|
|
173972
|
-
} })), viewState.view.type ===
|
|
173977
|
+
} }), viewState.view.type === AddTokensWidgetViews.ADD_TOKENS && (jsx(AddTokens, { config: config, checkout: checkout, toTokenAddress: toTokenAddress, toAmount: toAmount, showBackButton: showBackButton, showOnrampOption: showOnrampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, onCloseButtonClick: () => sendAddTokensCloseEvent(eventTarget), onBackButtonClick: () => {
|
|
173978
|
+
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, {});
|
|
173979
|
+
} })), viewState.view.type === AddTokensWidgetViews.REVIEW && (jsx(Review, { data: viewState.view.data, onCloseButtonClick: () => sendAddTokensCloseEvent(eventTarget), onBackButtonClick: () => {
|
|
173973
173980
|
viewDispatch({
|
|
173974
173981
|
payload: {
|
|
173975
173982
|
type: ViewActions.GO_BACK,
|
|
173976
173983
|
},
|
|
173977
173984
|
});
|
|
173978
|
-
}, showBackButton: true })), viewState.view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { actionText: t('views.ERROR_VIEW.actionText'), onActionClick: errorAction, onCloseClick: () =>
|
|
173985
|
+
}, showBackButton: true })), viewState.view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { actionText: t('views.ERROR_VIEW.actionText'), onActionClick: errorAction, onCloseClick: () => sendAddTokensCloseEvent(eventTarget), errorEventAction: () => {
|
|
173979
173986
|
page({
|
|
173980
|
-
userJourney: UserJourney.
|
|
173987
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
173981
173988
|
screen: 'Error',
|
|
173982
173989
|
});
|
|
173983
173990
|
} })), viewState.view.type
|
|
173984
|
-
=== SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (jsx(ServiceUnavailableErrorView, { service: ServiceType.GENERIC, onCloseClick: () =>
|
|
173991
|
+
=== SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (jsx(ServiceUnavailableErrorView, { service: ServiceType.GENERIC, onCloseClick: () => sendAddTokensCloseEvent(eventTarget) }))] }) }) }));
|
|
173985
173992
|
}
|
|
173986
173993
|
|
|
173987
|
-
export {
|
|
173994
|
+
export { AddTokensWidget as default };
|