@imtbl/sdk 1.52.0 → 1.52.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{blockchain_data-T7u5Hp0U.js → blockchain_data-DBBTvmmb.js} +2 -2
- package/dist/blockchain_data.d.ts +34 -3202
- package/dist/blockchain_data.js +3 -3
- package/dist/browser/checkout/{AddFundsWidget-DuG1OWEM.js → AddFundsWidget-SdKqlUUr.js} +124 -49
- package/dist/browser/checkout/{BridgeWidget-2D-8F1Vq.js → BridgeWidget-Bx1DFMXg.js} +11 -9
- package/dist/browser/checkout/{CheckoutWidget-Bvnur5WZ.js → CheckoutWidget-B1pE8Gc2.js} +81 -35
- package/dist/browser/checkout/{OnRampWidget-B4UV_TYW.js → OnRampWidget-bmvseWX-.js} +20 -12
- package/dist/browser/checkout/{SaleWidget-BQMUaWlZ.js → SaleWidget-Ddos1DHm.js} +9 -9
- package/dist/browser/checkout/{SpendingCapHero-BsQQYO_D.js → SpendingCapHero-BKdEyvIl.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-BK7sTJ6u.js → SwapWidget-CrEzJos9.js} +12 -10
- package/dist/browser/checkout/{TextInputForm-Cy6sTMjr.js → TextInputForm-BvZsFFRK.js} +1 -1
- package/dist/browser/checkout/{TopUpView-Dw-JH0Q5.js → TopUpView-CojeMjuL.js} +1 -1
- package/dist/browser/checkout/{WalletWidget-t6i1V-G5.js → WalletWidget-DcoX5T7s.js} +7 -6
- package/dist/browser/checkout/{auto-track-CMv29U8a.js → auto-track-CPy9e41Q.js} +1 -1
- package/dist/browser/checkout/{balance-Dt4oB1G1.js → balance-_0wiNzA1.js} +2 -2
- package/dist/browser/checkout/{index-D2zks65E.js → index-2yp2sttp.js} +2 -2
- package/dist/browser/checkout/{index-BRzBLTux.js → index-4LGmzy2P.js} +1 -1
- package/dist/browser/checkout/{index-Zraoakam.js → index-BjnD8v8p.js} +1 -1
- package/dist/browser/checkout/{index-DmXFGYTM.js → index-BpduNNVl.js} +1 -1
- package/dist/browser/checkout/{index-D4zR0DRy.js → index-CPLIXtyA.js} +1 -1
- package/dist/browser/checkout/{index-CMBbtkDe.js → index-CcR4tO_g.js} +1 -1
- package/dist/browser/checkout/{index-5qc7Vsg4.js → index-DnQfQojQ.js} +63 -46
- package/dist/browser/checkout/{index-DwTyassh.js → index-Dv7_L5sJ.js} +1 -1
- package/dist/browser/checkout/{index.umd-CCwq6cRd.js → index.umd-LRNZ8nMO.js} +1 -1
- package/dist/browser/checkout/{retry-C_l6vh-l.js → retry-TNKwGgHJ.js} +1 -1
- package/dist/browser/checkout/sdk.js +5 -5
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +279 -128
- package/dist/{checkout-DxDRj3k-.js → checkout-BoEdWIoM.js} +7 -6
- package/dist/checkout.d.ts +38 -10
- package/dist/checkout.js +5 -5
- package/dist/{config-Dj7PQqL4.js → config-4V88kddG.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-8m8-bJcZ.js → index-5q3Doq32.js} +1 -1
- package/dist/{index-1bjDCdo5.js → index-CAL1gWlu.js} +4 -4
- package/dist/{index-XxjQ6oVx.js → index-D0T-P8dM.js} +53 -53
- package/dist/{index-D4eU2e1C.js → index-DDE1ZfXv.js} +1 -1
- package/dist/{index-BxF866Mh.js → index-Dg5cqGBu.js} +1 -1
- package/dist/{index-snMwBaY-.js → index-Dqva106f.js} +1 -1
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +66 -61
- package/dist/index.d.ts +266 -3404
- package/dist/index.js +14 -14
- package/dist/{minting_backend-DfBB5ptf.js → minting_backend-x7gO9bio.js} +3 -3
- package/dist/minting_backend.d.ts +312 -228
- package/dist/minting_backend.js +5 -5
- package/dist/{orderbook-CnmzmGtG.js → orderbook-BUiL0rqz.js} +1 -1
- package/dist/orderbook.js +2 -2
- package/dist/{passport-B8WhzCZf.js → passport-DGaas7w4.js} +10 -6
- package/dist/passport.d.ts +3 -1
- package/dist/passport.js +4 -4
- package/dist/{webhook-DzAoMhRT.js → webhook-Be5S01dB.js} +1 -1
- package/dist/webhook.js +2 -2
- package/dist/{x-DbbHwlbW.js → x-7ExOXsHk.js} +3 -3
- package/dist/x.js +4 -4
- package/package.json +1 -1
|
@@ -126214,6 +126214,7 @@
|
|
|
126214
126214
|
OrchestrationEventType["REQUEST_BRIDGE"] = "request-bridge";
|
|
126215
126215
|
OrchestrationEventType["REQUEST_ONRAMP"] = "request-onramp";
|
|
126216
126216
|
OrchestrationEventType["REQUEST_ADD_FUNDS"] = "request-add-funds";
|
|
126217
|
+
OrchestrationEventType["REQUEST_GO_BACK"] = "request-go-back";
|
|
126217
126218
|
})(OrchestrationEventType || (OrchestrationEventType = {}));
|
|
126218
126219
|
|
|
126219
126220
|
/**
|
|
@@ -126274,7 +126275,6 @@
|
|
|
126274
126275
|
AddFundsEventType["REQUEST_BRIDGE"] = "request-bridge";
|
|
126275
126276
|
AddFundsEventType["REQUEST_ONRAMP"] = "request-onramp";
|
|
126276
126277
|
AddFundsEventType["REQUEST_SWAP"] = "request-swap";
|
|
126277
|
-
AddFundsEventType["GO_BACK"] = "go-back";
|
|
126278
126278
|
})(AddFundsEventType || (AddFundsEventType = {}));
|
|
126279
126279
|
|
|
126280
126280
|
/**
|
|
@@ -126800,6 +126800,7 @@
|
|
|
126800
126800
|
PostMessageHandlerEventType["PROVIDER_UPDATED"] = "IMTBL_PROVIDER_UPDATED";
|
|
126801
126801
|
PostMessageHandlerEventType["EIP_6963_EVENT"] = "IMTBL_EIP_6963_EVENT";
|
|
126802
126802
|
PostMessageHandlerEventType["WIDGET_EVENT"] = "IMTBL_CHECKOUT_WIDGET_EVENT";
|
|
126803
|
+
PostMessageHandlerEventType["WIDGET_PROVIDER_EVENT"] = "IMTBL_WIDGET_PROVIDER_EVENT";
|
|
126803
126804
|
})(PostMessageHandlerEventType || (PostMessageHandlerEventType = {}));
|
|
126804
126805
|
|
|
126805
126806
|
class PostMessageHandler {
|
|
@@ -193869,10 +193870,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
193869
193870
|
if (eventTarget !== undefined)
|
|
193870
193871
|
eventTarget.dispatchEvent(requestBridgeEvent);
|
|
193871
193872
|
}
|
|
193873
|
+
function sendRequestGoBackEvent(eventTarget, imtblWidgetEvent, eventData) {
|
|
193874
|
+
// eslint-disable-next-line max-len
|
|
193875
|
+
const requestGoBackEvent = new CustomEvent(imtblWidgetEvent, {
|
|
193876
|
+
detail: {
|
|
193877
|
+
type: OrchestrationEventType.REQUEST_GO_BACK,
|
|
193878
|
+
data: eventData,
|
|
193879
|
+
},
|
|
193880
|
+
});
|
|
193881
|
+
// TODO: please remove or if necessary keep the eslint ignore
|
|
193882
|
+
// eslint-disable-next-line no-console
|
|
193883
|
+
console.log(`go back event from ${imtblWidgetEvent}:`, eventTarget, requestGoBackEvent);
|
|
193884
|
+
if (eventTarget !== undefined)
|
|
193885
|
+
eventTarget.dispatchEvent(requestGoBackEvent);
|
|
193886
|
+
}
|
|
193872
193887
|
const orchestrationEvents = {
|
|
193873
193888
|
sendRequestBridgeEvent,
|
|
193874
193889
|
sendRequestSwapEvent,
|
|
193875
193890
|
sendRequestOnrampEvent,
|
|
193891
|
+
sendRequestGoBackEvent,
|
|
193876
193892
|
};
|
|
193877
193893
|
|
|
193878
193894
|
const topUpBridgeOption = (isBridgeEnabled, isNotPassport) => {
|
|
@@ -194059,7 +194075,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194059
194075
|
allowedChains: [getL2ChainId(this.checkout.config)],
|
|
194060
194076
|
};
|
|
194061
194077
|
const topUpOptions = this.topUpOptions();
|
|
194062
|
-
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "swap-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(GeoblockLoader, { checkout: this.checkout, widget: (jsx$1(ConnectLoader, { params: connectLoaderParams, widgetConfig: this.strongConfig(), closeEvent: () => sendSwapWidgetCloseEvent(window), children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: jsx$1(SwapWidget$2, { fromTokenAddress: this.parameters.fromTokenAddress, toTokenAddress: this.parameters.toTokenAddress, amount: this.parameters.amount, config: this.strongConfig(), autoProceed: this.parameters.autoProceed, direction: this.parameters.direction ?? SwapDirection$1.FROM }) }) })), serviceUnavailableView: (jsx$1(ServiceUnavailableErrorView, { service: ServiceType.SWAP, onCloseClick: () => sendSwapWidgetCloseEvent(window), primaryActionText: topUpOptions && topUpOptions?.length > 0
|
|
194078
|
+
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "swap-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(GeoblockLoader, { checkout: this.checkout, widget: (jsx$1(ConnectLoader, { params: connectLoaderParams, widgetConfig: this.strongConfig(), closeEvent: () => sendSwapWidgetCloseEvent(window), children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: jsx$1(SwapWidget$2, { fromTokenAddress: this.parameters.fromTokenAddress, toTokenAddress: this.parameters.toTokenAddress, amount: this.parameters.amount, config: this.strongConfig(), autoProceed: this.parameters.autoProceed, direction: this.parameters.direction ?? SwapDirection$1.FROM, showBackButton: this.parameters.showBackButton }) }) })), serviceUnavailableView: (jsx$1(ServiceUnavailableErrorView, { service: ServiceType.SWAP, onCloseClick: () => sendSwapWidgetCloseEvent(window), primaryActionText: topUpOptions && topUpOptions?.length > 0
|
|
194063
194079
|
? t(topUpOptions[0].textKey)
|
|
194064
194080
|
: undefined, onPrimaryButtonClick: topUpOptions && topUpOptions?.length > 0
|
|
194065
194081
|
? topUpOptions[0].action
|
|
@@ -194158,7 +194174,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194158
194174
|
checkout: this.checkout,
|
|
194159
194175
|
allowedChains: [getL1ChainId(this.checkout.config), getL2ChainId(this.checkout.config)],
|
|
194160
194176
|
};
|
|
194161
|
-
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "onramp-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(ConnectLoader, { widgetConfig: this.strongConfig(), params: connectLoaderParams, closeEvent: () => sendOnRampWidgetCloseEvent(window), children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.ONRAMP.initialLoadingText') }), children: jsx$1(OnRampWidget$2, { tokenAddress: this.parameters.tokenAddress, amount: this.parameters.amount, config: this.strongConfig() }) }) }) }) }) }) }));
|
|
194177
|
+
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "onramp-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(ConnectLoader, { widgetConfig: this.strongConfig(), params: connectLoaderParams, closeEvent: () => sendOnRampWidgetCloseEvent(window), children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.ONRAMP.initialLoadingText') }), children: jsx$1(OnRampWidget$2, { tokenAddress: this.parameters.tokenAddress, amount: this.parameters.amount, config: this.strongConfig(), showBackButton: this.parameters.showBackButton }) }) }) }) }) }) }));
|
|
194162
194178
|
}
|
|
194163
194179
|
}
|
|
194164
194180
|
|
|
@@ -194350,14 +194366,27 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194350
194366
|
class Sale extends Base$3 {
|
|
194351
194367
|
eventTopic = IMTBLWidgetEvents.IMTBL_SALE_WIDGET_EVENT;
|
|
194352
194368
|
// TODO: add specific validation logic for the sale items
|
|
194353
|
-
|
|
194369
|
+
isValidArray(items) {
|
|
194354
194370
|
try {
|
|
194355
|
-
return Array.isArray(
|
|
194371
|
+
return Array.isArray(items);
|
|
194356
194372
|
}
|
|
194357
194373
|
catch {
|
|
194358
194374
|
return false;
|
|
194359
194375
|
}
|
|
194360
194376
|
}
|
|
194377
|
+
deduplicateItems(items) {
|
|
194378
|
+
if (!items || !this.isValidArray(items))
|
|
194379
|
+
return [];
|
|
194380
|
+
const uniqueItems = items.reduce((acc, item) => {
|
|
194381
|
+
const itemIndex = acc.findIndex(({ productId }) => productId === item.productId);
|
|
194382
|
+
if (itemIndex !== -1) {
|
|
194383
|
+
acc[itemIndex] = { ...item, qty: acc[itemIndex].qty + item.qty };
|
|
194384
|
+
return acc;
|
|
194385
|
+
}
|
|
194386
|
+
return [...acc, { ...item }];
|
|
194387
|
+
}, []);
|
|
194388
|
+
return uniqueItems;
|
|
194389
|
+
}
|
|
194361
194390
|
getValidatedProperties({ config, }) {
|
|
194362
194391
|
let validatedConfig;
|
|
194363
194392
|
if (config) {
|
|
@@ -194378,8 +194407,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194378
194407
|
console.warn('[IMTBL]: invalid "walletProviderName" widget input');
|
|
194379
194408
|
validatedParams.walletProviderName = undefined;
|
|
194380
194409
|
}
|
|
194381
|
-
|
|
194382
|
-
if (!this.isValidProucts(params.items ?? [])) {
|
|
194410
|
+
if (!this.isValidArray(params.items)) {
|
|
194383
194411
|
// eslint-disable-next-line no-console
|
|
194384
194412
|
console.warn('[IMTBL]: invalid "items" widget input.');
|
|
194385
194413
|
validatedParams.items = [];
|
|
@@ -194400,7 +194428,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194400
194428
|
console.warn('[IMTBL]: invalid "excludePaymentTypes" widget input');
|
|
194401
194429
|
validatedParams.excludePaymentTypes = [];
|
|
194402
194430
|
}
|
|
194403
|
-
return
|
|
194431
|
+
return {
|
|
194432
|
+
...validatedParams,
|
|
194433
|
+
items: this.deduplicateItems(params.items),
|
|
194434
|
+
};
|
|
194404
194435
|
}
|
|
194405
194436
|
render() {
|
|
194406
194437
|
if (!this.reactRoot)
|
|
@@ -194461,7 +194492,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194461
194492
|
if (!this.reactRoot)
|
|
194462
194493
|
return;
|
|
194463
194494
|
const { t } = instance;
|
|
194464
|
-
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "bridge-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: jsx$1(BridgeWidget$2, { checkout: this.checkout, config: this.strongConfig(), web3Provider: this.web3Provider, tokenAddress: this.parameters.tokenAddress, amount: this.parameters.amount, walletProviderName: this.parameters.walletProviderName }) }) }) }) }) }));
|
|
194495
|
+
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "bridge-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: jsx$1(BridgeWidget$2, { checkout: this.checkout, config: this.strongConfig(), web3Provider: this.web3Provider, tokenAddress: this.parameters.tokenAddress, amount: this.parameters.amount, walletProviderName: this.parameters.walletProviderName, showBackButton: !!this.parameters.showBackButton }) }) }) }) }) }));
|
|
194465
194496
|
}
|
|
194466
194497
|
};
|
|
194467
194498
|
|
|
@@ -194510,20 +194541,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194510
194541
|
if (eventTarget !== undefined)
|
|
194511
194542
|
eventTarget.dispatchEvent(closeWidgetEvent);
|
|
194512
194543
|
}
|
|
194513
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
194514
|
-
function sendAddFundsGoBackEvent(eventTarget) {
|
|
194515
|
-
const closeWidgetEvent = new CustomEvent(IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT, {
|
|
194516
|
-
detail: {
|
|
194517
|
-
type: AddFundsEventType.GO_BACK,
|
|
194518
|
-
data: {},
|
|
194519
|
-
},
|
|
194520
|
-
});
|
|
194521
|
-
// TODO: please remove or if necessary keep the eslint ignore
|
|
194522
|
-
// eslint-disable-next-line no-console
|
|
194523
|
-
console.log('go back event:', closeWidgetEvent);
|
|
194524
|
-
if (eventTarget !== undefined)
|
|
194525
|
-
eventTarget.dispatchEvent(closeWidgetEvent);
|
|
194526
|
-
}
|
|
194527
194544
|
|
|
194528
194545
|
const AddFundsWidget$2 = React.lazy(() => Promise.resolve().then(function () { return AddFundsWidget$1; }));
|
|
194529
194546
|
let AddFunds$1 = class AddFunds extends Base$3 {
|
|
@@ -194543,10 +194560,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194543
194560
|
}
|
|
194544
194561
|
getValidatedParameters(params) {
|
|
194545
194562
|
const validatedParams = params;
|
|
194546
|
-
if (!isValidAmount(params.
|
|
194563
|
+
if (!isValidAmount(params.toAmount)) {
|
|
194547
194564
|
// eslint-disable-next-line no-console
|
|
194548
|
-
console.warn('[IMTBL]: invalid "
|
|
194549
|
-
validatedParams.
|
|
194565
|
+
console.warn('[IMTBL]: invalid "toAmount" widget input');
|
|
194566
|
+
validatedParams.toAmount = '';
|
|
194550
194567
|
}
|
|
194551
194568
|
return validatedParams;
|
|
194552
194569
|
}
|
|
@@ -194565,7 +194582,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
194565
194582
|
getL2ChainId(this.checkout.config),
|
|
194566
194583
|
],
|
|
194567
194584
|
};
|
|
194568
|
-
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "add-funds-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(ConnectLoader, { widgetConfig: this.strongConfig(), params: connectLoaderParams, closeEvent: () => sendAddFundsCloseEvent(window), children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: jsx$1(AddFundsWidget$2, { checkout: this.checkout, web3Provider: this.web3Provider, showBridgeOption: this.parameters.showBridgeOption, showSwapOption: this.parameters.showSwapOption, showOnrampOption: this.parameters.showOnrampOption,
|
|
194585
|
+
this.reactRoot.render(jsx$1(React.StrictMode, { children: jsx$1(CustomAnalyticsProvider, { checkout: this.checkout, children: jsx$1(ThemeProvider, { id: "add-funds-container", config: this.strongConfig(), children: jsx$1(HandoverProvider, { children: jsx$1(ConnectLoader, { widgetConfig: this.strongConfig(), params: connectLoaderParams, closeEvent: () => sendAddFundsCloseEvent(window), children: jsx$1(reactExports.Suspense, { fallback: jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') }), children: jsx$1(AddFundsWidget$2, { checkout: this.checkout, web3Provider: this.web3Provider, showBridgeOption: this.parameters.showBridgeOption, showSwapOption: this.parameters.showSwapOption, showOnrampOption: this.parameters.showOnrampOption, toTokenAddress: this.parameters.toTokenAddress, toAmount: this.parameters.toAmount, showBackButton: this.parameters.showBackButton }) }) }) }) }) }) }));
|
|
194569
194586
|
}
|
|
194570
194587
|
};
|
|
194571
194588
|
|
|
@@ -206521,7 +206538,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
206521
206538
|
return zeroBalance;
|
|
206522
206539
|
};
|
|
206523
206540
|
|
|
206524
|
-
function SwapCoins({ theme, cancelAutoProceed, fromAmount, toAmount, fromTokenAddress, toTokenAddress, }) {
|
|
206541
|
+
function SwapCoins({ theme, cancelAutoProceed, fromAmount, toAmount, fromTokenAddress, toTokenAddress, showBackButton, }) {
|
|
206525
206542
|
const { t } = useTranslation();
|
|
206526
206543
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
206527
206544
|
const { eventTargetState: { eventTarget } } = reactExports.useContext(EventTargetContext);
|
|
@@ -206546,7 +206563,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
206546
206563
|
setShowNotEnoughImxDrawer(true);
|
|
206547
206564
|
}
|
|
206548
206565
|
}, [tokenBalances]);
|
|
206549
|
-
return (jsxs(SimpleLayout, { header: !autoProceed ? (jsx$1(HeaderNavigation, { title: t('views.SWAP.header.title'), onCloseButtonClick: () => sendSwapWidgetCloseEvent(eventTarget)
|
|
206566
|
+
return (jsxs(SimpleLayout, { header: !autoProceed ? (jsx$1(HeaderNavigation, { title: t('views.SWAP.header.title'), onCloseButtonClick: () => sendSwapWidgetCloseEvent(eventTarget), showBack: showBackButton, onBackButtonClick: () => {
|
|
206567
|
+
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_SWAP_WIDGET_EVENT, {});
|
|
206568
|
+
} })) : '', footer: jsx$1(QuickswapFooter, { environment: checkout?.config.environment, theme: theme }), children: [jsxs(Box, { sx: {
|
|
206550
206569
|
height: '100%',
|
|
206551
206570
|
display: 'flex',
|
|
206552
206571
|
flexDirection: 'column',
|
|
@@ -207468,7 +207487,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
207468
207487
|
return { allowList, allowedBalances };
|
|
207469
207488
|
};
|
|
207470
207489
|
|
|
207471
|
-
function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProceed, direction, }) {
|
|
207490
|
+
function SwapWidget({ amount, fromTokenAddress, toTokenAddress, config, autoProceed, direction, showBackButton, }) {
|
|
207472
207491
|
const { t } = useTranslation();
|
|
207473
207492
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
207474
207493
|
const { environment, theme, isOnRampEnabled, isSwapEnabled, isBridgeEnabled, } = config;
|
|
@@ -207581,7 +207600,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
207581
207600
|
}, [autoProceed, swapDispatch]);
|
|
207582
207601
|
const fromAmount = direction === SwapDirection$1.FROM || direction == null ? amount : undefined;
|
|
207583
207602
|
const toAmount = direction === SwapDirection$1.TO ? amount : undefined;
|
|
207584
|
-
return (jsx$1(ViewContext.Provider, { value: viewReducerValues, children: jsx$1(SwapContext.Provider, { value: swapReducerValues, children: jsxs(CryptoFiatProvider, { environment: environment, children: [viewState.view.type === SharedViews.LOADING_VIEW && (jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), viewState.view.type === SwapWidgetViews.SWAP && (jsx$1(SwapCoins, { theme: theme, cancelAutoProceed: cancelAutoProceed, fromAmount: viewState.view.data?.fromAmount ?? fromAmount, toAmount: viewState.view.data?.toAmount ?? toAmount, fromTokenAddress: viewState.view.data?.fromTokenAddress ?? fromTokenAddress, toTokenAddress: viewState.view.data?.toTokenAddress ?? toTokenAddress })), viewState.view.type === SwapWidgetViews.IN_PROGRESS && (jsx$1(SwapInProgress, { transactionResponse: viewState.view.data.transactionResponse, swapForm: viewState.view.data.swapForm })), viewState.view.type === SwapWidgetViews.APPROVE_ERC20 && (jsx$1(ApproveERC20Onboarding, { data: viewState.view.data })), viewState.view.type === SwapWidgetViews.SUCCESS && (jsx$1(StatusView, { statusText: t('views.SWAP.success.text'), actionText: t('views.SWAP.success.actionText'), onRenderEvent: () => {
|
|
207603
|
+
return (jsx$1(ViewContext.Provider, { value: viewReducerValues, children: jsx$1(SwapContext.Provider, { value: swapReducerValues, children: jsxs(CryptoFiatProvider, { environment: environment, children: [viewState.view.type === SharedViews.LOADING_VIEW && (jsx$1(LoadingView, { loadingText: t('views.LOADING_VIEW.text') })), viewState.view.type === SwapWidgetViews.SWAP && (jsx$1(SwapCoins, { theme: theme, cancelAutoProceed: cancelAutoProceed, fromAmount: viewState.view.data?.fromAmount ?? fromAmount, toAmount: viewState.view.data?.toAmount ?? toAmount, fromTokenAddress: viewState.view.data?.fromTokenAddress ?? fromTokenAddress, toTokenAddress: viewState.view.data?.toTokenAddress ?? toTokenAddress, showBackButton: showBackButton })), viewState.view.type === SwapWidgetViews.IN_PROGRESS && (jsx$1(SwapInProgress, { transactionResponse: viewState.view.data.transactionResponse, swapForm: viewState.view.data.swapForm })), viewState.view.type === SwapWidgetViews.APPROVE_ERC20 && (jsx$1(ApproveERC20Onboarding, { data: viewState.view.data })), viewState.view.type === SwapWidgetViews.SUCCESS && (jsx$1(StatusView, { statusText: t('views.SWAP.success.text'), actionText: t('views.SWAP.success.actionText'), onRenderEvent: () => {
|
|
207585
207604
|
page({
|
|
207586
207605
|
userJourney: UserJourney.SWAP,
|
|
207587
207606
|
screen: 'SwapSuccess',
|
|
@@ -208999,17 +209018,19 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
208999
209018
|
|
|
209000
209019
|
const transakIframeId = 'transak-iframe';
|
|
209001
209020
|
const IN_PROGRESS_VIEW_DELAY_MS = 6000; // 6 second
|
|
209002
|
-
function OnRampMain({ passport, showIframe, tokenAmount, tokenAddress, }) {
|
|
209021
|
+
function OnRampMain({ passport, showIframe, tokenAmount, tokenAddress, showBackButton, }) {
|
|
209003
209022
|
const { connectLoaderState } = reactExports.useContext(ConnectLoaderContext);
|
|
209004
209023
|
const { checkout, provider } = connectLoaderState;
|
|
209005
|
-
const { eventTargetState: { eventTarget } } = reactExports.useContext(EventTargetContext);
|
|
209024
|
+
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
209006
209025
|
const { t } = useTranslation();
|
|
209007
209026
|
const { viewState, viewDispatch } = reactExports.useContext(ViewContext);
|
|
209008
209027
|
const [widgetUrl, setWidgetUrl] = reactExports.useState('');
|
|
209009
209028
|
const eventTimer = reactExports.useRef();
|
|
209010
209029
|
const isPassport = !!passport && provider?.provider?.isPassport;
|
|
209011
|
-
const
|
|
209012
|
-
&& viewState.history[viewState.history.length - 2].type
|
|
209030
|
+
const openedFromTopUpView = reactExports.useMemo(() => viewState.history.length > 2
|
|
209031
|
+
&& viewState.history[viewState.history.length - 2].type
|
|
209032
|
+
=== SharedViews.TOP_UP_VIEW, [viewState.history]);
|
|
209033
|
+
const showBack = showBackButton || openedFromTopUpView;
|
|
209013
209034
|
const { track } = useAnalytics();
|
|
209014
209035
|
const trackSegmentEvents = async (event, walletAddress) => {
|
|
209015
209036
|
const miscProps = {
|
|
@@ -209164,15 +209185,21 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
209164
209185
|
return;
|
|
209165
209186
|
const host = url.parse(event.origin)?.host?.toLowerCase();
|
|
209166
209187
|
if (event.source === domIframe.contentWindow
|
|
209167
|
-
&& host
|
|
209188
|
+
&& host
|
|
209189
|
+
&& TRANSAK_ORIGIN.includes(host)) {
|
|
209168
209190
|
trackSegmentEvents(event.data, userWalletAddress);
|
|
209169
209191
|
transakEventHandler(event.data);
|
|
209170
209192
|
}
|
|
209171
209193
|
};
|
|
209172
209194
|
window.addEventListener('message', handleTransakEvents);
|
|
209173
209195
|
}, [checkout, provider, tokenAmount, tokenAddress, passport]);
|
|
209174
|
-
return (jsx$1(Box, { sx: boxMainStyle(showIframe), children: jsx$1(SimpleLayout, { header: (jsx$1(HeaderNavigation, {
|
|
209175
|
-
|
|
209196
|
+
return (jsx$1(Box, { sx: boxMainStyle(showIframe), children: jsx$1(SimpleLayout, { header: (jsx$1(HeaderNavigation, { title: t('views.ONRAMP.header.title'), onCloseButtonClick: () => sendOnRampWidgetCloseEvent(eventTarget), showBack: showBack, onBackButtonClick: () => {
|
|
209197
|
+
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT, {});
|
|
209198
|
+
} })), footerBackgroundColor: "base.color.translucent.emphasis.200", children: jsx$1(Box, { sx: containerStyle$1(showIframe), children: jsx$1("iframe", { title: "Transak", id: transakIframeId, src: widgetUrl, allow: "camera;microphone;fullscreen;payment", style: {
|
|
209199
|
+
height: '100%',
|
|
209200
|
+
width: '100%',
|
|
209201
|
+
border: 'none',
|
|
209202
|
+
position: 'absolute',
|
|
209176
209203
|
} }) }) }) }));
|
|
209177
209204
|
}
|
|
209178
209205
|
|
|
@@ -209182,7 +209209,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
209182
209209
|
return (jsx$1(SimpleLayout, { testId: "order-in-progress-view", header: (jsx$1(HeaderNavigation, { transparent: true, onCloseButtonClick: () => sendOnRampWidgetCloseEvent(eventTarget) })), footer: (jsx$1(FooterLogo, {})), heroContent: jsx$1(SpendingCapHero, {}), floatHeader: true, children: jsxs(SimpleTextBody, { heading: t('views.ONRAMP.IN_PROGRESS.content.heading'), children: [t('views.ONRAMP.IN_PROGRESS.content.body1'), jsx$1("br", {}), jsx$1("br", {}), t('views.ONRAMP.IN_PROGRESS.content.body2')] }) }));
|
|
209183
209210
|
}
|
|
209184
209211
|
|
|
209185
|
-
function OnRampWidget({ amount, tokenAddress, config, }) {
|
|
209212
|
+
function OnRampWidget({ amount, tokenAddress, config, showBackButton, }) {
|
|
209186
209213
|
const { isOnRampEnabled, isSwapEnabled, isBridgeEnabled, } = config;
|
|
209187
209214
|
const [viewState, viewDispatch] = reactExports.useReducer(viewReducer, {
|
|
209188
209215
|
...initialViewState,
|
|
@@ -209225,7 +209252,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
209225
209252
|
},
|
|
209226
209253
|
});
|
|
209227
209254
|
}, statusType: StatusType.FAILURE, onCloseClick: () => sendOnRampWidgetCloseEvent(eventTarget), testId: "fail-view" })), (viewState.view.type !== OnRampWidgetViews.SUCCESS
|
|
209228
|
-
&& viewState.view.type !== OnRampWidgetViews.FAIL) && (jsx$1(OnRampMain, { passport: checkout?.passport, showIframe: showIframe, tokenAmount: amount ?? viewState.view.data?.amount, tokenAddress: tknAddr ?? viewState.view.data?.tokenAddress })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx$1(TopUpView, { analytics: { userJourney: UserJourney.ON_RAMP }, widgetEvent: IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT, checkout: checkout, provider: provider, showOnrampOption: isOnRampEnabled, showSwapOption: isSwapEnabled, showBridgeOption: isBridgeEnabled, onCloseButtonClick: () => sendOnRampWidgetCloseEvent(eventTarget) }))] }));
|
|
209255
|
+
&& viewState.view.type !== OnRampWidgetViews.FAIL) && (jsx$1(OnRampMain, { passport: checkout?.passport, showIframe: showIframe, tokenAmount: amount ?? viewState.view.data?.amount, tokenAddress: tknAddr ?? viewState.view.data?.tokenAddress, showBackButton: showBackButton })), viewState.view.type === SharedViews.TOP_UP_VIEW && (jsx$1(TopUpView, { analytics: { userJourney: UserJourney.ON_RAMP }, widgetEvent: IMTBLWidgetEvents.IMTBL_ONRAMP_WIDGET_EVENT, checkout: checkout, provider: provider, showOnrampOption: isOnRampEnabled, showSwapOption: isSwapEnabled, showBridgeOption: isBridgeEnabled, onCloseButtonClick: () => sendOnRampWidgetCloseEvent(eventTarget) }))] }));
|
|
209229
209256
|
}
|
|
209230
209257
|
|
|
209231
209258
|
var OnRampWidget$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -209610,9 +209637,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
209610
209637
|
...balanceResult,
|
|
209611
209638
|
token: {
|
|
209612
209639
|
...balanceResult.token,
|
|
209613
|
-
icon:
|
|
209614
|
-
|
|
209615
|
-
|
|
209640
|
+
icon: balanceResult.token.icon
|
|
209641
|
+
?? getTokenImageByAddress(checkout.config.environment, isNativeToken(balanceResult.token.address)
|
|
209642
|
+
? balanceResult.token.symbol
|
|
209643
|
+
: balanceResult.token.address ?? ''),
|
|
209616
209644
|
},
|
|
209617
209645
|
}));
|
|
209618
209646
|
return sortedTokens;
|
|
@@ -213844,7 +213872,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
213844
213872
|
}, environment: environment }), jsx$1(Box, { sx: submitButtonWrapperStyles, children: jsx$1(Button, { testId: `${testId$1}-submit-button`, size: "large", onClick: handleSubmitDetails, children: t('views.WALLET_NETWORK_SELECTION.submitButton.text') }) })] }))] }));
|
|
213845
213873
|
}
|
|
213846
213874
|
|
|
213847
|
-
function WalletNetworkSelectionView() {
|
|
213875
|
+
function WalletNetworkSelectionView({ showBackButton, }) {
|
|
213848
213876
|
const { t } = useTranslation();
|
|
213849
213877
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
213850
213878
|
const { eventTargetState: { eventTarget } } = reactExports.useContext(EventTargetContext);
|
|
@@ -213862,7 +213890,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
213862
213890
|
view: { type: BridgeWidgetViews.TRANSACTIONS },
|
|
213863
213891
|
},
|
|
213864
213892
|
});
|
|
213865
|
-
}, testId: "move-transactions-button" }))
|
|
213893
|
+
}, testId: "move-transactions-button" })), showBack: showBackButton, onBackButtonClick: () => {
|
|
213894
|
+
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_BRIDGE_WIDGET_EVENT, {});
|
|
213895
|
+
} })), footer: jsx$1(FooterLogo, {}), children: jsx$1(WalletAndNetworkSelector, {}) }));
|
|
213866
213896
|
}
|
|
213867
213897
|
|
|
213868
213898
|
function validateToken(fromToken) {
|
|
@@ -215279,7 +215309,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
215279
215309
|
: handleWithdrawalClaimClick({ forceChangeAccount: true })), children: loading || txProcessing ? (jsx$1(Button.Icon, { icon: "Loading", sx: { width: 'base.icon.size.400' } })) : t(`views.CLAIM_WITHDRAWAL.${hasWithdrawError ? 'footer.retryText' : 'footer.buttonText'}`) }) }), jsx$1(FooterLogo, {})] })), children: [jsxs(SimpleTextBody, { heading: `${t('views.CLAIM_WITHDRAWAL.content.heading')} ${getChainNameById(getL1ChainId(checkout.config))}`, children: [jsx$1(Box, { sx: { display: 'flex', flexWrap: 'wrap', pb: 'base.spacing.x1' }, children: t('views.CLAIM_WITHDRAWAL.content.body') }), jsxs(Box, { children: [t('views.CLAIM_WITHDRAWAL.content.body2'), jsx$1(EllipsizedText, { text: transaction.details.to_address.toLowerCase() ?? '' })] })] }), jsx$1(NotEnoughEthToWithdraw, { visible: showNotEnoughEthDrawer, onClose: () => setShowNotEnoughEthDrawer(false), onChangeAccount: () => handleWithdrawalClaimClick({ forceChangeAccount: true }) })] }));
|
|
215280
215310
|
}
|
|
215281
215311
|
|
|
215282
|
-
function BridgeWidget({ checkout, web3Provider, config, amount, tokenAddress, }) {
|
|
215312
|
+
function BridgeWidget({ checkout, web3Provider, config, amount, tokenAddress, showBackButton, }) {
|
|
215283
215313
|
const { t } = useTranslation();
|
|
215284
215314
|
const { environment, isOnRampEnabled, isSwapEnabled, isBridgeEnabled, theme, } = config;
|
|
215285
215315
|
const defaultTokenImage = getDefaultTokenImage(checkout.config.environment, theme);
|
|
@@ -215373,7 +215403,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
215373
215403
|
});
|
|
215374
215404
|
})();
|
|
215375
215405
|
}, [web3Provider]);
|
|
215376
|
-
return (jsx$1(ViewContext.Provider, { value: viewReducerValues, children: jsx$1(BridgeContext.Provider, { value: bridgeReducerValues, children: jsxs(CryptoFiatProvider, { environment: environment, children: [viewState.view.type === BridgeWidgetViews.WALLET_NETWORK_SELECTION && (jsx$1(WalletNetworkSelectionView, {})), viewState.view.type === BridgeWidgetViews.BRIDGE_FORM && (jsx$1(Bridge, { amount: amount, tokenAddress: tokenAddress, defaultTokenImage: defaultTokenImage, theme: theme })), viewState.view.type === BridgeWidgetViews.BRIDGE_REVIEW && (jsx$1(BridgeReview, {})), viewState.view.type === BridgeWidgetViews.IN_PROGRESS && (jsx$1(MoveInProgress, { transactionHash: viewState.view.transactionHash, isTransfer: viewState.view.isTransfer })), viewState.view.type === BridgeWidgetViews.BRIDGE_FAILURE
|
|
215406
|
+
return (jsx$1(ViewContext.Provider, { value: viewReducerValues, children: jsx$1(BridgeContext.Provider, { value: bridgeReducerValues, children: jsxs(CryptoFiatProvider, { environment: environment, children: [viewState.view.type === BridgeWidgetViews.WALLET_NETWORK_SELECTION && (jsx$1(WalletNetworkSelectionView, { showBackButton: showBackButton })), viewState.view.type === BridgeWidgetViews.BRIDGE_FORM && (jsx$1(Bridge, { amount: amount, tokenAddress: tokenAddress, defaultTokenImage: defaultTokenImage, theme: theme })), viewState.view.type === BridgeWidgetViews.BRIDGE_REVIEW && (jsx$1(BridgeReview, {})), viewState.view.type === BridgeWidgetViews.IN_PROGRESS && (jsx$1(MoveInProgress, { transactionHash: viewState.view.transactionHash, isTransfer: viewState.view.isTransfer })), viewState.view.type === BridgeWidgetViews.BRIDGE_FAILURE
|
|
215377
215407
|
&& (jsx$1(StatusView, { testId: "bridge-fail", statusText: t('views.BRIDGE_FAILURE.bridgeFailureText.statusText'), actionText: t('views.BRIDGE_FAILURE.bridgeFailureText.actionText'), onActionClick: goBackToReview, statusType: StatusType.FAILURE, onRenderEvent: () => {
|
|
215378
215408
|
let reason = '';
|
|
215379
215409
|
if (viewState.view.type === BridgeWidgetViews.BRIDGE_FAILURE) {
|
|
@@ -216008,6 +216038,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216008
216038
|
postMessageHandler?.send(PostMessageHandlerEventType.EIP_6963_EVENT, {
|
|
216009
216039
|
message: 'eip6963:announceProvider',
|
|
216010
216040
|
info: event.detail.info,
|
|
216041
|
+
isPassport: event.detail.provider?.isPassport,
|
|
216042
|
+
isMetamask: event.detail.provider?.isMetamask,
|
|
216011
216043
|
});
|
|
216012
216044
|
}, [postMessageHandler]);
|
|
216013
216045
|
reactExports.useEffect(() => {
|
|
@@ -216033,6 +216065,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216033
216065
|
}, [postMessageHandler, onRequest]);
|
|
216034
216066
|
}
|
|
216035
216067
|
|
|
216068
|
+
var ConnectMethods;
|
|
216069
|
+
(function (ConnectMethods) {
|
|
216070
|
+
ConnectMethods["REQUEST_ACCOUNTS"] = "eth_requestAccounts";
|
|
216071
|
+
ConnectMethods["REQUEST_PERMISSIONS"] = "wallet_requestPermissions";
|
|
216072
|
+
})(ConnectMethods || (ConnectMethods = {}));
|
|
216036
216073
|
function useProviderRelay() {
|
|
216037
216074
|
const [{ checkout, postMessageHandler, provider }, checkoutDispatch] = useCheckoutContext();
|
|
216038
216075
|
const unsubscribePostMessageHandler = reactExports.useRef();
|
|
@@ -216059,11 +216096,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216059
216096
|
});
|
|
216060
216097
|
}
|
|
216061
216098
|
catch (error) {
|
|
216062
|
-
|
|
216063
|
-
postMessageHandler.send(PostMessageHandlerEventType.PROVIDER_RELAY, {
|
|
216064
|
-
response: { id: payload.jsonRpcRequestMessage.id, error: error.message, jsonrpc: '2.0' },
|
|
216065
|
-
eip6963Info: payload.eip6963Info,
|
|
216066
|
-
});
|
|
216099
|
+
throw new Error(error);
|
|
216067
216100
|
}
|
|
216068
216101
|
}, [postMessageHandler]);
|
|
216069
216102
|
/**
|
|
@@ -216082,26 +216115,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216082
216115
|
console.error('PARENT - requested provider not found', providerRelayPayload?.eip6963Info, injectedProviders);
|
|
216083
216116
|
return;
|
|
216084
216117
|
}
|
|
216085
|
-
// If provider is not defined, connect the target provider
|
|
216086
216118
|
let currentProvider = provider;
|
|
216119
|
+
// If provider is not defined, create a provider
|
|
216087
216120
|
if (!currentProvider && targetProvider) {
|
|
216088
|
-
|
|
216089
|
-
provider: new Web3Provider(targetProvider.provider),
|
|
216090
|
-
});
|
|
216091
|
-
currentProvider = connectResponse.provider;
|
|
216092
|
-
// Set provider and execute the request
|
|
216093
|
-
checkoutDispatch({
|
|
216094
|
-
payload: {
|
|
216095
|
-
type: CheckoutActions.SET_PROVIDER,
|
|
216096
|
-
provider: currentProvider,
|
|
216097
|
-
},
|
|
216098
|
-
});
|
|
216121
|
+
currentProvider = new Web3Provider(targetProvider.provider);
|
|
216099
216122
|
}
|
|
216100
216123
|
if (!currentProvider) {
|
|
216101
216124
|
throw new Error('Provider is not defined');
|
|
216102
216125
|
}
|
|
216103
216126
|
try {
|
|
216104
216127
|
await execute(providerRelayPayload, currentProvider);
|
|
216128
|
+
if (providerRelayPayload.jsonRpcRequestMessage.method === ConnectMethods.REQUEST_ACCOUNTS
|
|
216129
|
+
|| providerRelayPayload.jsonRpcRequestMessage.method === ConnectMethods.REQUEST_PERMISSIONS) {
|
|
216130
|
+
checkoutDispatch({
|
|
216131
|
+
payload: {
|
|
216132
|
+
type: CheckoutActions.SET_PROVIDER,
|
|
216133
|
+
provider: currentProvider,
|
|
216134
|
+
},
|
|
216135
|
+
});
|
|
216136
|
+
}
|
|
216105
216137
|
}
|
|
216106
216138
|
catch (error) {
|
|
216107
216139
|
// Send the error using the postMessageHandler
|
|
@@ -216115,16 +216147,12 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216115
216147
|
* Subscribe to provider relay messages
|
|
216116
216148
|
*/
|
|
216117
216149
|
reactExports.useEffect(() => {
|
|
216118
|
-
// TODO we need to unsubscribe everywhere
|
|
216119
216150
|
if (!postMessageHandler)
|
|
216120
216151
|
return;
|
|
216121
216152
|
unsubscribePostMessageHandler.current?.();
|
|
216122
216153
|
unsubscribePostMessageHandler.current = postMessageHandler?.subscribe(onJsonRpcRequestMessage);
|
|
216123
216154
|
}, [postMessageHandler, onJsonRpcRequestMessage]);
|
|
216124
216155
|
}
|
|
216125
|
-
// TODO -
|
|
216126
|
-
// 1 - commit the unsub part
|
|
216127
|
-
// 2 - add unsubs to all postMessageHandlers subscriptions
|
|
216128
216156
|
|
|
216129
216157
|
/**
|
|
216130
216158
|
* The timeout in milliseconds for the iframe to be initialized.
|
|
@@ -216149,6 +216177,20 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216149
216177
|
.trim()
|
|
216150
216178
|
.replace(/\n/g, '');
|
|
216151
216179
|
|
|
216180
|
+
function useWidgetProviderEventRelayer() {
|
|
216181
|
+
const [checkoutState] = useCheckoutContext();
|
|
216182
|
+
const { postMessageHandler } = checkoutState;
|
|
216183
|
+
const onWidgetProviderEvent = reactExports.useCallback(() => {
|
|
216184
|
+
postMessageHandler?.send(PostMessageHandlerEventType.WIDGET_PROVIDER_EVENT, {});
|
|
216185
|
+
}, [postMessageHandler]);
|
|
216186
|
+
reactExports.useEffect(() => {
|
|
216187
|
+
if (!postMessageHandler)
|
|
216188
|
+
return () => { };
|
|
216189
|
+
window.addEventListener(PostMessageHandlerEventType.WIDGET_PROVIDER_EVENT, onWidgetProviderEvent);
|
|
216190
|
+
return () => window.removeEventListener(PostMessageHandlerEventType.WIDGET_PROVIDER_EVENT, onWidgetProviderEvent);
|
|
216191
|
+
}, [postMessageHandler, onWidgetProviderEvent]);
|
|
216192
|
+
}
|
|
216193
|
+
|
|
216152
216194
|
function CheckoutAppIframe() {
|
|
216153
216195
|
const { t } = useTranslation();
|
|
216154
216196
|
const iframeRef = reactExports.useRef(null);
|
|
@@ -216159,6 +216201,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216159
216201
|
useCheckoutEventsRelayer();
|
|
216160
216202
|
useEip6963Relayer();
|
|
216161
216203
|
useProviderRelay();
|
|
216204
|
+
useWidgetProviderEventRelayer();
|
|
216162
216205
|
const loading = !iframeURL || !iframeContentWindow || !initialised;
|
|
216163
216206
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
216164
216207
|
reactExports.useEffect(() => {
|
|
@@ -216206,6 +216249,21 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216206
216249
|
} }))] }));
|
|
216207
216250
|
}
|
|
216208
216251
|
|
|
216252
|
+
/**
|
|
216253
|
+
* Encodes a JSON object using base64 encoding.
|
|
216254
|
+
*/
|
|
216255
|
+
const encodeObject = async (value) => {
|
|
216256
|
+
try {
|
|
216257
|
+
const str = JSON.stringify(value);
|
|
216258
|
+
const base64String = btoa(str);
|
|
216259
|
+
return encodeURIComponent(base64String);
|
|
216260
|
+
}
|
|
216261
|
+
catch (error) {
|
|
216262
|
+
throw new Error(`Compression failed: ${error.message}`);
|
|
216263
|
+
}
|
|
216264
|
+
};
|
|
216265
|
+
|
|
216266
|
+
/* eslint-disable no-case-declarations */
|
|
216209
216267
|
/**
|
|
216210
216268
|
* Converts a record of parameters to a query string.
|
|
216211
216269
|
*/
|
|
@@ -216224,7 +216282,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216224
216282
|
/**
|
|
216225
216283
|
* Maps the flow configuration and params to the corresponding query parameters.
|
|
216226
216284
|
*/
|
|
216227
|
-
const getIframeParams = (params, widgetConfig, checkoutConfig) => {
|
|
216285
|
+
const getIframeParams = async (params, widgetConfig, checkoutConfig) => {
|
|
216228
216286
|
const { flow } = params;
|
|
216229
216287
|
const commonConfig = {
|
|
216230
216288
|
theme: widgetConfig.theme,
|
|
@@ -216294,6 +216352,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216294
216352
|
toAmount: params.tokenAddress,
|
|
216295
216353
|
});
|
|
216296
216354
|
case CheckoutFlowType.SALE:
|
|
216355
|
+
const items = await encodeObject(params.items || []);
|
|
216297
216356
|
return toQueryString({
|
|
216298
216357
|
...commonConfig,
|
|
216299
216358
|
...(widgetConfig.sale || {}),
|
|
@@ -216306,7 +216365,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216306
216365
|
// TODO: Get from hub
|
|
216307
216366
|
environmentId: params.environmentId,
|
|
216308
216367
|
collectionName: params.collectionName,
|
|
216309
|
-
items
|
|
216368
|
+
items,
|
|
216310
216369
|
preferredCurrency: params.preferredCurrency,
|
|
216311
216370
|
excludePaymentTypes: params.excludePaymentTypes,
|
|
216312
216371
|
excludeFiatCurrencies: params.excludeFiatCurrencies,
|
|
@@ -216318,10 +216377,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216318
216377
|
/**
|
|
216319
216378
|
* Returns the iframe URL for the Checkout App based on the environment.
|
|
216320
216379
|
*/
|
|
216321
|
-
const getIframeURL = (params, widgetConfig, checkoutConfig) => {
|
|
216380
|
+
const getIframeURL = async (params, widgetConfig, checkoutConfig) => {
|
|
216322
216381
|
const { flow } = params;
|
|
216323
216382
|
const { publishableKey } = checkoutConfig;
|
|
216324
|
-
|
|
216383
|
+
if (!publishableKey)
|
|
216384
|
+
return '';
|
|
216325
216385
|
let environment = checkoutConfig.environment || Environment$1.SANDBOX;
|
|
216326
216386
|
if (checkoutConfig.isDevelopment) {
|
|
216327
216387
|
environment = ENV_DEVELOPMENT;
|
|
@@ -216329,10 +216389,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216329
216389
|
if (checkoutConfig.overrides?.environment) {
|
|
216330
216390
|
environment = checkoutConfig.overrides.environment;
|
|
216331
216391
|
}
|
|
216332
|
-
const baseURL = checkoutConfig.overrides?.checkoutAppUrl
|
|
216333
|
-
|
|
216334
|
-
const
|
|
216335
|
-
|
|
216392
|
+
const baseURL = checkoutConfig.overrides?.checkoutAppUrl
|
|
216393
|
+
?? CHECKOUT_APP_URL[environment];
|
|
216394
|
+
const queryParams = await getIframeParams(params, widgetConfig, checkoutConfig);
|
|
216395
|
+
const iframeURL = `${baseURL}/${flow}?${queryParams}`;
|
|
216396
|
+
return iframeURL;
|
|
216336
216397
|
};
|
|
216337
216398
|
|
|
216338
216399
|
/**
|
|
@@ -216352,13 +216413,28 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216352
216413
|
}, [deps, effect, compare]);
|
|
216353
216414
|
};
|
|
216354
216415
|
|
|
216416
|
+
/**
|
|
216417
|
+
* Handle asynchronous operations with memoization.
|
|
216418
|
+
* It only re-executes the async function when dependencies change.
|
|
216419
|
+
*/
|
|
216420
|
+
const useAsyncMemo = (asyncFn, dependencies) => {
|
|
216421
|
+
const [value, setValue] = reactExports.useState();
|
|
216422
|
+
reactExports.useEffect(() => {
|
|
216423
|
+
let isMounted = true;
|
|
216424
|
+
asyncFn().then((result) => {
|
|
216425
|
+
if (isMounted)
|
|
216426
|
+
setValue(result);
|
|
216427
|
+
});
|
|
216428
|
+
return () => {
|
|
216429
|
+
isMounted = false;
|
|
216430
|
+
};
|
|
216431
|
+
}, dependencies);
|
|
216432
|
+
return value;
|
|
216433
|
+
};
|
|
216434
|
+
|
|
216355
216435
|
function CheckoutWidget(props) {
|
|
216356
216436
|
const { config, checkout, params, provider, } = props;
|
|
216357
|
-
const
|
|
216358
|
-
if (!checkout.config.publishableKey)
|
|
216359
|
-
return ['', ''];
|
|
216360
|
-
return getIframeURL(params, config, checkout.config);
|
|
216361
|
-
}, [params, config, checkout.config]);
|
|
216437
|
+
const iframeURL = useAsyncMemo(async () => getIframeURL(params, config, checkout.config), [params, config, checkout.config]);
|
|
216362
216438
|
const [checkoutState, checkoutDispatch] = reactExports.useReducer(checkoutReducer, initialCheckoutState);
|
|
216363
216439
|
const checkoutReducerValues = reactExports.useMemo(() => ({
|
|
216364
216440
|
checkoutState: { ...checkoutState, iframeURL, checkout },
|
|
@@ -216392,8 +216468,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216392
216468
|
const initialAddFundsState = {
|
|
216393
216469
|
checkout: null,
|
|
216394
216470
|
provider: null,
|
|
216395
|
-
allowedTokens:
|
|
216471
|
+
allowedTokens: [],
|
|
216396
216472
|
squid: null,
|
|
216473
|
+
chains: [],
|
|
216474
|
+
balances: [],
|
|
216397
216475
|
};
|
|
216398
216476
|
var AddFundsActions;
|
|
216399
216477
|
(function (AddFundsActions) {
|
|
@@ -216401,6 +216479,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216401
216479
|
AddFundsActions["SET_PROVIDER"] = "SET_PROVIDER";
|
|
216402
216480
|
AddFundsActions["SET_ALLOWED_TOKENS"] = "SET_ALLOWED_TOKENS";
|
|
216403
216481
|
AddFundsActions["SET_SQUID"] = "SET_SQUID";
|
|
216482
|
+
AddFundsActions["SET_CHAINS"] = "SET_CHAINS";
|
|
216483
|
+
AddFundsActions["SET_BALANCES"] = "SET_BALANCES";
|
|
216404
216484
|
})(AddFundsActions || (AddFundsActions = {}));
|
|
216405
216485
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
216406
216486
|
const AddFundsContext = reactExports.createContext({
|
|
@@ -216430,15 +216510,20 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216430
216510
|
...state,
|
|
216431
216511
|
squid: action.payload.squid,
|
|
216432
216512
|
};
|
|
216513
|
+
case AddFundsActions.SET_CHAINS:
|
|
216514
|
+
return {
|
|
216515
|
+
...state,
|
|
216516
|
+
chains: action.payload.chains,
|
|
216517
|
+
};
|
|
216518
|
+
case AddFundsActions.SET_BALANCES:
|
|
216519
|
+
return {
|
|
216520
|
+
...state,
|
|
216521
|
+
balances: action.payload.balances,
|
|
216522
|
+
};
|
|
216433
216523
|
default:
|
|
216434
216524
|
return state;
|
|
216435
216525
|
}
|
|
216436
216526
|
};
|
|
216437
|
-
const useAddFundsValues = (overrides = {}) => {
|
|
216438
|
-
const [addFundsState, addFundsDispatch] = reactExports.useReducer(addFundsReducer, { ...initialAddFundsState, ...overrides });
|
|
216439
|
-
const values = reactExports.useMemo(() => ({ addFundsState, addFundsDispatch }), [addFundsState, addFundsDispatch]);
|
|
216440
|
-
return values;
|
|
216441
|
-
};
|
|
216442
216527
|
|
|
216443
216528
|
var AddFundsWidgetViews;
|
|
216444
216529
|
(function (AddFundsWidgetViews) {
|
|
@@ -216521,19 +216606,20 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216521
216606
|
} }) }) }) }));
|
|
216522
216607
|
}
|
|
216523
216608
|
|
|
216524
|
-
function AddFunds({ checkout, provider,
|
|
216609
|
+
function AddFunds({ checkout, provider, toAmount, toTokenAddress, showBackButton = false, showOnrampOption = true, showSwapOption = true, showBridgeOption = true, onBackButtonClick, onCloseButtonClick, }) {
|
|
216525
216610
|
console.log('provider', provider);
|
|
216526
216611
|
console.log('showOnrampOption', showOnrampOption);
|
|
216527
216612
|
console.log('showSwapOption', showSwapOption);
|
|
216528
216613
|
console.log('showBridgeOption', showBridgeOption);
|
|
216614
|
+
const showBack = showBackButton || !!onBackButtonClick;
|
|
216529
216615
|
const { addFundsDispatch } = reactExports.useContext(AddFundsContext);
|
|
216530
216616
|
const { viewDispatch } = reactExports.useContext(ViewContext);
|
|
216531
216617
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
216532
216618
|
const [showOptionsDrawer, setShowOptionsDrawer] = reactExports.useState(false);
|
|
216533
216619
|
const [onRampAllowedTokens, setOnRampAllowedTokens] = reactExports.useState([]);
|
|
216534
216620
|
const [allowedTokens, setAllowedTokens] = reactExports.useState([]);
|
|
216535
|
-
const [
|
|
216536
|
-
const [
|
|
216621
|
+
const [currentToAmount, setCurrentToAmount] = reactExports.useState(toAmount || '0');
|
|
216622
|
+
const [currentToTokenAddress, setCurrentToTokenAddress] = reactExports.useState();
|
|
216537
216623
|
const showErrorView = reactExports.useCallback((error) => {
|
|
216538
216624
|
viewDispatch({
|
|
216539
216625
|
payload: {
|
|
@@ -216558,8 +216644,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216558
216644
|
});
|
|
216559
216645
|
if (tokenResponse?.tokens.length > 0) {
|
|
216560
216646
|
setAllowedTokens(tokenResponse.tokens);
|
|
216561
|
-
const token = tokenResponse.tokens.find((t) => t.address ===
|
|
216562
|
-
|
|
216647
|
+
const token = tokenResponse.tokens.find((t) => t.address === toTokenAddress)
|
|
216648
|
+
|| tokenResponse.tokens[0];
|
|
216649
|
+
setCurrentToTokenAddress(token);
|
|
216563
216650
|
addFundsDispatch({
|
|
216564
216651
|
payload: {
|
|
216565
216652
|
type: AddFundsActions.SET_ALLOWED_TOKENS,
|
|
@@ -216573,7 +216660,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216573
216660
|
}
|
|
216574
216661
|
};
|
|
216575
216662
|
fetchTokens();
|
|
216576
|
-
}, [checkout,
|
|
216663
|
+
}, [checkout, toTokenAddress]);
|
|
216577
216664
|
reactExports.useEffect(() => {
|
|
216578
216665
|
if (!checkout) {
|
|
216579
216666
|
showErrorView(new Error('Checkout object is missing'));
|
|
@@ -216599,43 +216686,47 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216599
216686
|
setShowOptionsDrawer(true);
|
|
216600
216687
|
};
|
|
216601
216688
|
const updateAmount = (value) => {
|
|
216602
|
-
|
|
216689
|
+
setCurrentToAmount(value);
|
|
216603
216690
|
};
|
|
216604
|
-
const isSelected = (token) => token.address ===
|
|
216605
|
-
const isDisabled = !
|
|
216691
|
+
const isSelected = (token) => token.address === currentToTokenAddress;
|
|
216692
|
+
const isDisabled = !currentToTokenAddress || !toAmount || parseFloat(toAmount) <= 0;
|
|
216606
216693
|
const handleTokenChange = (token) => {
|
|
216607
|
-
|
|
216694
|
+
setCurrentToTokenAddress(token);
|
|
216608
216695
|
};
|
|
216609
216696
|
// const handleReviewClick = () => {
|
|
216610
216697
|
// console.log('handle review click');
|
|
216611
216698
|
// };
|
|
216612
216699
|
const onPayWithCard = (paymentType) => {
|
|
216613
216700
|
console.log('paymentType', paymentType);
|
|
216614
|
-
console.log('=== toTokenAddress',
|
|
216701
|
+
console.log('=== toTokenAddress', currentToTokenAddress);
|
|
216615
216702
|
console.log('=== toAmount', toAmount);
|
|
216616
216703
|
if (paymentType === OptionTypes.SWAP) {
|
|
216617
216704
|
orchestrationEvents.sendRequestSwapEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT, {
|
|
216618
|
-
toTokenAddress:
|
|
216705
|
+
toTokenAddress: currentToTokenAddress?.address ?? '',
|
|
216619
216706
|
amount: toAmount ?? '',
|
|
216620
216707
|
fromTokenAddress: '',
|
|
216621
216708
|
});
|
|
216622
216709
|
}
|
|
216623
216710
|
else {
|
|
216624
216711
|
const data = {
|
|
216625
|
-
tokenAddress:
|
|
216712
|
+
tokenAddress: currentToTokenAddress?.address ?? '',
|
|
216626
216713
|
amount: toAmount ?? '',
|
|
216627
216714
|
};
|
|
216628
216715
|
orchestrationEvents.sendRequestOnrampEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT, data);
|
|
216629
216716
|
}
|
|
216630
216717
|
};
|
|
216631
216718
|
const checkShowOnRampOption = () => {
|
|
216632
|
-
if (showOnrampOption &&
|
|
216633
|
-
const token = onRampAllowedTokens.find((t) => t.address?.toLowerCase()
|
|
216719
|
+
if (showOnrampOption && currentToTokenAddress) {
|
|
216720
|
+
const token = onRampAllowedTokens.find((t) => t.address?.toLowerCase()
|
|
216721
|
+
=== currentToTokenAddress.address?.toLowerCase());
|
|
216634
216722
|
return !!token;
|
|
216635
216723
|
}
|
|
216636
216724
|
return false;
|
|
216637
216725
|
};
|
|
216638
|
-
return (jsx$1(SimpleLayout, { header: (jsx$1(HeaderNavigation, { title: "Add",
|
|
216726
|
+
return (jsx$1(SimpleLayout, { header: (jsx$1(HeaderNavigation, { title: "Add", onCloseButtonClick: onCloseButtonClick, showBack: showBack, onBackButtonClick: () => {
|
|
216727
|
+
orchestrationEvents.sendRequestGoBackEvent(eventTarget, IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT, {});
|
|
216728
|
+
onBackButtonClick?.();
|
|
216729
|
+
} })), children: jsxs(Box, { sx: {
|
|
216639
216730
|
display: 'flex',
|
|
216640
216731
|
flexDirection: 'column',
|
|
216641
216732
|
justifyContent: 'space-between',
|
|
@@ -216644,14 +216735,14 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
216644
216735
|
display: 'flex',
|
|
216645
216736
|
justifyContent: 'center',
|
|
216646
216737
|
marginTop: 'base.spacing.x10',
|
|
216647
|
-
}, children: jsxs(Box, { sx: { width: 'base.spacing.x40' }, children: [jsx$1(Box, { sx: { marginBottom: 'base.spacing.x3' }, children: jsx$1(TextInputForm, { testId: "add-funds-amount", type: "number", value:
|
|
216738
|
+
}, children: jsxs(Box, { sx: { width: 'base.spacing.x40' }, children: [jsx$1(Box, { sx: { marginBottom: 'base.spacing.x3' }, children: jsx$1(TextInputForm, { testId: "add-funds-amount", type: "number", value: currentToAmount, validator: amountInputValidation, onTextInputChange: (value) => updateAmount(value), textAlign: "right", inputMode: "decimal" }) }), jsxs(Box, { sx: {
|
|
216648
216739
|
display: 'flex',
|
|
216649
216740
|
borderRadius: 'base.borderRadius.x20',
|
|
216650
216741
|
alignItems: 'center',
|
|
216651
216742
|
gap: 'base.spacing.x5',
|
|
216652
216743
|
justifyContent: 'center',
|
|
216653
216744
|
border: '1px solid grey',
|
|
216654
|
-
}, children: [jsx$1(Body, { size: "large", weight: "bold", children:
|
|
216745
|
+
}, children: [jsx$1(Body, { size: "large", weight: "bold", children: currentToTokenAddress?.name ?? '' }), jsx$1(OverflowPopoverMenu, { testId: "add-funds-tokens-menu", children: allowedTokens.map((token) => (jsx$1(MenuItem, { onClick: () => handleTokenChange(token), selected: isSelected(token), children: jsx$1(MenuItem.Label, { children: token.name }) }, token.address))) })] })] }) }), jsxs(MenuItem, { size: "small", emphasized: true, disabled: isDisabled, sx: {
|
|
216655
216746
|
opacity: isDisabled ? 0.5 : 1,
|
|
216656
216747
|
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
216657
216748
|
}, onClick: () => {
|
|
@@ -380492,44 +380583,60 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
380492
380583
|
Squid_1 = dist$2.Squid = Squid;
|
|
380493
380584
|
|
|
380494
380585
|
const SQUID_SDK_BASE_URL = 'https://apiplus.squidrouter.com';
|
|
380586
|
+
const SQUID_API_BASE_URL = 'https://api.squidrouter.com/v1';
|
|
380495
380587
|
|
|
380496
|
-
const useSquid = () => {
|
|
380588
|
+
const useSquid = (checkout) => {
|
|
380497
380589
|
const [squid, setSquid] = reactExports.useState(null);
|
|
380590
|
+
const squidConfig = reactExports.useCallback(async () => {
|
|
380591
|
+
try {
|
|
380592
|
+
return (await checkout?.config?.remote.getConfig('squid'));
|
|
380593
|
+
}
|
|
380594
|
+
catch (err) {
|
|
380595
|
+
// eslint-disable-next-line no-console
|
|
380596
|
+
console.error('Unable to fetch squid config: ', err);
|
|
380597
|
+
}
|
|
380598
|
+
return undefined;
|
|
380599
|
+
}, [checkout]);
|
|
380498
380600
|
reactExports.useEffect(() => {
|
|
380499
|
-
if (squid) {
|
|
380601
|
+
if (squid || !squidConfig) {
|
|
380500
380602
|
return;
|
|
380501
380603
|
}
|
|
380502
380604
|
const initialiseSquid = async () => {
|
|
380605
|
+
const config = await squidConfig();
|
|
380606
|
+
if (!config?.integratorId)
|
|
380607
|
+
return;
|
|
380503
380608
|
const squidSDK = new Squid_1({
|
|
380504
380609
|
baseUrl: SQUID_SDK_BASE_URL,
|
|
380505
|
-
integratorId:
|
|
380610
|
+
integratorId: config.integratorId,
|
|
380506
380611
|
});
|
|
380507
380612
|
await squidSDK.init();
|
|
380508
380613
|
setSquid(squidSDK);
|
|
380509
380614
|
};
|
|
380510
380615
|
initialiseSquid();
|
|
380511
|
-
}, []);
|
|
380616
|
+
}, [squidConfig]);
|
|
380512
380617
|
return squid;
|
|
380513
380618
|
};
|
|
380514
380619
|
|
|
380515
|
-
|
|
380516
|
-
const
|
|
380517
|
-
const
|
|
380518
|
-
|
|
380519
|
-
|
|
380520
|
-
|
|
380521
|
-
|
|
380522
|
-
|
|
380523
|
-
|
|
380524
|
-
|
|
380525
|
-
|
|
380526
|
-
|
|
380527
|
-
|
|
380528
|
-
|
|
380529
|
-
|
|
380530
|
-
|
|
380620
|
+
const fetchChains = async () => {
|
|
380621
|
+
const url = `${SQUID_API_BASE_URL}/chains`;
|
|
380622
|
+
const response = await fetch(url, {
|
|
380623
|
+
method: 'GET',
|
|
380624
|
+
headers: {
|
|
380625
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
380626
|
+
'Content-Type': 'application/json',
|
|
380627
|
+
},
|
|
380628
|
+
});
|
|
380629
|
+
const data = await response.json();
|
|
380630
|
+
const chains = data.chains.map((chain) => ({
|
|
380631
|
+
id: chain.chainId.toString(),
|
|
380632
|
+
name: chain.chainName,
|
|
380633
|
+
iconUrl: chain.chainIconURI,
|
|
380634
|
+
type: chain.chainType,
|
|
380635
|
+
}));
|
|
380636
|
+
return chains;
|
|
380637
|
+
};
|
|
380531
380638
|
|
|
380532
|
-
function AddFundsWidget({ checkout, web3Provider, showOnrampOption = true, showSwapOption = true, showBridgeOption = true,
|
|
380639
|
+
function AddFundsWidget({ checkout, web3Provider, showOnrampOption = true, showSwapOption = true, showBridgeOption = true, toTokenAddress, toAmount, showBackButton, }) {
|
|
380533
380640
|
const [viewState, viewDispatch] = reactExports.useReducer(viewReducer, {
|
|
380534
380641
|
...initialViewState,
|
|
380535
380642
|
view: { type: AddFundsWidgetViews.ADD_FUNDS },
|
|
@@ -380541,7 +380648,51 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
380541
380648
|
viewState,
|
|
380542
380649
|
viewDispatch,
|
|
380543
380650
|
}), [viewState, viewReducer]);
|
|
380544
|
-
const
|
|
380651
|
+
const [addFundsState, addFundsDispatch] = reactExports.useReducer(addFundsReducer, initialAddFundsState);
|
|
380652
|
+
const addFundsReducerValues = reactExports.useMemo(() => ({
|
|
380653
|
+
addFundsState,
|
|
380654
|
+
addFundsDispatch,
|
|
380655
|
+
}), [addFundsState, addFundsDispatch]);
|
|
380656
|
+
const squid = useSquid(checkout);
|
|
380657
|
+
reactExports.useEffect(() => {
|
|
380658
|
+
(async () => {
|
|
380659
|
+
const chains = await fetchChains();
|
|
380660
|
+
addFundsDispatch({
|
|
380661
|
+
payload: {
|
|
380662
|
+
type: AddFundsActions.SET_CHAINS,
|
|
380663
|
+
chains,
|
|
380664
|
+
},
|
|
380665
|
+
});
|
|
380666
|
+
})();
|
|
380667
|
+
}, []);
|
|
380668
|
+
reactExports.useEffect(() => {
|
|
380669
|
+
if (!addFundsState.squid || !addFundsState.chains || !addFundsState.provider)
|
|
380670
|
+
return;
|
|
380671
|
+
(async () => {
|
|
380672
|
+
const chainIds = addFundsState.chains.map((chain) => chain.id);
|
|
380673
|
+
const fromAddress = await addFundsState.provider?.getSigner().getAddress();
|
|
380674
|
+
const balances = await addFundsState.squid?.getAllBalances({
|
|
380675
|
+
chainIds,
|
|
380676
|
+
evmAddress: fromAddress,
|
|
380677
|
+
});
|
|
380678
|
+
addFundsDispatch({
|
|
380679
|
+
payload: {
|
|
380680
|
+
type: AddFundsActions.SET_BALANCES,
|
|
380681
|
+
balances: balances?.evmBalances ?? [],
|
|
380682
|
+
},
|
|
380683
|
+
});
|
|
380684
|
+
})();
|
|
380685
|
+
}, [addFundsState.squid, addFundsState.chains, addFundsState.provider]);
|
|
380686
|
+
reactExports.useEffect(() => {
|
|
380687
|
+
if (!squid || addFundsState.squid)
|
|
380688
|
+
return;
|
|
380689
|
+
addFundsDispatch({
|
|
380690
|
+
payload: {
|
|
380691
|
+
type: AddFundsActions.SET_SQUID,
|
|
380692
|
+
squid,
|
|
380693
|
+
},
|
|
380694
|
+
});
|
|
380695
|
+
}, [squid]);
|
|
380545
380696
|
reactExports.useEffect(() => {
|
|
380546
380697
|
if (!web3Provider)
|
|
380547
380698
|
return;
|
|
@@ -380563,7 +380714,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
380563
380714
|
});
|
|
380564
380715
|
}, [checkout]);
|
|
380565
380716
|
const { eventTargetState: { eventTarget }, } = reactExports.useContext(EventTargetContext);
|
|
380566
|
-
return (jsx$1(ViewContext.Provider, { value: viewReducerValues, children: jsxs(
|
|
380717
|
+
return (jsx$1(ViewContext.Provider, { value: viewReducerValues, children: jsxs(AddFundsContext.Provider, { value: addFundsReducerValues, children: [viewState.view.type === AddFundsWidgetViews.ADD_FUNDS && (jsx$1(AddFunds, { checkout: checkout, provider: web3Provider, toTokenAddress: toTokenAddress, toAmount: toAmount, showBackButton: showBackButton, showOnrampOption: showOnrampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, onCloseButtonClick: () => sendAddFundsCloseEvent(eventTarget) })), viewState.view.type === SharedViews.ERROR_VIEW && (jsx$1(ErrorView, { actionText: t('views.ERROR_VIEW.actionText'), onActionClick: () => undefined, onCloseClick: () => sendAddFundsCloseEvent(eventTarget), errorEventAction: () => {
|
|
380567
380718
|
page({
|
|
380568
380719
|
userJourney: UserJourney.ADD_FUNDS,
|
|
380569
380720
|
screen: 'Error',
|