@imtbl/sdk 0.3.0-alpha.3 → 0.3.1-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/index.js CHANGED
@@ -8,10 +8,10 @@ import { OpenIdExtension } from '@magic-ext/oidc';
8
8
  import BN$2 from 'bn.js';
9
9
  import * as encUtils from 'enc-utils';
10
10
  import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
11
+ import { EventEmitter } from 'events';
11
12
  import { ethers, BigNumber as BigNumber$1, providers, constants, utils as utils$2, Contract as Contract$1, ContractFactory } from 'ethers';
12
13
  import { walletContracts } from '@0xsequence/abi';
13
14
  import { encodeSignature } from '@0xsequence/config';
14
- import { EventEmitter } from 'events';
15
15
  import FormData$2 from 'form-data';
16
16
  import { Seaport as Seaport$1 } from '@opensea/seaport-js';
17
17
  import { parseUnits } from '@ethersproject/units';
@@ -5531,7 +5531,7 @@ class MultiRollupApiClients {
5531
5531
  }
5532
5532
 
5533
5533
  // eslint-disable-next-line @typescript-eslint/naming-convention
5534
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.3.0-alpha.3' };
5534
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.3.1-alpha' };
5535
5535
  const createConfig = ({ basePath, headers, }) => {
5536
5536
  if (!basePath.trim()) {
5537
5537
  throw Error('basePath can not be empty');
@@ -5591,7 +5591,7 @@ class APIError extends Error {
5591
5591
 
5592
5592
  /* eslint-disable implicit-arrow-linebreak */
5593
5593
  const defaultHeaders = {
5594
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.3.0-alpha.3',
5594
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.3.1-alpha',
5595
5595
  };
5596
5596
  /**
5597
5597
  * createAPIConfiguration to create a custom Configuration
@@ -5857,7 +5857,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
5857
5857
  chainID,
5858
5858
  coreContractAddress,
5859
5859
  registrationContractAddress,
5860
- sdkVersion: 'ts-immutable-sdk-0.3.0-alpha.3',
5860
+ sdkVersion: 'ts-immutable-sdk-0.3.1-alpha',
5861
5861
  });
5862
5862
  /**
5863
5863
  * Sets `sdkVersion` at the time of build
@@ -9581,6 +9581,8 @@ var globalAxios = axios;
9581
9581
  * https://openapi-generator.tech
9582
9582
  * Do not edit the class manually.
9583
9583
  */
9584
+ // Some imports not used depending on template conditions
9585
+ // @ts-ignore
9584
9586
  const BASE_PATH = "https://guardian.sandbox.imtbl.com".replace(/\/+$/, "");
9585
9587
  /**
9586
9588
  *
@@ -9608,10 +9610,10 @@ class BaseAPI {
9608
9610
  */
9609
9611
  class RequiredError extends Error {
9610
9612
  field;
9613
+ name = "RequiredError";
9611
9614
  constructor(field, msg) {
9612
9615
  super(msg);
9613
9616
  this.field = field;
9614
- this.name = "RequiredError";
9615
9617
  }
9616
9618
  }
9617
9619
 
@@ -9656,8 +9658,6 @@ const setBearerAuthToObject = async function (object, configuration) {
9656
9658
  }
9657
9659
  };
9658
9660
  function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
9659
- if (parameter == null)
9660
- return;
9661
9661
  if (typeof parameter === "object") {
9662
9662
  if (Array.isArray(parameter)) {
9663
9663
  parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
@@ -9813,7 +9813,7 @@ const TransactionsApiAxiosParamCreator = function (configuration) {
9813
9813
  * @summary Info for a specific transaction
9814
9814
  * @param {string} transactionID The id of the starkex transaction to retrieve
9815
9815
  * @param {'starkex' | 'evm'} chainType roll up type
9816
- * @param {number} [chainID] ID of evm chain
9816
+ * @param {string} [chainID] ID of evm chain
9817
9817
  * @param {*} [options] Override http request option.
9818
9818
  * @throws {RequiredError}
9819
9819
  */
@@ -9888,7 +9888,7 @@ const TransactionsApiFp = function (configuration) {
9888
9888
  * @summary Info for a specific transaction
9889
9889
  * @param {string} transactionID The id of the starkex transaction to retrieve
9890
9890
  * @param {'starkex' | 'evm'} chainType roll up type
9891
- * @param {number} [chainID] ID of evm chain
9891
+ * @param {string} [chainID] ID of evm chain
9892
9892
  * @param {*} [options] Override http request option.
9893
9893
  * @throws {RequiredError}
9894
9894
  */
@@ -10575,6 +10575,7 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
10575
10575
  amount_sell: amountSell,
10576
10576
  token_sell: convertToSignableToken(request.sell),
10577
10577
  fees: request.fees,
10578
+ split_fees: true,
10578
10579
  expiration_timestamp: request.expiration_timestamp,
10579
10580
  };
10580
10581
  const getSignableOrderResponse = await ordersApi.getSignableOrder({
@@ -11088,7 +11089,7 @@ class PassportConfiguration {
11088
11089
  this.imxPublicApiDomain = 'https://api.immutable.com';
11089
11090
  this.zkEvmRpcUrl = ''; // TODO: ID-785 Update once mainnet has been deployed
11090
11091
  this.zkEvmChainId = ''; // TODO: ID-785 Update once mainnet has been deployed
11091
- this.relayerUrl = 'https://relayer.immutable.com'; // TODO: ID-784 Update once we have added Relayer URL to config
11092
+ this.relayerUrl = 'https://api.immutable.com/relayer-mr';
11092
11093
  this.multiRollupConfig = multiRollupConfig.getProduction();
11093
11094
  break;
11094
11095
  }
@@ -11102,7 +11103,7 @@ class PassportConfiguration {
11102
11103
  this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
11103
11104
  this.zkEvmRpcUrl = 'https://zkevm-rpc.sandbox.x.immutable.com';
11104
11105
  this.zkEvmChainId = 'eip155:13392';
11105
- this.relayerUrl = 'https://evm-relayer.sandbox.imtbl.com'; // TODO: ID-784 Update once we have added Relayer URL to config
11106
+ this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
11106
11107
  this.multiRollupConfig = multiRollupConfig.getSandbox();
11107
11108
  break;
11108
11109
  }
@@ -11264,6 +11265,169 @@ class ConfirmationScreen {
11264
11265
  }
11265
11266
  }
11266
11267
 
11268
+ var RelayerTransactionStatus;
11269
+ (function (RelayerTransactionStatus) {
11270
+ RelayerTransactionStatus["PENDING"] = "PENDING";
11271
+ RelayerTransactionStatus["SUBMITTED"] = "SUBMITTED";
11272
+ RelayerTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
11273
+ RelayerTransactionStatus["REVERTED"] = "REVERTED";
11274
+ RelayerTransactionStatus["FAILED"] = "FAILED";
11275
+ })(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
11276
+ var ProviderEvent;
11277
+ (function (ProviderEvent) {
11278
+ ProviderEvent["ACCOUNTS_CHANGED"] = "accountsChanged";
11279
+ })(ProviderEvent || (ProviderEvent = {}));
11280
+
11281
+ class TypedEventEmitter {
11282
+ emitter = new EventEmitter();
11283
+ emit(eventName, ...eventArg) {
11284
+ this.emitter.emit(eventName, ...eventArg);
11285
+ }
11286
+ on(eventName, handler) {
11287
+ this.emitter.on(eventName, handler);
11288
+ }
11289
+ removeListener(eventName, handler) {
11290
+ this.emitter.removeListener(eventName, handler);
11291
+ }
11292
+ }
11293
+
11294
+ class RelayerClient {
11295
+ config;
11296
+ constructor({ config }) {
11297
+ this.config = config;
11298
+ }
11299
+ async postToRelayer(request) {
11300
+ const body = {
11301
+ id: 1,
11302
+ jsonrpc: '2.0',
11303
+ ...request,
11304
+ };
11305
+ const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
11306
+ method: 'POST',
11307
+ headers: {
11308
+ 'Content-Type': 'application/json',
11309
+ },
11310
+ body: JSON.stringify(body),
11311
+ });
11312
+ const jsonResponse = await response.json();
11313
+ if (jsonResponse.error) {
11314
+ throw jsonResponse.error;
11315
+ }
11316
+ return jsonResponse;
11317
+ }
11318
+ async ethSendTransaction(to, data) {
11319
+ const payload = {
11320
+ method: 'eth_sendTransaction',
11321
+ params: [{
11322
+ to,
11323
+ data,
11324
+ chainId: this.config.zkEvmChainId.toString(),
11325
+ }],
11326
+ };
11327
+ const { result } = await this.postToRelayer(payload);
11328
+ return result;
11329
+ }
11330
+ async imGetTransactionByHash(hash) {
11331
+ const payload = {
11332
+ method: 'im_getTransactionByHash',
11333
+ params: [hash],
11334
+ };
11335
+ const { result } = await this.postToRelayer(payload);
11336
+ return result;
11337
+ }
11338
+ async imGetFeeOptions(userAddress, data) {
11339
+ const payload = {
11340
+ method: 'im_getFeeOptions',
11341
+ params: [{
11342
+ userAddress,
11343
+ data,
11344
+ chainId: this.config.zkEvmChainId.toString(),
11345
+ }],
11346
+ };
11347
+ const { result } = await this.postToRelayer(payload);
11348
+ return result;
11349
+ }
11350
+ }
11351
+
11352
+ /**
11353
+ * ProviderErrors should take priority over RpcErrorCodes
11354
+ */
11355
+ var ProviderErrorCode;
11356
+ (function (ProviderErrorCode) {
11357
+ ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
11358
+ ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
11359
+ ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
11360
+ ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
11361
+ })(ProviderErrorCode || (ProviderErrorCode = {}));
11362
+ var RpcErrorCode;
11363
+ (function (RpcErrorCode) {
11364
+ RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
11365
+ RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
11366
+ RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
11367
+ RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
11368
+ RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
11369
+ RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
11370
+ })(RpcErrorCode || (RpcErrorCode = {}));
11371
+ class JsonRpcError extends Error {
11372
+ message;
11373
+ code;
11374
+ constructor(code, message) {
11375
+ super(message);
11376
+ this.message = message;
11377
+ this.code = code;
11378
+ }
11379
+ }
11380
+
11381
+ const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
11382
+ async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
11383
+ const web3Provider = new Web3Provider(magicProvider);
11384
+ const ethSigner = web3Provider.getSigner();
11385
+ const ethereumAddress = await ethSigner.getAddress();
11386
+ const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
11387
+ const headers = { Authorization: `Bearer ${accessToken}` };
11388
+ try {
11389
+ await multiRollupApiClients.passportApi.createCounterfactualAddress({
11390
+ createCounterfactualAddressRequest: {
11391
+ ethereumAddress,
11392
+ ethereumSignature,
11393
+ },
11394
+ }, { headers });
11395
+ }
11396
+ catch (error) {
11397
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
11398
+ }
11399
+ const user = await authManager.loginSilent();
11400
+ if (!user?.zkEvm) {
11401
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
11402
+ }
11403
+ return user;
11404
+ }
11405
+
11406
+ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
11407
+ const user = await authManager.getUser() || await authManager.login();
11408
+ if (!user.idToken) {
11409
+ throw new Error('User is missing idToken');
11410
+ }
11411
+ const magicProvider = await magicAdapter.login(user.idToken, config.network);
11412
+ if (!user.zkEvm) {
11413
+ // Generate counterfactual address and retrieve updated Auth0 user
11414
+ const userZkevm = await registerZkEvmUser({
11415
+ authManager,
11416
+ magicProvider,
11417
+ multiRollupApiClients,
11418
+ accessToken: user.accessToken,
11419
+ });
11420
+ return {
11421
+ user: userZkevm,
11422
+ magicProvider,
11423
+ };
11424
+ }
11425
+ return {
11426
+ user: user,
11427
+ magicProvider,
11428
+ };
11429
+ };
11430
+
11267
11431
  // These are ignored by the Relayer but for consistency we set them to the
11268
11432
  // appropriate values for a 1/1 wallet.
11269
11433
  //
@@ -11339,51 +11503,48 @@ const chainIdNumber = (chainId) => {
11339
11503
  return BigNumber$1.from(caip2Components[1]);
11340
11504
  };
11341
11505
 
11342
- var RelayerTransactionStatus;
11343
- (function (RelayerTransactionStatus) {
11344
- RelayerTransactionStatus["PENDING"] = "PENDING";
11345
- RelayerTransactionStatus["SUBMITTED"] = "SUBMITTED";
11346
- RelayerTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
11347
- RelayerTransactionStatus["REVERTED"] = "REVERTED";
11348
- RelayerTransactionStatus["FAILED"] = "FAILED";
11349
- })(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
11350
- var ProviderEventNames;
11351
- (function (ProviderEventNames) {
11352
- ProviderEventNames["ACCOUNTS_CHANGED"] = "accountsChanged";
11353
- })(ProviderEventNames || (ProviderEventNames = {}));
11354
-
11355
- /**
11356
- * ProviderErrors should take priority over RpcErrorCodes
11357
- */
11358
- var ProviderErrorCode;
11359
- (function (ProviderErrorCode) {
11360
- ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
11361
- ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
11362
- ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
11363
- ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
11364
- })(ProviderErrorCode || (ProviderErrorCode = {}));
11365
- var RpcErrorCode;
11366
- (function (RpcErrorCode) {
11367
- RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
11368
- RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
11369
- RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
11370
- RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
11371
- RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
11372
- RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
11373
- })(RpcErrorCode || (RpcErrorCode = {}));
11374
- class JsonRpcError extends Error {
11375
- message;
11376
- code;
11377
- constructor(code, message) {
11378
- super(message);
11379
- this.message = message;
11380
- this.code = code;
11381
- }
11382
- }
11383
-
11384
11506
  const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
11385
11507
  const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
11386
- const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, config, user, }) => {
11508
+ const converBigNumberishToNumber = (value) => BigNumber$1.from(value).toNumber();
11509
+ const transformGardianTransactions = (txs) => {
11510
+ try {
11511
+ return txs.map((t) => ({
11512
+ delegateCall: t.delegateCall === true,
11513
+ revertOnError: t.revertOnError === true,
11514
+ gasLimit: t.gasLimit ? converBigNumberishToNumber(t.gasLimit).toString() : '0',
11515
+ target: t.to ?? ethers.constants.AddressZero,
11516
+ value: t.value ? converBigNumberishToNumber(t.value).toString() : '0',
11517
+ data: t.data ? t.data.toString() : '0x00',
11518
+ }));
11519
+ }
11520
+ catch (error) {
11521
+ const errorMessage = (error instanceof Error) ? error.message : String(error);
11522
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Transaction failed to parsing: ${errorMessage}`);
11523
+ }
11524
+ };
11525
+ const guardianValidation = async ({ transactionAPI, chainId, nonce, user, metaTransactions, }) => {
11526
+ const headers = { Authorization: `Bearer ${user.accessToken}` };
11527
+ const guardianTransactions = transformGardianTransactions(metaTransactions);
11528
+ try {
11529
+ await transactionAPI.evaluateTransaction({
11530
+ id: 'evm',
11531
+ transactionEvaluationRequest: {
11532
+ chainType: 'evm',
11533
+ chainId,
11534
+ transactionData: {
11535
+ nonce,
11536
+ userAddress: user.zkEvm.ethAddress,
11537
+ metaTransactions: guardianTransactions,
11538
+ },
11539
+ },
11540
+ }, { headers });
11541
+ }
11542
+ catch (error) {
11543
+ const errorMessage = (error instanceof Error) ? error.message : String(error);
11544
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
11545
+ }
11546
+ };
11547
+ const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, transactionAPI, config, user, }) => {
11387
11548
  const transactionRequest = params[0];
11388
11549
  if (!transactionRequest.to) {
11389
11550
  throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
@@ -11421,6 +11582,13 @@ const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayer
11421
11582
  value: imxFeeOption.tokenPrice,
11422
11583
  revertOnError: true,
11423
11584
  };
11585
+ await guardianValidation({
11586
+ transactionAPI,
11587
+ chainId: config.zkEvmChainId,
11588
+ nonce: converBigNumberishToNumber(nonce),
11589
+ user,
11590
+ metaTransactions: [metaTransaction, feeMetaTransaction],
11591
+ });
11424
11592
  // NOTE: We sign again because we now are adding the fee transaction, so the
11425
11593
  // whole payload is different and needs a new signature.
11426
11594
  const signedTransactions = await getSignedMetaTransactions([metaTransaction, feeMetaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
@@ -11448,146 +11616,30 @@ const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayer
11448
11616
  return relayerTransaction.hash;
11449
11617
  };
11450
11618
 
11451
- class TypedEventEmitter {
11452
- emitter = new EventEmitter();
11453
- emit(eventName, ...eventArg) {
11454
- this.emitter.emit(eventName, ...eventArg);
11455
- }
11456
- on(eventName, handler) {
11457
- this.emitter.on(eventName, handler);
11458
- }
11459
- removeListener(eventName, handler) {
11460
- this.emitter.removeListener(eventName, handler);
11461
- }
11462
- }
11463
-
11464
- class RelayerClient {
11465
- config;
11466
- constructor({ config }) {
11467
- this.config = config;
11468
- }
11469
- async postToRelayer(request) {
11470
- const body = {
11471
- id: 1,
11472
- jsonrpc: '2.0',
11473
- ...request,
11474
- };
11475
- const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
11476
- method: 'POST',
11477
- headers: {
11478
- 'Content-Type': 'application/json',
11479
- },
11480
- body: JSON.stringify(body),
11481
- });
11482
- const jsonResponse = await response.json();
11483
- if (jsonResponse.error) {
11484
- throw jsonResponse.error;
11485
- }
11486
- return jsonResponse;
11487
- }
11488
- async ethSendTransaction(to, data) {
11489
- const payload = {
11490
- method: 'eth_sendTransaction',
11491
- params: [{
11492
- to,
11493
- data,
11494
- chainId: this.config.zkEvmChainId.toString(),
11495
- }],
11496
- };
11497
- const { result } = await this.postToRelayer(payload);
11498
- return result;
11499
- }
11500
- async imGetTransactionByHash(hash) {
11501
- const payload = {
11502
- method: 'im_getTransactionByHash',
11503
- params: [hash],
11504
- };
11505
- const { result } = await this.postToRelayer(payload);
11506
- return result;
11507
- }
11508
- async imGetFeeOptions(userAddress, data) {
11509
- const payload = {
11510
- method: 'im_getFeeOptions',
11511
- params: [{
11512
- userAddress,
11513
- data,
11514
- chainId: this.config.zkEvmChainId.toString(),
11515
- }],
11516
- };
11517
- const { result } = await this.postToRelayer(payload);
11518
- return result;
11519
- }
11520
- }
11521
-
11522
- const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
11523
- async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
11524
- const web3Provider = new Web3Provider(magicProvider);
11525
- const ethSigner = web3Provider.getSigner();
11526
- const ethereumAddress = await ethSigner.getAddress();
11527
- const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
11528
- const headers = { Authorization: `Bearer ${accessToken}` };
11529
- try {
11530
- await multiRollupApiClients.passportApi.createCounterfactualAddress({
11531
- createCounterfactualAddressRequest: {
11532
- ethereumAddress,
11533
- ethereumSignature,
11534
- },
11535
- }, { headers });
11536
- }
11537
- catch (error) {
11538
- throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
11539
- }
11540
- const user = await authManager.loginSilent();
11541
- if (!user?.zkEvm) {
11542
- throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
11543
- }
11544
- return user;
11545
- }
11546
-
11547
- const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
11548
- const user = await authManager.getUser() || await authManager.login();
11549
- if (!user.idToken) {
11550
- throw new Error('User is missing idToken');
11551
- }
11552
- const magicProvider = await magicAdapter.login(user.idToken, config.network);
11553
- if (!user.zkEvm) {
11554
- // Generate counterfactual address and retrieve updated Auth0 user
11555
- const userZkevm = await registerZkEvmUser({
11556
- authManager,
11557
- magicProvider,
11558
- multiRollupApiClients,
11559
- accessToken: user.accessToken,
11560
- });
11561
- return {
11562
- user: userZkevm,
11563
- magicProvider,
11564
- };
11565
- }
11566
- return {
11567
- user: user,
11568
- magicProvider,
11569
- };
11570
- };
11571
-
11572
- class ZkEvmProvider extends TypedEventEmitter {
11619
+ class ZkEvmProvider {
11573
11620
  authManager;
11574
11621
  config;
11575
11622
  confirmationScreen;
11576
11623
  magicAdapter;
11577
11624
  relayerClient;
11625
+ transactionAPI;
11578
11626
  multiRollupApiClients;
11579
- jsonRpcProvider; // Used for read operations
11627
+ jsonRpcProvider; // Used for read
11628
+ eventEmitter;
11580
11629
  magicProvider; // Used for signing
11581
11630
  user;
11582
11631
  constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, }) {
11583
- super();
11584
11632
  this.authManager = authManager;
11585
11633
  this.magicAdapter = magicAdapter;
11586
11634
  this.config = config;
11587
11635
  this.confirmationScreen = confirmationScreen;
11588
11636
  this.relayerClient = new RelayerClient({ config });
11637
+ this.transactionAPI = new TransactionsApi(new Configuration({
11638
+ basePath: this.config.imxPublicApiDomain,
11639
+ }));
11589
11640
  this.jsonRpcProvider = new JsonRpcProvider(this.config.zkEvmRpcUrl);
11590
11641
  this.multiRollupApiClients = multiRollupApiClients;
11642
+ this.eventEmitter = new TypedEventEmitter();
11591
11643
  }
11592
11644
  isLoggedIn() {
11593
11645
  return this.magicProvider !== undefined && this.user !== undefined;
@@ -11606,7 +11658,7 @@ class ZkEvmProvider extends TypedEventEmitter {
11606
11658
  });
11607
11659
  this.user = user;
11608
11660
  this.magicProvider = magicProvider;
11609
- this.emit(ProviderEventNames.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
11661
+ this.eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
11610
11662
  return [this.user.zkEvm.ethAddress];
11611
11663
  }
11612
11664
  case 'eth_sendTransaction': {
@@ -11616,6 +11668,7 @@ class ZkEvmProvider extends TypedEventEmitter {
11616
11668
  return sendTransaction({
11617
11669
  params: request.params || [],
11618
11670
  magicProvider: this.magicProvider,
11671
+ transactionAPI: this.transactionAPI,
11619
11672
  jsonRpcProvider: this.jsonRpcProvider,
11620
11673
  config: this.config,
11621
11674
  relayerClient: this.relayerClient,
@@ -11735,6 +11788,12 @@ class ZkEvmProvider extends TypedEventEmitter {
11735
11788
  }
11736
11789
  throw new JsonRpcError(RpcErrorCode.INVALID_REQUEST, 'Invalid request');
11737
11790
  }
11791
+ on(event, listener) {
11792
+ this.eventEmitter.on(event, listener);
11793
+ }
11794
+ removeListener(event, listener) {
11795
+ this.eventEmitter.removeListener(event, listener);
11796
+ }
11738
11797
  }
11739
11798
 
11740
11799
  class Passport {
@@ -25047,7 +25106,7 @@ const ETH_MAINNET_CHAIN_ID = 'eip155:1';
25047
25106
  /**
25048
25107
  * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
25049
25108
  */
25050
- const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13403';
25109
+ const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13423';
25051
25110
  /**
25052
25111
  /**
25053
25112
  * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
@@ -25105,8 +25164,8 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
25105
25164
  */
25106
25165
  const CONTRACTS_FOR_BRIDGE = new Map()
25107
25166
  .set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
25108
- rootChainERC20Predicate: '0x15Dd735de418B6d290727aed82cC25F8966dE4A5',
25109
- rootChainStateSender: '0xb3Bac13799dAca9D9eC9307303a65fA1218b4724',
25167
+ rootChainERC20Predicate: '0xf0b3435411A74F1aeCBD0fd6D53a90D5227fEeba',
25168
+ rootChainStateSender: '0x868097dbAcfD431F441d09D0e4D3B5eD3182E597',
25110
25169
  childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
25111
25170
  childChainStateReceiver: '0x0000000000000000000000000000000000001001',
25112
25171
  })
@@ -28093,16 +28152,19 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
28093
28152
  if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
28094
28153
  return new (Web3Provider)(provider);
28095
28154
  }
28096
- async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
28097
- let web3Provider = null;
28098
- switch(defaultProvider){
28155
+ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
28156
+ let provider = null;
28157
+ switch(walletProviderName){
28099
28158
  case ($e768639828688ca3$export$2d7a51a18d87e21d).METAMASK:
28100
- web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
28159
+ provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
28101
28160
  break;
28102
28161
  default:
28103
28162
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).DEFAULT_PROVIDER_ERROR);
28104
28163
  }
28105
- return web3Provider;
28164
+ return {
28165
+ provider: provider,
28166
+ walletProviderName: walletProviderName
28167
+ };
28106
28168
  }
28107
28169
 
28108
28170
 
@@ -28498,10 +28560,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28498
28560
  * @param {CreateProviderParams} params - The parameters for creating the provider.
28499
28561
  * @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
28500
28562
  */ async createProvider(params) {
28501
- const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
28502
- return {
28503
- provider: web3Provider
28504
- };
28563
+ return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
28505
28564
  }
28506
28565
  /**
28507
28566
  * Checks if a wallet is connected to the specified provider.
@@ -28618,7 +28677,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28618
28677
  function $parcel$export(e, n, v, s) {
28619
28678
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
28620
28679
  }
28621
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.3.0-alpha.3";
28680
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.3.1-alpha";
28622
28681
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
28623
28682
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
28624
28683
 
@@ -30417,4 +30476,4 @@ class ERC721PermissionedMintable {
30417
30476
  }
30418
30477
  }
30419
30478
 
30420
- export { APIError, BlockchainData, $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, ERC20, ERC721PermissionedMintable, Environment$1 as Environment, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient, JsonRpcError, MetaMaskIMXProvider, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, Networks, $ad06b030b1a3ba34$export$b80d2daf830437b9 as OrchestrationEventType, Orderbook, Passport, PassportError, ProviderConfiguration, ProviderErrorCode, ProviderEventNames, RpcErrorCode, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $045213b18e9f1f94$export$c88931fdc51854eb as WidgetTheme, module };
30479
+ export { APIError, BlockchainData, $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, ERC20, ERC721PermissionedMintable, Environment$1 as Environment, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient, JsonRpcError, MetaMaskIMXProvider, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, Networks, $ad06b030b1a3ba34$export$b80d2daf830437b9 as OrchestrationEventType, Orderbook, Passport, PassportError, ProviderConfiguration, ProviderErrorCode, ProviderEvent, RpcErrorCode, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $045213b18e9f1f94$export$c88931fdc51854eb as WidgetTheme, module };
@@ -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<Order>;
10355
+ getOrder(request: OrdersApiGetOrderRequest): Promise<OrderV3>;
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<ListOrdersResponse>;
10362
+ listOrders(request?: OrdersApiListOrdersRequest): Promise<ListOrdersResponseV3>;
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
@@ -10556,7 +10556,7 @@ type Provider = {
10556
10556
  on: (event: string, listener: (...args: any[]) => void) => void;
10557
10557
  removeListener: (event: string, listener: (...args: any[]) => void) => void;
10558
10558
  };
10559
- declare enum ProviderEventNames {
10559
+ declare enum ProviderEvent {
10560
10560
  ACCOUNTS_CHANGED = "accountsChanged"
10561
10561
  }
10562
10562
  type AccountsChangedEvent = Array<string>;
@@ -10594,4 +10594,4 @@ declare class Passport {
10594
10594
  getAccessToken(): Promise<string | undefined>;
10595
10595
  }
10596
10596
 
10597
- export { AccountsChangedEvent, DeviceConnectResponse, DeviceTokenResponse, JsonRpcError, JsonRpcRequestCallback, JsonRpcRequestPayload, JsonRpcResponsePayload, Networks, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, Provider, ProviderErrorCode, ProviderEventNames, RequestArguments, RpcErrorCode, UserProfile };
10597
+ export { AccountsChangedEvent, DeviceConnectResponse, DeviceTokenResponse, JsonRpcError, JsonRpcRequestCallback, JsonRpcRequestPayload, JsonRpcResponsePayload, Networks, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, Provider, ProviderErrorCode, ProviderEvent, RequestArguments, RpcErrorCode, UserProfile };