@imtbl/sdk 1.30.0-alpha.7 → 1.30.0-alpha.8
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.js +2 -2
- package/dist/browser/checkout/{BridgeWidget-51ce1387.js → BridgeWidget-e42b9f82.js} +1 -1
- package/dist/browser/checkout/{HorizontalMenu-75e465c0.js → HorizontalMenu-abeb3f9e.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-2c83424e.js → OnRampWidget-be92b2b1.js} +1 -1
- package/dist/browser/checkout/{SaleWidget-d31be72e.js → SaleWidget-303c922e.js} +1 -1
- package/dist/browser/checkout/{SpendingCapHero-b0dce7c9.js → SpendingCapHero-84dc756f.js} +1 -1
- package/dist/browser/checkout/SwapWidget-0ebc34b3.js +1 -0
- package/dist/browser/checkout/{TopUpView-e7c322fa.js → TopUpView-658767e5.js} +1 -1
- package/dist/browser/checkout/{WalletWidget-8718feff.js → WalletWidget-bc2804c5.js} +1 -1
- package/dist/browser/checkout/{auto-track-3704c9a6.js → auto-track-8ee8c1c4.js} +1 -1
- package/dist/browser/checkout/{balance-d56c60d4.js → balance-1f0de3ac.js} +1 -1
- package/dist/browser/checkout/index-05a0f5e3.js +1 -0
- package/dist/browser/checkout/{index-7d430f20.js → index-17ada566.js} +1 -1
- package/dist/browser/checkout/{index-e8c4ec89.js → index-784363ef.js} +1 -1
- package/dist/browser/checkout/{index-aad9a3ee.js → index-8cc6b23b.js} +2 -2
- package/dist/browser/checkout/{index-80392bd7.js → index-9e6fdcc3.js} +1 -1
- package/dist/browser/checkout/{index-ea3863ef.js → index-cab90969.js} +1 -1
- package/dist/browser/checkout/{index-9d6944b2.js → index-ed4cd0bb.js} +1 -1
- package/dist/browser/checkout/{index-020bde05.js → index-f2932839.js} +1 -1
- package/dist/browser/checkout/{index.umd-14e670d3.js → index.umd-c8f6d9c7.js} +1 -1
- package/dist/browser/checkout/{retry-ebd849e0.js → retry-d0541bc6.js} +1 -1
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +1 -1
- package/dist/checkout.js +4 -4
- package/dist/config.js +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.cjs +7 -7
- package/dist/index.js +7 -7
- package/dist/orderbook.js +1 -1
- package/dist/passport.js +4 -4
- package/dist/x.js +3 -3
- package/package.json +1 -1
- package/dist/browser/checkout/SwapWidget-a9d28254.js +0 -1
- package/dist/browser/checkout/index-761dc84d.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -183,7 +183,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
186
|
-
const SDK_VERSION$1 = '1.30.0-alpha.
|
|
186
|
+
const SDK_VERSION$1 = '1.30.0-alpha.8';
|
|
187
187
|
const getFrameParentDomain$1 = () => {
|
|
188
188
|
if (isNode$1()) {
|
|
189
189
|
return '';
|
|
@@ -14194,7 +14194,7 @@ class MultiRollupApiClients {
|
|
|
14194
14194
|
}
|
|
14195
14195
|
|
|
14196
14196
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14197
|
-
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
14197
|
+
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
14198
14198
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
14199
14199
|
if (!basePath.trim()) {
|
|
14200
14200
|
throw Error('basePath can not be empty');
|
|
@@ -14266,7 +14266,7 @@ class APIError extends Error {
|
|
|
14266
14266
|
|
|
14267
14267
|
/* eslint-disable implicit-arrow-linebreak */
|
|
14268
14268
|
const defaultHeaders$1 = {
|
|
14269
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.30.0-alpha.
|
|
14269
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.30.0-alpha.8',
|
|
14270
14270
|
};
|
|
14271
14271
|
/**
|
|
14272
14272
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -14740,7 +14740,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
|
|
|
14740
14740
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
14741
14741
|
class ApiConfiguration extends index$2.Configuration {
|
|
14742
14742
|
}
|
|
14743
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
14743
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
14744
14744
|
/**
|
|
14745
14745
|
* @dev use createImmutableXConfiguration instead
|
|
14746
14746
|
*/
|
|
@@ -14779,7 +14779,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
14779
14779
|
chainID,
|
|
14780
14780
|
coreContractAddress,
|
|
14781
14781
|
registrationContractAddress,
|
|
14782
|
-
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.
|
|
14782
|
+
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.8',
|
|
14783
14783
|
baseConfig,
|
|
14784
14784
|
});
|
|
14785
14785
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
|
@@ -57535,7 +57535,7 @@ const flattenProperties = (properties) => {
|
|
|
57535
57535
|
};
|
|
57536
57536
|
|
|
57537
57537
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
57538
|
-
const SDK_VERSION = '1.30.0-alpha.
|
|
57538
|
+
const SDK_VERSION = '1.30.0-alpha.8';
|
|
57539
57539
|
const getFrameParentDomain = () => {
|
|
57540
57540
|
if (isNode()) {
|
|
57541
57541
|
return '';
|
|
@@ -62756,7 +62756,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
62756
62756
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
62757
62757
|
};
|
|
62758
62758
|
|
|
62759
|
-
const SDK_VERSION_MARKER = '1.30.0-alpha.
|
|
62759
|
+
const SDK_VERSION_MARKER = '1.30.0-alpha.8';
|
|
62760
62760
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
62761
62761
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
62762
62762
|
|
package/dist/index.js
CHANGED
|
@@ -160,7 +160,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
163
|
-
const SDK_VERSION$1 = '1.30.0-alpha.
|
|
163
|
+
const SDK_VERSION$1 = '1.30.0-alpha.8';
|
|
164
164
|
const getFrameParentDomain$1 = () => {
|
|
165
165
|
if (isNode$1()) {
|
|
166
166
|
return '';
|
|
@@ -14171,7 +14171,7 @@ class MultiRollupApiClients {
|
|
|
14171
14171
|
}
|
|
14172
14172
|
|
|
14173
14173
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14174
|
-
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
14174
|
+
const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
14175
14175
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
14176
14176
|
if (!basePath.trim()) {
|
|
14177
14177
|
throw Error('basePath can not be empty');
|
|
@@ -14243,7 +14243,7 @@ class APIError extends Error {
|
|
|
14243
14243
|
|
|
14244
14244
|
/* eslint-disable implicit-arrow-linebreak */
|
|
14245
14245
|
const defaultHeaders$1 = {
|
|
14246
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.30.0-alpha.
|
|
14246
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.30.0-alpha.8',
|
|
14247
14247
|
};
|
|
14248
14248
|
/**
|
|
14249
14249
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -14717,7 +14717,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
|
|
|
14717
14717
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
14718
14718
|
class ApiConfiguration extends index$2.Configuration {
|
|
14719
14719
|
}
|
|
14720
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
14720
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
14721
14721
|
/**
|
|
14722
14722
|
* @dev use createImmutableXConfiguration instead
|
|
14723
14723
|
*/
|
|
@@ -14756,7 +14756,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
14756
14756
|
chainID,
|
|
14757
14757
|
coreContractAddress,
|
|
14758
14758
|
registrationContractAddress,
|
|
14759
|
-
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.
|
|
14759
|
+
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.8',
|
|
14760
14760
|
baseConfig,
|
|
14761
14761
|
});
|
|
14762
14762
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
|
@@ -57512,7 +57512,7 @@ const flattenProperties = (properties) => {
|
|
|
57512
57512
|
};
|
|
57513
57513
|
|
|
57514
57514
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
57515
|
-
const SDK_VERSION = '1.30.0-alpha.
|
|
57515
|
+
const SDK_VERSION = '1.30.0-alpha.8';
|
|
57516
57516
|
const getFrameParentDomain = () => {
|
|
57517
57517
|
if (isNode()) {
|
|
57518
57518
|
return '';
|
|
@@ -62733,7 +62733,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
62733
62733
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
62734
62734
|
};
|
|
62735
62735
|
|
|
62736
|
-
const SDK_VERSION_MARKER = '1.30.0-alpha.
|
|
62736
|
+
const SDK_VERSION_MARKER = '1.30.0-alpha.8';
|
|
62737
62737
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
62738
62738
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
62739
62739
|
|
package/dist/orderbook.js
CHANGED
|
@@ -132,7 +132,7 @@ const flattenProperties = (properties) => {
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
135
|
-
const SDK_VERSION = '1.30.0-alpha.
|
|
135
|
+
const SDK_VERSION = '1.30.0-alpha.8';
|
|
136
136
|
const getFrameParentDomain = () => {
|
|
137
137
|
if (isNode()) {
|
|
138
138
|
return '';
|
package/dist/passport.js
CHANGED
|
@@ -11444,7 +11444,7 @@ class MultiRollupApiClients {
|
|
|
11444
11444
|
}
|
|
11445
11445
|
|
|
11446
11446
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11447
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
11447
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
11448
11448
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
11449
11449
|
if (!basePath.trim()) {
|
|
11450
11450
|
throw Error('basePath can not be empty');
|
|
@@ -11623,7 +11623,7 @@ const flattenProperties = (properties) => {
|
|
|
11623
11623
|
};
|
|
11624
11624
|
|
|
11625
11625
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
11626
|
-
const SDK_VERSION = '1.30.0-alpha.
|
|
11626
|
+
const SDK_VERSION = '1.30.0-alpha.8';
|
|
11627
11627
|
const getFrameParentDomain = () => {
|
|
11628
11628
|
if (isNode()) {
|
|
11629
11629
|
return '';
|
|
@@ -12013,7 +12013,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
12013
12013
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
12014
12014
|
class ApiConfiguration extends index$2.Configuration {
|
|
12015
12015
|
}
|
|
12016
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
12016
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
12017
12017
|
/**
|
|
12018
12018
|
* @dev use createImmutableXConfiguration instead
|
|
12019
12019
|
*/
|
|
@@ -12052,7 +12052,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
12052
12052
|
chainID,
|
|
12053
12053
|
coreContractAddress,
|
|
12054
12054
|
registrationContractAddress,
|
|
12055
|
-
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.
|
|
12055
|
+
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.8',
|
|
12056
12056
|
baseConfig,
|
|
12057
12057
|
});
|
|
12058
12058
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
package/dist/x.js
CHANGED
|
@@ -9003,7 +9003,7 @@ const flattenProperties = (properties) => {
|
|
|
9003
9003
|
};
|
|
9004
9004
|
|
|
9005
9005
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
9006
|
-
const SDK_VERSION = '1.30.0-alpha.
|
|
9006
|
+
const SDK_VERSION = '1.30.0-alpha.8';
|
|
9007
9007
|
const getFrameParentDomain = () => {
|
|
9008
9008
|
if (isNode()) {
|
|
9009
9009
|
return '';
|
|
@@ -9269,7 +9269,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
9269
9269
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
9270
9270
|
class ApiConfiguration extends index$2.Configuration {
|
|
9271
9271
|
}
|
|
9272
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.
|
|
9272
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.30.0-alpha.8' };
|
|
9273
9273
|
/**
|
|
9274
9274
|
* @dev use createImmutableXConfiguration instead
|
|
9275
9275
|
*/
|
|
@@ -9308,7 +9308,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
9308
9308
|
chainID,
|
|
9309
9309
|
coreContractAddress,
|
|
9310
9310
|
registrationContractAddress,
|
|
9311
|
-
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.
|
|
9311
|
+
sdkVersion: 'ts-immutable-sdk-1.30.0-alpha.8',
|
|
9312
9312
|
baseConfig,
|
|
9313
9313
|
});
|
|
9314
9314
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as e,aP as t,aQ as o,j as a,aR as n,B as s,aS as r,a as i,b as d,aT as c,r as l,ae as p,V as u,C as m,e as w,p as f,U as T,g as y,d as A,i as E,m as v,S,aU as g,ay as x,aV as h,aW as I,H as b,aX as C,aY as k,k as P,l as R,aZ as _,t as F,f as O,y as W,a_ as D,a$ as N,ac as L,aF as V,b0 as U,b1 as B,b2 as M,E as j,z as G,b3 as $,J as z,b4 as H,a0 as J,W as q,b5 as K,_ as X,$ as Q,T as Z,D as Y,b6 as ee,b7 as te,aK as oe,b8 as ae,aJ as ne,b9 as se,ba as re,a1 as ie,I as de}from"./index-aad9a3ee.js";import{S as ce,T as le,a as pe,F as ue,N as me,W as we,g as fe}from"./balance-d56c60d4.js";import{p as Te,S as ye,C as Ae,a as Ee,c as ve,f as Se,T as ge,b as xe}from"./TopUpView-e7c322fa.js";import{u as he}from"./retry-ebd849e0.js";import{S as Ie}from"./SpendingCapHero-b0dce7c9.js";function be({theme:l,environment:p}){const{t:u}=e(),m=l===t.DARK?o(p,"/quickswapdark.webp"):o(p,"/quickswaplight.webp");return a(s,{testId:"quickswap-footer-container",sx:n,children:[a(s,{testId:"quickswap-logo",sx:r,children:[i(d,{size:"xSmall",sx:{paddingRight:"base.spacing.x1"},children:"By"}),i("img",{style:{height:"26px"},alt:"Quickswap logo",src:m})]}),i(d,{testId:"quickswap-footer-disclaimer-text",size:"xSmall",sx:c,children:u("footers.quickswapFooter.disclaimerText")})]})}const Ce={exchange:null,walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,allowedTokens:[]};var ke;!function(e){e.SET_EXCHANGE="SET_EXCHANGE",e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_SUPPORTED_TOP_UPS="SET_SUPPORTED_TOP_UPS",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_ALLOWED_TOKENS="SET_ALLOWED_TOKENS"}(ke||(ke={}));const Pe=l.createContext({swapState:Ce,swapDispatch:()=>{}});Pe.displayName="SwapContext";const Re=(e,t)=>{switch(t.payload.type){case ke.SET_EXCHANGE:return{...e,exchange:t.payload.exchange};case ke.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case ke.SET_NETWORK:return{...e,network:t.payload.network};case ke.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0}};case ke.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case ke.SET_ALLOWED_TOKENS:return{...e,allowedTokens:t.payload.allowedTokens};default:return e}},_e={fromAmountIn:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountIn(s,o.address,n.address,p.from(Te(a,o.decimals)))},fromAmountOut:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountOut(s,n.address,o.address,p.from(Te(a,o.decimals)))}},Fe={display:"flex",flexDirection:"row",justifyContent:"space-between",columnGap:"base.spacing.x1"},Oe={flex:1},We={flex:2};function De({testId:e,options:t,textInputValue:o,textInputPlaceholder:n,textInputValidator:r,textInputType:d,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,textInputTextAlign:u,textInputSubtext:m,textInputErrorMessage:w,selectTextAlign:f,selectSubtext:T,selectErrorMessage:y,textInputMaxButtonClick:A,onSelectChange:E,textInputDisabled:v,selectInputDisabled:S,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h}){return a(s,{sx:Fe,children:[i(s,{sx:Oe,children:i(ce,{testId:`${e}-select-form`,options:t,subtext:T,textAlign:f,errorMessage:y,onSelectChange:E,disabled:S,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h})}),i(s,{sx:We,children:i(le,{type:d,testId:`${e}-text-form`,value:o,placeholder:n,subtext:m,textAlign:u,errorMessage:w,validator:r,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,maxButtonClick:A,disabled:v})})]})}const Ne={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6",paddingX:"base.spacing.x4"},Le={width:"base.icon.size.400"};function Ve({loading:t,updateLoading:o,validator:n,transaction:r,data:d,insufficientFundsForGas:c,openNotEnoughImxDrawer:g,openNetworkSwitchDrawer:x}){const{t:h}=e(),[I,b]=l.useState(!1),{viewDispatch:C}=l.useContext(u),{connectLoaderState:k}=l.useContext(m),{checkout:P,provider:R}=k,{track:_}=w(),F=async()=>{const e=n();if(_({userJourney:T.SWAP,screen:"SwapCoins",control:"Swap",controlType:"Button",extras:{swapFromAddress:d?.fromTokenAddress,swapFromAmount:d?.fromAmount,swapFromTokenSymbol:d?.fromTokenSymbol,swapToAddress:d?.toTokenAddress,swapToAmount:d?.toAmount,swapToTokenSymbol:d?.toTokenSymbol,isSwapFormValid:e,hasFundsForGas:!c}}),e&&P&&R&&r)if(c)g();else{try{const e=await R.provider.request({method:"eth_chainId",params:[]});if(parseInt(e.toString())!==y(P.config))return void x()}catch(e){console.error("Current network check failed",e)}if(r)try{o(!0);const e={fromAmount:d?.fromAmount||"",fromTokenAddress:d?.fromTokenAddress||"",toTokenAddress:d?.toTokenAddress||"",toAmount:d?.toAmount||""};if(r.approval)return void C({payload:{type:A.UPDATE_VIEW,view:{type:ye.APPROVE_ERC20,data:{approveTransaction:r.approval.transaction,transaction:r.swap.transaction,info:r.quote,swapFormInfo:e}}}});const t=await P.sendTransaction({provider:R,transaction:{...r.swap.transaction,gasPrice:E(R)?p.from(0):void 0}});C({payload:{type:A.UPDATE_VIEW,view:{type:ye.IN_PROGRESS,data:{transactionResponse:t.transactionResponse,swapForm:e}}}})}catch(e){if(console.error(e),o(!1),e.type===v.USER_REJECTED_REQUEST_ERROR)return void b(!0);if(e.type===v.UNPREDICTABLE_GAS_LIMIT)return void C({payload:{type:A.UPDATE_VIEW,view:{type:ye.PRICE_SURGE,data:d}}});if(e.type===v.TRANSACTION_FAILED||e.type===v.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status)return void C({payload:{type:A.UPDATE_VIEW,view:{type:ye.FAIL,reason:"Transaction failed",data:d}}});C({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:e}}})}}};return a(s,{sx:Ne,children:[i(f,{testId:"swap-button",disabled:t,variant:"primary",onClick:F,size:"large",children:t?i(f.Icon,{icon:"Loading",sx:Le}):h("views.SWAP.swapForm.buttonText")}),i(pe,{visible:I,showHeaderBar:!1,onCloseDrawer:()=>b(!1),onRetry:()=>{F(),b(!1)}})]})}const Ue={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},Be={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},Me={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},je={width:"100%",height:"base.spacing.x16"},Ge={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"};function $e({environment:t,visible:o,showAdjustAmount:n,hasZeroImx:r,onCloseDrawer:c,onAddCoinsClick:l}){const{t:p}=e(),u=g(t);return i(x,{size:"full",onCloseDrawer:c,visible:o,showHeaderBar:!1,children:i(x.Content,{children:a(s,{testId:"not-enough-gas-bottom-sheet",sx:Ue,children:[i(h,{imageUrl:u,imageResizeServiceUrl:I[t],sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),i(b,{size:"small",sx:Be,testId:"not-enough-gas-heading",children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.heading`)}),i(d,{sx:Be,children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.body`)}),a(s,{sx:Me,children:[n&&i(f,{testId:"not-enough-gas-adjust-amount-button",sx:je,variant:"tertiary",onClick:c,children:p("drawers.notEnoughImx.buttons.adjustAmount")}),i(f,{testId:"not-enough-gas-add-imx-button",sx:je,variant:"tertiary",onClick:l,children:p("drawers.notEnoughImx.buttons.addMoreImx")}),i(f,{sx:je,variant:"tertiary",onClick:c,testId:"not-enough-gas-cancel-button",children:p("drawers.notEnoughImx.buttons.cancel")})]}),i(s,{sx:Ge,children:i(C,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const ze={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x4",paddingX:"base.spacing.x4",height:"100%"},He={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},Je={display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},qe={width:"100%",height:"base.spacing.x16",marginBottom:"base.spacing.x16"},Ke={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"},Xe={width:"base.icon.size.600",fill:"base.color.status.fatal.bright"};function Qe({visible:t,onCloseDrawer:o}){const{t:n}=e();return i(x,{size:"full",onCloseDrawer:o,visible:t,showHeaderBar:!1,children:i(x.Content,{children:a(s,{testId:"unable-to-swap-bottom-sheet",sx:ze,children:[i(k,{icon:"Alert",testId:"unable-to-swap-icon",variant:"bold",sx:Xe}),i(b,{size:"small",sx:He,testId:"unable-to-swap-heading",children:n("drawers.unableToSwap.heading")}),i(d,{sx:He,children:n("drawers.unableToSwap.body")}),i(s,{sx:Je,children:i(f,{sx:qe,variant:"tertiary",onClick:o,testId:"unable-to-swap-cancel-button",children:n("drawers.unableToSwap.buttons.cancel")})}),i(s,{sx:Ke,children:i(C,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const Ze=(e,t=500)=>{const[o,a]=l.useState(e);return l.useEffect((()=>{const o=setTimeout((()=>{a(e)}),t);return()=>{clearTimeout(o)}}),[e,t]),o};class Ye{static id=0;promiseId=0;promise;isCancelled=!1;onCancel=null;rejectPromise=()=>{};constructor(e){Ye.id+=1,this.promiseId=Ye.id,this.promise=new Promise(((t,o)=>{this.rejectPromise=o,e((e=>{this.isCancelled?o({cancelled:!0}):t(e)}),(e=>{this.isCancelled?o({cancelled:!0}):o(e)}))}))}static all(e){return new Ye(((t,o)=>{Promise.all(e.map((e=>e instanceof Ye?e.promise:e))).then(t,o)}))}then(e,t){return new Ye(((o,a)=>{this.promise.then((t=>o(e?e(t):t)),(e=>t?o(t(e)):a(e)))}))}catch(e){return this.then(void 0,e)}finally(e){return new Ye(((t,o)=>{this.promise.then(t,o).finally((()=>{e&&e()}))}))}cancel(){this.isCancelled||(this.isCancelled=!0,this.onCancel&&this.onCancel(),this.rejectPromise({cancelled:!0}))}onCancelled(e){this.onCancel=e}get cancelled(){return this.isCancelled}}var et;!function(e){e.FROM="FROM",e.TO="TO"}(et||(et={}));const tt=({swapFromToken:e,swapToToken:t,swapFromAmount:o,swapToAmount:a,conversion:n})=>{const s={fromToConversion:"",swapToAmount:""};if(!a)return s;if(s.swapToAmount=F(a),o&&e&&t){const o=O(F(Se(n,t.decimals)),!0);s.fromToConversion=`1 ${e.symbol} ≈ ${o} ${t.symbol}`}return s},ot=(e,t)=>void 0!==e&&(""!==e&&t!==e);let at;function nt({data:t,theme:o}){const{t:n}=e(),{swapState:{allowedTokens:r,exchange:c,tokenBalances:f,network:v}}=l.useContext(Pe),{connectLoaderState:g}=l.useContext(m),{checkout:x,provider:h}=g,I=P(x?.config.environment,o),C=l.useCallback(((e,t)=>R(t)?_:`${e.toLowerCase()}-${t.toLowerCase()}`),[]),{cryptoFiatState:k,cryptoFiatDispatch:j}=l.useContext(Ae),{viewDispatch:G}=l.useContext(u),[$,z]=l.useState(et.FROM),[H,J]=l.useState(!1),[q,K]=l.useState(p.from(0)),[X,Q]=l.useState(""),{track:Z}=w(),[Y,ee]=l.useState(t?.fromAmount||""),[te,oe]=l.useState(""),ae=Ze(Y,U),[ne,se]=l.useState(),[re,ie]=l.useState(""),[de,ce]=l.useState(""),[le,pe]=l.useState(0),[we,fe]=l.useState(t?.toAmount||""),[ye,ge]=l.useState(""),xe=Ze(we,U),[Ie,be]=l.useState(),[Ce,ke]=l.useState(""),[Re,Fe]=l.useState(""),[Oe,We]=l.useState(null),[Ne,Le]=l.useState(""),[Ue,Be]=l.useState(void 0),[Me,je]=l.useState(""),[Ge,ze]=l.useState([]),[He,Je]=l.useState(!1),[qe,Ke]=l.useState(!1),[Xe,nt]=l.useState(!1);l.useEffect((()=>{if(0===f.length)return;if(!v)return;const e=f.filter((e=>e.balance.gt(0))).map((e=>({id:C(e.token.symbol,e.token.address),name:e.token.name,symbol:e.token.symbol,icon:e.token.icon,balance:{formattedAmount:F(e.formattedBalance),formattedFiatAmount:0===k.conversions.size?O(""):W(e.formattedBalance,e.token.symbol||"",k.conversions)}})));ze(e),t?.fromTokenAddress&&!ne&&(se(r.find((e=>R(e.address)&&t?.fromTokenAddress?.toLowerCase()===_||e.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))),ie(f.find((e=>R(e.token.address)&&t?.fromTokenAddress?.toLowerCase()===_||e.token.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))?.formattedBalance??"")),ot(t?.toTokenAddress,t?.fromTokenAddress)&&!Ie&&be(r.find((e=>R(e.address)&&t?.toTokenAddress?.toLowerCase()===_||e.address?.toLowerCase()===t?.toTokenAddress?.toLowerCase())))}),[f,r,k.conversions,t?.fromTokenAddress,t?.toTokenAddress,se,ie,be,ze,C,O,v]);const st=l.useMemo((()=>r.map((e=>({id:C(e.symbol,e.address),name:e.name,symbol:e.symbol,icon:e.icon})))),[r,ne]);l.useEffect((()=>{j({payload:{type:Ee.SET_TOKEN_SYMBOLS,tokenSymbols:r.map((e=>e.symbol))}})}),[j,r]);const rt=()=>{oe(""),ce(""),ge(""),ke("")},it=()=>{at&&at.cancel(),Q(""),je(""),We(null)},dt=(e,t)=>!Number.isNaN(parseFloat(e))&&(!(parseFloat(e)<=0)&&(!!ne&&(!!Ie&&(!t||!H)))),ct=async(e=!1)=>{dt(Y,e)&&(at&&at.cancel(),e||J(!0),await(async(e=!1)=>{if(h&&c&&ne&&Ie){try{e||Q("");const t=_e.fromAmountIn(c,h,ne,Y,Ie),o=_e.fromAmountIn(c,h,ne,"1",Ie),a=Ye.all([t,o]);at=a;const n=await a,s=n[0],i=n[1];K(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=Se(l,M),m=d?.token,w=r.find((e=>e.address?.toLocaleLowerCase()===m?.address?.toLocaleLowerCase()));We(s),Le(u),Be({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),je(W(u,w?.symbol||"",k.conversions)),fe(O(F(Se(s.quote.amount.value,s.quote.amount.token.decimals),s.quote.amount.token.decimals))),rt()}catch(e){e.cancelled||(it(),Je(!1),Ke(!0))}e||J(!1)}})(e))},lt=(e,t)=>!Number.isNaN(parseFloat(e))&&(!(parseFloat(e)<=0)&&(!!ne&&(!!Ie&&(!t||!H)))),pt=async(e=!1)=>{lt(we,e)&&(at&&at.cancel(),e||J(!0),await(async(e=!1)=>{if(h&&c&&ne&&Ie){try{e||Q("");const t=_e.fromAmountOut(c,h,Ie,we,ne),o=_e.fromAmountIn(c,h,ne,"1",Ie),a=Ye.all([t,o]);at=a;const n=await a,s=n[0],i=n[1];K(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=Se(l,M),m=d?.token,w=r.find((e=>e.symbol===m?.symbol));We(s),Le(u),Be({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),je(W(u,w?.symbol||"",k.conversions)),ee(O(F(Se(s.quote.amount.value,s.quote.amount.token.decimals)))),rt()}catch(e){e.cancelled||(it(),Je(!1),Ke(!0))}e||J(!1)}})(e))},ut=async(e=!1)=>{$===et.FROM?await ct(e):await pt(e)};he((()=>ut(!0)),D),l.useEffect((()=>{if($===et.FROM){if(ae<=0)return J(!1),void it();(async()=>{await ut()})()}}),[ae,ne,Ie,le]),l.useEffect((()=>{if($===et.TO){if(xe<=0)return J(!1),void it();(async()=>{await ut()})()}}),[xe,Ie,ne]);const mt=l.useMemo((()=>{if(!h)return!0;if(E(h))return!1;const e=f.find((e=>e.token.address?.toLowerCase()===_));if(!e)return!0;const t=ne?.address?.toLowerCase()===_,o=ve(0!==Ne.length?Ne:"0"),a=t&&!Number.isNaN(parseFloat(Y))?Te(Y,ne?.decimals||18):p.from("0");return o.add(a).gt(e.balance)}),[Ne,f,ne,Y,h]);l.useEffect((()=>{Y&&ne&&Fe(W(Y,ne.symbol,k.conversions))}),[Y,ne]);const wt=l.useCallback((e=>{const t=f.find((t=>e===C(t.token.symbol,t.token.address)));t&&(Ie&&e===C(Ie.symbol,Ie?.address)&&be(void 0),se(t.token),ie(t.formattedBalance),ce(""))}),[Ie]),ft=l.useCallback((e=>{const t=r.find((t=>e===C(t.symbol,t.address)));t&&(ne&&e===C(ne.symbol,ne?.address)&&se(void 0),be(t),ke(""))}),[ne]);return l.useEffect((()=>{Oe&&q&&Q(tt({swapFromToken:ne,swapFromAmount:Y,swapToToken:Ie,swapToAmount:we,conversion:q}).fromToConversion)}),[Oe,q]),a(V,{children:[a(s,{sx:{paddingX:"base.spacing.x4",marginBottom:"base.spacing.x2"},children:[i(b,{size:"small",weight:"regular",sx:{paddingBottom:"base.spacing.x4"},children:n("views.SWAP.content.title")}),a(s,{sx:{display:"flex",flexDirection:"column",rowGap:"base.spacing.x6",paddingBottom:"base.spacing.x2"},children:[a(s,{children:[i(b,{size:"xSmall",sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:n("views.SWAP.swapForm.from.label")}),i(De,{testId:"fromTokenInputs",options:Ge,selectSubtext:ne?`${n("views.SWAP.content.availableBalancePrefix")} ${F(re)}`:"",selectTextAlign:"left",textInputType:"number",textInputValue:Y,textInputPlaceholder:n("views.SWAP.swapForm.from.inputPlaceholder"),textInputSubtext:`${n("views.SWAP.content.fiatPricePrefix")} \n $${O(Re,!0)}`,textInputTextAlign:"right",textInputValidator:N,onTextInputChange:e=>{return t=e,rt(),it(),fe(""),dt(t,!1)&&J(!0),void ee(t);var t},onTextInputFocus:()=>{z(et.FROM)},textInputMaxButtonClick:()=>{if(!re)return;const e=re.slice(0,re.indexOf(".")+B+1);rt(),it(),z(et.FROM),fe(""),dt(e,!1)&&J(!0),Y===e?pe(le+1):ee(e),Z({userJourney:T.SWAP,screen:"SwapCoins",control:"MaxFrom",controlType:"Button",extras:{fromBalance:re,fromBalanceTruncated:e}})},onSelectChange:wt,textInputErrorMessage:n(te),selectErrorMessage:n(de),selectedOption:ne?C(ne.symbol,ne.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.from.selectorTitle"),defaultTokenImage:I})]}),a(s,{children:[a(s,{sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:[i(b,{size:"xSmall",children:n("views.SWAP.swapForm.to.label")}),i(d,{sx:{color:"base.color.brand.4"},size:"small",children:X})]}),i(De,{testId:"toTokenInputs",options:st,selectTextAlign:"left",textInputType:"number",textInputValue:we,textInputPlaceholder:n("views.SWAP.swapForm.to.inputPlaceholder"),textInputTextAlign:"right",textInputValidator:N,onTextInputChange:e=>{return t=e,rt(),it(),Fe(""),ee(""),lt(t,!1)&&J(!0),void fe(t);var t},onTextInputFocus:()=>{z(et.TO)},onSelectChange:ft,textInputErrorMessage:n(ye),selectErrorMessage:n(Ce),selectedOption:Ie?C(Ie.symbol,Ie.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.to.selectorTitle"),defaultTokenImage:I})]})]}),i(ue,{gasFeeFiatValue:Me,gasFeeToken:Ue,gasFeeValue:Ne,fees:[{label:n("drawers.feesBreakdown.fees.gasFeeSwap.label"),fiatAmount:`~ ${n("drawers.feesBreakdown.fees.fiatPricePrefix")}${Me}`,amount:F(Ne),prefix:"~"}],onFeesClick:()=>{Z({userJourney:T.SWAP,screen:"SwapCoins",control:"ViewFees",controlType:"Button"})},sx:{paddingBottom:"0"},loading:H})]}),i(Ve,{validator:()=>{const e=function(e){return e?"":"views.SWAP.validation.noFromTokenSelected"}(ne),t=(a=re,(o=Y)&&0!==parseFloat(o)?a&&Number(o)>Number(a)?"views.SWAP.validation.insufficientBalance":"":"views.SWAP.validation.noAmountInputted");var o,a;const n=function(e){return e?"":"views.SWAP.validation.noToTokenSelected"}(Ie),s=function(e){return e&&0!==parseFloat(e)?"":"views.SWAP.validation.noAmountInputted"}(we);$===et.FROM?(ge(""),t&&oe(t)):$===et.TO&&(oe(""),s&&ge(s)),e&&ce(e),n&&ke(n);let r=!0;return(e||n||t&&$===et.FROM||s&&$===et.TO)&&(r=!1),Z({userJourney:T.SWAP,screen:"SwapCoins",control:"FormValid",controlType:"Button",extras:{isSwapFormValid:r,swapFromAddress:ne?.address,swapFromAmount:Y,swapFromTokenSymbol:ne?.symbol,swapToAddress:Ie?.address,swapToAmount:we,swapToTokenSymbol:Ie?.symbol}}),r},updateLoading:e=>{J(e)},loading:H,transaction:Oe,data:{fromAmount:Y,toAmount:we,fromTokenSymbol:ne?.symbol,fromTokenAddress:ne?.address,toTokenSymbol:Ie?.symbol,toTokenAddress:Ie?.address},insufficientFundsForGas:mt,openNotEnoughImxDrawer:()=>{Ke(!1),Je(!0)},openNetworkSwitchDrawer:()=>nt(!0)}),i($e,{environment:x?.config.environment??L.PRODUCTION,visible:He,showAdjustAmount:ne?.address===_,hasZeroImx:!1,onAddCoinsClick:()=>{G({payload:{type:A.UPDATE_VIEW,view:{type:S.TOP_UP_VIEW},currentViewData:{fromTokenAddress:ne?.address??"",fromAmount:Y,toTokenAddress:Ie?.address??""}}})},onCloseDrawer:()=>Je(!1)}),i(Qe,{visible:qe,onCloseDrawer:()=>{Ke(!1),se(void 0),ee(""),be(void 0),fe("")}}),i(me,{visible:Xe,targetChainId:y(x?.config),provider:h,checkout:x,onCloseDrawer:()=>nt(!1)})]})}const st=(e,t)=>{if(0===e.length)return!0;let o=!1;return e.forEach((e=>{e.token.symbol===t&&e.balance.eq(0)&&(o=!0)})),o};function rt({theme:t,fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}){const{t:c}=e(),{viewDispatch:p}=l.useContext(u),{eventTargetState:{eventTarget:f}}=l.useContext(j),{swapState:{tokenBalances:y}}=l.useContext(Pe),{connectLoaderState:{checkout:v,provider:g}}=l.useContext(m),[x,h]=l.useState(!1),{page:I}=w();return l.useEffect((()=>{I({userJourney:T.SWAP,screen:"SwapCoins",extras:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}})}),[]),l.useEffect((()=>{console.log("tokenBalances",y,"isPassportProvider",E(g),g),st(y,H)&&!E(g)&&h(!0)}),[y]),i(z,{header:i(G,{title:c("views.SWAP.header.title"),onCloseButtonClick:()=>$(f)}),footer:i(be,{environment:v?.config.environment,theme:t}),children:a(s,{sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[i(nt,{data:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d},theme:t}),i($e,{environment:v?.config.environment??L.PRODUCTION,visible:x,showAdjustAmount:!1,hasZeroImx:!0,onAddCoinsClick:()=>{p({payload:{type:A.UPDATE_VIEW,view:{type:S.TOP_UP_VIEW}}})},onCloseDrawer:()=>{h(!1)}})]})})}function it({transactionResponse:t,swapForm:o}){const{t:a}=e(),{viewDispatch:n}=l.useContext(u),{page:s}=w();return l.useEffect((()=>{s({userJourney:T.SWAP,screen:"SwapInProgress",extras:{swapFormInfo:o}})}),[]),l.useEffect((()=>{(async()=>{try{const e=await t.wait();if(1===e.status)return void n({payload:{type:A.UPDATE_VIEW,view:{type:ye.SUCCESS,data:{fromTokenAddress:o.fromTokenAddress,fromAmount:o.fromAmount,toTokenAddress:o.toTokenAddress,toAmount:o.toAmount||"",transactionHash:e.transactionHash}}}});n({payload:{type:A.UPDATE_VIEW,view:{type:ye.FAIL,data:o,reason:"Transaction failed"}}})}catch{n({payload:{type:A.UPDATE_VIEW,view:{type:ye.FAIL,data:o,reason:"Transaction failed"}}})}})()}),[t]),i(J,{loadingText:a("views.SWAP.IN_PROGRESS.loading.text")})}function dt({data:t}){const{t:o}=e(),{swapState:{allowedTokens:n}}=l.useContext(Pe),{connectLoaderState:r}=l.useContext(m),{checkout:d,provider:c}=r,{viewDispatch:f}=l.useContext(u),{eventTargetState:{eventTarget:y}}=l.useContext(j),g=E(c),[x,h]=l.useState(!1),[I,b]=l.useState(!1),[C,k]=l.useState(!1),[P,R]=l.useState(!1),[_,F]=l.useState(!1),[O,W]=l.useState(!1),{page:D,track:N}=w();l.useEffect((()=>{D({userJourney:T.SWAP,screen:"ApproveERC20",extras:{swapFormInfo:t.swapFormInfo}})}),[]);const L=l.useMemo((()=>n.find((e=>e.address===t.swapFormInfo.fromTokenAddress))),[n,t.swapFormInfo.fromTokenAddress]),U=l.useCallback((()=>{f({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:new Error("No checkout object or no provider object found")}}})}),[f]),B=l.useCallback((()=>{f({payload:{type:A.UPDATE_VIEW,view:{type:ye.SWAP,data:t.swapFormInfo}}})}),[f]),M=(e,t)=>{e.type!==v.UNPREDICTABLE_GAS_LIMIT?e.type===v.TRANSACTION_FAILED||e.type===v.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status?f({payload:{type:A.UPDATE_VIEW,view:{type:ye.FAIL,reason:"Transaction failed",data:t}}}):(console.error("Approve ERC20 failed",e),f({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,error:e}}})):f({payload:{type:A.UPDATE_VIEW,view:{type:ye.PRICE_SURGE,data:t}}})},H=(e,t=!1)=>({...e,gasPrice:t?p.from(0):void 0}),X=l.useCallback((async()=>{if(!P)if(N({userJourney:T.SWAP,screen:"ApproveERC20",control:"ApproveSpending",controlType:"Button"}),R(!0),d&&c){if(!x){h(!0);try{const e=await d.sendTransaction({provider:c,transaction:H(t.approveTransaction,g)});b(!0);if(1!==(await e.transactionResponse.wait()).status)return void f({payload:{type:A.UPDATE_VIEW,view:{type:ye.FAIL,data:t.swapFormInfo}}});b(!1),h(!1),k(!0)}catch(e){if(b(!1),h(!1),e.type===v.USER_REJECTED_REQUEST_ERROR)return void F(!0);M(e,t.swapFormInfo)}finally{R(!1)}}}else U()}),[d,c,U,f,W,t.approveTransaction,t.swapFormInfo,x,h,b]),Q=l.useMemo((()=>a(q,{heading:o(`views.APPROVE_ERC20.approveSpending.content.${g?"passport":"metamask"}.heading`),children:[g&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.passport.body")}),!g&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.metamask.body",{amount:`${t.swapFormInfo.fromAmount} ${L?.symbol||""}`})})]})),[t.swapFormInfo,L,g]),Z=l.useMemo((()=>i(K,{loading:P,actionText:o(_?"views.APPROVE_ERC20.approveSpending.footer.retryText":"views.APPROVE_ERC20.approveSpending.footer.buttonText"),onActionClick:X})),[_,X,P]),Y=l.useCallback((async()=>{if(!P)if(N({userJourney:T.SWAP,screen:"ApproveERC20",control:"ApproveSwap",controlType:"Button"}),R(!0),d&&c){if(!x){h(!0);try{const e=await d.sendTransaction({provider:c,transaction:H(t.transaction,g)});h(!1),f({payload:{type:A.UPDATE_VIEW,view:{type:ye.IN_PROGRESS,data:{transactionResponse:e.transactionResponse,swapForm:t.swapFormInfo}}}})}catch(e){if(h(!1),e.type===v.USER_REJECTED_REQUEST_ERROR)return void W(!0);M(e,t.swapFormInfo)}finally{R(!1)}}}else U()}),[d,c,U,f,W,t.transaction,t.swapFormInfo,x,h]),ee=i(q,{heading:o("views.APPROVE_ERC20.approveSwap.content.heading"),children:i(s,{children:o("views.APPROVE_ERC20.approveSwap.content.body")})}),te=l.useMemo((()=>i(K,{loading:P,actionText:o(O?"views.APPROVE_ERC20.approveSwap.footer.retryText":"views.APPROVE_ERC20.approveSwap.footer.buttonText"),onActionClick:Y})),[O,Y,P]);return a(V,{children:[I&&i(J,{loadingText:o("views.APPROVE_ERC20.approveSpending.loading.text")}),!I&&i(z,{header:i(G,{transparent:!0,showBack:!0,onCloseButtonClick:()=>$(y),onBackButtonClick:B}),floatHeader:!0,heroContent:i(C?we:Ie,{}),footer:C?te:Z,children:C?ee:Q})]})}function ct({amount:t,fromTokenAddress:o,toTokenAddress:n,config:s}){const{t:r}=e(),{eventTargetState:{eventTarget:d}}=l.useContext(j),{environment:c,theme:p,isOnRampEnabled:f,isSwapEnabled:E,isBridgeEnabled:v}=s,{connectLoaderState:{checkout:g,provider:x}}=l.useContext(m),[h,I]=l.useReducer(X,{...Q,history:[]}),[b,C]=l.useReducer(Re,Ce),{page:k}=w(),[P,R]=l.useState(!1),_=l.useMemo((()=>({swapState:b,swapDispatch:C})),[b,C]),F=l.useMemo((()=>({viewState:h,viewDispatch:I})),[h,I]),O=l.useCallback(((e,t)=>{I({payload:{type:A.UPDATE_VIEW,view:{type:S.ERROR_VIEW,tryAgain:t,error:e}}})}),[I]),W=l.useCallback((()=>{I({payload:{type:A.UPDATE_VIEW,view:{type:ye.SWAP}}})}),[I]),D=l.useCallback((async()=>{if(!g)throw new Error("loadBalances: missing checkout");if(!x)throw new Error("loadBalances: missing provider");try{const e=await fe({checkout:g,provider:x,allowTokenListType:Z.SWAP});if(void 0===e)return!1;C({payload:{type:ke.SET_ALLOWED_TOKENS,allowedTokens:e.allowList.tokens}}),C({payload:{type:ke.SET_TOKEN_BALANCES,tokenBalances:e.allowedBalances}})}catch(e){if(Y.nonRetryable(e))return O(e,D),!1}return!0}),[g,x]);return l.useEffect((()=>{(async()=>{if(!g||!x)return;const e=await g.getNetworkInfo({provider:x});if(e.chainId!==y(g.config))return;let t;try{t=await g.config.remote.getConfig("dex")}catch(e){return void O(e)}const o=new ee({chainId:e.chainId,baseConfig:new te({environment:c}),secondaryFees:t.secondaryFees,overrides:t.overrides});C({payload:{type:ke.SET_EXCHANGE,exchange:o}}),C({payload:{type:ke.SET_NETWORK,network:e}}),await D()&&h.view.type===S.LOADING_VIEW&&W()})()}),[g,x]),i(u.Provider,{value:F,children:i(Pe.Provider,{value:_,children:a(xe,{environment:c,children:[h.view.type===S.LOADING_VIEW&&i(J,{loadingText:r("views.LOADING_VIEW.text")}),h.view.type===ye.SWAP&&i(rt,{theme:p,fromAmount:h.view.data?.fromAmount??t,fromTokenAddress:h.view.data?.fromTokenAddress??o,toTokenAddress:h.view.data?.toTokenAddress??n}),h.view.type===ye.IN_PROGRESS&&i(it,{transactionResponse:h.view.data.transactionResponse,swapForm:h.view.data.swapForm}),h.view.type===ye.APPROVE_ERC20&&i(dt,{data:h.view.data}),h.view.type===ye.SUCCESS&&i(oe,{statusText:r("views.SWAP.success.text"),actionText:r("views.SWAP.success.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"SwapSuccess",extras:{fromTokenAddress:h.view.data?.fromTokenAddress,fromAmount:h.view.data?.fromAmount,toTokenAddress:h.view.data?.toTokenAddress,toAmount:h.view.data?.toAmount}}),ae(d,h.view.data.transactionHash)},onActionClick:()=>$(d),statusType:ne.SUCCESS,testId:"success-view"}),h.view.type===ye.FAIL&&i(oe,{statusText:r("views.SWAP.failed.text"),actionText:r("views.SWAP.failed.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"SwapFailed"}),se(d,"Transaction failed")},onActionClick:()=>{h.view.type===ye.FAIL&&I({payload:{type:A.UPDATE_VIEW,view:{type:ye.SWAP,data:h.view.data}}})},statusType:ne.FAILURE,onCloseClick:()=>$(d),testId:"fail-view"}),h.view.type===ye.PRICE_SURGE&&i(oe,{statusText:r("views.SWAP.rejected.text"),actionText:r("views.SWAP.rejected.actionText"),onRenderEvent:()=>{k({userJourney:T.SWAP,screen:"PriceSurge"}),re(d,"Price surge")},onActionClick:()=>{h.view.type===ye.PRICE_SURGE&&I({payload:{type:A.UPDATE_VIEW,view:{type:ye.SWAP,data:h.view.data}}})},statusType:ne.WARNING,onCloseClick:()=>$(d),testId:"price-surge-view"}),h.view.type===S.ERROR_VIEW&&i(ie,{actionText:r("views.ERROR_VIEW.actionText"),onActionClick:async()=>{R(!0);const e=h.view;if(!e.tryAgain)return W(),void R(!1);await e.tryAgain()&&W(),R(!1)},onCloseClick:()=>$(d),errorEventActionLoading:P}),h.view.type===S.TOP_UP_VIEW&&i(ge,{analytics:{userJourney:T.SWAP},checkout:g,provider:x,widgetEvent:de.IMTBL_SWAP_WIDGET_EVENT,showOnrampOption:f,showSwapOption:E,showBridgeOption:v,onCloseButtonClick:()=>$(d)})]})})})}export{ct as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{dj as n,dk as t}from"./index-aad9a3ee.js";function i(i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return[4,import("./index.umd-14e670d3.js").then((function(n){return n.i}))];case 1:return n=t.sent(),i._plugins=n,[2]}}))}))}export{i as loadLegacyVideoPlugins};
|