@imtbl/sdk 0.14.0-alpha.1 → 0.14.0-alpha.2
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 +2 -0
- package/dist/checkout_sdk.js +406 -89
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +7 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +410 -93
- package/dist/index.d.ts +8 -0
- package/dist/index.js +410 -93
- package/dist/orderbook.d.ts +6 -0
- package/dist/orderbook.js +72 -62
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/checkout_sdk.d.ts
CHANGED
|
@@ -11524,6 +11524,7 @@ declare enum CheckoutErrorType {
|
|
|
11524
11524
|
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
11525
11525
|
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
11526
11526
|
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
11527
|
+
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
11527
11528
|
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
11528
11529
|
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
11529
11530
|
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
@@ -11535,6 +11536,7 @@ declare enum CheckoutErrorType {
|
|
|
11535
11536
|
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
11536
11537
|
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
11537
11538
|
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
11539
|
+
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
11538
11540
|
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
11539
11541
|
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
11540
11542
|
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
package/dist/checkout_sdk.js
CHANGED
|
@@ -16176,6 +16176,67 @@ var ActionType;
|
|
|
16176
16176
|
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
16177
16177
|
})(ActionType || (ActionType = {}));
|
|
16178
16178
|
|
|
16179
|
+
function mapFromOpenApiOrder(order) {
|
|
16180
|
+
const buyItems = order.buy.map((item) => {
|
|
16181
|
+
if (item.item_type === 'ERC20') {
|
|
16182
|
+
return {
|
|
16183
|
+
type: 'ERC20',
|
|
16184
|
+
contractAddress: item.contract_address,
|
|
16185
|
+
amount: item.start_amount,
|
|
16186
|
+
};
|
|
16187
|
+
}
|
|
16188
|
+
if (item.item_type === 'NATIVE') {
|
|
16189
|
+
return {
|
|
16190
|
+
type: 'NATIVE',
|
|
16191
|
+
amount: item.start_amount,
|
|
16192
|
+
};
|
|
16193
|
+
}
|
|
16194
|
+
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
16195
|
+
});
|
|
16196
|
+
const sellItems = order.sell.map((item) => {
|
|
16197
|
+
if (item.item_type === 'ERC721') {
|
|
16198
|
+
return {
|
|
16199
|
+
type: 'ERC721',
|
|
16200
|
+
contractAddress: item.contract_address,
|
|
16201
|
+
tokenId: item.token_id,
|
|
16202
|
+
};
|
|
16203
|
+
}
|
|
16204
|
+
throw new Error('Sell items must ERC721');
|
|
16205
|
+
});
|
|
16206
|
+
return {
|
|
16207
|
+
id: order.id,
|
|
16208
|
+
accountAddress: order.account_address,
|
|
16209
|
+
buy: buyItems,
|
|
16210
|
+
sell: sellItems,
|
|
16211
|
+
fees: order.fees.map((fee) => ({
|
|
16212
|
+
amount: fee.amount,
|
|
16213
|
+
recipient: fee.recipient,
|
|
16214
|
+
type: fee.fee_type,
|
|
16215
|
+
})),
|
|
16216
|
+
chain: order.chain,
|
|
16217
|
+
createTime: order.create_time,
|
|
16218
|
+
endTime: order.end_time,
|
|
16219
|
+
protocolData: {
|
|
16220
|
+
counter: order.protocol_data.counter,
|
|
16221
|
+
orderType: order.protocol_data.order_type,
|
|
16222
|
+
seaportAddress: order.protocol_data.seaport_address,
|
|
16223
|
+
seaportVersion: order.protocol_data.seaport_version,
|
|
16224
|
+
zoneAddress: order.protocol_data.zone_address,
|
|
16225
|
+
},
|
|
16226
|
+
salt: order.salt,
|
|
16227
|
+
signature: order.signature,
|
|
16228
|
+
startTime: order.start_time,
|
|
16229
|
+
status: order.status,
|
|
16230
|
+
updateTime: order.update_time,
|
|
16231
|
+
};
|
|
16232
|
+
}
|
|
16233
|
+
function mapFromOpenApiPage(page) {
|
|
16234
|
+
return {
|
|
16235
|
+
nextCursor: page.next_cursor,
|
|
16236
|
+
previousCursor: page.previous_cursor,
|
|
16237
|
+
};
|
|
16238
|
+
}
|
|
16239
|
+
|
|
16179
16240
|
/* eslint-disable */
|
|
16180
16241
|
// TODO: Resolve these from seaport-js.
|
|
16181
16242
|
// There is some bundling issue that is preventing this from working
|
|
@@ -16405,7 +16466,17 @@ class Seaport {
|
|
|
16405
16466
|
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
16406
16467
|
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
16407
16468
|
});
|
|
16408
|
-
|
|
16469
|
+
// Expirtaion bytes in SIP7 extra data [21:29]
|
|
16470
|
+
// In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
|
|
16471
|
+
// In JS slice (start, end_inclusive), (44,60)
|
|
16472
|
+
// 8 bytes uint64 epoch time in seconds
|
|
16473
|
+
const expirationHex = extraData.slice(44, 60);
|
|
16474
|
+
const expirationInSeconds = parseInt(expirationHex, 16);
|
|
16475
|
+
return {
|
|
16476
|
+
actions: fulfillmentActions,
|
|
16477
|
+
expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
|
|
16478
|
+
order: mapFromOpenApiOrder(order),
|
|
16479
|
+
};
|
|
16409
16480
|
}
|
|
16410
16481
|
async cancelOrder(order, account) {
|
|
16411
16482
|
const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
@@ -16594,67 +16665,6 @@ function getOrderbookConfig(environment) {
|
|
|
16594
16665
|
}
|
|
16595
16666
|
}
|
|
16596
16667
|
|
|
16597
|
-
function mapFromOpenApiOrder(order) {
|
|
16598
|
-
const buyItems = order.buy.map((item) => {
|
|
16599
|
-
if (item.item_type === 'ERC20') {
|
|
16600
|
-
return {
|
|
16601
|
-
type: 'ERC20',
|
|
16602
|
-
contractAddress: item.contract_address,
|
|
16603
|
-
amount: item.start_amount,
|
|
16604
|
-
};
|
|
16605
|
-
}
|
|
16606
|
-
if (item.item_type === 'NATIVE') {
|
|
16607
|
-
return {
|
|
16608
|
-
type: 'NATIVE',
|
|
16609
|
-
amount: item.start_amount,
|
|
16610
|
-
};
|
|
16611
|
-
}
|
|
16612
|
-
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
16613
|
-
});
|
|
16614
|
-
const sellItems = order.sell.map((item) => {
|
|
16615
|
-
if (item.item_type === 'ERC721') {
|
|
16616
|
-
return {
|
|
16617
|
-
type: 'ERC721',
|
|
16618
|
-
contractAddress: item.contract_address,
|
|
16619
|
-
tokenId: item.token_id,
|
|
16620
|
-
};
|
|
16621
|
-
}
|
|
16622
|
-
throw new Error('Sell items must ERC721');
|
|
16623
|
-
});
|
|
16624
|
-
return {
|
|
16625
|
-
id: order.id,
|
|
16626
|
-
accountAddress: order.account_address,
|
|
16627
|
-
buy: buyItems,
|
|
16628
|
-
sell: sellItems,
|
|
16629
|
-
fees: order.fees.map((fee) => ({
|
|
16630
|
-
amount: fee.amount,
|
|
16631
|
-
recipient: fee.recipient,
|
|
16632
|
-
type: fee.fee_type,
|
|
16633
|
-
})),
|
|
16634
|
-
chain: order.chain,
|
|
16635
|
-
createTime: order.create_time,
|
|
16636
|
-
endTime: order.end_time,
|
|
16637
|
-
protocolData: {
|
|
16638
|
-
counter: order.protocol_data.counter,
|
|
16639
|
-
orderType: order.protocol_data.order_type,
|
|
16640
|
-
seaportAddress: order.protocol_data.seaport_address,
|
|
16641
|
-
seaportVersion: order.protocol_data.seaport_version,
|
|
16642
|
-
zoneAddress: order.protocol_data.zone_address,
|
|
16643
|
-
},
|
|
16644
|
-
salt: order.salt,
|
|
16645
|
-
signature: order.signature,
|
|
16646
|
-
startTime: order.start_time,
|
|
16647
|
-
status: order.status,
|
|
16648
|
-
updateTime: order.update_time,
|
|
16649
|
-
};
|
|
16650
|
-
}
|
|
16651
|
-
function mapFromOpenApiPage(page) {
|
|
16652
|
-
return {
|
|
16653
|
-
nextCursor: page.next_cursor,
|
|
16654
|
-
previousCursor: page.previous_cursor,
|
|
16655
|
-
};
|
|
16656
|
-
}
|
|
16657
|
-
|
|
16658
16668
|
class SeaportLibFactory {
|
|
16659
16669
|
defaultSeaportContractAddress;
|
|
16660
16670
|
provider;
|
|
@@ -16928,6 +16938,8 @@ const $e768639828688ca3$export$44dde05038008549 = {
|
|
|
16928
16938
|
|
|
16929
16939
|
|
|
16930
16940
|
const $d85ad1457a3f1a83$export$7d3a9eeba384fa59 = "development";
|
|
16941
|
+
const $d85ad1457a3f1a83$export$b80040cb173ba6e9 = "0x0000000000000000000000000000000000001010";
|
|
16942
|
+
const $d85ad1457a3f1a83$export$903389470ba9433c = 18;
|
|
16931
16943
|
const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
16932
16944
|
[$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://checkout-api.dev.immutable.com",
|
|
16933
16945
|
[(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
@@ -17210,6 +17222,25 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
|
|
|
17210
17222
|
payable: false,
|
|
17211
17223
|
stateMutability: "view",
|
|
17212
17224
|
type: "function"
|
|
17225
|
+
},
|
|
17226
|
+
{
|
|
17227
|
+
inputs: [
|
|
17228
|
+
{
|
|
17229
|
+
internalType: "uint256",
|
|
17230
|
+
name: "tokenId",
|
|
17231
|
+
type: "uint256"
|
|
17232
|
+
}
|
|
17233
|
+
],
|
|
17234
|
+
name: "ownerOf",
|
|
17235
|
+
outputs: [
|
|
17236
|
+
{
|
|
17237
|
+
internalType: "address",
|
|
17238
|
+
name: "",
|
|
17239
|
+
type: "address"
|
|
17240
|
+
}
|
|
17241
|
+
],
|
|
17242
|
+
stateMutability: "view",
|
|
17243
|
+
type: "function"
|
|
17213
17244
|
}
|
|
17214
17245
|
];
|
|
17215
17246
|
|
|
@@ -17251,6 +17282,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
17251
17282
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
17252
17283
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
17253
17284
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
17285
|
+
CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
|
|
17254
17286
|
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
17255
17287
|
CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
|
|
17256
17288
|
CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
|
|
@@ -17262,6 +17294,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
17262
17294
|
CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
17263
17295
|
CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
|
|
17264
17296
|
CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
|
|
17297
|
+
CheckoutErrorType["UNSUPPORTED_BALANCE_REQUIREMENT_ERROR"] = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR";
|
|
17265
17298
|
CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
|
|
17266
17299
|
CheckoutErrorType["SWITCH_NETWORK_UNSUPPORTED"] = "SWITCH_NETWORK_UNSUPPORTED";
|
|
17267
17300
|
CheckoutErrorType["GET_ERC20_ALLOWANCE_ERROR"] = "GET_ERC20_ALLOWANCE_ERROR";
|
|
@@ -17483,39 +17516,48 @@ const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, w
|
|
|
17483
17516
|
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, contractAddress) {
|
|
17484
17517
|
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
17485
17518
|
const contract = new (Contract$1)(contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), web3Provider);
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17496
|
-
|
|
17497
|
-
|
|
17498
|
-
|
|
17499
|
-
|
|
17500
|
-
|
|
17519
|
+
return Promise.all([
|
|
17520
|
+
contract.name(),
|
|
17521
|
+
contract.symbol(),
|
|
17522
|
+
contract.balanceOf(walletAddress),
|
|
17523
|
+
contract.decimals()
|
|
17524
|
+
]).then(([name, symbol, balance, decimals])=>{
|
|
17525
|
+
const formattedBalance = (utils).formatUnits(balance, decimals);
|
|
17526
|
+
return {
|
|
17527
|
+
balance: balance,
|
|
17528
|
+
formattedBalance: formattedBalance,
|
|
17529
|
+
token: {
|
|
17530
|
+
name: name,
|
|
17531
|
+
symbol: symbol,
|
|
17532
|
+
decimals: decimals,
|
|
17533
|
+
address: contractAddress
|
|
17534
|
+
}
|
|
17535
|
+
};
|
|
17536
|
+
});
|
|
17501
17537
|
}, {
|
|
17502
17538
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
17503
17539
|
});
|
|
17504
17540
|
}
|
|
17505
|
-
const $1564e43dde50bb61$export$
|
|
17506
|
-
const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
|
|
17507
|
-
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
17508
|
-
chainId: chainId
|
|
17509
|
-
});
|
|
17541
|
+
const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
|
|
17510
17542
|
const allBalancePromises = [];
|
|
17511
|
-
|
|
17512
|
-
|
|
17543
|
+
tokens.forEach((token)=>{
|
|
17544
|
+
// Check for NATIVE token
|
|
17545
|
+
if (!token.address || token.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(config, web3Provider, walletAddress));
|
|
17546
|
+
else allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, token.address));
|
|
17547
|
+
});
|
|
17513
17548
|
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
17514
|
-
const
|
|
17549
|
+
const balances = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
|
|
17515
17550
|
return {
|
|
17516
|
-
balances:
|
|
17551
|
+
balances: balances
|
|
17517
17552
|
};
|
|
17518
17553
|
};
|
|
17554
|
+
const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, walletAddress, chainId)=>{
|
|
17555
|
+
const { tokens: tokens } = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
|
|
17556
|
+
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
17557
|
+
chainId: chainId
|
|
17558
|
+
});
|
|
17559
|
+
return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
|
|
17560
|
+
};
|
|
17519
17561
|
|
|
17520
17562
|
|
|
17521
17563
|
|
|
@@ -18264,6 +18306,278 @@ const $35c3fc7013888ba5$export$be546c525d418988 = async (provider, ownerAddress,
|
|
|
18264
18306
|
|
|
18265
18307
|
|
|
18266
18308
|
|
|
18309
|
+
/* eslint-disable arrow-body-style */
|
|
18310
|
+
|
|
18311
|
+
|
|
18312
|
+
|
|
18313
|
+
|
|
18314
|
+
|
|
18315
|
+
const $aa6caea9a60d18c7$export$f4d35754ad350071 = (itemRequirements)=>{
|
|
18316
|
+
const aggregatedMap = new Map();
|
|
18317
|
+
const aggregatedItemRequirements = [];
|
|
18318
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
18319
|
+
const { type: type } = itemRequirement;
|
|
18320
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
18321
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
18322
|
+
return;
|
|
18323
|
+
}
|
|
18324
|
+
const { amount: amount } = itemRequirement;
|
|
18325
|
+
const aggregateItem = aggregatedMap.get(type);
|
|
18326
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
18327
|
+
else aggregatedMap.set(type, {
|
|
18328
|
+
...itemRequirement
|
|
18329
|
+
});
|
|
18330
|
+
});
|
|
18331
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
18332
|
+
};
|
|
18333
|
+
const $aa6caea9a60d18c7$export$b8de545554d50911 = (itemRequirements)=>{
|
|
18334
|
+
const aggregatedMap = new Map();
|
|
18335
|
+
const aggregatedItemRequirements = [];
|
|
18336
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
18337
|
+
const { type: type } = itemRequirement;
|
|
18338
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
|
|
18339
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
18340
|
+
return;
|
|
18341
|
+
}
|
|
18342
|
+
const { contractAddress: contractAddress, amount: amount } = itemRequirement;
|
|
18343
|
+
const key = `${contractAddress}`;
|
|
18344
|
+
const aggregateItem = aggregatedMap.get(key);
|
|
18345
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
18346
|
+
else aggregatedMap.set(key, {
|
|
18347
|
+
...itemRequirement
|
|
18348
|
+
});
|
|
18349
|
+
});
|
|
18350
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
18351
|
+
};
|
|
18352
|
+
const $aa6caea9a60d18c7$export$74fbc29ef48b4f31 = (itemRequirements)=>{
|
|
18353
|
+
const aggregatedMap = new Map();
|
|
18354
|
+
const aggregatedItemRequirements = [];
|
|
18355
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
18356
|
+
const { type: type } = itemRequirement;
|
|
18357
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) {
|
|
18358
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
18359
|
+
return;
|
|
18360
|
+
}
|
|
18361
|
+
const { contractAddress: contractAddress, id: id } = itemRequirement;
|
|
18362
|
+
const key = `${contractAddress}${id}`;
|
|
18363
|
+
const aggregateItem = aggregatedMap.get(key);
|
|
18364
|
+
if (!aggregateItem) aggregatedMap.set(key, {
|
|
18365
|
+
...itemRequirement
|
|
18366
|
+
});
|
|
18367
|
+
});
|
|
18368
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
18369
|
+
};
|
|
18370
|
+
const $aa6caea9a60d18c7$export$f96d1c819a615a64 = (itemRequirements)=>$aa6caea9a60d18c7$export$74fbc29ef48b4f31($aa6caea9a60d18c7$export$b8de545554d50911($aa6caea9a60d18c7$export$f4d35754ad350071(itemRequirements)));
|
|
18371
|
+
|
|
18372
|
+
|
|
18373
|
+
/* eslint-disable arrow-body-style */
|
|
18374
|
+
|
|
18375
|
+
const $73d2282a108cc7e2$export$ed7929b58bab85da = (itemRequirements)=>itemRequirements.map((itemRequirement)=>{
|
|
18376
|
+
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
|
|
18377
|
+
name: "IMX",
|
|
18378
|
+
symbol: "IMX",
|
|
18379
|
+
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
18380
|
+
};
|
|
18381
|
+
return {
|
|
18382
|
+
name: itemRequirement.type,
|
|
18383
|
+
address: itemRequirement.contractAddress
|
|
18384
|
+
};
|
|
18385
|
+
});
|
|
18386
|
+
const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
|
|
18387
|
+
const requiredBalance = (BigNumber$1).from(1);
|
|
18388
|
+
// Find the requirements related balance
|
|
18389
|
+
const itemBalanceResult = balances.find((balance)=>{
|
|
18390
|
+
const balanceERC721Result = balance;
|
|
18391
|
+
return balanceERC721Result.contractAddress === itemRequirement.contractAddress && balanceERC721Result.id === itemRequirement.id;
|
|
18392
|
+
});
|
|
18393
|
+
// Calculate the balance delta
|
|
18394
|
+
const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
|
|
18395
|
+
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
18396
|
+
let erc721BalanceResult = itemBalanceResult;
|
|
18397
|
+
if (!erc721BalanceResult) erc721BalanceResult = {
|
|
18398
|
+
balance: (BigNumber$1).from(0),
|
|
18399
|
+
formattedBalance: "0",
|
|
18400
|
+
contractAddress: itemRequirement.contractAddress,
|
|
18401
|
+
id: itemRequirement.id
|
|
18402
|
+
};
|
|
18403
|
+
return {
|
|
18404
|
+
sufficient: sufficient,
|
|
18405
|
+
type: itemRequirement.type,
|
|
18406
|
+
delta: {
|
|
18407
|
+
balance: delta,
|
|
18408
|
+
formattedBalance: delta.toString()
|
|
18409
|
+
},
|
|
18410
|
+
current: erc721BalanceResult,
|
|
18411
|
+
required: {
|
|
18412
|
+
...erc721BalanceResult,
|
|
18413
|
+
balance: (BigNumber$1).from(1),
|
|
18414
|
+
formattedBalance: "1"
|
|
18415
|
+
}
|
|
18416
|
+
};
|
|
18417
|
+
};
|
|
18418
|
+
const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
18419
|
+
let itemBalanceResult;
|
|
18420
|
+
// Get the requirements related balance
|
|
18421
|
+
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) itemBalanceResult = balances.find((balance)=>{
|
|
18422
|
+
return balance.token?.address === itemRequirement.contractAddress;
|
|
18423
|
+
});
|
|
18424
|
+
else if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) itemBalanceResult = balances.find((balance)=>{
|
|
18425
|
+
return !("address" in balance.token) || balance.token?.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9);
|
|
18426
|
+
});
|
|
18427
|
+
// Calculate the balance delta
|
|
18428
|
+
const requiredBalance = itemRequirement.amount;
|
|
18429
|
+
const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
|
|
18430
|
+
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
18431
|
+
let decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
18432
|
+
if (itemBalanceResult) decimals = itemBalanceResult.token?.decimals ?? ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
18433
|
+
let tokenBalanceResult = itemBalanceResult;
|
|
18434
|
+
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
18435
|
+
// No token balance so mark as zero native
|
|
18436
|
+
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
18437
|
+
balance: (BigNumber$1).from(0),
|
|
18438
|
+
formattedBalance: "0",
|
|
18439
|
+
token: {
|
|
18440
|
+
name: "IMX",
|
|
18441
|
+
symbol: "IMX",
|
|
18442
|
+
decimals: ($d85ad1457a3f1a83$export$903389470ba9433c),
|
|
18443
|
+
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
18444
|
+
}
|
|
18445
|
+
};
|
|
18446
|
+
return {
|
|
18447
|
+
sufficient: sufficient,
|
|
18448
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
18449
|
+
delta: {
|
|
18450
|
+
balance: delta,
|
|
18451
|
+
formattedBalance: (utils).formatUnits(delta, decimals)
|
|
18452
|
+
},
|
|
18453
|
+
current: tokenBalanceResult,
|
|
18454
|
+
required: {
|
|
18455
|
+
...tokenBalanceResult,
|
|
18456
|
+
balance: (BigNumber$1).from(itemRequirement.amount),
|
|
18457
|
+
formattedBalance: (utils).formatUnits(itemRequirement.amount, decimals)
|
|
18458
|
+
}
|
|
18459
|
+
};
|
|
18460
|
+
}
|
|
18461
|
+
// No token balance so mark as zero
|
|
18462
|
+
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
18463
|
+
balance: (BigNumber$1).from(0),
|
|
18464
|
+
formattedBalance: "0",
|
|
18465
|
+
token: {
|
|
18466
|
+
address: itemRequirement.contractAddress
|
|
18467
|
+
}
|
|
18468
|
+
};
|
|
18469
|
+
return {
|
|
18470
|
+
sufficient: sufficient,
|
|
18471
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
18472
|
+
delta: {
|
|
18473
|
+
balance: delta,
|
|
18474
|
+
formattedBalance: (utils).formatUnits(delta, decimals)
|
|
18475
|
+
},
|
|
18476
|
+
current: tokenBalanceResult,
|
|
18477
|
+
required: {
|
|
18478
|
+
...tokenBalanceResult,
|
|
18479
|
+
balance: (BigNumber$1).from(itemRequirement.amount),
|
|
18480
|
+
formattedBalance: (utils).formatUnits(itemRequirement.amount, decimals)
|
|
18481
|
+
}
|
|
18482
|
+
};
|
|
18483
|
+
};
|
|
18484
|
+
|
|
18485
|
+
|
|
18486
|
+
/**
|
|
18487
|
+
* Gets the balances for all NATIVE and ERC20 balance requirements.
|
|
18488
|
+
*/ const $beb896e098e41faf$var$getTokenBalances = async (config, provider, ownerAddress, itemRequirements)=>{
|
|
18489
|
+
let tokenBalances = [];
|
|
18490
|
+
try {
|
|
18491
|
+
const tokenList = (0, $73d2282a108cc7e2$export$ed7929b58bab85da)(itemRequirements);
|
|
18492
|
+
const { balances: balances } = await (0, $1564e43dde50bb61$export$a3238cee431627c6)(config, provider, ownerAddress, tokenList);
|
|
18493
|
+
tokenBalances = [
|
|
18494
|
+
...balances.map((balance)=>balance)
|
|
18495
|
+
];
|
|
18496
|
+
} catch (error) {
|
|
18497
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR);
|
|
18498
|
+
}
|
|
18499
|
+
return tokenBalances;
|
|
18500
|
+
};
|
|
18501
|
+
/**
|
|
18502
|
+
* Gets the balances for all ERC721 balance requirements.
|
|
18503
|
+
*/ const $beb896e098e41faf$var$getERC721Balances = async (provider, ownerAddress, itemRequirements)=>{
|
|
18504
|
+
const erc721Balances = [];
|
|
18505
|
+
// Setup maps to be able to link data back to the associated promises
|
|
18506
|
+
const erc721s = new Map();
|
|
18507
|
+
const erc721OwnershipPromises = new Map();
|
|
18508
|
+
itemRequirements.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721).forEach((itemRequirement)=>{
|
|
18509
|
+
const erc721Requirement = itemRequirement;
|
|
18510
|
+
const contract = new (Contract$1)(erc721Requirement.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$8b8be7a2a654f23e)), provider);
|
|
18511
|
+
erc721s.set(erc721Requirement.contractAddress, itemRequirement);
|
|
18512
|
+
erc721OwnershipPromises.set(erc721Requirement.contractAddress, contract.ownerOf(erc721Requirement.id));
|
|
18513
|
+
});
|
|
18514
|
+
try {
|
|
18515
|
+
// Convert ERC721 ownership into a balance result
|
|
18516
|
+
const erc721Owners = await Promise.all(erc721OwnershipPromises.values());
|
|
18517
|
+
const erc721OwnersPromiseIds = Array.from(erc721OwnershipPromises.keys());
|
|
18518
|
+
erc721Owners.forEach((erc721OwnerAddress, index)=>{
|
|
18519
|
+
const itemRequirement = erc721s.get(erc721OwnersPromiseIds[index]);
|
|
18520
|
+
let itemCount = 0;
|
|
18521
|
+
if (itemRequirement && ownerAddress === erc721OwnerAddress) itemCount = 1;
|
|
18522
|
+
erc721Balances.push({
|
|
18523
|
+
balance: (0, BigNumber$1).from(itemCount),
|
|
18524
|
+
formattedBalance: itemCount.toString(),
|
|
18525
|
+
contractAddress: itemRequirement.contractAddress,
|
|
18526
|
+
id: itemRequirement.id
|
|
18527
|
+
});
|
|
18528
|
+
});
|
|
18529
|
+
} catch (error) {
|
|
18530
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get ERC721 balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC721_BALANCE_ERROR);
|
|
18531
|
+
}
|
|
18532
|
+
return erc721Balances;
|
|
18533
|
+
};
|
|
18534
|
+
const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, ownerAddress, itemRequirements)=>{
|
|
18535
|
+
const aggregatedItems = ($aa6caea9a60d18c7$export$f96d1c819a615a64)(itemRequirements);
|
|
18536
|
+
if (aggregatedItems.filter((itemRequirement)=>{
|
|
18537
|
+
return itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721 && itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
18538
|
+
}).length > 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Unsupported item requirement balance check", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);
|
|
18539
|
+
// Get all ERC20 and NATIVE balances
|
|
18540
|
+
const currentBalances = [];
|
|
18541
|
+
const tokenItemRequirements = aggregatedItems.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 || itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE);
|
|
18542
|
+
if (tokenItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
18543
|
+
// Get all ERC721 balances
|
|
18544
|
+
const erc721ItemRequirements = aggregatedItems.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721);
|
|
18545
|
+
if (erc721ItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
18546
|
+
// Wait for all balances and calculate the requirements
|
|
18547
|
+
const balanceRequirements = await Promise.all(currentBalances).then((balances)=>{
|
|
18548
|
+
const requirements = [];
|
|
18549
|
+
if (balances.length > 1 || tokenItemRequirements.length > 0) {
|
|
18550
|
+
const tokenBalances = balances[0];
|
|
18551
|
+
tokenItemRequirements.forEach((tokenItemRequirement)=>{
|
|
18552
|
+
requirements.push(($73d2282a108cc7e2$export$6ab9757fda54db7e)(tokenItemRequirement, tokenBalances));
|
|
18553
|
+
});
|
|
18554
|
+
if (erc721ItemRequirements.length > 0) {
|
|
18555
|
+
const erc721Balances = balances[1];
|
|
18556
|
+
erc721ItemRequirements.forEach((erc721ItemRequirement)=>{
|
|
18557
|
+
requirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(erc721ItemRequirement, erc721Balances));
|
|
18558
|
+
});
|
|
18559
|
+
}
|
|
18560
|
+
} else if (erc721ItemRequirements.length > 0) {
|
|
18561
|
+
// Only erc721
|
|
18562
|
+
const erc721Balances = balances[0];
|
|
18563
|
+
erc721ItemRequirements.forEach((erc721ItemRequirement)=>{
|
|
18564
|
+
requirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(erc721ItemRequirement, erc721Balances));
|
|
18565
|
+
});
|
|
18566
|
+
}
|
|
18567
|
+
return requirements;
|
|
18568
|
+
});
|
|
18569
|
+
const sufficient = balanceRequirements.reduce((acc, balanceRequirement)=>{
|
|
18570
|
+
return acc && balanceRequirement.sufficient;
|
|
18571
|
+
}, true);
|
|
18572
|
+
return {
|
|
18573
|
+
sufficient: sufficient,
|
|
18574
|
+
itemRequirements: balanceRequirements
|
|
18575
|
+
};
|
|
18576
|
+
};
|
|
18577
|
+
|
|
18578
|
+
|
|
18579
|
+
|
|
18580
|
+
|
|
18267
18581
|
|
|
18268
18582
|
|
|
18269
18583
|
|
|
@@ -18320,7 +18634,7 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
18320
18634
|
};
|
|
18321
18635
|
|
|
18322
18636
|
|
|
18323
|
-
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
18637
|
+
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
18324
18638
|
// eslint-disable-next-line no-console
|
|
18325
18639
|
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
18326
18640
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
@@ -18339,6 +18653,9 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequireme
|
|
|
18339
18653
|
}
|
|
18340
18654
|
// eslint-disable-next-line no-console
|
|
18341
18655
|
console.log("Aggregated Items", aggregatedItems);
|
|
18656
|
+
const balanceRequirements = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
18657
|
+
// eslint-disable-next-line no-console
|
|
18658
|
+
console.log("Balance Requirements", balanceRequirements);
|
|
18342
18659
|
return {
|
|
18343
18660
|
sufficient: true,
|
|
18344
18661
|
transactionRequirements: [
|
|
@@ -18459,7 +18776,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
18459
18776
|
const itemRequirements = [
|
|
18460
18777
|
$64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
|
|
18461
18778
|
];
|
|
18462
|
-
await ($0e7419077c373b24$export$9e073f9ada8c81e6)(provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
|
|
18779
|
+
await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
|
|
18463
18780
|
return {
|
|
18464
18781
|
itemRequirements: itemRequirements,
|
|
18465
18782
|
gasToken: {
|
|
@@ -18628,7 +18945,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
18628
18945
|
// eslint-disable-next-line no-console
|
|
18629
18946
|
console.warn("This endpoint is currently under construction.");
|
|
18630
18947
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
18631
|
-
await $0e7419077c373b24$export$9e073f9ada8c81e6(web3Provider, params.itemRequirements, params.transactionOrGasAmount);
|
|
18948
|
+
await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, params.itemRequirements, params.transactionOrGasAmount);
|
|
18632
18949
|
}
|
|
18633
18950
|
/**
|
|
18634
18951
|
* Checks if the given object is a Web3 provider.
|
package/dist/checkout_widgets.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha.
|
|
7
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha.2";
|
|
8
8
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
9
9
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
16
16
|
chainID,
|
|
17
17
|
coreContractAddress,
|
|
18
18
|
registrationContractAddress,
|
|
19
|
-
sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.
|
|
19
|
+
sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.2',
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Sets `sdkVersion` at the time of build
|