@imtbl/sdk 0.3.0-alpha.2 → 0.3.0-alpha.3
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 +11 -0
- package/dist/checkout_sdk.js +23 -3
- package/dist/checkout_widgets.d.ts +3 -0
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +15 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +90 -43
- package/dist/index.d.ts +32 -4
- package/dist/index.js +77 -31
- package/dist/passport.d.ts +18 -4
- package/dist/passport.js +52 -26
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ var providers = require('@ethersproject/providers');
|
|
|
12
12
|
var ethers = require('ethers');
|
|
13
13
|
var abi = require('@0xsequence/abi');
|
|
14
14
|
var config = require('@0xsequence/config');
|
|
15
|
+
var events = require('events');
|
|
15
16
|
var FormData$2 = require('form-data');
|
|
16
17
|
var seaportJs = require('@opensea/seaport-js');
|
|
17
18
|
var units = require('@ethersproject/units');
|
|
@@ -5550,7 +5551,7 @@ class MultiRollupApiClients {
|
|
|
5550
5551
|
}
|
|
5551
5552
|
|
|
5552
5553
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5553
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.3.0-alpha.
|
|
5554
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.3.0-alpha.3' };
|
|
5554
5555
|
const createConfig = ({ basePath, headers, }) => {
|
|
5555
5556
|
if (!basePath.trim()) {
|
|
5556
5557
|
throw Error('basePath can not be empty');
|
|
@@ -5610,7 +5611,7 @@ class APIError extends Error {
|
|
|
5610
5611
|
|
|
5611
5612
|
/* eslint-disable implicit-arrow-linebreak */
|
|
5612
5613
|
const defaultHeaders = {
|
|
5613
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.3.0-alpha.
|
|
5614
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.3.0-alpha.3',
|
|
5614
5615
|
};
|
|
5615
5616
|
/**
|
|
5616
5617
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -5876,7 +5877,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
5876
5877
|
chainID,
|
|
5877
5878
|
coreContractAddress,
|
|
5878
5879
|
registrationContractAddress,
|
|
5879
|
-
sdkVersion: 'ts-immutable-sdk-0.3.0-alpha.
|
|
5880
|
+
sdkVersion: 'ts-immutable-sdk-0.3.0-alpha.3',
|
|
5880
5881
|
});
|
|
5881
5882
|
/**
|
|
5882
5883
|
* Sets `sdkVersion` at the time of build
|
|
@@ -11315,7 +11316,7 @@ function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
|
|
|
11315
11316
|
return ethers.ethers.utils.keccak256(packMetaTransactionsNonceData);
|
|
11316
11317
|
}
|
|
11317
11318
|
const getNonce = async (jsonRpcProvider, smartContractWalletAddress) => {
|
|
11318
|
-
const code = await jsonRpcProvider.send('eth_getCode', [smartContractWalletAddress]);
|
|
11319
|
+
const code = await jsonRpcProvider.send('eth_getCode', [smartContractWalletAddress, 'latest']);
|
|
11319
11320
|
if (code && code !== '0x') {
|
|
11320
11321
|
const contract = new ethers.ethers.Contract(smartContractWalletAddress, abi.walletContracts.mainModule.abi, jsonRpcProvider);
|
|
11321
11322
|
return contract.nonce();
|
|
@@ -11366,17 +11367,30 @@ var RelayerTransactionStatus;
|
|
|
11366
11367
|
RelayerTransactionStatus["REVERTED"] = "REVERTED";
|
|
11367
11368
|
RelayerTransactionStatus["FAILED"] = "FAILED";
|
|
11368
11369
|
})(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
|
|
11369
|
-
|
|
11370
|
-
|
|
11370
|
+
exports.ProviderEventNames = void 0;
|
|
11371
|
+
(function (ProviderEventNames) {
|
|
11372
|
+
ProviderEventNames["ACCOUNTS_CHANGED"] = "accountsChanged";
|
|
11373
|
+
})(exports.ProviderEventNames || (exports.ProviderEventNames = {}));
|
|
11374
|
+
|
|
11375
|
+
/**
|
|
11376
|
+
* ProviderErrors should take priority over RpcErrorCodes
|
|
11377
|
+
*/
|
|
11378
|
+
exports.ProviderErrorCode = void 0;
|
|
11379
|
+
(function (ProviderErrorCode) {
|
|
11380
|
+
ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
|
|
11381
|
+
ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
|
|
11382
|
+
ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
|
|
11383
|
+
ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
|
|
11384
|
+
})(exports.ProviderErrorCode || (exports.ProviderErrorCode = {}));
|
|
11385
|
+
exports.RpcErrorCode = void 0;
|
|
11371
11386
|
(function (RpcErrorCode) {
|
|
11372
11387
|
RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
|
|
11373
11388
|
RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
11374
11389
|
RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
11375
11390
|
RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
11376
11391
|
RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
11377
|
-
RpcErrorCode[RpcErrorCode["UNAUTHORIZED"] = -32604] = "UNAUTHORIZED";
|
|
11378
11392
|
RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
11379
|
-
})(RpcErrorCode || (RpcErrorCode = {}));
|
|
11393
|
+
})(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
11380
11394
|
class JsonRpcError extends Error {
|
|
11381
11395
|
message;
|
|
11382
11396
|
code;
|
|
@@ -11389,10 +11403,10 @@ class JsonRpcError extends Error {
|
|
|
11389
11403
|
|
|
11390
11404
|
const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
|
|
11391
11405
|
const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
|
|
11392
|
-
const
|
|
11406
|
+
const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, config, user, }) => {
|
|
11393
11407
|
const transactionRequest = params[0];
|
|
11394
11408
|
if (!transactionRequest.to) {
|
|
11395
|
-
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
11409
|
+
throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
11396
11410
|
}
|
|
11397
11411
|
const chainId = chainIdNumber(config.zkEvmChainId);
|
|
11398
11412
|
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
@@ -11446,14 +11460,27 @@ const ethSendTransaction = async ({ params, magicProvider, jsonRpcProvider, rela
|
|
|
11446
11460
|
const relayerTransaction = await retryWithDelay(retrieveRelayerTransaction, {
|
|
11447
11461
|
retries: MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES,
|
|
11448
11462
|
interval: TRANSACTION_HASH_RETRIEVAL_WAIT,
|
|
11449
|
-
finalErr: new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
|
|
11463
|
+
finalErr: new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
|
|
11450
11464
|
});
|
|
11451
11465
|
if (![RelayerTransactionStatus.SUBMITTED, RelayerTransactionStatus.SUCCESSFUL].includes(relayerTransaction.status)) {
|
|
11452
|
-
throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
|
|
11466
|
+
throw new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
|
|
11453
11467
|
}
|
|
11454
11468
|
return relayerTransaction.hash;
|
|
11455
11469
|
};
|
|
11456
11470
|
|
|
11471
|
+
class TypedEventEmitter {
|
|
11472
|
+
emitter = new events.EventEmitter();
|
|
11473
|
+
emit(eventName, ...eventArg) {
|
|
11474
|
+
this.emitter.emit(eventName, ...eventArg);
|
|
11475
|
+
}
|
|
11476
|
+
on(eventName, handler) {
|
|
11477
|
+
this.emitter.on(eventName, handler);
|
|
11478
|
+
}
|
|
11479
|
+
removeListener(eventName, handler) {
|
|
11480
|
+
this.emitter.removeListener(eventName, handler);
|
|
11481
|
+
}
|
|
11482
|
+
}
|
|
11483
|
+
|
|
11457
11484
|
class RelayerClient {
|
|
11458
11485
|
config;
|
|
11459
11486
|
constructor({ config }) {
|
|
@@ -11513,7 +11540,7 @@ class RelayerClient {
|
|
|
11513
11540
|
}
|
|
11514
11541
|
|
|
11515
11542
|
const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
|
|
11516
|
-
async function
|
|
11543
|
+
async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
|
|
11517
11544
|
const web3Provider = new providers.Web3Provider(magicProvider);
|
|
11518
11545
|
const ethSigner = web3Provider.getSigner();
|
|
11519
11546
|
const ethereumAddress = await ethSigner.getAddress();
|
|
@@ -11528,16 +11555,16 @@ async function createCounterfactualAddress({ authManager, magicProvider, multiRo
|
|
|
11528
11555
|
}, { headers });
|
|
11529
11556
|
}
|
|
11530
11557
|
catch (error) {
|
|
11531
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
|
|
11558
|
+
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
|
|
11532
11559
|
}
|
|
11533
11560
|
const user = await authManager.loginSilent();
|
|
11534
11561
|
if (!user?.zkEvm) {
|
|
11535
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
|
|
11562
|
+
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
|
|
11536
11563
|
}
|
|
11537
11564
|
return user;
|
|
11538
11565
|
}
|
|
11539
11566
|
|
|
11540
|
-
const
|
|
11567
|
+
const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
|
|
11541
11568
|
const user = await authManager.getUser() || await authManager.login();
|
|
11542
11569
|
if (!user.idToken) {
|
|
11543
11570
|
throw new Error('User is missing idToken');
|
|
@@ -11545,7 +11572,7 @@ const registerZkEvmUser = async ({ authManager, config, magicAdapter, multiRollu
|
|
|
11545
11572
|
const magicProvider = await magicAdapter.login(user.idToken, config.network);
|
|
11546
11573
|
if (!user.zkEvm) {
|
|
11547
11574
|
// Generate counterfactual address and retrieve updated Auth0 user
|
|
11548
|
-
const userZkevm = await
|
|
11575
|
+
const userZkevm = await registerZkEvmUser({
|
|
11549
11576
|
authManager,
|
|
11550
11577
|
magicProvider,
|
|
11551
11578
|
multiRollupApiClients,
|
|
@@ -11562,7 +11589,7 @@ const registerZkEvmUser = async ({ authManager, config, magicAdapter, multiRollu
|
|
|
11562
11589
|
};
|
|
11563
11590
|
};
|
|
11564
11591
|
|
|
11565
|
-
class ZkEvmProvider {
|
|
11592
|
+
class ZkEvmProvider extends TypedEventEmitter {
|
|
11566
11593
|
authManager;
|
|
11567
11594
|
config;
|
|
11568
11595
|
confirmationScreen;
|
|
@@ -11573,6 +11600,7 @@ class ZkEvmProvider {
|
|
|
11573
11600
|
magicProvider; // Used for signing
|
|
11574
11601
|
user;
|
|
11575
11602
|
constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, }) {
|
|
11603
|
+
super();
|
|
11576
11604
|
this.authManager = authManager;
|
|
11577
11605
|
this.magicAdapter = magicAdapter;
|
|
11578
11606
|
this.config = config;
|
|
@@ -11585,25 +11613,12 @@ class ZkEvmProvider {
|
|
|
11585
11613
|
return this.magicProvider !== undefined && this.user !== undefined;
|
|
11586
11614
|
}
|
|
11587
11615
|
async performRequest(request) {
|
|
11588
|
-
const authWrapper = (fn) => {
|
|
11589
|
-
if (!this.isLoggedIn()) {
|
|
11590
|
-
throw new JsonRpcError(RpcErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
|
|
11591
|
-
}
|
|
11592
|
-
return fn({
|
|
11593
|
-
params: request.params || [],
|
|
11594
|
-
magicProvider: this.magicProvider,
|
|
11595
|
-
jsonRpcProvider: this.jsonRpcProvider,
|
|
11596
|
-
config: this.config,
|
|
11597
|
-
relayerClient: this.relayerClient,
|
|
11598
|
-
user: this.user,
|
|
11599
|
-
});
|
|
11600
|
-
};
|
|
11601
11616
|
switch (request.method) {
|
|
11602
11617
|
case 'eth_requestAccounts': {
|
|
11603
11618
|
if (this.isLoggedIn()) {
|
|
11604
11619
|
return [this.user.zkEvm.ethAddress];
|
|
11605
11620
|
}
|
|
11606
|
-
const { magicProvider, user } = await
|
|
11621
|
+
const { magicProvider, user } = await loginZkEvmUser({
|
|
11607
11622
|
authManager: this.authManager,
|
|
11608
11623
|
config: this.config,
|
|
11609
11624
|
magicAdapter: this.magicAdapter,
|
|
@@ -11611,10 +11626,21 @@ class ZkEvmProvider {
|
|
|
11611
11626
|
});
|
|
11612
11627
|
this.user = user;
|
|
11613
11628
|
this.magicProvider = magicProvider;
|
|
11629
|
+
this.emit(exports.ProviderEventNames.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
|
|
11614
11630
|
return [this.user.zkEvm.ethAddress];
|
|
11615
11631
|
}
|
|
11616
11632
|
case 'eth_sendTransaction': {
|
|
11617
|
-
|
|
11633
|
+
if (!this.isLoggedIn()) {
|
|
11634
|
+
throw new JsonRpcError(exports.ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
|
|
11635
|
+
}
|
|
11636
|
+
return sendTransaction({
|
|
11637
|
+
params: request.params || [],
|
|
11638
|
+
magicProvider: this.magicProvider,
|
|
11639
|
+
jsonRpcProvider: this.jsonRpcProvider,
|
|
11640
|
+
config: this.config,
|
|
11641
|
+
relayerClient: this.relayerClient,
|
|
11642
|
+
user: this.user,
|
|
11643
|
+
});
|
|
11618
11644
|
}
|
|
11619
11645
|
case 'eth_accounts': {
|
|
11620
11646
|
return this.isLoggedIn() ? [this.user.zkEvm.ethAddress] : [];
|
|
@@ -11635,7 +11661,7 @@ class ZkEvmProvider {
|
|
|
11635
11661
|
return this.jsonRpcProvider.send(request.method, request.params || []);
|
|
11636
11662
|
}
|
|
11637
11663
|
default: {
|
|
11638
|
-
throw new JsonRpcError(
|
|
11664
|
+
throw new JsonRpcError(exports.ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
|
|
11639
11665
|
}
|
|
11640
11666
|
}
|
|
11641
11667
|
}
|
|
@@ -11655,10 +11681,10 @@ class ZkEvmProvider {
|
|
|
11655
11681
|
jsonRpcError = error;
|
|
11656
11682
|
}
|
|
11657
11683
|
else if (error instanceof Error) {
|
|
11658
|
-
jsonRpcError = new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11684
|
+
jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11659
11685
|
}
|
|
11660
11686
|
else {
|
|
11661
|
-
jsonRpcError = new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11687
|
+
jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11662
11688
|
}
|
|
11663
11689
|
return {
|
|
11664
11690
|
id,
|
|
@@ -11676,9 +11702,9 @@ class ZkEvmProvider {
|
|
|
11676
11702
|
throw error;
|
|
11677
11703
|
}
|
|
11678
11704
|
if (error instanceof Error) {
|
|
11679
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11705
|
+
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
|
|
11680
11706
|
}
|
|
11681
|
-
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11707
|
+
throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
|
|
11682
11708
|
}
|
|
11683
11709
|
}
|
|
11684
11710
|
sendAsync(request, callback) {
|
|
@@ -11727,7 +11753,7 @@ class ZkEvmProvider {
|
|
|
11727
11753
|
if (!Array.isArray(request) && typeof request === 'object') {
|
|
11728
11754
|
return this.performJsonRpcRequest(request);
|
|
11729
11755
|
}
|
|
11730
|
-
throw new JsonRpcError(RpcErrorCode.INVALID_REQUEST, 'Invalid request');
|
|
11756
|
+
throw new JsonRpcError(exports.RpcErrorCode.INVALID_REQUEST, 'Invalid request');
|
|
11731
11757
|
}
|
|
11732
11758
|
}
|
|
11733
11759
|
|
|
@@ -27337,16 +27363,28 @@ const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
|
|
|
27337
27363
|
[exports.Environment.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
|
|
27338
27364
|
};
|
|
27339
27365
|
function validateOverrides(overrides) {
|
|
27340
|
-
|
|
27341
|
-
|
|
27366
|
+
const keysToCheck = ['rpcURL', 'exchangeContracts', 'commonRoutingTokens', 'nativeToken'];
|
|
27367
|
+
for (const key of keysToCheck) {
|
|
27368
|
+
if (!overrides[key]) {
|
|
27342
27369
|
throw new InvalidConfigurationError(`Missing override: ${key}`);
|
|
27343
27370
|
}
|
|
27344
|
-
}
|
|
27371
|
+
}
|
|
27345
27372
|
Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
|
|
27346
27373
|
if (!isValidNonZeroAddress(contract)) {
|
|
27347
27374
|
throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
|
|
27348
27375
|
}
|
|
27349
27376
|
});
|
|
27377
|
+
if (!overrides.secondaryFees) {
|
|
27378
|
+
return;
|
|
27379
|
+
}
|
|
27380
|
+
for (const secondaryFee of overrides.secondaryFees) {
|
|
27381
|
+
if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
|
|
27382
|
+
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
|
|
27383
|
+
}
|
|
27384
|
+
if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > 10000) {
|
|
27385
|
+
throw new InvalidConfigurationError(`Invalid secondary fee percentage: ${secondaryFee.feeBasisPoints}`);
|
|
27386
|
+
}
|
|
27387
|
+
}
|
|
27350
27388
|
}
|
|
27351
27389
|
/**
|
|
27352
27390
|
* {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
|
|
@@ -27356,6 +27394,7 @@ function validateOverrides(overrides) {
|
|
|
27356
27394
|
class ExchangeConfiguration {
|
|
27357
27395
|
baseConfig;
|
|
27358
27396
|
chain;
|
|
27397
|
+
secondaryFees;
|
|
27359
27398
|
constructor({ chainId, baseConfig, overrides }) {
|
|
27360
27399
|
this.baseConfig = baseConfig;
|
|
27361
27400
|
if (overrides) {
|
|
@@ -27367,8 +27406,10 @@ class ExchangeConfiguration {
|
|
|
27367
27406
|
commonRoutingTokens: overrides.commonRoutingTokens,
|
|
27368
27407
|
nativeToken: overrides.nativeToken,
|
|
27369
27408
|
};
|
|
27409
|
+
this.secondaryFees = overrides.secondaryFees ? overrides.secondaryFees : [];
|
|
27370
27410
|
return;
|
|
27371
27411
|
}
|
|
27412
|
+
this.secondaryFees = [];
|
|
27372
27413
|
const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
|
|
27373
27414
|
if (!chain) {
|
|
27374
27415
|
throw new ChainNotSupportedError(chainId, baseConfig.environment);
|
|
@@ -27382,11 +27423,13 @@ class Exchange {
|
|
|
27382
27423
|
router;
|
|
27383
27424
|
chainId;
|
|
27384
27425
|
nativeToken;
|
|
27426
|
+
secondaryFees;
|
|
27385
27427
|
constructor(configuration) {
|
|
27386
27428
|
const config = new ExchangeConfiguration(configuration);
|
|
27387
27429
|
this.chainId = config.chain.chainId;
|
|
27388
27430
|
this.nativeToken = config.chain.nativeToken;
|
|
27389
27431
|
this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
|
|
27432
|
+
this.secondaryFees = config.secondaryFees;
|
|
27390
27433
|
this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
|
|
27391
27434
|
multicallAddress: config.chain.contracts.multicall,
|
|
27392
27435
|
factoryAddress: config.chain.contracts.coreFactory,
|
|
@@ -27469,6 +27512,9 @@ class Exchange {
|
|
|
27469
27512
|
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
|
|
27470
27513
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, sdkCore.TradeType.EXACT_OUTPUT);
|
|
27471
27514
|
}
|
|
27515
|
+
thereAreSecondaryFees() {
|
|
27516
|
+
return this.secondaryFees.length > 0;
|
|
27517
|
+
}
|
|
27472
27518
|
}
|
|
27473
27519
|
|
|
27474
27520
|
/* eslint-disable class-methods-use-this */
|
|
@@ -28592,7 +28638,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28592
28638
|
function $parcel$export(e, n, v, s) {
|
|
28593
28639
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28594
28640
|
}
|
|
28595
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.3.0-alpha.
|
|
28641
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.3.0-alpha.3";
|
|
28596
28642
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28597
28643
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28598
28644
|
|
|
@@ -30411,6 +30457,7 @@ exports.ERC721PermissionedMintable = ERC721PermissionedMintable;
|
|
|
30411
30457
|
exports.GenericIMXProvider = GenericIMXProvider;
|
|
30412
30458
|
exports.ImmutableConfiguration = ImmutableConfiguration;
|
|
30413
30459
|
exports.ImmutableXClient = ImmutableXClient;
|
|
30460
|
+
exports.JsonRpcError = JsonRpcError;
|
|
30414
30461
|
exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
|
|
30415
30462
|
exports.Orderbook = Orderbook;
|
|
30416
30463
|
exports.Passport = Passport;
|
package/dist/index.d.ts
CHANGED
|
@@ -12779,19 +12779,27 @@ type DeviceTokenResponse = {
|
|
|
12779
12779
|
expires_in: number;
|
|
12780
12780
|
};
|
|
12781
12781
|
|
|
12782
|
+
/**
|
|
12783
|
+
* ProviderErrors should take priority over RpcErrorCodes
|
|
12784
|
+
*/
|
|
12785
|
+
declare enum ProviderErrorCode {
|
|
12786
|
+
USER_REJECTED_REQUEST = 4001,
|
|
12787
|
+
UNAUTHORIZED = 4100,
|
|
12788
|
+
UNSUPPORTED_METHOD = 4200,
|
|
12789
|
+
DISCONNECTED = 4900
|
|
12790
|
+
}
|
|
12782
12791
|
declare enum RpcErrorCode {
|
|
12783
12792
|
RPC_SERVER_ERROR = -32000,
|
|
12784
12793
|
INVALID_REQUEST = -32600,
|
|
12785
12794
|
METHOD_NOT_FOUND = -32601,
|
|
12786
12795
|
INVALID_PARAMS = -32602,
|
|
12787
12796
|
INTERNAL_ERROR = -32603,
|
|
12788
|
-
UNAUTHORIZED = -32604,
|
|
12789
12797
|
PARSE_ERROR = -32700
|
|
12790
12798
|
}
|
|
12791
12799
|
declare class JsonRpcError extends Error {
|
|
12792
12800
|
readonly message: string;
|
|
12793
|
-
readonly code: RpcErrorCode;
|
|
12794
|
-
constructor(code: RpcErrorCode, message: string);
|
|
12801
|
+
readonly code: ProviderErrorCode | RpcErrorCode;
|
|
12802
|
+
constructor(code: ProviderErrorCode | RpcErrorCode, message: string);
|
|
12795
12803
|
}
|
|
12796
12804
|
|
|
12797
12805
|
interface RequestArguments {
|
|
@@ -12815,7 +12823,13 @@ type Provider = {
|
|
|
12815
12823
|
request: (request: RequestArguments) => Promise<any>;
|
|
12816
12824
|
sendAsync: (request: JsonRpcRequestPayload | JsonRpcRequestPayload[], callback: JsonRpcRequestCallback) => void;
|
|
12817
12825
|
send: (request: string | JsonRpcRequestPayload | JsonRpcRequestPayload[], callbackOrParams?: JsonRpcRequestCallback | Array<any>, callback?: JsonRpcRequestCallback) => void;
|
|
12826
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
12827
|
+
removeListener: (event: string, listener: (...args: any[]) => void) => void;
|
|
12818
12828
|
};
|
|
12829
|
+
declare enum ProviderEventNames {
|
|
12830
|
+
ACCOUNTS_CHANGED = "accountsChanged"
|
|
12831
|
+
}
|
|
12832
|
+
type AccountsChangedEvent = Array<string>;
|
|
12819
12833
|
|
|
12820
12834
|
declare class Passport {
|
|
12821
12835
|
private readonly authManager;
|
|
@@ -12909,6 +12923,16 @@ declare class Orderbook {
|
|
|
12909
12923
|
|
|
12910
12924
|
declare const module = "orderbook";
|
|
12911
12925
|
|
|
12926
|
+
/**
|
|
12927
|
+
* Interface representing the secondary fees for a swap
|
|
12928
|
+
* @property {string} feeRecipient - The fee recipient address
|
|
12929
|
+
* @property {number} feeBasisPoints - The fee percentage in basis points
|
|
12930
|
+
* @example 100 basis points = 1%
|
|
12931
|
+
*/
|
|
12932
|
+
type SecondaryFee = {
|
|
12933
|
+
feeRecipient: string;
|
|
12934
|
+
feeBasisPoints: number;
|
|
12935
|
+
};
|
|
12912
12936
|
/**
|
|
12913
12937
|
* Interface representing a token
|
|
12914
12938
|
* @property {number} chainId - The chain ID
|
|
@@ -12929,6 +12953,7 @@ interface ExchangeOverrides {
|
|
|
12929
12953
|
exchangeContracts: ExchangeContracts;
|
|
12930
12954
|
commonRoutingTokens: TokenInfo$1[];
|
|
12931
12955
|
nativeToken: TokenInfo$1;
|
|
12956
|
+
secondaryFees?: SecondaryFee[];
|
|
12932
12957
|
}
|
|
12933
12958
|
|
|
12934
12959
|
/**
|
|
@@ -27102,6 +27127,9 @@ declare namespace React {
|
|
|
27102
27127
|
// - "string"
|
|
27103
27128
|
// - union of string literals
|
|
27104
27129
|
interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
|
27130
|
+
// React-specific Attributes
|
|
27131
|
+
suppressHydrationWarning?: boolean | undefined;
|
|
27132
|
+
|
|
27105
27133
|
// Attributes which also defined in HTMLAttributes
|
|
27106
27134
|
// See comment in SVGDOMPropertyConfig.js
|
|
27107
27135
|
className?: string | undefined;
|
|
@@ -28566,4 +28594,4 @@ declare class ERC721PermissionedMintable {
|
|
|
28566
28594
|
}): Promise<PopulatedTransaction>;
|
|
28567
28595
|
}
|
|
28568
28596
|
|
|
28569
|
-
export { APIError, ActivityType, AllowedNetworkConfig, BlockchainData, BlockchainDataModuleConfiguration, BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, CHECKOUT_API_BASE_URL, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectReact, ConnectResult, ConnectionFailed, ConnectionSuccess, DeviceConnectResponse, DeviceTokenResponse, DexConfig, ERC20, ERC721PermissionedMintable, Environment, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GenericIMXProvider, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IMXProvider, ImmutableConfiguration, ImmutableXClient, ImtblBridgeProps, ImtblConnectProps, ImtblSwapProps, ImtblWalletProps, ImxModuleConfiguration as ImxClientModuleConfiguration, WalletConnection as ImxClientWalletConnection, JsonRpcRequestCallback, JsonRpcRequestPayload, JsonRpcResponsePayload, MetaMaskIMXProvider, ModuleConfiguration, NetworkFilter, NetworkFilterTypes, NetworkInfo, Networks, OrchestrationEventType, Orderbook, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, Provider, ProviderConfiguration, RemoteConfiguration, RequestArguments, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SemanticVersion, SendTransactionParams, SendTransactionResult, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, UpdateConfig, UserProfile, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, module };
|
|
28597
|
+
export { APIError, AccountsChangedEvent, ActivityType, AllowedNetworkConfig, BlockchainData, BlockchainDataModuleConfiguration, BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, CHECKOUT_API_BASE_URL, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectReact, ConnectResult, ConnectionFailed, ConnectionSuccess, DeviceConnectResponse, DeviceTokenResponse, DexConfig, ERC20, ERC721PermissionedMintable, Environment, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GenericIMXProvider, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IMXProvider, ImmutableConfiguration, ImmutableXClient, ImtblBridgeProps, ImtblConnectProps, ImtblSwapProps, ImtblWalletProps, ImxModuleConfiguration as ImxClientModuleConfiguration, WalletConnection as ImxClientWalletConnection, JsonRpcError, JsonRpcRequestCallback, JsonRpcRequestPayload, JsonRpcResponsePayload, MetaMaskIMXProvider, ModuleConfiguration, NetworkFilter, NetworkFilterTypes, NetworkInfo, Networks, OrchestrationEventType, Orderbook, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, Provider, ProviderConfiguration, ProviderErrorCode, ProviderEventNames, RemoteConfiguration, RequestArguments, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, RpcErrorCode, SemanticVersion, SendTransactionParams, SendTransactionResult, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, UpdateConfig, UserProfile, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, module };
|