@imtbl/sdk 1.62.0 → 1.63.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/{blockchain_data-sxvR7yJA.js → blockchain_data-Dpv5muPl.js} +2 -2
- package/dist/blockchain_data.js +3 -3
- package/dist/browser/checkout/{AddFundsWidget-ZVSgslAw.js → AddTokensWidget-BfDY0LwB.js} +166 -166
- package/dist/browser/checkout/{BridgeWidget-Cdho2hYD.js → BridgeWidget-DreWq2OO.js} +8 -8
- package/dist/browser/checkout/{CommerceWidget-BzipzAPM.js → CommerceWidget-BFEo_z63.js} +28 -28
- package/dist/browser/checkout/{EllipsizedText-CvkYzx6o.js → EllipsizedText-_yDoxF8V.js} +1 -1
- package/dist/browser/checkout/{FeesBreakdown-2gL4cI-R.js → FeesBreakdown-CQVi4M-W.js} +1 -1
- package/dist/browser/checkout/{HandoverContent-Bl4qmdQg.js → HandoverContent-D0HXf455.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-QJuXcGjQ.js → OnRampWidget-BpRLbHli.js} +3 -3
- package/dist/browser/checkout/{SaleWidget-edWOlmfl.js → SaleWidget-C-ATgwRu.js} +17 -17
- package/dist/browser/checkout/{SpendingCapHero-CqFT2_-Q.js → SpendingCapHero-DLdYNa0u.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-gFL-1ypc.js → SwapWidget-Dm2cQUYh.js} +8 -8
- package/dist/browser/checkout/{TopUpView-BQBIv4KK.js → TopUpView-Nbu5J6zy.js} +10 -10
- package/dist/browser/checkout/{WalletApproveHero-CLTmvRwO.js → WalletApproveHero-Cc6p3CkR.js} +3 -3
- package/dist/browser/checkout/{WalletWidget-DqzlgTAL.js → WalletWidget-C25SCVnz.js} +22 -22
- package/dist/browser/checkout/{auto-track-B_DVujaR.js → auto-track-1Zr4QLt3.js} +1 -1
- package/dist/browser/checkout/{index-CRuWUFZW.js → index-3DC3zK0u.js} +1 -1
- package/dist/browser/checkout/{index-BGasM3FI.js → index-B7urOO_H.js} +1 -1
- package/dist/browser/checkout/{index-DYTK3G7G.js → index-BYrBQsd2.js} +2 -2
- package/dist/browser/checkout/{index-DvBzy5DX.js → index-Co93fBqn.js} +67 -67
- package/dist/browser/checkout/{index-CgtLpuEZ.js → index-DthkZUK5.js} +1 -1
- package/dist/browser/checkout/{index-B_wChk6v.js → index-DzrC5Kuy.js} +1 -1
- package/dist/browser/checkout/{index-yoSSDRdd.js → index-Vadzr0yp.js} +1 -1
- package/dist/browser/checkout/{index-DitiTTnr.js → index-c7pVchOF.js} +1 -1
- package/dist/browser/checkout/{index-BVEcFW11.js → index-t2b5ztUB.js} +1 -1
- package/dist/browser/checkout/{index.umd-5W8TJb-e.js → index.umd-CwLr5uH5.js} +1 -1
- package/dist/browser/checkout/{retry-Bd7qMg0v.js → retry-DqIpQ6wO.js} +1 -1
- package/dist/browser/checkout/sdk.js +15 -15
- package/dist/browser/checkout/{useInterval-DI0ddcnq.js → useInterval-D42dwhRA.js} +1 -1
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +251 -251
- package/dist/{checkout-C12Br7lr.js → checkout-Dr99AQC1.js} +22 -22
- package/dist/checkout.d.ts +50 -50
- package/dist/checkout.js +5 -5
- package/dist/{config-BR83WwI2.js → config-DkJOEY8_.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-o82oWSK6.js → index-B7ZGqefm.js} +1 -1
- package/dist/{index-CA86ogWz.js → index-BI-lDUrN.js} +3 -3
- package/dist/{index-DeyLbhnj.js → index-CK8NRXyO.js} +1 -1
- package/dist/{index-B12uBW7v.js → index-DWXUkxHc.js} +1 -1
- package/dist/{index-B3-R16ZI.js → index-Dvd-bDuR.js} +4 -4
- package/dist/{index-oQTMj48l.js → index-ONuhnAdl.js} +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +23 -23
- package/dist/index.d.ts +63 -63
- package/dist/index.js +14 -14
- package/dist/{minting_backend-BZNiHRmU.js → minting_backend-CpZGmZ-L.js} +3 -3
- package/dist/minting_backend.js +5 -5
- package/dist/{orderbook-B1Tjr_q4.js → orderbook-BGc1pQHt.js} +1 -1
- package/dist/orderbook.js +2 -2
- package/dist/{passport-BSNhvk09.js → passport-CsmpMk_U.js} +3 -3
- package/dist/passport.js +4 -4
- package/dist/{webhook-2lD6l4rk.js → webhook-8q1P3n_h.js} +1 -1
- package/dist/webhook.js +2 -2
- package/dist/{x-BuvtdpOp.js → x-BNK0EB3B.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 Heading, aB as WalletDrawer, aC as UnableToConnectDrawer, aD as ChangedYourMindDrawer, aE as WalletProviderRdns, aF as getProviderSlugFromRdns, aG as Web3Provider, aH as connectEIP6963Provider, aI as identifyUser, aJ as ConnectEIP6963ProviderError, aK as ProvidersContextActions, aL as ViewContext, V as ViewActions, o as SharedViews, k as ChainId, aM as commonjsRequire, aN as getRemoteImage, aO as useHandover, aP as HandoverTarget, aQ as EventTargetContext, aR as getRemoteRive, aS as Trans, aT as Link, aU as useInjectedProviders, aV as getDefaultTokenImage, aW as OverflowDrawerMenu, aX as SimpleLayout, aY as TokenFilterTypes, h as getL2ChainId, aZ as isNativeToken, a_ as getTokenImageByAddress, a$ as orchestrationEvents, b0 as requireSecp256k1$1, b1 as requireLib_commonjs, b2 as require$$0$2, b3 as bech32$2, b4 as bnExports$1, b5 as require$$0$3, b6 as getAugmentedNamespace, b7 as require$$0$4, b8 as minimalisticAssert, b9 as require$$2, ba as hash$6, bb as MaxUint256, bc as merge$3, bd as SvgIcon, be as WalletWarningHero, bf as Environment, bg as t, bh as PriceDisplay, L as LoadingView, bi as viewReducer, bj as initialViewState, bk as isValidAddress, bl as amountInputValidation, bm as CloudImage, E as ErrorView, bn as ServiceUnavailableErrorView, bo as ServiceType } from './index-Co93fBqn.js';
|
|
2
|
+
import { f as formatUnits, p as parseUnits } from './index-DzrC5Kuy.js';
|
|
3
|
+
import { E as EllipsizedText, C as Contract } from './EllipsizedText-_yDoxF8V.js';
|
|
4
|
+
import { r as retry, T as TokenImage } from './retry-DqIpQ6wO.js';
|
|
5
|
+
import { H as HandoverContent } from './HandoverContent-D0HXf455.js';
|
|
6
|
+
import { F as FeesBreakdown } from './FeesBreakdown-CQVi4M-W.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) {
|
|
@@ -1754,7 +1754,7 @@ function OptionsDrawer({ checkout, routes, visible, onClose, onRouteClick, onCar
|
|
|
1754
1754
|
showSwapOption,
|
|
1755
1755
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1756
1756
|
showBridgeOption, insufficientBalance, }) {
|
|
1757
|
-
const {
|
|
1757
|
+
const { addTokensState: { chains }, } = reactExports.useContext(AddTokensContext);
|
|
1758
1758
|
const { providersState: { fromProviderInfo, fromAddress }, } = useProvidersContext();
|
|
1759
1759
|
const selectedRouteIndex = reactExports.useRef(0);
|
|
1760
1760
|
const handleOnRouteClick = (route, index) => {
|
|
@@ -2424,12 +2424,12 @@ const sortRoutesByFastestTime = (routes) => {
|
|
|
2424
2424
|
const BASE_SLIPPAGE = 0.02;
|
|
2425
2425
|
const useRoutes = () => {
|
|
2426
2426
|
const latestRequestIdRef = reactExports.useRef(0);
|
|
2427
|
-
const {
|
|
2427
|
+
const { addTokensDispatch } = reactExports.useContext(AddTokensContext);
|
|
2428
2428
|
const { track } = useAnalytics();
|
|
2429
2429
|
const setRoutes = (routes) => {
|
|
2430
|
-
|
|
2430
|
+
addTokensDispatch({
|
|
2431
2431
|
payload: {
|
|
2432
|
-
type:
|
|
2432
|
+
type: AddTokensActions.SET_ROUTES,
|
|
2433
2433
|
routes,
|
|
2434
2434
|
},
|
|
2435
2435
|
});
|
|
@@ -2526,7 +2526,7 @@ const useRoutes = () => {
|
|
|
2526
2526
|
return { route: newRoute };
|
|
2527
2527
|
}
|
|
2528
2528
|
track({
|
|
2529
|
-
userJourney: UserJourney.
|
|
2529
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
2530
2530
|
screen: 'Routes',
|
|
2531
2531
|
action: 'Failed',
|
|
2532
2532
|
extras: {
|
|
@@ -5722,30 +5722,30 @@ var localforage = {exports: {}};
|
|
|
5722
5722
|
var localforageExports = localforage.exports;
|
|
5723
5723
|
var localForage = /*@__PURE__*/getDefaultExportFromCjs(localforageExports);
|
|
5724
5724
|
|
|
5725
|
-
const
|
|
5726
|
-
name: '
|
|
5725
|
+
const addTokensOnboardingCache = localForage.createInstance({
|
|
5726
|
+
name: 'AddTokens Onboarding State',
|
|
5727
5727
|
version: 1.0,
|
|
5728
5728
|
storeName: 'Internal state',
|
|
5729
|
-
description: 'A small IndexDB for storage of state relating to the
|
|
5729
|
+
description: 'A small IndexDB for storage of state relating to the AddTokens Onboarding Drawer',
|
|
5730
5730
|
});
|
|
5731
5731
|
const SEEN_ONBOARDING_KEY = 'seen-onboarding';
|
|
5732
5732
|
async function getCacheItem(key) {
|
|
5733
|
-
const data = await
|
|
5733
|
+
const data = await addTokensOnboardingCache.getItem(key);
|
|
5734
5734
|
if (!data)
|
|
5735
5735
|
return null;
|
|
5736
5736
|
const { value } = data;
|
|
5737
5737
|
return value;
|
|
5738
5738
|
}
|
|
5739
5739
|
async function setCacheItem(key, value) {
|
|
5740
|
-
return
|
|
5740
|
+
return addTokensOnboardingCache.setItem(key, {
|
|
5741
5741
|
value,
|
|
5742
5742
|
});
|
|
5743
5743
|
}
|
|
5744
5744
|
|
|
5745
5745
|
const HERO_IMAGES = [
|
|
5746
|
-
'/add-
|
|
5747
|
-
'/add-
|
|
5748
|
-
'/add-
|
|
5746
|
+
'/add-tokens-onboarding-1.svg',
|
|
5747
|
+
'/add-tokens-onboarding-2.svg',
|
|
5748
|
+
'/add-tokens-onboarding-3.svg',
|
|
5749
5749
|
];
|
|
5750
5750
|
function OnboardingDrawer({ environment }) {
|
|
5751
5751
|
const { t } = useTranslation();
|
|
@@ -5780,11 +5780,11 @@ function OnboardingDrawer({ environment }) {
|
|
|
5780
5780
|
alignItems: 'center',
|
|
5781
5781
|
textAlign: 'center',
|
|
5782
5782
|
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.
|
|
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.ADD_TOKENS.onboarding.screen${screenIndex}.caption`) }), jsx(Heading, { size: "small", sx: {
|
|
5784
5784
|
// @NOTE: this preserves newlines inside any strings, which
|
|
5785
5785
|
// come out of the translation layer
|
|
5786
5786
|
whiteSpace: 'pre-line',
|
|
5787
|
-
}, children: t(`views.
|
|
5787
|
+
}, 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
5788
|
}
|
|
5789
5789
|
|
|
5790
5790
|
const useError = (environment) => {
|
|
@@ -5795,94 +5795,94 @@ const useError = (environment) => {
|
|
|
5795
5795
|
});
|
|
5796
5796
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
5797
5797
|
const closeWidget = () => {
|
|
5798
|
-
|
|
5798
|
+
sendAddTokensCloseEvent(eventTarget);
|
|
5799
5799
|
};
|
|
5800
|
-
const
|
|
5800
|
+
const goBackToAddTokensView = () => {
|
|
5801
5801
|
closeHandover();
|
|
5802
5802
|
viewDispatch({
|
|
5803
5803
|
payload: {
|
|
5804
5804
|
type: ViewActions.UPDATE_VIEW,
|
|
5805
5805
|
view: {
|
|
5806
|
-
type:
|
|
5806
|
+
type: AddTokensWidgetViews.ADD_TOKENS,
|
|
5807
5807
|
},
|
|
5808
5808
|
},
|
|
5809
5809
|
});
|
|
5810
5810
|
};
|
|
5811
5811
|
const errorConfig = {
|
|
5812
|
-
[
|
|
5812
|
+
[AddTokensErrorTypes.DEFAULT]: {
|
|
5813
5813
|
headingText: 'Sorry, something went wrong. Please try again later.',
|
|
5814
5814
|
secondaryButtonText: 'Close',
|
|
5815
5815
|
onSecondaryButtonClick: closeWidget,
|
|
5816
5816
|
},
|
|
5817
|
-
[
|
|
5817
|
+
[AddTokensErrorTypes.INVALID_PARAMETERS]: {
|
|
5818
5818
|
headingText: 'Invalid parameters',
|
|
5819
5819
|
subHeadingText: 'The widget parameters provided are invalid. Please check again.',
|
|
5820
5820
|
secondaryButtonText: 'Close',
|
|
5821
5821
|
onSecondaryButtonClick: closeWidget,
|
|
5822
5822
|
},
|
|
5823
|
-
[
|
|
5823
|
+
[AddTokensErrorTypes.SERVICE_BREAKDOWN]: {
|
|
5824
5824
|
headingText: 'Our system is currently down',
|
|
5825
5825
|
subHeadingText: 'We are currently experiencing technical difficulties. Please try again later.',
|
|
5826
5826
|
secondaryButtonText: 'Close',
|
|
5827
5827
|
onSecondaryButtonClick: closeWidget,
|
|
5828
5828
|
},
|
|
5829
|
-
[
|
|
5829
|
+
[AddTokensErrorTypes.TRANSACTION_FAILED]: {
|
|
5830
5830
|
headingText: 'Transaction failed',
|
|
5831
5831
|
subHeadingText: 'The transaction failed. Please try again.',
|
|
5832
5832
|
primaryButtonText: 'Retry',
|
|
5833
|
-
onPrimaryButtonClick:
|
|
5833
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5834
5834
|
secondaryButtonText: 'Close',
|
|
5835
5835
|
onSecondaryButtonClick: closeWidget,
|
|
5836
5836
|
},
|
|
5837
|
-
[
|
|
5837
|
+
[AddTokensErrorTypes.UNRECOGNISED_CHAIN]: {
|
|
5838
5838
|
headingText: 'Unrecognised chain',
|
|
5839
5839
|
subHeadingText: 'Please add the chain to your account and try again.',
|
|
5840
5840
|
primaryButtonText: 'Retry',
|
|
5841
|
-
onPrimaryButtonClick:
|
|
5841
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5842
5842
|
secondaryButtonText: 'Close',
|
|
5843
5843
|
onSecondaryButtonClick: closeWidget,
|
|
5844
5844
|
},
|
|
5845
|
-
[
|
|
5845
|
+
[AddTokensErrorTypes.PROVIDER_ERROR]: {
|
|
5846
5846
|
headingText: 'Wallet cannot be found',
|
|
5847
5847
|
subHeadingText: 'Please try to connect your wallet and try again.',
|
|
5848
5848
|
primaryButtonText: 'Retry',
|
|
5849
|
-
onPrimaryButtonClick:
|
|
5849
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5850
5850
|
secondaryButtonText: 'Close',
|
|
5851
5851
|
onSecondaryButtonClick: closeWidget,
|
|
5852
5852
|
},
|
|
5853
|
-
[
|
|
5853
|
+
[AddTokensErrorTypes.WALLET_FAILED]: {
|
|
5854
5854
|
headingText: 'Transaction failed',
|
|
5855
5855
|
subHeadingText: 'The transaction failed. Please try again.',
|
|
5856
5856
|
primaryButtonText: 'Retry',
|
|
5857
|
-
onPrimaryButtonClick:
|
|
5857
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5858
5858
|
secondaryButtonText: 'Close',
|
|
5859
|
-
onSecondaryButtonClick:
|
|
5859
|
+
onSecondaryButtonClick: goBackToAddTokensView,
|
|
5860
5860
|
},
|
|
5861
|
-
[
|
|
5861
|
+
[AddTokensErrorTypes.WALLET_REJECTED]: {
|
|
5862
5862
|
headingText: 'Transaction rejected',
|
|
5863
5863
|
subHeadingText: "You'll need to approve the transaction in your wallet to proceed.",
|
|
5864
5864
|
primaryButtonText: 'Retry',
|
|
5865
|
-
onPrimaryButtonClick:
|
|
5865
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5866
5866
|
secondaryButtonText: 'Close',
|
|
5867
5867
|
onSecondaryButtonClick: closeWidget,
|
|
5868
5868
|
},
|
|
5869
|
-
[
|
|
5869
|
+
[AddTokensErrorTypes.WALLET_REJECTED_NO_FUNDS]: {
|
|
5870
5870
|
headingText: 'Insufficient funds',
|
|
5871
5871
|
subHeadingText: 'You do not have enough funds to complete the transaction.',
|
|
5872
5872
|
primaryButtonText: 'Retry',
|
|
5873
|
-
onPrimaryButtonClick:
|
|
5873
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5874
5874
|
secondaryButtonText: 'Close',
|
|
5875
5875
|
onSecondaryButtonClick: closeWidget,
|
|
5876
5876
|
},
|
|
5877
|
-
[
|
|
5877
|
+
[AddTokensErrorTypes.WALLET_POPUP_BLOCKED]: {
|
|
5878
5878
|
headingText: "Browser's popup blocked",
|
|
5879
5879
|
subHeadingText: 'Please allow pop-ups in your browser to proceed.',
|
|
5880
5880
|
primaryButtonText: 'Retry',
|
|
5881
|
-
onPrimaryButtonClick:
|
|
5881
|
+
onPrimaryButtonClick: goBackToAddTokensView,
|
|
5882
5882
|
secondaryButtonText: 'Close',
|
|
5883
|
-
onSecondaryButtonClick:
|
|
5883
|
+
onSecondaryButtonClick: goBackToAddTokensView,
|
|
5884
5884
|
},
|
|
5885
|
-
[
|
|
5885
|
+
[AddTokensErrorTypes.ENVIRONMENT_ERROR]: {
|
|
5886
5886
|
headingText: 'Unsupported environment',
|
|
5887
5887
|
subHeadingText: 'This is only supported in production environment.',
|
|
5888
5888
|
secondaryButtonText: 'Close',
|
|
@@ -5892,7 +5892,7 @@ const useError = (environment) => {
|
|
|
5892
5892
|
const getErrorConfig = (errorType) => errorConfig[errorType];
|
|
5893
5893
|
const showErrorHandover = (errorType, data) => {
|
|
5894
5894
|
page({
|
|
5895
|
-
userJourney: UserJourney.
|
|
5895
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5896
5896
|
screen: 'Error',
|
|
5897
5897
|
extras: {
|
|
5898
5898
|
errorType,
|
|
@@ -5915,15 +5915,15 @@ function SquidFooter() {
|
|
|
5915
5915
|
return (jsx(Body, { size: "xSmall", sx: {
|
|
5916
5916
|
textAlign: 'center',
|
|
5917
5917
|
color: 'base.color.text.body.secondary',
|
|
5918
|
-
}, children: jsx(Trans, { i18nKey: t('views.
|
|
5918
|
+
}, children: jsx(Trans, { i18nKey: t('views.ADD_TOKENS.footer.body'), components: {
|
|
5919
5919
|
squidLink: jsx(Link, { size: "xSmall", rc: jsx("a", { target: "_blank", href: " https://app.squidrouter.com", rel: "noreferrer" }) }),
|
|
5920
5920
|
} }) }));
|
|
5921
5921
|
}
|
|
5922
5922
|
|
|
5923
|
-
function
|
|
5923
|
+
function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOption = true, showSwapOption = true, showBridgeOption = true, onCloseButtonClick, showBackButton, onBackButtonClick, }) {
|
|
5924
5924
|
const { fetchRoutesWithRateLimit, resetRoutes } = useRoutes();
|
|
5925
5925
|
const { showErrorHandover } = useError(config.environment);
|
|
5926
|
-
const {
|
|
5926
|
+
const { addTokensState: { squid, chains, balances, tokens, selectedAmount, routes, selectedRouteData, selectedToken, isSwapAvailable, }, addTokensDispatch, } = reactExports.useContext(AddTokensContext);
|
|
5927
5927
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
5928
5928
|
const { track, page } = useAnalytics();
|
|
5929
5929
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
@@ -5938,7 +5938,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5938
5938
|
const selectedAmountUsd = reactExports.useMemo(() => convertToUsd(tokens, inputValue, selectedToken), [tokens, inputValue, selectedToken]);
|
|
5939
5939
|
const setSelectedAmount = reactExports.useMemo(() => debounce$2((value) => {
|
|
5940
5940
|
track({
|
|
5941
|
-
userJourney: UserJourney.
|
|
5941
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5942
5942
|
screen: 'InputScreen',
|
|
5943
5943
|
control: 'AmountInput',
|
|
5944
5944
|
controlType: 'TextInput',
|
|
@@ -5946,16 +5946,16 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5946
5946
|
toAmount: value,
|
|
5947
5947
|
},
|
|
5948
5948
|
});
|
|
5949
|
-
|
|
5949
|
+
addTokensDispatch({
|
|
5950
5950
|
payload: {
|
|
5951
|
-
type:
|
|
5951
|
+
type: AddTokensActions.SET_SELECTED_AMOUNT,
|
|
5952
5952
|
selectedAmount: value,
|
|
5953
5953
|
},
|
|
5954
5954
|
});
|
|
5955
5955
|
}, 2500), []);
|
|
5956
5956
|
const setSelectedToken = (token) => {
|
|
5957
5957
|
track({
|
|
5958
|
-
userJourney: UserJourney.
|
|
5958
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5959
5959
|
screen: 'InputScreen',
|
|
5960
5960
|
control: 'TokensMenu',
|
|
5961
5961
|
controlType: 'MenuItem',
|
|
@@ -5963,9 +5963,9 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5963
5963
|
tokenAddress: token?.address,
|
|
5964
5964
|
},
|
|
5965
5965
|
});
|
|
5966
|
-
|
|
5966
|
+
addTokensDispatch({
|
|
5967
5967
|
payload: {
|
|
5968
|
-
type:
|
|
5968
|
+
type: AddTokensActions.SET_SELECTED_TOKEN,
|
|
5969
5969
|
selectedToken: token,
|
|
5970
5970
|
},
|
|
5971
5971
|
});
|
|
@@ -5973,7 +5973,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5973
5973
|
const setSelectedRouteData = (route) => {
|
|
5974
5974
|
if (route) {
|
|
5975
5975
|
track({
|
|
5976
|
-
userJourney: UserJourney.
|
|
5976
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
5977
5977
|
screen: 'InputScreen',
|
|
5978
5978
|
control: 'RoutesMenu',
|
|
5979
5979
|
controlType: 'MenuItem',
|
|
@@ -5987,9 +5987,9 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
5987
5987
|
},
|
|
5988
5988
|
});
|
|
5989
5989
|
}
|
|
5990
|
-
|
|
5990
|
+
addTokensDispatch({
|
|
5991
5991
|
payload: {
|
|
5992
|
-
type:
|
|
5992
|
+
type: AddTokensActions.SET_SELECTED_ROUTE_DATA,
|
|
5993
5993
|
selectedRouteData: route,
|
|
5994
5994
|
},
|
|
5995
5995
|
});
|
|
@@ -6020,7 +6020,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6020
6020
|
}), [providers]);
|
|
6021
6021
|
reactExports.useEffect(() => {
|
|
6022
6022
|
page({
|
|
6023
|
-
userJourney: UserJourney.
|
|
6023
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6024
6024
|
screen: 'InputScreen',
|
|
6025
6025
|
extras: {
|
|
6026
6026
|
toAmount,
|
|
@@ -6091,16 +6091,16 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6091
6091
|
setSelectedToken(token);
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
|
-
|
|
6094
|
+
addTokensDispatch({
|
|
6095
6095
|
payload: {
|
|
6096
|
-
type:
|
|
6096
|
+
type: AddTokensActions.SET_ALLOWED_TOKENS,
|
|
6097
6097
|
allowedTokens: tokenResponse.tokens,
|
|
6098
6098
|
},
|
|
6099
6099
|
});
|
|
6100
6100
|
}
|
|
6101
6101
|
}
|
|
6102
6102
|
catch (error) {
|
|
6103
|
-
showErrorHandover(
|
|
6103
|
+
showErrorHandover(AddTokensErrorTypes.SERVICE_BREAKDOWN, { error });
|
|
6104
6104
|
}
|
|
6105
6105
|
};
|
|
6106
6106
|
fetchTokens();
|
|
@@ -6119,7 +6119,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6119
6119
|
}
|
|
6120
6120
|
}
|
|
6121
6121
|
catch (error) {
|
|
6122
|
-
showErrorHandover(
|
|
6122
|
+
showErrorHandover(AddTokensErrorTypes.SERVICE_BREAKDOWN, { error });
|
|
6123
6123
|
}
|
|
6124
6124
|
};
|
|
6125
6125
|
fetchOnRampTokens();
|
|
@@ -6130,7 +6130,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6130
6130
|
}, []);
|
|
6131
6131
|
const handleCardClick = () => {
|
|
6132
6132
|
track({
|
|
6133
|
-
userJourney: UserJourney.
|
|
6133
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6134
6134
|
screen: 'InputScreen',
|
|
6135
6135
|
control: 'PayWithCardMenu',
|
|
6136
6136
|
controlType: 'MenuItem',
|
|
@@ -6144,7 +6144,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6144
6144
|
amount: selectedAmount ?? '',
|
|
6145
6145
|
showBackButton: true,
|
|
6146
6146
|
};
|
|
6147
|
-
orchestrationEvents.sendRequestOnrampEvent(eventTarget, IMTBLWidgetEvents.
|
|
6147
|
+
orchestrationEvents.sendRequestOnrampEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, data);
|
|
6148
6148
|
};
|
|
6149
6149
|
const handleRouteClick = (route) => {
|
|
6150
6150
|
setShowOptionsDrawer(false);
|
|
@@ -6156,7 +6156,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6156
6156
|
if (!selectedRouteData || !selectedToken?.address)
|
|
6157
6157
|
return;
|
|
6158
6158
|
track({
|
|
6159
|
-
userJourney: UserJourney.
|
|
6159
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6160
6160
|
screen: 'InputScreen',
|
|
6161
6161
|
control: 'RoutesMenu',
|
|
6162
6162
|
controlType: 'MenuItem',
|
|
@@ -6173,7 +6173,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6173
6173
|
payload: {
|
|
6174
6174
|
type: ViewActions.UPDATE_VIEW,
|
|
6175
6175
|
view: {
|
|
6176
|
-
type:
|
|
6176
|
+
type: AddTokensWidgetViews.REVIEW,
|
|
6177
6177
|
data: {
|
|
6178
6178
|
balance: selectedRouteData.amountData.balance,
|
|
6179
6179
|
toChainId: ChainId.IMTBL_ZKEVM_MAINNET.toString(),
|
|
@@ -6205,7 +6205,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6205
6205
|
const readyToReview = routeInputsReady && !!toAddress && !!selectedRouteData && !loading;
|
|
6206
6206
|
const handleWalletConnected = (providerType, provider, providerInfo) => {
|
|
6207
6207
|
track({
|
|
6208
|
-
userJourney: UserJourney.
|
|
6208
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
6209
6209
|
screen: 'InputScreen',
|
|
6210
6210
|
control: 'WalletsMenu',
|
|
6211
6211
|
controlType: 'MenuItem',
|
|
@@ -6240,7 +6240,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6240
6240
|
boxShadow: ({ base }) => `0 0 0 ${base.border.size[200]} ${base.color.text.body.primary}`,
|
|
6241
6241
|
},
|
|
6242
6242
|
} })),
|
|
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-
|
|
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-tokens-amount-input", type: "number", value: inputValue, onChange: (value) => handleOnAmountInputChange(value), placeholder: "0", maxTextSize: "xLarge" }), jsxs(HeroFormControl.Caption, { children: ["USD $", getFormattedNumberWithDecimalPlaces(selectedAmountUsd)] })] }))] }), jsxs(Stack, { testId: "bottomSection", sx: {
|
|
6244
6244
|
alignSelf: 'stretch',
|
|
6245
6245
|
p: 'base.spacing.x3',
|
|
6246
6246
|
pb: 'base.spacing.x5',
|
|
@@ -6261,7 +6261,7 @@ function AddFunds({ checkout, toAmount, config, toTokenAddress, showOnrampOption
|
|
|
6261
6261
|
} }) }), jsx(SelectedWallet, { label: "Deliver to", providerInfo: {
|
|
6262
6262
|
...toProviderInfo,
|
|
6263
6263
|
address: toAddress,
|
|
6264
|
-
}, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx(Button, { testId: "add-
|
|
6264
|
+
}, 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
6265
|
}
|
|
6266
6266
|
|
|
6267
6267
|
var dist$2 = {};
|
|
@@ -173356,24 +173356,24 @@ const useExecute = (environment) => {
|
|
|
173356
173356
|
const { showErrorHandover } = useError(environment);
|
|
173357
173357
|
const handleTransactionError = (err) => {
|
|
173358
173358
|
const reason = `${err?.reason || err?.message || ''}`.toLowerCase();
|
|
173359
|
-
let errorType =
|
|
173359
|
+
let errorType = AddTokensErrorTypes.WALLET_FAILED;
|
|
173360
173360
|
if (reason.includes('failed') && reason.includes('open confirmation')) {
|
|
173361
|
-
errorType =
|
|
173361
|
+
errorType = AddTokensErrorTypes.WALLET_POPUP_BLOCKED;
|
|
173362
173362
|
}
|
|
173363
173363
|
if (reason.includes('rejected') && reason.includes('user')) {
|
|
173364
|
-
errorType =
|
|
173364
|
+
errorType = AddTokensErrorTypes.WALLET_REJECTED;
|
|
173365
173365
|
}
|
|
173366
173366
|
if (reason.includes('failed to submit')
|
|
173367
173367
|
&& reason.includes('highest gas limit')) {
|
|
173368
|
-
errorType =
|
|
173368
|
+
errorType = AddTokensErrorTypes.WALLET_REJECTED_NO_FUNDS;
|
|
173369
173369
|
}
|
|
173370
173370
|
if (reason.includes('status failed')
|
|
173371
173371
|
|| reason.includes('transaction failed')) {
|
|
173372
|
-
errorType =
|
|
173372
|
+
errorType = AddTokensErrorTypes.TRANSACTION_FAILED;
|
|
173373
173373
|
}
|
|
173374
173374
|
if (reason.includes('unrecognized chain')
|
|
173375
173375
|
|| reason.includes('unrecognized chain')) {
|
|
173376
|
-
errorType =
|
|
173376
|
+
errorType = AddTokensErrorTypes.UNRECOGNISED_CHAIN;
|
|
173377
173377
|
}
|
|
173378
173378
|
const error = {
|
|
173379
173379
|
type: errorType,
|
|
@@ -173429,7 +173429,7 @@ const useExecute = (environment) => {
|
|
|
173429
173429
|
return MaxUint256; // no approval is needed for native tokens
|
|
173430
173430
|
}
|
|
173431
173431
|
catch (error) {
|
|
173432
|
-
showErrorHandover(
|
|
173432
|
+
showErrorHandover(AddTokensErrorTypes.DEFAULT, { error });
|
|
173433
173433
|
return undefined;
|
|
173434
173434
|
}
|
|
173435
173435
|
};
|
|
@@ -173578,7 +173578,7 @@ const dividerSx = {
|
|
|
173578
173578
|
function Review({ data, showBackButton = false, onBackButtonClick, onCloseButtonClick, }) {
|
|
173579
173579
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
173580
173580
|
const { track, page } = useAnalytics();
|
|
173581
|
-
const {
|
|
173581
|
+
const { addTokensState: { squid, chains, tokens }, } = reactExports.useContext(AddTokensContext);
|
|
173582
173582
|
const { providersState: { checkout, fromProvider, fromAddress, toAddress, }, } = useProvidersContext();
|
|
173583
173583
|
const [route, setRoute] = reactExports.useState();
|
|
173584
173584
|
const [proceedDisabled, setProceedDisabled] = reactExports.useState(true);
|
|
@@ -173592,7 +173592,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173592
173592
|
const { checkProviderChain, getAllowance, approve, execute, } = useExecute(checkout?.config.environment || Environment.SANDBOX);
|
|
173593
173593
|
reactExports.useEffect(() => {
|
|
173594
173594
|
page({
|
|
173595
|
-
userJourney: UserJourney.
|
|
173595
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
173596
173596
|
screen: 'Review',
|
|
173597
173597
|
extras: {
|
|
173598
173598
|
toAmount: data.toAmount,
|
|
@@ -173653,7 +173653,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173653
173653
|
currentFromAddress = await fromProvider.getSigner().getAddress();
|
|
173654
173654
|
}
|
|
173655
173655
|
catch (error) {
|
|
173656
|
-
showErrorHandover(
|
|
173656
|
+
showErrorHandover(AddTokensErrorTypes.PROVIDER_ERROR, { error });
|
|
173657
173657
|
return;
|
|
173658
173658
|
}
|
|
173659
173659
|
if (currentFromAddress !== fromAddress) {
|
|
@@ -173682,7 +173682,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173682
173682
|
const executeTxnReceipt = await execute(squid, changeableProvider, route);
|
|
173683
173683
|
if (executeTxnReceipt) {
|
|
173684
173684
|
track({
|
|
173685
|
-
userJourney: UserJourney.
|
|
173685
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
173686
173686
|
screen: 'FundsAdded',
|
|
173687
173687
|
action: 'Succeeded',
|
|
173688
173688
|
extras: {
|
|
@@ -173769,7 +173769,7 @@ function Review({ data, showBackButton = false, onBackButtonClick, onCloseButton
|
|
|
173769
173769
|
payload: {
|
|
173770
173770
|
type: ViewActions.UPDATE_VIEW,
|
|
173771
173771
|
view: {
|
|
173772
|
-
type:
|
|
173772
|
+
type: AddTokensWidgetViews.ADD_TOKENS,
|
|
173773
173773
|
},
|
|
173774
173774
|
},
|
|
173775
173775
|
});
|
|
@@ -173853,13 +173853,13 @@ const useTokens = (checkout) => {
|
|
|
173853
173853
|
return tokens;
|
|
173854
173854
|
};
|
|
173855
173855
|
|
|
173856
|
-
function
|
|
173856
|
+
function AddTokensWidget({ showOnrampOption = true, showSwapOption = true, showBridgeOption = true, toTokenAddress, toAmount, showBackButton, config, }) {
|
|
173857
173857
|
const fetchingBalances = reactExports.useRef(false);
|
|
173858
173858
|
const { base: { colorMode } } = useTheme();
|
|
173859
173859
|
const [viewState, viewDispatch] = reactExports.useReducer(viewReducer, {
|
|
173860
173860
|
...initialViewState,
|
|
173861
|
-
view: { type:
|
|
173862
|
-
history: [{ type:
|
|
173861
|
+
view: { type: AddTokensWidgetViews.ADD_TOKENS },
|
|
173862
|
+
history: [{ type: AddTokensWidgetViews.ADD_TOKENS }],
|
|
173863
173863
|
});
|
|
173864
173864
|
const { t } = useTranslation();
|
|
173865
173865
|
const { page } = useAnalytics();
|
|
@@ -173867,28 +173867,28 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173867
173867
|
viewState,
|
|
173868
173868
|
viewDispatch,
|
|
173869
173869
|
}), [viewState, viewReducer]);
|
|
173870
|
-
const [
|
|
173870
|
+
const [addTokensState, addTokensDispatch] = reactExports.useReducer(addTokensReducer, initialAddTokensState);
|
|
173871
173871
|
const { providersState: { checkout, fromProvider }, } = useProvidersContext();
|
|
173872
|
-
const { squid, chains } =
|
|
173873
|
-
const
|
|
173874
|
-
|
|
173875
|
-
|
|
173876
|
-
}), [
|
|
173872
|
+
const { squid, chains } = addTokensState;
|
|
173873
|
+
const addTokensReducerValues = reactExports.useMemo(() => ({
|
|
173874
|
+
addTokensState,
|
|
173875
|
+
addTokensDispatch,
|
|
173876
|
+
}), [addTokensState, addTokensDispatch]);
|
|
173877
173877
|
const squidSdk = useSquid(checkout);
|
|
173878
173878
|
const tokensResponse = useTokens(checkout);
|
|
173879
173879
|
const { showErrorHandover } = useError(checkout.config.environment);
|
|
173880
173880
|
reactExports.useEffect(() => {
|
|
173881
173881
|
if (config.environment !== Environment.PRODUCTION) {
|
|
173882
|
-
showErrorHandover(
|
|
173882
|
+
showErrorHandover(AddTokensErrorTypes.ENVIRONMENT_ERROR);
|
|
173883
173883
|
}
|
|
173884
173884
|
}, [config]);
|
|
173885
173885
|
reactExports.useEffect(() => {
|
|
173886
173886
|
if (!checkout)
|
|
173887
173887
|
return;
|
|
173888
173888
|
(async () => {
|
|
173889
|
-
|
|
173889
|
+
addTokensDispatch({
|
|
173890
173890
|
payload: {
|
|
173891
|
-
type:
|
|
173891
|
+
type: AddTokensActions.SET_IS_SWAP_AVAILABLE,
|
|
173892
173892
|
isSwapAvailable: await checkout.isSwapAvailable(),
|
|
173893
173893
|
},
|
|
173894
173894
|
});
|
|
@@ -173898,15 +173898,15 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173898
173898
|
const isInvalidToTokenAddress = toTokenAddress && !isValidAddress(toTokenAddress);
|
|
173899
173899
|
const isInvalidToAmount = toAmount && !amountInputValidation(toAmount);
|
|
173900
173900
|
if (isInvalidToTokenAddress || isInvalidToAmount) {
|
|
173901
|
-
showErrorHandover(
|
|
173901
|
+
showErrorHandover(AddTokensErrorTypes.INVALID_PARAMETERS);
|
|
173902
173902
|
}
|
|
173903
173903
|
}, [toTokenAddress, toAmount]);
|
|
173904
173904
|
reactExports.useEffect(() => {
|
|
173905
173905
|
(async () => {
|
|
173906
173906
|
const chainsResponse = await fetchChains();
|
|
173907
|
-
|
|
173907
|
+
addTokensDispatch({
|
|
173908
173908
|
payload: {
|
|
173909
|
-
type:
|
|
173909
|
+
type: AddTokensActions.SET_CHAINS,
|
|
173910
173910
|
chains: chainsResponse,
|
|
173911
173911
|
},
|
|
173912
173912
|
});
|
|
@@ -173920,9 +173920,9 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173920
173920
|
fetchingBalances.current = true;
|
|
173921
173921
|
const evmChains = chains.filter((chain) => chain.type === 'evm');
|
|
173922
173922
|
const balances = await fetchBalances(squid, evmChains, fromProvider);
|
|
173923
|
-
|
|
173923
|
+
addTokensDispatch({
|
|
173924
173924
|
payload: {
|
|
173925
|
-
type:
|
|
173925
|
+
type: AddTokensActions.SET_BALANCES,
|
|
173926
173926
|
balances,
|
|
173927
173927
|
},
|
|
173928
173928
|
});
|
|
@@ -173935,9 +173935,9 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173935
173935
|
reactExports.useEffect(() => {
|
|
173936
173936
|
if (!squidSdk)
|
|
173937
173937
|
return;
|
|
173938
|
-
|
|
173938
|
+
addTokensDispatch({
|
|
173939
173939
|
payload: {
|
|
173940
|
-
type:
|
|
173940
|
+
type: AddTokensActions.SET_SQUID,
|
|
173941
173941
|
squid: squidSdk,
|
|
173942
173942
|
},
|
|
173943
173943
|
});
|
|
@@ -173945,9 +173945,9 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173945
173945
|
reactExports.useEffect(() => {
|
|
173946
173946
|
if (!tokensResponse)
|
|
173947
173947
|
return;
|
|
173948
|
-
|
|
173948
|
+
addTokensDispatch({
|
|
173949
173949
|
payload: {
|
|
173950
|
-
type:
|
|
173950
|
+
type: AddTokensActions.SET_TOKENS,
|
|
173951
173951
|
tokens: tokensResponse,
|
|
173952
173952
|
},
|
|
173953
173953
|
});
|
|
@@ -173957,31 +173957,31 @@ function AddFundsWidget({ showOnrampOption = true, showSwapOption = true, showBr
|
|
|
173957
173957
|
viewDispatch({
|
|
173958
173958
|
payload: {
|
|
173959
173959
|
type: ViewActions.UPDATE_VIEW,
|
|
173960
|
-
view: { type:
|
|
173960
|
+
view: { type: AddTokensWidgetViews.ADD_TOKENS },
|
|
173961
173961
|
},
|
|
173962
173962
|
});
|
|
173963
173963
|
};
|
|
173964
|
-
return (jsx(ViewContext.Provider, { value: viewReducerValues, children: jsx(
|
|
173964
|
+
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
173965
|
pos: 'absolute',
|
|
173966
173966
|
h: '100%',
|
|
173967
173967
|
w: '100%',
|
|
173968
173968
|
objectFit: 'cover',
|
|
173969
173969
|
objectPosition: 'center',
|
|
173970
|
-
} }), viewState.view.type ===
|
|
173971
|
-
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.
|
|
173972
|
-
} })), viewState.view.type ===
|
|
173970
|
+
} }), 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: () => {
|
|
173971
|
+
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_TOKENS_WIDGET_EVENT, {});
|
|
173972
|
+
} })), viewState.view.type === AddTokensWidgetViews.REVIEW && (jsx(Review, { data: viewState.view.data, onCloseButtonClick: () => sendAddTokensCloseEvent(eventTarget), onBackButtonClick: () => {
|
|
173973
173973
|
viewDispatch({
|
|
173974
173974
|
payload: {
|
|
173975
173975
|
type: ViewActions.GO_BACK,
|
|
173976
173976
|
},
|
|
173977
173977
|
});
|
|
173978
|
-
}, showBackButton: true })), viewState.view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { actionText: t('views.ERROR_VIEW.actionText'), onActionClick: errorAction, onCloseClick: () =>
|
|
173978
|
+
}, showBackButton: true })), viewState.view.type === SharedViews.ERROR_VIEW && (jsx(ErrorView, { actionText: t('views.ERROR_VIEW.actionText'), onActionClick: errorAction, onCloseClick: () => sendAddTokensCloseEvent(eventTarget), errorEventAction: () => {
|
|
173979
173979
|
page({
|
|
173980
|
-
userJourney: UserJourney.
|
|
173980
|
+
userJourney: UserJourney.ADD_TOKENS,
|
|
173981
173981
|
screen: 'Error',
|
|
173982
173982
|
});
|
|
173983
173983
|
} })), viewState.view.type
|
|
173984
|
-
=== SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (jsx(ServiceUnavailableErrorView, { service: ServiceType.GENERIC, onCloseClick: () =>
|
|
173984
|
+
=== SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && (jsx(ServiceUnavailableErrorView, { service: ServiceType.GENERIC, onCloseClick: () => sendAddTokensCloseEvent(eventTarget) }))] }) }) }));
|
|
173985
173985
|
}
|
|
173986
173986
|
|
|
173987
|
-
export {
|
|
173987
|
+
export { AddTokensWidget as default };
|