@imtbl/sdk 0.11.0-alpha → 0.12.0-alpha
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 +12 -4
- package/dist/checkout_sdk.js +499 -1224
- package/dist/checkout_widgets.d.ts +10 -3
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +14 -14
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +595 -1330
- package/dist/index.d.ts +17 -8
- package/dist/index.js +596 -1331
- package/dist/orderbook.d.ts +5 -4
- package/dist/orderbook.js +58 -987
- package/dist/passport.d.ts +10 -3
- package/dist/passport.js +186 -188
- package/package.json +2 -2
package/dist/checkout_sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ethers, ContractFactory, utils, Contract as Contract$1, BigNumber as BigNumber$1, providers, constants } from 'ethers';
|
|
1
|
+
import { ethers, ContractFactory, utils, Contract as Contract$1, BigNumber as BigNumber$1, providers, constants as constants$1 } from 'ethers';
|
|
2
2
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
3
3
|
import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
|
|
4
4
|
import { Token, TradeType, Percent, CurrencyAmount } from '@uniswap/sdk-core';
|
|
@@ -13815,7 +13815,7 @@ class SecondaryFee__factory extends ContractFactory {
|
|
|
13815
13815
|
/* Autogenerated file. Do not edit manually. */
|
|
13816
13816
|
/* tslint:disable */
|
|
13817
13817
|
/* eslint-disable */
|
|
13818
|
-
const _abi
|
|
13818
|
+
const _abi = [
|
|
13819
13819
|
{
|
|
13820
13820
|
inputs: [],
|
|
13821
13821
|
stateMutability: "nonpayable",
|
|
@@ -14811,7 +14811,7 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
14811
14811
|
super(...args);
|
|
14812
14812
|
}
|
|
14813
14813
|
else {
|
|
14814
|
-
super(_abi
|
|
14814
|
+
super(_abi, _bytecode, args[0]);
|
|
14815
14815
|
}
|
|
14816
14816
|
}
|
|
14817
14817
|
deploy(overrides) {
|
|
@@ -14827,12 +14827,12 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
14827
14827
|
return super.connect(signer);
|
|
14828
14828
|
}
|
|
14829
14829
|
static bytecode = _bytecode;
|
|
14830
|
-
static abi = _abi
|
|
14830
|
+
static abi = _abi;
|
|
14831
14831
|
static createInterface() {
|
|
14832
|
-
return new utils.Interface(_abi
|
|
14832
|
+
return new utils.Interface(_abi);
|
|
14833
14833
|
}
|
|
14834
14834
|
static connect(address, signerOrProvider) {
|
|
14835
|
-
return new Contract$1(address, _abi
|
|
14835
|
+
return new Contract$1(address, _abi, signerOrProvider);
|
|
14836
14836
|
}
|
|
14837
14837
|
}
|
|
14838
14838
|
|
|
@@ -15484,7 +15484,7 @@ function validateSecondaryFees(secondaryFees) {
|
|
|
15484
15484
|
if (!isValidNonZeroAddress(secondaryFee.recipient)) {
|
|
15485
15485
|
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.recipient}`);
|
|
15486
15486
|
}
|
|
15487
|
-
if (secondaryFee.basisPoints
|
|
15487
|
+
if (secondaryFee.basisPoints <= 0 || secondaryFee.basisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
|
|
15488
15488
|
throw new InvalidConfigurationError(`Invalid secondary fee basis points: ${secondaryFee.basisPoints}`);
|
|
15489
15489
|
}
|
|
15490
15490
|
totalSecondaryFeeBasisPoints += secondaryFee.basisPoints;
|
|
@@ -16164,6 +16164,9 @@ var Fee;
|
|
|
16164
16164
|
(function (Fee) {
|
|
16165
16165
|
(function (fee_type) {
|
|
16166
16166
|
fee_type["ROYALTY"] = "ROYALTY";
|
|
16167
|
+
fee_type["MAKER_MARKETPLACE"] = "MAKER_MARKETPLACE";
|
|
16168
|
+
fee_type["TAKER_MARKETPLACE"] = "TAKER_MARKETPLACE";
|
|
16169
|
+
fee_type["PROTOCOL"] = "PROTOCOL";
|
|
16167
16170
|
})(Fee.fee_type || (Fee.fee_type = {}));
|
|
16168
16171
|
})(Fee || (Fee = {}));
|
|
16169
16172
|
|
|
@@ -16293,7 +16296,7 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
|
|
|
16293
16296
|
endAmount: buyItem.start_amount,
|
|
16294
16297
|
itemType: ItemType.NATIVE,
|
|
16295
16298
|
recipient: order.account_address,
|
|
16296
|
-
token: constants.AddressZero,
|
|
16299
|
+
token: constants$1.AddressZero,
|
|
16297
16300
|
identifierOrCriteria: '0',
|
|
16298
16301
|
};
|
|
16299
16302
|
case 'ERC20':
|
|
@@ -16302,7 +16305,7 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
|
|
|
16302
16305
|
endAmount: buyItem.start_amount,
|
|
16303
16306
|
itemType: ItemType.ERC20,
|
|
16304
16307
|
recipient: order.account_address,
|
|
16305
|
-
token: buyItem.contract_address || constants.AddressZero,
|
|
16308
|
+
token: buyItem.contract_address || constants$1.AddressZero,
|
|
16306
16309
|
identifierOrCriteria: '0',
|
|
16307
16310
|
};
|
|
16308
16311
|
default: // ERC721
|
|
@@ -16311,43 +16314,46 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
|
|
|
16311
16314
|
endAmount: '1',
|
|
16312
16315
|
itemType: ItemType.ERC721,
|
|
16313
16316
|
recipient: order.account_address,
|
|
16314
|
-
token: buyItem.contract_address || constants.AddressZero,
|
|
16317
|
+
token: buyItem.contract_address || constants$1.AddressZero,
|
|
16315
16318
|
identifierOrCriteria: '0',
|
|
16316
16319
|
};
|
|
16317
16320
|
}
|
|
16318
16321
|
});
|
|
16319
16322
|
const fees = order.fees.map((fee) => ({
|
|
16320
|
-
|
|
16321
|
-
endAmount: fee.amount,
|
|
16323
|
+
amount: fee.amount,
|
|
16322
16324
|
itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
16323
16325
|
recipient: fee.recipient,
|
|
16324
16326
|
token: order.buy[0].item_type === 'ERC20'
|
|
16325
16327
|
? order.buy[0].contract_address
|
|
16326
|
-
: constants.AddressZero,
|
|
16328
|
+
: constants$1.AddressZero,
|
|
16327
16329
|
identifierOrCriteria: '0',
|
|
16328
16330
|
}));
|
|
16329
16331
|
return {
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
|
|
16342
|
-
|
|
16343
|
-
|
|
16344
|
-
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16332
|
+
orderComponents: {
|
|
16333
|
+
conduitKey: constants$1.HashZero,
|
|
16334
|
+
consideration: [...considerationItems],
|
|
16335
|
+
offer: order.sell.map((sellItem) => {
|
|
16336
|
+
const erc721Item = sellItem;
|
|
16337
|
+
return {
|
|
16338
|
+
startAmount: '1',
|
|
16339
|
+
endAmount: '1',
|
|
16340
|
+
itemType: ItemType.ERC721,
|
|
16341
|
+
token: erc721Item.contract_address,
|
|
16342
|
+
identifierOrCriteria: erc721Item.token_id,
|
|
16343
|
+
};
|
|
16344
|
+
}),
|
|
16345
|
+
counter,
|
|
16346
|
+
endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
|
|
16347
|
+
startTime: Math.round(new Date(order.start_time).getTime() / 1000).toString(),
|
|
16348
|
+
salt: order.salt,
|
|
16349
|
+
offerer: order.account_address,
|
|
16350
|
+
zone: zoneAddress,
|
|
16351
|
+
// this should be the fee exclusive number of items the user signed for
|
|
16352
|
+
totalOriginalConsiderationItems: considerationItems.length,
|
|
16353
|
+
orderType: OrderType.FULL_RESTRICTED,
|
|
16354
|
+
zoneHash: constants$1.HashZero,
|
|
16355
|
+
},
|
|
16356
|
+
tips: fees,
|
|
16351
16357
|
};
|
|
16352
16358
|
}
|
|
16353
16359
|
|
|
@@ -16362,11 +16368,10 @@ class Seaport {
|
|
|
16362
16368
|
this.seaportContractAddress = seaportContractAddress;
|
|
16363
16369
|
this.zoneContractAddress = zoneContractAddress;
|
|
16364
16370
|
}
|
|
16365
|
-
async prepareSeaportOrder(offerer, listingItem, considerationItem,
|
|
16366
|
-
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem,
|
|
16371
|
+
async prepareSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
|
|
16372
|
+
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry);
|
|
16367
16373
|
const listingActions = [];
|
|
16368
|
-
const approvalAction = seaportActions
|
|
16369
|
-
.find((action) => action.type === 'approval');
|
|
16374
|
+
const approvalAction = seaportActions.find((action) => action.type === 'approval');
|
|
16370
16375
|
if (approvalAction) {
|
|
16371
16376
|
listingActions.push({
|
|
16372
16377
|
type: ActionType.TRANSACTION,
|
|
@@ -16374,8 +16379,7 @@ class Seaport {
|
|
|
16374
16379
|
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
16375
16380
|
});
|
|
16376
16381
|
}
|
|
16377
|
-
const createAction = seaportActions
|
|
16378
|
-
.find((action) => action.type === 'create');
|
|
16382
|
+
const createAction = seaportActions.find((action) => action.type === 'create');
|
|
16379
16383
|
if (!createAction) {
|
|
16380
16384
|
throw new Error('No create order action found');
|
|
16381
16385
|
}
|
|
@@ -16393,21 +16397,23 @@ class Seaport {
|
|
|
16393
16397
|
};
|
|
16394
16398
|
}
|
|
16395
16399
|
async fulfillOrder(order, account, extraData) {
|
|
16396
|
-
const orderComponents =
|
|
16400
|
+
const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
16397
16401
|
const seaportLib = this.getSeaportLib(order);
|
|
16398
16402
|
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
16399
16403
|
accountAddress: account,
|
|
16400
|
-
fulfillOrderDetails: [
|
|
16404
|
+
fulfillOrderDetails: [
|
|
16405
|
+
{
|
|
16401
16406
|
order: {
|
|
16402
16407
|
parameters: orderComponents,
|
|
16403
16408
|
signature: order.signature,
|
|
16404
16409
|
},
|
|
16405
16410
|
extraData,
|
|
16406
|
-
|
|
16411
|
+
tips,
|
|
16412
|
+
},
|
|
16413
|
+
],
|
|
16407
16414
|
});
|
|
16408
16415
|
const fulfillmentActions = [];
|
|
16409
|
-
const approvalAction = seaportActions
|
|
16410
|
-
.find((action) => action.type === 'approval');
|
|
16416
|
+
const approvalAction = seaportActions.find((action) => action.type === 'approval');
|
|
16411
16417
|
if (approvalAction) {
|
|
16412
16418
|
fulfillmentActions.push({
|
|
16413
16419
|
type: ActionType.TRANSACTION,
|
|
@@ -16415,8 +16421,7 @@ class Seaport {
|
|
|
16415
16421
|
purpose: TransactionPurpose.APPROVAL,
|
|
16416
16422
|
});
|
|
16417
16423
|
}
|
|
16418
|
-
const fulfilOrderAction = seaportActions
|
|
16419
|
-
.find((action) => action.type === 'exchange');
|
|
16424
|
+
const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
|
|
16420
16425
|
if (!fulfilOrderAction) {
|
|
16421
16426
|
throw new Error('No exchange action found');
|
|
16422
16427
|
}
|
|
@@ -16428,7 +16433,7 @@ class Seaport {
|
|
|
16428
16433
|
return { actions: fulfillmentActions };
|
|
16429
16434
|
}
|
|
16430
16435
|
async cancelOrder(order, account) {
|
|
16431
|
-
const orderComponents =
|
|
16436
|
+
const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
16432
16437
|
const seaportLib = this.getSeaportLib(order);
|
|
16433
16438
|
const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
|
|
16434
16439
|
return prepareTransaction(cancellationTransaction)();
|
|
@@ -16437,7 +16442,7 @@ class Seaport {
|
|
|
16437
16442
|
const orderCounter = order.protocol_data.counter;
|
|
16438
16443
|
return mapImmutableOrderToSeaportOrderComponents(order, orderCounter, this.zoneContractAddress);
|
|
16439
16444
|
}
|
|
16440
|
-
createSeaportOrder(offerer, listingItem, considerationItem,
|
|
16445
|
+
createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
|
|
16441
16446
|
const seaportLib = this.getSeaportLib();
|
|
16442
16447
|
return seaportLib.createOrder({
|
|
16443
16448
|
allowPartialFills: false,
|
|
@@ -16450,15 +16455,12 @@ class Seaport {
|
|
|
16450
16455
|
],
|
|
16451
16456
|
consideration: [
|
|
16452
16457
|
{
|
|
16453
|
-
token: considerationItem.type === 'ERC20'
|
|
16458
|
+
token: considerationItem.type === 'ERC20'
|
|
16459
|
+
? considerationItem.contractAddress
|
|
16460
|
+
: undefined,
|
|
16454
16461
|
amount: considerationItem.amount,
|
|
16455
16462
|
recipient: offerer,
|
|
16456
16463
|
},
|
|
16457
|
-
{
|
|
16458
|
-
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
16459
|
-
amount: royaltyInfo.amountRequired,
|
|
16460
|
-
recipient: royaltyInfo.recipient,
|
|
16461
|
-
},
|
|
16462
16464
|
],
|
|
16463
16465
|
startTime: (orderStart.getTime() / 1000).toFixed(0),
|
|
16464
16466
|
endTime: (orderExpiry.getTime() / 1000).toFixed(0),
|
|
@@ -16517,7 +16519,7 @@ class ImmutableApiClient {
|
|
|
16517
16519
|
...listOrderParams,
|
|
16518
16520
|
});
|
|
16519
16521
|
}
|
|
16520
|
-
async createListing({ orderHash, orderComponents, orderSignature, }) {
|
|
16522
|
+
async createListing({ orderHash, orderComponents, orderSignature, makerFee, }) {
|
|
16521
16523
|
if (orderComponents.offer.length !== 1) {
|
|
16522
16524
|
throw new Error('Only one item can be listed at a time');
|
|
16523
16525
|
}
|
|
@@ -16546,15 +16548,7 @@ class ImmutableApiClient {
|
|
|
16546
16548
|
contract_address: orderComponents.consideration[0].token,
|
|
16547
16549
|
},
|
|
16548
16550
|
],
|
|
16549
|
-
fees:
|
|
16550
|
-
? [
|
|
16551
|
-
{
|
|
16552
|
-
amount: orderComponents.consideration[1].startAmount,
|
|
16553
|
-
recipient: orderComponents.consideration[1].recipient,
|
|
16554
|
-
fee_type: Fee.fee_type.ROYALTY,
|
|
16555
|
-
},
|
|
16556
|
-
]
|
|
16557
|
-
: [],
|
|
16551
|
+
fees: makerFee ? [makerFee] : [],
|
|
16558
16552
|
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
16559
16553
|
protocol_data: {
|
|
16560
16554
|
order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
|
|
@@ -16621,1038 +16615,115 @@ function getOrderbookConfig(environment) {
|
|
|
16621
16615
|
}
|
|
16622
16616
|
}
|
|
16623
16617
|
|
|
16624
|
-
class
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16618
|
+
class SeaportLibFactory {
|
|
16619
|
+
defaultSeaportContractAddress;
|
|
16620
|
+
provider;
|
|
16621
|
+
constructor(defaultSeaportContractAddress, provider) {
|
|
16622
|
+
this.defaultSeaportContractAddress = defaultSeaportContractAddress;
|
|
16623
|
+
this.provider = provider;
|
|
16628
16624
|
}
|
|
16629
|
-
|
|
16630
|
-
const
|
|
16631
|
-
|
|
16625
|
+
create(orderSeaportVersion, orderSeaportAddress) {
|
|
16626
|
+
const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_5;
|
|
16627
|
+
const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
|
|
16628
|
+
return new Seaport$1(this.provider, {
|
|
16629
|
+
seaportVersion,
|
|
16630
|
+
balanceAndApprovalChecksOnOrderCreation: true,
|
|
16631
|
+
overrides: {
|
|
16632
|
+
contractAddress: seaportContractAddress,
|
|
16633
|
+
},
|
|
16634
|
+
});
|
|
16632
16635
|
}
|
|
16633
16636
|
}
|
|
16634
16637
|
|
|
16635
|
-
|
|
16636
|
-
|
|
16637
|
-
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
|
|
16650
|
-
|
|
16651
|
-
|
|
16652
|
-
|
|
16653
|
-
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
16668
|
-
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
|
|
16672
|
-
|
|
16673
|
-
|
|
16674
|
-
|
|
16675
|
-
|
|
16676
|
-
|
|
16677
|
-
|
|
16678
|
-
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
|
|
16698
|
-
|
|
16699
|
-
|
|
16700
|
-
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
16707
|
-
|
|
16708
|
-
|
|
16709
|
-
|
|
16710
|
-
|
|
16711
|
-
|
|
16712
|
-
|
|
16713
|
-
|
|
16714
|
-
|
|
16715
|
-
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
16719
|
-
internalType: "uint256",
|
|
16720
|
-
name: "tokenId",
|
|
16721
|
-
type: "uint256",
|
|
16722
|
-
},
|
|
16723
|
-
],
|
|
16724
|
-
name: "Approval",
|
|
16725
|
-
type: "event",
|
|
16726
|
-
},
|
|
16727
|
-
{
|
|
16728
|
-
anonymous: false,
|
|
16729
|
-
inputs: [
|
|
16730
|
-
{
|
|
16731
|
-
indexed: true,
|
|
16732
|
-
internalType: "address",
|
|
16733
|
-
name: "owner",
|
|
16734
|
-
type: "address",
|
|
16735
|
-
},
|
|
16736
|
-
{
|
|
16737
|
-
indexed: true,
|
|
16738
|
-
internalType: "address",
|
|
16739
|
-
name: "operator",
|
|
16740
|
-
type: "address",
|
|
16741
|
-
},
|
|
16742
|
-
{
|
|
16743
|
-
indexed: false,
|
|
16744
|
-
internalType: "bool",
|
|
16745
|
-
name: "approved",
|
|
16746
|
-
type: "bool",
|
|
16747
|
-
},
|
|
16748
|
-
],
|
|
16749
|
-
name: "ApprovalForAll",
|
|
16750
|
-
type: "event",
|
|
16751
|
-
},
|
|
16752
|
-
{
|
|
16753
|
-
anonymous: false,
|
|
16754
|
-
inputs: [
|
|
16755
|
-
{
|
|
16756
|
-
indexed: true,
|
|
16757
|
-
internalType: "bytes32",
|
|
16758
|
-
name: "role",
|
|
16759
|
-
type: "bytes32",
|
|
16760
|
-
},
|
|
16761
|
-
{
|
|
16762
|
-
indexed: true,
|
|
16763
|
-
internalType: "bytes32",
|
|
16764
|
-
name: "previousAdminRole",
|
|
16765
|
-
type: "bytes32",
|
|
16766
|
-
},
|
|
16767
|
-
{
|
|
16768
|
-
indexed: true,
|
|
16769
|
-
internalType: "bytes32",
|
|
16770
|
-
name: "newAdminRole",
|
|
16771
|
-
type: "bytes32",
|
|
16772
|
-
},
|
|
16773
|
-
],
|
|
16774
|
-
name: "RoleAdminChanged",
|
|
16775
|
-
type: "event",
|
|
16776
|
-
},
|
|
16777
|
-
{
|
|
16778
|
-
anonymous: false,
|
|
16779
|
-
inputs: [
|
|
16780
|
-
{
|
|
16781
|
-
indexed: true,
|
|
16782
|
-
internalType: "bytes32",
|
|
16783
|
-
name: "role",
|
|
16784
|
-
type: "bytes32",
|
|
16785
|
-
},
|
|
16786
|
-
{
|
|
16787
|
-
indexed: true,
|
|
16788
|
-
internalType: "address",
|
|
16789
|
-
name: "account",
|
|
16790
|
-
type: "address",
|
|
16791
|
-
},
|
|
16638
|
+
/**
|
|
16639
|
+
* zkEVM orderbook SDK
|
|
16640
|
+
* @constructor
|
|
16641
|
+
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
16642
|
+
*/
|
|
16643
|
+
class Orderbook {
|
|
16644
|
+
apiClient;
|
|
16645
|
+
seaport;
|
|
16646
|
+
orderbookConfig;
|
|
16647
|
+
constructor(config) {
|
|
16648
|
+
const obConfig = getOrderbookConfig(config.baseConfig.environment);
|
|
16649
|
+
const finalConfig = {
|
|
16650
|
+
...obConfig,
|
|
16651
|
+
...config.overrides,
|
|
16652
|
+
};
|
|
16653
|
+
if (!finalConfig) {
|
|
16654
|
+
throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
|
|
16655
|
+
}
|
|
16656
|
+
this.orderbookConfig = finalConfig;
|
|
16657
|
+
const { apiEndpoint, chainName } = this.orderbookConfig;
|
|
16658
|
+
if (!apiEndpoint) {
|
|
16659
|
+
throw new Error('API endpoint must be provided');
|
|
16660
|
+
}
|
|
16661
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
16662
|
+
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
16663
|
+
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
16664
|
+
}
|
|
16665
|
+
/**
|
|
16666
|
+
* Return the configuration for the orderbook module.
|
|
16667
|
+
* @return {OrderbookModuleConfiguration} The configuration for the orderbook module.
|
|
16668
|
+
*/
|
|
16669
|
+
config() {
|
|
16670
|
+
return this.orderbookConfig;
|
|
16671
|
+
}
|
|
16672
|
+
/**
|
|
16673
|
+
* Get an order by ID
|
|
16674
|
+
* @param {string} listingId - The listingId to find.
|
|
16675
|
+
* @return {ListingResult} The returned order result.
|
|
16676
|
+
*/
|
|
16677
|
+
getListing(listingId) {
|
|
16678
|
+
return this.apiClient.getListing(listingId);
|
|
16679
|
+
}
|
|
16680
|
+
/**
|
|
16681
|
+
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
16682
|
+
* in the params object.
|
|
16683
|
+
* @param {ListListingsParams} listOrderParams - Filtering, ordering and page parameters.
|
|
16684
|
+
* @return {ListListingsResult} The paged orders.
|
|
16685
|
+
*/
|
|
16686
|
+
listListings(listOrderParams) {
|
|
16687
|
+
return this.apiClient.listListings(listOrderParams);
|
|
16688
|
+
}
|
|
16689
|
+
/**
|
|
16690
|
+
* Get required transactions and messages for signing prior to creating a listing
|
|
16691
|
+
* through the createListing method
|
|
16692
|
+
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
16693
|
+
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
16694
|
+
* the unsigned approval transaction, the typed order message for signing and
|
|
16695
|
+
* the order components that can be submitted to `createListing` with a signature.
|
|
16696
|
+
*/
|
|
16697
|
+
async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
|
|
16698
|
+
return this.seaport.prepareSeaportOrder(makerAddress, sell, buy,
|
|
16699
|
+
// Default order start to now
|
|
16700
|
+
new Date(),
|
|
16701
|
+
// Default order expiry to 2 years from now
|
|
16702
|
+
orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
|
|
16703
|
+
}
|
|
16704
|
+
/**
|
|
16705
|
+
* Create an order
|
|
16706
|
+
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
16707
|
+
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
16708
|
+
*/
|
|
16709
|
+
createListing(createListingParams) {
|
|
16710
|
+
return this.apiClient.createListing(createListingParams);
|
|
16711
|
+
}
|
|
16712
|
+
/**
|
|
16713
|
+
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
16714
|
+
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
16715
|
+
* transaction can be submitted or it will be reverted.
|
|
16716
|
+
* @param {string} listingId - The listingId to fulfil.
|
|
16717
|
+
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
16718
|
+
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
16719
|
+
*/
|
|
16720
|
+
async fulfillOrder(listingId, takerAddress, takerFee) {
|
|
16721
|
+
const fulfillmentDataRes = await this.apiClient.fulfillmentData([
|
|
16792
16722
|
{
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
name: "sender",
|
|
16796
|
-
type: "address",
|
|
16723
|
+
order_id: listingId,
|
|
16724
|
+
fee: takerFee,
|
|
16797
16725
|
},
|
|
16798
|
-
]
|
|
16799
|
-
name: "RoleGranted",
|
|
16800
|
-
type: "event",
|
|
16801
|
-
},
|
|
16802
|
-
{
|
|
16803
|
-
anonymous: false,
|
|
16804
|
-
inputs: [
|
|
16805
|
-
{
|
|
16806
|
-
indexed: true,
|
|
16807
|
-
internalType: "bytes32",
|
|
16808
|
-
name: "role",
|
|
16809
|
-
type: "bytes32",
|
|
16810
|
-
},
|
|
16811
|
-
{
|
|
16812
|
-
indexed: true,
|
|
16813
|
-
internalType: "address",
|
|
16814
|
-
name: "account",
|
|
16815
|
-
type: "address",
|
|
16816
|
-
},
|
|
16817
|
-
{
|
|
16818
|
-
indexed: true,
|
|
16819
|
-
internalType: "address",
|
|
16820
|
-
name: "sender",
|
|
16821
|
-
type: "address",
|
|
16822
|
-
},
|
|
16823
|
-
],
|
|
16824
|
-
name: "RoleRevoked",
|
|
16825
|
-
type: "event",
|
|
16826
|
-
},
|
|
16827
|
-
{
|
|
16828
|
-
anonymous: false,
|
|
16829
|
-
inputs: [
|
|
16830
|
-
{
|
|
16831
|
-
indexed: false,
|
|
16832
|
-
internalType: "address",
|
|
16833
|
-
name: "oldRegistry",
|
|
16834
|
-
type: "address",
|
|
16835
|
-
},
|
|
16836
|
-
{
|
|
16837
|
-
indexed: false,
|
|
16838
|
-
internalType: "address",
|
|
16839
|
-
name: "newRegistry",
|
|
16840
|
-
type: "address",
|
|
16841
|
-
},
|
|
16842
|
-
],
|
|
16843
|
-
name: "RoyaltytAllowlistRegistryUpdated",
|
|
16844
|
-
type: "event",
|
|
16845
|
-
},
|
|
16846
|
-
{
|
|
16847
|
-
anonymous: false,
|
|
16848
|
-
inputs: [
|
|
16849
|
-
{
|
|
16850
|
-
indexed: true,
|
|
16851
|
-
internalType: "address",
|
|
16852
|
-
name: "from",
|
|
16853
|
-
type: "address",
|
|
16854
|
-
},
|
|
16855
|
-
{
|
|
16856
|
-
indexed: true,
|
|
16857
|
-
internalType: "address",
|
|
16858
|
-
name: "to",
|
|
16859
|
-
type: "address",
|
|
16860
|
-
},
|
|
16861
|
-
{
|
|
16862
|
-
indexed: true,
|
|
16863
|
-
internalType: "uint256",
|
|
16864
|
-
name: "tokenId",
|
|
16865
|
-
type: "uint256",
|
|
16866
|
-
},
|
|
16867
|
-
],
|
|
16868
|
-
name: "Transfer",
|
|
16869
|
-
type: "event",
|
|
16870
|
-
},
|
|
16871
|
-
{
|
|
16872
|
-
inputs: [],
|
|
16873
|
-
name: "DEFAULT_ADMIN_ROLE",
|
|
16874
|
-
outputs: [
|
|
16875
|
-
{
|
|
16876
|
-
internalType: "bytes32",
|
|
16877
|
-
name: "",
|
|
16878
|
-
type: "bytes32",
|
|
16879
|
-
},
|
|
16880
|
-
],
|
|
16881
|
-
stateMutability: "view",
|
|
16882
|
-
type: "function",
|
|
16883
|
-
},
|
|
16884
|
-
{
|
|
16885
|
-
inputs: [],
|
|
16886
|
-
name: "MINTER_ROLE",
|
|
16887
|
-
outputs: [
|
|
16888
|
-
{
|
|
16889
|
-
internalType: "bytes32",
|
|
16890
|
-
name: "",
|
|
16891
|
-
type: "bytes32",
|
|
16892
|
-
},
|
|
16893
|
-
],
|
|
16894
|
-
stateMutability: "view",
|
|
16895
|
-
type: "function",
|
|
16896
|
-
},
|
|
16897
|
-
{
|
|
16898
|
-
inputs: [
|
|
16899
|
-
{
|
|
16900
|
-
internalType: "address",
|
|
16901
|
-
name: "to",
|
|
16902
|
-
type: "address",
|
|
16903
|
-
},
|
|
16904
|
-
{
|
|
16905
|
-
internalType: "uint256",
|
|
16906
|
-
name: "tokenId",
|
|
16907
|
-
type: "uint256",
|
|
16908
|
-
},
|
|
16909
|
-
],
|
|
16910
|
-
name: "approve",
|
|
16911
|
-
outputs: [],
|
|
16912
|
-
stateMutability: "nonpayable",
|
|
16913
|
-
type: "function",
|
|
16914
|
-
},
|
|
16915
|
-
{
|
|
16916
|
-
inputs: [
|
|
16917
|
-
{
|
|
16918
|
-
internalType: "address",
|
|
16919
|
-
name: "owner",
|
|
16920
|
-
type: "address",
|
|
16921
|
-
},
|
|
16922
|
-
],
|
|
16923
|
-
name: "balanceOf",
|
|
16924
|
-
outputs: [
|
|
16925
|
-
{
|
|
16926
|
-
internalType: "uint256",
|
|
16927
|
-
name: "",
|
|
16928
|
-
type: "uint256",
|
|
16929
|
-
},
|
|
16930
|
-
],
|
|
16931
|
-
stateMutability: "view",
|
|
16932
|
-
type: "function",
|
|
16933
|
-
},
|
|
16934
|
-
{
|
|
16935
|
-
inputs: [],
|
|
16936
|
-
name: "baseURI",
|
|
16937
|
-
outputs: [
|
|
16938
|
-
{
|
|
16939
|
-
internalType: "string",
|
|
16940
|
-
name: "",
|
|
16941
|
-
type: "string",
|
|
16942
|
-
},
|
|
16943
|
-
],
|
|
16944
|
-
stateMutability: "view",
|
|
16945
|
-
type: "function",
|
|
16946
|
-
},
|
|
16947
|
-
{
|
|
16948
|
-
inputs: [
|
|
16949
|
-
{
|
|
16950
|
-
internalType: "uint256",
|
|
16951
|
-
name: "tokenId",
|
|
16952
|
-
type: "uint256",
|
|
16953
|
-
},
|
|
16954
|
-
],
|
|
16955
|
-
name: "burn",
|
|
16956
|
-
outputs: [],
|
|
16957
|
-
stateMutability: "nonpayable",
|
|
16958
|
-
type: "function",
|
|
16959
|
-
},
|
|
16960
|
-
{
|
|
16961
|
-
inputs: [],
|
|
16962
|
-
name: "contractURI",
|
|
16963
|
-
outputs: [
|
|
16964
|
-
{
|
|
16965
|
-
internalType: "string",
|
|
16966
|
-
name: "",
|
|
16967
|
-
type: "string",
|
|
16968
|
-
},
|
|
16969
|
-
],
|
|
16970
|
-
stateMutability: "view",
|
|
16971
|
-
type: "function",
|
|
16972
|
-
},
|
|
16973
|
-
{
|
|
16974
|
-
inputs: [],
|
|
16975
|
-
name: "getAdmins",
|
|
16976
|
-
outputs: [
|
|
16977
|
-
{
|
|
16978
|
-
internalType: "address[]",
|
|
16979
|
-
name: "",
|
|
16980
|
-
type: "address[]",
|
|
16981
|
-
},
|
|
16982
|
-
],
|
|
16983
|
-
stateMutability: "view",
|
|
16984
|
-
type: "function",
|
|
16985
|
-
},
|
|
16986
|
-
{
|
|
16987
|
-
inputs: [
|
|
16988
|
-
{
|
|
16989
|
-
internalType: "uint256",
|
|
16990
|
-
name: "tokenId",
|
|
16991
|
-
type: "uint256",
|
|
16992
|
-
},
|
|
16993
|
-
],
|
|
16994
|
-
name: "getApproved",
|
|
16995
|
-
outputs: [
|
|
16996
|
-
{
|
|
16997
|
-
internalType: "address",
|
|
16998
|
-
name: "",
|
|
16999
|
-
type: "address",
|
|
17000
|
-
},
|
|
17001
|
-
],
|
|
17002
|
-
stateMutability: "view",
|
|
17003
|
-
type: "function",
|
|
17004
|
-
},
|
|
17005
|
-
{
|
|
17006
|
-
inputs: [
|
|
17007
|
-
{
|
|
17008
|
-
internalType: "bytes32",
|
|
17009
|
-
name: "role",
|
|
17010
|
-
type: "bytes32",
|
|
17011
|
-
},
|
|
17012
|
-
],
|
|
17013
|
-
name: "getRoleAdmin",
|
|
17014
|
-
outputs: [
|
|
17015
|
-
{
|
|
17016
|
-
internalType: "bytes32",
|
|
17017
|
-
name: "",
|
|
17018
|
-
type: "bytes32",
|
|
17019
|
-
},
|
|
17020
|
-
],
|
|
17021
|
-
stateMutability: "view",
|
|
17022
|
-
type: "function",
|
|
17023
|
-
},
|
|
17024
|
-
{
|
|
17025
|
-
inputs: [
|
|
17026
|
-
{
|
|
17027
|
-
internalType: "bytes32",
|
|
17028
|
-
name: "role",
|
|
17029
|
-
type: "bytes32",
|
|
17030
|
-
},
|
|
17031
|
-
{
|
|
17032
|
-
internalType: "uint256",
|
|
17033
|
-
name: "index",
|
|
17034
|
-
type: "uint256",
|
|
17035
|
-
},
|
|
17036
|
-
],
|
|
17037
|
-
name: "getRoleMember",
|
|
17038
|
-
outputs: [
|
|
17039
|
-
{
|
|
17040
|
-
internalType: "address",
|
|
17041
|
-
name: "",
|
|
17042
|
-
type: "address",
|
|
17043
|
-
},
|
|
17044
|
-
],
|
|
17045
|
-
stateMutability: "view",
|
|
17046
|
-
type: "function",
|
|
17047
|
-
},
|
|
17048
|
-
{
|
|
17049
|
-
inputs: [
|
|
17050
|
-
{
|
|
17051
|
-
internalType: "bytes32",
|
|
17052
|
-
name: "role",
|
|
17053
|
-
type: "bytes32",
|
|
17054
|
-
},
|
|
17055
|
-
],
|
|
17056
|
-
name: "getRoleMemberCount",
|
|
17057
|
-
outputs: [
|
|
17058
|
-
{
|
|
17059
|
-
internalType: "uint256",
|
|
17060
|
-
name: "",
|
|
17061
|
-
type: "uint256",
|
|
17062
|
-
},
|
|
17063
|
-
],
|
|
17064
|
-
stateMutability: "view",
|
|
17065
|
-
type: "function",
|
|
17066
|
-
},
|
|
17067
|
-
{
|
|
17068
|
-
inputs: [
|
|
17069
|
-
{
|
|
17070
|
-
internalType: "address",
|
|
17071
|
-
name: "user",
|
|
17072
|
-
type: "address",
|
|
17073
|
-
},
|
|
17074
|
-
],
|
|
17075
|
-
name: "grantMinterRole",
|
|
17076
|
-
outputs: [],
|
|
17077
|
-
stateMutability: "nonpayable",
|
|
17078
|
-
type: "function",
|
|
17079
|
-
},
|
|
17080
|
-
{
|
|
17081
|
-
inputs: [
|
|
17082
|
-
{
|
|
17083
|
-
internalType: "bytes32",
|
|
17084
|
-
name: "role",
|
|
17085
|
-
type: "bytes32",
|
|
17086
|
-
},
|
|
17087
|
-
{
|
|
17088
|
-
internalType: "address",
|
|
17089
|
-
name: "account",
|
|
17090
|
-
type: "address",
|
|
17091
|
-
},
|
|
17092
|
-
],
|
|
17093
|
-
name: "grantRole",
|
|
17094
|
-
outputs: [],
|
|
17095
|
-
stateMutability: "nonpayable",
|
|
17096
|
-
type: "function",
|
|
17097
|
-
},
|
|
17098
|
-
{
|
|
17099
|
-
inputs: [
|
|
17100
|
-
{
|
|
17101
|
-
internalType: "bytes32",
|
|
17102
|
-
name: "role",
|
|
17103
|
-
type: "bytes32",
|
|
17104
|
-
},
|
|
17105
|
-
{
|
|
17106
|
-
internalType: "address",
|
|
17107
|
-
name: "account",
|
|
17108
|
-
type: "address",
|
|
17109
|
-
},
|
|
17110
|
-
],
|
|
17111
|
-
name: "hasRole",
|
|
17112
|
-
outputs: [
|
|
17113
|
-
{
|
|
17114
|
-
internalType: "bool",
|
|
17115
|
-
name: "",
|
|
17116
|
-
type: "bool",
|
|
17117
|
-
},
|
|
17118
|
-
],
|
|
17119
|
-
stateMutability: "view",
|
|
17120
|
-
type: "function",
|
|
17121
|
-
},
|
|
17122
|
-
{
|
|
17123
|
-
inputs: [
|
|
17124
|
-
{
|
|
17125
|
-
internalType: "address",
|
|
17126
|
-
name: "owner",
|
|
17127
|
-
type: "address",
|
|
17128
|
-
},
|
|
17129
|
-
{
|
|
17130
|
-
internalType: "address",
|
|
17131
|
-
name: "operator",
|
|
17132
|
-
type: "address",
|
|
17133
|
-
},
|
|
17134
|
-
],
|
|
17135
|
-
name: "isApprovedForAll",
|
|
17136
|
-
outputs: [
|
|
17137
|
-
{
|
|
17138
|
-
internalType: "bool",
|
|
17139
|
-
name: "",
|
|
17140
|
-
type: "bool",
|
|
17141
|
-
},
|
|
17142
|
-
],
|
|
17143
|
-
stateMutability: "view",
|
|
17144
|
-
type: "function",
|
|
17145
|
-
},
|
|
17146
|
-
{
|
|
17147
|
-
inputs: [
|
|
17148
|
-
{
|
|
17149
|
-
internalType: "address",
|
|
17150
|
-
name: "to",
|
|
17151
|
-
type: "address",
|
|
17152
|
-
},
|
|
17153
|
-
{
|
|
17154
|
-
internalType: "uint256",
|
|
17155
|
-
name: "amount",
|
|
17156
|
-
type: "uint256",
|
|
17157
|
-
},
|
|
17158
|
-
],
|
|
17159
|
-
name: "mint",
|
|
17160
|
-
outputs: [],
|
|
17161
|
-
stateMutability: "nonpayable",
|
|
17162
|
-
type: "function",
|
|
17163
|
-
},
|
|
17164
|
-
{
|
|
17165
|
-
inputs: [],
|
|
17166
|
-
name: "name",
|
|
17167
|
-
outputs: [
|
|
17168
|
-
{
|
|
17169
|
-
internalType: "string",
|
|
17170
|
-
name: "",
|
|
17171
|
-
type: "string",
|
|
17172
|
-
},
|
|
17173
|
-
],
|
|
17174
|
-
stateMutability: "view",
|
|
17175
|
-
type: "function",
|
|
17176
|
-
},
|
|
17177
|
-
{
|
|
17178
|
-
inputs: [
|
|
17179
|
-
{
|
|
17180
|
-
internalType: "uint256",
|
|
17181
|
-
name: "tokenId",
|
|
17182
|
-
type: "uint256",
|
|
17183
|
-
},
|
|
17184
|
-
],
|
|
17185
|
-
name: "ownerOf",
|
|
17186
|
-
outputs: [
|
|
17187
|
-
{
|
|
17188
|
-
internalType: "address",
|
|
17189
|
-
name: "",
|
|
17190
|
-
type: "address",
|
|
17191
|
-
},
|
|
17192
|
-
],
|
|
17193
|
-
stateMutability: "view",
|
|
17194
|
-
type: "function",
|
|
17195
|
-
},
|
|
17196
|
-
{
|
|
17197
|
-
inputs: [
|
|
17198
|
-
{
|
|
17199
|
-
internalType: "bytes32",
|
|
17200
|
-
name: "role",
|
|
17201
|
-
type: "bytes32",
|
|
17202
|
-
},
|
|
17203
|
-
{
|
|
17204
|
-
internalType: "address",
|
|
17205
|
-
name: "account",
|
|
17206
|
-
type: "address",
|
|
17207
|
-
},
|
|
17208
|
-
],
|
|
17209
|
-
name: "renounceRole",
|
|
17210
|
-
outputs: [],
|
|
17211
|
-
stateMutability: "nonpayable",
|
|
17212
|
-
type: "function",
|
|
17213
|
-
},
|
|
17214
|
-
{
|
|
17215
|
-
inputs: [
|
|
17216
|
-
{
|
|
17217
|
-
internalType: "address",
|
|
17218
|
-
name: "user",
|
|
17219
|
-
type: "address",
|
|
17220
|
-
},
|
|
17221
|
-
],
|
|
17222
|
-
name: "revokeMinterRole",
|
|
17223
|
-
outputs: [],
|
|
17224
|
-
stateMutability: "nonpayable",
|
|
17225
|
-
type: "function",
|
|
17226
|
-
},
|
|
17227
|
-
{
|
|
17228
|
-
inputs: [
|
|
17229
|
-
{
|
|
17230
|
-
internalType: "bytes32",
|
|
17231
|
-
name: "role",
|
|
17232
|
-
type: "bytes32",
|
|
17233
|
-
},
|
|
17234
|
-
{
|
|
17235
|
-
internalType: "address",
|
|
17236
|
-
name: "account",
|
|
17237
|
-
type: "address",
|
|
17238
|
-
},
|
|
17239
|
-
],
|
|
17240
|
-
name: "revokeRole",
|
|
17241
|
-
outputs: [],
|
|
17242
|
-
stateMutability: "nonpayable",
|
|
17243
|
-
type: "function",
|
|
17244
|
-
},
|
|
17245
|
-
{
|
|
17246
|
-
inputs: [],
|
|
17247
|
-
name: "royaltyAllowlist",
|
|
17248
|
-
outputs: [
|
|
17249
|
-
{
|
|
17250
|
-
internalType: "contract IRoyaltyAllowlist",
|
|
17251
|
-
name: "",
|
|
17252
|
-
type: "address",
|
|
17253
|
-
},
|
|
17254
|
-
],
|
|
17255
|
-
stateMutability: "view",
|
|
17256
|
-
type: "function",
|
|
17257
|
-
},
|
|
17258
|
-
{
|
|
17259
|
-
inputs: [
|
|
17260
|
-
{
|
|
17261
|
-
internalType: "uint256",
|
|
17262
|
-
name: "_tokenId",
|
|
17263
|
-
type: "uint256",
|
|
17264
|
-
},
|
|
17265
|
-
{
|
|
17266
|
-
internalType: "uint256",
|
|
17267
|
-
name: "_salePrice",
|
|
17268
|
-
type: "uint256",
|
|
17269
|
-
},
|
|
17270
|
-
],
|
|
17271
|
-
name: "royaltyInfo",
|
|
17272
|
-
outputs: [
|
|
17273
|
-
{
|
|
17274
|
-
internalType: "address",
|
|
17275
|
-
name: "",
|
|
17276
|
-
type: "address",
|
|
17277
|
-
},
|
|
17278
|
-
{
|
|
17279
|
-
internalType: "uint256",
|
|
17280
|
-
name: "",
|
|
17281
|
-
type: "uint256",
|
|
17282
|
-
},
|
|
17283
|
-
],
|
|
17284
|
-
stateMutability: "view",
|
|
17285
|
-
type: "function",
|
|
17286
|
-
},
|
|
17287
|
-
{
|
|
17288
|
-
inputs: [
|
|
17289
|
-
{
|
|
17290
|
-
internalType: "address",
|
|
17291
|
-
name: "from",
|
|
17292
|
-
type: "address",
|
|
17293
|
-
},
|
|
17294
|
-
{
|
|
17295
|
-
internalType: "address",
|
|
17296
|
-
name: "to",
|
|
17297
|
-
type: "address",
|
|
17298
|
-
},
|
|
17299
|
-
{
|
|
17300
|
-
internalType: "uint256",
|
|
17301
|
-
name: "tokenId",
|
|
17302
|
-
type: "uint256",
|
|
17303
|
-
},
|
|
17304
|
-
],
|
|
17305
|
-
name: "safeTransferFrom",
|
|
17306
|
-
outputs: [],
|
|
17307
|
-
stateMutability: "nonpayable",
|
|
17308
|
-
type: "function",
|
|
17309
|
-
},
|
|
17310
|
-
{
|
|
17311
|
-
inputs: [
|
|
17312
|
-
{
|
|
17313
|
-
internalType: "address",
|
|
17314
|
-
name: "from",
|
|
17315
|
-
type: "address",
|
|
17316
|
-
},
|
|
17317
|
-
{
|
|
17318
|
-
internalType: "address",
|
|
17319
|
-
name: "to",
|
|
17320
|
-
type: "address",
|
|
17321
|
-
},
|
|
17322
|
-
{
|
|
17323
|
-
internalType: "uint256",
|
|
17324
|
-
name: "tokenId",
|
|
17325
|
-
type: "uint256",
|
|
17326
|
-
},
|
|
17327
|
-
{
|
|
17328
|
-
internalType: "bytes",
|
|
17329
|
-
name: "data",
|
|
17330
|
-
type: "bytes",
|
|
17331
|
-
},
|
|
17332
|
-
],
|
|
17333
|
-
name: "safeTransferFrom",
|
|
17334
|
-
outputs: [],
|
|
17335
|
-
stateMutability: "nonpayable",
|
|
17336
|
-
type: "function",
|
|
17337
|
-
},
|
|
17338
|
-
{
|
|
17339
|
-
inputs: [
|
|
17340
|
-
{
|
|
17341
|
-
internalType: "address",
|
|
17342
|
-
name: "operator",
|
|
17343
|
-
type: "address",
|
|
17344
|
-
},
|
|
17345
|
-
{
|
|
17346
|
-
internalType: "bool",
|
|
17347
|
-
name: "approved",
|
|
17348
|
-
type: "bool",
|
|
17349
|
-
},
|
|
17350
|
-
],
|
|
17351
|
-
name: "setApprovalForAll",
|
|
17352
|
-
outputs: [],
|
|
17353
|
-
stateMutability: "nonpayable",
|
|
17354
|
-
type: "function",
|
|
17355
|
-
},
|
|
17356
|
-
{
|
|
17357
|
-
inputs: [
|
|
17358
|
-
{
|
|
17359
|
-
internalType: "string",
|
|
17360
|
-
name: "baseURI_",
|
|
17361
|
-
type: "string",
|
|
17362
|
-
},
|
|
17363
|
-
],
|
|
17364
|
-
name: "setBaseURI",
|
|
17365
|
-
outputs: [],
|
|
17366
|
-
stateMutability: "nonpayable",
|
|
17367
|
-
type: "function",
|
|
17368
|
-
},
|
|
17369
|
-
{
|
|
17370
|
-
inputs: [
|
|
17371
|
-
{
|
|
17372
|
-
internalType: "string",
|
|
17373
|
-
name: "_contractURI",
|
|
17374
|
-
type: "string",
|
|
17375
|
-
},
|
|
17376
|
-
],
|
|
17377
|
-
name: "setContractURI",
|
|
17378
|
-
outputs: [],
|
|
17379
|
-
stateMutability: "nonpayable",
|
|
17380
|
-
type: "function",
|
|
17381
|
-
},
|
|
17382
|
-
{
|
|
17383
|
-
inputs: [
|
|
17384
|
-
{
|
|
17385
|
-
internalType: "address",
|
|
17386
|
-
name: "_royaltyAllowlist",
|
|
17387
|
-
type: "address",
|
|
17388
|
-
},
|
|
17389
|
-
],
|
|
17390
|
-
name: "setRoyaltyAllowlistRegistry",
|
|
17391
|
-
outputs: [],
|
|
17392
|
-
stateMutability: "nonpayable",
|
|
17393
|
-
type: "function",
|
|
17394
|
-
},
|
|
17395
|
-
{
|
|
17396
|
-
inputs: [
|
|
17397
|
-
{
|
|
17398
|
-
internalType: "bytes4",
|
|
17399
|
-
name: "interfaceId",
|
|
17400
|
-
type: "bytes4",
|
|
17401
|
-
},
|
|
17402
|
-
],
|
|
17403
|
-
name: "supportsInterface",
|
|
17404
|
-
outputs: [
|
|
17405
|
-
{
|
|
17406
|
-
internalType: "bool",
|
|
17407
|
-
name: "",
|
|
17408
|
-
type: "bool",
|
|
17409
|
-
},
|
|
17410
|
-
],
|
|
17411
|
-
stateMutability: "view",
|
|
17412
|
-
type: "function",
|
|
17413
|
-
},
|
|
17414
|
-
{
|
|
17415
|
-
inputs: [],
|
|
17416
|
-
name: "symbol",
|
|
17417
|
-
outputs: [
|
|
17418
|
-
{
|
|
17419
|
-
internalType: "string",
|
|
17420
|
-
name: "",
|
|
17421
|
-
type: "string",
|
|
17422
|
-
},
|
|
17423
|
-
],
|
|
17424
|
-
stateMutability: "view",
|
|
17425
|
-
type: "function",
|
|
17426
|
-
},
|
|
17427
|
-
{
|
|
17428
|
-
inputs: [
|
|
17429
|
-
{
|
|
17430
|
-
internalType: "uint256",
|
|
17431
|
-
name: "index",
|
|
17432
|
-
type: "uint256",
|
|
17433
|
-
},
|
|
17434
|
-
],
|
|
17435
|
-
name: "tokenByIndex",
|
|
17436
|
-
outputs: [
|
|
17437
|
-
{
|
|
17438
|
-
internalType: "uint256",
|
|
17439
|
-
name: "",
|
|
17440
|
-
type: "uint256",
|
|
17441
|
-
},
|
|
17442
|
-
],
|
|
17443
|
-
stateMutability: "view",
|
|
17444
|
-
type: "function",
|
|
17445
|
-
},
|
|
17446
|
-
{
|
|
17447
|
-
inputs: [
|
|
17448
|
-
{
|
|
17449
|
-
internalType: "address",
|
|
17450
|
-
name: "owner",
|
|
17451
|
-
type: "address",
|
|
17452
|
-
},
|
|
17453
|
-
{
|
|
17454
|
-
internalType: "uint256",
|
|
17455
|
-
name: "index",
|
|
17456
|
-
type: "uint256",
|
|
17457
|
-
},
|
|
17458
|
-
],
|
|
17459
|
-
name: "tokenOfOwnerByIndex",
|
|
17460
|
-
outputs: [
|
|
17461
|
-
{
|
|
17462
|
-
internalType: "uint256",
|
|
17463
|
-
name: "",
|
|
17464
|
-
type: "uint256",
|
|
17465
|
-
},
|
|
17466
|
-
],
|
|
17467
|
-
stateMutability: "view",
|
|
17468
|
-
type: "function",
|
|
17469
|
-
},
|
|
17470
|
-
{
|
|
17471
|
-
inputs: [
|
|
17472
|
-
{
|
|
17473
|
-
internalType: "uint256",
|
|
17474
|
-
name: "tokenId",
|
|
17475
|
-
type: "uint256",
|
|
17476
|
-
},
|
|
17477
|
-
],
|
|
17478
|
-
name: "tokenURI",
|
|
17479
|
-
outputs: [
|
|
17480
|
-
{
|
|
17481
|
-
internalType: "string",
|
|
17482
|
-
name: "",
|
|
17483
|
-
type: "string",
|
|
17484
|
-
},
|
|
17485
|
-
],
|
|
17486
|
-
stateMutability: "view",
|
|
17487
|
-
type: "function",
|
|
17488
|
-
},
|
|
17489
|
-
{
|
|
17490
|
-
inputs: [],
|
|
17491
|
-
name: "totalSupply",
|
|
17492
|
-
outputs: [
|
|
17493
|
-
{
|
|
17494
|
-
internalType: "uint256",
|
|
17495
|
-
name: "",
|
|
17496
|
-
type: "uint256",
|
|
17497
|
-
},
|
|
17498
|
-
],
|
|
17499
|
-
stateMutability: "view",
|
|
17500
|
-
type: "function",
|
|
17501
|
-
},
|
|
17502
|
-
{
|
|
17503
|
-
inputs: [
|
|
17504
|
-
{
|
|
17505
|
-
internalType: "address",
|
|
17506
|
-
name: "from",
|
|
17507
|
-
type: "address",
|
|
17508
|
-
},
|
|
17509
|
-
{
|
|
17510
|
-
internalType: "address",
|
|
17511
|
-
name: "to",
|
|
17512
|
-
type: "address",
|
|
17513
|
-
},
|
|
17514
|
-
{
|
|
17515
|
-
internalType: "uint256",
|
|
17516
|
-
name: "tokenId",
|
|
17517
|
-
type: "uint256",
|
|
17518
|
-
},
|
|
17519
|
-
],
|
|
17520
|
-
name: "transferFrom",
|
|
17521
|
-
outputs: [],
|
|
17522
|
-
stateMutability: "nonpayable",
|
|
17523
|
-
type: "function",
|
|
17524
|
-
},
|
|
17525
|
-
];
|
|
17526
|
-
class ImmutableERC721Base__factory {
|
|
17527
|
-
static abi = _abi;
|
|
17528
|
-
static createInterface() {
|
|
17529
|
-
return new utils.Interface(_abi);
|
|
17530
|
-
}
|
|
17531
|
-
static connect(address, signerOrProvider) {
|
|
17532
|
-
return new Contract$1(address, _abi, signerOrProvider);
|
|
17533
|
-
}
|
|
17534
|
-
}
|
|
17535
|
-
|
|
17536
|
-
class ERC721Factory {
|
|
17537
|
-
erc721;
|
|
17538
|
-
constructor(contractAddress, provider) {
|
|
17539
|
-
this.erc721 = ImmutableERC721Base__factory.connect(contractAddress, provider);
|
|
17540
|
-
}
|
|
17541
|
-
create() {
|
|
17542
|
-
return new ERC721(this.erc721);
|
|
17543
|
-
}
|
|
17544
|
-
}
|
|
17545
|
-
|
|
17546
|
-
class SeaportLibFactory {
|
|
17547
|
-
defaultSeaportContractAddress;
|
|
17548
|
-
provider;
|
|
17549
|
-
constructor(defaultSeaportContractAddress, provider) {
|
|
17550
|
-
this.defaultSeaportContractAddress = defaultSeaportContractAddress;
|
|
17551
|
-
this.provider = provider;
|
|
17552
|
-
}
|
|
17553
|
-
create(orderSeaportVersion, orderSeaportAddress) {
|
|
17554
|
-
const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_5;
|
|
17555
|
-
const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
|
|
17556
|
-
return new Seaport$1(this.provider, {
|
|
17557
|
-
seaportVersion,
|
|
17558
|
-
balanceAndApprovalChecksOnOrderCreation: true,
|
|
17559
|
-
overrides: {
|
|
17560
|
-
contractAddress: seaportContractAddress,
|
|
17561
|
-
},
|
|
17562
|
-
});
|
|
17563
|
-
}
|
|
17564
|
-
}
|
|
17565
|
-
|
|
17566
|
-
/**
|
|
17567
|
-
* zkEVM orderbook SDK
|
|
17568
|
-
* @constructor
|
|
17569
|
-
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
17570
|
-
*/
|
|
17571
|
-
class Orderbook {
|
|
17572
|
-
apiClient;
|
|
17573
|
-
seaport;
|
|
17574
|
-
orderbookConfig;
|
|
17575
|
-
constructor(config) {
|
|
17576
|
-
const obConfig = getOrderbookConfig(config.baseConfig.environment);
|
|
17577
|
-
const finalConfig = {
|
|
17578
|
-
...obConfig,
|
|
17579
|
-
...config.overrides,
|
|
17580
|
-
};
|
|
17581
|
-
if (!finalConfig) {
|
|
17582
|
-
throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
|
|
17583
|
-
}
|
|
17584
|
-
this.orderbookConfig = finalConfig;
|
|
17585
|
-
const { apiEndpoint, chainName } = this.orderbookConfig;
|
|
17586
|
-
if (!apiEndpoint) {
|
|
17587
|
-
throw new Error('API endpoint must be provided');
|
|
17588
|
-
}
|
|
17589
|
-
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
17590
|
-
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
17591
|
-
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
17592
|
-
}
|
|
17593
|
-
/**
|
|
17594
|
-
* Return the configuration for the orderbook module.
|
|
17595
|
-
* @return {OrderbookModuleConfiguration} The configuration for the orderbook module.
|
|
17596
|
-
*/
|
|
17597
|
-
config() {
|
|
17598
|
-
return this.orderbookConfig;
|
|
17599
|
-
}
|
|
17600
|
-
/**
|
|
17601
|
-
* Get an order by ID
|
|
17602
|
-
* @param {string} listingId - The listingId to find.
|
|
17603
|
-
* @return {ListingResult} The returned order result.
|
|
17604
|
-
*/
|
|
17605
|
-
getListing(listingId) {
|
|
17606
|
-
return this.apiClient.getListing(listingId);
|
|
17607
|
-
}
|
|
17608
|
-
/**
|
|
17609
|
-
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
17610
|
-
* in the params object.
|
|
17611
|
-
* @param {ListOrderParams} listOrderParams - Filtering, ordering and page parameters.
|
|
17612
|
-
* @return {Orders} The paged orders.
|
|
17613
|
-
*/
|
|
17614
|
-
listListings(listOrderParams) {
|
|
17615
|
-
return this.apiClient.listListings(listOrderParams);
|
|
17616
|
-
}
|
|
17617
|
-
/**
|
|
17618
|
-
* Get required transactions and messages for signing prior to creating a listing
|
|
17619
|
-
* through the createListing method
|
|
17620
|
-
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
17621
|
-
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
17622
|
-
* the unsigned approval transaction, the typed order message for signing and
|
|
17623
|
-
* the order components that can be submitted to `createListing` with a signature.
|
|
17624
|
-
*/
|
|
17625
|
-
async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
|
|
17626
|
-
const erc721 = new ERC721Factory(sell.contractAddress, this.orderbookConfig.provider).create();
|
|
17627
|
-
const royaltyInfo = await erc721.royaltyInfo(sell.tokenId, buy.amount);
|
|
17628
|
-
return this.seaport.prepareSeaportOrder(makerAddress, sell, buy, royaltyInfo,
|
|
17629
|
-
// Default order start to now
|
|
17630
|
-
new Date(),
|
|
17631
|
-
// Default order expiry to 2 years from now
|
|
17632
|
-
orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
|
|
17633
|
-
}
|
|
17634
|
-
/**
|
|
17635
|
-
* Create an order
|
|
17636
|
-
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
17637
|
-
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
17638
|
-
*/
|
|
17639
|
-
createListing(createListingParams) {
|
|
17640
|
-
return this.apiClient.createListing(createListingParams);
|
|
17641
|
-
}
|
|
17642
|
-
/**
|
|
17643
|
-
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
17644
|
-
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
17645
|
-
* transaction can be submitted or it will be reverted.
|
|
17646
|
-
* @param {string} listingId - The listingId to fulfil.
|
|
17647
|
-
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
17648
|
-
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
17649
|
-
*/
|
|
17650
|
-
async fulfillOrder(listingId, takerAddress) {
|
|
17651
|
-
const fulfillmentDataRes = await this.apiClient.fulfillmentData([{
|
|
17652
|
-
order_id: listingId,
|
|
17653
|
-
// fee: takerFee,
|
|
17654
|
-
fee: undefined,
|
|
17655
|
-
}]);
|
|
16726
|
+
]);
|
|
17656
16727
|
if (fulfillmentDataRes.result.length !== 1) {
|
|
17657
16728
|
throw new Error('unexpected fulfillment data result length');
|
|
17658
16729
|
}
|
|
@@ -17661,91 +16732,40 @@ class Orderbook {
|
|
|
17661
16732
|
if (orderResult.status !== OrderStatus.ACTIVE) {
|
|
17662
16733
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
|
|
17663
16734
|
}
|
|
17664
|
-
return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
|
|
17665
|
-
}
|
|
17666
|
-
/**
|
|
17667
|
-
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
17668
|
-
* the account that created them.
|
|
17669
|
-
* @param {string} listingId - The listingId to cancel.
|
|
17670
|
-
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
17671
|
-
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
17672
|
-
*/
|
|
17673
|
-
async cancelOrder(listingId, accountAddress) {
|
|
17674
|
-
const orderResult = await this.apiClient.getListing(listingId);
|
|
17675
|
-
if (orderResult.result.status !== OrderStatus.ACTIVE
|
|
17676
|
-
&& orderResult.result.status !== OrderStatus.INACTIVE
|
|
17677
|
-
&& orderResult.result.status !== OrderStatus.PENDING) {
|
|
17678
|
-
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
17679
|
-
}
|
|
17680
|
-
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
17681
|
-
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${listingId}`);
|
|
17682
|
-
}
|
|
17683
|
-
const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
|
|
17684
|
-
return { unsignedCancelOrderTransaction: cancelOrderTransaction };
|
|
17685
|
-
}
|
|
17686
|
-
}
|
|
17687
|
-
|
|
17688
|
-
/* eslint-disable class-methods-use-this */
|
|
17689
|
-
|
|
17690
|
-
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
17691
|
-
{
|
|
17692
|
-
constant: true,
|
|
17693
|
-
inputs: [],
|
|
17694
|
-
name: "name",
|
|
17695
|
-
outputs: [
|
|
17696
|
-
{
|
|
17697
|
-
name: "",
|
|
17698
|
-
type: "string"
|
|
17699
|
-
}
|
|
17700
|
-
],
|
|
17701
|
-
payable: false,
|
|
17702
|
-
type: "function"
|
|
17703
|
-
},
|
|
17704
|
-
{
|
|
17705
|
-
constant: true,
|
|
17706
|
-
inputs: [],
|
|
17707
|
-
name: "decimals",
|
|
17708
|
-
outputs: [
|
|
17709
|
-
{
|
|
17710
|
-
name: "",
|
|
17711
|
-
type: "uint8"
|
|
17712
|
-
}
|
|
17713
|
-
],
|
|
17714
|
-
payable: false,
|
|
17715
|
-
type: "function"
|
|
17716
|
-
},
|
|
17717
|
-
{
|
|
17718
|
-
constant: true,
|
|
17719
|
-
inputs: [
|
|
17720
|
-
{
|
|
17721
|
-
name: "_owner",
|
|
17722
|
-
type: "address"
|
|
17723
|
-
}
|
|
17724
|
-
],
|
|
17725
|
-
name: "balanceOf",
|
|
17726
|
-
outputs: [
|
|
17727
|
-
{
|
|
17728
|
-
name: "balance",
|
|
17729
|
-
type: "uint256"
|
|
17730
|
-
}
|
|
17731
|
-
],
|
|
17732
|
-
payable: false,
|
|
17733
|
-
type: "function"
|
|
17734
|
-
},
|
|
17735
|
-
{
|
|
17736
|
-
constant: true,
|
|
17737
|
-
inputs: [],
|
|
17738
|
-
name: "symbol",
|
|
17739
|
-
outputs: [
|
|
17740
|
-
{
|
|
17741
|
-
name: "",
|
|
17742
|
-
type: "string"
|
|
17743
|
-
}
|
|
17744
|
-
],
|
|
17745
|
-
payable: false,
|
|
17746
|
-
type: "function"
|
|
16735
|
+
return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
|
|
17747
16736
|
}
|
|
17748
|
-
|
|
16737
|
+
/**
|
|
16738
|
+
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
16739
|
+
* the account that created them.
|
|
16740
|
+
* @param {string} listingId - The listingId to cancel.
|
|
16741
|
+
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
16742
|
+
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
16743
|
+
*/
|
|
16744
|
+
async cancelOrder(listingId, accountAddress) {
|
|
16745
|
+
const orderResult = await this.apiClient.getListing(listingId);
|
|
16746
|
+
if (orderResult.result.status !== OrderStatus.ACTIVE
|
|
16747
|
+
&& orderResult.result.status !== OrderStatus.INACTIVE
|
|
16748
|
+
&& orderResult.result.status !== OrderStatus.PENDING) {
|
|
16749
|
+
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
16750
|
+
}
|
|
16751
|
+
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
16752
|
+
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${listingId}`);
|
|
16753
|
+
}
|
|
16754
|
+
const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
|
|
16755
|
+
return { unsignedCancelOrderTransaction: cancelOrderTransaction };
|
|
16756
|
+
}
|
|
16757
|
+
}
|
|
16758
|
+
|
|
16759
|
+
// Consumers might want an estimated gas limit for fulfilling an order
|
|
16760
|
+
// without calling the transaction builder. This is an estimate that
|
|
16761
|
+
// should work for all fulfillment scenarios.
|
|
16762
|
+
const ESTIMATED_FULFILLMENT_GAS_GWEI = 400000;
|
|
16763
|
+
const constants = {
|
|
16764
|
+
estimatedFulfillmentGasGwei: ESTIMATED_FULFILLMENT_GAS_GWEI,
|
|
16765
|
+
};
|
|
16766
|
+
|
|
16767
|
+
/* eslint-disable class-methods-use-this */
|
|
16768
|
+
|
|
17749
16769
|
|
|
17750
16770
|
|
|
17751
16771
|
|
|
@@ -17953,6 +16973,111 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
|
|
|
17953
16973
|
}
|
|
17954
16974
|
]
|
|
17955
16975
|
]);
|
|
16976
|
+
const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
|
|
16977
|
+
{
|
|
16978
|
+
constant: true,
|
|
16979
|
+
inputs: [],
|
|
16980
|
+
name: "name",
|
|
16981
|
+
outputs: [
|
|
16982
|
+
{
|
|
16983
|
+
name: "",
|
|
16984
|
+
type: "string"
|
|
16985
|
+
}
|
|
16986
|
+
],
|
|
16987
|
+
payable: false,
|
|
16988
|
+
type: "function"
|
|
16989
|
+
},
|
|
16990
|
+
{
|
|
16991
|
+
constant: true,
|
|
16992
|
+
inputs: [],
|
|
16993
|
+
name: "decimals",
|
|
16994
|
+
outputs: [
|
|
16995
|
+
{
|
|
16996
|
+
name: "",
|
|
16997
|
+
type: "uint8"
|
|
16998
|
+
}
|
|
16999
|
+
],
|
|
17000
|
+
payable: false,
|
|
17001
|
+
type: "function"
|
|
17002
|
+
},
|
|
17003
|
+
{
|
|
17004
|
+
constant: true,
|
|
17005
|
+
inputs: [
|
|
17006
|
+
{
|
|
17007
|
+
name: "_owner",
|
|
17008
|
+
type: "address"
|
|
17009
|
+
}
|
|
17010
|
+
],
|
|
17011
|
+
name: "balanceOf",
|
|
17012
|
+
outputs: [
|
|
17013
|
+
{
|
|
17014
|
+
name: "balance",
|
|
17015
|
+
type: "uint256"
|
|
17016
|
+
}
|
|
17017
|
+
],
|
|
17018
|
+
payable: false,
|
|
17019
|
+
type: "function"
|
|
17020
|
+
},
|
|
17021
|
+
{
|
|
17022
|
+
constant: true,
|
|
17023
|
+
inputs: [],
|
|
17024
|
+
name: "symbol",
|
|
17025
|
+
outputs: [
|
|
17026
|
+
{
|
|
17027
|
+
name: "",
|
|
17028
|
+
type: "string"
|
|
17029
|
+
}
|
|
17030
|
+
],
|
|
17031
|
+
payable: false,
|
|
17032
|
+
type: "function"
|
|
17033
|
+
},
|
|
17034
|
+
{
|
|
17035
|
+
constant: true,
|
|
17036
|
+
inputs: [
|
|
17037
|
+
{
|
|
17038
|
+
name: "_owner",
|
|
17039
|
+
type: "address"
|
|
17040
|
+
},
|
|
17041
|
+
{
|
|
17042
|
+
name: "_spender",
|
|
17043
|
+
type: "address"
|
|
17044
|
+
}
|
|
17045
|
+
],
|
|
17046
|
+
name: "allowance",
|
|
17047
|
+
outputs: [
|
|
17048
|
+
{
|
|
17049
|
+
name: "",
|
|
17050
|
+
type: "uint256"
|
|
17051
|
+
}
|
|
17052
|
+
],
|
|
17053
|
+
payable: false,
|
|
17054
|
+
stateMutability: "view",
|
|
17055
|
+
type: "function"
|
|
17056
|
+
},
|
|
17057
|
+
{
|
|
17058
|
+
constant: false,
|
|
17059
|
+
inputs: [
|
|
17060
|
+
{
|
|
17061
|
+
name: "_spender",
|
|
17062
|
+
type: "address"
|
|
17063
|
+
},
|
|
17064
|
+
{
|
|
17065
|
+
name: "_value",
|
|
17066
|
+
type: "uint256"
|
|
17067
|
+
}
|
|
17068
|
+
],
|
|
17069
|
+
name: "approve",
|
|
17070
|
+
outputs: [
|
|
17071
|
+
{
|
|
17072
|
+
name: "",
|
|
17073
|
+
type: "bool"
|
|
17074
|
+
}
|
|
17075
|
+
],
|
|
17076
|
+
payable: false,
|
|
17077
|
+
stateMutability: "nonpayable",
|
|
17078
|
+
type: "function"
|
|
17079
|
+
}
|
|
17080
|
+
];
|
|
17956
17081
|
|
|
17957
17082
|
|
|
17958
17083
|
var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
|
|
@@ -18005,6 +17130,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
18005
17130
|
CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
|
|
18006
17131
|
CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
|
|
18007
17132
|
CheckoutErrorType["SWITCH_NETWORK_UNSUPPORTED"] = "SWITCH_NETWORK_UNSUPPORTED";
|
|
17133
|
+
CheckoutErrorType["GET_ERC20_ALLOWANCE_ERROR"] = "GET_ERC20_ALLOWANCE_ERROR";
|
|
18008
17134
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
18009
17135
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
18010
17136
|
message;
|
|
@@ -18221,7 +17347,7 @@ const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, w
|
|
|
18221
17347
|
});
|
|
18222
17348
|
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, contractAddress) {
|
|
18223
17349
|
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
18224
|
-
const contract = new (Contract$1)(contractAddress, JSON.stringify(($
|
|
17350
|
+
const contract = new (Contract$1)(contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), web3Provider);
|
|
18225
17351
|
const name = await contract.name();
|
|
18226
17352
|
const symbol = await contract.symbol();
|
|
18227
17353
|
const balance = await contract.balanceOf(walletAddress);
|
|
@@ -18345,6 +17471,8 @@ function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
|
|
|
18345
17471
|
}
|
|
18346
17472
|
async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
|
|
18347
17473
|
return ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
17474
|
+
if (web3Provider.provider?.isPassport) // if Passport skip the validation checks
|
|
17475
|
+
return web3Provider;
|
|
18348
17476
|
if (!$bb88265fe45a0393$export$ebe4804963e71f98(web3Provider)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Parsed provider is not a valid Web3Provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR);
|
|
18349
17477
|
// this sets the default options and overrides them with any parsed options
|
|
18350
17478
|
const options = {
|
|
@@ -18603,7 +17731,7 @@ const $2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS = "0x00000000000000000000000000
|
|
|
18603
17731
|
const $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS = 18;
|
|
18604
17732
|
async function $2e7bf45a7c9a9570$var$getTokenInfoByAddress(config, tokenAddress, chainId, provider) {
|
|
18605
17733
|
if (tokenAddress === "NATIVE") return config.networkMap.get(chainId)?.nativeCurrency;
|
|
18606
|
-
const contract = new (Contract$1)(tokenAddress, JSON.stringify(($
|
|
17734
|
+
const contract = new (Contract$1)(tokenAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
|
|
18607
17735
|
const name = await contract.name();
|
|
18608
17736
|
const symbol = await contract.symbol();
|
|
18609
17737
|
const decimals = await contract.decimals();
|
|
@@ -18698,16 +17826,169 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
18698
17826
|
|
|
18699
17827
|
|
|
18700
17828
|
|
|
18701
|
-
|
|
18702
|
-
|
|
18703
|
-
|
|
17829
|
+
|
|
17830
|
+
|
|
17831
|
+
|
|
17832
|
+
|
|
17833
|
+
|
|
17834
|
+
const $2499eab4caa6dc71$export$1ede6278abcdf1cb = (itemRequirements)=>{
|
|
17835
|
+
const aggregatedMap = new Map();
|
|
17836
|
+
const aggregatedItemRequirements = [];
|
|
17837
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
17838
|
+
const { type: type } = itemRequirement;
|
|
17839
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
|
|
17840
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
17841
|
+
return;
|
|
17842
|
+
}
|
|
17843
|
+
const { contractAddress: contractAddress, spenderAddress: spenderAddress, amount: amount } = itemRequirement;
|
|
17844
|
+
const key = `${contractAddress}${spenderAddress}`;
|
|
17845
|
+
const aggregateItem = aggregatedMap.get(key);
|
|
17846
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
17847
|
+
else aggregatedMap.set(key, {
|
|
17848
|
+
...itemRequirement
|
|
17849
|
+
});
|
|
17850
|
+
});
|
|
17851
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
17852
|
+
};
|
|
17853
|
+
const $2499eab4caa6dc71$export$c804c9ade5c28607 = (itemRequirements)=>$2499eab4caa6dc71$export$1ede6278abcdf1cb(itemRequirements);
|
|
17854
|
+
|
|
17855
|
+
|
|
17856
|
+
|
|
17857
|
+
|
|
17858
|
+
|
|
17859
|
+
const $95b61a5bfb091547$export$41491ea105c4dc2d = async (provider, ownerAddress, contractAddress, spenderAddress)=>{
|
|
17860
|
+
try {
|
|
17861
|
+
const contract = new (0, Contract$1)(contractAddress, JSON.stringify((0, $d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
|
|
17862
|
+
return await contract.allowance(ownerAddress, spenderAddress);
|
|
17863
|
+
} catch (err) {
|
|
17864
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get the allowance for ERC20", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_ALLOWANCE_ERROR, {
|
|
17865
|
+
contractAddress: contractAddress
|
|
17866
|
+
});
|
|
17867
|
+
}
|
|
17868
|
+
};
|
|
17869
|
+
const $95b61a5bfb091547$export$5c6bea080a6ee647 = async (provider, ownerAddress, contractAddress, spenderAddress, amount)=>{
|
|
17870
|
+
try {
|
|
17871
|
+
const contract = new (0, Contract$1)(contractAddress, JSON.stringify((0, $d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
|
|
17872
|
+
const approveTransaction = await contract.populateTransaction.approve(spenderAddress, amount);
|
|
17873
|
+
if (approveTransaction) approveTransaction.from = ownerAddress;
|
|
17874
|
+
return approveTransaction;
|
|
17875
|
+
} catch {
|
|
17876
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get the approval transaction for ERC20", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_ALLOWANCE_ERROR, {
|
|
17877
|
+
contractAddress: contractAddress
|
|
17878
|
+
});
|
|
17879
|
+
}
|
|
17880
|
+
};
|
|
17881
|
+
const $95b61a5bfb091547$export$d93c00812189e36 = async (provider, ownerAddress, itemRequirements)=>{
|
|
17882
|
+
let sufficient = true;
|
|
17883
|
+
const sufficientAllowances = [];
|
|
17884
|
+
const erc20s = new Map();
|
|
17885
|
+
const allowancePromises = new Map();
|
|
17886
|
+
const insufficientERC20s = new Map();
|
|
17887
|
+
const transactionPromises = new Map();
|
|
17888
|
+
// Populate maps for both the ERC20 data and promises to get the allowance using the same key
|
|
17889
|
+
// so the promise and data can be linked together when the promise resolves
|
|
17890
|
+
for (const itemRequirement of itemRequirements){
|
|
17891
|
+
if (itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) continue;
|
|
17892
|
+
const { contractAddress: contractAddress, spenderAddress: spenderAddress } = itemRequirement;
|
|
17893
|
+
erc20s.set(`${contractAddress}${spenderAddress}`, itemRequirement);
|
|
17894
|
+
allowancePromises.set(`${contractAddress}${spenderAddress}`, $95b61a5bfb091547$export$41491ea105c4dc2d(provider, ownerAddress, contractAddress, spenderAddress));
|
|
17895
|
+
}
|
|
17896
|
+
const allowances = await Promise.all(allowancePromises.values());
|
|
17897
|
+
const allowancePromiseIds = Array.from(allowancePromises.keys());
|
|
17898
|
+
// Iterate through the allowance promises and get the ERC20 data from the ERC20 map
|
|
17899
|
+
// If the allowance returned for that ERC20 is sufficient then just set the item requirements
|
|
17900
|
+
// If the allowance is insufficient then set the delta and a promise for the approval transaction
|
|
17901
|
+
for(let index = 0; index < allowances.length; index++){
|
|
17902
|
+
const itemRequirement = erc20s.get(allowancePromiseIds[index]);
|
|
17903
|
+
if (!itemRequirement || itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) continue;
|
|
17904
|
+
if (allowances[index].gte(itemRequirement.amount)) {
|
|
17905
|
+
sufficientAllowances.push({
|
|
17906
|
+
sufficient: true,
|
|
17907
|
+
itemRequirement: itemRequirement
|
|
17908
|
+
});
|
|
17909
|
+
continue;
|
|
17910
|
+
}
|
|
17911
|
+
sufficient = false; // Set sufficient false on the root of the return object when an ERC20 is insufficient
|
|
17912
|
+
const { contractAddress: contractAddress, spenderAddress: spenderAddress } = itemRequirement;
|
|
17913
|
+
const delta = itemRequirement.amount.sub(allowances[index]);
|
|
17914
|
+
// Create maps for both the insufficient ERC20 data and the transaction promises using the same key so the results can be merged
|
|
17915
|
+
insufficientERC20s.set(`${contractAddress}${spenderAddress}`, {
|
|
17916
|
+
sufficient: false,
|
|
17917
|
+
delta: delta,
|
|
17918
|
+
itemRequirement: itemRequirement,
|
|
17919
|
+
approvalTransaction: undefined
|
|
17920
|
+
});
|
|
17921
|
+
transactionPromises.set(`${contractAddress}${spenderAddress}`, $95b61a5bfb091547$export$5c6bea080a6ee647(provider, ownerAddress, contractAddress, spenderAddress, delta));
|
|
17922
|
+
}
|
|
17923
|
+
// Resolves the approval transactions and merges them with the insufficient ERC20 data
|
|
17924
|
+
const transactions = await Promise.all(transactionPromises.values());
|
|
17925
|
+
const transactionPromiseIds = Array.from(allowancePromises.keys());
|
|
17926
|
+
transactions.forEach((transaction, index)=>{
|
|
17927
|
+
const insufficientERC20 = insufficientERC20s.get(transactionPromiseIds[index]);
|
|
17928
|
+
if (!insufficientERC20) return;
|
|
17929
|
+
if (insufficientERC20.sufficient) return;
|
|
17930
|
+
insufficientERC20.approvalTransaction = transaction;
|
|
17931
|
+
});
|
|
17932
|
+
// Merge the allowance arrays to get both the sufficient allowances and the insufficient ERC20 allowances
|
|
17933
|
+
return {
|
|
17934
|
+
sufficient: sufficient,
|
|
17935
|
+
allowances: sufficientAllowances.concat(Array.from(insufficientERC20s.values()))
|
|
17936
|
+
};
|
|
17937
|
+
};
|
|
17938
|
+
|
|
17939
|
+
|
|
17940
|
+
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
17941
|
+
const ownerAddress = await provider.getSigner().getAddress();
|
|
17942
|
+
// eslint-disable-next-line no-console
|
|
17943
|
+
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
17944
|
+
const aggregatedItems = ($2499eab4caa6dc71$export$c804c9ade5c28607)(itemRequirements);
|
|
17945
|
+
// eslint-disable-next-line no-console
|
|
17946
|
+
console.log(aggregatedItems);
|
|
17947
|
+
const erc20Allowances = await ($95b61a5bfb091547$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
|
|
17948
|
+
// eslint-disable-next-line no-console
|
|
17949
|
+
console.log(erc20Allowances);
|
|
17950
|
+
return {
|
|
17951
|
+
sufficient: true,
|
|
17952
|
+
transactionRequirements: [
|
|
17953
|
+
{
|
|
17954
|
+
type: ($4b58188d47aafe8d$export$5d3b0ad129b9b98e).GAS,
|
|
17955
|
+
sufficient: true,
|
|
17956
|
+
required: {
|
|
17957
|
+
balance: (BigNumber$1).from(0),
|
|
17958
|
+
formattedBalance: "0",
|
|
17959
|
+
token: {
|
|
17960
|
+
name: "IMX",
|
|
17961
|
+
symbol: "IMX",
|
|
17962
|
+
address: "0x0",
|
|
17963
|
+
decimals: 18
|
|
17964
|
+
}
|
|
17965
|
+
},
|
|
17966
|
+
current: {
|
|
17967
|
+
balance: (BigNumber$1).from(1),
|
|
17968
|
+
formattedBalance: "1",
|
|
17969
|
+
token: {
|
|
17970
|
+
name: "IMX",
|
|
17971
|
+
symbol: "IMX",
|
|
17972
|
+
address: "0x0",
|
|
17973
|
+
decimals: 18
|
|
17974
|
+
}
|
|
17975
|
+
}
|
|
17976
|
+
}
|
|
17977
|
+
]
|
|
17978
|
+
};
|
|
17979
|
+
};
|
|
17980
|
+
|
|
17981
|
+
|
|
17982
|
+
|
|
17983
|
+
|
|
17984
|
+
const $64863c39386de592$export$4249179755829904 = (type, contractAddress, amount, spenderAddress)=>{
|
|
18704
17985
|
switch(type){
|
|
18705
17986
|
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
|
|
18706
17987
|
return {
|
|
18707
17988
|
type: type,
|
|
18708
17989
|
amount: amount,
|
|
18709
17990
|
contractAddress: contractAddress,
|
|
18710
|
-
spenderAddress:
|
|
17991
|
+
spenderAddress: spenderAddress
|
|
18711
17992
|
};
|
|
18712
17993
|
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE:
|
|
18713
17994
|
default:
|
|
@@ -18717,17 +17998,48 @@ const $c147333b1f360629$export$4249179755829904 = (type, contractAddress, amount
|
|
|
18717
17998
|
};
|
|
18718
17999
|
}
|
|
18719
18000
|
};
|
|
18720
|
-
const $
|
|
18001
|
+
const $64863c39386de592$export$e0cb3ec5326d496b = async (actions)=>{
|
|
18002
|
+
for (const action of actions){
|
|
18003
|
+
if (action.type === (ActionType).TRANSACTION && action.purpose === (TransactionPurpose).FULFILL_ORDER) // eslint-disable-next-line no-await-in-loop
|
|
18004
|
+
return await action.buildTransaction();
|
|
18005
|
+
}
|
|
18006
|
+
return undefined;
|
|
18007
|
+
};
|
|
18008
|
+
const $64863c39386de592$export$8f2ff92ab8657f0b = (gasLimit, transaction)=>{
|
|
18009
|
+
if (transaction) return {
|
|
18010
|
+
type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION,
|
|
18011
|
+
transaction: transaction
|
|
18012
|
+
};
|
|
18013
|
+
return {
|
|
18014
|
+
type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
|
|
18015
|
+
gasToken: {
|
|
18016
|
+
type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
|
|
18017
|
+
limit: (BigNumber$1).from(gasLimit)
|
|
18018
|
+
}
|
|
18019
|
+
};
|
|
18020
|
+
};
|
|
18021
|
+
const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, orderId)=>{
|
|
18022
|
+
let orderbook;
|
|
18721
18023
|
let order;
|
|
18024
|
+
let spenderAddress = "";
|
|
18025
|
+
const gasLimit = (constants).estimatedFulfillmentGasGwei;
|
|
18722
18026
|
try {
|
|
18723
|
-
|
|
18027
|
+
orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
18724
18028
|
order = await orderbook.getListing(orderId);
|
|
18029
|
+
const { seaportContractAddress: seaportContractAddress } = orderbook.config();
|
|
18030
|
+
spenderAddress = seaportContractAddress;
|
|
18725
18031
|
} catch (err) {
|
|
18726
18032
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while getting the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ORDER_LISTING_ERROR, {
|
|
18727
18033
|
orderId: orderId,
|
|
18728
18034
|
message: err.message
|
|
18729
18035
|
});
|
|
18730
18036
|
}
|
|
18037
|
+
let unsignedTransaction;
|
|
18038
|
+
try {
|
|
18039
|
+
const fulfillerAddress = await provider.getSigner().getAddress();
|
|
18040
|
+
const { actions: actions } = await orderbook.fulfillOrder(orderId, fulfillerAddress);
|
|
18041
|
+
unsignedTransaction = await $64863c39386de592$export$e0cb3ec5326d496b(actions);
|
|
18042
|
+
} catch {}
|
|
18731
18043
|
let amount = (BigNumber$1).from("0");
|
|
18732
18044
|
let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
18733
18045
|
let contractAddress = "";
|
|
@@ -18753,13 +18065,14 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
18753
18065
|
amount = amount.add((BigNumber$1).from(item.amount));
|
|
18754
18066
|
});
|
|
18755
18067
|
const itemRequirements = [
|
|
18756
|
-
$
|
|
18068
|
+
$64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
|
|
18757
18069
|
];
|
|
18070
|
+
await ($0e7419077c373b24$export$9e073f9ada8c81e6)(provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
|
|
18758
18071
|
return {
|
|
18759
18072
|
itemRequirements: itemRequirements,
|
|
18760
18073
|
gasToken: {
|
|
18761
18074
|
type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
|
|
18762
|
-
limit: (BigNumber$1).from(
|
|
18075
|
+
limit: (BigNumber$1).from(gasLimit)
|
|
18763
18076
|
}
|
|
18764
18077
|
};
|
|
18765
18078
|
};
|
|
@@ -18769,44 +18082,6 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
18769
18082
|
|
|
18770
18083
|
|
|
18771
18084
|
|
|
18772
|
-
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
18773
|
-
// eslint-disable-next-line no-console
|
|
18774
|
-
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
18775
|
-
return {
|
|
18776
|
-
sufficient: true,
|
|
18777
|
-
transactionRequirements: [
|
|
18778
|
-
{
|
|
18779
|
-
type: ($4b58188d47aafe8d$export$5d3b0ad129b9b98e).GAS,
|
|
18780
|
-
sufficient: true,
|
|
18781
|
-
required: {
|
|
18782
|
-
balance: (BigNumber$1).from(0),
|
|
18783
|
-
formattedBalance: "0",
|
|
18784
|
-
token: {
|
|
18785
|
-
name: "IMX",
|
|
18786
|
-
symbol: "IMX",
|
|
18787
|
-
address: "0x0",
|
|
18788
|
-
decimals: 18
|
|
18789
|
-
}
|
|
18790
|
-
},
|
|
18791
|
-
current: {
|
|
18792
|
-
balance: (BigNumber$1).from(1),
|
|
18793
|
-
formattedBalance: "1",
|
|
18794
|
-
token: {
|
|
18795
|
-
name: "IMX",
|
|
18796
|
-
symbol: "IMX",
|
|
18797
|
-
address: "0x0",
|
|
18798
|
-
decimals: 18
|
|
18799
|
-
}
|
|
18800
|
-
}
|
|
18801
|
-
}
|
|
18802
|
-
]
|
|
18803
|
-
};
|
|
18804
|
-
};
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
|
|
18809
|
-
|
|
18810
18085
|
|
|
18811
18086
|
|
|
18812
18087
|
|
|
@@ -18951,7 +18226,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
18951
18226
|
// eslint-disable-next-line no-console
|
|
18952
18227
|
console.warn("This endpoint is currently under construction.");
|
|
18953
18228
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
18954
|
-
await $
|
|
18229
|
+
await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
|
|
18955
18230
|
}
|
|
18956
18231
|
/**
|
|
18957
18232
|
* Determines the transaction requirements to complete a purchase.
|