@imtbl/sdk 0.4.0-alpha → 0.4.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 +1 -1
- 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 +66 -847
- package/dist/index.d.ts +45 -126
- package/dist/index.js +67 -847
- 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/index.cjs
CHANGED
|
@@ -9,11 +9,8 @@ var oidc = require('@magic-ext/oidc');
|
|
|
9
9
|
var BN$2 = require('bn.js');
|
|
10
10
|
var encUtils = require('enc-utils');
|
|
11
11
|
var providers = require('@ethersproject/providers');
|
|
12
|
-
var events = require('events');
|
|
13
|
-
var ethers = require('ethers');
|
|
14
|
-
var abi = require('@0xsequence/abi');
|
|
15
|
-
var config = require('@0xsequence/config');
|
|
16
12
|
var FormData$2 = require('form-data');
|
|
13
|
+
var ethers = require('ethers');
|
|
17
14
|
var seaportJs = require('@opensea/seaport-js');
|
|
18
15
|
var units = require('@ethersproject/units');
|
|
19
16
|
var bignumber = require('@ethersproject/bignumber');
|
|
@@ -3268,94 +3265,6 @@ axios$1.default = axios$1;
|
|
|
3268
3265
|
// this module should only have a default export
|
|
3269
3266
|
var globalAxios$1 = axios$1;
|
|
3270
3267
|
|
|
3271
|
-
/* tslint:disable */
|
|
3272
|
-
/* eslint-disable */
|
|
3273
|
-
/**
|
|
3274
|
-
* Immutable X API
|
|
3275
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
3276
|
-
*
|
|
3277
|
-
* The version of the OpenAPI document: 3.0
|
|
3278
|
-
* Contact: support@immutable.com
|
|
3279
|
-
*
|
|
3280
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
3281
|
-
* https://openapi-generator.tech
|
|
3282
|
-
* Do not edit the class manually.
|
|
3283
|
-
*/
|
|
3284
|
-
let Configuration$1 = class Configuration {
|
|
3285
|
-
/**
|
|
3286
|
-
* parameter for apiKey security
|
|
3287
|
-
* @param name security name
|
|
3288
|
-
* @memberof Configuration
|
|
3289
|
-
*/
|
|
3290
|
-
apiKey;
|
|
3291
|
-
/**
|
|
3292
|
-
* parameter for basic security
|
|
3293
|
-
*
|
|
3294
|
-
* @type {string}
|
|
3295
|
-
* @memberof Configuration
|
|
3296
|
-
*/
|
|
3297
|
-
username;
|
|
3298
|
-
/**
|
|
3299
|
-
* parameter for basic security
|
|
3300
|
-
*
|
|
3301
|
-
* @type {string}
|
|
3302
|
-
* @memberof Configuration
|
|
3303
|
-
*/
|
|
3304
|
-
password;
|
|
3305
|
-
/**
|
|
3306
|
-
* parameter for oauth2 security
|
|
3307
|
-
* @param name security name
|
|
3308
|
-
* @param scopes oauth2 scope
|
|
3309
|
-
* @memberof Configuration
|
|
3310
|
-
*/
|
|
3311
|
-
accessToken;
|
|
3312
|
-
/**
|
|
3313
|
-
* override base path
|
|
3314
|
-
*
|
|
3315
|
-
* @type {string}
|
|
3316
|
-
* @memberof Configuration
|
|
3317
|
-
*/
|
|
3318
|
-
basePath;
|
|
3319
|
-
/**
|
|
3320
|
-
* base options for axios calls
|
|
3321
|
-
*
|
|
3322
|
-
* @type {any}
|
|
3323
|
-
* @memberof Configuration
|
|
3324
|
-
*/
|
|
3325
|
-
baseOptions;
|
|
3326
|
-
/**
|
|
3327
|
-
* The FormData constructor that will be used to create multipart form data
|
|
3328
|
-
* requests. You can inject this here so that execution environments that
|
|
3329
|
-
* do not support the FormData class can still run the generated client.
|
|
3330
|
-
*
|
|
3331
|
-
* @type {new () => FormData}
|
|
3332
|
-
*/
|
|
3333
|
-
formDataCtor;
|
|
3334
|
-
constructor(param = {}) {
|
|
3335
|
-
this.apiKey = param.apiKey;
|
|
3336
|
-
this.username = param.username;
|
|
3337
|
-
this.password = param.password;
|
|
3338
|
-
this.accessToken = param.accessToken;
|
|
3339
|
-
this.basePath = param.basePath;
|
|
3340
|
-
this.baseOptions = param.baseOptions;
|
|
3341
|
-
this.formDataCtor = param.formDataCtor;
|
|
3342
|
-
}
|
|
3343
|
-
/**
|
|
3344
|
-
* Check if the given MIME is a JSON MIME.
|
|
3345
|
-
* JSON MIME examples:
|
|
3346
|
-
* application/json
|
|
3347
|
-
* application/json; charset=UTF8
|
|
3348
|
-
* APPLICATION/JSON
|
|
3349
|
-
* application/vnd.company+json
|
|
3350
|
-
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
3351
|
-
* @return True if the given MIME is JSON, false otherwise.
|
|
3352
|
-
*/
|
|
3353
|
-
isJsonMime(mime) {
|
|
3354
|
-
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
3355
|
-
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
3356
|
-
}
|
|
3357
|
-
};
|
|
3358
|
-
|
|
3359
3268
|
/* tslint:disable */
|
|
3360
3269
|
/* eslint-disable */
|
|
3361
3270
|
/**
|
|
@@ -5064,7 +4973,7 @@ class TokensApi extends BaseAPI$1 {
|
|
|
5064
4973
|
* https://openapi-generator.tech
|
|
5065
4974
|
* Do not edit the class manually.
|
|
5066
4975
|
*/
|
|
5067
|
-
let Configuration$
|
|
4976
|
+
let Configuration$1 = class Configuration {
|
|
5068
4977
|
/**
|
|
5069
4978
|
* parameter for apiKey security
|
|
5070
4979
|
* @param name security name
|
|
@@ -5497,7 +5406,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
5497
5406
|
CollectionsApiAxiosParamCreator: CollectionsApiAxiosParamCreator,
|
|
5498
5407
|
CollectionsApiFactory: CollectionsApiFactory,
|
|
5499
5408
|
CollectionsApiFp: CollectionsApiFp,
|
|
5500
|
-
Configuration: Configuration$
|
|
5409
|
+
Configuration: Configuration$1,
|
|
5501
5410
|
CreateOrderProtocolDataOrderTypeEnum: CreateOrderProtocolDataOrderTypeEnum,
|
|
5502
5411
|
ERC20ItemItemTypeEnum: ERC20ItemItemTypeEnum,
|
|
5503
5412
|
ERC721ItemItemTypeEnum: ERC721ItemItemTypeEnum,
|
|
@@ -5529,69 +5438,6 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
5529
5438
|
TokensApiFp: TokensApiFp
|
|
5530
5439
|
});
|
|
5531
5440
|
|
|
5532
|
-
class MultiRollupApiClients {
|
|
5533
|
-
config;
|
|
5534
|
-
activitiesApi;
|
|
5535
|
-
chainsApi;
|
|
5536
|
-
collectionApi;
|
|
5537
|
-
nftOwnersApi;
|
|
5538
|
-
nftsApi;
|
|
5539
|
-
ordersApi;
|
|
5540
|
-
passportApi;
|
|
5541
|
-
constructor(config) {
|
|
5542
|
-
this.config = config;
|
|
5543
|
-
this.activitiesApi = new ActivitiesApi(config.indexer);
|
|
5544
|
-
this.chainsApi = new ChainsApi(config.indexer);
|
|
5545
|
-
this.collectionApi = new CollectionsApi(config.indexer);
|
|
5546
|
-
this.nftOwnersApi = new NftOwnersApi(config.indexer);
|
|
5547
|
-
this.nftsApi = new NftsApi(config.indexer);
|
|
5548
|
-
this.ordersApi = new OrdersApi(config.orderBook);
|
|
5549
|
-
this.passportApi = new PassportApi(config.passport);
|
|
5550
|
-
}
|
|
5551
|
-
}
|
|
5552
|
-
|
|
5553
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5554
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.4.0-alpha' };
|
|
5555
|
-
const createConfig = ({ basePath, headers, }) => {
|
|
5556
|
-
if (!basePath.trim()) {
|
|
5557
|
-
throw Error('basePath can not be empty');
|
|
5558
|
-
}
|
|
5559
|
-
const composedHeaders = { ...defaultHeaders$1, ...(headers || {}) };
|
|
5560
|
-
const apiConfigOptions = {
|
|
5561
|
-
basePath,
|
|
5562
|
-
baseOptions: { headers: composedHeaders },
|
|
5563
|
-
};
|
|
5564
|
-
return new Configuration$1(apiConfigOptions);
|
|
5565
|
-
};
|
|
5566
|
-
/**
|
|
5567
|
-
* Creates a Configuration for the specified environment
|
|
5568
|
-
* @returns an MultiRollupAPIConfiguration
|
|
5569
|
-
*/
|
|
5570
|
-
const multiRollupConfig = {
|
|
5571
|
-
getProduction: () => ({
|
|
5572
|
-
indexer: createConfig({
|
|
5573
|
-
basePath: 'https://indexer-mr.imtbl.com',
|
|
5574
|
-
}),
|
|
5575
|
-
orderBook: createConfig({
|
|
5576
|
-
basePath: 'https://order-book-mr.imtbl.com',
|
|
5577
|
-
}),
|
|
5578
|
-
passport: createConfig({
|
|
5579
|
-
basePath: 'https://api.immutable.com',
|
|
5580
|
-
}),
|
|
5581
|
-
}),
|
|
5582
|
-
getSandbox: () => ({
|
|
5583
|
-
indexer: createConfig({
|
|
5584
|
-
basePath: 'https://indexer-mr.sandbox.imtbl.com',
|
|
5585
|
-
}),
|
|
5586
|
-
orderBook: createConfig({
|
|
5587
|
-
basePath: 'https://order-book-mr.sandbox.imtbl.com',
|
|
5588
|
-
}),
|
|
5589
|
-
passport: createConfig({
|
|
5590
|
-
basePath: 'https://api.sandbox.immutable.com',
|
|
5591
|
-
}),
|
|
5592
|
-
}),
|
|
5593
|
-
};
|
|
5594
|
-
|
|
5595
5441
|
/**
|
|
5596
5442
|
* Custom Error class that is returned from the API when a request fails
|
|
5597
5443
|
*/
|
|
@@ -5611,7 +5457,7 @@ class APIError extends Error {
|
|
|
5611
5457
|
|
|
5612
5458
|
/* eslint-disable implicit-arrow-linebreak */
|
|
5613
5459
|
const defaultHeaders = {
|
|
5614
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha',
|
|
5460
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha.1',
|
|
5615
5461
|
};
|
|
5616
5462
|
/**
|
|
5617
5463
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -5877,7 +5723,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
5877
5723
|
chainID,
|
|
5878
5724
|
coreContractAddress,
|
|
5879
5725
|
registrationContractAddress,
|
|
5880
|
-
sdkVersion: 'ts-immutable-sdk-0.4.0-alpha',
|
|
5726
|
+
sdkVersion: 'ts-immutable-sdk-0.4.0-alpha.1',
|
|
5881
5727
|
});
|
|
5882
5728
|
/**
|
|
5883
5729
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9601,8 +9447,6 @@ var globalAxios = axios;
|
|
|
9601
9447
|
* https://openapi-generator.tech
|
|
9602
9448
|
* Do not edit the class manually.
|
|
9603
9449
|
*/
|
|
9604
|
-
// Some imports not used depending on template conditions
|
|
9605
|
-
// @ts-ignore
|
|
9606
9450
|
const BASE_PATH = "https://guardian.sandbox.imtbl.com".replace(/\/+$/, "");
|
|
9607
9451
|
/**
|
|
9608
9452
|
*
|
|
@@ -9630,10 +9474,10 @@ class BaseAPI {
|
|
|
9630
9474
|
*/
|
|
9631
9475
|
class RequiredError extends Error {
|
|
9632
9476
|
field;
|
|
9633
|
-
name = "RequiredError";
|
|
9634
9477
|
constructor(field, msg) {
|
|
9635
9478
|
super(msg);
|
|
9636
9479
|
this.field = field;
|
|
9480
|
+
this.name = "RequiredError";
|
|
9637
9481
|
}
|
|
9638
9482
|
}
|
|
9639
9483
|
|
|
@@ -9678,6 +9522,8 @@ const setBearerAuthToObject = async function (object, configuration) {
|
|
|
9678
9522
|
}
|
|
9679
9523
|
};
|
|
9680
9524
|
function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
9525
|
+
if (parameter == null)
|
|
9526
|
+
return;
|
|
9681
9527
|
if (typeof parameter === "object") {
|
|
9682
9528
|
if (Array.isArray(parameter)) {
|
|
9683
9529
|
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
@@ -9833,7 +9679,7 @@ const TransactionsApiAxiosParamCreator = function (configuration) {
|
|
|
9833
9679
|
* @summary Info for a specific transaction
|
|
9834
9680
|
* @param {string} transactionID The id of the starkex transaction to retrieve
|
|
9835
9681
|
* @param {'starkex' | 'evm'} chainType roll up type
|
|
9836
|
-
* @param {
|
|
9682
|
+
* @param {number} [chainID] ID of evm chain
|
|
9837
9683
|
* @param {*} [options] Override http request option.
|
|
9838
9684
|
* @throws {RequiredError}
|
|
9839
9685
|
*/
|
|
@@ -9908,7 +9754,7 @@ const TransactionsApiFp = function (configuration) {
|
|
|
9908
9754
|
* @summary Info for a specific transaction
|
|
9909
9755
|
* @param {string} transactionID The id of the starkex transaction to retrieve
|
|
9910
9756
|
* @param {'starkex' | 'evm'} chainType roll up type
|
|
9911
|
-
* @param {
|
|
9757
|
+
* @param {number} [chainID] ID of evm chain
|
|
9912
9758
|
* @param {*} [options] Override http request option.
|
|
9913
9759
|
* @throws {RequiredError}
|
|
9914
9760
|
*/
|
|
@@ -10225,12 +10071,10 @@ class AuthManager {
|
|
|
10225
10071
|
userManager;
|
|
10226
10072
|
config;
|
|
10227
10073
|
deviceCredentialsManager;
|
|
10228
|
-
logoutMode;
|
|
10229
10074
|
constructor(config) {
|
|
10230
10075
|
this.config = config;
|
|
10231
10076
|
this.userManager = new oidcClientTs.UserManager(getAuthConfiguration(config));
|
|
10232
10077
|
this.deviceCredentialsManager = new DeviceCredentialsManager();
|
|
10233
|
-
this.logoutMode = config.oidcConfiguration.logoutMode || 'redirect';
|
|
10234
10078
|
}
|
|
10235
10079
|
static mapOidcUserToDomainModel = (oidcUser) => {
|
|
10236
10080
|
const passport = oidcUser.profile?.passport;
|
|
@@ -10384,15 +10228,7 @@ class AuthManager {
|
|
|
10384
10228
|
return response.data;
|
|
10385
10229
|
}
|
|
10386
10230
|
async logout() {
|
|
10387
|
-
return withPassportError(async () =>
|
|
10388
|
-
if (this.logoutMode === 'silent') {
|
|
10389
|
-
return this.userManager.signoutSilent();
|
|
10390
|
-
}
|
|
10391
|
-
return this.userManager.signoutRedirect();
|
|
10392
|
-
}, PassportErrorType.LOGOUT_ERROR);
|
|
10393
|
-
}
|
|
10394
|
-
async logoutSilentCallback(url) {
|
|
10395
|
-
return this.userManager.signoutSilentCallback(url);
|
|
10231
|
+
return withPassportError(async () => this.userManager.signoutRedirect(), PassportErrorType.LOGOUT_ERROR);
|
|
10396
10232
|
}
|
|
10397
10233
|
async logoutDeviceFlow() {
|
|
10398
10234
|
return withPassportError(async () => {
|
|
@@ -10595,7 +10431,6 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
|
|
|
10595
10431
|
amount_sell: amountSell,
|
|
10596
10432
|
token_sell: convertToSignableToken(request.sell),
|
|
10597
10433
|
fees: request.fees,
|
|
10598
|
-
split_fees: true,
|
|
10599
10434
|
expiration_timestamp: request.expiration_timestamp,
|
|
10600
10435
|
};
|
|
10601
10436
|
const getSignableOrderResponse = await ordersApi.getSignableOrder({
|
|
@@ -11050,10 +10885,6 @@ class PassportConfiguration {
|
|
|
11050
10885
|
magicProviderId;
|
|
11051
10886
|
oidcConfiguration;
|
|
11052
10887
|
baseConfig;
|
|
11053
|
-
zkEvmChainId;
|
|
11054
|
-
zkEvmRpcUrl;
|
|
11055
|
-
relayerUrl;
|
|
11056
|
-
multiRollupConfig;
|
|
11057
10888
|
constructor({ baseConfig, overrides, ...oidcConfiguration }) {
|
|
11058
10889
|
validateConfiguration(oidcConfiguration, [
|
|
11059
10890
|
'clientId',
|
|
@@ -11066,16 +10897,10 @@ class PassportConfiguration {
|
|
|
11066
10897
|
validateConfiguration(overrides, [
|
|
11067
10898
|
'network',
|
|
11068
10899
|
'authenticationDomain',
|
|
11069
|
-
'passportDomain',
|
|
11070
10900
|
'magicPublishableApiKey',
|
|
11071
10901
|
'magicProviderId',
|
|
11072
|
-
'
|
|
11073
|
-
'zkEvmChainId',
|
|
11074
|
-
'relayerUrl',
|
|
10902
|
+
'passportDomain',
|
|
11075
10903
|
'imxPublicApiDomain',
|
|
11076
|
-
'indexerMrBasePath',
|
|
11077
|
-
'orderBookMrBasePath',
|
|
11078
|
-
'passportMrBasePath',
|
|
11079
10904
|
], 'overrides');
|
|
11080
10905
|
this.network = overrides.network;
|
|
11081
10906
|
this.authenticationDomain = overrides.authenticationDomain;
|
|
@@ -11083,20 +10908,6 @@ class PassportConfiguration {
|
|
|
11083
10908
|
this.imxPublicApiDomain = overrides.imxPublicApiDomain;
|
|
11084
10909
|
this.magicPublishableApiKey = overrides.magicPublishableApiKey;
|
|
11085
10910
|
this.magicProviderId = overrides.magicProviderId;
|
|
11086
|
-
this.zkEvmRpcUrl = overrides.zkEvmRpcUrl;
|
|
11087
|
-
this.zkEvmChainId = overrides.zkEvmChainId;
|
|
11088
|
-
this.relayerUrl = overrides.relayerUrl;
|
|
11089
|
-
this.multiRollupConfig = {
|
|
11090
|
-
indexer: createConfig({
|
|
11091
|
-
basePath: overrides.indexerMrBasePath,
|
|
11092
|
-
}),
|
|
11093
|
-
orderBook: createConfig({
|
|
11094
|
-
basePath: overrides.orderBookMrBasePath,
|
|
11095
|
-
}),
|
|
11096
|
-
passport: createConfig({
|
|
11097
|
-
basePath: overrides.passportMrBasePath,
|
|
11098
|
-
}),
|
|
11099
|
-
};
|
|
11100
10911
|
}
|
|
11101
10912
|
else {
|
|
11102
10913
|
switch (baseConfig.environment) {
|
|
@@ -11107,10 +10918,6 @@ class PassportConfiguration {
|
|
|
11107
10918
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
11108
10919
|
this.passportDomain = 'https://passport.immutable.com';
|
|
11109
10920
|
this.imxPublicApiDomain = 'https://api.immutable.com';
|
|
11110
|
-
this.zkEvmRpcUrl = ''; // TODO: ID-785 Update once mainnet has been deployed
|
|
11111
|
-
this.zkEvmChainId = ''; // TODO: ID-785 Update once mainnet has been deployed
|
|
11112
|
-
this.relayerUrl = 'https://api.immutable.com/relayer-mr';
|
|
11113
|
-
this.multiRollupConfig = multiRollupConfig.getProduction();
|
|
11114
10921
|
break;
|
|
11115
10922
|
}
|
|
11116
10923
|
case exports.Environment.SANDBOX:
|
|
@@ -11121,10 +10928,6 @@ class PassportConfiguration {
|
|
|
11121
10928
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
11122
10929
|
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
11123
10930
|
this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
|
|
11124
|
-
this.zkEvmRpcUrl = 'https://zkevm-rpc.sandbox.x.immutable.com';
|
|
11125
|
-
this.zkEvmChainId = 'eip155:13392';
|
|
11126
|
-
this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
|
|
11127
|
-
this.multiRollupConfig = multiRollupConfig.getSandbox();
|
|
11128
10931
|
break;
|
|
11129
10932
|
}
|
|
11130
10933
|
}
|
|
@@ -11285,537 +11088,6 @@ class ConfirmationScreen {
|
|
|
11285
11088
|
}
|
|
11286
11089
|
}
|
|
11287
11090
|
|
|
11288
|
-
var RelayerTransactionStatus;
|
|
11289
|
-
(function (RelayerTransactionStatus) {
|
|
11290
|
-
RelayerTransactionStatus["PENDING"] = "PENDING";
|
|
11291
|
-
RelayerTransactionStatus["SUBMITTED"] = "SUBMITTED";
|
|
11292
|
-
RelayerTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
11293
|
-
RelayerTransactionStatus["REVERTED"] = "REVERTED";
|
|
11294
|
-
RelayerTransactionStatus["FAILED"] = "FAILED";
|
|
11295
|
-
})(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
|
|
11296
|
-
exports.ProviderEvent = void 0;
|
|
11297
|
-
(function (ProviderEvent) {
|
|
11298
|
-
ProviderEvent["ACCOUNTS_CHANGED"] = "accountsChanged";
|
|
11299
|
-
})(exports.ProviderEvent || (exports.ProviderEvent = {}));
|
|
11300
|
-
|
|
11301
|
-
class TypedEventEmitter {
|
|
11302
|
-
emitter = new events.EventEmitter();
|
|
11303
|
-
emit(eventName, ...eventArg) {
|
|
11304
|
-
this.emitter.emit(eventName, ...eventArg);
|
|
11305
|
-
}
|
|
11306
|
-
on(eventName, handler) {
|
|
11307
|
-
this.emitter.on(eventName, handler);
|
|
11308
|
-
}
|
|
11309
|
-
removeListener(eventName, handler) {
|
|
11310
|
-
this.emitter.removeListener(eventName, handler);
|
|
11311
|
-
}
|
|
11312
|
-
}
|
|
11313
|
-
|
|
11314
|
-
class RelayerClient {
|
|
11315
|
-
config;
|
|
11316
|
-
constructor({ config }) {
|
|
11317
|
-
this.config = config;
|
|
11318
|
-
}
|
|
11319
|
-
async postToRelayer(request) {
|
|
11320
|
-
const body = {
|
|
11321
|
-
id: 1,
|
|
11322
|
-
jsonrpc: '2.0',
|
|
11323
|
-
...request,
|
|
11324
|
-
};
|
|
11325
|
-
const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
|
|
11326
|
-
method: 'POST',
|
|
11327
|
-
headers: {
|
|
11328
|
-
'Content-Type': 'application/json',
|
|
11329
|
-
},
|
|
11330
|
-
body: JSON.stringify(body),
|
|
11331
|
-
});
|
|
11332
|
-
const jsonResponse = await response.json();
|
|
11333
|
-
if (jsonResponse.error) {
|
|
11334
|
-
throw jsonResponse.error;
|
|
11335
|
-
}
|
|
11336
|
-
return jsonResponse;
|
|
11337
|
-
}
|
|
11338
|
-
async ethSendTransaction(to, data) {
|
|
11339
|
-
const payload = {
|
|
11340
|
-
method: 'eth_sendTransaction',
|
|
11341
|
-
params: [{
|
|
11342
|
-
to,
|
|
11343
|
-
data,
|
|
11344
|
-
chainId: this.config.zkEvmChainId.toString(),
|
|
11345
|
-
}],
|
|
11346
|
-
};
|
|
11347
|
-
const { result } = await this.postToRelayer(payload);
|
|
11348
|
-
return result;
|
|
11349
|
-
}
|
|
11350
|
-
async imGetTransactionByHash(hash) {
|
|
11351
|
-
const payload = {
|
|
11352
|
-
method: 'im_getTransactionByHash',
|
|
11353
|
-
params: [hash],
|
|
11354
|
-
};
|
|
11355
|
-
const { result } = await this.postToRelayer(payload);
|
|
11356
|
-
return result;
|
|
11357
|
-
}
|
|
11358
|
-
async imGetFeeOptions(userAddress, data) {
|
|
11359
|
-
const payload = {
|
|
11360
|
-
method: 'im_getFeeOptions',
|
|
11361
|
-
params: [{
|
|
11362
|
-
userAddress,
|
|
11363
|
-
data,
|
|
11364
|
-
chainId: this.config.zkEvmChainId.toString(),
|
|
11365
|
-
}],
|
|
11366
|
-
};
|
|
11367
|
-
const { result } = await this.postToRelayer(payload);
|
|
11368
|
-
return result;
|
|
11369
|
-
}
|
|
11370
|
-
}
|
|
11371
|
-
|
|
11372
|
-
/**
|
|
11373
|
-
* ProviderErrors should take priority over RpcErrorCodes
|
|
11374
|
-
*/
|
|
11375
|
-
exports.ProviderErrorCode = void 0;
|
|
11376
|
-
(function (ProviderErrorCode) {
|
|
11377
|
-
ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
|
|
11378
|
-
ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
|
|
11379
|
-
ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
|
|
11380
|
-
ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
|
|
11381
|
-
})(exports.ProviderErrorCode || (exports.ProviderErrorCode = {}));
|
|
11382
|
-
exports.RpcErrorCode = void 0;
|
|
11383
|
-
(function (RpcErrorCode) {
|
|
11384
|
-
RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
|
|
11385
|
-
RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
11386
|
-
RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
11387
|
-
RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
11388
|
-
RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
11389
|
-
RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
11390
|
-
})(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
11391
|
-
class JsonRpcError extends Error {
|
|
11392
|
-
message;
|
|
11393
|
-
code;
|
|
11394
|
-
constructor(code, message) {
|
|
11395
|
-
super(message);
|
|
11396
|
-
this.message = message;
|
|
11397
|
-
this.code = code;
|
|
11398
|
-
}
|
|
11399
|
-
}
|
|
11400
|
-
|
|
11401
|
-
const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
|
|
11402
|
-
async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
|
|
11403
|
-
const web3Provider = new providers.Web3Provider(magicProvider);
|
|
11404
|
-
const ethSigner = web3Provider.getSigner();
|
|
11405
|
-
const ethereumAddress = await ethSigner.getAddress();
|
|
11406
|
-
const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
|
|
11407
|
-
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
11408
|
-
try {
|
|
11409
|
-
await multiRollupApiClients.passportApi.createCounterfactualAddress({
|
|
11410
|
-
createCounterfactualAddressRequest: {
|
|
11411
|
-
ethereumAddress,
|
|
11412
|
-
ethereumSignature,
|
|
11413
|
-
},
|
|
11414
|
-
}, { headers });
|
|
11415
|
-
}
|
|
11416
|
-
catch (error) {
|
|
11417
|
-
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
|
|
11418
|
-
}
|
|
11419
|
-
const user = await authManager.loginSilent();
|
|
11420
|
-
if (!user?.zkEvm) {
|
|
11421
|
-
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
|
|
11422
|
-
}
|
|
11423
|
-
return user;
|
|
11424
|
-
}
|
|
11425
|
-
|
|
11426
|
-
const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
|
|
11427
|
-
const user = await authManager.getUser() || await authManager.login();
|
|
11428
|
-
if (!user.idToken) {
|
|
11429
|
-
throw new Error('User is missing idToken');
|
|
11430
|
-
}
|
|
11431
|
-
const magicProvider = await magicAdapter.login(user.idToken, config.network);
|
|
11432
|
-
if (!user.zkEvm) {
|
|
11433
|
-
// Generate counterfactual address and retrieve updated Auth0 user
|
|
11434
|
-
const userZkevm = await registerZkEvmUser({
|
|
11435
|
-
authManager,
|
|
11436
|
-
magicProvider,
|
|
11437
|
-
multiRollupApiClients,
|
|
11438
|
-
accessToken: user.accessToken,
|
|
11439
|
-
});
|
|
11440
|
-
return {
|
|
11441
|
-
user: userZkevm,
|
|
11442
|
-
magicProvider,
|
|
11443
|
-
};
|
|
11444
|
-
}
|
|
11445
|
-
return {
|
|
11446
|
-
user: user,
|
|
11447
|
-
magicProvider,
|
|
11448
|
-
};
|
|
11449
|
-
};
|
|
11450
|
-
|
|
11451
|
-
// These are ignored by the Relayer but for consistency we set them to the
|
|
11452
|
-
// appropriate values for a 1/1 wallet.
|
|
11453
|
-
//
|
|
11454
|
-
// Weight of a single signature in the multisig
|
|
11455
|
-
const SIGNATURE_WEIGHT = 1;
|
|
11456
|
-
// Total required weight in the multisig
|
|
11457
|
-
const SIGNATURE_THRESHOLD = 1;
|
|
11458
|
-
const ETH_SIGN_FLAG = '02';
|
|
11459
|
-
const ETH_SIGN_PREFIX = '\x19\x01';
|
|
11460
|
-
const META_TRANSACTIONS_TYPE = `tuple(
|
|
11461
|
-
bool delegateCall,
|
|
11462
|
-
bool revertOnError,
|
|
11463
|
-
uint256 gasLimit,
|
|
11464
|
-
address target,
|
|
11465
|
-
uint256 value,
|
|
11466
|
-
bytes data
|
|
11467
|
-
)[]`;
|
|
11468
|
-
function getNormalisedTransactions(txs) {
|
|
11469
|
-
return txs.map((t) => ({
|
|
11470
|
-
delegateCall: t.delegateCall === true,
|
|
11471
|
-
revertOnError: t.revertOnError === true,
|
|
11472
|
-
gasLimit: t.gasLimit ?? ethers.ethers.constants.Zero,
|
|
11473
|
-
target: t.to ?? ethers.ethers.constants.AddressZero,
|
|
11474
|
-
value: t.value ?? ethers.ethers.constants.Zero,
|
|
11475
|
-
data: t.data ?? [],
|
|
11476
|
-
}));
|
|
11477
|
-
}
|
|
11478
|
-
function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
|
|
11479
|
-
const packMetaTransactionsNonceData = ethers.ethers.utils.defaultAbiCoder.encode(['uint256', META_TRANSACTIONS_TYPE], [nonce, normalisedTransactions]);
|
|
11480
|
-
return ethers.ethers.utils.keccak256(packMetaTransactionsNonceData);
|
|
11481
|
-
}
|
|
11482
|
-
const getNonce = async (jsonRpcProvider, smartContractWalletAddress) => {
|
|
11483
|
-
const code = await jsonRpcProvider.send('eth_getCode', [smartContractWalletAddress, 'latest']);
|
|
11484
|
-
if (code && code !== '0x') {
|
|
11485
|
-
const contract = new ethers.ethers.Contract(smartContractWalletAddress, abi.walletContracts.mainModule.abi, jsonRpcProvider);
|
|
11486
|
-
return contract.nonce();
|
|
11487
|
-
}
|
|
11488
|
-
return 0;
|
|
11489
|
-
};
|
|
11490
|
-
const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
|
|
11491
|
-
const normalisedMetaTransactions = getNormalisedTransactions(metaTransactions);
|
|
11492
|
-
// Get the hash
|
|
11493
|
-
const digest = digestOfTransactionsAndNonce(nonce, normalisedMetaTransactions);
|
|
11494
|
-
const completePayload = ethers.ethers.utils.solidityPack(['string', 'uint256', 'address', 'bytes32'], [ETH_SIGN_PREFIX, chainId, walletAddress, digest]);
|
|
11495
|
-
const hash = ethers.ethers.utils.keccak256(completePayload);
|
|
11496
|
-
// Sign the digest
|
|
11497
|
-
const hashArray = ethers.ethers.utils.arrayify(hash);
|
|
11498
|
-
const ethsigNoType = await signer.signMessage(hashArray);
|
|
11499
|
-
const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
|
|
11500
|
-
// Add metadata
|
|
11501
|
-
const encodedSignature = config.encodeSignature({
|
|
11502
|
-
threshold: SIGNATURE_THRESHOLD,
|
|
11503
|
-
signers: [
|
|
11504
|
-
{
|
|
11505
|
-
weight: SIGNATURE_WEIGHT,
|
|
11506
|
-
signature: signedDigest,
|
|
11507
|
-
},
|
|
11508
|
-
],
|
|
11509
|
-
});
|
|
11510
|
-
// Encode the transaction;
|
|
11511
|
-
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
11512
|
-
return walletInterface.encodeFunctionData(walletInterface.getFunction('execute'), [
|
|
11513
|
-
normalisedMetaTransactions,
|
|
11514
|
-
nonce,
|
|
11515
|
-
encodedSignature,
|
|
11516
|
-
]);
|
|
11517
|
-
};
|
|
11518
|
-
const chainIdNumber = (chainId) => {
|
|
11519
|
-
const caip2Components = chainId.split(':');
|
|
11520
|
-
if (caip2Components.length !== 2) {
|
|
11521
|
-
throw new Error('Invalid configuration, chain ID is not in CAIP-2 format');
|
|
11522
|
-
}
|
|
11523
|
-
return ethers.BigNumber.from(caip2Components[1]);
|
|
11524
|
-
};
|
|
11525
|
-
|
|
11526
|
-
const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
|
|
11527
|
-
const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
|
|
11528
|
-
const converBigNumberishToNumber = (value) => ethers.BigNumber.from(value).toNumber();
|
|
11529
|
-
const transformGardianTransactions = (txs) => {
|
|
11530
|
-
try {
|
|
11531
|
-
return txs.map((t) => ({
|
|
11532
|
-
delegateCall: t.delegateCall === true,
|
|
11533
|
-
revertOnError: t.revertOnError === true,
|
|
11534
|
-
gasLimit: t.gasLimit ? converBigNumberishToNumber(t.gasLimit).toString() : '0',
|
|
11535
|
-
target: t.to ?? ethers.ethers.constants.AddressZero,
|
|
11536
|
-
value: t.value ? converBigNumberishToNumber(t.value).toString() : '0',
|
|
11537
|
-
data: t.data ? t.data.toString() : '0x00',
|
|
11538
|
-
}));
|
|
11539
|
-
}
|
|
11540
|
-
catch (error) {
|
|
11541
|
-
const errorMessage = (error instanceof Error) ? error.message : String(error);
|
|
11542
|
-
throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, `Transaction failed to parsing: ${errorMessage}`);
|
|
11543
|
-
}
|
|
11544
|
-
};
|
|
11545
|
-
const guardianValidation = async ({ transactionAPI, chainId, nonce, user, metaTransactions, }) => {
|
|
11546
|
-
const headers = { Authorization: `Bearer ${user.accessToken}` };
|
|
11547
|
-
const guardianTransactions = transformGardianTransactions(metaTransactions);
|
|
11548
|
-
try {
|
|
11549
|
-
await transactionAPI.evaluateTransaction({
|
|
11550
|
-
id: 'evm',
|
|
11551
|
-
transactionEvaluationRequest: {
|
|
11552
|
-
chainType: 'evm',
|
|
11553
|
-
chainId,
|
|
11554
|
-
transactionData: {
|
|
11555
|
-
nonce,
|
|
11556
|
-
userAddress: user.zkEvm.ethAddress,
|
|
11557
|
-
metaTransactions: guardianTransactions,
|
|
11558
|
-
},
|
|
11559
|
-
},
|
|
11560
|
-
}, { headers });
|
|
11561
|
-
}
|
|
11562
|
-
catch (error) {
|
|
11563
|
-
const errorMessage = (error instanceof Error) ? error.message : String(error);
|
|
11564
|
-
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
|
|
11565
|
-
}
|
|
11566
|
-
};
|
|
11567
|
-
const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, transactionAPI, config, user, }) => {
|
|
11568
|
-
const transactionRequest = params[0];
|
|
11569
|
-
if (!transactionRequest.to) {
|
|
11570
|
-
throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
11571
|
-
}
|
|
11572
|
-
const chainId = chainIdNumber(config.zkEvmChainId);
|
|
11573
|
-
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
11574
|
-
const signer = magicWeb3Provider.getSigner();
|
|
11575
|
-
const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
|
|
11576
|
-
const metaTransaction = {
|
|
11577
|
-
to: transactionRequest.to,
|
|
11578
|
-
data: transactionRequest.data,
|
|
11579
|
-
nonce,
|
|
11580
|
-
value: transactionRequest.value,
|
|
11581
|
-
revertOnError: true,
|
|
11582
|
-
};
|
|
11583
|
-
// NOTE: We sign the transaction before getting the fee options because
|
|
11584
|
-
// accurate estimation of a transaction gas cost is only possible if the smart
|
|
11585
|
-
// wallet contract can actually execute it (in a simulated environment) - and
|
|
11586
|
-
// it can only execute signed transactions.
|
|
11587
|
-
const signedTransaction = await getSignedMetaTransactions([metaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
|
|
11588
|
-
// TODO: ID-698 Add support for non-native gas payments (e.g ERC20, feeTransaction initialisation must change)
|
|
11589
|
-
// NOTE: "Fee Options" represent the multiple ways we could pay for the gas
|
|
11590
|
-
// used in this transaction. Each fee option has a "recipientAddress" we
|
|
11591
|
-
// should transfer the payment to, an amount and a currency. We choose one
|
|
11592
|
-
// option and build a transaction that sends the expected currency amount for
|
|
11593
|
-
// that option to the specified address.
|
|
11594
|
-
const feeOptions = await relayerClient.imGetFeeOptions(user.zkEvm.ethAddress, signedTransaction);
|
|
11595
|
-
const imxFeeOption = feeOptions.find((feeOption) => feeOption.tokenSymbol === 'IMX');
|
|
11596
|
-
if (!imxFeeOption) {
|
|
11597
|
-
throw new Error('Failed to retrieve fees for IMX token');
|
|
11598
|
-
}
|
|
11599
|
-
const feeMetaTransaction = {
|
|
11600
|
-
nonce,
|
|
11601
|
-
to: imxFeeOption.recipientAddress,
|
|
11602
|
-
value: imxFeeOption.tokenPrice,
|
|
11603
|
-
revertOnError: true,
|
|
11604
|
-
};
|
|
11605
|
-
await guardianValidation({
|
|
11606
|
-
transactionAPI,
|
|
11607
|
-
chainId: config.zkEvmChainId,
|
|
11608
|
-
nonce: converBigNumberishToNumber(nonce),
|
|
11609
|
-
user,
|
|
11610
|
-
metaTransactions: [metaTransaction, feeMetaTransaction],
|
|
11611
|
-
});
|
|
11612
|
-
// NOTE: We sign again because we now are adding the fee transaction, so the
|
|
11613
|
-
// whole payload is different and needs a new signature.
|
|
11614
|
-
const signedTransactions = await getSignedMetaTransactions([metaTransaction, feeMetaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
|
|
11615
|
-
// TODO: ID-697 Evaluate transactions through Guardian
|
|
11616
|
-
const relayerId = await relayerClient.ethSendTransaction(user.zkEvm.ethAddress, signedTransactions);
|
|
11617
|
-
const retrieveRelayerTransaction = async () => {
|
|
11618
|
-
const tx = await relayerClient.imGetTransactionByHash(relayerId);
|
|
11619
|
-
// NOTE: The transaction hash is only available from the Relayer once the
|
|
11620
|
-
// transaction is actually submitted onchain. Hence we need to poll the
|
|
11621
|
-
// Relayer get transaction endpoint until the status transitions to one that
|
|
11622
|
-
// has the hash available.
|
|
11623
|
-
if (tx.status === RelayerTransactionStatus.PENDING) {
|
|
11624
|
-
throw new Error();
|
|
11625
|
-
}
|
|
11626
|
-
return tx;
|
|
11627
|
-
};
|
|
11628
|
-
const relayerTransaction = await retryWithDelay(retrieveRelayerTransaction, {
|
|
11629
|
-
retries: MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES,
|
|
11630
|
-
interval: TRANSACTION_HASH_RETRIEVAL_WAIT,
|
|
11631
|
-
finalErr: new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
|
|
11632
|
-
});
|
|
11633
|
-
if (![RelayerTransactionStatus.SUBMITTED, RelayerTransactionStatus.SUCCESSFUL].includes(relayerTransaction.status)) {
|
|
11634
|
-
throw new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
|
|
11635
|
-
}
|
|
11636
|
-
return relayerTransaction.hash;
|
|
11637
|
-
};
|
|
11638
|
-
|
|
11639
|
-
class ZkEvmProvider {
|
|
11640
|
-
authManager;
|
|
11641
|
-
config;
|
|
11642
|
-
confirmationScreen;
|
|
11643
|
-
magicAdapter;
|
|
11644
|
-
relayerClient;
|
|
11645
|
-
transactionAPI;
|
|
11646
|
-
multiRollupApiClients;
|
|
11647
|
-
jsonRpcProvider; // Used for read
|
|
11648
|
-
eventEmitter;
|
|
11649
|
-
magicProvider; // Used for signing
|
|
11650
|
-
user;
|
|
11651
|
-
constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, }) {
|
|
11652
|
-
this.authManager = authManager;
|
|
11653
|
-
this.magicAdapter = magicAdapter;
|
|
11654
|
-
this.config = config;
|
|
11655
|
-
this.confirmationScreen = confirmationScreen;
|
|
11656
|
-
this.relayerClient = new RelayerClient({ config });
|
|
11657
|
-
this.transactionAPI = new TransactionsApi(new Configuration({
|
|
11658
|
-
basePath: this.config.imxPublicApiDomain,
|
|
11659
|
-
}));
|
|
11660
|
-
this.jsonRpcProvider = new providers.JsonRpcProvider(this.config.zkEvmRpcUrl);
|
|
11661
|
-
this.multiRollupApiClients = multiRollupApiClients;
|
|
11662
|
-
this.eventEmitter = new TypedEventEmitter();
|
|
11663
|
-
}
|
|
11664
|
-
isLoggedIn() {
|
|
11665
|
-
return this.magicProvider !== undefined && this.user !== undefined;
|
|
11666
|
-
}
|
|
11667
|
-
async performRequest(request) {
|
|
11668
|
-
switch (request.method) {
|
|
11669
|
-
case 'eth_requestAccounts': {
|
|
11670
|
-
if (this.isLoggedIn()) {
|
|
11671
|
-
return [this.user.zkEvm.ethAddress];
|
|
11672
|
-
}
|
|
11673
|
-
const { magicProvider, user } = await loginZkEvmUser({
|
|
11674
|
-
authManager: this.authManager,
|
|
11675
|
-
config: this.config,
|
|
11676
|
-
magicAdapter: this.magicAdapter,
|
|
11677
|
-
multiRollupApiClients: this.multiRollupApiClients,
|
|
11678
|
-
});
|
|
11679
|
-
this.user = user;
|
|
11680
|
-
this.magicProvider = magicProvider;
|
|
11681
|
-
this.eventEmitter.emit(exports.ProviderEvent.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
|
|
11682
|
-
return [this.user.zkEvm.ethAddress];
|
|
11683
|
-
}
|
|
11684
|
-
case 'eth_sendTransaction': {
|
|
11685
|
-
if (!this.isLoggedIn()) {
|
|
11686
|
-
throw new JsonRpcError(exports.ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
|
|
11687
|
-
}
|
|
11688
|
-
return sendTransaction({
|
|
11689
|
-
params: request.params || [],
|
|
11690
|
-
magicProvider: this.magicProvider,
|
|
11691
|
-
transactionAPI: this.transactionAPI,
|
|
11692
|
-
jsonRpcProvider: this.jsonRpcProvider,
|
|
11693
|
-
config: this.config,
|
|
11694
|
-
relayerClient: this.relayerClient,
|
|
11695
|
-
user: this.user,
|
|
11696
|
-
});
|
|
11697
|
-
}
|
|
11698
|
-
case 'eth_accounts': {
|
|
11699
|
-
return this.isLoggedIn() ? [this.user.zkEvm.ethAddress] : [];
|
|
11700
|
-
}
|
|
11701
|
-
// Pass through methods
|
|
11702
|
-
case 'eth_gasPrice':
|
|
11703
|
-
case 'eth_getBalance':
|
|
11704
|
-
case 'eth_getStorageAt':
|
|
11705
|
-
case 'eth_estimateGas':
|
|
11706
|
-
case 'eth_call':
|
|
11707
|
-
case 'eth_blockNumber':
|
|
11708
|
-
case 'eth_chainId':
|
|
11709
|
-
case 'eth_getBlockByHash':
|
|
11710
|
-
case 'eth_getBlockByNumber':
|
|
11711
|
-
case 'eth_getTransactionByHash':
|
|
11712
|
-
case 'eth_getTransactionReceipt':
|
|
11713
|
-
case 'eth_getTransactionCount': {
|
|
11714
|
-
return this.jsonRpcProvider.send(request.method, request.params || []);
|
|
11715
|
-
}
|
|
11716
|
-
default: {
|
|
11717
|
-
throw new JsonRpcError(exports.ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
|
|
11718
|
-
}
|
|
11719
|
-
}
|
|
11720
|
-
}
|
|
11721
|
-
async performJsonRpcRequest(request) {
|
|
11722
|
-
const { id, jsonrpc } = request;
|
|
11723
|
-
try {
|
|
11724
|
-
const result = await this.performRequest(request);
|
|
11725
|
-
return {
|
|
11726
|
-
id,
|
|
11727
|
-
jsonrpc,
|
|
11728
|
-
result,
|
|
11729
|
-
};
|
|
11730
|
-
}
|
|
11731
|
-
catch (error) {
|
|
11732
|
-
let jsonRpcError;
|
|
11733
|
-
if (error instanceof JsonRpcError) {
|
|
11734
|
-
jsonRpcError = error;
|
|
11735
|
-
}
|
|
11736
|
-
else if (error instanceof Error) {
|
|
11737
|
-
jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11738
|
-
}
|
|
11739
|
-
else {
|
|
11740
|
-
jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11741
|
-
}
|
|
11742
|
-
return {
|
|
11743
|
-
id,
|
|
11744
|
-
jsonrpc,
|
|
11745
|
-
error: jsonRpcError,
|
|
11746
|
-
};
|
|
11747
|
-
}
|
|
11748
|
-
}
|
|
11749
|
-
async request(request) {
|
|
11750
|
-
try {
|
|
11751
|
-
return this.performRequest(request);
|
|
11752
|
-
}
|
|
11753
|
-
catch (error) {
|
|
11754
|
-
if (error instanceof JsonRpcError) {
|
|
11755
|
-
throw error;
|
|
11756
|
-
}
|
|
11757
|
-
if (error instanceof Error) {
|
|
11758
|
-
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11759
|
-
}
|
|
11760
|
-
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11761
|
-
}
|
|
11762
|
-
}
|
|
11763
|
-
sendAsync(request, callback) {
|
|
11764
|
-
if (!callback) {
|
|
11765
|
-
throw new Error('No callback provided');
|
|
11766
|
-
}
|
|
11767
|
-
if (Array.isArray(request)) {
|
|
11768
|
-
Promise.all(request.map(this.performJsonRpcRequest)).then((result) => {
|
|
11769
|
-
callback(null, result);
|
|
11770
|
-
}).catch((error) => {
|
|
11771
|
-
callback(error, []);
|
|
11772
|
-
});
|
|
11773
|
-
}
|
|
11774
|
-
else {
|
|
11775
|
-
this.performJsonRpcRequest(request).then((result) => {
|
|
11776
|
-
callback(null, result);
|
|
11777
|
-
}).catch((error) => {
|
|
11778
|
-
callback(error, null);
|
|
11779
|
-
});
|
|
11780
|
-
}
|
|
11781
|
-
}
|
|
11782
|
-
async send(request, callbackOrParams, callback) {
|
|
11783
|
-
// Web3 >= 1.0.0-beta.38 calls `send` with method and parameters.
|
|
11784
|
-
if (typeof request === 'string') {
|
|
11785
|
-
if (typeof callbackOrParams === 'function') {
|
|
11786
|
-
return this.sendAsync({
|
|
11787
|
-
method: request,
|
|
11788
|
-
params: [],
|
|
11789
|
-
}, callbackOrParams);
|
|
11790
|
-
}
|
|
11791
|
-
if (callback) {
|
|
11792
|
-
return this.sendAsync({
|
|
11793
|
-
method: request,
|
|
11794
|
-
params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
|
|
11795
|
-
}, callback);
|
|
11796
|
-
}
|
|
11797
|
-
return this.request({
|
|
11798
|
-
method: request,
|
|
11799
|
-
params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
|
|
11800
|
-
});
|
|
11801
|
-
}
|
|
11802
|
-
// Web3 <= 1.0.0-beta.37 uses `send` with a callback for async queries.
|
|
11803
|
-
if (typeof callbackOrParams === 'function') {
|
|
11804
|
-
return this.sendAsync(request, callbackOrParams);
|
|
11805
|
-
}
|
|
11806
|
-
if (!Array.isArray(request) && typeof request === 'object') {
|
|
11807
|
-
return this.performJsonRpcRequest(request);
|
|
11808
|
-
}
|
|
11809
|
-
throw new JsonRpcError(exports.RpcErrorCode.INVALID_REQUEST, 'Invalid request');
|
|
11810
|
-
}
|
|
11811
|
-
on(event, listener) {
|
|
11812
|
-
this.eventEmitter.on(event, listener);
|
|
11813
|
-
}
|
|
11814
|
-
removeListener(event, listener) {
|
|
11815
|
-
this.eventEmitter.removeListener(event, listener);
|
|
11816
|
-
}
|
|
11817
|
-
}
|
|
11818
|
-
|
|
11819
11091
|
class Passport {
|
|
11820
11092
|
authManager;
|
|
11821
11093
|
config;
|
|
@@ -11823,7 +11095,6 @@ class Passport {
|
|
|
11823
11095
|
immutableXClient;
|
|
11824
11096
|
magicAdapter;
|
|
11825
11097
|
passportImxProviderFactory;
|
|
11826
|
-
multiRollupApiClients;
|
|
11827
11098
|
constructor(passportModuleConfiguration) {
|
|
11828
11099
|
this.config = new PassportConfiguration(passportModuleConfiguration);
|
|
11829
11100
|
this.authManager = new AuthManager(this.config);
|
|
@@ -11833,7 +11104,6 @@ class Passport {
|
|
|
11833
11104
|
|| new ImmutableXClient({
|
|
11834
11105
|
baseConfig: passportModuleConfiguration.baseConfig,
|
|
11835
11106
|
});
|
|
11836
|
-
this.multiRollupApiClients = new MultiRollupApiClients(this.config.multiRollupConfig);
|
|
11837
11107
|
this.passportImxProviderFactory = new PassportImxProviderFactory({
|
|
11838
11108
|
authManager: this.authManager,
|
|
11839
11109
|
config: this.config,
|
|
@@ -11863,29 +11133,12 @@ class Passport {
|
|
|
11863
11133
|
async connectImxWithCredentials(tokenResponse) {
|
|
11864
11134
|
return this.passportImxProviderFactory.getProviderWithCredentials(tokenResponse);
|
|
11865
11135
|
}
|
|
11866
|
-
// TODO ID-926 Make method public once development has been finalised
|
|
11867
|
-
connectEvm() {
|
|
11868
|
-
return new ZkEvmProvider({
|
|
11869
|
-
authManager: this.authManager,
|
|
11870
|
-
magicAdapter: this.magicAdapter,
|
|
11871
|
-
config: this.config,
|
|
11872
|
-
confirmationScreen: this.confirmationScreen,
|
|
11873
|
-
multiRollupApiClients: this.multiRollupApiClients,
|
|
11874
|
-
});
|
|
11875
|
-
}
|
|
11876
11136
|
async loginCallback() {
|
|
11877
11137
|
return this.authManager.loginCallback();
|
|
11878
11138
|
}
|
|
11879
11139
|
async logout() {
|
|
11880
11140
|
return this.authManager.logout();
|
|
11881
11141
|
}
|
|
11882
|
-
/**
|
|
11883
|
-
* This method should only be called from the logout redirect uri
|
|
11884
|
-
* when logout mode is 'silent'.
|
|
11885
|
-
*/
|
|
11886
|
-
async logoutSilentCallback(url) {
|
|
11887
|
-
return this.authManager.logoutSilentCallback(url);
|
|
11888
|
-
}
|
|
11889
11142
|
async logoutDeviceFlow() {
|
|
11890
11143
|
return this.authManager.logoutDeviceFlow();
|
|
11891
11144
|
}
|
|
@@ -12802,25 +12055,31 @@ class ImmutableApiClientFactory {
|
|
|
12802
12055
|
}
|
|
12803
12056
|
}
|
|
12804
12057
|
|
|
12058
|
+
const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
|
|
12805
12059
|
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
12806
12060
|
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
12807
|
-
function getOrderbookConfig(
|
|
12808
|
-
switch (
|
|
12809
|
-
case
|
|
12061
|
+
function getOrderbookConfig(chainName) {
|
|
12062
|
+
switch (chainName) {
|
|
12063
|
+
case DEVNET_CHAIN_NAME:
|
|
12064
|
+
return {
|
|
12065
|
+
seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
|
|
12066
|
+
zoneContractAddress: '0xCb5063b0c1dcF4f7fed8E7eaa79faf9859792767',
|
|
12067
|
+
apiEndpoint: 'https://order-book-mr.dev.imtbl.com',
|
|
12068
|
+
provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.dev.x.immutable.com'),
|
|
12069
|
+
};
|
|
12070
|
+
case TESTNET_CHAIN_NAME:
|
|
12810
12071
|
return {
|
|
12811
12072
|
seaportContractAddress: '0x45E23dA18804F99Cf67408AeBE85F67c958381Ff',
|
|
12812
12073
|
zoneContractAddress: '0x25b00b7eb97eab6194798E9B8eF63Aa526D5bd7E',
|
|
12813
12074
|
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
12814
|
-
chainName: TESTNET_CHAIN_NAME,
|
|
12815
12075
|
provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.sandbox.x.immutable.com'),
|
|
12816
12076
|
};
|
|
12817
|
-
|
|
12818
|
-
|
|
12077
|
+
case MAINNET_CHAIN_NAME:
|
|
12078
|
+
// not yet deployed
|
|
12819
12079
|
return {
|
|
12820
12080
|
seaportContractAddress: '',
|
|
12821
12081
|
zoneContractAddress: '',
|
|
12822
12082
|
apiEndpoint: 'https://order-book-mr.imtbl.com',
|
|
12823
|
-
chainName: MAINNET_CHAIN_NAME,
|
|
12824
12083
|
provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.x.immutable.com'),
|
|
12825
12084
|
};
|
|
12826
12085
|
default:
|
|
@@ -13779,19 +13038,21 @@ class Orderbook {
|
|
|
13779
13038
|
apiClient;
|
|
13780
13039
|
seaport;
|
|
13781
13040
|
orderbookConfig;
|
|
13782
|
-
constructor(config) {
|
|
13783
|
-
|
|
13784
|
-
const
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
}
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
}
|
|
13791
|
-
this.orderbookConfig = finalConfig;
|
|
13792
|
-
const { apiEndpoint, chainName } = this.orderbookConfig;
|
|
13041
|
+
constructor(config, localConfig) {
|
|
13042
|
+
// either use preconfigured config or local config passed in
|
|
13043
|
+
const maybeConfig = getOrderbookConfig(config.overrides?.chainName) || localConfig;
|
|
13044
|
+
if (!maybeConfig) {
|
|
13045
|
+
throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
|
|
13046
|
+
}
|
|
13047
|
+
this.orderbookConfig = maybeConfig;
|
|
13048
|
+
const { apiEndpoint } = this.orderbookConfig;
|
|
13793
13049
|
if (!apiEndpoint) {
|
|
13794
|
-
throw new Error('API endpoint must be provided');
|
|
13050
|
+
throw new Error('API endpoint must be provided as an override');
|
|
13051
|
+
}
|
|
13052
|
+
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
13053
|
+
const chainName = config.overrides?.chainName;
|
|
13054
|
+
if (!chainName) {
|
|
13055
|
+
throw new Error('chainName must be provided as an override');
|
|
13795
13056
|
}
|
|
13796
13057
|
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
13797
13058
|
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
@@ -25126,7 +24387,7 @@ const ETH_MAINNET_CHAIN_ID = 'eip155:1';
|
|
|
25126
24387
|
/**
|
|
25127
24388
|
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
25128
24389
|
*/
|
|
25129
|
-
const ZKEVM_DEVNET_CHAIN_ID = 'eip155:
|
|
24390
|
+
const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13403';
|
|
25130
24391
|
/**
|
|
25131
24392
|
/**
|
|
25132
24393
|
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
@@ -25184,8 +24445,8 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
|
|
|
25184
24445
|
*/
|
|
25185
24446
|
const CONTRACTS_FOR_BRIDGE = new Map()
|
|
25186
24447
|
.set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
|
|
25187
|
-
rootChainERC20Predicate: '
|
|
25188
|
-
rootChainStateSender: '
|
|
24448
|
+
rootChainERC20Predicate: '0x15Dd735de418B6d290727aed82cC25F8966dE4A5',
|
|
24449
|
+
rootChainStateSender: '0xb3Bac13799dAca9D9eC9307303a65fA1218b4724',
|
|
25189
24450
|
childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
|
|
25190
24451
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
25191
24452
|
})
|
|
@@ -27422,28 +26683,16 @@ const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
|
|
|
27422
26683
|
[exports.Environment.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
|
|
27423
26684
|
};
|
|
27424
26685
|
function validateOverrides(overrides) {
|
|
27425
|
-
|
|
27426
|
-
|
|
27427
|
-
if (!overrides[key]) {
|
|
26686
|
+
Object.entries(overrides).forEach(([key, value]) => {
|
|
26687
|
+
if (!value) {
|
|
27428
26688
|
throw new InvalidConfigurationError(`Missing override: ${key}`);
|
|
27429
26689
|
}
|
|
27430
|
-
}
|
|
26690
|
+
});
|
|
27431
26691
|
Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
|
|
27432
26692
|
if (!isValidNonZeroAddress(contract)) {
|
|
27433
26693
|
throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
|
|
27434
26694
|
}
|
|
27435
26695
|
});
|
|
27436
|
-
if (!overrides.secondaryFees) {
|
|
27437
|
-
return;
|
|
27438
|
-
}
|
|
27439
|
-
for (const secondaryFee of overrides.secondaryFees) {
|
|
27440
|
-
if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
|
|
27441
|
-
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
|
|
27442
|
-
}
|
|
27443
|
-
if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > 10000) {
|
|
27444
|
-
throw new InvalidConfigurationError(`Invalid secondary fee percentage: ${secondaryFee.feeBasisPoints}`);
|
|
27445
|
-
}
|
|
27446
|
-
}
|
|
27447
26696
|
}
|
|
27448
26697
|
/**
|
|
27449
26698
|
* {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
|
|
@@ -27453,7 +26702,6 @@ function validateOverrides(overrides) {
|
|
|
27453
26702
|
class ExchangeConfiguration {
|
|
27454
26703
|
baseConfig;
|
|
27455
26704
|
chain;
|
|
27456
|
-
secondaryFees;
|
|
27457
26705
|
constructor({ chainId, baseConfig, overrides }) {
|
|
27458
26706
|
this.baseConfig = baseConfig;
|
|
27459
26707
|
if (overrides) {
|
|
@@ -27465,10 +26713,8 @@ class ExchangeConfiguration {
|
|
|
27465
26713
|
commonRoutingTokens: overrides.commonRoutingTokens,
|
|
27466
26714
|
nativeToken: overrides.nativeToken,
|
|
27467
26715
|
};
|
|
27468
|
-
this.secondaryFees = overrides.secondaryFees ? overrides.secondaryFees : [];
|
|
27469
26716
|
return;
|
|
27470
26717
|
}
|
|
27471
|
-
this.secondaryFees = [];
|
|
27472
26718
|
const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
|
|
27473
26719
|
if (!chain) {
|
|
27474
26720
|
throw new ChainNotSupportedError(chainId, baseConfig.environment);
|
|
@@ -27482,13 +26728,11 @@ class Exchange {
|
|
|
27482
26728
|
router;
|
|
27483
26729
|
chainId;
|
|
27484
26730
|
nativeToken;
|
|
27485
|
-
secondaryFees;
|
|
27486
26731
|
constructor(configuration) {
|
|
27487
26732
|
const config = new ExchangeConfiguration(configuration);
|
|
27488
26733
|
this.chainId = config.chain.chainId;
|
|
27489
26734
|
this.nativeToken = config.chain.nativeToken;
|
|
27490
26735
|
this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
|
|
27491
|
-
this.secondaryFees = config.secondaryFees;
|
|
27492
26736
|
this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
|
|
27493
26737
|
multicallAddress: config.chain.contracts.multicall,
|
|
27494
26738
|
factoryAddress: config.chain.contracts.coreFactory,
|
|
@@ -27571,9 +26815,6 @@ class Exchange {
|
|
|
27571
26815
|
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
|
|
27572
26816
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, sdkCore.TradeType.EXACT_OUTPUT);
|
|
27573
26817
|
}
|
|
27574
|
-
thereAreSecondaryFees() {
|
|
27575
|
-
return this.secondaryFees.length > 0;
|
|
27576
|
-
}
|
|
27577
26818
|
}
|
|
27578
26819
|
|
|
27579
26820
|
/* eslint-disable class-methods-use-this */
|
|
@@ -27650,8 +26891,8 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
|
27650
26891
|
*/ exports.ChainId = void 0;
|
|
27651
26892
|
(function(ChainId) {
|
|
27652
26893
|
ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
|
|
27653
|
-
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] =
|
|
27654
|
-
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] =
|
|
26894
|
+
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13392] = "IMTBL_ZKEVM_TESTNET";
|
|
26895
|
+
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13403] = "IMTBL_ZKEVM_DEVNET";
|
|
27655
26896
|
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
27656
26897
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
27657
26898
|
})(exports.ChainId || (exports.ChainId = {}));
|
|
@@ -27736,10 +26977,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
|
27736
26977
|
[(exports.Environment).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
27737
26978
|
[(exports.Environment).PRODUCTION]: "https://checkout-api.immutable.com"
|
|
27738
26979
|
};
|
|
27739
|
-
const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
|
|
27740
|
-
[(exports.Environment).SANDBOX]: "https://zkevm-rpc.sandbox.x.immutable.com",
|
|
27741
|
-
[(exports.Environment).PRODUCTION]: "https://zkevm-rpc.x.immutable.com"
|
|
27742
|
-
};
|
|
27743
26980
|
const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
27744
26981
|
[
|
|
27745
26982
|
(exports.ChainId).ETHEREUM,
|
|
@@ -27765,7 +27002,7 @@ const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
|
27765
27002
|
chainIdHex: `0x${(exports.ChainId).IMTBL_ZKEVM_MAINNET.toString(16)}`,
|
|
27766
27003
|
chainName: (exports.ChainName).IMTBL_ZKEVM_MAINNET,
|
|
27767
27004
|
rpcUrls: [
|
|
27768
|
-
"https://rpc.immutable.com"
|
|
27005
|
+
"https://zkevm-rpc.x.immutable.com"
|
|
27769
27006
|
],
|
|
27770
27007
|
nativeCurrency: {
|
|
27771
27008
|
name: "IMX",
|
|
@@ -27800,7 +27037,7 @@ const $d85ad1457a3f1a83$export$3e81fc0987227f10 = new Map([
|
|
|
27800
27037
|
chainIdHex: `0x${(exports.ChainId).IMTBL_ZKEVM_TESTNET.toString(16)}`,
|
|
27801
27038
|
chainName: (exports.ChainName).IMTBL_ZKEVM_TESTNET,
|
|
27802
27039
|
rpcUrls: [
|
|
27803
|
-
"https://rpc.
|
|
27040
|
+
"https://zkevm-rpc.sandbox.x.immutable.com"
|
|
27804
27041
|
],
|
|
27805
27042
|
nativeCurrency: {
|
|
27806
27043
|
name: "IMX",
|
|
@@ -28176,19 +27413,16 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
|
|
|
28176
27413
|
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", (exports.CheckoutErrorType).METAMASK_PROVIDER_ERROR);
|
|
28177
27414
|
return new (providers.Web3Provider)(provider);
|
|
28178
27415
|
}
|
|
28179
|
-
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(
|
|
28180
|
-
let
|
|
28181
|
-
switch(
|
|
27416
|
+
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
|
|
27417
|
+
let web3Provider = null;
|
|
27418
|
+
switch(defaultProvider){
|
|
28182
27419
|
case (exports.WalletProviderName).METAMASK:
|
|
28183
|
-
|
|
27420
|
+
web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
|
|
28184
27421
|
break;
|
|
28185
27422
|
default:
|
|
28186
27423
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", (exports.CheckoutErrorType).DEFAULT_PROVIDER_ERROR);
|
|
28187
27424
|
}
|
|
28188
|
-
return
|
|
28189
|
-
provider: provider,
|
|
28190
|
-
walletProviderName: walletProviderName
|
|
28191
|
-
};
|
|
27425
|
+
return web3Provider;
|
|
28192
27426
|
}
|
|
28193
27427
|
|
|
28194
27428
|
|
|
@@ -28197,8 +27431,9 @@ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
|
|
|
28197
27431
|
|
|
28198
27432
|
|
|
28199
27433
|
|
|
27434
|
+
|
|
28200
27435
|
function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
|
|
28201
|
-
if (web3Provider && web3Provider.
|
|
27436
|
+
if (web3Provider && web3Provider instanceof (providers.Web3Provider) && web3Provider.provider?.request) return true;
|
|
28202
27437
|
return false;
|
|
28203
27438
|
}
|
|
28204
27439
|
async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
|
|
@@ -28408,23 +27643,10 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
|
|
|
28408
27643
|
this.message = message;
|
|
28409
27644
|
}
|
|
28410
27645
|
}
|
|
28411
|
-
const $4013c5c91bb535f6$var$networkMap = (prod, dev
|
|
28412
|
-
|
|
28413
|
-
if (
|
|
28414
|
-
|
|
28415
|
-
networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
|
|
28416
|
-
if (local) {
|
|
28417
|
-
const rpcUrls = networks.get((exports.ChainId).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
|
|
28418
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(exports.Environment).PRODUCTION]);
|
|
28419
|
-
}
|
|
28420
|
-
} else {
|
|
28421
|
-
networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
|
|
28422
|
-
if (local) {
|
|
28423
|
-
const rpcUrls = networks.get((exports.ChainId).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
|
|
28424
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(exports.Environment).SANDBOX]);
|
|
28425
|
-
}
|
|
28426
|
-
}
|
|
28427
|
-
return networks;
|
|
27646
|
+
const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
|
|
27647
|
+
if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
|
|
27648
|
+
if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
|
|
27649
|
+
return $d85ad1457a3f1a83$export$3e81fc0987227f10;
|
|
28428
27650
|
};
|
|
28429
27651
|
const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
|
|
28430
27652
|
// DevMode and Sandbox will both use Sepolia.
|
|
@@ -28442,11 +27664,6 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
28442
27664
|
// This will be used to get around the lack of
|
|
28443
27665
|
// Environment.DEVELOPMENT
|
|
28444
27666
|
isDevelopment = false;
|
|
28445
|
-
// This is a hidden feature that is only available
|
|
28446
|
-
// when building the project from source code.
|
|
28447
|
-
// This will be used to get around the lack of
|
|
28448
|
-
// Environment.LOCAL_DEVELOPMENT
|
|
28449
|
-
isLocal = false;
|
|
28450
27667
|
isProduction;
|
|
28451
27668
|
remote;
|
|
28452
27669
|
environment;
|
|
@@ -28456,7 +27673,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
28456
27673
|
this.environment = config.baseConfig.environment;
|
|
28457
27674
|
// Developer mode will super set any environment configuration
|
|
28458
27675
|
this.isProduction = !this.isDevelopment && this.environment === (exports.Environment).PRODUCTION;
|
|
28459
|
-
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment
|
|
27676
|
+
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
|
|
28460
27677
|
this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
|
|
28461
27678
|
isDevelopment: this.isDevelopment,
|
|
28462
27679
|
isProduction: this.isProduction
|
|
@@ -28602,7 +27819,10 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28602
27819
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
28603
27820
|
* @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
|
|
28604
27821
|
*/ async createProvider(params) {
|
|
28605
|
-
|
|
27822
|
+
const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
|
|
27823
|
+
return {
|
|
27824
|
+
provider: web3Provider
|
|
27825
|
+
};
|
|
28606
27826
|
}
|
|
28607
27827
|
/**
|
|
28608
27828
|
* Checks if a wallet is connected to the specified provider.
|
|
@@ -28719,7 +27939,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28719
27939
|
function $parcel$export(e, n, v, s) {
|
|
28720
27940
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28721
27941
|
}
|
|
28722
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha";
|
|
27942
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha.1";
|
|
28723
27943
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28724
27944
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28725
27945
|
|
|
@@ -30538,7 +29758,6 @@ exports.ERC721PermissionedMintable = ERC721PermissionedMintable;
|
|
|
30538
29758
|
exports.GenericIMXProvider = GenericIMXProvider;
|
|
30539
29759
|
exports.ImmutableConfiguration = ImmutableConfiguration;
|
|
30540
29760
|
exports.ImmutableXClient = ImmutableXClient;
|
|
30541
|
-
exports.JsonRpcError = JsonRpcError;
|
|
30542
29761
|
exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
|
|
30543
29762
|
exports.Orderbook = Orderbook;
|
|
30544
29763
|
exports.Passport = Passport;
|