@imtbl/sdk 0.1.10-alpha.4 → 0.2.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.js +76 -74
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.cjs +92 -126
- package/dist/index.d.ts +3 -3
- package/dist/index.js +92 -126
- package/dist/orderbook.d.ts +3 -3
- package/dist/orderbook.js +13 -49
- package/dist/passport.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import * as encUtils from 'enc-utils';
|
|
|
9
9
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
10
10
|
import FormData$2 from 'form-data';
|
|
11
11
|
import { providers, BigNumber as BigNumber$1, constants, utils as utils$2, Contract as Contract$1, ethers, ContractFactory } from 'ethers';
|
|
12
|
-
import dotenv from 'dotenv';
|
|
13
12
|
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
14
13
|
import { parseUnits } from '@ethersproject/units';
|
|
15
14
|
import { BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
|
|
@@ -5437,7 +5436,7 @@ class APIError extends Error {
|
|
|
5437
5436
|
|
|
5438
5437
|
/* eslint-disable implicit-arrow-linebreak */
|
|
5439
5438
|
const defaultHeaders = {
|
|
5440
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
5439
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.2.0-alpha',
|
|
5441
5440
|
};
|
|
5442
5441
|
/**
|
|
5443
5442
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -5703,7 +5702,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
5703
5702
|
chainID,
|
|
5704
5703
|
coreContractAddress,
|
|
5705
5704
|
registrationContractAddress,
|
|
5706
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
5705
|
+
sdkVersion: 'ts-immutable-sdk-0.2.0-alpha',
|
|
5707
5706
|
});
|
|
5708
5707
|
/**
|
|
5709
5708
|
* Sets `sdkVersion` at the time of build
|
|
@@ -11826,49 +11825,11 @@ class ImmutableApiClientFactory {
|
|
|
11826
11825
|
}
|
|
11827
11826
|
}
|
|
11828
11827
|
|
|
11829
|
-
// eslint-disable-next-line
|
|
11830
|
-
dotenv.config();
|
|
11831
|
-
function getConfigFromEnv() {
|
|
11832
|
-
if (!process.env.ORDERBOOK_MR_API_URL
|
|
11833
|
-
|| !process.env.SEAPORT_CONTRACT_ADDRESS
|
|
11834
|
-
|| !process.env.ZONE_CONTRACT_ADDRESS) {
|
|
11835
|
-
throw new Error('missing config');
|
|
11836
|
-
}
|
|
11837
|
-
return {
|
|
11838
|
-
apiUrl: process.env.ORDERBOOK_MR_API_URL,
|
|
11839
|
-
seaportContractAddress: process.env.SEAPORT_CONTRACT_ADDRESS,
|
|
11840
|
-
zoneContractAddress: process.env.ZONE_CONTRACT_ADDRESS,
|
|
11841
|
-
};
|
|
11842
|
-
}
|
|
11843
|
-
|
|
11844
|
-
dotenv.config();
|
|
11845
|
-
function getLocalhostProvider() {
|
|
11846
|
-
const endpoint = process.env.LOCAL_RPC_ENDPOINT;
|
|
11847
|
-
if (!endpoint) {
|
|
11848
|
-
throw new Error('LOCAL_RPC_ENDPOINT not set');
|
|
11849
|
-
}
|
|
11850
|
-
return new providers.JsonRpcProvider(endpoint);
|
|
11851
|
-
}
|
|
11852
|
-
|
|
11853
|
-
dotenv.config();
|
|
11854
|
-
|
|
11855
|
-
const LOCAL_CHAIN_NAME = 'imtbl-zkevm-local';
|
|
11856
11828
|
const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
|
|
11857
11829
|
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
11858
11830
|
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
11859
|
-
function localChainConfig() {
|
|
11860
|
-
const localConfig = getConfigFromEnv();
|
|
11861
|
-
return {
|
|
11862
|
-
seaportContractAddress: localConfig.seaportContractAddress,
|
|
11863
|
-
zoneContractAddress: localConfig.zoneContractAddress,
|
|
11864
|
-
apiEndpoint: localConfig.apiUrl,
|
|
11865
|
-
provider: getLocalhostProvider(),
|
|
11866
|
-
};
|
|
11867
|
-
}
|
|
11868
11831
|
function getOrderbookConfig(chainName) {
|
|
11869
11832
|
switch (chainName) {
|
|
11870
|
-
case LOCAL_CHAIN_NAME:
|
|
11871
|
-
return localChainConfig();
|
|
11872
11833
|
case DEVNET_CHAIN_NAME:
|
|
11873
11834
|
return {
|
|
11874
11835
|
seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
|
|
@@ -12844,13 +12805,17 @@ class SeaportLibFactory {
|
|
|
12844
12805
|
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
12845
12806
|
*/
|
|
12846
12807
|
class Orderbook {
|
|
12847
|
-
config;
|
|
12848
12808
|
apiClient;
|
|
12849
12809
|
seaport;
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
const
|
|
12810
|
+
orderbookConfig;
|
|
12811
|
+
constructor(config, localConfig) {
|
|
12812
|
+
// either use preconfigured config or local config passed in
|
|
12813
|
+
const maybeConfig = getOrderbookConfig(config.overrides?.chainName) || localConfig;
|
|
12814
|
+
if (!maybeConfig) {
|
|
12815
|
+
throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
|
|
12816
|
+
}
|
|
12817
|
+
this.orderbookConfig = maybeConfig;
|
|
12818
|
+
const { apiEndpoint } = this.orderbookConfig;
|
|
12854
12819
|
if (!apiEndpoint) {
|
|
12855
12820
|
throw new Error('API endpoint must be provided as an override');
|
|
12856
12821
|
}
|
|
@@ -12859,9 +12824,9 @@ class Orderbook {
|
|
|
12859
12824
|
if (!chainName) {
|
|
12860
12825
|
throw new Error('chainName must be provided as an override');
|
|
12861
12826
|
}
|
|
12862
|
-
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, orderbookConfig.seaportContractAddress).create();
|
|
12863
|
-
const seaportLibFactory = new SeaportLibFactory(orderbookConfig.seaportContractAddress, orderbookConfig.provider);
|
|
12864
|
-
this.seaport = new Seaport(seaportLibFactory, orderbookConfig.provider, orderbookConfig.seaportContractAddress, orderbookConfig.zoneContractAddress);
|
|
12827
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
12828
|
+
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
12829
|
+
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
12865
12830
|
}
|
|
12866
12831
|
/**
|
|
12867
12832
|
* Get an order by ID
|
|
@@ -12889,8 +12854,7 @@ class Orderbook {
|
|
|
12889
12854
|
* the order components that can be submitted to `createListing` with a signature.
|
|
12890
12855
|
*/
|
|
12891
12856
|
async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
|
|
12892
|
-
const
|
|
12893
|
-
const erc721 = new ERC721Factory(sell.contractAddress, orderbookConfig.provider).create();
|
|
12857
|
+
const erc721 = new ERC721Factory(sell.contractAddress, this.orderbookConfig.provider).create();
|
|
12894
12858
|
const royaltyInfo = await erc721.royaltyInfo(sell.tokenId, buy.amount);
|
|
12895
12859
|
return this.seaport.prepareSeaportOrder(makerAddress, sell, buy, royaltyInfo,
|
|
12896
12860
|
// Default order start to now
|
|
@@ -24364,9 +24328,8 @@ class ExchangeError extends Error {
|
|
|
24364
24328
|
}
|
|
24365
24329
|
}
|
|
24366
24330
|
class InvalidConfigurationError extends ExchangeError {
|
|
24367
|
-
constructor() {
|
|
24368
|
-
|
|
24369
|
-
super(message, ExchangeErrorCode.INVALID_CONFIGURATION);
|
|
24331
|
+
constructor(message) {
|
|
24332
|
+
super(message || 'Invalid configuration', ExchangeErrorCode.INVALID_CONFIGURATION);
|
|
24370
24333
|
}
|
|
24371
24334
|
}
|
|
24372
24335
|
class ChainNotSupportedError extends ExchangeError {
|
|
@@ -26467,20 +26430,84 @@ function getSwap(nativeToken, routeAndQuote, fromAddress, slippage, deadline, pe
|
|
|
26467
26430
|
};
|
|
26468
26431
|
}
|
|
26469
26432
|
|
|
26433
|
+
const CONTRACTS_FOR_CHAIN_ID = {
|
|
26434
|
+
[IMMUTABLE_TESTNET_CHAIN_ID]: {
|
|
26435
|
+
multicall: '0xb18c44b211065E69844FbA9AE146DA362104AfBf',
|
|
26436
|
+
coreFactory: '0x12739A8f1A8035F439092D016DAE19A2874F30d2',
|
|
26437
|
+
quoterV2: '0xF674847fBcca5C80315e3AE37043Dce99F6CC529',
|
|
26438
|
+
peripheryRouter: '0x0Afe6F5f4DC34461A801420634239FFaD50A2e44',
|
|
26439
|
+
},
|
|
26440
|
+
};
|
|
26441
|
+
const SUPPORTED_SANDBOX_CHAINS = {
|
|
26442
|
+
[IMMUTABLE_TESTNET_CHAIN_ID]: {
|
|
26443
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
26444
|
+
rpcUrl: IMMUTABLE_TESTNET_RPC_URL,
|
|
26445
|
+
contracts: CONTRACTS_FOR_CHAIN_ID[IMMUTABLE_TESTNET_CHAIN_ID],
|
|
26446
|
+
commonRoutingTokens: IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS,
|
|
26447
|
+
nativeToken: TIMX_IMMUTABLE_TESTNET,
|
|
26448
|
+
},
|
|
26449
|
+
};
|
|
26450
|
+
const SUPPORTED_PRODUCTION_CHAINS = {};
|
|
26451
|
+
const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
|
|
26452
|
+
[Environment$1.SANDBOX]: SUPPORTED_SANDBOX_CHAINS,
|
|
26453
|
+
[Environment$1.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
|
|
26454
|
+
};
|
|
26455
|
+
function validateOverrides(overrides) {
|
|
26456
|
+
Object.entries(overrides).forEach(([key, value]) => {
|
|
26457
|
+
if (!value) {
|
|
26458
|
+
throw new InvalidConfigurationError(`Missing override: ${key}`);
|
|
26459
|
+
}
|
|
26460
|
+
});
|
|
26461
|
+
Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
|
|
26462
|
+
if (!isValidNonZeroAddress(contract)) {
|
|
26463
|
+
throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
|
|
26464
|
+
}
|
|
26465
|
+
});
|
|
26466
|
+
}
|
|
26467
|
+
/**
|
|
26468
|
+
* {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
|
|
26469
|
+
* @param chainId the ID of the chain to configure. {@link SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT} contains the supported chains for each environment.
|
|
26470
|
+
* @param baseConfig the base {@link ImmutableConfiguration} for the {@link Exchange} class
|
|
26471
|
+
*/
|
|
26472
|
+
class ExchangeConfiguration {
|
|
26473
|
+
baseConfig;
|
|
26474
|
+
chain;
|
|
26475
|
+
constructor({ chainId, baseConfig, overrides }) {
|
|
26476
|
+
this.baseConfig = baseConfig;
|
|
26477
|
+
if (overrides) {
|
|
26478
|
+
validateOverrides(overrides);
|
|
26479
|
+
this.chain = {
|
|
26480
|
+
chainId,
|
|
26481
|
+
rpcUrl: overrides.rpcURL,
|
|
26482
|
+
contracts: overrides.exchangeContracts,
|
|
26483
|
+
commonRoutingTokens: overrides.commonRoutingTokens,
|
|
26484
|
+
nativeToken: overrides.nativeToken,
|
|
26485
|
+
};
|
|
26486
|
+
return;
|
|
26487
|
+
}
|
|
26488
|
+
const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
|
|
26489
|
+
if (!chain) {
|
|
26490
|
+
throw new ChainNotSupportedError(chainId, baseConfig.environment);
|
|
26491
|
+
}
|
|
26492
|
+
this.chain = chain;
|
|
26493
|
+
}
|
|
26494
|
+
}
|
|
26495
|
+
|
|
26470
26496
|
class Exchange {
|
|
26471
26497
|
provider;
|
|
26472
26498
|
router;
|
|
26473
26499
|
chainId;
|
|
26474
26500
|
nativeToken;
|
|
26475
26501
|
constructor(configuration) {
|
|
26476
|
-
|
|
26477
|
-
this.
|
|
26478
|
-
this.
|
|
26479
|
-
this.
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26502
|
+
const config = new ExchangeConfiguration(configuration);
|
|
26503
|
+
this.chainId = config.chain.chainId;
|
|
26504
|
+
this.nativeToken = config.chain.nativeToken;
|
|
26505
|
+
this.provider = new ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
|
|
26506
|
+
this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
|
|
26507
|
+
multicallAddress: config.chain.contracts.multicall,
|
|
26508
|
+
factoryAddress: config.chain.contracts.coreFactory,
|
|
26509
|
+
quoterAddress: config.chain.contracts.quoterV2,
|
|
26510
|
+
peripheryRouterAddress: config.chain.contracts.peripheryRouter,
|
|
26484
26511
|
});
|
|
26485
26512
|
}
|
|
26486
26513
|
static validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress) {
|
|
@@ -26560,67 +26587,6 @@ class Exchange {
|
|
|
26560
26587
|
}
|
|
26561
26588
|
}
|
|
26562
26589
|
|
|
26563
|
-
const CONTRACTS_FOR_CHAIN_ID = {
|
|
26564
|
-
[IMMUTABLE_TESTNET_CHAIN_ID]: {
|
|
26565
|
-
multicall: '0xb18c44b211065E69844FbA9AE146DA362104AfBf',
|
|
26566
|
-
coreFactory: '0x12739A8f1A8035F439092D016DAE19A2874F30d2',
|
|
26567
|
-
quoterV2: '0xF674847fBcca5C80315e3AE37043Dce99F6CC529',
|
|
26568
|
-
peripheryRouter: '0x0Afe6F5f4DC34461A801420634239FFaD50A2e44',
|
|
26569
|
-
},
|
|
26570
|
-
};
|
|
26571
|
-
const SUPPORTED_SANDBOX_CHAINS = {
|
|
26572
|
-
[IMMUTABLE_TESTNET_CHAIN_ID]: {
|
|
26573
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
26574
|
-
rpcUrl: IMMUTABLE_TESTNET_RPC_URL,
|
|
26575
|
-
contracts: CONTRACTS_FOR_CHAIN_ID[IMMUTABLE_TESTNET_CHAIN_ID],
|
|
26576
|
-
commonRoutingTokens: IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS,
|
|
26577
|
-
nativeToken: TIMX_IMMUTABLE_TESTNET,
|
|
26578
|
-
},
|
|
26579
|
-
};
|
|
26580
|
-
const SUPPORTED_PRODUCTION_CHAINS = {};
|
|
26581
|
-
const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
|
|
26582
|
-
[Environment$1.SANDBOX]: SUPPORTED_SANDBOX_CHAINS,
|
|
26583
|
-
[Environment$1.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
|
|
26584
|
-
};
|
|
26585
|
-
function validateOverrides(overrides) {
|
|
26586
|
-
if (!overrides.rpcURL || !overrides.exchangeContracts || !overrides.commonRoutingTokens || !overrides.nativeToken) {
|
|
26587
|
-
throw new InvalidConfigurationError();
|
|
26588
|
-
}
|
|
26589
|
-
Object.values(overrides.exchangeContracts).forEach((contract) => {
|
|
26590
|
-
if (!isValidNonZeroAddress(contract)) {
|
|
26591
|
-
throw new InvalidConfigurationError();
|
|
26592
|
-
}
|
|
26593
|
-
});
|
|
26594
|
-
}
|
|
26595
|
-
/**
|
|
26596
|
-
* {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
|
|
26597
|
-
* @param chainId the ID of the chain to configure. {@link SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT} contains the supported chains for each environment.
|
|
26598
|
-
* @param baseConfig the base {@link ImmutableConfiguration} for the {@link Exchange} class
|
|
26599
|
-
*/
|
|
26600
|
-
class ExchangeConfiguration {
|
|
26601
|
-
baseConfig;
|
|
26602
|
-
chain;
|
|
26603
|
-
constructor({ chainId, baseConfig, overrides }) {
|
|
26604
|
-
this.baseConfig = baseConfig;
|
|
26605
|
-
if (overrides) {
|
|
26606
|
-
validateOverrides(overrides);
|
|
26607
|
-
this.chain = {
|
|
26608
|
-
chainId,
|
|
26609
|
-
rpcUrl: overrides.rpcURL,
|
|
26610
|
-
contracts: overrides.exchangeContracts,
|
|
26611
|
-
commonRoutingTokens: overrides.commonRoutingTokens,
|
|
26612
|
-
nativeToken: overrides.nativeToken,
|
|
26613
|
-
};
|
|
26614
|
-
return;
|
|
26615
|
-
}
|
|
26616
|
-
const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
|
|
26617
|
-
if (!chain) {
|
|
26618
|
-
throw new ChainNotSupportedError(chainId, baseConfig.environment);
|
|
26619
|
-
}
|
|
26620
|
-
this.chain = chain;
|
|
26621
|
-
}
|
|
26622
|
-
}
|
|
26623
|
-
|
|
26624
26590
|
/* eslint-disable class-methods-use-this */
|
|
26625
26591
|
|
|
26626
26592
|
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
@@ -27373,13 +27339,13 @@ async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId,
|
|
|
27373
27339
|
}
|
|
27374
27340
|
async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
|
|
27375
27341
|
const dexConfig = await config.remote.getConfig("dex");
|
|
27376
|
-
return new (Exchange)(
|
|
27342
|
+
return new (Exchange)({
|
|
27377
27343
|
chainId: chainId,
|
|
27378
27344
|
baseConfig: new (ImmutableConfiguration)({
|
|
27379
27345
|
environment: config.environment
|
|
27380
27346
|
}),
|
|
27381
27347
|
overrides: dexConfig?.overrides
|
|
27382
|
-
})
|
|
27348
|
+
});
|
|
27383
27349
|
}
|
|
27384
27350
|
|
|
27385
27351
|
|
|
@@ -27743,7 +27709,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
27743
27709
|
function $parcel$export(e, n, v, s) {
|
|
27744
27710
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
27745
27711
|
}
|
|
27746
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
27712
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.2.0-alpha";
|
|
27747
27713
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
27748
27714
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
27749
27715
|
|
package/dist/orderbook.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrderbookOverrides } from 'config/config';
|
|
1
|
+
import { OrderbookOverrides, OrderbookModuleConfiguration } from 'config/config';
|
|
2
2
|
import { ListingResult, ListListingsResult } from 'openapi/sdk';
|
|
3
3
|
import { ListListingsParams, PrepareListingParams, PrepareListingResponse, CreateListingParams, FulfillOrderResponse, CancelOrderResponse } from 'types';
|
|
4
4
|
|
|
@@ -25,10 +25,10 @@ interface ModuleConfiguration<T> {
|
|
|
25
25
|
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
26
26
|
*/
|
|
27
27
|
declare class Orderbook {
|
|
28
|
-
private config;
|
|
29
28
|
private apiClient;
|
|
30
29
|
private seaport;
|
|
31
|
-
|
|
30
|
+
private orderbookConfig;
|
|
31
|
+
constructor(config: ModuleConfiguration<OrderbookOverrides>, localConfig?: OrderbookModuleConfiguration);
|
|
32
32
|
/**
|
|
33
33
|
* Get an order by ID
|
|
34
34
|
* @param {string} listingId - The listingId to find.
|
package/dist/orderbook.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import FormData from 'form-data';
|
|
3
3
|
import { providers, BigNumber, constants, utils, Contract } from 'ethers';
|
|
4
|
-
import dotenv from 'dotenv';
|
|
5
4
|
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
6
5
|
|
|
7
6
|
class BaseHttpRequest {
|
|
@@ -899,49 +898,11 @@ class ImmutableApiClientFactory {
|
|
|
899
898
|
}
|
|
900
899
|
}
|
|
901
900
|
|
|
902
|
-
// eslint-disable-next-line
|
|
903
|
-
dotenv.config();
|
|
904
|
-
function getConfigFromEnv() {
|
|
905
|
-
if (!process.env.ORDERBOOK_MR_API_URL
|
|
906
|
-
|| !process.env.SEAPORT_CONTRACT_ADDRESS
|
|
907
|
-
|| !process.env.ZONE_CONTRACT_ADDRESS) {
|
|
908
|
-
throw new Error('missing config');
|
|
909
|
-
}
|
|
910
|
-
return {
|
|
911
|
-
apiUrl: process.env.ORDERBOOK_MR_API_URL,
|
|
912
|
-
seaportContractAddress: process.env.SEAPORT_CONTRACT_ADDRESS,
|
|
913
|
-
zoneContractAddress: process.env.ZONE_CONTRACT_ADDRESS,
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
dotenv.config();
|
|
918
|
-
function getLocalhostProvider() {
|
|
919
|
-
const endpoint = process.env.LOCAL_RPC_ENDPOINT;
|
|
920
|
-
if (!endpoint) {
|
|
921
|
-
throw new Error('LOCAL_RPC_ENDPOINT not set');
|
|
922
|
-
}
|
|
923
|
-
return new providers.JsonRpcProvider(endpoint);
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
dotenv.config();
|
|
927
|
-
|
|
928
|
-
const LOCAL_CHAIN_NAME = 'imtbl-zkevm-local';
|
|
929
901
|
const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
|
|
930
902
|
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
931
903
|
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
932
|
-
function localChainConfig() {
|
|
933
|
-
const localConfig = getConfigFromEnv();
|
|
934
|
-
return {
|
|
935
|
-
seaportContractAddress: localConfig.seaportContractAddress,
|
|
936
|
-
zoneContractAddress: localConfig.zoneContractAddress,
|
|
937
|
-
apiEndpoint: localConfig.apiUrl,
|
|
938
|
-
provider: getLocalhostProvider(),
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
904
|
function getOrderbookConfig(chainName) {
|
|
942
905
|
switch (chainName) {
|
|
943
|
-
case LOCAL_CHAIN_NAME:
|
|
944
|
-
return localChainConfig();
|
|
945
906
|
case DEVNET_CHAIN_NAME:
|
|
946
907
|
return {
|
|
947
908
|
seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
|
|
@@ -1917,13 +1878,17 @@ class SeaportLibFactory {
|
|
|
1917
1878
|
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
1918
1879
|
*/
|
|
1919
1880
|
class Orderbook {
|
|
1920
|
-
config;
|
|
1921
1881
|
apiClient;
|
|
1922
1882
|
seaport;
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
const
|
|
1883
|
+
orderbookConfig;
|
|
1884
|
+
constructor(config, localConfig) {
|
|
1885
|
+
// either use preconfigured config or local config passed in
|
|
1886
|
+
const maybeConfig = getOrderbookConfig(config.overrides?.chainName) || localConfig;
|
|
1887
|
+
if (!maybeConfig) {
|
|
1888
|
+
throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
|
|
1889
|
+
}
|
|
1890
|
+
this.orderbookConfig = maybeConfig;
|
|
1891
|
+
const { apiEndpoint } = this.orderbookConfig;
|
|
1927
1892
|
if (!apiEndpoint) {
|
|
1928
1893
|
throw new Error('API endpoint must be provided as an override');
|
|
1929
1894
|
}
|
|
@@ -1932,9 +1897,9 @@ class Orderbook {
|
|
|
1932
1897
|
if (!chainName) {
|
|
1933
1898
|
throw new Error('chainName must be provided as an override');
|
|
1934
1899
|
}
|
|
1935
|
-
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, orderbookConfig.seaportContractAddress).create();
|
|
1936
|
-
const seaportLibFactory = new SeaportLibFactory(orderbookConfig.seaportContractAddress, orderbookConfig.provider);
|
|
1937
|
-
this.seaport = new Seaport(seaportLibFactory, orderbookConfig.provider, orderbookConfig.seaportContractAddress, orderbookConfig.zoneContractAddress);
|
|
1900
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
1901
|
+
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
1902
|
+
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
1938
1903
|
}
|
|
1939
1904
|
/**
|
|
1940
1905
|
* Get an order by ID
|
|
@@ -1962,8 +1927,7 @@ class Orderbook {
|
|
|
1962
1927
|
* the order components that can be submitted to `createListing` with a signature.
|
|
1963
1928
|
*/
|
|
1964
1929
|
async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
|
|
1965
|
-
const
|
|
1966
|
-
const erc721 = new ERC721Factory(sell.contractAddress, orderbookConfig.provider).create();
|
|
1930
|
+
const erc721 = new ERC721Factory(sell.contractAddress, this.orderbookConfig.provider).create();
|
|
1967
1931
|
const royaltyInfo = await erc721.royaltyInfo(sell.tokenId, buy.amount);
|
|
1968
1932
|
return this.seaport.prepareSeaportOrder(makerAddress, sell, buy, royaltyInfo,
|
|
1969
1933
|
// Default order start to now
|
package/dist/passport.js
CHANGED
|
@@ -21,7 +21,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
21
21
|
chainID,
|
|
22
22
|
coreContractAddress,
|
|
23
23
|
registrationContractAddress,
|
|
24
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
24
|
+
sdkVersion: 'ts-immutable-sdk-0.2.0-alpha',
|
|
25
25
|
});
|
|
26
26
|
/**
|
|
27
27
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED