@imtbl/sdk 0.6.0-alpha → 0.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +20 -4
- package/dist/checkout_sdk.js +2212 -122
- package/dist/checkout_widgets.d.ts +10498 -154
- package/dist/checkout_widgets.js +57 -8
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +239 -71
- package/dist/index.d.ts +77 -16
- package/dist/index.js +239 -71
- package/dist/orderbook.d.ts +30 -11
- package/dist/orderbook.js +61 -33
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2420,7 +2420,7 @@ class MultiRollupApiClients {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
|
|
2422
2422
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2423
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
2423
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.7.0-alpha.1' };
|
|
2424
2424
|
const createConfig = ({ basePath, headers, }) => {
|
|
2425
2425
|
if (!basePath.trim()) {
|
|
2426
2426
|
throw Error('basePath can not be empty');
|
|
@@ -2480,7 +2480,7 @@ class APIError extends Error {
|
|
|
2480
2480
|
|
|
2481
2481
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2482
2482
|
const defaultHeaders = {
|
|
2483
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
2483
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.7.0-alpha.1',
|
|
2484
2484
|
};
|
|
2485
2485
|
/**
|
|
2486
2486
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -2752,7 +2752,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2752
2752
|
chainID,
|
|
2753
2753
|
coreContractAddress,
|
|
2754
2754
|
registrationContractAddress,
|
|
2755
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
2755
|
+
sdkVersion: 'ts-immutable-sdk-0.7.0-alpha.1',
|
|
2756
2756
|
});
|
|
2757
2757
|
/**
|
|
2758
2758
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9491,6 +9491,21 @@ var OrderStatus;
|
|
|
9491
9491
|
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
9492
9492
|
})(OrderStatus || (OrderStatus = {}));
|
|
9493
9493
|
|
|
9494
|
+
var TransactionPurpose;
|
|
9495
|
+
(function (TransactionPurpose) {
|
|
9496
|
+
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
9497
|
+
TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
|
|
9498
|
+
})(TransactionPurpose || (TransactionPurpose = {}));
|
|
9499
|
+
var SignablePurpose;
|
|
9500
|
+
(function (SignablePurpose) {
|
|
9501
|
+
SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
|
|
9502
|
+
})(SignablePurpose || (SignablePurpose = {}));
|
|
9503
|
+
var ActionType;
|
|
9504
|
+
(function (ActionType) {
|
|
9505
|
+
ActionType["TRANSACTION"] = "TRANSACTION";
|
|
9506
|
+
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
9507
|
+
})(ActionType || (ActionType = {}));
|
|
9508
|
+
|
|
9494
9509
|
/* eslint-disable */
|
|
9495
9510
|
// TODO: Resolve these from seaport-js.
|
|
9496
9511
|
// There is some bundling issue that is preventing this from working
|
|
@@ -9567,12 +9582,14 @@ function getOrderComponentsFromMessage(orderMessage) {
|
|
|
9567
9582
|
|
|
9568
9583
|
// Add 20% more gas than estimate to prevent out of gas errors
|
|
9569
9584
|
// This can always be overwritten by the user signing the transaction
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
.
|
|
9575
|
-
|
|
9585
|
+
function prepareTransaction(transactionMethods) {
|
|
9586
|
+
return async () => {
|
|
9587
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
9588
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
9589
|
+
transaction.gasLimit = transaction.gasLimit
|
|
9590
|
+
.add(transaction.gasLimit.div(5));
|
|
9591
|
+
return transaction;
|
|
9592
|
+
};
|
|
9576
9593
|
}
|
|
9577
9594
|
|
|
9578
9595
|
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
@@ -9654,31 +9671,39 @@ class Seaport {
|
|
|
9654
9671
|
this.zoneContractAddress = zoneContractAddress;
|
|
9655
9672
|
}
|
|
9656
9673
|
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
9657
|
-
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
9658
|
-
|
|
9659
|
-
const approvalAction =
|
|
9674
|
+
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
9675
|
+
const listingActions = [];
|
|
9676
|
+
const approvalAction = seaportActions
|
|
9660
9677
|
.find((action) => action.type === 'approval');
|
|
9661
9678
|
if (approvalAction) {
|
|
9662
|
-
|
|
9679
|
+
listingActions.push({
|
|
9680
|
+
type: ActionType.TRANSACTION,
|
|
9681
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
9682
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
9683
|
+
});
|
|
9663
9684
|
}
|
|
9664
|
-
const createAction =
|
|
9685
|
+
const createAction = seaportActions
|
|
9665
9686
|
.find((action) => action.type === 'create');
|
|
9666
9687
|
if (!createAction) {
|
|
9667
9688
|
throw new Error('No create order action found');
|
|
9668
9689
|
}
|
|
9669
9690
|
const orderMessageToSign = await createAction.getMessageToSign();
|
|
9670
9691
|
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
9692
|
+
listingActions.push({
|
|
9693
|
+
type: ActionType.SIGNABLE,
|
|
9694
|
+
purpose: SignablePurpose.CREATE_LISTING,
|
|
9695
|
+
message: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
9696
|
+
});
|
|
9671
9697
|
return {
|
|
9672
|
-
|
|
9673
|
-
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
9698
|
+
actions: listingActions,
|
|
9674
9699
|
orderComponents,
|
|
9675
9700
|
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
9676
9701
|
};
|
|
9677
9702
|
}
|
|
9678
|
-
async
|
|
9703
|
+
async fulfillOrder(order, account) {
|
|
9679
9704
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9680
9705
|
const seaportLib = this.getSeaportLib(order);
|
|
9681
|
-
const { actions } = await seaportLib.fulfillOrders({
|
|
9706
|
+
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
9682
9707
|
accountAddress: account,
|
|
9683
9708
|
fulfillOrderDetails: [{
|
|
9684
9709
|
order: {
|
|
@@ -9688,28 +9713,33 @@ class Seaport {
|
|
|
9688
9713
|
extraData: order.protocol_data.operator_signature,
|
|
9689
9714
|
}],
|
|
9690
9715
|
});
|
|
9691
|
-
|
|
9692
|
-
const approvalAction =
|
|
9716
|
+
const fulfillmentActions = [];
|
|
9717
|
+
const approvalAction = seaportActions
|
|
9693
9718
|
.find((action) => action.type === 'approval');
|
|
9694
9719
|
if (approvalAction) {
|
|
9695
|
-
|
|
9720
|
+
fulfillmentActions.push({
|
|
9721
|
+
type: ActionType.TRANSACTION,
|
|
9722
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
9723
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
9724
|
+
});
|
|
9696
9725
|
}
|
|
9697
|
-
const
|
|
9726
|
+
const fulfilOrderAction = seaportActions
|
|
9698
9727
|
.find((action) => action.type === 'exchange');
|
|
9699
|
-
if (!
|
|
9728
|
+
if (!fulfilOrderAction) {
|
|
9700
9729
|
throw new Error('No exchange action found');
|
|
9701
9730
|
}
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
};
|
|
9731
|
+
fulfillmentActions.push({
|
|
9732
|
+
type: ActionType.TRANSACTION,
|
|
9733
|
+
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
9734
|
+
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
9735
|
+
});
|
|
9736
|
+
return { actions: fulfillmentActions };
|
|
9707
9737
|
}
|
|
9708
9738
|
async cancelOrder(order, account) {
|
|
9709
9739
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9710
9740
|
const seaportLib = this.getSeaportLib(order);
|
|
9711
9741
|
const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
|
|
9712
|
-
return prepareTransaction(cancellationTransaction);
|
|
9742
|
+
return prepareTransaction(cancellationTransaction)();
|
|
9713
9743
|
}
|
|
9714
9744
|
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
9715
9745
|
const orderCounter = order.protocol_data.counter;
|
|
@@ -9873,9 +9903,9 @@ function getOrderbookConfig(environment) {
|
|
|
9873
9903
|
switch (environment) {
|
|
9874
9904
|
case Environment$1.SANDBOX:
|
|
9875
9905
|
return {
|
|
9876
|
-
seaportContractAddress: '
|
|
9877
|
-
zoneContractAddress: '
|
|
9878
|
-
apiEndpoint: 'https://
|
|
9906
|
+
seaportContractAddress: '0x410000346E270aDbC89b2b688177d3AE76348dE9',
|
|
9907
|
+
zoneContractAddress: '0x979C2aCA989A56554Eb63E01e576E3179Cdad5A0',
|
|
9908
|
+
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
9879
9909
|
chainName: TESTNET_CHAIN_NAME,
|
|
9880
9910
|
provider: new ethers.providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
9881
9911
|
};
|
|
@@ -10917,7 +10947,7 @@ class Orderbook {
|
|
|
10917
10947
|
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
10918
10948
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
10919
10949
|
}
|
|
10920
|
-
return this.seaport.
|
|
10950
|
+
return this.seaport.fulfillOrder(orderResult.result, takerAddress);
|
|
10921
10951
|
}
|
|
10922
10952
|
/**
|
|
10923
10953
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
@@ -10941,12 +10971,12 @@ class Orderbook {
|
|
|
10941
10971
|
}
|
|
10942
10972
|
}
|
|
10943
10973
|
|
|
10944
|
-
const module$1 = 'orderbook';
|
|
10945
|
-
|
|
10946
10974
|
var orderbook = /*#__PURE__*/Object.freeze({
|
|
10947
10975
|
__proto__: null,
|
|
10976
|
+
get ActionType () { return ActionType; },
|
|
10948
10977
|
Orderbook: Orderbook,
|
|
10949
|
-
|
|
10978
|
+
get SignablePurpose () { return SignablePurpose; },
|
|
10979
|
+
get TransactionPurpose () { return TransactionPurpose; }
|
|
10950
10980
|
});
|
|
10951
10981
|
|
|
10952
10982
|
function isChainValid(chainID, config) {
|
|
@@ -27464,6 +27494,19 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
|
27464
27494
|
];
|
|
27465
27495
|
|
|
27466
27496
|
|
|
27497
|
+
var $aa144554f9ef124b$export$1fc8f52ad1810e52;
|
|
27498
|
+
(function(ItemType) {
|
|
27499
|
+
ItemType["NATIVE"] = "NATIVE";
|
|
27500
|
+
ItemType["ERC20"] = "ERC20";
|
|
27501
|
+
ItemType["ERC721"] = "ERC721";
|
|
27502
|
+
})($aa144554f9ef124b$export$1fc8f52ad1810e52 || ($aa144554f9ef124b$export$1fc8f52ad1810e52 = {}));
|
|
27503
|
+
var $aa144554f9ef124b$export$537fa3efd10ed435;
|
|
27504
|
+
(function(GasTokenType) {
|
|
27505
|
+
GasTokenType["NATIVE"] = "NATIVE";
|
|
27506
|
+
GasTokenType["ERC20"] = "ERC20";
|
|
27507
|
+
})($aa144554f9ef124b$export$537fa3efd10ed435 || ($aa144554f9ef124b$export$537fa3efd10ed435 = {}));
|
|
27508
|
+
|
|
27509
|
+
|
|
27467
27510
|
/**
|
|
27468
27511
|
* Enum representing different chain IDs.
|
|
27469
27512
|
* @enum {number}
|
|
@@ -27546,6 +27589,7 @@ var $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
|
27546
27589
|
var $e768639828688ca3$export$2d7a51a18d87e21d;
|
|
27547
27590
|
(function(WalletProviderName) {
|
|
27548
27591
|
WalletProviderName["METAMASK"] = "metamask";
|
|
27592
|
+
WalletProviderName["PASSPORT"] = "passport";
|
|
27549
27593
|
})($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
|
|
27550
27594
|
const $e768639828688ca3$export$44dde05038008549 = {
|
|
27551
27595
|
allowMistmatchedChainId: false,
|
|
@@ -27561,10 +27605,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
|
27561
27605
|
[(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
27562
27606
|
[(Environment$1).PRODUCTION]: "https://checkout-api.immutable.com"
|
|
27563
27607
|
};
|
|
27564
|
-
const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
|
|
27565
|
-
[(Environment$1).SANDBOX]: "https://zkevm-rpc.sandbox.imtbl.com",
|
|
27566
|
-
[(Environment$1).PRODUCTION]: "https://zkevm-rpc.imtbl.com"
|
|
27567
|
-
};
|
|
27568
27608
|
const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
27569
27609
|
[
|
|
27570
27610
|
($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
|
|
@@ -27694,6 +27734,8 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
|
|
|
27694
27734
|
CheckoutErrorType["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
27695
27735
|
CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
27696
27736
|
CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
|
|
27737
|
+
CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
|
|
27738
|
+
CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
|
|
27697
27739
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
27698
27740
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
27699
27741
|
message;
|
|
@@ -28140,6 +28182,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
|
|
|
28140
28182
|
|
|
28141
28183
|
|
|
28142
28184
|
|
|
28185
|
+
|
|
28143
28186
|
async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
|
|
28144
28187
|
const rootChainProvider = readOnlyProviders.get(fromChainId);
|
|
28145
28188
|
const childChainProvider = readOnlyProviders.get(toChainId);
|
|
@@ -28168,6 +28211,13 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
|
|
|
28168
28211
|
overrides: dexConfig?.overrides
|
|
28169
28212
|
});
|
|
28170
28213
|
}
|
|
28214
|
+
async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
|
|
28215
|
+
return new (Orderbook)({
|
|
28216
|
+
baseConfig: {
|
|
28217
|
+
environment: config.environment
|
|
28218
|
+
}
|
|
28219
|
+
});
|
|
28220
|
+
}
|
|
28171
28221
|
|
|
28172
28222
|
|
|
28173
28223
|
|
|
@@ -28234,23 +28284,10 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
|
|
|
28234
28284
|
this.message = message;
|
|
28235
28285
|
}
|
|
28236
28286
|
}
|
|
28237
|
-
const $4013c5c91bb535f6$var$networkMap = (prod, dev
|
|
28238
|
-
|
|
28239
|
-
if (
|
|
28240
|
-
|
|
28241
|
-
networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
|
|
28242
|
-
if (local) {
|
|
28243
|
-
const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
|
|
28244
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).PRODUCTION]);
|
|
28245
|
-
}
|
|
28246
|
-
} else {
|
|
28247
|
-
networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
|
|
28248
|
-
if (local) {
|
|
28249
|
-
const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
|
|
28250
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).SANDBOX]);
|
|
28251
|
-
}
|
|
28252
|
-
}
|
|
28253
|
-
return networks;
|
|
28287
|
+
const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
|
|
28288
|
+
if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
|
|
28289
|
+
if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
|
|
28290
|
+
return $d85ad1457a3f1a83$export$3e81fc0987227f10;
|
|
28254
28291
|
};
|
|
28255
28292
|
const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
|
|
28256
28293
|
// DevMode and Sandbox will both use Sepolia.
|
|
@@ -28268,11 +28305,6 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
28268
28305
|
// This will be used to get around the lack of
|
|
28269
28306
|
// Environment.DEVELOPMENT
|
|
28270
28307
|
isDevelopment = false;
|
|
28271
|
-
// This is a hidden feature that is only available
|
|
28272
|
-
// when building the project from source code.
|
|
28273
|
-
// This will be used to get around the lack of
|
|
28274
|
-
// Environment.LOCAL_DEVELOPMENT
|
|
28275
|
-
isLocal = false;
|
|
28276
28308
|
isProduction;
|
|
28277
28309
|
remote;
|
|
28278
28310
|
environment;
|
|
@@ -28282,7 +28314,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
28282
28314
|
this.environment = config.baseConfig.environment;
|
|
28283
28315
|
// Developer mode will super set any environment configuration
|
|
28284
28316
|
this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
|
|
28285
|
-
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment
|
|
28317
|
+
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
|
|
28286
28318
|
this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
|
|
28287
28319
|
isDevelopment: this.isDevelopment,
|
|
28288
28320
|
isProduction: this.isProduction
|
|
@@ -28392,6 +28424,84 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
28392
28424
|
|
|
28393
28425
|
|
|
28394
28426
|
|
|
28427
|
+
const $c147333b1f360629$export$92589613aaa38e1f = 300000;
|
|
28428
|
+
const $c147333b1f360629$export$dea9ce0e9bb2441c = "0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19";
|
|
28429
|
+
const $c147333b1f360629$export$5baee63457fa7911 = (type, amount, contractAddress)=>{
|
|
28430
|
+
switch(type){
|
|
28431
|
+
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20:
|
|
28432
|
+
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721:
|
|
28433
|
+
return {
|
|
28434
|
+
type: type,
|
|
28435
|
+
amount: amount,
|
|
28436
|
+
contractAddress: contractAddress,
|
|
28437
|
+
approvalContractAddress: $c147333b1f360629$export$dea9ce0e9bb2441c
|
|
28438
|
+
};
|
|
28439
|
+
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE:
|
|
28440
|
+
default:
|
|
28441
|
+
return {
|
|
28442
|
+
type: ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE,
|
|
28443
|
+
amount: amount
|
|
28444
|
+
};
|
|
28445
|
+
}
|
|
28446
|
+
};
|
|
28447
|
+
const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, orderId)=>{
|
|
28448
|
+
let order;
|
|
28449
|
+
try {
|
|
28450
|
+
const orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
28451
|
+
order = await orderbook.getListing(orderId);
|
|
28452
|
+
} catch (err) {
|
|
28453
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while getting the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ORDER_LISTING_ERROR, {
|
|
28454
|
+
orderId: orderId,
|
|
28455
|
+
message: err.message
|
|
28456
|
+
});
|
|
28457
|
+
}
|
|
28458
|
+
let amount = (ethers.BigNumber).from("0");
|
|
28459
|
+
let type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
|
|
28460
|
+
let contractAddress = "";
|
|
28461
|
+
const buyArray = order.result.buy;
|
|
28462
|
+
if (buyArray.length > 0) switch(buyArray[0].item_type){
|
|
28463
|
+
case "NATIVE":
|
|
28464
|
+
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
|
|
28465
|
+
break;
|
|
28466
|
+
case "ERC20":
|
|
28467
|
+
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20;
|
|
28468
|
+
contractAddress = buyArray[0].contract_address;
|
|
28469
|
+
break;
|
|
28470
|
+
case "ERC721":
|
|
28471
|
+
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721;
|
|
28472
|
+
contractAddress = buyArray[0].contract_address;
|
|
28473
|
+
break;
|
|
28474
|
+
default:
|
|
28475
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Purchasing token type is unsupported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_TOKEN_TYPE_ERROR, {
|
|
28476
|
+
orderId: orderId
|
|
28477
|
+
});
|
|
28478
|
+
}
|
|
28479
|
+
buyArray.forEach((item)=>{
|
|
28480
|
+
amount = amount.add((ethers.BigNumber).from(item.start_amount));
|
|
28481
|
+
});
|
|
28482
|
+
const feeArray = order.result.fees;
|
|
28483
|
+
feeArray.forEach((item)=>{
|
|
28484
|
+
amount = amount.add((ethers.BigNumber).from(item.amount));
|
|
28485
|
+
});
|
|
28486
|
+
const requirements = [
|
|
28487
|
+
$c147333b1f360629$export$5baee63457fa7911(type, amount, contractAddress)
|
|
28488
|
+
];
|
|
28489
|
+
return {
|
|
28490
|
+
requirements: requirements,
|
|
28491
|
+
gas: {
|
|
28492
|
+
type: ($aa144554f9ef124b$export$537fa3efd10ed435).NATIVE,
|
|
28493
|
+
limit: (ethers.BigNumber).from($c147333b1f360629$export$92589613aaa38e1f)
|
|
28494
|
+
}
|
|
28495
|
+
};
|
|
28496
|
+
};
|
|
28497
|
+
|
|
28498
|
+
|
|
28499
|
+
|
|
28500
|
+
|
|
28501
|
+
|
|
28502
|
+
|
|
28503
|
+
|
|
28504
|
+
|
|
28395
28505
|
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
28396
28506
|
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
28397
28507
|
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
@@ -28526,6 +28636,15 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28526
28636
|
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, web3Provider);
|
|
28527
28637
|
}
|
|
28528
28638
|
/**
|
|
28639
|
+
* Determines the requirements for performing a buy.
|
|
28640
|
+
* @param {BuyParams} params - The parameters for the buy.
|
|
28641
|
+
*/ async buy(params) {
|
|
28642
|
+
// eslint-disable-next-line no-console
|
|
28643
|
+
console.warn("This endpoint is currently under construction.");
|
|
28644
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
28645
|
+
await $c147333b1f360629$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
|
|
28646
|
+
}
|
|
28647
|
+
/**
|
|
28529
28648
|
* Checks if the given object is a Web3 provider.
|
|
28530
28649
|
* @param {Web3Provider} web3Provider - The object to check.
|
|
28531
28650
|
* @returns {boolean} - True if the object is a Web3 provider, false otherwise.
|
|
@@ -28559,7 +28678,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
28559
28678
|
function $parcel$export(e, n, v, s) {
|
|
28560
28679
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28561
28680
|
}
|
|
28562
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
28681
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.7.0-alpha.1";
|
|
28563
28682
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28564
28683
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28565
28684
|
|
|
@@ -28752,12 +28871,48 @@ function $77ec335383336bdd$export$931068bc678f0d73(tagName, provider) {
|
|
|
28752
28871
|
|
|
28753
28872
|
|
|
28754
28873
|
|
|
28874
|
+
function $b222a8f062090058$export$fae4199086a966a3(tagName, passport) {
|
|
28875
|
+
if (!passport) {
|
|
28876
|
+
// eslint-disable-next-line no-console
|
|
28877
|
+
console.error("no passport provided");
|
|
28878
|
+
return;
|
|
28879
|
+
}
|
|
28880
|
+
if (window === undefined) {
|
|
28881
|
+
// eslint-disable-next-line no-console
|
|
28882
|
+
console.error("missing window object: please run Checkout client side");
|
|
28883
|
+
return;
|
|
28884
|
+
}
|
|
28885
|
+
let attempts = 0;
|
|
28886
|
+
const maxAttempts = 10;
|
|
28887
|
+
let timer;
|
|
28888
|
+
const attemptToAddPassport = ()=>{
|
|
28889
|
+
try {
|
|
28890
|
+
const elements = document.getElementsByTagName(tagName);
|
|
28891
|
+
const widget = elements[0];
|
|
28892
|
+
widget.addPassportOption(passport);
|
|
28893
|
+
window.clearInterval(timer);
|
|
28894
|
+
} catch (err) {
|
|
28895
|
+
attempts++;
|
|
28896
|
+
if (attempts >= maxAttempts) {
|
|
28897
|
+
window.clearInterval(timer);
|
|
28898
|
+
// eslint-disable-next-line no-console
|
|
28899
|
+
console.error("failed to set the provider");
|
|
28900
|
+
}
|
|
28901
|
+
}
|
|
28902
|
+
};
|
|
28903
|
+
timer = window.setInterval(attemptToAddPassport, 10);
|
|
28904
|
+
attemptToAddPassport();
|
|
28905
|
+
}
|
|
28906
|
+
|
|
28907
|
+
|
|
28755
28908
|
function $1f969328e5988c99$export$30f61ebf204c69f6(props) {
|
|
28756
|
-
const { walletProvider: walletProvider, fromContractAddress: fromContractAddress, amount: amount, provider: provider } = props;
|
|
28909
|
+
const { walletProvider: walletProvider, fromContractAddress: fromContractAddress, amount: amount, provider: provider, passport: passport } = props;
|
|
28757
28910
|
(react.useEffect)(()=>{
|
|
28758
28911
|
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).BRIDGE, provider);
|
|
28912
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).BRIDGE, passport);
|
|
28759
28913
|
}, [
|
|
28760
|
-
provider
|
|
28914
|
+
provider,
|
|
28915
|
+
passport
|
|
28761
28916
|
]);
|
|
28762
28917
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
28763
28918
|
return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-bridge", {
|
|
@@ -28774,8 +28929,15 @@ var $f2083cd30e2f5c56$exports = {};
|
|
|
28774
28929
|
$parcel$export($f2083cd30e2f5c56$exports, "ConnectReact", () => $f2083cd30e2f5c56$export$49d62957f420a1e2);
|
|
28775
28930
|
|
|
28776
28931
|
|
|
28777
|
-
|
|
28932
|
+
|
|
28933
|
+
|
|
28934
|
+
function $f2083cd30e2f5c56$export$49d62957f420a1e2({ passport: passport }) {
|
|
28778
28935
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
28936
|
+
(react.useEffect)(()=>{
|
|
28937
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).CONNECT, passport);
|
|
28938
|
+
}, [
|
|
28939
|
+
passport
|
|
28940
|
+
]);
|
|
28779
28941
|
return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-connect", {
|
|
28780
28942
|
widgetConfig: config
|
|
28781
28943
|
});
|
|
@@ -28789,12 +28951,15 @@ $parcel$export($a4fbb8e3a6aeff58$exports, "SwapReact", () => $a4fbb8e3a6aeff58$e
|
|
|
28789
28951
|
|
|
28790
28952
|
|
|
28791
28953
|
|
|
28954
|
+
|
|
28792
28955
|
function $a4fbb8e3a6aeff58$export$971e031379577f4(props) {
|
|
28793
|
-
const { walletProvider: walletProvider, fromContractAddress: fromContractAddress, amount: amount, toContractAddress: toContractAddress, provider: provider } = props;
|
|
28956
|
+
const { walletProvider: walletProvider, fromContractAddress: fromContractAddress, amount: amount, toContractAddress: toContractAddress, provider: provider, passport: passport } = props;
|
|
28794
28957
|
(react.useEffect)(()=>{
|
|
28795
28958
|
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).SWAP, provider);
|
|
28959
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).SWAP, passport);
|
|
28796
28960
|
}, [
|
|
28797
|
-
provider
|
|
28961
|
+
provider,
|
|
28962
|
+
passport
|
|
28798
28963
|
]);
|
|
28799
28964
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
28800
28965
|
return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-swap", {
|
|
@@ -28814,12 +28979,15 @@ $parcel$export($89d55ace0f8f1c07$exports, "WalletReact", () => $89d55ace0f8f1c07
|
|
|
28814
28979
|
|
|
28815
28980
|
|
|
28816
28981
|
|
|
28982
|
+
|
|
28817
28983
|
function $89d55ace0f8f1c07$export$ceaac94f34dba154(props) {
|
|
28818
|
-
const { walletProvider: walletProvider, provider: provider } = props;
|
|
28984
|
+
const { walletProvider: walletProvider, provider: provider, passport: passport } = props;
|
|
28819
28985
|
(react.useEffect)(()=>{
|
|
28820
28986
|
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).WALLET, provider);
|
|
28987
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).WALLET, passport);
|
|
28821
28988
|
}, [
|
|
28822
|
-
provider
|
|
28989
|
+
provider,
|
|
28990
|
+
passport
|
|
28823
28991
|
]);
|
|
28824
28992
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
28825
28993
|
return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-wallet", {
|