@imtbl/sdk 0.30.2 → 0.30.4
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/sdk.js +3 -3
- package/dist/browser/checkout/widgets.js +56 -56
- package/dist/checkout_sdk.d.ts +0 -11
- package/dist/checkout_sdk.js +26 -28
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +30 -38
- package/dist/index.d.ts +0 -11
- package/dist/index.js +30 -38
- package/dist/passport.js +4 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3792,7 +3792,7 @@ class MultiRollupApiClients {
|
|
|
3792
3792
|
}
|
|
3793
3793
|
|
|
3794
3794
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3795
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.30.
|
|
3795
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.30.4' };
|
|
3796
3796
|
const createConfig = ({ basePath, headers, }) => {
|
|
3797
3797
|
if (!basePath.trim()) {
|
|
3798
3798
|
throw Error('basePath can not be empty');
|
|
@@ -3852,7 +3852,7 @@ class APIError extends Error {
|
|
|
3852
3852
|
|
|
3853
3853
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3854
3854
|
const defaultHeaders = {
|
|
3855
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.30.
|
|
3855
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.30.4',
|
|
3856
3856
|
};
|
|
3857
3857
|
/**
|
|
3858
3858
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4263,7 +4263,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4263
4263
|
chainID,
|
|
4264
4264
|
coreContractAddress,
|
|
4265
4265
|
registrationContractAddress,
|
|
4266
|
-
sdkVersion: 'ts-immutable-sdk-0.30.
|
|
4266
|
+
sdkVersion: 'ts-immutable-sdk-0.30.4',
|
|
4267
4267
|
});
|
|
4268
4268
|
/**
|
|
4269
4269
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9033,10 +9033,7 @@ class AuthManager {
|
|
|
9033
9033
|
try {
|
|
9034
9034
|
const tokenResponse = await this.getDeviceFlowToken(deviceCode);
|
|
9035
9035
|
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
9036
|
-
|
|
9037
|
-
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
9038
|
-
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9039
|
-
}
|
|
9036
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9040
9037
|
return user;
|
|
9041
9038
|
}
|
|
9042
9039
|
catch (error) {
|
|
@@ -9108,10 +9105,7 @@ class AuthManager {
|
|
|
9108
9105
|
}
|
|
9109
9106
|
const tokenResponse = await this.getPKCEToken(authorizationCode, pkceData.verifier);
|
|
9110
9107
|
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
9111
|
-
|
|
9112
|
-
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
9113
|
-
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9114
|
-
}
|
|
9108
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9115
9109
|
return user;
|
|
9116
9110
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
9117
9111
|
}
|
|
@@ -31321,42 +31315,40 @@ function getTokenContract(address, contractInterface, signerOrProvider) {
|
|
|
31321
31315
|
|
|
31322
31316
|
const DUMMY_WALLET_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
31323
31317
|
const DEFAULT_TOKEN_DECIMALS = 18;
|
|
31324
|
-
async function
|
|
31325
|
-
if (tokenAddress === 'NATIVE') {
|
|
31326
|
-
return config.networkMap.get(chainId)?.nativeCurrency;
|
|
31327
|
-
}
|
|
31328
|
-
const contract = new ethers.Contract(tokenAddress, JSON.stringify(ERC20ABI), provider);
|
|
31329
|
-
const name = await contract.name();
|
|
31330
|
-
const symbol = await contract.symbol();
|
|
31331
|
-
const decimals = await contract.decimals();
|
|
31332
|
-
return {
|
|
31333
|
-
name,
|
|
31334
|
-
symbol,
|
|
31335
|
-
decimals,
|
|
31336
|
-
address: tokenAddress,
|
|
31337
|
-
};
|
|
31338
|
-
}
|
|
31339
|
-
async function bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired, tokenAddress) {
|
|
31318
|
+
async function bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired) {
|
|
31340
31319
|
const fromChainId = getL1ChainId(config);
|
|
31341
31320
|
const toChainId = getL2ChainId(config);
|
|
31342
31321
|
const gasEstimateTokensConfig = (await config.remote.getConfig('gasEstimateTokens'));
|
|
31343
|
-
const {
|
|
31322
|
+
const { fromAddress } = gasEstimateTokensConfig[fromChainId].bridgeToL2Addresses;
|
|
31344
31323
|
const provider = readOnlyProviders.get(fromChainId);
|
|
31345
31324
|
if (!provider)
|
|
31346
31325
|
throw new Error(`Missing JsonRpcProvider for chain id: ${fromChainId}`);
|
|
31347
31326
|
try {
|
|
31348
|
-
|
|
31349
|
-
|
|
31350
|
-
|
|
31351
|
-
|
|
31327
|
+
let gasFees = {};
|
|
31328
|
+
const getGasFees = async () => {
|
|
31329
|
+
gasFees = await getBridgeEstimatedGas(provider, isSpendingCapApprovalRequired);
|
|
31330
|
+
gasFees.token = config.networkMap.get(fromChainId)?.nativeCurrency;
|
|
31331
|
+
};
|
|
31332
|
+
let bridgeFees = {
|
|
31333
|
+
bridgeFee: {},
|
|
31334
|
+
bridgeable: false,
|
|
31335
|
+
};
|
|
31336
|
+
const getBridgeFees = async () => {
|
|
31337
|
+
const tokenBridge = await createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
|
|
31338
|
+
bridgeFees = await getBridgeFeeEstimate$1(tokenBridge, fromAddress);
|
|
31339
|
+
};
|
|
31340
|
+
await Promise.all([
|
|
31341
|
+
getGasFees(),
|
|
31342
|
+
getBridgeFees(),
|
|
31343
|
+
]);
|
|
31352
31344
|
return {
|
|
31353
31345
|
gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
|
|
31354
|
-
gasFee,
|
|
31346
|
+
gasFee: gasFees,
|
|
31355
31347
|
bridgeFee: {
|
|
31356
|
-
estimatedAmount: bridgeFee?.estimatedAmount,
|
|
31357
|
-
token: bridgeFee?.token,
|
|
31348
|
+
estimatedAmount: bridgeFees.bridgeFee?.estimatedAmount,
|
|
31349
|
+
token: bridgeFees.bridgeFee?.token,
|
|
31358
31350
|
},
|
|
31359
|
-
bridgeable,
|
|
31351
|
+
bridgeable: bridgeFees.bridgeable,
|
|
31360
31352
|
};
|
|
31361
31353
|
}
|
|
31362
31354
|
catch {
|
|
@@ -31412,7 +31404,7 @@ async function swapGasEstimator(config) {
|
|
|
31412
31404
|
async function gasEstimator(params, readOnlyProviders, config) {
|
|
31413
31405
|
switch (params.gasEstimateType) {
|
|
31414
31406
|
case GasEstimateType.BRIDGE_TO_L2:
|
|
31415
|
-
return await bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired
|
|
31407
|
+
return await bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired);
|
|
31416
31408
|
case GasEstimateType.SWAP:
|
|
31417
31409
|
return await swapGasEstimator(config);
|
|
31418
31410
|
default:
|
|
@@ -34030,7 +34022,7 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
34030
34022
|
return itemRequirements;
|
|
34031
34023
|
}
|
|
34032
34024
|
|
|
34033
|
-
const SDK_VERSION_MARKER = '0.30.
|
|
34025
|
+
const SDK_VERSION_MARKER = '0.30.4';
|
|
34034
34026
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
34035
34027
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
34036
34028
|
|
package/dist/index.d.ts
CHANGED
|
@@ -16919,15 +16919,6 @@ interface CheckConnectionResult {
|
|
|
16919
16919
|
walletAddress: string;
|
|
16920
16920
|
}
|
|
16921
16921
|
|
|
16922
|
-
/**
|
|
16923
|
-
* @typedef {string} Address - Represents an Ethereum address.
|
|
16924
|
-
*/
|
|
16925
|
-
type Address = string;
|
|
16926
|
-
/**
|
|
16927
|
-
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
16928
|
-
*/
|
|
16929
|
-
type FungibleToken = Address | 'NATIVE';
|
|
16930
|
-
|
|
16931
16922
|
/**
|
|
16932
16923
|
* An enum representing the type of gas estimate.
|
|
16933
16924
|
* @enum {string}
|
|
@@ -16948,12 +16939,10 @@ type GasEstimateParams = GasEstimateBridgeToL2Params | GasEstimateSwapParams;
|
|
|
16948
16939
|
* An interface representing the parameters for estimating gas for a bridge to L2 transaction {@link Checkout.gasEstimate}.
|
|
16949
16940
|
* @param {GasEstimateType.BRIDGE_TO_L2} gasEstimateType - The type of gas estimate.
|
|
16950
16941
|
* @param {boolean} isSpendingCapApprovalRequired - Whether or not spending cap approval is required.
|
|
16951
|
-
* @param {FungibleToken | undefined} tokenAddress - The address of the fungible token to use in the transaction.
|
|
16952
16942
|
*/
|
|
16953
16943
|
interface GasEstimateBridgeToL2Params {
|
|
16954
16944
|
gasEstimateType: GasEstimateType.BRIDGE_TO_L2;
|
|
16955
16945
|
isSpendingCapApprovalRequired: boolean;
|
|
16956
|
-
tokenAddress?: FungibleToken;
|
|
16957
16946
|
}
|
|
16958
16947
|
/**
|
|
16959
16948
|
* An interface representing the parameters for a gas estimate swap {@link Checkout.gasEstimate}.
|
package/dist/index.js
CHANGED
|
@@ -3770,7 +3770,7 @@ class MultiRollupApiClients {
|
|
|
3770
3770
|
}
|
|
3771
3771
|
|
|
3772
3772
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3773
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.30.
|
|
3773
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.30.4' };
|
|
3774
3774
|
const createConfig = ({ basePath, headers, }) => {
|
|
3775
3775
|
if (!basePath.trim()) {
|
|
3776
3776
|
throw Error('basePath can not be empty');
|
|
@@ -3830,7 +3830,7 @@ class APIError extends Error {
|
|
|
3830
3830
|
|
|
3831
3831
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3832
3832
|
const defaultHeaders = {
|
|
3833
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.30.
|
|
3833
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.30.4',
|
|
3834
3834
|
};
|
|
3835
3835
|
/**
|
|
3836
3836
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4241,7 +4241,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4241
4241
|
chainID,
|
|
4242
4242
|
coreContractAddress,
|
|
4243
4243
|
registrationContractAddress,
|
|
4244
|
-
sdkVersion: 'ts-immutable-sdk-0.30.
|
|
4244
|
+
sdkVersion: 'ts-immutable-sdk-0.30.4',
|
|
4245
4245
|
});
|
|
4246
4246
|
/**
|
|
4247
4247
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9011,10 +9011,7 @@ class AuthManager {
|
|
|
9011
9011
|
try {
|
|
9012
9012
|
const tokenResponse = await this.getDeviceFlowToken(deviceCode);
|
|
9013
9013
|
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
9014
|
-
|
|
9015
|
-
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
9016
|
-
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9017
|
-
}
|
|
9014
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9018
9015
|
return user;
|
|
9019
9016
|
}
|
|
9020
9017
|
catch (error) {
|
|
@@ -9086,10 +9083,7 @@ class AuthManager {
|
|
|
9086
9083
|
}
|
|
9087
9084
|
const tokenResponse = await this.getPKCEToken(authorizationCode, pkceData.verifier);
|
|
9088
9085
|
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
9089
|
-
|
|
9090
|
-
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
9091
|
-
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9092
|
-
}
|
|
9086
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
9093
9087
|
return user;
|
|
9094
9088
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
9095
9089
|
}
|
|
@@ -31299,42 +31293,40 @@ function getTokenContract(address, contractInterface, signerOrProvider) {
|
|
|
31299
31293
|
|
|
31300
31294
|
const DUMMY_WALLET_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
31301
31295
|
const DEFAULT_TOKEN_DECIMALS = 18;
|
|
31302
|
-
async function
|
|
31303
|
-
if (tokenAddress === 'NATIVE') {
|
|
31304
|
-
return config.networkMap.get(chainId)?.nativeCurrency;
|
|
31305
|
-
}
|
|
31306
|
-
const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), provider);
|
|
31307
|
-
const name = await contract.name();
|
|
31308
|
-
const symbol = await contract.symbol();
|
|
31309
|
-
const decimals = await contract.decimals();
|
|
31310
|
-
return {
|
|
31311
|
-
name,
|
|
31312
|
-
symbol,
|
|
31313
|
-
decimals,
|
|
31314
|
-
address: tokenAddress,
|
|
31315
|
-
};
|
|
31316
|
-
}
|
|
31317
|
-
async function bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired, tokenAddress) {
|
|
31296
|
+
async function bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired) {
|
|
31318
31297
|
const fromChainId = getL1ChainId(config);
|
|
31319
31298
|
const toChainId = getL2ChainId(config);
|
|
31320
31299
|
const gasEstimateTokensConfig = (await config.remote.getConfig('gasEstimateTokens'));
|
|
31321
|
-
const {
|
|
31300
|
+
const { fromAddress } = gasEstimateTokensConfig[fromChainId].bridgeToL2Addresses;
|
|
31322
31301
|
const provider = readOnlyProviders.get(fromChainId);
|
|
31323
31302
|
if (!provider)
|
|
31324
31303
|
throw new Error(`Missing JsonRpcProvider for chain id: ${fromChainId}`);
|
|
31325
31304
|
try {
|
|
31326
|
-
|
|
31327
|
-
|
|
31328
|
-
|
|
31329
|
-
|
|
31305
|
+
let gasFees = {};
|
|
31306
|
+
const getGasFees = async () => {
|
|
31307
|
+
gasFees = await getBridgeEstimatedGas(provider, isSpendingCapApprovalRequired);
|
|
31308
|
+
gasFees.token = config.networkMap.get(fromChainId)?.nativeCurrency;
|
|
31309
|
+
};
|
|
31310
|
+
let bridgeFees = {
|
|
31311
|
+
bridgeFee: {},
|
|
31312
|
+
bridgeable: false,
|
|
31313
|
+
};
|
|
31314
|
+
const getBridgeFees = async () => {
|
|
31315
|
+
const tokenBridge = await createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
|
|
31316
|
+
bridgeFees = await getBridgeFeeEstimate$1(tokenBridge, fromAddress);
|
|
31317
|
+
};
|
|
31318
|
+
await Promise.all([
|
|
31319
|
+
getGasFees(),
|
|
31320
|
+
getBridgeFees(),
|
|
31321
|
+
]);
|
|
31330
31322
|
return {
|
|
31331
31323
|
gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
|
|
31332
|
-
gasFee,
|
|
31324
|
+
gasFee: gasFees,
|
|
31333
31325
|
bridgeFee: {
|
|
31334
|
-
estimatedAmount: bridgeFee?.estimatedAmount,
|
|
31335
|
-
token: bridgeFee?.token,
|
|
31326
|
+
estimatedAmount: bridgeFees.bridgeFee?.estimatedAmount,
|
|
31327
|
+
token: bridgeFees.bridgeFee?.token,
|
|
31336
31328
|
},
|
|
31337
|
-
bridgeable,
|
|
31329
|
+
bridgeable: bridgeFees.bridgeable,
|
|
31338
31330
|
};
|
|
31339
31331
|
}
|
|
31340
31332
|
catch {
|
|
@@ -31390,7 +31382,7 @@ async function swapGasEstimator(config) {
|
|
|
31390
31382
|
async function gasEstimator(params, readOnlyProviders, config) {
|
|
31391
31383
|
switch (params.gasEstimateType) {
|
|
31392
31384
|
case GasEstimateType.BRIDGE_TO_L2:
|
|
31393
|
-
return await bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired
|
|
31385
|
+
return await bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired);
|
|
31394
31386
|
case GasEstimateType.SWAP:
|
|
31395
31387
|
return await swapGasEstimator(config);
|
|
31396
31388
|
default:
|
|
@@ -34008,7 +34000,7 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
34008
34000
|
return itemRequirements;
|
|
34009
34001
|
}
|
|
34010
34002
|
|
|
34011
|
-
const SDK_VERSION_MARKER = '0.30.
|
|
34003
|
+
const SDK_VERSION_MARKER = '0.30.4';
|
|
34012
34004
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
34013
34005
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
34014
34006
|
|
package/dist/passport.js
CHANGED
|
@@ -2191,7 +2191,7 @@ class MultiRollupApiClients {
|
|
|
2191
2191
|
}
|
|
2192
2192
|
|
|
2193
2193
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2194
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.30.
|
|
2194
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.30.4' };
|
|
2195
2195
|
const createConfig = ({ basePath, headers, }) => {
|
|
2196
2196
|
if (!basePath.trim()) {
|
|
2197
2197
|
throw Error('basePath can not be empty');
|
|
@@ -2247,7 +2247,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2247
2247
|
chainID,
|
|
2248
2248
|
coreContractAddress,
|
|
2249
2249
|
registrationContractAddress,
|
|
2250
|
-
sdkVersion: 'ts-immutable-sdk-0.30.
|
|
2250
|
+
sdkVersion: 'ts-immutable-sdk-0.30.4',
|
|
2251
2251
|
});
|
|
2252
2252
|
/**
|
|
2253
2253
|
* Sets `sdkVersion` at the time of build
|
|
@@ -7000,10 +7000,7 @@ class AuthManager {
|
|
|
7000
7000
|
try {
|
|
7001
7001
|
const tokenResponse = await this.getDeviceFlowToken(deviceCode);
|
|
7002
7002
|
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
7003
|
-
|
|
7004
|
-
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
7005
|
-
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
7006
|
-
}
|
|
7003
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
7007
7004
|
return user;
|
|
7008
7005
|
}
|
|
7009
7006
|
catch (error) {
|
|
@@ -7075,10 +7072,7 @@ class AuthManager {
|
|
|
7075
7072
|
}
|
|
7076
7073
|
const tokenResponse = await this.getPKCEToken(authorizationCode, pkceData.verifier);
|
|
7077
7074
|
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
7078
|
-
|
|
7079
|
-
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
7080
|
-
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
7081
|
-
}
|
|
7075
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
7082
7076
|
return user;
|
|
7083
7077
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
7084
7078
|
}
|
package/package.json
CHANGED