@imtbl/sdk 0.15.1-alpha → 0.16.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain_data.js +252 -33
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +56 -1
- package/dist/checkout_sdk.js +460 -92
- package/dist/checkout_widgets.d.ts +1 -0
- package/dist/checkout_widgets.js +1 -1
- package/dist/erc721.d.ts +4 -4
- package/dist/erc721.js +57 -69
- package/dist/erc721_mint_by_id.d.ts +4 -4
- package/dist/erc721_mint_by_id.js +51 -51
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +15 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +857 -253
- package/dist/index.d.ts +225 -16
- package/dist/index.js +855 -251
- package/dist/orderbook.d.ts +150 -4
- package/dist/orderbook.js +135 -0
- package/dist/passport.d.ts +1 -0
- package/dist/passport.js +228 -18
- package/package.json +1 -1
package/dist/checkout_sdk.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
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
|
+
import $7v2Z6$axios, { HttpStatusCode } from 'axios';
|
|
3
4
|
import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
|
|
4
5
|
import { TradeType, Token, Percent, CurrencyAmount } from '@uniswap/sdk-core';
|
|
5
6
|
import assert from 'assert';
|
|
@@ -7,7 +8,6 @@ import { BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
|
|
|
7
8
|
import { FeeAmount, Route, SwapQuoter, Pool, Trade, toHex as toHex$1, encodeRouteToPath } from '@uniswap/v3-sdk';
|
|
8
9
|
import { keccak256 as keccak256$1 } from '@ethersproject/solidity';
|
|
9
10
|
import { SwapRouter } from '@uniswap/router-sdk';
|
|
10
|
-
import axios from 'axios';
|
|
11
11
|
import FormData from 'form-data';
|
|
12
12
|
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
13
13
|
|
|
@@ -36,8 +36,7 @@ const ETH_MAINNET_CHAIN_ID = '1';
|
|
|
36
36
|
/**
|
|
37
37
|
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
38
38
|
*/
|
|
39
|
-
const ZKEVM_DEVNET_CHAIN_ID = '
|
|
40
|
-
/**
|
|
39
|
+
const ZKEVM_DEVNET_CHAIN_ID = '13473';
|
|
41
40
|
/**
|
|
42
41
|
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
43
42
|
*/
|
|
@@ -12318,10 +12317,10 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
|
|
|
12318
12317
|
*/
|
|
12319
12318
|
const CONTRACTS_FOR_BRIDGE = new Map()
|
|
12320
12319
|
.set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
|
|
12321
|
-
rootChainERC20Predicate: '
|
|
12322
|
-
rootChainStateSender: '
|
|
12323
|
-
rootChainCheckpointManager: '
|
|
12324
|
-
rootChainExitHelper: '
|
|
12320
|
+
rootChainERC20Predicate: '0x75E468cF088F947B96422996132FbE71160F21F1',
|
|
12321
|
+
rootChainStateSender: '0xbdC11416f01b122b7621855e61c99C7ED986F894',
|
|
12322
|
+
rootChainCheckpointManager: '0x0721b564a96466b864A998D31846Ba409d21092B',
|
|
12323
|
+
rootChainExitHelper: '0x0a2cb3f90aE65429E5c516af500F59d8fed51844',
|
|
12325
12324
|
childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
|
|
12326
12325
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
12327
12326
|
})
|
|
@@ -15889,7 +15888,7 @@ const getRequestBody = (options) => {
|
|
|
15889
15888
|
return undefined;
|
|
15890
15889
|
};
|
|
15891
15890
|
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
15892
|
-
const source = axios.CancelToken.source();
|
|
15891
|
+
const source = $7v2Z6$axios.CancelToken.source();
|
|
15893
15892
|
const requestConfig = {
|
|
15894
15893
|
url,
|
|
15895
15894
|
headers,
|
|
@@ -15900,7 +15899,7 @@ const sendRequest = async (config, options, url, body, formData, headers, onCanc
|
|
|
15900
15899
|
};
|
|
15901
15900
|
onCancel(() => source.cancel('The user aborted a request.'));
|
|
15902
15901
|
try {
|
|
15903
|
-
return await axios.request(requestConfig);
|
|
15902
|
+
return await $7v2Z6$axios.request(requestConfig);
|
|
15904
15903
|
}
|
|
15905
15904
|
catch (error) {
|
|
15906
15905
|
const axiosError = error;
|
|
@@ -16094,6 +16093,54 @@ class OrdersService {
|
|
|
16094
16093
|
},
|
|
16095
16094
|
});
|
|
16096
16095
|
}
|
|
16096
|
+
/**
|
|
16097
|
+
* List all trades
|
|
16098
|
+
* List all trades
|
|
16099
|
+
* @returns ListTradeResult OK response.
|
|
16100
|
+
* @throws ApiError
|
|
16101
|
+
*/
|
|
16102
|
+
listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
16103
|
+
return this.httpRequest.request({
|
|
16104
|
+
method: 'GET',
|
|
16105
|
+
url: '/v1/chains/{chain_name}/trades',
|
|
16106
|
+
path: {
|
|
16107
|
+
'chain_name': chainName,
|
|
16108
|
+
},
|
|
16109
|
+
query: {
|
|
16110
|
+
'account_address': accountAddress,
|
|
16111
|
+
'page_size': pageSize,
|
|
16112
|
+
'sort_by': sortBy,
|
|
16113
|
+
'sort_direction': sortDirection,
|
|
16114
|
+
'page_cursor': pageCursor,
|
|
16115
|
+
},
|
|
16116
|
+
errors: {
|
|
16117
|
+
400: `Bad Request (400)`,
|
|
16118
|
+
404: `The specified resource was not found (404)`,
|
|
16119
|
+
500: `Internal Server Error (500)`,
|
|
16120
|
+
},
|
|
16121
|
+
});
|
|
16122
|
+
}
|
|
16123
|
+
/**
|
|
16124
|
+
* Get a single trade by ID
|
|
16125
|
+
* Get a single trade by ID
|
|
16126
|
+
* @returns TradeResult OK response.
|
|
16127
|
+
* @throws ApiError
|
|
16128
|
+
*/
|
|
16129
|
+
getTrade({ chainName, tradeId, }) {
|
|
16130
|
+
return this.httpRequest.request({
|
|
16131
|
+
method: 'GET',
|
|
16132
|
+
url: '/v1/chains/{chain_name}/trades/{trade_id}',
|
|
16133
|
+
path: {
|
|
16134
|
+
'chain_name': chainName,
|
|
16135
|
+
'trade_id': tradeId,
|
|
16136
|
+
},
|
|
16137
|
+
errors: {
|
|
16138
|
+
400: `Bad Request (400)`,
|
|
16139
|
+
404: `The specified resource was not found (404)`,
|
|
16140
|
+
500: `Internal Server Error (500)`,
|
|
16141
|
+
},
|
|
16142
|
+
});
|
|
16143
|
+
}
|
|
16097
16144
|
}
|
|
16098
16145
|
|
|
16099
16146
|
class OrderBookClient {
|
|
@@ -16230,6 +16277,57 @@ function mapFromOpenApiOrder(order) {
|
|
|
16230
16277
|
updateTime: order.update_time,
|
|
16231
16278
|
};
|
|
16232
16279
|
}
|
|
16280
|
+
function mapFromOpenApiTrade(trade) {
|
|
16281
|
+
const buyItems = trade.buy.map((item) => {
|
|
16282
|
+
if (item.item_type === 'ERC20') {
|
|
16283
|
+
return {
|
|
16284
|
+
type: 'ERC20',
|
|
16285
|
+
contractAddress: item.contract_address,
|
|
16286
|
+
amount: item.start_amount,
|
|
16287
|
+
};
|
|
16288
|
+
}
|
|
16289
|
+
if (item.item_type === 'NATIVE') {
|
|
16290
|
+
return {
|
|
16291
|
+
type: 'NATIVE',
|
|
16292
|
+
amount: item.start_amount,
|
|
16293
|
+
};
|
|
16294
|
+
}
|
|
16295
|
+
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
16296
|
+
});
|
|
16297
|
+
const sellItems = trade.sell.map((item) => {
|
|
16298
|
+
if (item.item_type === 'ERC721') {
|
|
16299
|
+
return {
|
|
16300
|
+
type: 'ERC721',
|
|
16301
|
+
contractAddress: item.contract_address,
|
|
16302
|
+
tokenId: item.token_id,
|
|
16303
|
+
};
|
|
16304
|
+
}
|
|
16305
|
+
throw new Error('Sell items must ERC721');
|
|
16306
|
+
});
|
|
16307
|
+
return {
|
|
16308
|
+
id: trade.id,
|
|
16309
|
+
orderId: trade.order_id,
|
|
16310
|
+
buy: buyItems,
|
|
16311
|
+
sell: sellItems,
|
|
16312
|
+
buyerFees: trade.buyer_fees.map((fee) => ({
|
|
16313
|
+
amount: fee.amount,
|
|
16314
|
+
recipient: fee.recipient,
|
|
16315
|
+
type: fee.fee_type,
|
|
16316
|
+
})),
|
|
16317
|
+
chain: trade.chain,
|
|
16318
|
+
indexedAt: trade.indexed_at,
|
|
16319
|
+
blockchainMetadata: {
|
|
16320
|
+
blockNumber: trade.blockchain_metadata.block_number,
|
|
16321
|
+
logIndex: trade.blockchain_metadata.log_index,
|
|
16322
|
+
transactionHash: trade.blockchain_metadata.transaction_hash,
|
|
16323
|
+
transactionIndex: trade.blockchain_metadata.transaction_index,
|
|
16324
|
+
},
|
|
16325
|
+
buyerAddress: trade.buyer_address,
|
|
16326
|
+
makerAddress: trade.maker_address,
|
|
16327
|
+
sellerAddress: trade.seller_address,
|
|
16328
|
+
takerAddress: trade.taker_address,
|
|
16329
|
+
};
|
|
16330
|
+
}
|
|
16233
16331
|
function mapFromOpenApiPage(page) {
|
|
16234
16332
|
return {
|
|
16235
16333
|
nextCursor: page.next_cursor,
|
|
@@ -16559,12 +16657,24 @@ class ImmutableApiClient {
|
|
|
16559
16657
|
listingId,
|
|
16560
16658
|
});
|
|
16561
16659
|
}
|
|
16660
|
+
async getTrade(tradeId) {
|
|
16661
|
+
return this.orderbookService.getTrade({
|
|
16662
|
+
chainName: this.chainName,
|
|
16663
|
+
tradeId,
|
|
16664
|
+
});
|
|
16665
|
+
}
|
|
16562
16666
|
async listListings(listOrderParams) {
|
|
16563
16667
|
return this.orderbookService.listListings({
|
|
16564
16668
|
chainName: this.chainName,
|
|
16565
16669
|
...listOrderParams,
|
|
16566
16670
|
});
|
|
16567
16671
|
}
|
|
16672
|
+
async listTrades(listTradesParams) {
|
|
16673
|
+
return this.orderbookService.listTrades({
|
|
16674
|
+
chainName: this.chainName,
|
|
16675
|
+
...listTradesParams,
|
|
16676
|
+
});
|
|
16677
|
+
}
|
|
16568
16678
|
async createListing({ orderHash, orderComponents, orderSignature, makerFee, }) {
|
|
16569
16679
|
if (orderComponents.offer.length !== 1) {
|
|
16570
16680
|
throw new Error('Only one item can be listed at a time');
|
|
@@ -16730,6 +16840,17 @@ class Orderbook {
|
|
|
16730
16840
|
result: mapFromOpenApiOrder(apiListing.result),
|
|
16731
16841
|
};
|
|
16732
16842
|
}
|
|
16843
|
+
/**
|
|
16844
|
+
* Get a trade by ID
|
|
16845
|
+
* @param {string} tradeId - The tradeId to find.
|
|
16846
|
+
* @return {TradeResult} The returned order result.
|
|
16847
|
+
*/
|
|
16848
|
+
async getTrade(tradeId) {
|
|
16849
|
+
const apiListing = await this.apiClient.getTrade(tradeId);
|
|
16850
|
+
return {
|
|
16851
|
+
result: mapFromOpenApiTrade(apiListing.result),
|
|
16852
|
+
};
|
|
16853
|
+
}
|
|
16733
16854
|
/**
|
|
16734
16855
|
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
16735
16856
|
* in the params object.
|
|
@@ -16743,6 +16864,19 @@ class Orderbook {
|
|
|
16743
16864
|
result: apiListings.result.map(mapFromOpenApiOrder),
|
|
16744
16865
|
};
|
|
16745
16866
|
}
|
|
16867
|
+
/**
|
|
16868
|
+
* List trades. This method is used to get a list of trades filtered by conditions specified
|
|
16869
|
+
* in the params object
|
|
16870
|
+
* @param {ListTradesParams} listTradesParams - Filtering, ordering and page parameters.
|
|
16871
|
+
* @return {ListTradesResult} The paged trades.
|
|
16872
|
+
*/
|
|
16873
|
+
async listTrades(listTradesParams) {
|
|
16874
|
+
const apiListings = await this.apiClient.listTrades(listTradesParams);
|
|
16875
|
+
return {
|
|
16876
|
+
page: mapFromOpenApiPage(apiListings.page),
|
|
16877
|
+
result: apiListings.result.map(mapFromOpenApiTrade),
|
|
16878
|
+
};
|
|
16879
|
+
}
|
|
16746
16880
|
/**
|
|
16747
16881
|
* Get required transactions and messages for signing prior to creating a listing
|
|
16748
16882
|
* through the createListing method
|
|
@@ -16945,6 +17079,9 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
|
16945
17079
|
[(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
16946
17080
|
[(Environment$1).PRODUCTION]: "https://checkout-api.immutable.com"
|
|
16947
17081
|
};
|
|
17082
|
+
const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
|
|
17083
|
+
[($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: "https://explorer.testnet.immutable.com"
|
|
17084
|
+
};
|
|
16948
17085
|
const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
16949
17086
|
[
|
|
16950
17087
|
($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
|
|
@@ -17264,13 +17401,6 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
|
17264
17401
|
GasTokenType["NATIVE"] = "NATIVE";
|
|
17265
17402
|
GasTokenType["ERC20"] = "ERC20";
|
|
17266
17403
|
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
17267
|
-
var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
17268
|
-
(function(TransactionRequirementType) {
|
|
17269
|
-
TransactionRequirementType["GAS"] = "GAS";
|
|
17270
|
-
TransactionRequirementType["NATIVE"] = "NATIVE";
|
|
17271
|
-
TransactionRequirementType["ERC20"] = "ERC20";
|
|
17272
|
-
TransactionRequirementType["ERC721"] = "ERC721";
|
|
17273
|
-
})($4b58188d47aafe8d$export$5d3b0ad129b9b98e || ($4b58188d47aafe8d$export$5d3b0ad129b9b98e = {}));
|
|
17274
17404
|
|
|
17275
17405
|
|
|
17276
17406
|
|
|
@@ -17284,6 +17414,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
17284
17414
|
CheckoutErrorType["DEFAULT_PROVIDER_ERROR"] = "DEFAULT_PROVIDER_ERROR";
|
|
17285
17415
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
17286
17416
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
17417
|
+
CheckoutErrorType["GET_INDEXER_BALANCE_ERROR"] = "GET_INDEXER_BALANCE_ERROR";
|
|
17287
17418
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
17288
17419
|
CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
|
|
17289
17420
|
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
@@ -17299,6 +17430,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
17299
17430
|
CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
|
|
17300
17431
|
CheckoutErrorType["UNSUPPORTED_BALANCE_REQUIREMENT_ERROR"] = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR";
|
|
17301
17432
|
CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
|
|
17433
|
+
CheckoutErrorType["PREPARE_ORDER_LISTING_ERROR"] = "PREPARE_ORDER_LISTING_ERROR";
|
|
17302
17434
|
CheckoutErrorType["SWITCH_NETWORK_UNSUPPORTED"] = "SWITCH_NETWORK_UNSUPPORTED";
|
|
17303
17435
|
CheckoutErrorType["GET_ERC20_ALLOWANCE_ERROR"] = "GET_ERC20_ALLOWANCE_ERROR";
|
|
17304
17436
|
CheckoutErrorType["GET_ERC721_ALLOWANCE_ERROR"] = "GET_ERC721_ALLOWANCE_ERROR";
|
|
@@ -17489,7 +17621,7 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
|
|
|
17489
17621
|
case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).BRIDGE:
|
|
17490
17622
|
case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL:
|
|
17491
17623
|
default:
|
|
17492
|
-
tokens = await config.remote.
|
|
17624
|
+
tokens = (await config.remote.getTokensConfig(chainId)).allowed;
|
|
17493
17625
|
}
|
|
17494
17626
|
if (!exclude || exclude?.length === 0) return {
|
|
17495
17627
|
tokens: tokens
|
|
@@ -17502,6 +17634,90 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
|
|
|
17502
17634
|
|
|
17503
17635
|
|
|
17504
17636
|
|
|
17637
|
+
|
|
17638
|
+
|
|
17639
|
+
const $fd8a8472dcc3ec2b$var$CACHE_DATA_TTL = 60; // seconds
|
|
17640
|
+
class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
|
|
17641
|
+
url;
|
|
17642
|
+
ttl;
|
|
17643
|
+
chainId;
|
|
17644
|
+
cacheMap;
|
|
17645
|
+
static async makeHttpRequest(url) {
|
|
17646
|
+
return ($7v2Z6$axios).get(url);
|
|
17647
|
+
}
|
|
17648
|
+
setCache(key, data) {
|
|
17649
|
+
this.cacheMap[key] = {
|
|
17650
|
+
data: data,
|
|
17651
|
+
ttl: new Date().getTime() + this.ttl * 1000
|
|
17652
|
+
};
|
|
17653
|
+
}
|
|
17654
|
+
getCache(key) {
|
|
17655
|
+
const d = this.cacheMap[key];
|
|
17656
|
+
if (!d || d.ttl <= new Date().getTime()) return null;
|
|
17657
|
+
return d.data;
|
|
17658
|
+
}
|
|
17659
|
+
/**
|
|
17660
|
+
* Blockscout constructor
|
|
17661
|
+
* @param chainId target chain
|
|
17662
|
+
* @param ttl cache TTL
|
|
17663
|
+
*/ constructor(params){
|
|
17664
|
+
this.chainId = params.chainId;
|
|
17665
|
+
this.url = ($d85ad1457a3f1a83$export$fc55ed5a42b458ba)[this.chainId];
|
|
17666
|
+
this.cacheMap = {};
|
|
17667
|
+
this.ttl = params.ttl !== undefined ? params.ttl : $fd8a8472dcc3ec2b$var$CACHE_DATA_TTL;
|
|
17668
|
+
}
|
|
17669
|
+
/**
|
|
17670
|
+
* isChainSupported verifies if the chain is supported by Blockscout
|
|
17671
|
+
* @param chainId
|
|
17672
|
+
*/ static isChainSupported = (chainId)=>Boolean(($d85ad1457a3f1a83$export$fc55ed5a42b458ba)[chainId]);
|
|
17673
|
+
/**
|
|
17674
|
+
* isBlockscoutError verifies if the error is a Blockscout client error
|
|
17675
|
+
* @param err error to evaluate
|
|
17676
|
+
*/ static isBlockscoutError = (err)=>"code" in err;
|
|
17677
|
+
/**
|
|
17678
|
+
* getAddressTokens fetches the list of tokens (by type) owned by the wallet address.
|
|
17679
|
+
* @param walletAddress wallet address
|
|
17680
|
+
* @param tokenType token types
|
|
17681
|
+
* @param nextPage parameters for the next page, to be provided along side walletAddress and tokenType
|
|
17682
|
+
* @returns list of tokens given the wallet address and the token types
|
|
17683
|
+
*/ async getAddressTokens(params) {
|
|
17684
|
+
try {
|
|
17685
|
+
let url = `${this.url}/api/v2/addresses/${params.walletAddress}/tokens?type=${params.tokenType.join(",")}`;
|
|
17686
|
+
if (params.nextPage) url += `&${new URLSearchParams(params.nextPage)}`;
|
|
17687
|
+
// Cache response data to prevent unnecessary requests
|
|
17688
|
+
const cached = this.getCache(url);
|
|
17689
|
+
if (cached && cached.status < 400) return Promise.resolve(cached.data);
|
|
17690
|
+
const response = await $fd8a8472dcc3ec2b$export$ef140a6b05dfc786.makeHttpRequest(url);
|
|
17691
|
+
if (response.status >= 400) return Promise.reject({
|
|
17692
|
+
code: response.status,
|
|
17693
|
+
message: response.statusText
|
|
17694
|
+
});
|
|
17695
|
+
this.setCache(url, response);
|
|
17696
|
+
return Promise.resolve(response.data);
|
|
17697
|
+
} catch (err) {
|
|
17698
|
+
let code = (HttpStatusCode).InternalServerError;
|
|
17699
|
+
let message = "InternalServerError";
|
|
17700
|
+
if (($7v2Z6$axios).isAxiosError(err)) {
|
|
17701
|
+
code = err.response?.status || code;
|
|
17702
|
+
message = err.message;
|
|
17703
|
+
}
|
|
17704
|
+
return Promise.reject({
|
|
17705
|
+
code: code,
|
|
17706
|
+
message: message
|
|
17707
|
+
});
|
|
17708
|
+
}
|
|
17709
|
+
}
|
|
17710
|
+
}
|
|
17711
|
+
|
|
17712
|
+
|
|
17713
|
+
/* eslint @typescript-eslint/naming-convention: off */ var $887a00f8f72d61f0$export$5bd1ea2b3d18210;
|
|
17714
|
+
(function(BlockscoutTokenType) {
|
|
17715
|
+
BlockscoutTokenType["ERC20"] = "ERC-20";
|
|
17716
|
+
})($887a00f8f72d61f0$export$5bd1ea2b3d18210 || ($887a00f8f72d61f0$export$5bd1ea2b3d18210 = {}));
|
|
17717
|
+
|
|
17718
|
+
|
|
17719
|
+
|
|
17720
|
+
|
|
17505
17721
|
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
17506
17722
|
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, web3Provider);
|
|
17507
17723
|
if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
|
|
@@ -17541,6 +17757,59 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAdd
|
|
|
17541
17757
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
17542
17758
|
});
|
|
17543
17759
|
}
|
|
17760
|
+
// Blockscout client singleton
|
|
17761
|
+
let $1564e43dde50bb61$var$blockscoutClient;
|
|
17762
|
+
const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, rename)=>{
|
|
17763
|
+
// Shuffle the mapping of the tokens configuration so it is a hashmap
|
|
17764
|
+
// for faster access to tokens config objects.
|
|
17765
|
+
const mapRename = Object.assign({}, ...rename.map((t)=>({
|
|
17766
|
+
[t.address || ""]: t
|
|
17767
|
+
})));
|
|
17768
|
+
// Ensure singleton is present and match the selected chain
|
|
17769
|
+
if (!$1564e43dde50bb61$var$blockscoutClient || $1564e43dde50bb61$var$blockscoutClient.chainId !== chainId) $1564e43dde50bb61$var$blockscoutClient = new ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786)({
|
|
17770
|
+
chainId: chainId
|
|
17771
|
+
});
|
|
17772
|
+
// Hold the items in an array for post-fetching processing
|
|
17773
|
+
const items = [];
|
|
17774
|
+
const tokenType = [
|
|
17775
|
+
($887a00f8f72d61f0$export$5bd1ea2b3d18210).ERC20
|
|
17776
|
+
];
|
|
17777
|
+
// Given that the widgets aren't yet designed to support pagination,
|
|
17778
|
+
// fetch all the possible tokens associated to a given wallet address.
|
|
17779
|
+
let resp;
|
|
17780
|
+
try {
|
|
17781
|
+
do {
|
|
17782
|
+
// eslint-disable-next-line no-await-in-loop
|
|
17783
|
+
resp = await $1564e43dde50bb61$var$blockscoutClient.getAddressTokens({
|
|
17784
|
+
walletAddress: walletAddress,
|
|
17785
|
+
tokenType: tokenType,
|
|
17786
|
+
nextPage: resp?.next_page_params
|
|
17787
|
+
});
|
|
17788
|
+
items.push(...resp.items);
|
|
17789
|
+
}while (resp.next_page_params);
|
|
17790
|
+
} catch (err) {
|
|
17791
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
17792
|
+
}
|
|
17793
|
+
return {
|
|
17794
|
+
balances: items.map((item)=>{
|
|
17795
|
+
const tokenData = item.token || {};
|
|
17796
|
+
const balance = (BigNumber$1).from(item.value);
|
|
17797
|
+
const renamed = mapRename[tokenData.address] || {};
|
|
17798
|
+
const token = {
|
|
17799
|
+
...tokenData,
|
|
17800
|
+
name: renamed.name ?? tokenData.name,
|
|
17801
|
+
symbol: renamed.symbol ?? tokenData.symbol,
|
|
17802
|
+
decimals: parseInt(tokenData.decimals, 10)
|
|
17803
|
+
};
|
|
17804
|
+
const formattedBalance = (utils).formatUnits(item.value, token.decimals);
|
|
17805
|
+
return {
|
|
17806
|
+
balance: balance,
|
|
17807
|
+
formattedBalance: formattedBalance,
|
|
17808
|
+
token: token
|
|
17809
|
+
};
|
|
17810
|
+
})
|
|
17811
|
+
};
|
|
17812
|
+
};
|
|
17544
17813
|
const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
|
|
17545
17814
|
const allBalancePromises = [];
|
|
17546
17815
|
tokens.forEach((token)=>{
|
|
@@ -17559,6 +17828,17 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, w
|
|
|
17559
17828
|
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
17560
17829
|
chainId: chainId
|
|
17561
17830
|
});
|
|
17831
|
+
// In order to prevent unnecessary RPC calls
|
|
17832
|
+
// let's use the Indexer if available for the
|
|
17833
|
+
// given chain.
|
|
17834
|
+
let flag = false;
|
|
17835
|
+
try {
|
|
17836
|
+
flag = (await config.remote.getTokensConfig(chainId)).blockscout || flag;
|
|
17837
|
+
} catch (err) {
|
|
17838
|
+
// eslint-disable-next-line no-console
|
|
17839
|
+
console.error(err);
|
|
17840
|
+
}
|
|
17841
|
+
if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId)) return await $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, tokens);
|
|
17562
17842
|
return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
|
|
17563
17843
|
};
|
|
17564
17844
|
|
|
@@ -17724,13 +18004,19 @@ const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (web3Provider, transacti
|
|
|
17724
18004
|
|
|
17725
18005
|
|
|
17726
18006
|
|
|
18007
|
+
const $dff2555fa96dda9a$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
18008
|
+
const $dff2555fa96dda9a$export$aa28f3111c524ec5 = (feeData)=>{
|
|
18009
|
+
if ($dff2555fa96dda9a$var$doesChainSupportEIP1559(feeData)) return (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas));
|
|
18010
|
+
if (feeData.gasPrice) return (BigNumber$1).from(feeData.gasPrice);
|
|
18011
|
+
return null;
|
|
18012
|
+
};
|
|
18013
|
+
|
|
18014
|
+
|
|
17727
18015
|
const $570856c68db0bd36$var$GAS_LIMIT = 140000;
|
|
17728
|
-
const $570856c68db0bd36$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
17729
|
-
const $570856c68db0bd36$var$getGasPriceInWei = (feeData)=>$570856c68db0bd36$var$doesChainSupportEIP1559(feeData) ? (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas)) : feeData.gasPrice && (BigNumber$1).from(feeData.gasPrice);
|
|
17730
18016
|
const $570856c68db0bd36$var$getGasEstimates = async (provider)=>{
|
|
17731
18017
|
const txnGasLimitInWei = $570856c68db0bd36$var$GAS_LIMIT; // todo: fetch gasLimit from bridgeSDK when they add new fn
|
|
17732
18018
|
const feeData = await provider.getFeeData();
|
|
17733
|
-
const gasPriceInWei = $
|
|
18019
|
+
const gasPriceInWei = ($dff2555fa96dda9a$export$aa28f3111c524ec5)(feeData);
|
|
17734
18020
|
if (!gasPriceInWei) return undefined;
|
|
17735
18021
|
return gasPriceInWei.mul(txnGasLimitInWei);
|
|
17736
18022
|
};
|
|
@@ -17821,7 +18107,7 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
|
|
|
17821
18107
|
static async makeHttpRequest(url) {
|
|
17822
18108
|
let response;
|
|
17823
18109
|
try {
|
|
17824
|
-
response = await (0, axios).get(url);
|
|
18110
|
+
response = await (0, $7v2Z6$axios).get(url);
|
|
17825
18111
|
} catch (error) {
|
|
17826
18112
|
throw new Error(`Error fetching from api: ${error.message}`);
|
|
17827
18113
|
}
|
|
@@ -17851,10 +18137,10 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
|
|
|
17851
18137
|
if (!key) return config;
|
|
17852
18138
|
return config[key];
|
|
17853
18139
|
}
|
|
17854
|
-
async
|
|
18140
|
+
async getTokensConfig(chainId) {
|
|
17855
18141
|
const config = await this.loadConfigTokens();
|
|
17856
|
-
if (!config) return
|
|
17857
|
-
return config[chainId]
|
|
18142
|
+
if (!config || !config[chainId]) return {};
|
|
18143
|
+
return config[chainId] ?? [];
|
|
17858
18144
|
}
|
|
17859
18145
|
}
|
|
17860
18146
|
|
|
@@ -18007,8 +18293,6 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
18007
18293
|
|
|
18008
18294
|
|
|
18009
18295
|
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
18296
|
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
18013
18297
|
const aggregatedAllowances = [];
|
|
18014
18298
|
if (!erc20allowances.sufficient) {
|
|
@@ -18179,7 +18463,9 @@ const $35c3fc7013888ba5$export$90366d6b714c6f69 = async (provider, ownerAddress,
|
|
|
18179
18463
|
return await contract.isApprovedForAll(ownerAddress, spenderAddress);
|
|
18180
18464
|
} catch (err) {
|
|
18181
18465
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to check approval for all ERC721s of collection", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC721_ALLOWANCE_ERROR, {
|
|
18182
|
-
|
|
18466
|
+
ownerAddress: ownerAddress,
|
|
18467
|
+
contractAddress: contractAddress,
|
|
18468
|
+
spenderAddress: spenderAddress
|
|
18183
18469
|
});
|
|
18184
18470
|
}
|
|
18185
18471
|
};
|
|
@@ -18191,7 +18477,10 @@ const $35c3fc7013888ba5$export$ebb2a35f2b4cf5f6 = async (provider, ownerAddress,
|
|
|
18191
18477
|
return transaction;
|
|
18192
18478
|
} catch (err) {
|
|
18193
18479
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get the approval transaction for ERC721", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC721_ALLOWANCE_ERROR, {
|
|
18194
|
-
|
|
18480
|
+
id: id.toString(),
|
|
18481
|
+
contractAddress: contractAddress,
|
|
18482
|
+
spenderAddress: spenderAddress,
|
|
18483
|
+
ownerAddress: ownerAddress
|
|
18195
18484
|
});
|
|
18196
18485
|
}
|
|
18197
18486
|
};
|
|
@@ -18201,6 +18490,7 @@ const $35c3fc7013888ba5$export$c4605a8dd415eeea = async (provider, contractAddre
|
|
|
18201
18490
|
return await contract.getApproved(id);
|
|
18202
18491
|
} catch (err) {
|
|
18203
18492
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get approved address for ERC721", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC721_ALLOWANCE_ERROR, {
|
|
18493
|
+
id: id.toString(),
|
|
18204
18494
|
contractAddress: contractAddress
|
|
18205
18495
|
});
|
|
18206
18496
|
}
|
|
@@ -18377,12 +18667,9 @@ const $aa6caea9a60d18c7$export$f96d1c819a615a64 = (itemRequirements)=>$aa6caea9a
|
|
|
18377
18667
|
|
|
18378
18668
|
const $73d2282a108cc7e2$export$ed7929b58bab85da = (itemRequirements)=>itemRequirements.map((itemRequirement)=>{
|
|
18379
18669
|
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
|
|
18380
|
-
name: "IMX",
|
|
18381
|
-
symbol: "IMX",
|
|
18382
18670
|
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
18383
18671
|
};
|
|
18384
18672
|
return {
|
|
18385
|
-
name: itemRequirement.type,
|
|
18386
18673
|
address: itemRequirement.contractAddress
|
|
18387
18674
|
};
|
|
18388
18675
|
});
|
|
@@ -18398,6 +18685,7 @@ const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
|
|
|
18398
18685
|
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
18399
18686
|
let erc721BalanceResult = itemBalanceResult;
|
|
18400
18687
|
if (!erc721BalanceResult) erc721BalanceResult = {
|
|
18688
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
18401
18689
|
balance: (BigNumber$1).from(0),
|
|
18402
18690
|
formattedBalance: "0",
|
|
18403
18691
|
contractAddress: itemRequirement.contractAddress,
|
|
@@ -18405,7 +18693,7 @@ const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
|
|
|
18405
18693
|
};
|
|
18406
18694
|
return {
|
|
18407
18695
|
sufficient: sufficient,
|
|
18408
|
-
type:
|
|
18696
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
18409
18697
|
delta: {
|
|
18410
18698
|
balance: delta,
|
|
18411
18699
|
formattedBalance: delta.toString()
|
|
@@ -18425,23 +18713,30 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18425
18713
|
return balance.token?.address === itemRequirement.contractAddress;
|
|
18426
18714
|
});
|
|
18427
18715
|
else if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) itemBalanceResult = balances.find((balance)=>{
|
|
18428
|
-
return
|
|
18716
|
+
return balance.token?.address === "" || balance.token?.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9);
|
|
18429
18717
|
});
|
|
18430
18718
|
// Calculate the balance delta
|
|
18431
18719
|
const requiredBalance = itemRequirement.amount;
|
|
18432
18720
|
const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
|
|
18433
18721
|
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
18722
|
+
let name = "";
|
|
18723
|
+
let symbol = "";
|
|
18434
18724
|
let decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
18435
|
-
if (itemBalanceResult)
|
|
18725
|
+
if (itemBalanceResult) {
|
|
18726
|
+
decimals = itemBalanceResult.token?.decimals ?? ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
18727
|
+
name = itemBalanceResult.token.name;
|
|
18728
|
+
symbol = itemBalanceResult.token.symbol;
|
|
18729
|
+
}
|
|
18436
18730
|
let tokenBalanceResult = itemBalanceResult;
|
|
18437
18731
|
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
18438
18732
|
// No token balance so mark as zero native
|
|
18439
18733
|
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
18734
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
18440
18735
|
balance: (BigNumber$1).from(0),
|
|
18441
18736
|
formattedBalance: "0",
|
|
18442
18737
|
token: {
|
|
18443
|
-
name:
|
|
18444
|
-
symbol:
|
|
18738
|
+
name: name,
|
|
18739
|
+
symbol: symbol,
|
|
18445
18740
|
decimals: ($d85ad1457a3f1a83$export$903389470ba9433c),
|
|
18446
18741
|
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
18447
18742
|
}
|
|
@@ -18453,9 +18748,13 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18453
18748
|
balance: delta,
|
|
18454
18749
|
formattedBalance: (utils).formatUnits(delta, decimals)
|
|
18455
18750
|
},
|
|
18456
|
-
current:
|
|
18751
|
+
current: {
|
|
18752
|
+
...tokenBalanceResult,
|
|
18753
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE
|
|
18754
|
+
},
|
|
18457
18755
|
required: {
|
|
18458
18756
|
...tokenBalanceResult,
|
|
18757
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
18459
18758
|
balance: (BigNumber$1).from(itemRequirement.amount),
|
|
18460
18759
|
formattedBalance: (utils).formatUnits(itemRequirement.amount, decimals)
|
|
18461
18760
|
}
|
|
@@ -18463,10 +18762,14 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18463
18762
|
}
|
|
18464
18763
|
// No token balance so mark as zero
|
|
18465
18764
|
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
18765
|
+
type: itemRequirement.type,
|
|
18466
18766
|
balance: (BigNumber$1).from(0),
|
|
18467
18767
|
formattedBalance: "0",
|
|
18468
18768
|
token: {
|
|
18469
|
-
|
|
18769
|
+
name: name,
|
|
18770
|
+
symbol: symbol,
|
|
18771
|
+
address: itemRequirement.contractAddress,
|
|
18772
|
+
decimals: decimals
|
|
18470
18773
|
}
|
|
18471
18774
|
};
|
|
18472
18775
|
return {
|
|
@@ -18508,11 +18811,11 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18508
18811
|
// Setup maps to be able to link data back to the associated promises
|
|
18509
18812
|
const erc721s = new Map();
|
|
18510
18813
|
const erc721OwnershipPromises = new Map();
|
|
18511
|
-
itemRequirements.
|
|
18512
|
-
|
|
18513
|
-
const contract = new (Contract$1)(
|
|
18514
|
-
erc721s.set(
|
|
18515
|
-
erc721OwnershipPromises.set(
|
|
18814
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
18815
|
+
if (itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) return;
|
|
18816
|
+
const contract = new (Contract$1)(itemRequirement.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$8b8be7a2a654f23e)), provider);
|
|
18817
|
+
erc721s.set(itemRequirement.contractAddress, itemRequirement);
|
|
18818
|
+
erc721OwnershipPromises.set(itemRequirement.contractAddress, contract.ownerOf(itemRequirement.id));
|
|
18516
18819
|
});
|
|
18517
18820
|
try {
|
|
18518
18821
|
// Convert ERC721 ownership into a balance result
|
|
@@ -18523,6 +18826,7 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18523
18826
|
let itemCount = 0;
|
|
18524
18827
|
if (itemRequirement && ownerAddress === erc721OwnerAddress) itemCount = 1;
|
|
18525
18828
|
erc721Balances.push({
|
|
18829
|
+
type: (0, $4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
18526
18830
|
balance: (0, BigNumber$1).from(itemCount),
|
|
18527
18831
|
formattedBalance: itemCount.toString(),
|
|
18528
18832
|
contractAddress: itemRequirement.contractAddress,
|
|
@@ -18574,7 +18878,7 @@ const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, owner
|
|
|
18574
18878
|
}, true);
|
|
18575
18879
|
return {
|
|
18576
18880
|
sufficient: sufficient,
|
|
18577
|
-
|
|
18881
|
+
balanceRequirements: balanceRequirements
|
|
18578
18882
|
};
|
|
18579
18883
|
};
|
|
18580
18884
|
|
|
@@ -18585,12 +18889,7 @@ const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, owner
|
|
|
18585
18889
|
|
|
18586
18890
|
|
|
18587
18891
|
|
|
18588
|
-
|
|
18589
|
-
const $7d1bfafb81e64d74$var$getGasPriceInWei = (feeData)=>{
|
|
18590
|
-
if ($7d1bfafb81e64d74$var$doesChainSupportEIP1559(feeData)) return (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas));
|
|
18591
|
-
if (feeData.gasPrice) return (BigNumber$1).from(feeData.gasPrice);
|
|
18592
|
-
return undefined;
|
|
18593
|
-
};
|
|
18892
|
+
|
|
18594
18893
|
const $7d1bfafb81e64d74$export$e0580ae1f48db848 = async (provider, transaction)=>{
|
|
18595
18894
|
try {
|
|
18596
18895
|
return await provider.estimateGas(transaction);
|
|
@@ -18623,9 +18922,11 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
18623
18922
|
if (transactionOrGas.type === ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION) estimateGasPromises.push($7d1bfafb81e64d74$export$e0580ae1f48db848(provider, transactionOrGas.transaction));
|
|
18624
18923
|
else {
|
|
18625
18924
|
const feeData = await provider.getFeeData();
|
|
18626
|
-
const gasPrice = $
|
|
18627
|
-
|
|
18628
|
-
|
|
18925
|
+
const gasPrice = ($dff2555fa96dda9a$export$aa28f3111c524ec5)(feeData);
|
|
18926
|
+
if (gasPrice !== null) {
|
|
18927
|
+
const gas = gasPrice?.mul(transactionOrGas.gasToken.limit);
|
|
18928
|
+
if (gas) totalGas = totalGas.add(gas);
|
|
18929
|
+
}
|
|
18629
18930
|
}
|
|
18630
18931
|
// Get the gas estimates for all the transactions and calculate the total gas
|
|
18631
18932
|
const gasEstimatePromises = await Promise.all(estimateGasPromises);
|
|
@@ -18637,57 +18938,39 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
18637
18938
|
};
|
|
18638
18939
|
|
|
18639
18940
|
|
|
18941
|
+
|
|
18942
|
+
|
|
18943
|
+
const $0e7419077c373b24$export$4a2a19d99fef3b1b = (balanceCheckResult)=>{
|
|
18944
|
+
let sufficient = true;
|
|
18945
|
+
const transactionRequirements = [];
|
|
18946
|
+
for (const balance of balanceCheckResult.balanceRequirements){
|
|
18947
|
+
if (!balance.sufficient) sufficient = false;
|
|
18948
|
+
transactionRequirements.push({
|
|
18949
|
+
type: balance.type,
|
|
18950
|
+
sufficient: balance.sufficient,
|
|
18951
|
+
required: balance.required,
|
|
18952
|
+
current: balance.current,
|
|
18953
|
+
delta: balance.delta
|
|
18954
|
+
});
|
|
18955
|
+
}
|
|
18956
|
+
return {
|
|
18957
|
+
sufficient: sufficient,
|
|
18958
|
+
transactionRequirements: transactionRequirements
|
|
18959
|
+
};
|
|
18960
|
+
};
|
|
18640
18961
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
18641
|
-
// eslint-disable-next-line no-console
|
|
18642
|
-
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
18643
18962
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
18644
18963
|
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
18645
18964
|
const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
|
|
18646
18965
|
const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
|
|
18647
|
-
// eslint-disable-next-line no-console
|
|
18648
|
-
console.log("ERC20 Allowances", erc20Allowances);
|
|
18649
|
-
// eslint-disable-next-line no-console
|
|
18650
|
-
console.log("ERC721 Allowances", erc721Allowances);
|
|
18651
18966
|
const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
|
|
18652
18967
|
const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
|
|
18653
18968
|
if (gasItem !== null) {
|
|
18654
18969
|
aggregatedItems.push(gasItem);
|
|
18655
18970
|
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
18656
18971
|
}
|
|
18657
|
-
// eslint-disable-next-line no-console
|
|
18658
|
-
console.log("Aggregated Items", aggregatedItems);
|
|
18659
18972
|
const balanceRequirements = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
18660
|
-
|
|
18661
|
-
console.log("Balance Requirements", balanceRequirements);
|
|
18662
|
-
return {
|
|
18663
|
-
sufficient: true,
|
|
18664
|
-
transactionRequirements: [
|
|
18665
|
-
{
|
|
18666
|
-
type: ($4b58188d47aafe8d$export$5d3b0ad129b9b98e).GAS,
|
|
18667
|
-
sufficient: true,
|
|
18668
|
-
required: {
|
|
18669
|
-
balance: (BigNumber$1).from(0),
|
|
18670
|
-
formattedBalance: "0",
|
|
18671
|
-
token: {
|
|
18672
|
-
name: "IMX",
|
|
18673
|
-
symbol: "IMX",
|
|
18674
|
-
address: "0x0",
|
|
18675
|
-
decimals: 18
|
|
18676
|
-
}
|
|
18677
|
-
},
|
|
18678
|
-
current: {
|
|
18679
|
-
balance: (BigNumber$1).from(1),
|
|
18680
|
-
formattedBalance: "1",
|
|
18681
|
-
token: {
|
|
18682
|
-
name: "IMX",
|
|
18683
|
-
symbol: "IMX",
|
|
18684
|
-
address: "0x0",
|
|
18685
|
-
decimals: 18
|
|
18686
|
-
}
|
|
18687
|
-
}
|
|
18688
|
-
}
|
|
18689
|
-
]
|
|
18690
|
-
};
|
|
18973
|
+
return $0e7419077c373b24$export$4a2a19d99fef3b1b(balanceRequirements);
|
|
18691
18974
|
};
|
|
18692
18975
|
|
|
18693
18976
|
|
|
@@ -18797,6 +19080,81 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
18797
19080
|
|
|
18798
19081
|
|
|
18799
19082
|
|
|
19083
|
+
|
|
19084
|
+
const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
|
|
19085
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
19086
|
+
id: id,
|
|
19087
|
+
contractAddress: contractAddress,
|
|
19088
|
+
spenderAddress: spenderAddress
|
|
19089
|
+
});
|
|
19090
|
+
const $9085b221b72ac69e$export$d2da5a4d143c85e5 = (buyToken)=>{
|
|
19091
|
+
if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
|
|
19092
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
19093
|
+
amount: buyToken.amount.toString()
|
|
19094
|
+
};
|
|
19095
|
+
return {
|
|
19096
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
19097
|
+
amount: buyToken.amount.toString(),
|
|
19098
|
+
contractAddress: buyToken.contractAddress
|
|
19099
|
+
};
|
|
19100
|
+
};
|
|
19101
|
+
const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, contractAddress, buyToken)=>{
|
|
19102
|
+
let orderbook;
|
|
19103
|
+
let listing;
|
|
19104
|
+
let spenderAddress = "";
|
|
19105
|
+
try {
|
|
19106
|
+
const walletAddress = await provider.getSigner().getAddress();
|
|
19107
|
+
orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
19108
|
+
const { seaportContractAddress: seaportContractAddress } = orderbook.config();
|
|
19109
|
+
spenderAddress = seaportContractAddress;
|
|
19110
|
+
listing = await orderbook.prepareListing({
|
|
19111
|
+
makerAddress: walletAddress,
|
|
19112
|
+
buy: $9085b221b72ac69e$export$d2da5a4d143c85e5(buyToken),
|
|
19113
|
+
sell: {
|
|
19114
|
+
type: (0, $4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
19115
|
+
contractAddress: contractAddress,
|
|
19116
|
+
tokenId: id
|
|
19117
|
+
}
|
|
19118
|
+
});
|
|
19119
|
+
} catch (err) {
|
|
19120
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR, {
|
|
19121
|
+
message: err.message,
|
|
19122
|
+
id: id,
|
|
19123
|
+
collectionAddress: contractAddress
|
|
19124
|
+
});
|
|
19125
|
+
}
|
|
19126
|
+
const itemRequirements = [
|
|
19127
|
+
$9085b221b72ac69e$export$af768ccdf17d5c04(id, contractAddress, spenderAddress)
|
|
19128
|
+
];
|
|
19129
|
+
// eslint-disable-next-line no-console
|
|
19130
|
+
console.log(listing); // TODO: Get order signature, provider.getSigner()._signTypedData to sign
|
|
19131
|
+
const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
|
|
19132
|
+
type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
|
|
19133
|
+
gasToken: {
|
|
19134
|
+
type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
|
|
19135
|
+
limit: (BigNumber$1).from((constants).estimatedFulfillmentGasGwei)
|
|
19136
|
+
}
|
|
19137
|
+
});
|
|
19138
|
+
// eslint-disable-next-line no-console
|
|
19139
|
+
console.log("transactionRequirements", smartCheckoutResult);
|
|
19140
|
+
return {
|
|
19141
|
+
itemRequirements: itemRequirements,
|
|
19142
|
+
gasToken: {
|
|
19143
|
+
type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
|
|
19144
|
+
limit: (BigNumber$1).from((constants).estimatedFulfillmentGasGwei)
|
|
19145
|
+
},
|
|
19146
|
+
smartCheckoutResult: smartCheckoutResult
|
|
19147
|
+
};
|
|
19148
|
+
};
|
|
19149
|
+
|
|
19150
|
+
|
|
19151
|
+
|
|
19152
|
+
|
|
19153
|
+
|
|
19154
|
+
|
|
19155
|
+
|
|
19156
|
+
|
|
19157
|
+
|
|
18800
19158
|
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
18801
19159
|
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
18802
19160
|
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
@@ -18941,6 +19299,16 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
18941
19299
|
await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
|
|
18942
19300
|
}
|
|
18943
19301
|
/**
|
|
19302
|
+
* Determines the requirements for performing a sell.
|
|
19303
|
+
* @param {SellParams} params - The parameters for the sell.
|
|
19304
|
+
*/ async sell(params) {
|
|
19305
|
+
if (this.config.isProduction) throw new Error("This endpoint is not currently available.");
|
|
19306
|
+
// eslint-disable-next-line no-console
|
|
19307
|
+
console.warn("This endpoint is currently under construction.");
|
|
19308
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
19309
|
+
await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.id, params.collectionAddress, params.buyToken);
|
|
19310
|
+
}
|
|
19311
|
+
/**
|
|
18944
19312
|
* Determines the transaction requirements to complete a purchase.
|
|
18945
19313
|
* @params {SmartCheckoutParams} params - The parameters for smart checkout.
|
|
18946
19314
|
*/ async smartCheckout(params) {
|