@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/index.js
CHANGED
|
@@ -10619,7 +10619,7 @@ class MultiRollupApiClients {
|
|
|
10619
10619
|
}
|
|
10620
10620
|
|
|
10621
10621
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10622
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.
|
|
10622
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.4' };
|
|
10623
10623
|
const createConfig = ({ basePath, headers, }) => {
|
|
10624
10624
|
if (!basePath.trim()) {
|
|
10625
10625
|
throw Error('basePath can not be empty');
|
|
@@ -10691,7 +10691,7 @@ class APIError extends Error {
|
|
|
10691
10691
|
|
|
10692
10692
|
/* eslint-disable implicit-arrow-linebreak */
|
|
10693
10693
|
const defaultHeaders = {
|
|
10694
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.
|
|
10694
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.4',
|
|
10695
10695
|
};
|
|
10696
10696
|
/**
|
|
10697
10697
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11130,7 +11130,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11130
11130
|
chainID,
|
|
11131
11131
|
coreContractAddress,
|
|
11132
11132
|
registrationContractAddress,
|
|
11133
|
-
sdkVersion: 'ts-immutable-sdk-0.44.
|
|
11133
|
+
sdkVersion: 'ts-immutable-sdk-0.44.4',
|
|
11134
11134
|
});
|
|
11135
11135
|
/**
|
|
11136
11136
|
* Sets `sdkVersion` at the time of build
|
|
@@ -17880,7 +17880,8 @@ class Passport {
|
|
|
17880
17880
|
this.passportEventEmitter = new TypedEventEmitter();
|
|
17881
17881
|
const imxClientConfig = this.config.baseConfig.environment === Environment$1.PRODUCTION
|
|
17882
17882
|
? imxApiConfig.getProduction() : imxApiConfig.getSandbox();
|
|
17883
|
-
const imxApiClients =
|
|
17883
|
+
const imxApiClients = passportModuleConfiguration.overrides?.imxApiClients
|
|
17884
|
+
|| new ImxApiClients(imxClientConfig);
|
|
17884
17885
|
this.passportImxProviderFactory = new PassportImxProviderFactory({
|
|
17885
17886
|
authManager: this.authManager,
|
|
17886
17887
|
config: this.config,
|
|
@@ -36426,6 +36427,7 @@ var BridgeMethodsGasLimit;
|
|
|
36426
36427
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
|
|
36427
36428
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
|
|
36428
36429
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
36430
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["APPROVE_TOKEN"] = 55000] = "APPROVE_TOKEN";
|
|
36429
36431
|
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
36430
36432
|
var StatusResponse;
|
|
36431
36433
|
(function (StatusResponse) {
|
|
@@ -36613,8 +36615,12 @@ class TokenBridge {
|
|
|
36613
36615
|
throw new BridgeError(`Finalised withdrawals must be on the root chain (${this.config.bridgeInstance.rootChainID})`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
36614
36616
|
}
|
|
36615
36617
|
let sourceChainGas = BigNumber.from(0);
|
|
36618
|
+
let approvalFee = BigNumber.from(0);
|
|
36616
36619
|
let bridgeFee = BigNumber.from(0);
|
|
36617
36620
|
const imtblFee = BigNumber.from(0);
|
|
36621
|
+
if ('token' in req && req.token !== 'NATIVE') {
|
|
36622
|
+
approvalFee = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.APPROVE_TOKEN);
|
|
36623
|
+
}
|
|
36618
36624
|
if (req.action === BridgeFeeActions.FINALISE_WITHDRAWAL) {
|
|
36619
36625
|
sourceChainGas = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.FINALISE_WITHDRAWAL);
|
|
36620
36626
|
}
|
|
@@ -36625,9 +36631,10 @@ class TokenBridge {
|
|
|
36625
36631
|
const feeResult = await this.calculateBridgeFee(req.sourceChainId, req.destinationChainId, BridgeMethodsGasLimit[`${req.action}_DESTINATION`], req.gasMultiplier);
|
|
36626
36632
|
bridgeFee = feeResult.bridgeFee;
|
|
36627
36633
|
}
|
|
36628
|
-
const totalFees = sourceChainGas.add(bridgeFee).add(imtblFee);
|
|
36634
|
+
const totalFees = sourceChainGas.add(approvalFee).add(bridgeFee).add(imtblFee);
|
|
36629
36635
|
return {
|
|
36630
36636
|
sourceChainGas,
|
|
36637
|
+
approvalFee,
|
|
36631
36638
|
bridgeFee,
|
|
36632
36639
|
imtblFee,
|
|
36633
36640
|
totalFees,
|
|
@@ -36857,6 +36864,8 @@ class TokenBridge {
|
|
|
36857
36864
|
gasMultiplier,
|
|
36858
36865
|
sourceChainId,
|
|
36859
36866
|
destinationChainId,
|
|
36867
|
+
token,
|
|
36868
|
+
amount,
|
|
36860
36869
|
});
|
|
36861
36870
|
const canReceive = await this.checkReceiver(provider, recipient);
|
|
36862
36871
|
if (!canReceive) {
|
|
@@ -41606,7 +41615,7 @@ async function switchWalletNetwork(config, web3Provider, chainId) {
|
|
|
41606
41615
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
41607
41616
|
}
|
|
41608
41617
|
catch (err) {
|
|
41609
|
-
throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
|
|
41618
|
+
throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
|
|
41610
41619
|
}
|
|
41611
41620
|
}
|
|
41612
41621
|
else {
|
|
@@ -41970,7 +41979,7 @@ const GAS_OVERRIDES = {
|
|
|
41970
41979
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
41971
41980
|
};
|
|
41972
41981
|
|
|
41973
|
-
const SDK_VERSION_MARKER = '0.44.
|
|
41982
|
+
const SDK_VERSION_MARKER = '0.44.4';
|
|
41974
41983
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
41975
41984
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
41976
41985
|
|
|
@@ -42000,8 +42009,8 @@ class RemoteConfigFetcher {
|
|
|
42000
42009
|
try {
|
|
42001
42010
|
responseData = JSON.parse(response.data);
|
|
42002
42011
|
}
|
|
42003
|
-
catch (
|
|
42004
|
-
throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
|
|
42012
|
+
catch (err) {
|
|
42013
|
+
throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR, { error: err });
|
|
42005
42014
|
}
|
|
42006
42015
|
}
|
|
42007
42016
|
return responseData;
|
|
@@ -42014,7 +42023,7 @@ class RemoteConfigFetcher {
|
|
|
42014
42023
|
response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
|
|
42015
42024
|
}
|
|
42016
42025
|
catch (err) {
|
|
42017
|
-
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
|
|
42026
|
+
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
42018
42027
|
}
|
|
42019
42028
|
// Ensure that the configuration is valid
|
|
42020
42029
|
this.configCache = this.parseResponse(response);
|
|
@@ -42028,7 +42037,7 @@ class RemoteConfigFetcher {
|
|
|
42028
42037
|
response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
|
|
42029
42038
|
}
|
|
42030
42039
|
catch (err) {
|
|
42031
|
-
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
|
|
42040
|
+
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
42032
42041
|
}
|
|
42033
42042
|
// Ensure that the configuration is valid
|
|
42034
42043
|
this.tokensCache = this.parseResponse(response);
|
|
@@ -42391,7 +42400,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
42391
42400
|
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
42392
42401
|
// or simply an incorrect wallet address was provided.
|
|
42393
42402
|
if (err?.code !== HttpStatusCode$3.NotFound) {
|
|
42394
|
-
throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
|
|
42403
|
+
throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
|
|
42395
42404
|
}
|
|
42396
42405
|
}
|
|
42397
42406
|
};
|
|
@@ -42410,7 +42419,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
42410
42419
|
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
42411
42420
|
// or simply an incorrect wallet address was provided.
|
|
42412
42421
|
if (err?.code !== HttpStatusCode$3.NotFound) {
|
|
42413
|
-
throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
|
|
42422
|
+
throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
|
|
42414
42423
|
}
|
|
42415
42424
|
}
|
|
42416
42425
|
};
|
|
@@ -42523,6 +42532,7 @@ async function checkIsWalletConnected(web3Provider) {
|
|
|
42523
42532
|
}
|
|
42524
42533
|
catch (err) {
|
|
42525
42534
|
throw new CheckoutError('Check wallet connection request failed', CheckoutErrorType.PROVIDER_REQUEST_FAILED_ERROR, {
|
|
42535
|
+
error: err,
|
|
42526
42536
|
rpcMethod: WalletAction.CHECK_CONNECTION,
|
|
42527
42537
|
});
|
|
42528
42538
|
}
|
|
@@ -42615,7 +42625,7 @@ async function validateProvider(config, web3Provider, validateProviderOptions) {
|
|
|
42615
42625
|
}
|
|
42616
42626
|
}
|
|
42617
42627
|
catch (err) {
|
|
42618
|
-
throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
|
|
42628
|
+
throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR, { error: err });
|
|
42619
42629
|
}
|
|
42620
42630
|
if (web3ChainId !== underlyingChainId && !options.allowMistmatchedChainId) {
|
|
42621
42631
|
throw new CheckoutError('Your wallet has changed network, please switch to a supported network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
|
|
@@ -42667,15 +42677,15 @@ const sendTransaction = async (web3Provider, transaction) => {
|
|
|
42667
42677
|
}
|
|
42668
42678
|
catch (err) {
|
|
42669
42679
|
if (err.code === ethers.errors.INSUFFICIENT_FUNDS) {
|
|
42670
|
-
throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS);
|
|
42680
|
+
throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS, { error: err });
|
|
42671
42681
|
}
|
|
42672
42682
|
if (err.code === ethers.errors.ACTION_REJECTED) {
|
|
42673
|
-
throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
|
|
42683
|
+
throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
|
|
42674
42684
|
}
|
|
42675
42685
|
if (err.code === ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
|
|
42676
|
-
throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
|
|
42686
|
+
throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
|
|
42677
42687
|
}
|
|
42678
|
-
throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED);
|
|
42688
|
+
throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED, { error: err });
|
|
42679
42689
|
}
|
|
42680
42690
|
};
|
|
42681
42691
|
|
|
@@ -42688,6 +42698,8 @@ async function getBridgeFeeEstimate$1(tokenBridge, fromChainId, toChainId, confi
|
|
|
42688
42698
|
gasMultiplier: 1.1,
|
|
42689
42699
|
sourceChainId: fromChainId.toString(),
|
|
42690
42700
|
destinationChainId: toChainId.toString(),
|
|
42701
|
+
token: NATIVE.toUpperCase(),
|
|
42702
|
+
amount: BigNumber$1.from(0),
|
|
42691
42703
|
});
|
|
42692
42704
|
}
|
|
42693
42705
|
|
|
@@ -42767,6 +42779,7 @@ async function bridgeToL2GasEstimator(readOnlyProviders, config) {
|
|
|
42767
42779
|
gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
|
|
42768
42780
|
fees: {
|
|
42769
42781
|
sourceChainGas: BigNumber$1.from(0),
|
|
42782
|
+
approvalFee: BigNumber$1.from(0),
|
|
42770
42783
|
bridgeFee: BigNumber$1.from(0),
|
|
42771
42784
|
imtblFee: BigNumber$1.from(0),
|
|
42772
42785
|
totalFees: BigNumber$1.from(0),
|
|
@@ -42916,7 +42929,7 @@ const getERC20Allowance = async (provider, ownerAddress, contractAddress, spende
|
|
|
42916
42929
|
return await contract.allowance(ownerAddress, spenderAddress);
|
|
42917
42930
|
}
|
|
42918
42931
|
catch (err) {
|
|
42919
|
-
throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
|
|
42932
|
+
throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
|
|
42920
42933
|
}
|
|
42921
42934
|
};
|
|
42922
42935
|
// Returns the approval transaction for the ERC20 that the owner can sign
|
|
@@ -42929,8 +42942,8 @@ const getERC20ApprovalTransaction = async (provider, ownerAddress, contractAddre
|
|
|
42929
42942
|
approveTransaction.from = ownerAddress;
|
|
42930
42943
|
return approveTransaction;
|
|
42931
42944
|
}
|
|
42932
|
-
catch {
|
|
42933
|
-
throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
|
|
42945
|
+
catch (err) {
|
|
42946
|
+
throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
|
|
42934
42947
|
}
|
|
42935
42948
|
};
|
|
42936
42949
|
const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
@@ -43002,7 +43015,12 @@ const getERC721ApprovedForAll = async (provider, ownerAddress, contractAddress,
|
|
|
43002
43015
|
return await contract.isApprovedForAll(ownerAddress, spenderAddress);
|
|
43003
43016
|
}
|
|
43004
43017
|
catch (err) {
|
|
43005
|
-
throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43018
|
+
throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43019
|
+
ownerAddress,
|
|
43020
|
+
contractAddress,
|
|
43021
|
+
spenderAddress,
|
|
43022
|
+
error: err,
|
|
43023
|
+
});
|
|
43006
43024
|
}
|
|
43007
43025
|
};
|
|
43008
43026
|
// Returns a populated transaction to approve the ERC721 for the spender.
|
|
@@ -43016,7 +43034,11 @@ const getApproveTransaction = async (provider, ownerAddress, contractAddress, sp
|
|
|
43016
43034
|
}
|
|
43017
43035
|
catch (err) {
|
|
43018
43036
|
throw new CheckoutError('Failed to get the approval transaction for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43019
|
-
id: id.toString(),
|
|
43037
|
+
id: id.toString(),
|
|
43038
|
+
contractAddress,
|
|
43039
|
+
spenderAddress,
|
|
43040
|
+
ownerAddress,
|
|
43041
|
+
error: err,
|
|
43020
43042
|
});
|
|
43021
43043
|
}
|
|
43022
43044
|
};
|
|
@@ -43028,7 +43050,11 @@ const getERC721ApprovedAddress = async (provider, contractAddress, id) => {
|
|
|
43028
43050
|
return await contract.getApproved(id);
|
|
43029
43051
|
}
|
|
43030
43052
|
catch (err) {
|
|
43031
|
-
throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43053
|
+
throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43054
|
+
id: id.toString(),
|
|
43055
|
+
contractAddress,
|
|
43056
|
+
error: err,
|
|
43057
|
+
});
|
|
43032
43058
|
}
|
|
43033
43059
|
};
|
|
43034
43060
|
const convertIdToNumber = (id, contractAddress) => {
|
|
@@ -43356,8 +43382,8 @@ const getTokenBalances = async (config, provider, ownerAddress, itemRequirements
|
|
|
43356
43382
|
const { balances } = await getAllBalances(config, provider, ownerAddress, getL2ChainId(config));
|
|
43357
43383
|
return balances.filter((balance) => tokenMap.get((balance.token.address || NATIVE).toLocaleLowerCase()));
|
|
43358
43384
|
}
|
|
43359
|
-
catch (
|
|
43360
|
-
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR);
|
|
43385
|
+
catch (err) {
|
|
43386
|
+
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR, { error: err });
|
|
43361
43387
|
}
|
|
43362
43388
|
};
|
|
43363
43389
|
/**
|
|
@@ -43395,8 +43421,8 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
43395
43421
|
});
|
|
43396
43422
|
});
|
|
43397
43423
|
}
|
|
43398
|
-
catch (
|
|
43399
|
-
throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR);
|
|
43424
|
+
catch (err) {
|
|
43425
|
+
throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR, { error: err });
|
|
43400
43426
|
}
|
|
43401
43427
|
return erc721Balances;
|
|
43402
43428
|
};
|
|
@@ -43466,7 +43492,7 @@ const estimateGas = async (provider, transaction) => {
|
|
|
43466
43492
|
return await provider.estimateGas(transaction);
|
|
43467
43493
|
}
|
|
43468
43494
|
catch (err) {
|
|
43469
|
-
throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
|
|
43495
|
+
throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
|
|
43470
43496
|
}
|
|
43471
43497
|
};
|
|
43472
43498
|
const getGasItemRequirement = (gas, transactionOrGas) => {
|
|
@@ -43530,14 +43556,14 @@ const availabilityService = (isDevelopment, isProduction) => {
|
|
|
43530
43556
|
try {
|
|
43531
43557
|
response = await globalAxios$1.post(`${postEndpoint()}/v1/availability/checkout/swap`);
|
|
43532
43558
|
}
|
|
43533
|
-
catch (
|
|
43559
|
+
catch (err) {
|
|
43534
43560
|
// The request was made and the server responded with a status code
|
|
43535
43561
|
// that falls out of the range of 2xx
|
|
43536
|
-
response =
|
|
43562
|
+
response = err.response;
|
|
43537
43563
|
// If 403 then the service is geo-blocked
|
|
43538
43564
|
if (response.status === 403)
|
|
43539
43565
|
return false;
|
|
43540
|
-
throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR);
|
|
43566
|
+
throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
43541
43567
|
}
|
|
43542
43568
|
return true;
|
|
43543
43569
|
};
|
|
@@ -44048,7 +44074,7 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
|
|
|
44048
44074
|
};
|
|
44049
44075
|
}
|
|
44050
44076
|
catch (err) {
|
|
44051
|
-
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
44077
|
+
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { error: err });
|
|
44052
44078
|
}
|
|
44053
44079
|
};
|
|
44054
44080
|
|
|
@@ -44698,7 +44724,7 @@ const routingCalculator = async (config, ownerAddress, balanceRequirements, avai
|
|
|
44698
44724
|
readOnlyProviders = await createReadOnlyProviders(config);
|
|
44699
44725
|
}
|
|
44700
44726
|
catch (err) {
|
|
44701
|
-
throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, {
|
|
44727
|
+
throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, { error: err });
|
|
44702
44728
|
}
|
|
44703
44729
|
const tokenBalances = await measureAsyncExecution(config, 'Time to get token balances inside router', getAllTokenBalances(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
|
|
44704
44730
|
const allowList = await measureAsyncExecution(config, 'Time to get routing allowlist', allowListCheck(config, tokenBalances, availableRoutingOptions));
|
|
@@ -44821,9 +44847,7 @@ const signApprovalTransactions = async (provider, approvalTransactions) => {
|
|
|
44821
44847
|
receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
|
|
44822
44848
|
}
|
|
44823
44849
|
catch (err) {
|
|
44824
|
-
throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, {
|
|
44825
|
-
message: err.message,
|
|
44826
|
-
});
|
|
44850
|
+
throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, { error: err });
|
|
44827
44851
|
}
|
|
44828
44852
|
for (const receipt of receipts) {
|
|
44829
44853
|
if (receipt.status === 0) {
|
|
@@ -44845,9 +44869,7 @@ const signFulfillmentTransactions = async (provider, fulfillmentTransactions) =>
|
|
|
44845
44869
|
receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
|
|
44846
44870
|
}
|
|
44847
44871
|
catch (err) {
|
|
44848
|
-
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
|
|
44849
|
-
message: err.message,
|
|
44850
|
-
});
|
|
44872
|
+
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, { error: err });
|
|
44851
44873
|
}
|
|
44852
44874
|
for (const receipt of receipts) {
|
|
44853
44875
|
if (receipt.status === 0) {
|
|
@@ -44873,9 +44895,7 @@ const signMessage = async (provider, unsignedMessage) => {
|
|
|
44873
44895
|
};
|
|
44874
44896
|
}
|
|
44875
44897
|
catch (err) {
|
|
44876
|
-
throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, {
|
|
44877
|
-
message: err.message,
|
|
44878
|
-
});
|
|
44898
|
+
throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, { error: err });
|
|
44879
44899
|
}
|
|
44880
44900
|
};
|
|
44881
44901
|
|
|
@@ -45058,8 +45078,8 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
45058
45078
|
}
|
|
45059
45079
|
catch (err) {
|
|
45060
45080
|
throw new CheckoutError('An error occurred while getting the order listing', CheckoutErrorType.GET_ORDER_LISTING_ERROR, {
|
|
45081
|
+
error: err,
|
|
45061
45082
|
orderId: id,
|
|
45062
|
-
message: err.message,
|
|
45063
45083
|
});
|
|
45064
45084
|
}
|
|
45065
45085
|
if (order.result.buy.length === 0) {
|
|
@@ -45098,7 +45118,7 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
45098
45118
|
if (!err.message.includes('The fulfiller does not have the balances needed to fulfill')) {
|
|
45099
45119
|
throw new CheckoutError('Error occurred while trying to fulfill the order', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
|
|
45100
45120
|
orderId: id,
|
|
45101
|
-
|
|
45121
|
+
error: err,
|
|
45102
45122
|
});
|
|
45103
45123
|
}
|
|
45104
45124
|
}
|
|
@@ -45157,9 +45177,7 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
45157
45177
|
}
|
|
45158
45178
|
}
|
|
45159
45179
|
catch (err) {
|
|
45160
|
-
throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
|
|
45161
|
-
message: err.message,
|
|
45162
|
-
});
|
|
45180
|
+
throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, { error: err });
|
|
45163
45181
|
}
|
|
45164
45182
|
if (overrides.waitFulfillmentSettlements) {
|
|
45165
45183
|
const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
|
|
@@ -45198,7 +45216,9 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
45198
45216
|
};
|
|
45199
45217
|
};
|
|
45200
45218
|
|
|
45201
|
-
const cancel = async (config, provider, orderIds
|
|
45219
|
+
const cancel = async (config, provider, orderIds, overrides = {
|
|
45220
|
+
waitFulfillmentSettlements: true,
|
|
45221
|
+
}) => {
|
|
45202
45222
|
let unsignedCancelOrderTransaction;
|
|
45203
45223
|
if (orderIds.length === 0) {
|
|
45204
45224
|
throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
|
|
@@ -45214,19 +45234,35 @@ const cancel = async (config, provider, orderIds) => {
|
|
|
45214
45234
|
catch (err) {
|
|
45215
45235
|
throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
|
|
45216
45236
|
orderId,
|
|
45217
|
-
|
|
45237
|
+
error: err,
|
|
45218
45238
|
});
|
|
45219
45239
|
}
|
|
45220
|
-
|
|
45221
|
-
|
|
45240
|
+
if (overrides.waitFulfillmentSettlements) {
|
|
45241
|
+
const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
|
|
45242
|
+
if (result.type === SignTransactionStatusType.FAILED) {
|
|
45243
|
+
return {
|
|
45244
|
+
status: CheckoutStatus.FAILED,
|
|
45245
|
+
transactionHash: result.transactionHash,
|
|
45246
|
+
reason: result.reason,
|
|
45247
|
+
};
|
|
45248
|
+
}
|
|
45222
45249
|
return {
|
|
45223
|
-
status: CheckoutStatus.
|
|
45224
|
-
transactionHash: result.transactionHash,
|
|
45225
|
-
reason: result.reason,
|
|
45250
|
+
status: CheckoutStatus.SUCCESS,
|
|
45226
45251
|
};
|
|
45227
45252
|
}
|
|
45253
|
+
let transactions;
|
|
45254
|
+
try {
|
|
45255
|
+
const response = await Promise.all([unsignedCancelOrderTransaction].map((transaction) => sendTransaction(provider, transaction)));
|
|
45256
|
+
transactions = response.map((result) => result.transactionResponse);
|
|
45257
|
+
}
|
|
45258
|
+
catch (err) {
|
|
45259
|
+
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
|
|
45260
|
+
message: err.message,
|
|
45261
|
+
});
|
|
45262
|
+
}
|
|
45228
45263
|
return {
|
|
45229
|
-
status: CheckoutStatus.
|
|
45264
|
+
status: CheckoutStatus.FULFILLMENTS_UNSETTLED,
|
|
45265
|
+
transactions,
|
|
45230
45266
|
};
|
|
45231
45267
|
};
|
|
45232
45268
|
|
|
@@ -45283,7 +45319,7 @@ const sell = async (config, provider, orders) => {
|
|
|
45283
45319
|
}
|
|
45284
45320
|
catch (err) {
|
|
45285
45321
|
throw new CheckoutError('An error occurred while preparing the listing', CheckoutErrorType.PREPARE_ORDER_LISTING_ERROR, {
|
|
45286
|
-
|
|
45322
|
+
error: err,
|
|
45287
45323
|
id: sellToken.id,
|
|
45288
45324
|
collectionAddress: sellToken.collectionAddress,
|
|
45289
45325
|
});
|
|
@@ -45339,7 +45375,7 @@ const sell = async (config, provider, orders) => {
|
|
|
45339
45375
|
}
|
|
45340
45376
|
catch (err) {
|
|
45341
45377
|
throw new CheckoutError('An error occurred while creating the listing', CheckoutErrorType.CREATE_ORDER_LISTING_ERROR, {
|
|
45342
|
-
|
|
45378
|
+
error: err,
|
|
45343
45379
|
collectionId: sellToken.id,
|
|
45344
45380
|
collectionAddress: sellToken.collectionAddress,
|
|
45345
45381
|
});
|
|
@@ -45636,7 +45672,7 @@ class Checkout {
|
|
|
45636
45672
|
}
|
|
45637
45673
|
}
|
|
45638
45674
|
catch (err) {
|
|
45639
|
-
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, {
|
|
45675
|
+
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
45640
45676
|
}
|
|
45641
45677
|
});
|
|
45642
45678
|
return factory;
|
|
@@ -45790,7 +45826,7 @@ class Checkout {
|
|
|
45790
45826
|
// eslint-disable-next-line no-console
|
|
45791
45827
|
console.warn('This endpoint currently only processes the first order in the array.');
|
|
45792
45828
|
const web3Provider = await validateProvider(this.config, params.provider);
|
|
45793
|
-
return await cancel(this.config, web3Provider, params.orderIds);
|
|
45829
|
+
return await cancel(this.config, web3Provider, params.orderIds, params.overrides);
|
|
45794
45830
|
}
|
|
45795
45831
|
/**
|
|
45796
45832
|
* Determines the transaction requirements to complete a purchase.
|
|
@@ -45802,8 +45838,8 @@ class Checkout {
|
|
|
45802
45838
|
try {
|
|
45803
45839
|
itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
|
|
45804
45840
|
}
|
|
45805
|
-
catch (
|
|
45806
|
-
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
|
|
45841
|
+
catch (err) {
|
|
45842
|
+
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR, { error: err });
|
|
45807
45843
|
}
|
|
45808
45844
|
return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
45809
45845
|
}
|