@imtbl/sdk 0.36.1-alpha.1 → 0.36.2-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.d.ts +138 -57
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +3 -3
- package/dist/browser/checkout/widgets.js +51 -51
- package/dist/checkout.d.ts +17 -16
- package/dist/checkout.js +144 -71
- 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 +146 -73
- package/dist/index.d.ts +155 -73
- package/dist/index.js +146 -73
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4256,7 +4256,7 @@ class MultiRollupApiClients {
|
|
|
4256
4256
|
}
|
|
4257
4257
|
|
|
4258
4258
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4259
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.
|
|
4259
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.2-alpha.1' };
|
|
4260
4260
|
const createConfig = ({ basePath, headers, }) => {
|
|
4261
4261
|
if (!basePath.trim()) {
|
|
4262
4262
|
throw Error('basePath can not be empty');
|
|
@@ -4316,7 +4316,7 @@ class APIError extends Error {
|
|
|
4316
4316
|
|
|
4317
4317
|
/* eslint-disable implicit-arrow-linebreak */
|
|
4318
4318
|
const defaultHeaders = {
|
|
4319
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.
|
|
4319
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.2-alpha.1',
|
|
4320
4320
|
};
|
|
4321
4321
|
/**
|
|
4322
4322
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4755,7 +4755,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4755
4755
|
chainID,
|
|
4756
4756
|
coreContractAddress,
|
|
4757
4757
|
registrationContractAddress,
|
|
4758
|
-
sdkVersion: 'ts-immutable-sdk-0.36.
|
|
4758
|
+
sdkVersion: 'ts-immutable-sdk-0.36.2-alpha.1',
|
|
4759
4759
|
});
|
|
4760
4760
|
/**
|
|
4761
4761
|
* Sets `sdkVersion` at the time of build
|
|
@@ -26775,59 +26775,18 @@ function parseUnits(value, unitName) {
|
|
|
26775
26775
|
return parseFixed(value, (unitName != null) ? unitName : 18);
|
|
26776
26776
|
}
|
|
26777
26777
|
|
|
26778
|
-
/**
|
|
26779
|
-
* @typedef {Object} CompletionStatus
|
|
26780
|
-
* @property {string} SUCCESS - The transaction has been successfully synced.
|
|
26781
|
-
* @property {string} PENDING - The transaction is still pending.
|
|
26782
|
-
* @property {string} FAILED - The transaction has failed.
|
|
26783
|
-
*/
|
|
26784
|
-
var CompletionStatus;
|
|
26785
|
-
(function (CompletionStatus) {
|
|
26786
|
-
CompletionStatus["SUCCESS"] = "SUCCESS";
|
|
26787
|
-
CompletionStatus["PENDING"] = "PENDING";
|
|
26788
|
-
CompletionStatus["FAILED"] = "FAILED";
|
|
26789
|
-
})(CompletionStatus || (CompletionStatus = {}));
|
|
26790
|
-
/**
|
|
26791
|
-
* @typedef {Object} BridgeFeeActions
|
|
26792
|
-
* @property {string} DEPOSIT - The transaction has been successfully synced.
|
|
26793
|
-
* @property {string} WITHDRAW - The transaction is still pending.
|
|
26794
|
-
* @property {string} FINALISE_WITHDRAWAL - Calculate gas .
|
|
26795
|
-
*/
|
|
26796
|
-
var BridgeFeeActions;
|
|
26797
|
-
(function (BridgeFeeActions) {
|
|
26798
|
-
BridgeFeeActions["DEPOSIT"] = "DEPOSIT";
|
|
26799
|
-
BridgeFeeActions["WITHDRAW"] = "WITHDRAW";
|
|
26800
|
-
BridgeFeeActions["FINALISE_WITHDRAWAL"] = "FINALISE_WITHDRAWAL";
|
|
26801
|
-
})(BridgeFeeActions || (BridgeFeeActions = {}));
|
|
26802
|
-
/**
|
|
26803
|
-
* @typedef {Object} BridgeMethodGas
|
|
26804
|
-
* @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
|
|
26805
|
-
* @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
|
|
26806
|
-
* @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
|
|
26807
|
-
* @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
|
|
26808
|
-
* @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
|
|
26809
|
-
*/
|
|
26810
|
-
var BridgeMethodsGasLimit;
|
|
26811
|
-
(function (BridgeMethodsGasLimit) {
|
|
26812
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
|
|
26813
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
|
|
26814
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
|
|
26815
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
|
|
26816
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
|
|
26817
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
|
|
26818
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
26819
|
-
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
26820
|
-
var StatusResponse;
|
|
26821
|
-
(function (StatusResponse) {
|
|
26822
|
-
StatusResponse["PROCESSING"] = "PROCESSING";
|
|
26823
|
-
StatusResponse["COMPLETE"] = "COMPLETE";
|
|
26824
|
-
StatusResponse["RETRY"] = "RETRY";
|
|
26825
|
-
StatusResponse["ERROR"] = "ERROR";
|
|
26826
|
-
StatusResponse["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
|
|
26827
|
-
StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
|
|
26828
|
-
})(StatusResponse || (StatusResponse = {}));
|
|
26829
|
-
|
|
26830
26778
|
const ROOT_ERC20_BRIDGE_FLOW_RATE = [
|
|
26779
|
+
{
|
|
26780
|
+
inputs: [
|
|
26781
|
+
{
|
|
26782
|
+
internalType: 'address',
|
|
26783
|
+
name: '_initializerAddress',
|
|
26784
|
+
type: 'address',
|
|
26785
|
+
},
|
|
26786
|
+
],
|
|
26787
|
+
stateMutability: 'nonpayable',
|
|
26788
|
+
type: 'constructor',
|
|
26789
|
+
},
|
|
26831
26790
|
{
|
|
26832
26791
|
inputs: [],
|
|
26833
26792
|
name: 'AlreadyMapped',
|
|
@@ -26978,6 +26937,16 @@ const ROOT_ERC20_BRIDGE_FLOW_RATE = [
|
|
|
26978
26937
|
name: 'TokenIsZero',
|
|
26979
26938
|
type: 'error',
|
|
26980
26939
|
},
|
|
26940
|
+
{
|
|
26941
|
+
inputs: [],
|
|
26942
|
+
name: 'TokenNotSupported',
|
|
26943
|
+
type: 'error',
|
|
26944
|
+
},
|
|
26945
|
+
{
|
|
26946
|
+
inputs: [],
|
|
26947
|
+
name: 'UnauthorizedInitializer',
|
|
26948
|
+
type: 'error',
|
|
26949
|
+
},
|
|
26981
26950
|
{
|
|
26982
26951
|
inputs: [
|
|
26983
26952
|
{
|
|
@@ -28401,6 +28370,19 @@ const ROOT_ERC20_BRIDGE_FLOW_RATE = [
|
|
|
28401
28370
|
stateMutability: 'pure',
|
|
28402
28371
|
type: 'function',
|
|
28403
28372
|
},
|
|
28373
|
+
{
|
|
28374
|
+
inputs: [],
|
|
28375
|
+
name: 'initializerAddress',
|
|
28376
|
+
outputs: [
|
|
28377
|
+
{
|
|
28378
|
+
internalType: 'address',
|
|
28379
|
+
name: '',
|
|
28380
|
+
type: 'address',
|
|
28381
|
+
},
|
|
28382
|
+
],
|
|
28383
|
+
stateMutability: 'view',
|
|
28384
|
+
type: 'function',
|
|
28385
|
+
},
|
|
28404
28386
|
{
|
|
28405
28387
|
inputs: [
|
|
28406
28388
|
{
|
|
@@ -29097,6 +29079,17 @@ const withBridgeError = async (fn, customErrorType, details) => {
|
|
|
29097
29079
|
};
|
|
29098
29080
|
|
|
29099
29081
|
const CHILD_ERC20_BRIDGE = [
|
|
29082
|
+
{
|
|
29083
|
+
inputs: [
|
|
29084
|
+
{
|
|
29085
|
+
internalType: 'address',
|
|
29086
|
+
name: '_initializerAddress',
|
|
29087
|
+
type: 'address',
|
|
29088
|
+
},
|
|
29089
|
+
],
|
|
29090
|
+
stateMutability: 'nonpayable',
|
|
29091
|
+
type: 'constructor',
|
|
29092
|
+
},
|
|
29100
29093
|
{
|
|
29101
29094
|
inputs: [],
|
|
29102
29095
|
name: 'AlreadyMapped',
|
|
@@ -29199,6 +29192,11 @@ const CHILD_ERC20_BRIDGE = [
|
|
|
29199
29192
|
name: 'TransferWIMXFailed',
|
|
29200
29193
|
type: 'error',
|
|
29201
29194
|
},
|
|
29195
|
+
{
|
|
29196
|
+
inputs: [],
|
|
29197
|
+
name: 'UnauthorizedInitializer',
|
|
29198
|
+
type: 'error',
|
|
29199
|
+
},
|
|
29202
29200
|
{
|
|
29203
29201
|
inputs: [],
|
|
29204
29202
|
name: 'ZeroAddress',
|
|
@@ -29953,6 +29951,19 @@ const CHILD_ERC20_BRIDGE = [
|
|
|
29953
29951
|
stateMutability: 'nonpayable',
|
|
29954
29952
|
type: 'function',
|
|
29955
29953
|
},
|
|
29954
|
+
{
|
|
29955
|
+
inputs: [],
|
|
29956
|
+
name: 'initializerAddress',
|
|
29957
|
+
outputs: [
|
|
29958
|
+
{
|
|
29959
|
+
internalType: 'address',
|
|
29960
|
+
name: '',
|
|
29961
|
+
type: 'address',
|
|
29962
|
+
},
|
|
29963
|
+
],
|
|
29964
|
+
stateMutability: 'view',
|
|
29965
|
+
type: 'function',
|
|
29966
|
+
},
|
|
29956
29967
|
{
|
|
29957
29968
|
inputs: [
|
|
29958
29969
|
{
|
|
@@ -30302,6 +30313,58 @@ const getGasPriceInWei$1 = (feeData) => {
|
|
|
30302
30313
|
return null;
|
|
30303
30314
|
};
|
|
30304
30315
|
|
|
30316
|
+
/**
|
|
30317
|
+
* @typedef {Object} CompletionStatus
|
|
30318
|
+
* @property {string} SUCCESS - The transaction has been successfully synced.
|
|
30319
|
+
* @property {string} PENDING - The transaction is still pending.
|
|
30320
|
+
* @property {string} FAILED - The transaction has failed.
|
|
30321
|
+
*/
|
|
30322
|
+
var CompletionStatus;
|
|
30323
|
+
(function (CompletionStatus) {
|
|
30324
|
+
CompletionStatus["SUCCESS"] = "SUCCESS";
|
|
30325
|
+
CompletionStatus["PENDING"] = "PENDING";
|
|
30326
|
+
CompletionStatus["FAILED"] = "FAILED";
|
|
30327
|
+
})(CompletionStatus || (CompletionStatus = {}));
|
|
30328
|
+
/**
|
|
30329
|
+
* @typedef {Object} BridgeFeeActions
|
|
30330
|
+
* @property {string} DEPOSIT - The transaction has been successfully synced.
|
|
30331
|
+
* @property {string} WITHDRAW - The transaction is still pending.
|
|
30332
|
+
* @property {string} FINALISE_WITHDRAWAL - Calculate gas .
|
|
30333
|
+
*/
|
|
30334
|
+
var BridgeFeeActions;
|
|
30335
|
+
(function (BridgeFeeActions) {
|
|
30336
|
+
BridgeFeeActions["DEPOSIT"] = "DEPOSIT";
|
|
30337
|
+
BridgeFeeActions["WITHDRAW"] = "WITHDRAW";
|
|
30338
|
+
BridgeFeeActions["FINALISE_WITHDRAWAL"] = "FINALISE_WITHDRAWAL";
|
|
30339
|
+
})(BridgeFeeActions || (BridgeFeeActions = {}));
|
|
30340
|
+
/**
|
|
30341
|
+
* @typedef {Object} BridgeMethodGas
|
|
30342
|
+
* @property {string} DEPOSIT_SOURCE - The gas required to deposit to the bridge.
|
|
30343
|
+
* @property {string} DEPOSIT_DESTINATION - The gas required to process the deposit on the destination chain.
|
|
30344
|
+
* @property {string} WITHDRAW_SOURCE - The gas required to withdraw from the bridge.
|
|
30345
|
+
* @property {string} WITHDRAW_DESTINATION - The gas required to process the withdrawal on the destination chain.
|
|
30346
|
+
* @property {string} FINALISE_WITHDRAWAL - The gas required to finalise a withdrawal from the flow rate queue.
|
|
30347
|
+
*/
|
|
30348
|
+
var BridgeMethodsGasLimit;
|
|
30349
|
+
(function (BridgeMethodsGasLimit) {
|
|
30350
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 500000] = "DEPOSIT_SOURCE";
|
|
30351
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 700000] = "DEPOSIT_DESTINATION";
|
|
30352
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 400000] = "WITHDRAW_SOURCE";
|
|
30353
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 700000] = "WITHDRAW_DESTINATION";
|
|
30354
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 300000] = "MAP_TOKEN_SOURCE";
|
|
30355
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 700000] = "MAP_TOKEN_DESTINATION";
|
|
30356
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
30357
|
+
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
30358
|
+
var StatusResponse;
|
|
30359
|
+
(function (StatusResponse) {
|
|
30360
|
+
StatusResponse["PROCESSING"] = "PROCESSING";
|
|
30361
|
+
StatusResponse["COMPLETE"] = "COMPLETE";
|
|
30362
|
+
StatusResponse["RETRY"] = "RETRY";
|
|
30363
|
+
StatusResponse["ERROR"] = "ERROR";
|
|
30364
|
+
StatusResponse["NOT_ENOUGH_GAS"] = "NOT_ENOUGH_GAS";
|
|
30365
|
+
StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
|
|
30366
|
+
})(StatusResponse || (StatusResponse = {}));
|
|
30367
|
+
|
|
30305
30368
|
/* eslint-disable class-methods-use-this */
|
|
30306
30369
|
/**
|
|
30307
30370
|
* Represents a token bridge, which manages asset transfers between two chains.
|
|
@@ -30922,8 +30985,8 @@ const CONTRACTS_FOR_BRIDGE = new Map()
|
|
|
30922
30985
|
wrappedIMX: '0x0',
|
|
30923
30986
|
})
|
|
30924
30987
|
.set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
|
|
30925
|
-
rootERC20BridgeFlowRate: '
|
|
30926
|
-
childERC20Bridge: '
|
|
30988
|
+
rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
|
|
30989
|
+
childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
|
|
30927
30990
|
wrappedIMX: '0xa86C6C6d3D51c0592BE85dA05A9b06B62360D56E',
|
|
30928
30991
|
})
|
|
30929
30992
|
.set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
|
|
@@ -34807,6 +34870,7 @@ var ExchangeType;
|
|
|
34807
34870
|
*/
|
|
34808
34871
|
var CheckoutErrorType;
|
|
34809
34872
|
(function (CheckoutErrorType) {
|
|
34873
|
+
CheckoutErrorType["MISSING_PARAMS"] = "MISSING_PARAMS";
|
|
34810
34874
|
CheckoutErrorType["WEB3_PROVIDER_ERROR"] = "WEB3_PROVIDER_ERROR";
|
|
34811
34875
|
CheckoutErrorType["PROVIDER_ERROR"] = "PROVIDER_ERROR";
|
|
34812
34876
|
CheckoutErrorType["DEFAULT_PROVIDER_ERROR"] = "DEFAULT_PROVIDER_ERROR";
|
|
@@ -35168,7 +35232,7 @@ const BLOCKSCOUT_CHAIN_URL_MAP = {
|
|
|
35168
35232
|
nativeToken: SANDBOX_CHAIN_ID_NETWORK_MAP.get(ChainId.IMTBL_ZKEVM_TESTNET).nativeCurrency,
|
|
35169
35233
|
},
|
|
35170
35234
|
[ChainId.IMTBL_ZKEVM_MAINNET]: {
|
|
35171
|
-
url: 'https://explorer.
|
|
35235
|
+
url: 'https://explorer.immutable.com',
|
|
35172
35236
|
nativeToken: PRODUCTION_CHAIN_ID_NETWORK_MAP.get(ChainId.IMTBL_ZKEVM_MAINNET).nativeCurrency,
|
|
35173
35237
|
},
|
|
35174
35238
|
[ChainId.SEPOLIA]: {
|
|
@@ -35380,7 +35444,7 @@ const GAS_OVERRIDES = {
|
|
|
35380
35444
|
maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
|
|
35381
35445
|
};
|
|
35382
35446
|
|
|
35383
|
-
const SDK_VERSION_MARKER = '0.36.
|
|
35447
|
+
const SDK_VERSION_MARKER = '0.36.2-alpha.1';
|
|
35384
35448
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
35385
35449
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
35386
35450
|
|
|
@@ -35707,9 +35771,9 @@ const getBalance = async (config, web3Provider, walletAddress) => await withChec
|
|
|
35707
35771
|
token: networkInfo.nativeCurrency,
|
|
35708
35772
|
};
|
|
35709
35773
|
}, { type: CheckoutErrorType.GET_BALANCE_ERROR });
|
|
35710
|
-
async function getERC20Balance(web3Provider, walletAddress,
|
|
35774
|
+
async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
|
|
35711
35775
|
return await withCheckoutError(async () => {
|
|
35712
|
-
const contract = new ethers.Contract(
|
|
35776
|
+
const contract = new ethers.Contract(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
35713
35777
|
return Promise.all([
|
|
35714
35778
|
contract.name(),
|
|
35715
35779
|
contract.symbol(),
|
|
@@ -35725,7 +35789,7 @@ async function getERC20Balance(web3Provider, walletAddress, contractAddress) {
|
|
|
35725
35789
|
name,
|
|
35726
35790
|
symbol,
|
|
35727
35791
|
decimals,
|
|
35728
|
-
address:
|
|
35792
|
+
address: tokenAddress,
|
|
35729
35793
|
},
|
|
35730
35794
|
};
|
|
35731
35795
|
});
|
|
@@ -35836,8 +35900,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
35836
35900
|
return { balances };
|
|
35837
35901
|
};
|
|
35838
35902
|
const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
35839
|
-
|
|
35840
|
-
|
|
35903
|
+
if (!walletAddress && !web3Provider) {
|
|
35904
|
+
throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
|
|
35905
|
+
}
|
|
35841
35906
|
const { tokens } = await getTokenAllowList(config, {
|
|
35842
35907
|
type: TokenFilterTypes.ALL,
|
|
35843
35908
|
chainId,
|
|
@@ -35853,6 +35918,7 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
|
35853
35918
|
// eslint-disable-next-line no-console
|
|
35854
35919
|
console.error(err);
|
|
35855
35920
|
}
|
|
35921
|
+
let address = walletAddress;
|
|
35856
35922
|
if (flag && Blockscout.isChainSupported(chainId)) {
|
|
35857
35923
|
// This is a hack because the widgets are still using the tokens symbol
|
|
35858
35924
|
// to drive the conversions. If we remove all the token symbols from e.g. zkevm
|
|
@@ -35860,12 +35926,18 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
|
35860
35926
|
// Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
|
|
35861
35927
|
// is done.
|
|
35862
35928
|
const isL1Chain = getL1ChainId(config) === chainId;
|
|
35863
|
-
|
|
35929
|
+
if (!address)
|
|
35930
|
+
address = await web3Provider?.getSigner().getAddress();
|
|
35931
|
+
return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(address, chainId, isL1Chain ? tokens : undefined));
|
|
35932
|
+
}
|
|
35933
|
+
if (!web3Provider) {
|
|
35934
|
+
throw new CheckoutError('indexer is disabled for this chain, you must provide a provider.', CheckoutErrorType.MISSING_PARAMS);
|
|
35864
35935
|
}
|
|
35865
35936
|
// This fallback to use ERC20s calls which is a best effort solution
|
|
35866
35937
|
// Fails in fetching data from the RCP calls might result in some
|
|
35867
35938
|
// missing data.
|
|
35868
|
-
|
|
35939
|
+
address ||= await web3Provider.getSigner().getAddress();
|
|
35940
|
+
return await measureAsyncExecution(config, `Time to fetch balances using RPC for ${chainId}`, getBalances(config, web3Provider, address, tokens));
|
|
35869
35941
|
};
|
|
35870
35942
|
|
|
35871
35943
|
async function checkIsWalletConnected(web3Provider) {
|
|
@@ -37392,14 +37464,16 @@ const getEthBalance = (balances) => {
|
|
|
37392
37464
|
const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toChainId) => {
|
|
37393
37465
|
const bridge = createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
|
|
37394
37466
|
try {
|
|
37395
|
-
const
|
|
37467
|
+
const bridgeFeeResponse = await bridge.getFee({
|
|
37396
37468
|
action: BridgeFeeActions.DEPOSIT,
|
|
37397
37469
|
gasMultiplier: 1.1,
|
|
37398
37470
|
sourceChainId: fromChainId.toString(),
|
|
37399
37471
|
destinationChainId: toChainId.toString(),
|
|
37400
37472
|
});
|
|
37401
|
-
|
|
37402
|
-
|
|
37473
|
+
return {
|
|
37474
|
+
...bridgeFeeResponse,
|
|
37475
|
+
approvalGas: ethers.BigNumber.from(0),
|
|
37476
|
+
};
|
|
37403
37477
|
}
|
|
37404
37478
|
catch (err) {
|
|
37405
37479
|
throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { message: err.message });
|
|
@@ -38937,10 +39011,10 @@ class Checkout {
|
|
|
38937
39011
|
*/
|
|
38938
39012
|
async getBalance(params) {
|
|
38939
39013
|
const web3Provider = await validateProvider(this.config, params.provider);
|
|
38940
|
-
if (!params.
|
|
39014
|
+
if (!params.tokenAddress || params.tokenAddress === '') {
|
|
38941
39015
|
return await getBalance(this.config, web3Provider, params.walletAddress);
|
|
38942
39016
|
}
|
|
38943
|
-
return await getERC20Balance(web3Provider, params.walletAddress, params.
|
|
39017
|
+
return await getERC20Balance(web3Provider, params.walletAddress, params.tokenAddress);
|
|
38944
39018
|
}
|
|
38945
39019
|
/**
|
|
38946
39020
|
* Retrieves the balances of all tokens for a given wallet address on a specific chain.
|
|
@@ -38948,8 +39022,7 @@ class Checkout {
|
|
|
38948
39022
|
* @returns {Promise<GetAllBalancesResult>} - A promise that resolves to the result of retrieving the balances.
|
|
38949
39023
|
*/
|
|
38950
39024
|
async getAllBalances(params) {
|
|
38951
|
-
|
|
38952
|
-
return getAllBalances(this.config, web3Provider, params.walletAddress, params.chainId);
|
|
39025
|
+
return getAllBalances(this.config, params.provider, params.walletAddress, params.chainId);
|
|
38953
39026
|
}
|
|
38954
39027
|
/**
|
|
38955
39028
|
* Retrieves the supported networks based on the provided parameters.
|