@imtbl/sdk 1.7.3-alpha.1 → 1.7.3-alpha.2
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.d.ts +288 -449
- package/dist/blockchain_data.js +2 -149
- package/dist/browser/checkout/BridgeWidget-85db50d2.js +1 -0
- package/dist/browser/checkout/OnRampWidget-58400404.js +1 -0
- package/dist/browser/checkout/SaleWidget-549f0f75.js +2 -0
- package/dist/browser/checkout/SpendingCapHero-24fed6d2.js +1 -0
- package/dist/browser/checkout/SwapWidget-9eecba27.js +1 -0
- package/dist/browser/checkout/TopUpView-26964a9e.js +1 -0
- package/dist/browser/checkout/WalletWidget-7e6fed9c.js +1 -0
- package/dist/browser/checkout/auto-track-da38e5a8.js +1 -0
- package/dist/browser/checkout/balance-310539bb.js +1 -0
- package/dist/browser/checkout/index-392bc434.js +1 -0
- package/dist/browser/checkout/index-3d847e0c.js +1 -0
- package/dist/browser/checkout/index-4e77760b.js +773 -0
- package/dist/browser/checkout/index-8184ffea.js +1 -0
- package/dist/browser/checkout/index-919a5df1.js +1 -0
- package/dist/browser/checkout/index-e6159023.js +1 -0
- package/dist/browser/checkout/index-eb42cd09.js +106 -0
- package/dist/browser/checkout/index.umd-c2e32802.js +1 -0
- package/dist/browser/checkout/is-plan-event-enabled-80f76ce6.js +1 -0
- package/dist/browser/checkout/retry-355e44f2.js +1 -0
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/useTransakEvents-c6a83ea5.js +2 -0
- package/dist/browser/checkout/widgets-esm.js +1 -0
- package/dist/browser/checkout/widgets.js +50 -51
- package/dist/checkout.d.ts +3 -1
- package/dist/checkout.js +65 -179
- package/dist/config.js +1 -1
- package/dist/index.browser.js +7 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +200 -290
- package/dist/index.d.ts +291 -450
- package/dist/index.js +200 -290
- package/dist/orderbook.js +1 -1
- package/dist/passport.js +136 -239
- package/dist/x.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -174,7 +174,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
177
|
-
const SDK_VERSION$1 = '1.7.3-alpha.
|
|
177
|
+
const SDK_VERSION$1 = '1.7.3-alpha.2';
|
|
178
178
|
const getReferrer$1 = () => {
|
|
179
179
|
if (isNode$1()) {
|
|
180
180
|
return '';
|
|
@@ -8441,85 +8441,6 @@ class NftOwnersApi extends BaseAPI$2 {
|
|
|
8441
8441
|
*/
|
|
8442
8442
|
const NftsApiAxiosParamCreator = function (configuration) {
|
|
8443
8443
|
return {
|
|
8444
|
-
/**
|
|
8445
|
-
* Create a mint request to mint a set of NFTs for a given collection
|
|
8446
|
-
* @summary Mint NFTs
|
|
8447
|
-
* @param {string} contractAddress The address of contract
|
|
8448
|
-
* @param {string} chainName The name of chain
|
|
8449
|
-
* @param {CreateMintRequestRequest} createMintRequestRequest the request body
|
|
8450
|
-
* @param {*} [options] Override http request option.
|
|
8451
|
-
* @throws {RequiredError}
|
|
8452
|
-
*/
|
|
8453
|
-
createMintRequest: async (contractAddress, chainName, createMintRequestRequest, options = {}) => {
|
|
8454
|
-
// verify required parameter 'contractAddress' is not null or undefined
|
|
8455
|
-
assertParamExists$2('createMintRequest', 'contractAddress', contractAddress);
|
|
8456
|
-
// verify required parameter 'chainName' is not null or undefined
|
|
8457
|
-
assertParamExists$2('createMintRequest', 'chainName', chainName);
|
|
8458
|
-
// verify required parameter 'createMintRequestRequest' is not null or undefined
|
|
8459
|
-
assertParamExists$2('createMintRequest', 'createMintRequestRequest', createMintRequestRequest);
|
|
8460
|
-
const localVarPath = `/v1/chains/{chain_name}/collections/{contract_address}/nfts/mint-requests`
|
|
8461
|
-
.replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress)))
|
|
8462
|
-
.replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
|
|
8463
|
-
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
8464
|
-
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL$2);
|
|
8465
|
-
let baseOptions;
|
|
8466
|
-
if (configuration) {
|
|
8467
|
-
baseOptions = configuration.baseOptions;
|
|
8468
|
-
}
|
|
8469
|
-
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
|
|
8470
|
-
const localVarHeaderParameter = {};
|
|
8471
|
-
const localVarQueryParameter = {};
|
|
8472
|
-
// authentication ImmutableApiKey required
|
|
8473
|
-
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
|
|
8474
|
-
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
8475
|
-
setSearchParams$2(localVarUrlObj, localVarQueryParameter);
|
|
8476
|
-
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
8477
|
-
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
8478
|
-
localVarRequestOptions.data = serializeDataIfNeeded$2(createMintRequestRequest, localVarRequestOptions, configuration);
|
|
8479
|
-
return {
|
|
8480
|
-
url: toPathString$2(localVarUrlObj),
|
|
8481
|
-
options: localVarRequestOptions,
|
|
8482
|
-
};
|
|
8483
|
-
},
|
|
8484
|
-
/**
|
|
8485
|
-
* Retrieve the status of a mint request identified by its reference_id
|
|
8486
|
-
* @summary Mint NFTs
|
|
8487
|
-
* @param {string} contractAddress The address of contract
|
|
8488
|
-
* @param {string} chainName The name of chain
|
|
8489
|
-
* @param {string} referenceId The ID of the mint request
|
|
8490
|
-
* @param {*} [options] Override http request option.
|
|
8491
|
-
* @throws {RequiredError}
|
|
8492
|
-
*/
|
|
8493
|
-
getMintRequest: async (contractAddress, chainName, referenceId, options = {}) => {
|
|
8494
|
-
// verify required parameter 'contractAddress' is not null or undefined
|
|
8495
|
-
assertParamExists$2('getMintRequest', 'contractAddress', contractAddress);
|
|
8496
|
-
// verify required parameter 'chainName' is not null or undefined
|
|
8497
|
-
assertParamExists$2('getMintRequest', 'chainName', chainName);
|
|
8498
|
-
// verify required parameter 'referenceId' is not null or undefined
|
|
8499
|
-
assertParamExists$2('getMintRequest', 'referenceId', referenceId);
|
|
8500
|
-
const localVarPath = `/v1/chains/{chain_name}/collections/{contract_address}/nfts/mint-requests/{reference_id}`
|
|
8501
|
-
.replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress)))
|
|
8502
|
-
.replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)))
|
|
8503
|
-
.replace(`{${"reference_id"}}`, encodeURIComponent(String(referenceId)));
|
|
8504
|
-
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
8505
|
-
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL$2);
|
|
8506
|
-
let baseOptions;
|
|
8507
|
-
if (configuration) {
|
|
8508
|
-
baseOptions = configuration.baseOptions;
|
|
8509
|
-
}
|
|
8510
|
-
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
|
|
8511
|
-
const localVarHeaderParameter = {};
|
|
8512
|
-
const localVarQueryParameter = {};
|
|
8513
|
-
// authentication ImmutableApiKey required
|
|
8514
|
-
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
|
|
8515
|
-
setSearchParams$2(localVarUrlObj, localVarQueryParameter);
|
|
8516
|
-
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
8517
|
-
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
8518
|
-
return {
|
|
8519
|
-
url: toPathString$2(localVarUrlObj),
|
|
8520
|
-
options: localVarRequestOptions,
|
|
8521
|
-
};
|
|
8522
|
-
},
|
|
8523
8444
|
/**
|
|
8524
8445
|
* Get NFT by token ID
|
|
8525
8446
|
* @summary Get NFT by token ID
|
|
@@ -8705,32 +8626,6 @@ const NftsApiAxiosParamCreator = function (configuration) {
|
|
|
8705
8626
|
const NftsApiFp = function (configuration) {
|
|
8706
8627
|
const localVarAxiosParamCreator = NftsApiAxiosParamCreator(configuration);
|
|
8707
8628
|
return {
|
|
8708
|
-
/**
|
|
8709
|
-
* Create a mint request to mint a set of NFTs for a given collection
|
|
8710
|
-
* @summary Mint NFTs
|
|
8711
|
-
* @param {string} contractAddress The address of contract
|
|
8712
|
-
* @param {string} chainName The name of chain
|
|
8713
|
-
* @param {CreateMintRequestRequest} createMintRequestRequest the request body
|
|
8714
|
-
* @param {*} [options] Override http request option.
|
|
8715
|
-
* @throws {RequiredError}
|
|
8716
|
-
*/
|
|
8717
|
-
async createMintRequest(contractAddress, chainName, createMintRequestRequest, options) {
|
|
8718
|
-
const localVarAxiosArgs = await localVarAxiosParamCreator.createMintRequest(contractAddress, chainName, createMintRequestRequest, options);
|
|
8719
|
-
return createRequestFunction$2(localVarAxiosArgs, globalAxios$1, BASE_PATH$2, configuration);
|
|
8720
|
-
},
|
|
8721
|
-
/**
|
|
8722
|
-
* Retrieve the status of a mint request identified by its reference_id
|
|
8723
|
-
* @summary Mint NFTs
|
|
8724
|
-
* @param {string} contractAddress The address of contract
|
|
8725
|
-
* @param {string} chainName The name of chain
|
|
8726
|
-
* @param {string} referenceId The ID of the mint request
|
|
8727
|
-
* @param {*} [options] Override http request option.
|
|
8728
|
-
* @throws {RequiredError}
|
|
8729
|
-
*/
|
|
8730
|
-
async getMintRequest(contractAddress, chainName, referenceId, options) {
|
|
8731
|
-
const localVarAxiosArgs = await localVarAxiosParamCreator.getMintRequest(contractAddress, chainName, referenceId, options);
|
|
8732
|
-
return createRequestFunction$2(localVarAxiosArgs, globalAxios$1, BASE_PATH$2, configuration);
|
|
8733
|
-
},
|
|
8734
8629
|
/**
|
|
8735
8630
|
* Get NFT by token ID
|
|
8736
8631
|
* @summary Get NFT by token ID
|
|
@@ -8798,26 +8693,6 @@ const NftsApiFp = function (configuration) {
|
|
|
8798
8693
|
const NftsApiFactory = function (configuration, basePath, axios) {
|
|
8799
8694
|
const localVarFp = NftsApiFp(configuration);
|
|
8800
8695
|
return {
|
|
8801
|
-
/**
|
|
8802
|
-
* Create a mint request to mint a set of NFTs for a given collection
|
|
8803
|
-
* @summary Mint NFTs
|
|
8804
|
-
* @param {NftsApiCreateMintRequestRequest} requestParameters Request parameters.
|
|
8805
|
-
* @param {*} [options] Override http request option.
|
|
8806
|
-
* @throws {RequiredError}
|
|
8807
|
-
*/
|
|
8808
|
-
createMintRequest(requestParameters, options) {
|
|
8809
|
-
return localVarFp.createMintRequest(requestParameters.contractAddress, requestParameters.chainName, requestParameters.createMintRequestRequest, options).then((request) => request(axios, basePath));
|
|
8810
|
-
},
|
|
8811
|
-
/**
|
|
8812
|
-
* Retrieve the status of a mint request identified by its reference_id
|
|
8813
|
-
* @summary Mint NFTs
|
|
8814
|
-
* @param {NftsApiGetMintRequestRequest} requestParameters Request parameters.
|
|
8815
|
-
* @param {*} [options] Override http request option.
|
|
8816
|
-
* @throws {RequiredError}
|
|
8817
|
-
*/
|
|
8818
|
-
getMintRequest(requestParameters, options) {
|
|
8819
|
-
return localVarFp.getMintRequest(requestParameters.contractAddress, requestParameters.chainName, requestParameters.referenceId, options).then((request) => request(axios, basePath));
|
|
8820
|
-
},
|
|
8821
8696
|
/**
|
|
8822
8697
|
* Get NFT by token ID
|
|
8823
8698
|
* @summary Get NFT by token ID
|
|
@@ -8867,28 +8742,6 @@ const NftsApiFactory = function (configuration, basePath, axios) {
|
|
|
8867
8742
|
* @extends {BaseAPI}
|
|
8868
8743
|
*/
|
|
8869
8744
|
class NftsApi extends BaseAPI$2 {
|
|
8870
|
-
/**
|
|
8871
|
-
* Create a mint request to mint a set of NFTs for a given collection
|
|
8872
|
-
* @summary Mint NFTs
|
|
8873
|
-
* @param {NftsApiCreateMintRequestRequest} requestParameters Request parameters.
|
|
8874
|
-
* @param {*} [options] Override http request option.
|
|
8875
|
-
* @throws {RequiredError}
|
|
8876
|
-
* @memberof NftsApi
|
|
8877
|
-
*/
|
|
8878
|
-
createMintRequest(requestParameters, options) {
|
|
8879
|
-
return NftsApiFp(this.configuration).createMintRequest(requestParameters.contractAddress, requestParameters.chainName, requestParameters.createMintRequestRequest, options).then((request) => request(this.axios, this.basePath));
|
|
8880
|
-
}
|
|
8881
|
-
/**
|
|
8882
|
-
* Retrieve the status of a mint request identified by its reference_id
|
|
8883
|
-
* @summary Mint NFTs
|
|
8884
|
-
* @param {NftsApiGetMintRequestRequest} requestParameters Request parameters.
|
|
8885
|
-
* @param {*} [options] Override http request option.
|
|
8886
|
-
* @throws {RequiredError}
|
|
8887
|
-
* @memberof NftsApi
|
|
8888
|
-
*/
|
|
8889
|
-
getMintRequest(requestParameters, options) {
|
|
8890
|
-
return NftsApiFp(this.configuration).getMintRequest(requestParameters.contractAddress, requestParameters.chainName, requestParameters.referenceId, options).then((request) => request(this.axios, this.basePath));
|
|
8891
|
-
}
|
|
8892
8745
|
/**
|
|
8893
8746
|
* Get NFT by token ID
|
|
8894
8747
|
* @summary Get NFT by token ID
|
|
@@ -11445,7 +11298,7 @@ class MultiRollupApiClients {
|
|
|
11445
11298
|
}
|
|
11446
11299
|
|
|
11447
11300
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11448
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.7.3-alpha.
|
|
11301
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.7.3-alpha.2' };
|
|
11449
11302
|
const createConfig = ({ basePath, headers, }) => {
|
|
11450
11303
|
if (!basePath.trim()) {
|
|
11451
11304
|
throw Error('basePath can not be empty');
|
|
@@ -11517,7 +11370,7 @@ class APIError extends Error {
|
|
|
11517
11370
|
|
|
11518
11371
|
/* eslint-disable implicit-arrow-linebreak */
|
|
11519
11372
|
const defaultHeaders = {
|
|
11520
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.7.3-alpha.
|
|
11373
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.7.3-alpha.2',
|
|
11521
11374
|
};
|
|
11522
11375
|
/**
|
|
11523
11376
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11950,7 +11803,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11950
11803
|
chainID,
|
|
11951
11804
|
coreContractAddress,
|
|
11952
11805
|
registrationContractAddress,
|
|
11953
|
-
sdkVersion: 'ts-immutable-sdk-1.7.3-alpha.
|
|
11806
|
+
sdkVersion: 'ts-immutable-sdk-1.7.3-alpha.2',
|
|
11954
11807
|
});
|
|
11955
11808
|
/**
|
|
11956
11809
|
* Sets `sdkVersion` at the time of build
|
|
@@ -16597,7 +16450,6 @@ const getAuthConfiguration = (config) => {
|
|
|
16597
16450
|
end_session_endpoint: endSessionEndpoint,
|
|
16598
16451
|
},
|
|
16599
16452
|
mergeClaims: true,
|
|
16600
|
-
loadUserInfo: true,
|
|
16601
16453
|
scope: oidcConfiguration.scope,
|
|
16602
16454
|
userStore,
|
|
16603
16455
|
};
|
|
@@ -16638,7 +16490,10 @@ class AuthManager {
|
|
|
16638
16490
|
this.logoutMode = config.oidcConfiguration.logoutMode || 'redirect';
|
|
16639
16491
|
}
|
|
16640
16492
|
static mapOidcUserToDomainModel = (oidcUser) => {
|
|
16641
|
-
|
|
16493
|
+
let passport;
|
|
16494
|
+
if (oidcUser.id_token) {
|
|
16495
|
+
passport = jwt_decode(oidcUser.id_token)?.passport;
|
|
16496
|
+
}
|
|
16642
16497
|
const user = {
|
|
16643
16498
|
expired: oidcUser.expired,
|
|
16644
16499
|
idToken: oidcUser.id_token,
|
|
@@ -18063,9 +17918,7 @@ class JsonRpcError extends Error {
|
|
|
18063
17918
|
}
|
|
18064
17919
|
|
|
18065
17920
|
const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
|
|
18066
|
-
async function registerZkEvmUser({ authManager,
|
|
18067
|
-
const web3Provider = new providers.Web3Provider(magicProvider);
|
|
18068
|
-
const ethSigner = web3Provider.getSigner();
|
|
17921
|
+
async function registerZkEvmUser({ authManager, ethSigner, multiRollupApiClients, accessToken, jsonRpcProvider, }) {
|
|
18069
17922
|
const ethereumAddress = await ethSigner.getAddress();
|
|
18070
17923
|
const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
|
|
18071
17924
|
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
@@ -18095,32 +17948,6 @@ async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiCli
|
|
|
18095
17948
|
return user;
|
|
18096
17949
|
}
|
|
18097
17950
|
|
|
18098
|
-
const loginZkEvmUser = async ({ authManager, magicAdapter, multiRollupApiClients, jsonRpcProvider, }) => {
|
|
18099
|
-
const user = await authManager.getUserOrLogin();
|
|
18100
|
-
if (!user.idToken) {
|
|
18101
|
-
throw new Error('User is missing idToken');
|
|
18102
|
-
}
|
|
18103
|
-
const magicProvider = await magicAdapter.login(user.idToken);
|
|
18104
|
-
if (!user.zkEvm) {
|
|
18105
|
-
// Generate counterfactual address and retrieve updated Auth0 user
|
|
18106
|
-
const userZkevm = await registerZkEvmUser({
|
|
18107
|
-
authManager,
|
|
18108
|
-
magicProvider,
|
|
18109
|
-
multiRollupApiClients,
|
|
18110
|
-
accessToken: user.accessToken,
|
|
18111
|
-
jsonRpcProvider,
|
|
18112
|
-
});
|
|
18113
|
-
return {
|
|
18114
|
-
user: userZkevm,
|
|
18115
|
-
magicProvider,
|
|
18116
|
-
};
|
|
18117
|
-
}
|
|
18118
|
-
return {
|
|
18119
|
-
user: user,
|
|
18120
|
-
magicProvider,
|
|
18121
|
-
};
|
|
18122
|
-
};
|
|
18123
|
-
|
|
18124
17951
|
const transactionRejectedCrossSdkBridgeError = 'Transaction requires confirmation but this functionality is not'
|
|
18125
17952
|
+ ' supported in this environment. Please contact Immutable support if you need to enable this feature.';
|
|
18126
17953
|
const convertBigNumberishToString = (value) => ethers.BigNumber.from(value).toString();
|
|
@@ -18316,7 +18143,7 @@ const getMetaTransactions = async (metaTransaction, nonce, chainId, walletAddres
|
|
|
18316
18143
|
}
|
|
18317
18144
|
return [metaTransaction, feeMetaTransaction];
|
|
18318
18145
|
};
|
|
18319
|
-
const sendTransaction$1 = ({ params,
|
|
18146
|
+
const sendTransaction$1 = ({ params, ethSigner, jsonRpcProvider, relayerClient, guardianClient, zkevmAddress, }) => guardianClient
|
|
18320
18147
|
.withConfirmationScreen({ width: 480, height: 720 })(async () => {
|
|
18321
18148
|
const transactionRequest = params[0];
|
|
18322
18149
|
if (!transactionRequest.to) {
|
|
@@ -18324,8 +18151,6 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
|
|
|
18324
18151
|
}
|
|
18325
18152
|
const { chainId } = await jsonRpcProvider.ready;
|
|
18326
18153
|
const chainIdBigNumber = ethers.BigNumber.from(chainId);
|
|
18327
|
-
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
18328
|
-
const signer = magicWeb3Provider.getSigner();
|
|
18329
18154
|
const nonce = await getNonce(jsonRpcProvider, zkevmAddress);
|
|
18330
18155
|
const metaTransaction = {
|
|
18331
18156
|
to: transactionRequest.to,
|
|
@@ -18334,7 +18159,7 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
|
|
|
18334
18159
|
value: transactionRequest.value,
|
|
18335
18160
|
revertOnError: true,
|
|
18336
18161
|
};
|
|
18337
|
-
const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber, zkevmAddress,
|
|
18162
|
+
const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber, zkevmAddress, ethSigner, relayerClient);
|
|
18338
18163
|
await guardianClient.validateEVMTransaction({
|
|
18339
18164
|
chainId: getEip155ChainId(chainId),
|
|
18340
18165
|
nonce: convertBigNumberishToString(nonce),
|
|
@@ -18342,7 +18167,7 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
|
|
|
18342
18167
|
});
|
|
18343
18168
|
// NOTE: We sign again because we now are adding the fee transaction, so the
|
|
18344
18169
|
// whole payload is different and needs a new signature.
|
|
18345
|
-
const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, zkevmAddress,
|
|
18170
|
+
const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, zkevmAddress, ethSigner);
|
|
18346
18171
|
const relayerId = await relayerClient.ethSendTransaction(zkevmAddress, signedTransactions);
|
|
18347
18172
|
const retrieveRelayerTransaction = async () => {
|
|
18348
18173
|
const tx = await relayerClient.imGetTransactionByHash(relayerId);
|
|
@@ -18411,7 +18236,7 @@ const transformTypedData = (typedData, chainId) => {
|
|
|
18411
18236
|
}
|
|
18412
18237
|
return transformedTypedData;
|
|
18413
18238
|
};
|
|
18414
|
-
const signTypedDataV4 = async ({ params, method,
|
|
18239
|
+
const signTypedDataV4 = async ({ params, method, ethSigner, jsonRpcProvider, relayerClient, guardianClient, }) => guardianClient
|
|
18415
18240
|
.withConfirmationScreen({ width: 480, height: 720 })(async () => {
|
|
18416
18241
|
const fromAddress = params[0];
|
|
18417
18242
|
const typedDataParam = params[1];
|
|
@@ -18422,106 +18247,158 @@ const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider,
|
|
|
18422
18247
|
const typedData = transformTypedData(typedDataParam, chainId);
|
|
18423
18248
|
await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData });
|
|
18424
18249
|
const relayerSignature = await relayerClient.imSignTypedData(fromAddress, typedData);
|
|
18425
|
-
|
|
18426
|
-
const signer = magicWeb3Provider.getSigner();
|
|
18427
|
-
return getSignedTypedData(typedData, relayerSignature, ethers.BigNumber.from(chainId), fromAddress, signer);
|
|
18250
|
+
return getSignedTypedData(typedData, relayerSignature, ethers.BigNumber.from(chainId), fromAddress, ethSigner);
|
|
18428
18251
|
});
|
|
18429
18252
|
|
|
18253
|
+
const isZkEvmUser = (user) => 'zkEvm' in user;
|
|
18430
18254
|
class ZkEvmProvider {
|
|
18431
|
-
authManager;
|
|
18432
|
-
config;
|
|
18433
|
-
|
|
18434
|
-
|
|
18435
|
-
jsonRpcProvider; // Used for read
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
relayerClient;
|
|
18439
|
-
|
|
18440
|
-
|
|
18255
|
+
#authManager;
|
|
18256
|
+
#config;
|
|
18257
|
+
#eventEmitter;
|
|
18258
|
+
#guardianClient;
|
|
18259
|
+
#jsonRpcProvider; // Used for read
|
|
18260
|
+
#magicAdapter;
|
|
18261
|
+
#multiRollupApiClients;
|
|
18262
|
+
#relayerClient;
|
|
18263
|
+
/**
|
|
18264
|
+
* This property is set during `#initialiseEthSigner` and stores the signer in a promise.
|
|
18265
|
+
* This property is not meant to be accessed directly, but through the
|
|
18266
|
+
* `#getSigner` method.
|
|
18267
|
+
* @see getSigner
|
|
18268
|
+
*/
|
|
18269
|
+
#ethSigner;
|
|
18270
|
+
#signerInitialisationError;
|
|
18271
|
+
#zkEvmAddress;
|
|
18441
18272
|
isPassport = true;
|
|
18442
18273
|
constructor({ authManager, magicAdapter, config, multiRollupApiClients, passportEventEmitter, guardianClient, }) {
|
|
18443
|
-
this
|
|
18444
|
-
this
|
|
18445
|
-
this
|
|
18446
|
-
this
|
|
18274
|
+
this.#authManager = authManager;
|
|
18275
|
+
this.#magicAdapter = magicAdapter;
|
|
18276
|
+
this.#config = config;
|
|
18277
|
+
this.#guardianClient = guardianClient;
|
|
18447
18278
|
if (config.crossSdkBridgeEnabled) {
|
|
18448
18279
|
// JsonRpcProvider by default sets the referrer as "client".
|
|
18449
18280
|
// On Unreal 4 this errors as the browser used is expecting a valid URL.
|
|
18450
|
-
this
|
|
18451
|
-
url: this
|
|
18281
|
+
this.#jsonRpcProvider = new providers.JsonRpcProvider({
|
|
18282
|
+
url: this.#config.zkEvmRpcUrl,
|
|
18452
18283
|
fetchOptions: { referrer: 'http://imtblgamesdk.local' },
|
|
18453
18284
|
});
|
|
18454
18285
|
}
|
|
18455
18286
|
else {
|
|
18456
|
-
this
|
|
18287
|
+
this.#jsonRpcProvider = new providers.JsonRpcProvider(this.#config.zkEvmRpcUrl);
|
|
18457
18288
|
}
|
|
18458
|
-
this
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
this
|
|
18465
|
-
|
|
18289
|
+
this.#relayerClient = new RelayerClient({
|
|
18290
|
+
config: this.#config,
|
|
18291
|
+
jsonRpcProvider: this.#jsonRpcProvider,
|
|
18292
|
+
authManager: this.#authManager,
|
|
18293
|
+
});
|
|
18294
|
+
this.#multiRollupApiClients = multiRollupApiClients;
|
|
18295
|
+
this.#eventEmitter = new TypedEventEmitter();
|
|
18296
|
+
passportEventEmitter.on(PassportEvents.LOGGED_OUT, this.#handleLogout);
|
|
18297
|
+
}
|
|
18298
|
+
#handleLogout = () => {
|
|
18299
|
+
const shouldEmitAccountsChanged = !!this.#zkEvmAddress;
|
|
18300
|
+
this.#ethSigner = undefined;
|
|
18301
|
+
this.#zkEvmAddress = undefined;
|
|
18466
18302
|
if (shouldEmitAccountsChanged) {
|
|
18467
|
-
this
|
|
18303
|
+
this.#eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, []);
|
|
18468
18304
|
}
|
|
18469
18305
|
};
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
|
|
18473
|
-
|
|
18306
|
+
/**
|
|
18307
|
+
* This method is called by `eth_requestAccounts` and asynchronously initialises the signer.
|
|
18308
|
+
* The signer is stored in a promise so that it can be retrieved by the provider
|
|
18309
|
+
* when needed.
|
|
18310
|
+
*
|
|
18311
|
+
* If an error is thrown during initialisation, it is stored in the `signerInitialisationError`,
|
|
18312
|
+
* so that it doesn't result in an unhandled promise rejection.
|
|
18313
|
+
*
|
|
18314
|
+
* This error is thrown when the signer is requested through:
|
|
18315
|
+
* @see #getSigner
|
|
18316
|
+
*
|
|
18317
|
+
*/
|
|
18318
|
+
async #initialiseEthSigner(user) {
|
|
18319
|
+
const generateSigner = async () => {
|
|
18320
|
+
const magicRpcProvider = await this.#magicAdapter.login(user.idToken);
|
|
18321
|
+
const web3Provider = new providers.Web3Provider(magicRpcProvider);
|
|
18322
|
+
return web3Provider.getSigner();
|
|
18323
|
+
};
|
|
18324
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
18325
|
+
this.#ethSigner = new Promise(async (resolve) => {
|
|
18326
|
+
try {
|
|
18327
|
+
resolve(await generateSigner());
|
|
18328
|
+
}
|
|
18329
|
+
catch (err) {
|
|
18330
|
+
// Capture and store the initialization error
|
|
18331
|
+
this.#signerInitialisationError = err;
|
|
18332
|
+
resolve(undefined);
|
|
18333
|
+
}
|
|
18334
|
+
});
|
|
18335
|
+
}
|
|
18336
|
+
async #getSigner() {
|
|
18337
|
+
const ethSigner = await this.#ethSigner;
|
|
18338
|
+
// Throw the stored error if the signers failed to initialise
|
|
18339
|
+
if (typeof ethSigner === 'undefined') {
|
|
18340
|
+
if (typeof this.#signerInitialisationError !== 'undefined') {
|
|
18341
|
+
throw this.#signerInitialisationError;
|
|
18342
|
+
}
|
|
18343
|
+
throw new Error('Signer failed to initialise');
|
|
18344
|
+
}
|
|
18345
|
+
return ethSigner;
|
|
18474
18346
|
}
|
|
18475
|
-
async performRequest(request) {
|
|
18347
|
+
async #performRequest(request) {
|
|
18476
18348
|
switch (request.method) {
|
|
18477
18349
|
case 'eth_requestAccounts': {
|
|
18478
|
-
if (this
|
|
18479
|
-
return [this
|
|
18350
|
+
if (this.#zkEvmAddress) {
|
|
18351
|
+
return [this.#zkEvmAddress];
|
|
18480
18352
|
}
|
|
18481
|
-
const
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18495
|
-
|
|
18353
|
+
const user = await this.#authManager.getUserOrLogin();
|
|
18354
|
+
this.#initialiseEthSigner(user);
|
|
18355
|
+
if (!isZkEvmUser(user)) {
|
|
18356
|
+
const ethSigner = await this.#getSigner();
|
|
18357
|
+
const userZkEvm = await registerZkEvmUser({
|
|
18358
|
+
ethSigner,
|
|
18359
|
+
authManager: this.#authManager,
|
|
18360
|
+
multiRollupApiClients: this.#multiRollupApiClients,
|
|
18361
|
+
accessToken: user.accessToken,
|
|
18362
|
+
jsonRpcProvider: this.#jsonRpcProvider,
|
|
18363
|
+
});
|
|
18364
|
+
this.#zkEvmAddress = userZkEvm.zkEvm.ethAddress;
|
|
18365
|
+
}
|
|
18366
|
+
else {
|
|
18367
|
+
this.#zkEvmAddress = user.zkEvm.ethAddress;
|
|
18368
|
+
}
|
|
18369
|
+
this.#eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [this.#zkEvmAddress]);
|
|
18370
|
+
return [this.#zkEvmAddress];
|
|
18496
18371
|
}
|
|
18497
18372
|
case 'eth_sendTransaction': {
|
|
18498
|
-
if (!this
|
|
18373
|
+
if (!this.#zkEvmAddress) {
|
|
18499
18374
|
throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
|
|
18500
18375
|
}
|
|
18376
|
+
const ethSigner = await this.#getSigner();
|
|
18501
18377
|
return sendTransaction$1({
|
|
18502
18378
|
params: request.params || [],
|
|
18503
|
-
|
|
18504
|
-
guardianClient: this
|
|
18505
|
-
jsonRpcProvider: this
|
|
18506
|
-
relayerClient: this
|
|
18507
|
-
zkevmAddress: this
|
|
18379
|
+
ethSigner,
|
|
18380
|
+
guardianClient: this.#guardianClient,
|
|
18381
|
+
jsonRpcProvider: this.#jsonRpcProvider,
|
|
18382
|
+
relayerClient: this.#relayerClient,
|
|
18383
|
+
zkevmAddress: this.#zkEvmAddress,
|
|
18508
18384
|
});
|
|
18509
18385
|
}
|
|
18510
18386
|
case 'eth_accounts': {
|
|
18511
|
-
return this
|
|
18387
|
+
return this.#zkEvmAddress ? [this.#zkEvmAddress] : [];
|
|
18512
18388
|
}
|
|
18513
18389
|
case 'eth_signTypedData':
|
|
18514
18390
|
case 'eth_signTypedData_v4': {
|
|
18515
|
-
if (!this
|
|
18391
|
+
if (!this.#zkEvmAddress) {
|
|
18516
18392
|
throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
|
|
18517
18393
|
}
|
|
18394
|
+
const ethSigner = await this.#getSigner();
|
|
18518
18395
|
return signTypedDataV4({
|
|
18519
18396
|
method: request.method,
|
|
18520
18397
|
params: request.params || [],
|
|
18521
|
-
|
|
18522
|
-
jsonRpcProvider: this
|
|
18523
|
-
relayerClient: this
|
|
18524
|
-
guardianClient: this
|
|
18398
|
+
ethSigner,
|
|
18399
|
+
jsonRpcProvider: this.#jsonRpcProvider,
|
|
18400
|
+
relayerClient: this.#relayerClient,
|
|
18401
|
+
guardianClient: this.#guardianClient,
|
|
18525
18402
|
});
|
|
18526
18403
|
}
|
|
18527
18404
|
// Pass through methods
|
|
@@ -18538,17 +18415,17 @@ class ZkEvmProvider {
|
|
|
18538
18415
|
case 'eth_getTransactionByHash':
|
|
18539
18416
|
case 'eth_getTransactionReceipt':
|
|
18540
18417
|
case 'eth_getTransactionCount': {
|
|
18541
|
-
return this
|
|
18418
|
+
return this.#jsonRpcProvider.send(request.method, request.params || []);
|
|
18542
18419
|
}
|
|
18543
18420
|
default: {
|
|
18544
18421
|
throw new JsonRpcError(ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
|
|
18545
18422
|
}
|
|
18546
18423
|
}
|
|
18547
18424
|
}
|
|
18548
|
-
async performJsonRpcRequest(request) {
|
|
18425
|
+
async #performJsonRpcRequest(request) {
|
|
18549
18426
|
const { id, jsonrpc } = request;
|
|
18550
18427
|
try {
|
|
18551
|
-
const result = await this
|
|
18428
|
+
const result = await this.#performRequest(request);
|
|
18552
18429
|
return {
|
|
18553
18430
|
id,
|
|
18554
18431
|
jsonrpc,
|
|
@@ -18575,7 +18452,7 @@ class ZkEvmProvider {
|
|
|
18575
18452
|
}
|
|
18576
18453
|
async request(request) {
|
|
18577
18454
|
try {
|
|
18578
|
-
return this
|
|
18455
|
+
return this.#performRequest(request);
|
|
18579
18456
|
}
|
|
18580
18457
|
catch (error) {
|
|
18581
18458
|
if (error instanceof JsonRpcError) {
|
|
@@ -18592,14 +18469,14 @@ class ZkEvmProvider {
|
|
|
18592
18469
|
throw new Error('No callback provided');
|
|
18593
18470
|
}
|
|
18594
18471
|
if (Array.isArray(request)) {
|
|
18595
|
-
Promise.all(request.map(this
|
|
18472
|
+
Promise.all(request.map(this.#performJsonRpcRequest)).then((result) => {
|
|
18596
18473
|
callback(null, result);
|
|
18597
18474
|
}).catch((error) => {
|
|
18598
18475
|
callback(error, []);
|
|
18599
18476
|
});
|
|
18600
18477
|
}
|
|
18601
18478
|
else {
|
|
18602
|
-
this
|
|
18479
|
+
this.#performJsonRpcRequest(request).then((result) => {
|
|
18603
18480
|
callback(null, result);
|
|
18604
18481
|
}).catch((error) => {
|
|
18605
18482
|
callback(error, null);
|
|
@@ -18631,15 +18508,15 @@ class ZkEvmProvider {
|
|
|
18631
18508
|
return this.sendAsync(request, callbackOrParams);
|
|
18632
18509
|
}
|
|
18633
18510
|
if (!Array.isArray(request) && typeof request === 'object') {
|
|
18634
|
-
return this
|
|
18511
|
+
return this.#performJsonRpcRequest(request);
|
|
18635
18512
|
}
|
|
18636
18513
|
throw new JsonRpcError(RpcErrorCode.INVALID_REQUEST, 'Invalid request');
|
|
18637
18514
|
}
|
|
18638
18515
|
on(event, listener) {
|
|
18639
|
-
this
|
|
18516
|
+
this.#eventEmitter.on(event, listener);
|
|
18640
18517
|
}
|
|
18641
18518
|
removeListener(event, listener) {
|
|
18642
|
-
this
|
|
18519
|
+
this.#eventEmitter.removeListener(event, listener);
|
|
18643
18520
|
}
|
|
18644
18521
|
}
|
|
18645
18522
|
|
|
@@ -37601,7 +37478,7 @@ const flattenProperties = (properties) => {
|
|
|
37601
37478
|
};
|
|
37602
37479
|
|
|
37603
37480
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
37604
|
-
const SDK_VERSION = '1.7.3-alpha.
|
|
37481
|
+
const SDK_VERSION = '1.7.3-alpha.2';
|
|
37605
37482
|
const getReferrer = () => {
|
|
37606
37483
|
if (isNode()) {
|
|
37607
37484
|
return '';
|
|
@@ -42769,7 +42646,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
42769
42646
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
42770
42647
|
};
|
|
42771
42648
|
|
|
42772
|
-
const SDK_VERSION_MARKER = '1.7.3-alpha.
|
|
42649
|
+
const SDK_VERSION_MARKER = '1.7.3-alpha.2';
|
|
42773
42650
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
42774
42651
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
42775
42652
|
|
|
@@ -46389,27 +46266,25 @@ function validateAndBuildVersion(version) {
|
|
|
46389
46266
|
return validatedVersion;
|
|
46390
46267
|
}
|
|
46391
46268
|
|
|
46392
|
-
|
|
46269
|
+
// Loads the checkout widgets bundle from the CDN and appends the script to the document head
|
|
46270
|
+
function loadUnresolvedBundle(tag, scriptId, validVersion) {
|
|
46393
46271
|
if (window === undefined) {
|
|
46394
46272
|
throw new Error('missing window object: please run Checkout client side');
|
|
46395
46273
|
}
|
|
46396
46274
|
if (document === undefined) {
|
|
46397
46275
|
throw new Error('missing document object: please run Checkout client side');
|
|
46398
46276
|
}
|
|
46399
|
-
const scriptId = 'immutable-checkout-widgets-bundle';
|
|
46400
|
-
const validVersion = validateAndBuildVersion(version);
|
|
46401
|
-
// Prevent the script to be loaded more than once
|
|
46402
|
-
// by checking the presence of the script and its version.
|
|
46403
|
-
const initScript = document.getElementById(scriptId);
|
|
46404
|
-
if (initScript)
|
|
46405
|
-
return { loaded: true, element: initScript };
|
|
46406
|
-
const tag = document.createElement('script');
|
|
46407
46277
|
let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets.js`;
|
|
46408
46278
|
tag.setAttribute('id', scriptId);
|
|
46409
46279
|
tag.setAttribute('data-version', validVersion);
|
|
46410
46280
|
tag.setAttribute('src', cdnUrl);
|
|
46411
46281
|
document.head.appendChild(tag);
|
|
46412
|
-
|
|
46282
|
+
}
|
|
46283
|
+
// Gets the CDN url for the split checkout widgets bundle
|
|
46284
|
+
function getWidgetsEsmUrl(version) {
|
|
46285
|
+
const validVersion = validateAndBuildVersion(version);
|
|
46286
|
+
let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets-esm.js`;
|
|
46287
|
+
return cdnUrl;
|
|
46413
46288
|
}
|
|
46414
46289
|
|
|
46415
46290
|
const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
|
|
@@ -46488,7 +46363,6 @@ const SANDBOX_CONFIGURATION = {
|
|
|
46488
46363
|
},
|
|
46489
46364
|
passport: undefined,
|
|
46490
46365
|
};
|
|
46491
|
-
const WIDGETS_SCRIPT_TIMEOUT = 100;
|
|
46492
46366
|
// Checkout SDK
|
|
46493
46367
|
class Checkout {
|
|
46494
46368
|
readOnlyProviders;
|
|
@@ -46518,26 +46392,44 @@ class Checkout {
|
|
|
46518
46392
|
const checkout = this;
|
|
46519
46393
|
// Preload the configurations
|
|
46520
46394
|
await checkout.config.remote.getConfig();
|
|
46395
|
+
try {
|
|
46396
|
+
const factory = await this.loadEsModules(init.config, init.version);
|
|
46397
|
+
return factory;
|
|
46398
|
+
}
|
|
46399
|
+
catch (err) {
|
|
46400
|
+
throw new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err });
|
|
46401
|
+
}
|
|
46402
|
+
}
|
|
46403
|
+
async loadUmdBundle(config, version) {
|
|
46404
|
+
const checkout = this;
|
|
46521
46405
|
const factory = new Promise((resolve, reject) => {
|
|
46522
|
-
function checkForWidgetsBundleLoaded() {
|
|
46523
|
-
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
46524
|
-
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
|
|
46525
|
-
}
|
|
46526
|
-
else {
|
|
46527
|
-
// If ImmutableCheckoutWidgets is not defined, wait for set amount of time.
|
|
46528
|
-
// When time has elapsed, check again if ImmutableCheckoutWidgets is defined.
|
|
46529
|
-
// Once it's defined, the promise will resolve and setTimeout won't be called again.
|
|
46530
|
-
setTimeout(checkForWidgetsBundleLoaded, WIDGETS_SCRIPT_TIMEOUT);
|
|
46531
|
-
}
|
|
46532
|
-
}
|
|
46533
46406
|
try {
|
|
46534
|
-
const
|
|
46535
|
-
|
|
46536
|
-
|
|
46537
|
-
|
|
46538
|
-
|
|
46539
|
-
|
|
46407
|
+
const scriptId = 'immutable-checkout-widgets-bundle';
|
|
46408
|
+
const validVersion = validateAndBuildVersion(version);
|
|
46409
|
+
// Prevent the script to be loaded more than once
|
|
46410
|
+
// by checking the presence of the script and its version.
|
|
46411
|
+
const initScript = document.getElementById(scriptId);
|
|
46412
|
+
if (initScript) {
|
|
46413
|
+
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
46414
|
+
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, config));
|
|
46415
|
+
}
|
|
46416
|
+
else {
|
|
46417
|
+
reject(new CheckoutError('Failed to find ImmutableCheckoutWidgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR));
|
|
46418
|
+
}
|
|
46540
46419
|
}
|
|
46420
|
+
const tag = document.createElement('script');
|
|
46421
|
+
tag.addEventListener('load', () => {
|
|
46422
|
+
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
46423
|
+
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, config));
|
|
46424
|
+
}
|
|
46425
|
+
else {
|
|
46426
|
+
reject(new CheckoutError('Failed to find ImmutableCheckoutWidgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR));
|
|
46427
|
+
}
|
|
46428
|
+
});
|
|
46429
|
+
tag.addEventListener('error', (err) => {
|
|
46430
|
+
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
46431
|
+
});
|
|
46432
|
+
loadUnresolvedBundle(tag, scriptId, validVersion);
|
|
46541
46433
|
}
|
|
46542
46434
|
catch (err) {
|
|
46543
46435
|
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
@@ -46545,6 +46437,24 @@ class Checkout {
|
|
|
46545
46437
|
});
|
|
46546
46438
|
return factory;
|
|
46547
46439
|
}
|
|
46440
|
+
async loadEsModules(config, version) {
|
|
46441
|
+
const checkout = this;
|
|
46442
|
+
try {
|
|
46443
|
+
const cdnUrl = getWidgetsEsmUrl(version);
|
|
46444
|
+
// WebpackIgnore comment required to prevent webpack modifying the import statement and
|
|
46445
|
+
// breaking the dynamic import in certain applications integrating checkout
|
|
46446
|
+
const checkoutWidgetsModule = await import(/* webpackIgnore: true */ cdnUrl);
|
|
46447
|
+
if (checkoutWidgetsModule && checkoutWidgetsModule.WidgetsFactory) {
|
|
46448
|
+
return new checkoutWidgetsModule.WidgetsFactory(checkout, config);
|
|
46449
|
+
}
|
|
46450
|
+
}
|
|
46451
|
+
catch (err) {
|
|
46452
|
+
// eslint-disable-next-line no-console
|
|
46453
|
+
console.warn(`Failed to resolve checkout widgets module, falling back to UMD bundle. Error: ${err.message}`);
|
|
46454
|
+
}
|
|
46455
|
+
// Fallback to UMD bundle if esm bundle fails to load
|
|
46456
|
+
return await checkout.loadUmdBundle(config, version);
|
|
46457
|
+
}
|
|
46548
46458
|
/**
|
|
46549
46459
|
* Creates a provider using the given parameters.
|
|
46550
46460
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|