@imtbl/sdk 0.44.1 → 0.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +3 -3
- package/dist/browser/checkout/widgets.js +60 -60
- package/dist/checkout.d.ts +33 -4
- package/dist/checkout.js +213 -143
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +11 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +215 -145
- package/dist/index.d.ts +38 -3
- package/dist/index.js +215 -145
- package/dist/orderbook.d.ts +1 -1
- package/dist/passport.js +2 -2
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -10641,7 +10641,7 @@ class MultiRollupApiClients {
|
|
|
10641
10641
|
}
|
|
10642
10642
|
|
|
10643
10643
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10644
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.
|
|
10644
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.3' };
|
|
10645
10645
|
const createConfig = ({ basePath, headers, }) => {
|
|
10646
10646
|
if (!basePath.trim()) {
|
|
10647
10647
|
throw Error('basePath can not be empty');
|
|
@@ -10713,7 +10713,7 @@ class APIError extends Error {
|
|
|
10713
10713
|
|
|
10714
10714
|
/* eslint-disable implicit-arrow-linebreak */
|
|
10715
10715
|
const defaultHeaders = {
|
|
10716
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.
|
|
10716
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.3',
|
|
10717
10717
|
};
|
|
10718
10718
|
/**
|
|
10719
10719
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11152,7 +11152,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11152
11152
|
chainID,
|
|
11153
11153
|
coreContractAddress,
|
|
11154
11154
|
registrationContractAddress,
|
|
11155
|
-
sdkVersion: 'ts-immutable-sdk-0.44.
|
|
11155
|
+
sdkVersion: 'ts-immutable-sdk-0.44.3',
|
|
11156
11156
|
});
|
|
11157
11157
|
/**
|
|
11158
11158
|
* Sets `sdkVersion` at the time of build
|
|
@@ -36448,6 +36448,7 @@ var BridgeMethodsGasLimit;
|
|
|
36448
36448
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
|
|
36449
36449
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
|
|
36450
36450
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
36451
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["APPROVE_TOKEN"] = 55000] = "APPROVE_TOKEN";
|
|
36451
36452
|
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
36452
36453
|
var StatusResponse;
|
|
36453
36454
|
(function (StatusResponse) {
|
|
@@ -36635,8 +36636,12 @@ class TokenBridge {
|
|
|
36635
36636
|
throw new BridgeError(`Finalised withdrawals must be on the root chain (${this.config.bridgeInstance.rootChainID})`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
36636
36637
|
}
|
|
36637
36638
|
let sourceChainGas = BigNumber.from(0);
|
|
36639
|
+
let approvalFee = BigNumber.from(0);
|
|
36638
36640
|
let bridgeFee = BigNumber.from(0);
|
|
36639
36641
|
const imtblFee = BigNumber.from(0);
|
|
36642
|
+
if ('token' in req && req.token !== 'NATIVE') {
|
|
36643
|
+
approvalFee = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.APPROVE_TOKEN);
|
|
36644
|
+
}
|
|
36640
36645
|
if (req.action === BridgeFeeActions.FINALISE_WITHDRAWAL) {
|
|
36641
36646
|
sourceChainGas = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.FINALISE_WITHDRAWAL);
|
|
36642
36647
|
}
|
|
@@ -36647,9 +36652,10 @@ class TokenBridge {
|
|
|
36647
36652
|
const feeResult = await this.calculateBridgeFee(req.sourceChainId, req.destinationChainId, BridgeMethodsGasLimit[`${req.action}_DESTINATION`], req.gasMultiplier);
|
|
36648
36653
|
bridgeFee = feeResult.bridgeFee;
|
|
36649
36654
|
}
|
|
36650
|
-
const totalFees = sourceChainGas.add(bridgeFee).add(imtblFee);
|
|
36655
|
+
const totalFees = sourceChainGas.add(approvalFee).add(bridgeFee).add(imtblFee);
|
|
36651
36656
|
return {
|
|
36652
36657
|
sourceChainGas,
|
|
36658
|
+
approvalFee,
|
|
36653
36659
|
bridgeFee,
|
|
36654
36660
|
imtblFee,
|
|
36655
36661
|
totalFees,
|
|
@@ -36879,6 +36885,8 @@ class TokenBridge {
|
|
|
36879
36885
|
gasMultiplier,
|
|
36880
36886
|
sourceChainId,
|
|
36881
36887
|
destinationChainId,
|
|
36888
|
+
token,
|
|
36889
|
+
amount,
|
|
36882
36890
|
});
|
|
36883
36891
|
const canReceive = await this.checkReceiver(provider, recipient);
|
|
36884
36892
|
if (!canReceive) {
|
|
@@ -37038,38 +37046,84 @@ class TokenBridge {
|
|
|
37038
37046
|
* @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
|
|
37039
37047
|
*/
|
|
37040
37048
|
async getTransactionStatus(req) {
|
|
37041
|
-
const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
|
|
37042
37049
|
const txStatusResponse = {
|
|
37043
37050
|
transactions: [],
|
|
37044
37051
|
};
|
|
37045
|
-
const
|
|
37046
|
-
const
|
|
37047
|
-
|
|
37048
|
-
|
|
37052
|
+
const txStatusItems = await this.getAxelarStatus(req.transactions, req.sourceChainId);
|
|
37053
|
+
const uniqueReceivers = await this.getUniqueReceivers(txStatusItems, req.sourceChainId);
|
|
37054
|
+
const pendingWithdrawalPromises = [];
|
|
37055
|
+
for (const address of uniqueReceivers) {
|
|
37056
|
+
pendingWithdrawalPromises.push(this.getPendingWithdrawals({ recipient: address }));
|
|
37049
37057
|
}
|
|
37050
|
-
let
|
|
37058
|
+
let pendingWithdrawalResponses = [];
|
|
37051
37059
|
try {
|
|
37052
|
-
|
|
37060
|
+
pendingWithdrawalResponses = await Promise.all(pendingWithdrawalPromises);
|
|
37053
37061
|
}
|
|
37054
37062
|
catch (err) {
|
|
37055
|
-
|
|
37063
|
+
console.log('err', err);
|
|
37064
|
+
throw new BridgeError(`Failed to fetch the pending withdrawals with: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
|
|
37056
37065
|
}
|
|
37057
|
-
|
|
37066
|
+
txStatusResponse.transactions = txStatusItems;
|
|
37067
|
+
// try match a completed transaction to a pending flowRate transaction
|
|
37068
|
+
for (const txStatusRes of txStatusResponse.transactions) {
|
|
37069
|
+
if (txStatusRes.status === StatusResponse.COMPLETE) {
|
|
37070
|
+
(() => {
|
|
37071
|
+
for (const pendingWithdrawals of pendingWithdrawalResponses) {
|
|
37072
|
+
const flowRatedTxIndex = pendingWithdrawals.pending.findIndex((el) => (el.amount.toString() === txStatusRes.amount.toString()
|
|
37073
|
+
&& el.token === txStatusRes.token
|
|
37074
|
+
&& el.withdrawer === txStatusRes.sender
|
|
37075
|
+
&& el.recipient === txStatusRes.recipient));
|
|
37076
|
+
if (flowRatedTxIndex !== -1) {
|
|
37077
|
+
txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
|
|
37078
|
+
txStatusRes.data = {
|
|
37079
|
+
canWithdraw: pendingWithdrawals.pending[flowRatedTxIndex].canWithdraw,
|
|
37080
|
+
timeoutStart: pendingWithdrawals.pending[flowRatedTxIndex].timeoutStart,
|
|
37081
|
+
timeoutEnd: pendingWithdrawals.pending[flowRatedTxIndex].timeoutEnd,
|
|
37082
|
+
};
|
|
37083
|
+
pendingWithdrawals.pending.splice(flowRatedTxIndex, 1);
|
|
37084
|
+
return;
|
|
37085
|
+
}
|
|
37086
|
+
}
|
|
37087
|
+
})();
|
|
37088
|
+
}
|
|
37089
|
+
}
|
|
37090
|
+
// Return the tx status response
|
|
37091
|
+
return txStatusResponse;
|
|
37092
|
+
}
|
|
37093
|
+
async getUniqueReceivers(txStatusItems, sourceChainId) {
|
|
37094
|
+
const uniqueReceivers = [];
|
|
37058
37095
|
const isWithdraw = [
|
|
37059
37096
|
ZKEVM_DEVNET_CHAIN_ID,
|
|
37060
37097
|
ZKEVM_TESTNET_CHAIN_ID,
|
|
37061
37098
|
ZKEVM_MAINNET_CHAIN_ID
|
|
37062
|
-
].includes(
|
|
37063
|
-
let
|
|
37064
|
-
|
|
37065
|
-
|
|
37066
|
-
const
|
|
37067
|
-
|
|
37068
|
-
|
|
37099
|
+
].includes(sourceChainId);
|
|
37100
|
+
for (let i = 0, l = txStatusItems.length; i < l; i++) {
|
|
37101
|
+
if (txStatusItems[i].status === StatusResponse.COMPLETE
|
|
37102
|
+
&& isWithdraw && txStatusItems[i].recipient) {
|
|
37103
|
+
const receiverIndex = uniqueReceivers.findIndex((el) => el === txStatusItems[i].recipient);
|
|
37104
|
+
if (receiverIndex === -1) {
|
|
37105
|
+
uniqueReceivers.push(txStatusItems[i].recipient);
|
|
37106
|
+
}
|
|
37107
|
+
}
|
|
37108
|
+
} // for
|
|
37109
|
+
return uniqueReceivers;
|
|
37110
|
+
}
|
|
37111
|
+
async getAxelarStatus(transactions, sourceChainId) {
|
|
37112
|
+
const txStatusItems = [];
|
|
37113
|
+
const statusPromises = [];
|
|
37114
|
+
const axelarAPIEndpoint = this.getAxelarEndpoint(sourceChainId);
|
|
37115
|
+
const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
|
|
37116
|
+
const abiCoder = new AbiCoder();
|
|
37117
|
+
for (const transaction of transactions) {
|
|
37118
|
+
statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
|
|
37119
|
+
}
|
|
37120
|
+
let statusResponses;
|
|
37121
|
+
try {
|
|
37122
|
+
statusResponses = await Promise.all(statusPromises);
|
|
37123
|
+
}
|
|
37124
|
+
catch (err) {
|
|
37125
|
+
throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
|
|
37069
37126
|
}
|
|
37070
|
-
const flowRatePromises = [];
|
|
37071
|
-
const flowRateLengthPromises = [];
|
|
37072
|
-
const flowRatePromisesReceivers = [];
|
|
37073
37127
|
for (let i = 0, l = statusResponses.length; i < l; i++) {
|
|
37074
37128
|
let metaStatus;
|
|
37075
37129
|
// consolidate axelar statuses to our own simplified metaStatus
|
|
@@ -37103,7 +37157,7 @@ class TokenBridge {
|
|
|
37103
37157
|
}
|
|
37104
37158
|
}
|
|
37105
37159
|
let txItem = {
|
|
37106
|
-
txHash:
|
|
37160
|
+
txHash: transactions[i].txHash,
|
|
37107
37161
|
status: metaStatus,
|
|
37108
37162
|
data: {
|
|
37109
37163
|
gmpResponse: statusResponses[i].status,
|
|
@@ -37120,61 +37174,9 @@ class TokenBridge {
|
|
|
37120
37174
|
amount: decodedData[4],
|
|
37121
37175
|
};
|
|
37122
37176
|
}
|
|
37123
|
-
|
|
37124
|
-
if (metaStatus === StatusResponse.COMPLETE
|
|
37125
|
-
&& isWithdraw && txItem.recipient) {
|
|
37126
|
-
// consolidate the calls we have to make to the flow rate by receiver
|
|
37127
|
-
if (flowRatePromiseIndex === -1) {
|
|
37128
|
-
flowRatePromisesReceivers.push(txItem.recipient);
|
|
37129
|
-
flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
|
|
37130
|
-
}
|
|
37131
|
-
txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
|
|
37132
|
-
}
|
|
37133
|
-
txStatusResponse.transactions.push(txItem);
|
|
37177
|
+
txStatusItems.push(txItem);
|
|
37134
37178
|
} // for
|
|
37135
|
-
|
|
37136
|
-
flowRateLengthPromises.push(rootBridge.getPendingWithdrawalsLength(flowRateReceiver));
|
|
37137
|
-
}
|
|
37138
|
-
let flowRateLengthResponses = [];
|
|
37139
|
-
try {
|
|
37140
|
-
flowRateLengthResponses = await Promise.all(flowRateLengthPromises);
|
|
37141
|
-
}
|
|
37142
|
-
catch (err) {
|
|
37143
|
-
throw new BridgeError(`Failed to fetch the Flow Rate pending lengths with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
|
|
37144
|
-
}
|
|
37145
|
-
for (let i = 0, l = flowRatePromisesReceivers.length; i < l; i++) {
|
|
37146
|
-
const indices = [];
|
|
37147
|
-
const indicesLength = flowRateLengthResponses[i].toNumber();
|
|
37148
|
-
for (let j = 0; j < indicesLength; j++) {
|
|
37149
|
-
indices.push(j);
|
|
37150
|
-
}
|
|
37151
|
-
flowRatePromises.push(rootBridge.getPendingWithdrawals(flowRatePromisesReceivers[i], indices));
|
|
37152
|
-
}
|
|
37153
|
-
let flowRateResponses = [];
|
|
37154
|
-
if (flowRatePromises.length > 0) {
|
|
37155
|
-
try {
|
|
37156
|
-
flowRateResponses = await Promise.all(flowRatePromises);
|
|
37157
|
-
}
|
|
37158
|
-
catch (err) {
|
|
37159
|
-
throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
|
|
37160
|
-
}
|
|
37161
|
-
}
|
|
37162
|
-
for (const txStatusRes of txStatusResponse.transactions) {
|
|
37163
|
-
if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
|
|
37164
|
-
const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
|
|
37165
|
-
&& el.token === txStatusRes.token
|
|
37166
|
-
&& el.withdrawer === txStatusRes.sender));
|
|
37167
|
-
if (flowRatedTx) {
|
|
37168
|
-
txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
|
|
37169
|
-
txStatusRes.data = {
|
|
37170
|
-
timestamp: flowRatedTx.timestamp.toString(),
|
|
37171
|
-
};
|
|
37172
|
-
}
|
|
37173
|
-
}
|
|
37174
|
-
delete txStatusRes.data.flowRatePromiseIndex;
|
|
37175
|
-
}
|
|
37176
|
-
// Return the tx status response
|
|
37177
|
-
return txStatusResponse;
|
|
37179
|
+
return txStatusItems;
|
|
37178
37180
|
}
|
|
37179
37181
|
/**
|
|
37180
37182
|
* Queries for the information about which tokens are flowrated and how long the delay is.
|
|
@@ -37200,6 +37202,7 @@ class TokenBridge {
|
|
|
37200
37202
|
token = ETHEREUM_NATIVE_TOKEN_ADDRESS;
|
|
37201
37203
|
}
|
|
37202
37204
|
contractPromises.push(rootBridge.flowRateBuckets(token));
|
|
37205
|
+
contractPromises.push(rootBridge.largeTransferThresholds(token));
|
|
37203
37206
|
}
|
|
37204
37207
|
let contractPromisesRes;
|
|
37205
37208
|
try {
|
|
@@ -37209,19 +37212,25 @@ class TokenBridge {
|
|
|
37209
37212
|
throw new BridgeError('unable to query contract for flowrate info', BridgeErrorType.INTERNAL_ERROR);
|
|
37210
37213
|
}
|
|
37211
37214
|
const tokensRes = {};
|
|
37212
|
-
|
|
37215
|
+
const withdrawalQueueActivated = contractPromisesRes[0];
|
|
37216
|
+
const withdrawalDelay = contractPromisesRes[1].toNumber();
|
|
37217
|
+
// remove first 2 items from promise all response
|
|
37218
|
+
contractPromisesRes.splice(0, 2);
|
|
37219
|
+
// the remaining items should be sets of 2 per token
|
|
37213
37220
|
for (let i = 0, l = req.tokens.length; i < l; i++) {
|
|
37221
|
+
const shifter = i * 2;
|
|
37214
37222
|
tokensRes[req.tokens[i]] = {
|
|
37215
|
-
capacity: contractPromisesRes[
|
|
37216
|
-
depth: contractPromisesRes[
|
|
37217
|
-
refillTime: contractPromisesRes[
|
|
37218
|
-
refillRate: contractPromisesRes[
|
|
37223
|
+
capacity: contractPromisesRes[shifter].capacity,
|
|
37224
|
+
depth: contractPromisesRes[shifter].depth,
|
|
37225
|
+
refillTime: contractPromisesRes[shifter].refillTime.toNumber(),
|
|
37226
|
+
refillRate: contractPromisesRes[shifter].refillRate,
|
|
37227
|
+
largeTransferThreshold: contractPromisesRes[shifter + 1],
|
|
37219
37228
|
};
|
|
37220
37229
|
}
|
|
37221
37230
|
// Return the token mappings
|
|
37222
37231
|
return {
|
|
37223
|
-
withdrawalQueueActivated
|
|
37224
|
-
withdrawalDelay
|
|
37232
|
+
withdrawalQueueActivated,
|
|
37233
|
+
withdrawalDelay,
|
|
37225
37234
|
tokens: tokensRes,
|
|
37226
37235
|
};
|
|
37227
37236
|
}
|
|
@@ -37268,6 +37277,7 @@ class TokenBridge {
|
|
|
37268
37277
|
canWithdraw: true,
|
|
37269
37278
|
};
|
|
37270
37279
|
}
|
|
37280
|
+
pendingWithdrawals.pending[i].recipient = req.recipient;
|
|
37271
37281
|
pendingWithdrawals.pending[i].withdrawer = pending[i].withdrawer;
|
|
37272
37282
|
pendingWithdrawals.pending[i].token = pending[i].token;
|
|
37273
37283
|
pendingWithdrawals.pending[i].amount = pending[i].amount;
|
|
@@ -37311,6 +37321,7 @@ class TokenBridge {
|
|
|
37311
37321
|
pendingWithdrawal: {
|
|
37312
37322
|
canWithdraw: false,
|
|
37313
37323
|
withdrawer: pending[0].withdrawer,
|
|
37324
|
+
recipient: req.recipient,
|
|
37314
37325
|
token: pending[0].token,
|
|
37315
37326
|
amount: pending[0].amount,
|
|
37316
37327
|
timeoutStart: pending[0].timestamp.toNumber(),
|
|
@@ -37324,6 +37335,7 @@ class TokenBridge {
|
|
|
37324
37335
|
pendingWithdrawal: {
|
|
37325
37336
|
canWithdraw: true,
|
|
37326
37337
|
withdrawer: pending[0].withdrawer,
|
|
37338
|
+
recipient: req.recipient,
|
|
37327
37339
|
token: pending[0].token,
|
|
37328
37340
|
amount: pending[0].amount,
|
|
37329
37341
|
timeoutStart: pending[0].timestamp.toNumber(),
|
|
@@ -37349,10 +37361,38 @@ class TokenBridge {
|
|
|
37349
37361
|
*/
|
|
37350
37362
|
async getTokenMapping(req) {
|
|
37351
37363
|
// eslint-disable-next-line no-console
|
|
37352
|
-
|
|
37364
|
+
if (req.rootToken.toUpperCase() === 'NATIVE'
|
|
37365
|
+
|| req.rootToken === this.config.bridgeContracts.rootChainWrappedETH) {
|
|
37366
|
+
const childBridge = await withBridgeError(async () => {
|
|
37367
|
+
const contract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE, this.config.childProvider);
|
|
37368
|
+
return contract;
|
|
37369
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
37370
|
+
const childETHToken = await childBridge.childETHToken();
|
|
37371
|
+
return {
|
|
37372
|
+
rootToken: req.rootToken,
|
|
37373
|
+
childToken: childETHToken,
|
|
37374
|
+
};
|
|
37375
|
+
}
|
|
37376
|
+
const rootBridge = await withBridgeError(async () => {
|
|
37377
|
+
const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
|
|
37378
|
+
return contract;
|
|
37379
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
37380
|
+
const rootTokenChildAddress = await rootBridge.rootTokenToChildToken(req.rootToken);
|
|
37381
|
+
if (rootTokenChildAddress === AddressZero) {
|
|
37382
|
+
return {
|
|
37383
|
+
rootToken: req.rootToken,
|
|
37384
|
+
childToken: null,
|
|
37385
|
+
};
|
|
37386
|
+
}
|
|
37387
|
+
if (rootTokenChildAddress === req.rootToken) {
|
|
37388
|
+
return {
|
|
37389
|
+
rootToken: req.rootToken,
|
|
37390
|
+
childToken: 'NATIVE',
|
|
37391
|
+
};
|
|
37392
|
+
}
|
|
37353
37393
|
return {
|
|
37354
|
-
rootToken:
|
|
37355
|
-
childToken:
|
|
37394
|
+
rootToken: req.rootToken,
|
|
37395
|
+
childToken: rootTokenChildAddress,
|
|
37356
37396
|
};
|
|
37357
37397
|
}
|
|
37358
37398
|
}
|
|
@@ -41278,12 +41318,14 @@ const validateProviderDefaults = {
|
|
|
41278
41318
|
* @property {string} SUCCESS - If checkout succeeded as the transactions were able to be processed
|
|
41279
41319
|
* @property {string} FAILED - If checkout failed due to transactions not settling on chain
|
|
41280
41320
|
* @property {string} INSUFFICIENT_FUNDS - If checkout failed due to insufficient funds
|
|
41321
|
+
* @property {string} FULFILLMENTS_UNSETTLED - If checkout succeeded but the fulfillment transactions are not yet settled
|
|
41281
41322
|
*/
|
|
41282
41323
|
var CheckoutStatus;
|
|
41283
41324
|
(function (CheckoutStatus) {
|
|
41284
41325
|
CheckoutStatus["SUCCESS"] = "SUCCESS";
|
|
41285
41326
|
CheckoutStatus["FAILED"] = "FAILED";
|
|
41286
41327
|
CheckoutStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
41328
|
+
CheckoutStatus["FULFILLMENTS_UNSETTLED"] = "FULFILLMENTS_UNSETTLED";
|
|
41287
41329
|
})(CheckoutStatus || (CheckoutStatus = {}));
|
|
41288
41330
|
/**
|
|
41289
41331
|
* An enum representing the item types
|
|
@@ -41594,7 +41636,7 @@ async function switchWalletNetwork(config, web3Provider, chainId) {
|
|
|
41594
41636
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
41595
41637
|
}
|
|
41596
41638
|
catch (err) {
|
|
41597
|
-
throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
|
|
41639
|
+
throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
|
|
41598
41640
|
}
|
|
41599
41641
|
}
|
|
41600
41642
|
else {
|
|
@@ -41958,7 +42000,7 @@ const GAS_OVERRIDES = {
|
|
|
41958
42000
|
maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
|
|
41959
42001
|
};
|
|
41960
42002
|
|
|
41961
|
-
const SDK_VERSION_MARKER = '0.44.
|
|
42003
|
+
const SDK_VERSION_MARKER = '0.44.3';
|
|
41962
42004
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
41963
42005
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
41964
42006
|
|
|
@@ -41988,8 +42030,8 @@ class RemoteConfigFetcher {
|
|
|
41988
42030
|
try {
|
|
41989
42031
|
responseData = JSON.parse(response.data);
|
|
41990
42032
|
}
|
|
41991
|
-
catch (
|
|
41992
|
-
throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
|
|
42033
|
+
catch (err) {
|
|
42034
|
+
throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR, { error: err });
|
|
41993
42035
|
}
|
|
41994
42036
|
}
|
|
41995
42037
|
return responseData;
|
|
@@ -42002,7 +42044,7 @@ class RemoteConfigFetcher {
|
|
|
42002
42044
|
response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
|
|
42003
42045
|
}
|
|
42004
42046
|
catch (err) {
|
|
42005
|
-
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
|
|
42047
|
+
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
42006
42048
|
}
|
|
42007
42049
|
// Ensure that the configuration is valid
|
|
42008
42050
|
this.configCache = this.parseResponse(response);
|
|
@@ -42016,7 +42058,7 @@ class RemoteConfigFetcher {
|
|
|
42016
42058
|
response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
|
|
42017
42059
|
}
|
|
42018
42060
|
catch (err) {
|
|
42019
|
-
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
|
|
42061
|
+
throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
42020
42062
|
}
|
|
42021
42063
|
// Ensure that the configuration is valid
|
|
42022
42064
|
this.tokensCache = this.parseResponse(response);
|
|
@@ -42379,7 +42421,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
42379
42421
|
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
42380
42422
|
// or simply an incorrect wallet address was provided.
|
|
42381
42423
|
if (err?.code !== globalAxios$1.HttpStatusCode.NotFound) {
|
|
42382
|
-
throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
|
|
42424
|
+
throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
|
|
42383
42425
|
}
|
|
42384
42426
|
}
|
|
42385
42427
|
};
|
|
@@ -42398,7 +42440,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
42398
42440
|
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
42399
42441
|
// or simply an incorrect wallet address was provided.
|
|
42400
42442
|
if (err?.code !== globalAxios$1.HttpStatusCode.NotFound) {
|
|
42401
|
-
throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
|
|
42443
|
+
throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
|
|
42402
42444
|
}
|
|
42403
42445
|
}
|
|
42404
42446
|
};
|
|
@@ -42511,6 +42553,7 @@ async function checkIsWalletConnected(web3Provider) {
|
|
|
42511
42553
|
}
|
|
42512
42554
|
catch (err) {
|
|
42513
42555
|
throw new CheckoutError('Check wallet connection request failed', CheckoutErrorType.PROVIDER_REQUEST_FAILED_ERROR, {
|
|
42556
|
+
error: err,
|
|
42514
42557
|
rpcMethod: WalletAction.CHECK_CONNECTION,
|
|
42515
42558
|
});
|
|
42516
42559
|
}
|
|
@@ -42603,7 +42646,7 @@ async function validateProvider(config, web3Provider, validateProviderOptions) {
|
|
|
42603
42646
|
}
|
|
42604
42647
|
}
|
|
42605
42648
|
catch (err) {
|
|
42606
|
-
throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
|
|
42649
|
+
throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR, { error: err });
|
|
42607
42650
|
}
|
|
42608
42651
|
if (web3ChainId !== underlyingChainId && !options.allowMistmatchedChainId) {
|
|
42609
42652
|
throw new CheckoutError('Your wallet has changed network, please switch to a supported network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
|
|
@@ -42655,15 +42698,15 @@ const sendTransaction = async (web3Provider, transaction) => {
|
|
|
42655
42698
|
}
|
|
42656
42699
|
catch (err) {
|
|
42657
42700
|
if (err.code === ethers.ethers.errors.INSUFFICIENT_FUNDS) {
|
|
42658
|
-
throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS);
|
|
42701
|
+
throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS, { error: err });
|
|
42659
42702
|
}
|
|
42660
42703
|
if (err.code === ethers.ethers.errors.ACTION_REJECTED) {
|
|
42661
|
-
throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
|
|
42704
|
+
throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
|
|
42662
42705
|
}
|
|
42663
42706
|
if (err.code === ethers.ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
|
|
42664
|
-
throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
|
|
42707
|
+
throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
|
|
42665
42708
|
}
|
|
42666
|
-
throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED);
|
|
42709
|
+
throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED, { error: err });
|
|
42667
42710
|
}
|
|
42668
42711
|
};
|
|
42669
42712
|
|
|
@@ -42676,6 +42719,8 @@ async function getBridgeFeeEstimate$1(tokenBridge, fromChainId, toChainId, confi
|
|
|
42676
42719
|
gasMultiplier: 1.1,
|
|
42677
42720
|
sourceChainId: fromChainId.toString(),
|
|
42678
42721
|
destinationChainId: toChainId.toString(),
|
|
42722
|
+
token: NATIVE.toUpperCase(),
|
|
42723
|
+
amount: ethers.BigNumber.from(0),
|
|
42679
42724
|
});
|
|
42680
42725
|
}
|
|
42681
42726
|
|
|
@@ -42755,6 +42800,7 @@ async function bridgeToL2GasEstimator(readOnlyProviders, config) {
|
|
|
42755
42800
|
gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
|
|
42756
42801
|
fees: {
|
|
42757
42802
|
sourceChainGas: ethers.BigNumber.from(0),
|
|
42803
|
+
approvalFee: ethers.BigNumber.from(0),
|
|
42758
42804
|
bridgeFee: ethers.BigNumber.from(0),
|
|
42759
42805
|
imtblFee: ethers.BigNumber.from(0),
|
|
42760
42806
|
totalFees: ethers.BigNumber.from(0),
|
|
@@ -42904,7 +42950,7 @@ const getERC20Allowance = async (provider, ownerAddress, contractAddress, spende
|
|
|
42904
42950
|
return await contract.allowance(ownerAddress, spenderAddress);
|
|
42905
42951
|
}
|
|
42906
42952
|
catch (err) {
|
|
42907
|
-
throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
|
|
42953
|
+
throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
|
|
42908
42954
|
}
|
|
42909
42955
|
};
|
|
42910
42956
|
// Returns the approval transaction for the ERC20 that the owner can sign
|
|
@@ -42917,8 +42963,8 @@ const getERC20ApprovalTransaction = async (provider, ownerAddress, contractAddre
|
|
|
42917
42963
|
approveTransaction.from = ownerAddress;
|
|
42918
42964
|
return approveTransaction;
|
|
42919
42965
|
}
|
|
42920
|
-
catch {
|
|
42921
|
-
throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
|
|
42966
|
+
catch (err) {
|
|
42967
|
+
throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
|
|
42922
42968
|
}
|
|
42923
42969
|
};
|
|
42924
42970
|
const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
@@ -42990,7 +43036,12 @@ const getERC721ApprovedForAll = async (provider, ownerAddress, contractAddress,
|
|
|
42990
43036
|
return await contract.isApprovedForAll(ownerAddress, spenderAddress);
|
|
42991
43037
|
}
|
|
42992
43038
|
catch (err) {
|
|
42993
|
-
throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43039
|
+
throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43040
|
+
ownerAddress,
|
|
43041
|
+
contractAddress,
|
|
43042
|
+
spenderAddress,
|
|
43043
|
+
error: err,
|
|
43044
|
+
});
|
|
42994
43045
|
}
|
|
42995
43046
|
};
|
|
42996
43047
|
// Returns a populated transaction to approve the ERC721 for the spender.
|
|
@@ -43004,7 +43055,11 @@ const getApproveTransaction = async (provider, ownerAddress, contractAddress, sp
|
|
|
43004
43055
|
}
|
|
43005
43056
|
catch (err) {
|
|
43006
43057
|
throw new CheckoutError('Failed to get the approval transaction for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43007
|
-
id: id.toString(),
|
|
43058
|
+
id: id.toString(),
|
|
43059
|
+
contractAddress,
|
|
43060
|
+
spenderAddress,
|
|
43061
|
+
ownerAddress,
|
|
43062
|
+
error: err,
|
|
43008
43063
|
});
|
|
43009
43064
|
}
|
|
43010
43065
|
};
|
|
@@ -43016,7 +43071,11 @@ const getERC721ApprovedAddress = async (provider, contractAddress, id) => {
|
|
|
43016
43071
|
return await contract.getApproved(id);
|
|
43017
43072
|
}
|
|
43018
43073
|
catch (err) {
|
|
43019
|
-
throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43074
|
+
throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
|
|
43075
|
+
id: id.toString(),
|
|
43076
|
+
contractAddress,
|
|
43077
|
+
error: err,
|
|
43078
|
+
});
|
|
43020
43079
|
}
|
|
43021
43080
|
};
|
|
43022
43081
|
const convertIdToNumber = (id, contractAddress) => {
|
|
@@ -43344,8 +43403,8 @@ const getTokenBalances = async (config, provider, ownerAddress, itemRequirements
|
|
|
43344
43403
|
const { balances } = await getAllBalances(config, provider, ownerAddress, getL2ChainId(config));
|
|
43345
43404
|
return balances.filter((balance) => tokenMap.get((balance.token.address || NATIVE).toLocaleLowerCase()));
|
|
43346
43405
|
}
|
|
43347
|
-
catch (
|
|
43348
|
-
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR);
|
|
43406
|
+
catch (err) {
|
|
43407
|
+
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR, { error: err });
|
|
43349
43408
|
}
|
|
43350
43409
|
};
|
|
43351
43410
|
/**
|
|
@@ -43383,8 +43442,8 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
43383
43442
|
});
|
|
43384
43443
|
});
|
|
43385
43444
|
}
|
|
43386
|
-
catch (
|
|
43387
|
-
throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR);
|
|
43445
|
+
catch (err) {
|
|
43446
|
+
throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR, { error: err });
|
|
43388
43447
|
}
|
|
43389
43448
|
return erc721Balances;
|
|
43390
43449
|
};
|
|
@@ -43454,7 +43513,7 @@ const estimateGas = async (provider, transaction) => {
|
|
|
43454
43513
|
return await provider.estimateGas(transaction);
|
|
43455
43514
|
}
|
|
43456
43515
|
catch (err) {
|
|
43457
|
-
throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
|
|
43516
|
+
throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
|
|
43458
43517
|
}
|
|
43459
43518
|
};
|
|
43460
43519
|
const getGasItemRequirement = (gas, transactionOrGas) => {
|
|
@@ -43518,14 +43577,14 @@ const availabilityService = (isDevelopment, isProduction) => {
|
|
|
43518
43577
|
try {
|
|
43519
43578
|
response = await globalAxios$1.post(`${postEndpoint()}/v1/availability/checkout/swap`);
|
|
43520
43579
|
}
|
|
43521
|
-
catch (
|
|
43580
|
+
catch (err) {
|
|
43522
43581
|
// The request was made and the server responded with a status code
|
|
43523
43582
|
// that falls out of the range of 2xx
|
|
43524
|
-
response =
|
|
43583
|
+
response = err.response;
|
|
43525
43584
|
// If 403 then the service is geo-blocked
|
|
43526
43585
|
if (response.status === 403)
|
|
43527
43586
|
return false;
|
|
43528
|
-
throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR);
|
|
43587
|
+
throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR, { error: err });
|
|
43529
43588
|
}
|
|
43530
43589
|
return true;
|
|
43531
43590
|
};
|
|
@@ -44036,7 +44095,7 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
|
|
|
44036
44095
|
};
|
|
44037
44096
|
}
|
|
44038
44097
|
catch (err) {
|
|
44039
|
-
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
44098
|
+
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { error: err });
|
|
44040
44099
|
}
|
|
44041
44100
|
};
|
|
44042
44101
|
|
|
@@ -44686,7 +44745,7 @@ const routingCalculator = async (config, ownerAddress, balanceRequirements, avai
|
|
|
44686
44745
|
readOnlyProviders = await createReadOnlyProviders(config);
|
|
44687
44746
|
}
|
|
44688
44747
|
catch (err) {
|
|
44689
|
-
throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, {
|
|
44748
|
+
throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, { error: err });
|
|
44690
44749
|
}
|
|
44691
44750
|
const tokenBalances = await measureAsyncExecution(config, 'Time to get token balances inside router', getAllTokenBalances(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
|
|
44692
44751
|
const allowList = await measureAsyncExecution(config, 'Time to get routing allowlist', allowListCheck(config, tokenBalances, availableRoutingOptions));
|
|
@@ -44809,9 +44868,7 @@ const signApprovalTransactions = async (provider, approvalTransactions) => {
|
|
|
44809
44868
|
receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
|
|
44810
44869
|
}
|
|
44811
44870
|
catch (err) {
|
|
44812
|
-
throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, {
|
|
44813
|
-
message: err.message,
|
|
44814
|
-
});
|
|
44871
|
+
throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, { error: err });
|
|
44815
44872
|
}
|
|
44816
44873
|
for (const receipt of receipts) {
|
|
44817
44874
|
if (receipt.status === 0) {
|
|
@@ -44833,9 +44890,7 @@ const signFulfillmentTransactions = async (provider, fulfillmentTransactions) =>
|
|
|
44833
44890
|
receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
|
|
44834
44891
|
}
|
|
44835
44892
|
catch (err) {
|
|
44836
|
-
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
|
|
44837
|
-
message: err.message,
|
|
44838
|
-
});
|
|
44893
|
+
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, { error: err });
|
|
44839
44894
|
}
|
|
44840
44895
|
for (const receipt of receipts) {
|
|
44841
44896
|
if (receipt.status === 0) {
|
|
@@ -44861,9 +44916,7 @@ const signMessage = async (provider, unsignedMessage) => {
|
|
|
44861
44916
|
};
|
|
44862
44917
|
}
|
|
44863
44918
|
catch (err) {
|
|
44864
|
-
throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, {
|
|
44865
|
-
message: err.message,
|
|
44866
|
-
});
|
|
44919
|
+
throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, { error: err });
|
|
44867
44920
|
}
|
|
44868
44921
|
};
|
|
44869
44922
|
|
|
@@ -45019,7 +45072,9 @@ const getTransactionOrGas = (gasLimit, fulfillmentTransactions) => {
|
|
|
45019
45072
|
},
|
|
45020
45073
|
};
|
|
45021
45074
|
};
|
|
45022
|
-
const buy = async (config, provider, orders
|
|
45075
|
+
const buy = async (config, provider, orders, overrides = {
|
|
45076
|
+
waitFulfillmentSettlements: true,
|
|
45077
|
+
}) => {
|
|
45023
45078
|
if (orders.length === 0) {
|
|
45024
45079
|
throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR);
|
|
45025
45080
|
}
|
|
@@ -45044,8 +45099,8 @@ const buy = async (config, provider, orders) => {
|
|
|
45044
45099
|
}
|
|
45045
45100
|
catch (err) {
|
|
45046
45101
|
throw new CheckoutError('An error occurred while getting the order listing', CheckoutErrorType.GET_ORDER_LISTING_ERROR, {
|
|
45102
|
+
error: err,
|
|
45047
45103
|
orderId: id,
|
|
45048
|
-
message: err.message,
|
|
45049
45104
|
});
|
|
45050
45105
|
}
|
|
45051
45106
|
if (order.result.buy.length === 0) {
|
|
@@ -45084,7 +45139,7 @@ const buy = async (config, provider, orders) => {
|
|
|
45084
45139
|
if (!err.message.includes('The fulfiller does not have the balances needed to fulfill')) {
|
|
45085
45140
|
throw new CheckoutError('Error occurred while trying to fulfill the order', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
|
|
45086
45141
|
orderId: id,
|
|
45087
|
-
|
|
45142
|
+
error: err,
|
|
45088
45143
|
});
|
|
45089
45144
|
}
|
|
45090
45145
|
}
|
|
@@ -45143,22 +45198,37 @@ const buy = async (config, provider, orders) => {
|
|
|
45143
45198
|
}
|
|
45144
45199
|
}
|
|
45145
45200
|
catch (err) {
|
|
45146
|
-
throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
|
|
45147
|
-
message: err.message,
|
|
45148
|
-
});
|
|
45201
|
+
throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, { error: err });
|
|
45149
45202
|
}
|
|
45150
|
-
|
|
45151
|
-
|
|
45203
|
+
if (overrides.waitFulfillmentSettlements) {
|
|
45204
|
+
const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
|
|
45205
|
+
if (fulfillmentResult.type === SignTransactionStatusType.FAILED) {
|
|
45206
|
+
return {
|
|
45207
|
+
status: CheckoutStatus.FAILED,
|
|
45208
|
+
transactionHash: fulfillmentResult.transactionHash,
|
|
45209
|
+
reason: fulfillmentResult.reason,
|
|
45210
|
+
smartCheckoutResult,
|
|
45211
|
+
};
|
|
45212
|
+
}
|
|
45152
45213
|
return {
|
|
45153
|
-
status: CheckoutStatus.
|
|
45154
|
-
transactionHash: fulfillmentResult.transactionHash,
|
|
45155
|
-
reason: fulfillmentResult.reason,
|
|
45214
|
+
status: CheckoutStatus.SUCCESS,
|
|
45156
45215
|
smartCheckoutResult,
|
|
45157
45216
|
};
|
|
45158
45217
|
}
|
|
45218
|
+
let transactions;
|
|
45219
|
+
try {
|
|
45220
|
+
const response = await Promise.all(unsignedFulfillmentTransactions.map((transaction) => sendTransaction(provider, transaction)));
|
|
45221
|
+
transactions = response.map((result) => result.transactionResponse);
|
|
45222
|
+
}
|
|
45223
|
+
catch (err) {
|
|
45224
|
+
throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
|
|
45225
|
+
message: err.message,
|
|
45226
|
+
});
|
|
45227
|
+
}
|
|
45159
45228
|
return {
|
|
45160
|
-
status: CheckoutStatus.
|
|
45229
|
+
status: CheckoutStatus.FULFILLMENTS_UNSETTLED,
|
|
45161
45230
|
smartCheckoutResult,
|
|
45231
|
+
transactions,
|
|
45162
45232
|
};
|
|
45163
45233
|
}
|
|
45164
45234
|
return {
|
|
@@ -45183,7 +45253,7 @@ const cancel = async (config, provider, orderIds) => {
|
|
|
45183
45253
|
catch (err) {
|
|
45184
45254
|
throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
|
|
45185
45255
|
orderId,
|
|
45186
|
-
|
|
45256
|
+
error: err,
|
|
45187
45257
|
});
|
|
45188
45258
|
}
|
|
45189
45259
|
const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
|
|
@@ -45252,7 +45322,7 @@ const sell = async (config, provider, orders) => {
|
|
|
45252
45322
|
}
|
|
45253
45323
|
catch (err) {
|
|
45254
45324
|
throw new CheckoutError('An error occurred while preparing the listing', CheckoutErrorType.PREPARE_ORDER_LISTING_ERROR, {
|
|
45255
|
-
|
|
45325
|
+
error: err,
|
|
45256
45326
|
id: sellToken.id,
|
|
45257
45327
|
collectionAddress: sellToken.collectionAddress,
|
|
45258
45328
|
});
|
|
@@ -45308,7 +45378,7 @@ const sell = async (config, provider, orders) => {
|
|
|
45308
45378
|
}
|
|
45309
45379
|
catch (err) {
|
|
45310
45380
|
throw new CheckoutError('An error occurred while creating the listing', CheckoutErrorType.CREATE_ORDER_LISTING_ERROR, {
|
|
45311
|
-
|
|
45381
|
+
error: err,
|
|
45312
45382
|
collectionId: sellToken.id,
|
|
45313
45383
|
collectionAddress: sellToken.collectionAddress,
|
|
45314
45384
|
});
|
|
@@ -45605,7 +45675,7 @@ class Checkout {
|
|
|
45605
45675
|
}
|
|
45606
45676
|
}
|
|
45607
45677
|
catch (err) {
|
|
45608
|
-
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, {
|
|
45678
|
+
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
45609
45679
|
}
|
|
45610
45680
|
});
|
|
45611
45681
|
return factory;
|
|
@@ -45735,7 +45805,7 @@ class Checkout {
|
|
|
45735
45805
|
console.warn('This endpoint currently only processes the first order in the array.');
|
|
45736
45806
|
}
|
|
45737
45807
|
const web3Provider = await validateProvider(this.config, params.provider);
|
|
45738
|
-
return await buy(this.config, web3Provider, params.orders);
|
|
45808
|
+
return await buy(this.config, web3Provider, params.orders, params.overrides);
|
|
45739
45809
|
}
|
|
45740
45810
|
/**
|
|
45741
45811
|
* Determines the requirements for performing a sell.
|
|
@@ -45771,8 +45841,8 @@ class Checkout {
|
|
|
45771
45841
|
try {
|
|
45772
45842
|
itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
|
|
45773
45843
|
}
|
|
45774
|
-
catch (
|
|
45775
|
-
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
|
|
45844
|
+
catch (err) {
|
|
45845
|
+
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR, { error: err });
|
|
45776
45846
|
}
|
|
45777
45847
|
return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
45778
45848
|
}
|