@imtbl/sdk 0.4.0-alpha → 0.4.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 +54 -3262
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +2 -16
- package/dist/checkout_sdk.js +26 -67
- package/dist/checkout_widgets.d.ts +2 -3
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.d.ts +2 -2
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +16 -16
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +145 -4134
- package/dist/index.d.ts +45 -126
- package/dist/index.js +135 -4123
- package/dist/orderbook.d.ts +2 -2
- package/dist/orderbook.js +26 -24
- package/dist/passport.d.ts +13 -79
- package/dist/passport.js +15 -5248
- package/package.json +3 -5
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
|
|
|
@@ -28,7 +28,7 @@ declare class Orderbook {
|
|
|
28
28
|
private apiClient;
|
|
29
29
|
private seaport;
|
|
30
30
|
private orderbookConfig;
|
|
31
|
-
constructor(config: ModuleConfiguration<OrderbookOverrides
|
|
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
|
@@ -3,12 +3,6 @@ import FormData from 'form-data';
|
|
|
3
3
|
import { providers, BigNumber, constants, utils, Contract } from 'ethers';
|
|
4
4
|
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
5
5
|
|
|
6
|
-
var Environment;
|
|
7
|
-
(function (Environment) {
|
|
8
|
-
Environment["PRODUCTION"] = "production";
|
|
9
|
-
Environment["SANDBOX"] = "sandbox";
|
|
10
|
-
})(Environment || (Environment = {}));
|
|
11
|
-
|
|
12
6
|
class BaseHttpRequest {
|
|
13
7
|
config;
|
|
14
8
|
constructor(config) {
|
|
@@ -904,25 +898,31 @@ class ImmutableApiClientFactory {
|
|
|
904
898
|
}
|
|
905
899
|
}
|
|
906
900
|
|
|
901
|
+
const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
|
|
907
902
|
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
908
903
|
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
909
|
-
function getOrderbookConfig(
|
|
910
|
-
switch (
|
|
911
|
-
case
|
|
904
|
+
function getOrderbookConfig(chainName) {
|
|
905
|
+
switch (chainName) {
|
|
906
|
+
case DEVNET_CHAIN_NAME:
|
|
907
|
+
return {
|
|
908
|
+
seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
|
|
909
|
+
zoneContractAddress: '0xCb5063b0c1dcF4f7fed8E7eaa79faf9859792767',
|
|
910
|
+
apiEndpoint: 'https://order-book-mr.dev.imtbl.com',
|
|
911
|
+
provider: new providers.JsonRpcProvider('https://zkevm-rpc.dev.x.immutable.com'),
|
|
912
|
+
};
|
|
913
|
+
case TESTNET_CHAIN_NAME:
|
|
912
914
|
return {
|
|
913
915
|
seaportContractAddress: '0x45E23dA18804F99Cf67408AeBE85F67c958381Ff',
|
|
914
916
|
zoneContractAddress: '0x25b00b7eb97eab6194798E9B8eF63Aa526D5bd7E',
|
|
915
917
|
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
916
|
-
chainName: TESTNET_CHAIN_NAME,
|
|
917
918
|
provider: new providers.JsonRpcProvider('https://zkevm-rpc.sandbox.x.immutable.com'),
|
|
918
919
|
};
|
|
919
|
-
|
|
920
|
-
|
|
920
|
+
case MAINNET_CHAIN_NAME:
|
|
921
|
+
// not yet deployed
|
|
921
922
|
return {
|
|
922
923
|
seaportContractAddress: '',
|
|
923
924
|
zoneContractAddress: '',
|
|
924
925
|
apiEndpoint: 'https://order-book-mr.imtbl.com',
|
|
925
|
-
chainName: MAINNET_CHAIN_NAME,
|
|
926
926
|
provider: new providers.JsonRpcProvider('https://zkevm-rpc.x.immutable.com'),
|
|
927
927
|
};
|
|
928
928
|
default:
|
|
@@ -1881,19 +1881,21 @@ class Orderbook {
|
|
|
1881
1881
|
apiClient;
|
|
1882
1882
|
seaport;
|
|
1883
1883
|
orderbookConfig;
|
|
1884
|
-
constructor(config) {
|
|
1885
|
-
|
|
1886
|
-
const
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
};
|
|
1890
|
-
if (!finalConfig) {
|
|
1891
|
-
throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
|
|
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');
|
|
1892
1889
|
}
|
|
1893
|
-
this.orderbookConfig =
|
|
1894
|
-
const { apiEndpoint
|
|
1890
|
+
this.orderbookConfig = maybeConfig;
|
|
1891
|
+
const { apiEndpoint } = this.orderbookConfig;
|
|
1895
1892
|
if (!apiEndpoint) {
|
|
1896
|
-
throw new Error('API endpoint must be provided');
|
|
1893
|
+
throw new Error('API endpoint must be provided as an override');
|
|
1894
|
+
}
|
|
1895
|
+
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
1896
|
+
const chainName = config.overrides?.chainName;
|
|
1897
|
+
if (!chainName) {
|
|
1898
|
+
throw new Error('chainName must be provided as an override');
|
|
1897
1899
|
}
|
|
1898
1900
|
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
1899
1901
|
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
package/dist/passport.d.ts
CHANGED
|
@@ -203,7 +203,7 @@ declare abstract class ForkEvent extends Description {
|
|
|
203
203
|
}
|
|
204
204
|
declare type EventType = string | Array<string | Array<string>> | EventFilter | ForkEvent;
|
|
205
205
|
declare type Listener = (...args: Array<any>) => void;
|
|
206
|
-
declare abstract class Provider
|
|
206
|
+
declare abstract class Provider implements OnceBlockable {
|
|
207
207
|
abstract getNetwork(): Promise<Network>;
|
|
208
208
|
abstract getBlockNumber(): Promise<number>;
|
|
209
209
|
abstract getGasPrice(): Promise<BigNumber>;
|
|
@@ -222,27 +222,27 @@ declare abstract class Provider$1 implements OnceBlockable {
|
|
|
222
222
|
abstract getLogs(filter: Filter): Promise<Array<Log>>;
|
|
223
223
|
abstract resolveName(name: string | Promise<string>): Promise<null | string>;
|
|
224
224
|
abstract lookupAddress(address: string | Promise<string>): Promise<null | string>;
|
|
225
|
-
abstract on(eventName: EventType, listener: Listener): Provider
|
|
226
|
-
abstract once(eventName: EventType, listener: Listener): Provider
|
|
225
|
+
abstract on(eventName: EventType, listener: Listener): Provider;
|
|
226
|
+
abstract once(eventName: EventType, listener: Listener): Provider;
|
|
227
227
|
abstract emit(eventName: EventType, ...args: Array<any>): boolean;
|
|
228
228
|
abstract listenerCount(eventName?: EventType): number;
|
|
229
229
|
abstract listeners(eventName?: EventType): Array<Listener>;
|
|
230
|
-
abstract off(eventName: EventType, listener?: Listener): Provider
|
|
231
|
-
abstract removeAllListeners(eventName?: EventType): Provider
|
|
232
|
-
addListener(eventName: EventType, listener: Listener): Provider
|
|
233
|
-
removeListener(eventName: EventType, listener: Listener): Provider
|
|
230
|
+
abstract off(eventName: EventType, listener?: Listener): Provider;
|
|
231
|
+
abstract removeAllListeners(eventName?: EventType): Provider;
|
|
232
|
+
addListener(eventName: EventType, listener: Listener): Provider;
|
|
233
|
+
removeListener(eventName: EventType, listener: Listener): Provider;
|
|
234
234
|
abstract waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt>;
|
|
235
235
|
readonly _isProvider: boolean;
|
|
236
236
|
constructor();
|
|
237
|
-
static isProvider(value: any): value is Provider
|
|
237
|
+
static isProvider(value: any): value is Provider;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
declare abstract class Signer {
|
|
241
|
-
readonly provider?: Provider
|
|
241
|
+
readonly provider?: Provider;
|
|
242
242
|
abstract getAddress(): Promise<string>;
|
|
243
243
|
abstract signMessage(message: Bytes | string): Promise<string>;
|
|
244
244
|
abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
|
|
245
|
-
abstract connect(provider: Provider
|
|
245
|
+
abstract connect(provider: Provider): Signer;
|
|
246
246
|
readonly _isSigner: boolean;
|
|
247
247
|
constructor();
|
|
248
248
|
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
|
@@ -10352,14 +10352,14 @@ declare class ImmutableXClient {
|
|
|
10352
10352
|
* @returns a promise that resolves with the requested Order
|
|
10353
10353
|
* @throws {@link index.IMXError}
|
|
10354
10354
|
*/
|
|
10355
|
-
getOrder(request: OrdersApiGetOrderRequest): Promise<
|
|
10355
|
+
getOrder(request: OrdersApiGetOrderRequest): Promise<Order>;
|
|
10356
10356
|
/**
|
|
10357
10357
|
* Get a list of Orders
|
|
10358
10358
|
* @param request - optional object containing the parameters to be provided in the API request
|
|
10359
10359
|
* @returns a promise that resolves with the requested list of Orders
|
|
10360
10360
|
* @throws {@link index.IMXError}
|
|
10361
10361
|
*/
|
|
10362
|
-
listOrders(request?: OrdersApiListOrdersRequest): Promise<
|
|
10362
|
+
listOrders(request?: OrdersApiListOrdersRequest): Promise<ListOrdersResponse>;
|
|
10363
10363
|
/**
|
|
10364
10364
|
* Get details of a Trade with the given ID
|
|
10365
10365
|
* @param request - the request object containing the parameters to be provided in the API request
|
|
@@ -10473,7 +10473,6 @@ declare enum Networks {
|
|
|
10473
10473
|
interface OidcConfiguration {
|
|
10474
10474
|
clientId: string;
|
|
10475
10475
|
logoutRedirectUri: string;
|
|
10476
|
-
logoutMode?: 'redirect' | 'silent';
|
|
10477
10476
|
redirectUri: string;
|
|
10478
10477
|
scope?: string;
|
|
10479
10478
|
audience?: string;
|
|
@@ -10486,12 +10485,6 @@ interface PassportOverrides {
|
|
|
10486
10485
|
passportDomain: string;
|
|
10487
10486
|
imxPublicApiDomain: string;
|
|
10488
10487
|
immutableXClient: ImmutableXClient;
|
|
10489
|
-
zkEvmRpcUrl: string;
|
|
10490
|
-
zkEvmChainId: string;
|
|
10491
|
-
relayerUrl: string;
|
|
10492
|
-
indexerMrBasePath: string;
|
|
10493
|
-
orderBookMrBasePath: string;
|
|
10494
|
-
passportMrBasePath: string;
|
|
10495
10488
|
}
|
|
10496
10489
|
interface PassportModuleConfiguration extends ModuleConfiguration<PassportOverrides>, OidcConfiguration {
|
|
10497
10490
|
}
|
|
@@ -10509,58 +10502,6 @@ type DeviceTokenResponse = {
|
|
|
10509
10502
|
expires_in: number;
|
|
10510
10503
|
};
|
|
10511
10504
|
|
|
10512
|
-
/**
|
|
10513
|
-
* ProviderErrors should take priority over RpcErrorCodes
|
|
10514
|
-
*/
|
|
10515
|
-
declare enum ProviderErrorCode {
|
|
10516
|
-
USER_REJECTED_REQUEST = 4001,
|
|
10517
|
-
UNAUTHORIZED = 4100,
|
|
10518
|
-
UNSUPPORTED_METHOD = 4200,
|
|
10519
|
-
DISCONNECTED = 4900
|
|
10520
|
-
}
|
|
10521
|
-
declare enum RpcErrorCode {
|
|
10522
|
-
RPC_SERVER_ERROR = -32000,
|
|
10523
|
-
INVALID_REQUEST = -32600,
|
|
10524
|
-
METHOD_NOT_FOUND = -32601,
|
|
10525
|
-
INVALID_PARAMS = -32602,
|
|
10526
|
-
INTERNAL_ERROR = -32603,
|
|
10527
|
-
PARSE_ERROR = -32700
|
|
10528
|
-
}
|
|
10529
|
-
declare class JsonRpcError extends Error {
|
|
10530
|
-
readonly message: string;
|
|
10531
|
-
readonly code: ProviderErrorCode | RpcErrorCode;
|
|
10532
|
-
constructor(code: ProviderErrorCode | RpcErrorCode, message: string);
|
|
10533
|
-
}
|
|
10534
|
-
|
|
10535
|
-
interface RequestArguments {
|
|
10536
|
-
method: string;
|
|
10537
|
-
params?: Array<any>;
|
|
10538
|
-
}
|
|
10539
|
-
type JsonRpcRequestPayload = RequestArguments & {
|
|
10540
|
-
jsonrpc?: string;
|
|
10541
|
-
id?: string | number;
|
|
10542
|
-
};
|
|
10543
|
-
interface JsonRpcRequestCallback {
|
|
10544
|
-
(err: JsonRpcError | null, result?: JsonRpcResponsePayload | (JsonRpcResponsePayload | null)[] | null): void;
|
|
10545
|
-
}
|
|
10546
|
-
interface JsonRpcResponsePayload {
|
|
10547
|
-
result?: Array<any> | null;
|
|
10548
|
-
error?: JsonRpcError | null;
|
|
10549
|
-
jsonrpc?: string;
|
|
10550
|
-
id?: string | number;
|
|
10551
|
-
}
|
|
10552
|
-
type Provider = {
|
|
10553
|
-
request: (request: RequestArguments) => Promise<any>;
|
|
10554
|
-
sendAsync: (request: JsonRpcRequestPayload | JsonRpcRequestPayload[], callback: JsonRpcRequestCallback) => void;
|
|
10555
|
-
send: (request: string | JsonRpcRequestPayload | JsonRpcRequestPayload[], callbackOrParams?: JsonRpcRequestCallback | Array<any>, callback?: JsonRpcRequestCallback) => void;
|
|
10556
|
-
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
10557
|
-
removeListener: (event: string, listener: (...args: any[]) => void) => void;
|
|
10558
|
-
};
|
|
10559
|
-
declare enum ProviderEvent {
|
|
10560
|
-
ACCOUNTS_CHANGED = "accountsChanged"
|
|
10561
|
-
}
|
|
10562
|
-
type AccountsChangedEvent = Array<string>;
|
|
10563
|
-
|
|
10564
10505
|
declare class Passport {
|
|
10565
10506
|
private readonly authManager;
|
|
10566
10507
|
private readonly config;
|
|
@@ -10568,7 +10509,6 @@ declare class Passport {
|
|
|
10568
10509
|
private readonly immutableXClient;
|
|
10569
10510
|
private readonly magicAdapter;
|
|
10570
10511
|
private readonly passportImxProviderFactory;
|
|
10571
|
-
private readonly multiRollupApiClients;
|
|
10572
10512
|
constructor(passportModuleConfiguration: PassportModuleConfiguration);
|
|
10573
10513
|
connectImxSilent(): Promise<IMXProvider | null>;
|
|
10574
10514
|
connectImx(): Promise<IMXProvider>;
|
|
@@ -10579,14 +10519,8 @@ declare class Passport {
|
|
|
10579
10519
|
*/
|
|
10580
10520
|
checkStoredDeviceFlowCredentials(): DeviceTokenResponse | null;
|
|
10581
10521
|
connectImxWithCredentials(tokenResponse: DeviceTokenResponse): Promise<IMXProvider | null>;
|
|
10582
|
-
protected connectEvm(): Provider;
|
|
10583
10522
|
loginCallback(): Promise<void>;
|
|
10584
10523
|
logout(): Promise<void>;
|
|
10585
|
-
/**
|
|
10586
|
-
* This method should only be called from the logout redirect uri
|
|
10587
|
-
* when logout mode is 'silent'.
|
|
10588
|
-
*/
|
|
10589
|
-
logoutSilentCallback(url: string): Promise<void>;
|
|
10590
10524
|
logoutDeviceFlow(): Promise<void>;
|
|
10591
10525
|
getUserInfo(): Promise<UserProfile | undefined>;
|
|
10592
10526
|
getUserInfoDeviceFlow(): Promise<UserProfile | undefined>;
|
|
@@ -10594,4 +10528,4 @@ declare class Passport {
|
|
|
10594
10528
|
getAccessToken(): Promise<string | undefined>;
|
|
10595
10529
|
}
|
|
10596
10530
|
|
|
10597
|
-
export {
|
|
10531
|
+
export { DeviceConnectResponse, DeviceTokenResponse, Networks, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, UserProfile };
|