@imtbl/sdk 0.44.2 → 0.44.4
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/README.md +1 -144
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +3 -3
- package/dist/browser/checkout/widgets.js +4 -4
- package/dist/checkout.d.ts +12553 -2151
- package/dist/checkout.js +94 -59
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +98 -62
- package/dist/index.d.ts +10410 -2
- package/dist/index.js +98 -62
- package/dist/passport.d.ts +11314 -552
- package/dist/passport.js +4 -3
- package/package.json +1 -1
package/dist/checkout.js
CHANGED
|
@@ -15746,6 +15746,7 @@ var BridgeMethodsGasLimit;
|
|
|
15746
15746
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
|
|
15747
15747
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
|
|
15748
15748
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
15749
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["APPROVE_TOKEN"] = 55000] = "APPROVE_TOKEN";
|
|
15749
15750
|
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
15750
15751
|
var StatusResponse;
|
|
15751
15752
|
(function (StatusResponse) {
|
|
@@ -15933,8 +15934,12 @@ class TokenBridge {
|
|
|
15933
15934
|
throw new BridgeError(`Finalised withdrawals must be on the root chain (${this.config.bridgeInstance.rootChainID})`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
15934
15935
|
}
|
|
15935
15936
|
let sourceChainGas = BigNumber.from(0);
|
|
15937
|
+
let approvalFee = BigNumber.from(0);
|
|
15936
15938
|
let bridgeFee = BigNumber.from(0);
|
|
15937
15939
|
const imtblFee = BigNumber.from(0);
|
|
15940
|
+
if ('token' in req && req.token !== 'NATIVE') {
|
|
15941
|
+
approvalFee = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.APPROVE_TOKEN);
|
|
15942
|
+
}
|
|
15938
15943
|
if (req.action === BridgeFeeActions.FINALISE_WITHDRAWAL) {
|
|
15939
15944
|
sourceChainGas = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.FINALISE_WITHDRAWAL);
|
|
15940
15945
|
}
|
|
@@ -15945,9 +15950,10 @@ class TokenBridge {
|
|
|
15945
15950
|
const feeResult = await this.calculateBridgeFee(req.sourceChainId, req.destinationChainId, BridgeMethodsGasLimit[`${req.action}_DESTINATION`], req.gasMultiplier);
|
|
15946
15951
|
bridgeFee = feeResult.bridgeFee;
|
|
15947
15952
|
}
|
|
15948
|
-
const totalFees = sourceChainGas.add(bridgeFee).add(imtblFee);
|
|
15953
|
+
const totalFees = sourceChainGas.add(approvalFee).add(bridgeFee).add(imtblFee);
|
|
15949
15954
|
return {
|
|
15950
15955
|
sourceChainGas,
|
|
15956
|
+
approvalFee,
|
|
15951
15957
|
bridgeFee,
|
|
15952
15958
|
imtblFee,
|
|
15953
15959
|
totalFees,
|
|
@@ -16177,6 +16183,8 @@ class TokenBridge {
|
|
|
16177
16183
|
gasMultiplier,
|
|
16178
16184
|
sourceChainId,
|
|
16179
16185
|
destinationChainId,
|
|
16186
|
+
token,
|
|
16187
|
+
amount,
|
|
16180
16188
|
});
|
|
16181
16189
|
const canReceive = await this.checkReceiver(provider, recipient);
|
|
16182
16190
|
if (!canReceive) {
|
|
@@ -25953,7 +25961,7 @@ class APIError extends Error {
|
|
|
25953
25961
|
|
|
25954
25962
|
/* eslint-disable implicit-arrow-linebreak */
|
|
25955
25963
|
const defaultHeaders = {
|
|
25956
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.
|
|
25964
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.4',
|
|
25957
25965
|
};
|
|
25958
25966
|
/**
|
|
25959
25967
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -26950,7 +26958,7 @@ async function switchWalletNetwork(config, web3Provider, chainId) {
|
|
|
26950
26958
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
26951
26959
|
}
|
|
26952
26960
|
catch (err) {
|
|
26953
|
-
throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
|
|
26961
|
+
throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
|
|
26954
26962
|
}
|
|
26955
26963
|
}
|
|
26956
26964
|
else {
|
|
@@ -27314,7 +27322,7 @@ const GAS_OVERRIDES = {
|
|
|
27314
27322
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
27315
27323
|
};
|
|
27316
27324
|
|
|
27317
|
-
const SDK_VERSION_MARKER = '0.44.
|
|
27325
|
+
const SDK_VERSION_MARKER = '0.44.4';
|
|
27318
27326
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27319
27327
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27320
27328
|
|
|
@@ -27344,8 +27352,8 @@ class RemoteConfigFetcher {
|
|
|
27344
27352
|
try {
|
|
27345
27353
|
responseData = JSON.parse(response.data);
|
|
27346
27354
|
}
|
|
27347
|
-
catch (
|
|
27348
|
-
throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
|
|
27355
|
+
catch (err) {
|
|
27356
|
+
throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR, { error: err });
|
|
27349
27357
|
}
|
|
27350
27358
|
}
|
|
27351
27359
|
return responseData;
|
|
@@ -27358,7 +27366,7 @@ class RemoteConfigFetcher {
|
|
|
27358
27366
|
response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
|
|
27359
27367
|
}
|
|
27360
27368
|
catch (err) {
|
|
27361
|
-
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
|
|
27369
|
+
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
27362
27370
|
}
|
|
27363
27371
|
// Ensure that the configuration is valid
|
|
27364
27372
|
this.configCache = this.parseResponse(response);
|
|
@@ -27372,7 +27380,7 @@ class RemoteConfigFetcher {
|
|
|
27372
27380
|
response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
|
|
27373
27381
|
}
|
|
27374
27382
|
catch (err) {
|
|
27375
|
-
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
|
|
27383
|
+
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
27376
27384
|
}
|
|
27377
27385
|
// Ensure that the configuration is valid
|
|
27378
27386
|
this.tokensCache = this.parseResponse(response);
|
|
@@ -27735,7 +27743,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
27735
27743
|
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
27736
27744
|
// or simply an incorrect wallet address was provided.
|
|
27737
27745
|
if (err?.code !== HttpStatusCode$2.NotFound) {
|
|
27738
|
-
throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
|
|
27746
|
+
throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
|
|
27739
27747
|
}
|
|
27740
27748
|
}
|
|
27741
27749
|
};
|
|
@@ -27754,7 +27762,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
27754
27762
|
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
27755
27763
|
// or simply an incorrect wallet address was provided.
|
|
27756
27764
|
if (err?.code !== HttpStatusCode$2.NotFound) {
|
|
27757
|
-
throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
|
|
27765
|
+
throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
|
|
27758
27766
|
}
|
|
27759
27767
|
}
|
|
27760
27768
|
};
|
|
@@ -27867,6 +27875,7 @@ async function checkIsWalletConnected(web3Provider) {
|
|
|
27867
27875
|
}
|
|
27868
27876
|
catch (err) {
|
|
27869
27877
|
throw new CheckoutError('Check wallet connection request failed', CheckoutErrorType.PROVIDER_REQUEST_FAILED_ERROR, {
|
|
27878
|
+
error: err,
|
|
27870
27879
|
rpcMethod: WalletAction.CHECK_CONNECTION,
|
|
27871
27880
|
});
|
|
27872
27881
|
}
|
|
@@ -27959,7 +27968,7 @@ async function validateProvider(config, web3Provider, validateProviderOptions) {
|
|
|
27959
27968
|
}
|
|
27960
27969
|
}
|
|
27961
27970
|
catch (err) {
|
|
27962
|
-
throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
|
|
27971
|
+
throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR, { error: err });
|
|
27963
27972
|
}
|
|
27964
27973
|
if (web3ChainId !== underlyingChainId && !options.allowMistmatchedChainId) {
|
|
27965
27974
|
throw new CheckoutError('Your wallet has changed network, please switch to a supported network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
|
|
@@ -28011,15 +28020,15 @@ const sendTransaction = async (web3Provider, transaction) => {
|
|
|
28011
28020
|
}
|
|
28012
28021
|
catch (err) {
|
|
28013
28022
|
if (err.code === ethers.errors.INSUFFICIENT_FUNDS) {
|
|
28014
|
-
throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS);
|
|
28023
|
+
throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS, { error: err });
|
|
28015
28024
|
}
|
|
28016
28025
|
if (err.code === ethers.errors.ACTION_REJECTED) {
|
|
28017
|
-
throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
|
|
28026
|
+
throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
|
|
28018
28027
|
}
|
|
28019
28028
|
if (err.code === ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
|
|
28020
|
-
throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
|
|
28029
|
+
throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
|
|
28021
28030
|
}
|
|
28022
|
-
throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED);
|
|
28031
|
+
throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED, { error: err });
|
|
28023
28032
|
}
|
|
28024
28033
|
};
|
|
28025
28034
|
|
|
@@ -28032,6 +28041,8 @@ async function getBridgeFeeEstimate$1(tokenBridge, fromChainId, toChainId, confi
|
|
|
28032
28041
|
gasMultiplier: 1.1,
|
|
28033
28042
|
sourceChainId: fromChainId.toString(),
|
|
28034
28043
|
destinationChainId: toChainId.toString(),
|
|
28044
|
+
token: NATIVE.toUpperCase(),
|
|
28045
|
+
amount: BigNumber$1.from(0),
|
|
28035
28046
|
});
|
|
28036
28047
|
}
|
|
28037
28048
|
|
|
@@ -28111,6 +28122,7 @@ async function bridgeToL2GasEstimator(readOnlyProviders, config) {
|
|
|
28111
28122
|
gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
|
|
28112
28123
|
fees: {
|
|
28113
28124
|
sourceChainGas: BigNumber$1.from(0),
|
|
28125
|
+
approvalFee: BigNumber$1.from(0),
|
|
28114
28126
|
bridgeFee: BigNumber$1.from(0),
|
|
28115
28127
|
imtblFee: BigNumber$1.from(0),
|
|
28116
28128
|
totalFees: BigNumber$1.from(0),
|
|
@@ -28260,7 +28272,7 @@ const getERC20Allowance = async (provider, ownerAddress, contractAddress, spende
|
|
|
28260
28272
|
return await contract.allowance(ownerAddress, spenderAddress);
|
|
28261
28273
|
}
|
|
28262
28274
|
catch (err) {
|
|
28263
|
-
throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
|
|
28275
|
+
throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
|
|
28264
28276
|
}
|
|
28265
28277
|
};
|
|
28266
28278
|
// Returns the approval transaction for the ERC20 that the owner can sign
|
|
@@ -28273,8 +28285,8 @@ const getERC20ApprovalTransaction = async (provider, ownerAddress, contractAddre
|
|
|
28273
28285
|
approveTransaction.from = ownerAddress;
|
|
28274
28286
|
return approveTransaction;
|
|
28275
28287
|
}
|
|
28276
|
-
catch {
|
|
28277
|
-
throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
|
|
28288
|
+
catch (err) {
|
|
28289
|
+
throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
|
|
28278
28290
|
}
|
|
28279
28291
|
};
|
|
28280
28292
|
const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
@@ -28346,7 +28358,12 @@ const getERC721ApprovedForAll = async (provider, ownerAddress, contractAddress,
|
|
|
28346
28358
|
return await contract.isApprovedForAll(ownerAddress, spenderAddress);
|
|
28347
28359
|
}
|
|
28348
28360
|
catch (err) {
|
|
28349
|
-
throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
28361
|
+
throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
28362
|
+
ownerAddress,
|
|
28363
|
+
contractAddress,
|
|
28364
|
+
spenderAddress,
|
|
28365
|
+
error: err,
|
|
28366
|
+
});
|
|
28350
28367
|
}
|
|
28351
28368
|
};
|
|
28352
28369
|
// Returns a populated transaction to approve the ERC721 for the spender.
|
|
@@ -28360,7 +28377,11 @@ const getApproveTransaction = async (provider, ownerAddress, contractAddress, sp
|
|
|
28360
28377
|
}
|
|
28361
28378
|
catch (err) {
|
|
28362
28379
|
throw new CheckoutError('Failed to get the approval transaction for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
28363
|
-
id: id.toString(),
|
|
28380
|
+
id: id.toString(),
|
|
28381
|
+
contractAddress,
|
|
28382
|
+
spenderAddress,
|
|
28383
|
+
ownerAddress,
|
|
28384
|
+
error: err,
|
|
28364
28385
|
});
|
|
28365
28386
|
}
|
|
28366
28387
|
};
|
|
@@ -28372,7 +28393,11 @@ const getERC721ApprovedAddress = async (provider, contractAddress, id) => {
|
|
|
28372
28393
|
return await contract.getApproved(id);
|
|
28373
28394
|
}
|
|
28374
28395
|
catch (err) {
|
|
28375
|
-
throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
28396
|
+
throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
28397
|
+
id: id.toString(),
|
|
28398
|
+
contractAddress,
|
|
28399
|
+
error: err,
|
|
28400
|
+
});
|
|
28376
28401
|
}
|
|
28377
28402
|
};
|
|
28378
28403
|
const convertIdToNumber = (id, contractAddress) => {
|
|
@@ -28700,8 +28725,8 @@ const getTokenBalances = async (config, provider, ownerAddress, itemRequirements
|
|
|
28700
28725
|
const { balances } = await getAllBalances(config, provider, ownerAddress, getL2ChainId(config));
|
|
28701
28726
|
return balances.filter((balance) => tokenMap.get((balance.token.address || NATIVE).toLocaleLowerCase()));
|
|
28702
28727
|
}
|
|
28703
|
-
catch (
|
|
28704
|
-
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR);
|
|
28728
|
+
catch (err) {
|
|
28729
|
+
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR, { error: err });
|
|
28705
28730
|
}
|
|
28706
28731
|
};
|
|
28707
28732
|
/**
|
|
@@ -28739,8 +28764,8 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
28739
28764
|
});
|
|
28740
28765
|
});
|
|
28741
28766
|
}
|
|
28742
|
-
catch (
|
|
28743
|
-
throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR);
|
|
28767
|
+
catch (err) {
|
|
28768
|
+
throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR, { error: err });
|
|
28744
28769
|
}
|
|
28745
28770
|
return erc721Balances;
|
|
28746
28771
|
};
|
|
@@ -28810,7 +28835,7 @@ const estimateGas = async (provider, transaction) => {
|
|
|
28810
28835
|
return await provider.estimateGas(transaction);
|
|
28811
28836
|
}
|
|
28812
28837
|
catch (err) {
|
|
28813
|
-
throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
|
|
28838
|
+
throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
|
|
28814
28839
|
}
|
|
28815
28840
|
};
|
|
28816
28841
|
const getGasItemRequirement = (gas, transactionOrGas) => {
|
|
@@ -28874,14 +28899,14 @@ const availabilityService = (isDevelopment, isProduction) => {
|
|
|
28874
28899
|
try {
|
|
28875
28900
|
response = await globalAxios.post(`${postEndpoint()}/v1/availability/checkout/swap`);
|
|
28876
28901
|
}
|
|
28877
|
-
catch (
|
|
28902
|
+
catch (err) {
|
|
28878
28903
|
// The request was made and the server responded with a status code
|
|
28879
28904
|
// that falls out of the range of 2xx
|
|
28880
|
-
response =
|
|
28905
|
+
response = err.response;
|
|
28881
28906
|
// If 403 then the service is geo-blocked
|
|
28882
28907
|
if (response.status === 403)
|
|
28883
28908
|
return false;
|
|
28884
|
-
throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR);
|
|
28909
|
+
throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
28885
28910
|
}
|
|
28886
28911
|
return true;
|
|
28887
28912
|
};
|
|
@@ -29392,7 +29417,7 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
|
|
|
29392
29417
|
};
|
|
29393
29418
|
}
|
|
29394
29419
|
catch (err) {
|
|
29395
|
-
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
29420
|
+
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { error: err });
|
|
29396
29421
|
}
|
|
29397
29422
|
};
|
|
29398
29423
|
|
|
@@ -30042,7 +30067,7 @@ const routingCalculator = async (config, ownerAddress, balanceRequirements, avai
|
|
|
30042
30067
|
readOnlyProviders = await createReadOnlyProviders(config);
|
|
30043
30068
|
}
|
|
30044
30069
|
catch (err) {
|
|
30045
|
-
throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, {
|
|
30070
|
+
throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, { error: err });
|
|
30046
30071
|
}
|
|
30047
30072
|
const tokenBalances = await measureAsyncExecution(config, 'Time to get token balances inside router', getAllTokenBalances(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
|
|
30048
30073
|
const allowList = await measureAsyncExecution(config, 'Time to get routing allowlist', allowListCheck(config, tokenBalances, availableRoutingOptions));
|
|
@@ -30165,9 +30190,7 @@ const signApprovalTransactions = async (provider, approvalTransactions) => {
|
|
|
30165
30190
|
receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
|
|
30166
30191
|
}
|
|
30167
30192
|
catch (err) {
|
|
30168
|
-
throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, {
|
|
30169
|
-
message: err.message,
|
|
30170
|
-
});
|
|
30193
|
+
throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, { error: err });
|
|
30171
30194
|
}
|
|
30172
30195
|
for (const receipt of receipts) {
|
|
30173
30196
|
if (receipt.status === 0) {
|
|
@@ -30189,9 +30212,7 @@ const signFulfillmentTransactions = async (provider, fulfillmentTransactions) =>
|
|
|
30189
30212
|
receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
|
|
30190
30213
|
}
|
|
30191
30214
|
catch (err) {
|
|
30192
|
-
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
|
|
30193
|
-
message: err.message,
|
|
30194
|
-
});
|
|
30215
|
+
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, { error: err });
|
|
30195
30216
|
}
|
|
30196
30217
|
for (const receipt of receipts) {
|
|
30197
30218
|
if (receipt.status === 0) {
|
|
@@ -30217,9 +30238,7 @@ const signMessage = async (provider, unsignedMessage) => {
|
|
|
30217
30238
|
};
|
|
30218
30239
|
}
|
|
30219
30240
|
catch (err) {
|
|
30220
|
-
throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, {
|
|
30221
|
-
message: err.message,
|
|
30222
|
-
});
|
|
30241
|
+
throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, { error: err });
|
|
30223
30242
|
}
|
|
30224
30243
|
};
|
|
30225
30244
|
|
|
@@ -30402,8 +30421,8 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
30402
30421
|
}
|
|
30403
30422
|
catch (err) {
|
|
30404
30423
|
throw new CheckoutError('An error occurred while getting the order listing', CheckoutErrorType.GET_ORDER_LISTING_ERROR, {
|
|
30424
|
+
error: err,
|
|
30405
30425
|
orderId: id,
|
|
30406
|
-
message: err.message,
|
|
30407
30426
|
});
|
|
30408
30427
|
}
|
|
30409
30428
|
if (order.result.buy.length === 0) {
|
|
@@ -30442,7 +30461,7 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
30442
30461
|
if (!err.message.includes('The fulfiller does not have the balances needed to fulfill')) {
|
|
30443
30462
|
throw new CheckoutError('Error occurred while trying to fulfill the order', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
|
|
30444
30463
|
orderId: id,
|
|
30445
|
-
|
|
30464
|
+
error: err,
|
|
30446
30465
|
});
|
|
30447
30466
|
}
|
|
30448
30467
|
}
|
|
@@ -30501,9 +30520,7 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
30501
30520
|
}
|
|
30502
30521
|
}
|
|
30503
30522
|
catch (err) {
|
|
30504
|
-
throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
|
|
30505
|
-
message: err.message,
|
|
30506
|
-
});
|
|
30523
|
+
throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, { error: err });
|
|
30507
30524
|
}
|
|
30508
30525
|
if (overrides.waitFulfillmentSettlements) {
|
|
30509
30526
|
const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
|
|
@@ -30542,7 +30559,9 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
30542
30559
|
};
|
|
30543
30560
|
};
|
|
30544
30561
|
|
|
30545
|
-
const cancel = async (config, provider, orderIds
|
|
30562
|
+
const cancel = async (config, provider, orderIds, overrides = {
|
|
30563
|
+
waitFulfillmentSettlements: true,
|
|
30564
|
+
}) => {
|
|
30546
30565
|
let unsignedCancelOrderTransaction;
|
|
30547
30566
|
if (orderIds.length === 0) {
|
|
30548
30567
|
throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
|
|
@@ -30558,19 +30577,35 @@ const cancel = async (config, provider, orderIds) => {
|
|
|
30558
30577
|
catch (err) {
|
|
30559
30578
|
throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
|
|
30560
30579
|
orderId,
|
|
30561
|
-
|
|
30580
|
+
error: err,
|
|
30562
30581
|
});
|
|
30563
30582
|
}
|
|
30564
|
-
|
|
30565
|
-
|
|
30583
|
+
if (overrides.waitFulfillmentSettlements) {
|
|
30584
|
+
const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
|
|
30585
|
+
if (result.type === SignTransactionStatusType.FAILED) {
|
|
30586
|
+
return {
|
|
30587
|
+
status: CheckoutStatus.FAILED,
|
|
30588
|
+
transactionHash: result.transactionHash,
|
|
30589
|
+
reason: result.reason,
|
|
30590
|
+
};
|
|
30591
|
+
}
|
|
30566
30592
|
return {
|
|
30567
|
-
status: CheckoutStatus.
|
|
30568
|
-
transactionHash: result.transactionHash,
|
|
30569
|
-
reason: result.reason,
|
|
30593
|
+
status: CheckoutStatus.SUCCESS,
|
|
30570
30594
|
};
|
|
30571
30595
|
}
|
|
30596
|
+
let transactions;
|
|
30597
|
+
try {
|
|
30598
|
+
const response = await Promise.all([unsignedCancelOrderTransaction].map((transaction) => sendTransaction(provider, transaction)));
|
|
30599
|
+
transactions = response.map((result) => result.transactionResponse);
|
|
30600
|
+
}
|
|
30601
|
+
catch (err) {
|
|
30602
|
+
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
|
|
30603
|
+
message: err.message,
|
|
30604
|
+
});
|
|
30605
|
+
}
|
|
30572
30606
|
return {
|
|
30573
|
-
status: CheckoutStatus.
|
|
30607
|
+
status: CheckoutStatus.FULFILLMENTS_UNSETTLED,
|
|
30608
|
+
transactions,
|
|
30574
30609
|
};
|
|
30575
30610
|
};
|
|
30576
30611
|
|
|
@@ -30627,7 +30662,7 @@ const sell = async (config, provider, orders) => {
|
|
|
30627
30662
|
}
|
|
30628
30663
|
catch (err) {
|
|
30629
30664
|
throw new CheckoutError('An error occurred while preparing the listing', CheckoutErrorType.PREPARE_ORDER_LISTING_ERROR, {
|
|
30630
|
-
|
|
30665
|
+
error: err,
|
|
30631
30666
|
id: sellToken.id,
|
|
30632
30667
|
collectionAddress: sellToken.collectionAddress,
|
|
30633
30668
|
});
|
|
@@ -30683,7 +30718,7 @@ const sell = async (config, provider, orders) => {
|
|
|
30683
30718
|
}
|
|
30684
30719
|
catch (err) {
|
|
30685
30720
|
throw new CheckoutError('An error occurred while creating the listing', CheckoutErrorType.CREATE_ORDER_LISTING_ERROR, {
|
|
30686
|
-
|
|
30721
|
+
error: err,
|
|
30687
30722
|
collectionId: sellToken.id,
|
|
30688
30723
|
collectionAddress: sellToken.collectionAddress,
|
|
30689
30724
|
});
|
|
@@ -30980,7 +31015,7 @@ class Checkout {
|
|
|
30980
31015
|
}
|
|
30981
31016
|
}
|
|
30982
31017
|
catch (err) {
|
|
30983
|
-
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, {
|
|
31018
|
+
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
30984
31019
|
}
|
|
30985
31020
|
});
|
|
30986
31021
|
return factory;
|
|
@@ -31134,7 +31169,7 @@ class Checkout {
|
|
|
31134
31169
|
// eslint-disable-next-line no-console
|
|
31135
31170
|
console.warn('This endpoint currently only processes the first order in the array.');
|
|
31136
31171
|
const web3Provider = await validateProvider(this.config, params.provider);
|
|
31137
|
-
return await cancel(this.config, web3Provider, params.orderIds);
|
|
31172
|
+
return await cancel(this.config, web3Provider, params.orderIds, params.overrides);
|
|
31138
31173
|
}
|
|
31139
31174
|
/**
|
|
31140
31175
|
* Determines the transaction requirements to complete a purchase.
|
|
@@ -31146,8 +31181,8 @@ class Checkout {
|
|
|
31146
31181
|
try {
|
|
31147
31182
|
itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
|
|
31148
31183
|
}
|
|
31149
|
-
catch (
|
|
31150
|
-
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
|
|
31184
|
+
catch (err) {
|
|
31185
|
+
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR, { error: err });
|
|
31151
31186
|
}
|
|
31152
31187
|
return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
31153
31188
|
}
|
|
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
17
17
|
chainID,
|
|
18
18
|
coreContractAddress,
|
|
19
19
|
registrationContractAddress,
|
|
20
|
-
sdkVersion: 'ts-immutable-sdk-0.44.
|
|
20
|
+
sdkVersion: 'ts-immutable-sdk-0.44.4',
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Sets `sdkVersion` at the time of build
|