@imtbl/sdk 0.4.1-alpha → 0.4.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 +126 -48
- package/dist/blockchain-data.js +34 -32
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +0 -11
- package/dist/checkout_sdk.js +2970 -346
- 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 +2977 -351
- package/dist/index.d.ts +126 -59
- package/dist/index.js +2978 -352
- package/dist/passport.js +14 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3361,7 +3361,7 @@ let Configuration$1 = class Configuration {
|
|
|
3361
3361
|
/* tslint:disable */
|
|
3362
3362
|
/* eslint-disable */
|
|
3363
3363
|
/**
|
|
3364
|
-
* Immutable
|
|
3364
|
+
* Immutable zkEVM API
|
|
3365
3365
|
* Immutable Multi Rollup API
|
|
3366
3366
|
*
|
|
3367
3367
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -3373,7 +3373,7 @@ let Configuration$1 = class Configuration {
|
|
|
3373
3373
|
*/
|
|
3374
3374
|
// Some imports not used depending on template conditions
|
|
3375
3375
|
// @ts-ignore
|
|
3376
|
-
const BASE_PATH$1 = "https://
|
|
3376
|
+
const BASE_PATH$1 = "https://api.sandbox.immutable.com".replace(/\/+$/, "");
|
|
3377
3377
|
/**
|
|
3378
3378
|
*
|
|
3379
3379
|
* @export
|
|
@@ -3410,7 +3410,7 @@ let RequiredError$1 = class RequiredError extends Error {
|
|
|
3410
3410
|
/* tslint:disable */
|
|
3411
3411
|
/* eslint-disable */
|
|
3412
3412
|
/**
|
|
3413
|
-
* Immutable
|
|
3413
|
+
* Immutable zkEVM API
|
|
3414
3414
|
* Immutable Multi Rollup API
|
|
3415
3415
|
*
|
|
3416
3416
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -3508,7 +3508,7 @@ const createRequestFunction$1 = function (axiosArgs, globalAxios, BASE_PATH, con
|
|
|
3508
3508
|
/* tslint:disable */
|
|
3509
3509
|
/* eslint-disable */
|
|
3510
3510
|
/**
|
|
3511
|
-
* Immutable
|
|
3511
|
+
* Immutable zkEVM API
|
|
3512
3512
|
* Immutable Multi Rollup API
|
|
3513
3513
|
*
|
|
3514
3514
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -3742,7 +3742,7 @@ class ActivitiesApi extends BaseAPI$1 {
|
|
|
3742
3742
|
/* tslint:disable */
|
|
3743
3743
|
/* eslint-disable */
|
|
3744
3744
|
/**
|
|
3745
|
-
* Immutable
|
|
3745
|
+
* Immutable zkEVM API
|
|
3746
3746
|
* Immutable Multi Rollup API
|
|
3747
3747
|
*
|
|
3748
3748
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -3857,7 +3857,7 @@ class ChainsApi extends BaseAPI$1 {
|
|
|
3857
3857
|
/* tslint:disable */
|
|
3858
3858
|
/* eslint-disable */
|
|
3859
3859
|
/**
|
|
3860
|
-
* Immutable
|
|
3860
|
+
* Immutable zkEVM API
|
|
3861
3861
|
* Immutable Multi Rollup API
|
|
3862
3862
|
*
|
|
3863
3863
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -4045,7 +4045,7 @@ class CollectionsApi extends BaseAPI$1 {
|
|
|
4045
4045
|
/* tslint:disable */
|
|
4046
4046
|
/* eslint-disable */
|
|
4047
4047
|
/**
|
|
4048
|
-
* Immutable
|
|
4048
|
+
* Immutable zkEVM API
|
|
4049
4049
|
* Immutable Multi Rollup API
|
|
4050
4050
|
*
|
|
4051
4051
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -4178,7 +4178,7 @@ class NftOwnersApi extends BaseAPI$1 {
|
|
|
4178
4178
|
/* tslint:disable */
|
|
4179
4179
|
/* eslint-disable */
|
|
4180
4180
|
/**
|
|
4181
|
-
* Immutable
|
|
4181
|
+
* Immutable zkEVM API
|
|
4182
4182
|
* Immutable Multi Rollup API
|
|
4183
4183
|
*
|
|
4184
4184
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -4463,7 +4463,7 @@ class NftsApi extends BaseAPI$1 {
|
|
|
4463
4463
|
/* tslint:disable */
|
|
4464
4464
|
/* eslint-disable */
|
|
4465
4465
|
/**
|
|
4466
|
-
* Immutable
|
|
4466
|
+
* Immutable zkEVM API
|
|
4467
4467
|
* Immutable Multi Rollup API
|
|
4468
4468
|
*
|
|
4469
4469
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -4755,7 +4755,7 @@ class OrdersApi extends BaseAPI$1 {
|
|
|
4755
4755
|
/* tslint:disable */
|
|
4756
4756
|
/* eslint-disable */
|
|
4757
4757
|
/**
|
|
4758
|
-
* Immutable
|
|
4758
|
+
* Immutable zkEVM API
|
|
4759
4759
|
* Immutable Multi Rollup API
|
|
4760
4760
|
*
|
|
4761
4761
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -4868,7 +4868,7 @@ class PassportApi extends BaseAPI$1 {
|
|
|
4868
4868
|
/* tslint:disable */
|
|
4869
4869
|
/* eslint-disable */
|
|
4870
4870
|
/**
|
|
4871
|
-
* Immutable
|
|
4871
|
+
* Immutable zkEVM API
|
|
4872
4872
|
* Immutable Multi Rollup API
|
|
4873
4873
|
*
|
|
4874
4874
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5056,7 +5056,7 @@ class TokensApi extends BaseAPI$1 {
|
|
|
5056
5056
|
/* tslint:disable */
|
|
5057
5057
|
/* eslint-disable */
|
|
5058
5058
|
/**
|
|
5059
|
-
* Immutable
|
|
5059
|
+
* Immutable zkEVM API
|
|
5060
5060
|
* Immutable Multi Rollup API
|
|
5061
5061
|
*
|
|
5062
5062
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5144,7 +5144,7 @@ let Configuration$2 = class Configuration {
|
|
|
5144
5144
|
/* tslint:disable */
|
|
5145
5145
|
/* eslint-disable */
|
|
5146
5146
|
/**
|
|
5147
|
-
* Immutable
|
|
5147
|
+
* Immutable zkEVM API
|
|
5148
5148
|
* Immutable Multi Rollup API
|
|
5149
5149
|
*
|
|
5150
5150
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5161,7 +5161,7 @@ const APIError400AllOfCodeEnum = {
|
|
|
5161
5161
|
/* tslint:disable */
|
|
5162
5162
|
/* eslint-disable */
|
|
5163
5163
|
/**
|
|
5164
|
-
* Immutable
|
|
5164
|
+
* Immutable zkEVM API
|
|
5165
5165
|
* Immutable Multi Rollup API
|
|
5166
5166
|
*
|
|
5167
5167
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5178,7 +5178,7 @@ const APIError401AllOfCodeEnum = {
|
|
|
5178
5178
|
/* tslint:disable */
|
|
5179
5179
|
/* eslint-disable */
|
|
5180
5180
|
/**
|
|
5181
|
-
* Immutable
|
|
5181
|
+
* Immutable zkEVM API
|
|
5182
5182
|
* Immutable Multi Rollup API
|
|
5183
5183
|
*
|
|
5184
5184
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5195,7 +5195,7 @@ const APIError403AllOfCodeEnum = {
|
|
|
5195
5195
|
/* tslint:disable */
|
|
5196
5196
|
/* eslint-disable */
|
|
5197
5197
|
/**
|
|
5198
|
-
* Immutable
|
|
5198
|
+
* Immutable zkEVM API
|
|
5199
5199
|
* Immutable Multi Rollup API
|
|
5200
5200
|
*
|
|
5201
5201
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5212,7 +5212,7 @@ const APIError404AllOfCodeEnum = {
|
|
|
5212
5212
|
/* tslint:disable */
|
|
5213
5213
|
/* eslint-disable */
|
|
5214
5214
|
/**
|
|
5215
|
-
* Immutable
|
|
5215
|
+
* Immutable zkEVM API
|
|
5216
5216
|
* Immutable Multi Rollup API
|
|
5217
5217
|
*
|
|
5218
5218
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5229,7 +5229,7 @@ const APIError429AllOfCodeEnum = {
|
|
|
5229
5229
|
/* tslint:disable */
|
|
5230
5230
|
/* eslint-disable */
|
|
5231
5231
|
/**
|
|
5232
|
-
* Immutable
|
|
5232
|
+
* Immutable zkEVM API
|
|
5233
5233
|
* Immutable Multi Rollup API
|
|
5234
5234
|
*
|
|
5235
5235
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5246,7 +5246,7 @@ const APIError500AllOfCodeEnum = {
|
|
|
5246
5246
|
/* tslint:disable */
|
|
5247
5247
|
/* eslint-disable */
|
|
5248
5248
|
/**
|
|
5249
|
-
* Immutable
|
|
5249
|
+
* Immutable zkEVM API
|
|
5250
5250
|
* Immutable Multi Rollup API
|
|
5251
5251
|
*
|
|
5252
5252
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5265,13 +5265,15 @@ const ActivityType = {
|
|
|
5265
5265
|
Mint: 'mint',
|
|
5266
5266
|
Burn: 'burn',
|
|
5267
5267
|
Transfer: 'transfer',
|
|
5268
|
-
Sale: 'sale'
|
|
5268
|
+
Sale: 'sale',
|
|
5269
|
+
Deposit: 'deposit',
|
|
5270
|
+
Withdrawal: 'withdrawal'
|
|
5269
5271
|
};
|
|
5270
5272
|
|
|
5271
5273
|
/* tslint:disable */
|
|
5272
5274
|
/* eslint-disable */
|
|
5273
5275
|
/**
|
|
5274
|
-
* Immutable
|
|
5276
|
+
* Immutable zkEVM API
|
|
5275
5277
|
* Immutable Multi Rollup API
|
|
5276
5278
|
*
|
|
5277
5279
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5293,7 +5295,7 @@ const CollectionContractType = {
|
|
|
5293
5295
|
/* tslint:disable */
|
|
5294
5296
|
/* eslint-disable */
|
|
5295
5297
|
/**
|
|
5296
|
-
* Immutable
|
|
5298
|
+
* Immutable zkEVM API
|
|
5297
5299
|
* Immutable Multi Rollup API
|
|
5298
5300
|
*
|
|
5299
5301
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5310,7 +5312,7 @@ const CreateOrderProtocolDataOrderTypeEnum = {
|
|
|
5310
5312
|
/* tslint:disable */
|
|
5311
5313
|
/* eslint-disable */
|
|
5312
5314
|
/**
|
|
5313
|
-
* Immutable
|
|
5315
|
+
* Immutable zkEVM API
|
|
5314
5316
|
* Immutable Multi Rollup API
|
|
5315
5317
|
*
|
|
5316
5318
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5327,7 +5329,7 @@ const ERC20ItemItemTypeEnum = {
|
|
|
5327
5329
|
/* tslint:disable */
|
|
5328
5330
|
/* eslint-disable */
|
|
5329
5331
|
/**
|
|
5330
|
-
* Immutable
|
|
5332
|
+
* Immutable zkEVM API
|
|
5331
5333
|
* Immutable Multi Rollup API
|
|
5332
5334
|
*
|
|
5333
5335
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5344,7 +5346,7 @@ const ERC721ItemItemTypeEnum = {
|
|
|
5344
5346
|
/* tslint:disable */
|
|
5345
5347
|
/* eslint-disable */
|
|
5346
5348
|
/**
|
|
5347
|
-
* Immutable
|
|
5349
|
+
* Immutable zkEVM API
|
|
5348
5350
|
* Immutable Multi Rollup API
|
|
5349
5351
|
*
|
|
5350
5352
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5361,7 +5363,7 @@ const FeeFeeTypeEnum = {
|
|
|
5361
5363
|
/* tslint:disable */
|
|
5362
5364
|
/* eslint-disable */
|
|
5363
5365
|
/**
|
|
5364
|
-
* Immutable
|
|
5366
|
+
* Immutable zkEVM API
|
|
5365
5367
|
* Immutable Multi Rollup API
|
|
5366
5368
|
*
|
|
5367
5369
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5383,7 +5385,7 @@ const NFTContractType = {
|
|
|
5383
5385
|
/* tslint:disable */
|
|
5384
5386
|
/* eslint-disable */
|
|
5385
5387
|
/**
|
|
5386
|
-
* Immutable
|
|
5388
|
+
* Immutable zkEVM API
|
|
5387
5389
|
* Immutable Multi Rollup API
|
|
5388
5390
|
*
|
|
5389
5391
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5400,7 +5402,7 @@ const NativeItemItemTypeEnum = {
|
|
|
5400
5402
|
/* tslint:disable */
|
|
5401
5403
|
/* eslint-disable */
|
|
5402
5404
|
/**
|
|
5403
|
-
* Immutable
|
|
5405
|
+
* Immutable zkEVM API
|
|
5404
5406
|
* Immutable Multi Rollup API
|
|
5405
5407
|
*
|
|
5406
5408
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5427,7 +5429,7 @@ const OrderStatus$1 = {
|
|
|
5427
5429
|
/* tslint:disable */
|
|
5428
5430
|
/* eslint-disable */
|
|
5429
5431
|
/**
|
|
5430
|
-
* Immutable
|
|
5432
|
+
* Immutable zkEVM API
|
|
5431
5433
|
* Immutable Multi Rollup API
|
|
5432
5434
|
*
|
|
5433
5435
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5444,7 +5446,7 @@ const SaleFeeTypeEnum = {
|
|
|
5444
5446
|
/* tslint:disable */
|
|
5445
5447
|
/* eslint-disable */
|
|
5446
5448
|
/**
|
|
5447
|
-
* Immutable
|
|
5449
|
+
* Immutable zkEVM API
|
|
5448
5450
|
* Immutable Multi Rollup API
|
|
5449
5451
|
*
|
|
5450
5452
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5466,7 +5468,7 @@ const TokenContractType = {
|
|
|
5466
5468
|
/* tslint:disable */
|
|
5467
5469
|
/* eslint-disable */
|
|
5468
5470
|
/**
|
|
5469
|
-
* Immutable
|
|
5471
|
+
* Immutable zkEVM API
|
|
5470
5472
|
* Immutable Multi Rollup API
|
|
5471
5473
|
*
|
|
5472
5474
|
* The version of the OpenAPI document: 1.0.0
|
|
@@ -5553,7 +5555,7 @@ class MultiRollupApiClients {
|
|
|
5553
5555
|
}
|
|
5554
5556
|
|
|
5555
5557
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5556
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.4.
|
|
5558
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.4.2-alpha.1' };
|
|
5557
5559
|
const createConfig = ({ basePath, headers, }) => {
|
|
5558
5560
|
if (!basePath.trim()) {
|
|
5559
5561
|
throw Error('basePath can not be empty');
|
|
@@ -5613,7 +5615,7 @@ class APIError extends Error {
|
|
|
5613
5615
|
|
|
5614
5616
|
/* eslint-disable implicit-arrow-linebreak */
|
|
5615
5617
|
const defaultHeaders = {
|
|
5616
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.
|
|
5618
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.2-alpha.1',
|
|
5617
5619
|
};
|
|
5618
5620
|
/**
|
|
5619
5621
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -5879,7 +5881,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
5879
5881
|
chainID,
|
|
5880
5882
|
coreContractAddress,
|
|
5881
5883
|
registrationContractAddress,
|
|
5882
|
-
sdkVersion: 'ts-immutable-sdk-0.4.
|
|
5884
|
+
sdkVersion: 'ts-immutable-sdk-0.4.2-alpha.1',
|
|
5883
5885
|
});
|
|
5884
5886
|
/**
|
|
5885
5887
|
* Sets `sdkVersion` at the time of build
|
|
@@ -11310,7 +11312,7 @@ class PassportConfiguration {
|
|
|
11310
11312
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
11311
11313
|
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
11312
11314
|
this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
|
|
11313
|
-
this.zkEvmRpcUrl = 'https://
|
|
11315
|
+
this.zkEvmRpcUrl = 'https://rpc.testnet.immutable.com';
|
|
11314
11316
|
this.zkEvmChainId = 'eip155:13392';
|
|
11315
11317
|
this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
|
|
11316
11318
|
this.multiRollupConfig = multiRollupConfig.getSandbox();
|
|
@@ -11695,7 +11697,7 @@ const chainIdNumber = (chainId) => {
|
|
|
11695
11697
|
const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
|
|
11696
11698
|
const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
|
|
11697
11699
|
const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, config, user, }) => {
|
|
11698
|
-
const popupWindowSize = { width: 480, height:
|
|
11700
|
+
const popupWindowSize = { width: 480, height: 520 };
|
|
11699
11701
|
guardianClient.loading(popupWindowSize);
|
|
11700
11702
|
const transactionRequest = params[0];
|
|
11701
11703
|
if (!transactionRequest.to) {
|
|
@@ -12985,7 +12987,7 @@ class ERC721 {
|
|
|
12985
12987
|
/* Autogenerated file. Do not edit manually. */
|
|
12986
12988
|
/* tslint:disable */
|
|
12987
12989
|
/* eslint-disable */
|
|
12988
|
-
const _abi$
|
|
12990
|
+
const _abi$5 = [
|
|
12989
12991
|
{
|
|
12990
12992
|
inputs: [
|
|
12991
12993
|
{
|
|
@@ -13874,12 +13876,12 @@ const _abi$3 = [
|
|
|
13874
13876
|
},
|
|
13875
13877
|
];
|
|
13876
13878
|
class ImmutableERC721Base__factory {
|
|
13877
|
-
static abi = _abi$
|
|
13879
|
+
static abi = _abi$5;
|
|
13878
13880
|
static createInterface() {
|
|
13879
|
-
return new ethers.utils.Interface(_abi$
|
|
13881
|
+
return new ethers.utils.Interface(_abi$5);
|
|
13880
13882
|
}
|
|
13881
13883
|
static connect(address, signerOrProvider) {
|
|
13882
|
-
return new ethers.Contract(address, _abi$
|
|
13884
|
+
return new ethers.Contract(address, _abi$5, signerOrProvider);
|
|
13883
13885
|
}
|
|
13884
13886
|
}
|
|
13885
13887
|
|
|
@@ -21087,6 +21089,13 @@ function arrayifyInteger(value) {
|
|
|
21087
21089
|
}
|
|
21088
21090
|
return result;
|
|
21089
21091
|
}
|
|
21092
|
+
function unarrayifyInteger(data, offset, length) {
|
|
21093
|
+
let result = 0;
|
|
21094
|
+
for (let i = 0; i < length; i++) {
|
|
21095
|
+
result = (result * 256) + data[offset + i];
|
|
21096
|
+
}
|
|
21097
|
+
return result;
|
|
21098
|
+
}
|
|
21090
21099
|
function _encode(object) {
|
|
21091
21100
|
if (Array.isArray(object)) {
|
|
21092
21101
|
let payload = [];
|
|
@@ -21119,6 +21128,72 @@ function _encode(object) {
|
|
|
21119
21128
|
function encode(object) {
|
|
21120
21129
|
return hexlify(_encode(object));
|
|
21121
21130
|
}
|
|
21131
|
+
function _decodeChildren(data, offset, childOffset, length) {
|
|
21132
|
+
const result = [];
|
|
21133
|
+
while (childOffset < offset + 1 + length) {
|
|
21134
|
+
const decoded = _decode(data, childOffset);
|
|
21135
|
+
result.push(decoded.result);
|
|
21136
|
+
childOffset += decoded.consumed;
|
|
21137
|
+
if (childOffset > offset + 1 + length) {
|
|
21138
|
+
logger$9.throwError("child data too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21139
|
+
}
|
|
21140
|
+
}
|
|
21141
|
+
return { consumed: (1 + length), result: result };
|
|
21142
|
+
}
|
|
21143
|
+
// returns { consumed: number, result: Object }
|
|
21144
|
+
function _decode(data, offset) {
|
|
21145
|
+
if (data.length === 0) {
|
|
21146
|
+
logger$9.throwError("data too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21147
|
+
}
|
|
21148
|
+
// Array with extra length prefix
|
|
21149
|
+
if (data[offset] >= 0xf8) {
|
|
21150
|
+
const lengthLength = data[offset] - 0xf7;
|
|
21151
|
+
if (offset + 1 + lengthLength > data.length) {
|
|
21152
|
+
logger$9.throwError("data short segment too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21153
|
+
}
|
|
21154
|
+
const length = unarrayifyInteger(data, offset + 1, lengthLength);
|
|
21155
|
+
if (offset + 1 + lengthLength + length > data.length) {
|
|
21156
|
+
logger$9.throwError("data long segment too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21157
|
+
}
|
|
21158
|
+
return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length);
|
|
21159
|
+
}
|
|
21160
|
+
else if (data[offset] >= 0xc0) {
|
|
21161
|
+
const length = data[offset] - 0xc0;
|
|
21162
|
+
if (offset + 1 + length > data.length) {
|
|
21163
|
+
logger$9.throwError("data array too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21164
|
+
}
|
|
21165
|
+
return _decodeChildren(data, offset, offset + 1, length);
|
|
21166
|
+
}
|
|
21167
|
+
else if (data[offset] >= 0xb8) {
|
|
21168
|
+
const lengthLength = data[offset] - 0xb7;
|
|
21169
|
+
if (offset + 1 + lengthLength > data.length) {
|
|
21170
|
+
logger$9.throwError("data array too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21171
|
+
}
|
|
21172
|
+
const length = unarrayifyInteger(data, offset + 1, lengthLength);
|
|
21173
|
+
if (offset + 1 + lengthLength + length > data.length) {
|
|
21174
|
+
logger$9.throwError("data array too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21175
|
+
}
|
|
21176
|
+
const result = hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length));
|
|
21177
|
+
return { consumed: (1 + lengthLength + length), result: result };
|
|
21178
|
+
}
|
|
21179
|
+
else if (data[offset] >= 0x80) {
|
|
21180
|
+
const length = data[offset] - 0x80;
|
|
21181
|
+
if (offset + 1 + length > data.length) {
|
|
21182
|
+
logger$9.throwError("data too short", Logger.errors.BUFFER_OVERRUN, {});
|
|
21183
|
+
}
|
|
21184
|
+
const result = hexlify(data.slice(offset + 1, offset + 1 + length));
|
|
21185
|
+
return { consumed: (1 + length), result: result };
|
|
21186
|
+
}
|
|
21187
|
+
return { consumed: 1, result: hexlify(data[offset]) };
|
|
21188
|
+
}
|
|
21189
|
+
function decode(data) {
|
|
21190
|
+
const bytes = arrayify(data);
|
|
21191
|
+
const decoded = _decode(bytes, 0);
|
|
21192
|
+
if (decoded.consumed !== bytes.length) {
|
|
21193
|
+
logger$9.throwArgumentError("invalid rlp data", "data", data);
|
|
21194
|
+
}
|
|
21195
|
+
return decoded.result;
|
|
21196
|
+
}
|
|
21122
21197
|
|
|
21123
21198
|
const version$5 = "address/5.7.0";
|
|
21124
21199
|
|
|
@@ -23985,6 +24060,19 @@ const ROOT_ERC20_PREDICATE = [
|
|
|
23985
24060
|
stateMutability: 'view',
|
|
23986
24061
|
type: 'function',
|
|
23987
24062
|
},
|
|
24063
|
+
{
|
|
24064
|
+
inputs: [],
|
|
24065
|
+
name: 'NATIVE_TOKEN',
|
|
24066
|
+
outputs: [
|
|
24067
|
+
{
|
|
24068
|
+
internalType: 'address',
|
|
24069
|
+
name: '',
|
|
24070
|
+
type: 'address',
|
|
24071
|
+
},
|
|
24072
|
+
],
|
|
24073
|
+
stateMutability: 'view',
|
|
24074
|
+
type: 'function',
|
|
24075
|
+
},
|
|
23988
24076
|
{
|
|
23989
24077
|
inputs: [],
|
|
23990
24078
|
name: 'WITHDRAW_SIG',
|
|
@@ -24042,6 +24130,19 @@ const ROOT_ERC20_PREDICATE = [
|
|
|
24042
24130
|
stateMutability: 'nonpayable',
|
|
24043
24131
|
type: 'function',
|
|
24044
24132
|
},
|
|
24133
|
+
{
|
|
24134
|
+
inputs: [
|
|
24135
|
+
{
|
|
24136
|
+
internalType: 'address',
|
|
24137
|
+
name: 'receiver',
|
|
24138
|
+
type: 'address',
|
|
24139
|
+
},
|
|
24140
|
+
],
|
|
24141
|
+
name: 'depositNativeTo',
|
|
24142
|
+
outputs: [],
|
|
24143
|
+
stateMutability: 'payable',
|
|
24144
|
+
type: 'function',
|
|
24145
|
+
},
|
|
24045
24146
|
{
|
|
24046
24147
|
inputs: [
|
|
24047
24148
|
{
|
|
@@ -24120,7 +24221,13 @@ const ROOT_ERC20_PREDICATE = [
|
|
|
24120
24221
|
},
|
|
24121
24222
|
],
|
|
24122
24223
|
name: 'mapToken',
|
|
24123
|
-
outputs: [
|
|
24224
|
+
outputs: [
|
|
24225
|
+
{
|
|
24226
|
+
internalType: 'address',
|
|
24227
|
+
name: '',
|
|
24228
|
+
type: 'address',
|
|
24229
|
+
},
|
|
24230
|
+
],
|
|
24124
24231
|
stateMutability: 'nonpayable',
|
|
24125
24232
|
type: 'function',
|
|
24126
24233
|
},
|
|
@@ -24415,6 +24522,8 @@ var BridgeErrorType;
|
|
|
24415
24522
|
BridgeErrorType["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
24416
24523
|
BridgeErrorType["PROVIDER_ERROR"] = "PROVIDER_ERROR";
|
|
24417
24524
|
BridgeErrorType["TRANSACTION_REVERTED"] = "TRANSACTION_REVERTED";
|
|
24525
|
+
BridgeErrorType["INVALID_TOKEN"] = "INVALID_TOKEN";
|
|
24526
|
+
BridgeErrorType["INVALID_TRANSACTION"] = "INVALID_TRANSACTION";
|
|
24418
24527
|
})(BridgeErrorType || (BridgeErrorType = {}));
|
|
24419
24528
|
/**
|
|
24420
24529
|
* Represents a custom error for bridge operations.
|
|
@@ -24442,14 +24551,18 @@ class BridgeError extends Error {
|
|
|
24442
24551
|
* @template T - The type of the value that the Promise resolves to.
|
|
24443
24552
|
* @param {() => Promise<T>} fn - The function to wrap with error handling.
|
|
24444
24553
|
* @param {BridgeErrorType} customErrorType - The custom error type to use for the error.
|
|
24554
|
+
* @param {string} [details] - Additional details to add to the error message.
|
|
24445
24555
|
* @returns {Promise<T>} The result of the wrapped function or a rejected promise with a BridgeError.
|
|
24446
24556
|
*/
|
|
24447
|
-
const withBridgeError = async (fn, customErrorType) => {
|
|
24557
|
+
const withBridgeError = async (fn, customErrorType, details) => {
|
|
24448
24558
|
try {
|
|
24449
24559
|
return await fn();
|
|
24450
24560
|
}
|
|
24451
24561
|
catch (error) {
|
|
24452
|
-
|
|
24562
|
+
let errorMessage = `${customErrorType}: ${error.message}` || 'UnknownError';
|
|
24563
|
+
if (details) {
|
|
24564
|
+
errorMessage = `${details}: ${errorMessage}`;
|
|
24565
|
+
}
|
|
24453
24566
|
throw new BridgeError(errorMessage, customErrorType);
|
|
24454
24567
|
}
|
|
24455
24568
|
};
|
|
@@ -24964,202 +25077,1839 @@ async function getBlockNumberClosestToTimestamp(provider, targetTimestamp, block
|
|
|
24964
25077
|
return lowerBlockNumber;
|
|
24965
25078
|
}
|
|
24966
25079
|
|
|
24967
|
-
|
|
24968
|
-
|
|
24969
|
-
|
|
24970
|
-
|
|
24971
|
-
|
|
24972
|
-
|
|
24973
|
-
|
|
24974
|
-
config;
|
|
24975
|
-
/**
|
|
24976
|
-
* Constructs a TokenBridge instance.
|
|
24977
|
-
*
|
|
24978
|
-
* @param {BridgeConfiguration} config - The bridge configuration object.
|
|
24979
|
-
*/
|
|
24980
|
-
constructor(config) {
|
|
24981
|
-
this.config = config;
|
|
24982
|
-
}
|
|
24983
|
-
/**
|
|
24984
|
-
* Retrieves the bridge fee for a specific token.
|
|
24985
|
-
*
|
|
24986
|
-
* @param {BridgeFeeRequest} req - The fee request object containing the token address for which the fee is required.
|
|
24987
|
-
* @returns {Promise<BridgeFeeResponse>} - A promise that resolves to an object containing the bridge fee for the specified token and a flag indicating if the token is bridgeable.
|
|
24988
|
-
* @throws {BridgeError} - If an error occurs during the fee retrieval, a BridgeError will be thrown with a specific error type.
|
|
24989
|
-
*
|
|
24990
|
-
* Possible BridgeError types include:
|
|
24991
|
-
* - INVALID_ADDRESS: The token address provided in the request is invalid.
|
|
24992
|
-
*
|
|
24993
|
-
* @example
|
|
24994
|
-
* const feeRequest = {
|
|
24995
|
-
* token: '0x123456...', // ERC20 token address
|
|
24996
|
-
* };
|
|
24997
|
-
*
|
|
24998
|
-
* bridgeSdk.getFee(feeRequest)
|
|
24999
|
-
* .then((feeResponse) => {
|
|
25000
|
-
* console.log('Bridgeable:', feeResponse.bridgeable);
|
|
25001
|
-
* console.log('Fee Amount:', feeResponse.feeAmount.toString());
|
|
25002
|
-
* })
|
|
25003
|
-
* .catch((error) => {
|
|
25004
|
-
* console.error('Error:', error.message);
|
|
25005
|
-
* });
|
|
25006
|
-
*/
|
|
25007
|
-
async getFee(req) {
|
|
25008
|
-
if (!isAddress(req.token)) {
|
|
25009
|
-
throw new BridgeError(`token address ${req.token} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
25010
|
-
}
|
|
25011
|
-
return {
|
|
25012
|
-
bridgeable: true,
|
|
25013
|
-
feeAmount: await this.getFeeForToken(req.token),
|
|
25014
|
-
};
|
|
25015
|
-
}
|
|
25016
|
-
/**
|
|
25017
|
-
* Generates an unsigned deposit transaction for a user to sign and submit to the bridge.
|
|
25018
|
-
*
|
|
25019
|
-
* @param {BridgeDepositRequest} req - The deposit request object containing the required data for depositing tokens.
|
|
25020
|
-
* @returns {Promise<BridgeDepositResponse>} - A promise that resolves to an object containing the unsigned transaction data.
|
|
25021
|
-
* @throws {BridgeError} - If an error occurs during the generation of the unsigned transaction, a BridgeError will be thrown with a specific error type.
|
|
25022
|
-
*
|
|
25023
|
-
* Possible BridgeError types include:
|
|
25024
|
-
* - UNSUPPORTED_ERROR: The operation is not supported. Currently thrown when attempting to deposit native tokens.
|
|
25025
|
-
* - INVALID_ADDRESS: An Ethereum address provided in the request is invalid. This could be the depositor's, recipient's or the token's address.
|
|
25026
|
-
* - INVALID_AMOUNT: The deposit amount provided in the request is invalid (less than or equal to 0).
|
|
25027
|
-
* - INTERNAL_ERROR: An unexpected error occurred during the execution, likely due to the bridge SDK implementation.
|
|
25028
|
-
*
|
|
25029
|
-
* @example
|
|
25030
|
-
* const depositRequest = {
|
|
25031
|
-
* token: '0x123456...', // ERC20 token address
|
|
25032
|
-
* depositorAddress: '0xabcdef...', // User's wallet address
|
|
25033
|
-
* recipientAddress: '0x987654...', // Destination wallet address on the target chain
|
|
25034
|
-
* depositAmount: ethers.utils.parseUnits('100', 18), // Deposit amount in wei
|
|
25035
|
-
* };
|
|
25036
|
-
*
|
|
25037
|
-
* bridgeSdk.getUnsignedDepositTx(depositRequest)
|
|
25038
|
-
* .then((depositResponse) => {
|
|
25039
|
-
* console.log(depositResponse.unsignedTx);
|
|
25040
|
-
* })
|
|
25041
|
-
* .catch((error) => {
|
|
25042
|
-
* console.error('Error:', error.message);
|
|
25043
|
-
* });
|
|
25044
|
-
*/
|
|
25045
|
-
async getUnsignedDepositTx(req) {
|
|
25046
|
-
if (req.token === 'NATIVE') {
|
|
25047
|
-
throw new BridgeError('native token deposit is not yet supported', BridgeErrorType.UNSUPPORTED_ERROR);
|
|
25048
|
-
}
|
|
25049
|
-
if (!isAddress(req.depositorAddress)) {
|
|
25050
|
-
throw new BridgeError(`depositor address ${req.depositorAddress} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
25051
|
-
}
|
|
25052
|
-
if (!isAddress(req.recipientAddress)) {
|
|
25053
|
-
throw new BridgeError(`recipient address ${req.recipientAddress} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
25054
|
-
}
|
|
25055
|
-
// If the token is ERC20, the address must be valid
|
|
25056
|
-
if (req.token !== 'NATIVE' && !isAddress(req.token)) {
|
|
25057
|
-
throw new BridgeError(`token address ${req.token} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
25058
|
-
}
|
|
25059
|
-
// The deposit amount cannot be <= 0
|
|
25060
|
-
if (req.depositAmount.isNegative() || req.depositAmount.isZero()) {
|
|
25061
|
-
throw new BridgeError(`deposit amount ${req.depositAmount.toString()} is invalid`, BridgeErrorType.INVALID_AMOUNT);
|
|
25062
|
-
}
|
|
25063
|
-
// Convert the addresses to correct format addresses (e.g. prepend 0x if not already)
|
|
25064
|
-
const depositor = getAddress(req.depositorAddress);
|
|
25065
|
-
const receipient = getAddress(req.recipientAddress);
|
|
25066
|
-
const token = getAddress(req.token);
|
|
25067
|
-
const rootERC20PredicateContract = await withBridgeError(async () => {
|
|
25068
|
-
const contract = new Contract(this.config.bridgeContracts.rootChainERC20Predicate, ROOT_ERC20_PREDICATE);
|
|
25069
|
-
return contract;
|
|
25070
|
-
}, BridgeErrorType.INTERNAL_ERROR);
|
|
25071
|
-
// Encode the function data into a payload
|
|
25072
|
-
const data = await withBridgeError(async () => rootERC20PredicateContract.interface.encodeFunctionData('depositTo', [token, receipient, req.depositAmount]), BridgeErrorType.INTERNAL_ERROR);
|
|
25073
|
-
return {
|
|
25074
|
-
unsignedTx: {
|
|
25075
|
-
data,
|
|
25076
|
-
to: this.config.bridgeContracts.rootChainERC20Predicate,
|
|
25077
|
-
value: 0,
|
|
25078
|
-
from: depositor,
|
|
25080
|
+
const CHILD_ERC20_PREDICATE = [
|
|
25081
|
+
{
|
|
25082
|
+
inputs: [
|
|
25083
|
+
{
|
|
25084
|
+
internalType: 'string',
|
|
25085
|
+
name: 'only',
|
|
25086
|
+
type: 'string',
|
|
25079
25087
|
},
|
|
25080
|
-
|
|
25081
|
-
|
|
25082
|
-
|
|
25083
|
-
|
|
25084
|
-
|
|
25085
|
-
|
|
25086
|
-
|
|
25087
|
-
|
|
25088
|
-
|
|
25089
|
-
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25093
|
-
|
|
25094
|
-
|
|
25095
|
-
|
|
25096
|
-
|
|
25097
|
-
|
|
25098
|
-
|
|
25099
|
-
|
|
25100
|
-
|
|
25101
|
-
|
|
25102
|
-
|
|
25103
|
-
|
|
25104
|
-
|
|
25105
|
-
|
|
25106
|
-
|
|
25107
|
-
|
|
25108
|
-
|
|
25109
|
-
|
|
25110
|
-
|
|
25111
|
-
|
|
25112
|
-
|
|
25113
|
-
|
|
25114
|
-
|
|
25115
|
-
|
|
25116
|
-
|
|
25117
|
-
|
|
25118
|
-
|
|
25119
|
-
|
|
25120
|
-
|
|
25121
|
-
|
|
25122
|
-
|
|
25123
|
-
|
|
25124
|
-
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
|
|
25132
|
-
|
|
25133
|
-
|
|
25134
|
-
|
|
25135
|
-
|
|
25136
|
-
|
|
25137
|
-
|
|
25138
|
-
|
|
25139
|
-
|
|
25140
|
-
|
|
25141
|
-
|
|
25142
|
-
|
|
25143
|
-
|
|
25144
|
-
|
|
25145
|
-
|
|
25146
|
-
|
|
25147
|
-
|
|
25148
|
-
|
|
25149
|
-
|
|
25150
|
-
|
|
25151
|
-
|
|
25152
|
-
|
|
25153
|
-
|
|
25154
|
-
|
|
25155
|
-
|
|
25156
|
-
|
|
25088
|
+
],
|
|
25089
|
+
name: 'Unauthorized',
|
|
25090
|
+
type: 'error',
|
|
25091
|
+
},
|
|
25092
|
+
{
|
|
25093
|
+
anonymous: false,
|
|
25094
|
+
inputs: [
|
|
25095
|
+
{
|
|
25096
|
+
indexed: false,
|
|
25097
|
+
internalType: 'uint8',
|
|
25098
|
+
name: 'version',
|
|
25099
|
+
type: 'uint8',
|
|
25100
|
+
},
|
|
25101
|
+
],
|
|
25102
|
+
name: 'Initialized',
|
|
25103
|
+
type: 'event',
|
|
25104
|
+
},
|
|
25105
|
+
{
|
|
25106
|
+
anonymous: false,
|
|
25107
|
+
inputs: [
|
|
25108
|
+
{
|
|
25109
|
+
indexed: true,
|
|
25110
|
+
internalType: 'address',
|
|
25111
|
+
name: 'rootToken',
|
|
25112
|
+
type: 'address',
|
|
25113
|
+
},
|
|
25114
|
+
{
|
|
25115
|
+
indexed: true,
|
|
25116
|
+
internalType: 'address',
|
|
25117
|
+
name: 'childToken',
|
|
25118
|
+
type: 'address',
|
|
25119
|
+
},
|
|
25120
|
+
{
|
|
25121
|
+
indexed: false,
|
|
25122
|
+
internalType: 'address',
|
|
25123
|
+
name: 'sender',
|
|
25124
|
+
type: 'address',
|
|
25125
|
+
},
|
|
25126
|
+
{
|
|
25127
|
+
indexed: true,
|
|
25128
|
+
internalType: 'address',
|
|
25129
|
+
name: 'receiver',
|
|
25130
|
+
type: 'address',
|
|
25131
|
+
},
|
|
25132
|
+
{
|
|
25133
|
+
indexed: false,
|
|
25134
|
+
internalType: 'uint256',
|
|
25135
|
+
name: 'amount',
|
|
25136
|
+
type: 'uint256',
|
|
25137
|
+
},
|
|
25138
|
+
],
|
|
25139
|
+
name: 'L2ERC20Deposit',
|
|
25140
|
+
type: 'event',
|
|
25141
|
+
},
|
|
25142
|
+
{
|
|
25143
|
+
anonymous: false,
|
|
25144
|
+
inputs: [
|
|
25145
|
+
{
|
|
25146
|
+
indexed: true,
|
|
25147
|
+
internalType: 'address',
|
|
25148
|
+
name: 'rootToken',
|
|
25149
|
+
type: 'address',
|
|
25150
|
+
},
|
|
25151
|
+
{
|
|
25152
|
+
indexed: true,
|
|
25153
|
+
internalType: 'address',
|
|
25154
|
+
name: 'childToken',
|
|
25155
|
+
type: 'address',
|
|
25156
|
+
},
|
|
25157
|
+
{
|
|
25158
|
+
indexed: false,
|
|
25159
|
+
internalType: 'address',
|
|
25160
|
+
name: 'sender',
|
|
25161
|
+
type: 'address',
|
|
25162
|
+
},
|
|
25163
|
+
{
|
|
25164
|
+
indexed: true,
|
|
25165
|
+
internalType: 'address',
|
|
25166
|
+
name: 'receiver',
|
|
25167
|
+
type: 'address',
|
|
25168
|
+
},
|
|
25169
|
+
{
|
|
25170
|
+
indexed: false,
|
|
25171
|
+
internalType: 'uint256',
|
|
25172
|
+
name: 'amount',
|
|
25173
|
+
type: 'uint256',
|
|
25174
|
+
},
|
|
25175
|
+
],
|
|
25176
|
+
name: 'L2ERC20Withdraw',
|
|
25177
|
+
type: 'event',
|
|
25178
|
+
},
|
|
25179
|
+
{
|
|
25180
|
+
anonymous: false,
|
|
25181
|
+
inputs: [
|
|
25182
|
+
{
|
|
25183
|
+
indexed: true,
|
|
25184
|
+
internalType: 'address',
|
|
25185
|
+
name: 'rootToken',
|
|
25186
|
+
type: 'address',
|
|
25187
|
+
},
|
|
25188
|
+
{
|
|
25189
|
+
indexed: true,
|
|
25190
|
+
internalType: 'address',
|
|
25191
|
+
name: 'childToken',
|
|
25192
|
+
type: 'address',
|
|
25193
|
+
},
|
|
25194
|
+
],
|
|
25195
|
+
name: 'L2TokenMapped',
|
|
25196
|
+
type: 'event',
|
|
25197
|
+
},
|
|
25198
|
+
{
|
|
25199
|
+
inputs: [],
|
|
25200
|
+
name: 'DEPOSIT_SIG',
|
|
25201
|
+
outputs: [
|
|
25202
|
+
{
|
|
25203
|
+
internalType: 'bytes32',
|
|
25204
|
+
name: '',
|
|
25205
|
+
type: 'bytes32',
|
|
25206
|
+
},
|
|
25207
|
+
],
|
|
25208
|
+
stateMutability: 'view',
|
|
25209
|
+
type: 'function',
|
|
25210
|
+
},
|
|
25211
|
+
{
|
|
25212
|
+
inputs: [],
|
|
25213
|
+
name: 'MAP_TOKEN_SIG',
|
|
25214
|
+
outputs: [
|
|
25215
|
+
{
|
|
25216
|
+
internalType: 'bytes32',
|
|
25217
|
+
name: '',
|
|
25218
|
+
type: 'bytes32',
|
|
25219
|
+
},
|
|
25220
|
+
],
|
|
25221
|
+
stateMutability: 'view',
|
|
25222
|
+
type: 'function',
|
|
25223
|
+
},
|
|
25224
|
+
{
|
|
25225
|
+
inputs: [],
|
|
25226
|
+
name: 'NATIVE_TOKEN_CONTRACT',
|
|
25227
|
+
outputs: [
|
|
25228
|
+
{
|
|
25229
|
+
internalType: 'address',
|
|
25230
|
+
name: '',
|
|
25231
|
+
type: 'address',
|
|
25232
|
+
},
|
|
25233
|
+
],
|
|
25234
|
+
stateMutability: 'view',
|
|
25235
|
+
type: 'function',
|
|
25236
|
+
},
|
|
25237
|
+
{
|
|
25238
|
+
inputs: [],
|
|
25239
|
+
name: 'NATIVE_TRANSFER_PRECOMPILE',
|
|
25240
|
+
outputs: [
|
|
25241
|
+
{
|
|
25242
|
+
internalType: 'address',
|
|
25243
|
+
name: '',
|
|
25244
|
+
type: 'address',
|
|
25245
|
+
},
|
|
25246
|
+
],
|
|
25247
|
+
stateMutability: 'view',
|
|
25248
|
+
type: 'function',
|
|
25249
|
+
},
|
|
25250
|
+
{
|
|
25251
|
+
inputs: [],
|
|
25252
|
+
name: 'NATIVE_TRANSFER_PRECOMPILE_GAS',
|
|
25253
|
+
outputs: [
|
|
25254
|
+
{
|
|
25255
|
+
internalType: 'uint256',
|
|
25256
|
+
name: '',
|
|
25257
|
+
type: 'uint256',
|
|
25258
|
+
},
|
|
25259
|
+
],
|
|
25260
|
+
stateMutability: 'view',
|
|
25261
|
+
type: 'function',
|
|
25262
|
+
},
|
|
25263
|
+
{
|
|
25264
|
+
inputs: [],
|
|
25265
|
+
name: 'SYSTEM',
|
|
25266
|
+
outputs: [
|
|
25267
|
+
{
|
|
25268
|
+
internalType: 'address',
|
|
25269
|
+
name: '',
|
|
25270
|
+
type: 'address',
|
|
25271
|
+
},
|
|
25272
|
+
],
|
|
25273
|
+
stateMutability: 'view',
|
|
25274
|
+
type: 'function',
|
|
25275
|
+
},
|
|
25276
|
+
{
|
|
25277
|
+
inputs: [],
|
|
25278
|
+
name: 'VALIDATOR_PKCHECK_PRECOMPILE',
|
|
25279
|
+
outputs: [
|
|
25280
|
+
{
|
|
25281
|
+
internalType: 'address',
|
|
25282
|
+
name: '',
|
|
25283
|
+
type: 'address',
|
|
25284
|
+
},
|
|
25285
|
+
],
|
|
25286
|
+
stateMutability: 'view',
|
|
25287
|
+
type: 'function',
|
|
25288
|
+
},
|
|
25289
|
+
{
|
|
25290
|
+
inputs: [],
|
|
25291
|
+
name: 'VALIDATOR_PKCHECK_PRECOMPILE_GAS',
|
|
25292
|
+
outputs: [
|
|
25293
|
+
{
|
|
25294
|
+
internalType: 'uint256',
|
|
25295
|
+
name: '',
|
|
25296
|
+
type: 'uint256',
|
|
25297
|
+
},
|
|
25298
|
+
],
|
|
25299
|
+
stateMutability: 'view',
|
|
25300
|
+
type: 'function',
|
|
25301
|
+
},
|
|
25302
|
+
{
|
|
25303
|
+
inputs: [],
|
|
25304
|
+
name: 'WITHDRAW_SIG',
|
|
25305
|
+
outputs: [
|
|
25306
|
+
{
|
|
25307
|
+
internalType: 'bytes32',
|
|
25308
|
+
name: '',
|
|
25309
|
+
type: 'bytes32',
|
|
25310
|
+
},
|
|
25311
|
+
],
|
|
25312
|
+
stateMutability: 'view',
|
|
25313
|
+
type: 'function',
|
|
25314
|
+
},
|
|
25315
|
+
{
|
|
25316
|
+
inputs: [],
|
|
25317
|
+
name: 'childTokenTemplate',
|
|
25318
|
+
outputs: [
|
|
25319
|
+
{
|
|
25320
|
+
internalType: 'address',
|
|
25321
|
+
name: '',
|
|
25322
|
+
type: 'address',
|
|
25323
|
+
},
|
|
25324
|
+
],
|
|
25325
|
+
stateMutability: 'view',
|
|
25326
|
+
type: 'function',
|
|
25327
|
+
},
|
|
25328
|
+
{
|
|
25329
|
+
inputs: [
|
|
25330
|
+
{
|
|
25331
|
+
internalType: 'address',
|
|
25332
|
+
name: 'newL2StateSender',
|
|
25333
|
+
type: 'address',
|
|
25334
|
+
},
|
|
25335
|
+
{
|
|
25336
|
+
internalType: 'address',
|
|
25337
|
+
name: 'newStateReceiver',
|
|
25338
|
+
type: 'address',
|
|
25339
|
+
},
|
|
25340
|
+
{
|
|
25341
|
+
internalType: 'address',
|
|
25342
|
+
name: 'newRootERC20Predicate',
|
|
25343
|
+
type: 'address',
|
|
25344
|
+
},
|
|
25345
|
+
{
|
|
25346
|
+
internalType: 'address',
|
|
25347
|
+
name: 'newChildTokenTemplate',
|
|
25348
|
+
type: 'address',
|
|
25349
|
+
},
|
|
25350
|
+
{
|
|
25351
|
+
internalType: 'address',
|
|
25352
|
+
name: 'newNativeTokenRootAddress',
|
|
25353
|
+
type: 'address',
|
|
25354
|
+
},
|
|
25355
|
+
],
|
|
25356
|
+
name: 'initialize',
|
|
25357
|
+
outputs: [],
|
|
25358
|
+
stateMutability: 'nonpayable',
|
|
25359
|
+
type: 'function',
|
|
25360
|
+
},
|
|
25361
|
+
{
|
|
25362
|
+
inputs: [],
|
|
25363
|
+
name: 'l2StateSender',
|
|
25364
|
+
outputs: [
|
|
25365
|
+
{
|
|
25366
|
+
internalType: 'contract IStateSender',
|
|
25367
|
+
name: '',
|
|
25368
|
+
type: 'address',
|
|
25369
|
+
},
|
|
25370
|
+
],
|
|
25371
|
+
stateMutability: 'view',
|
|
25372
|
+
type: 'function',
|
|
25373
|
+
},
|
|
25374
|
+
{
|
|
25375
|
+
inputs: [
|
|
25376
|
+
{
|
|
25377
|
+
internalType: 'uint256',
|
|
25378
|
+
name: '',
|
|
25379
|
+
type: 'uint256',
|
|
25380
|
+
},
|
|
25381
|
+
{
|
|
25382
|
+
internalType: 'address',
|
|
25383
|
+
name: 'sender',
|
|
25384
|
+
type: 'address',
|
|
25385
|
+
},
|
|
25386
|
+
{
|
|
25387
|
+
internalType: 'bytes',
|
|
25388
|
+
name: 'data',
|
|
25389
|
+
type: 'bytes',
|
|
25390
|
+
},
|
|
25391
|
+
],
|
|
25392
|
+
name: 'onStateReceive',
|
|
25393
|
+
outputs: [],
|
|
25394
|
+
stateMutability: 'nonpayable',
|
|
25395
|
+
type: 'function',
|
|
25396
|
+
},
|
|
25397
|
+
{
|
|
25398
|
+
inputs: [],
|
|
25399
|
+
name: 'rootERC20Predicate',
|
|
25400
|
+
outputs: [
|
|
25401
|
+
{
|
|
25402
|
+
internalType: 'address',
|
|
25403
|
+
name: '',
|
|
25404
|
+
type: 'address',
|
|
25405
|
+
},
|
|
25406
|
+
],
|
|
25407
|
+
stateMutability: 'view',
|
|
25408
|
+
type: 'function',
|
|
25409
|
+
},
|
|
25410
|
+
{
|
|
25411
|
+
inputs: [
|
|
25412
|
+
{
|
|
25413
|
+
internalType: 'address',
|
|
25414
|
+
name: '',
|
|
25415
|
+
type: 'address',
|
|
25416
|
+
},
|
|
25417
|
+
],
|
|
25418
|
+
name: 'rootTokenToChildToken',
|
|
25419
|
+
outputs: [
|
|
25420
|
+
{
|
|
25421
|
+
internalType: 'address',
|
|
25422
|
+
name: '',
|
|
25423
|
+
type: 'address',
|
|
25424
|
+
},
|
|
25425
|
+
],
|
|
25426
|
+
stateMutability: 'view',
|
|
25427
|
+
type: 'function',
|
|
25428
|
+
},
|
|
25429
|
+
{
|
|
25430
|
+
inputs: [],
|
|
25431
|
+
name: 'stateReceiver',
|
|
25432
|
+
outputs: [
|
|
25433
|
+
{
|
|
25434
|
+
internalType: 'address',
|
|
25435
|
+
name: '',
|
|
25436
|
+
type: 'address',
|
|
25437
|
+
},
|
|
25438
|
+
],
|
|
25439
|
+
stateMutability: 'view',
|
|
25440
|
+
type: 'function',
|
|
25441
|
+
},
|
|
25442
|
+
{
|
|
25443
|
+
inputs: [
|
|
25444
|
+
{
|
|
25445
|
+
internalType: 'contract IChildERC20',
|
|
25446
|
+
name: 'childToken',
|
|
25447
|
+
type: 'address',
|
|
25448
|
+
},
|
|
25449
|
+
{
|
|
25450
|
+
internalType: 'uint256',
|
|
25451
|
+
name: 'amount',
|
|
25452
|
+
type: 'uint256',
|
|
25453
|
+
},
|
|
25454
|
+
],
|
|
25455
|
+
name: 'withdraw',
|
|
25456
|
+
outputs: [],
|
|
25457
|
+
stateMutability: 'nonpayable',
|
|
25458
|
+
type: 'function',
|
|
25459
|
+
},
|
|
25460
|
+
{
|
|
25461
|
+
inputs: [
|
|
25462
|
+
{
|
|
25463
|
+
internalType: 'contract IChildERC20',
|
|
25464
|
+
name: 'childToken',
|
|
25465
|
+
type: 'address',
|
|
25466
|
+
},
|
|
25467
|
+
{
|
|
25468
|
+
internalType: 'address',
|
|
25469
|
+
name: 'receiver',
|
|
25470
|
+
type: 'address',
|
|
25471
|
+
},
|
|
25472
|
+
{
|
|
25473
|
+
internalType: 'uint256',
|
|
25474
|
+
name: 'amount',
|
|
25475
|
+
type: 'uint256',
|
|
25476
|
+
},
|
|
25477
|
+
],
|
|
25478
|
+
name: 'withdrawTo',
|
|
25479
|
+
outputs: [],
|
|
25480
|
+
stateMutability: 'nonpayable',
|
|
25481
|
+
type: 'function',
|
|
25482
|
+
},
|
|
25483
|
+
];
|
|
25484
|
+
|
|
25485
|
+
const CHECKPOINT_MANAGER = [
|
|
25486
|
+
{
|
|
25487
|
+
anonymous: false,
|
|
25488
|
+
inputs: [
|
|
25489
|
+
{
|
|
25490
|
+
indexed: false,
|
|
25491
|
+
internalType: 'uint8',
|
|
25492
|
+
name: 'version',
|
|
25493
|
+
type: 'uint8',
|
|
25494
|
+
},
|
|
25495
|
+
],
|
|
25496
|
+
name: 'Initialized',
|
|
25497
|
+
type: 'event',
|
|
25498
|
+
},
|
|
25499
|
+
{
|
|
25500
|
+
inputs: [],
|
|
25501
|
+
name: 'DOMAIN',
|
|
25502
|
+
outputs: [
|
|
25503
|
+
{
|
|
25504
|
+
internalType: 'bytes32',
|
|
25505
|
+
name: '',
|
|
25506
|
+
type: 'bytes32',
|
|
25507
|
+
},
|
|
25508
|
+
],
|
|
25509
|
+
stateMutability: 'view',
|
|
25510
|
+
type: 'function',
|
|
25511
|
+
},
|
|
25512
|
+
{
|
|
25513
|
+
inputs: [],
|
|
25514
|
+
name: 'bls',
|
|
25515
|
+
outputs: [
|
|
25516
|
+
{
|
|
25517
|
+
internalType: 'contract IBLS',
|
|
25518
|
+
name: '',
|
|
25519
|
+
type: 'address',
|
|
25520
|
+
},
|
|
25521
|
+
],
|
|
25522
|
+
stateMutability: 'view',
|
|
25523
|
+
type: 'function',
|
|
25524
|
+
},
|
|
25525
|
+
{
|
|
25526
|
+
inputs: [],
|
|
25527
|
+
name: 'bn256G2',
|
|
25528
|
+
outputs: [
|
|
25529
|
+
{
|
|
25530
|
+
internalType: 'contract IBN256G2',
|
|
25531
|
+
name: '',
|
|
25532
|
+
type: 'address',
|
|
25533
|
+
},
|
|
25534
|
+
],
|
|
25535
|
+
stateMutability: 'view',
|
|
25536
|
+
type: 'function',
|
|
25537
|
+
},
|
|
25538
|
+
{
|
|
25539
|
+
inputs: [],
|
|
25540
|
+
name: 'chainId',
|
|
25541
|
+
outputs: [
|
|
25542
|
+
{
|
|
25543
|
+
internalType: 'uint256',
|
|
25544
|
+
name: '',
|
|
25545
|
+
type: 'uint256',
|
|
25546
|
+
},
|
|
25547
|
+
],
|
|
25548
|
+
stateMutability: 'view',
|
|
25549
|
+
type: 'function',
|
|
25550
|
+
},
|
|
25551
|
+
{
|
|
25552
|
+
inputs: [
|
|
25553
|
+
{
|
|
25554
|
+
internalType: 'uint256',
|
|
25555
|
+
name: '',
|
|
25556
|
+
type: 'uint256',
|
|
25557
|
+
},
|
|
25558
|
+
],
|
|
25559
|
+
name: 'checkpointBlockNumbers',
|
|
25560
|
+
outputs: [
|
|
25561
|
+
{
|
|
25562
|
+
internalType: 'uint256',
|
|
25563
|
+
name: '',
|
|
25564
|
+
type: 'uint256',
|
|
25565
|
+
},
|
|
25566
|
+
],
|
|
25567
|
+
stateMutability: 'view',
|
|
25568
|
+
type: 'function',
|
|
25569
|
+
},
|
|
25570
|
+
{
|
|
25571
|
+
inputs: [
|
|
25572
|
+
{
|
|
25573
|
+
internalType: 'uint256',
|
|
25574
|
+
name: '',
|
|
25575
|
+
type: 'uint256',
|
|
25576
|
+
},
|
|
25577
|
+
],
|
|
25578
|
+
name: 'checkpoints',
|
|
25579
|
+
outputs: [
|
|
25580
|
+
{
|
|
25581
|
+
internalType: 'uint256',
|
|
25582
|
+
name: 'epoch',
|
|
25583
|
+
type: 'uint256',
|
|
25584
|
+
},
|
|
25585
|
+
{
|
|
25586
|
+
internalType: 'uint256',
|
|
25587
|
+
name: 'blockNumber',
|
|
25588
|
+
type: 'uint256',
|
|
25589
|
+
},
|
|
25590
|
+
{
|
|
25591
|
+
internalType: 'bytes32',
|
|
25592
|
+
name: 'eventRoot',
|
|
25593
|
+
type: 'bytes32',
|
|
25594
|
+
},
|
|
25595
|
+
],
|
|
25596
|
+
stateMutability: 'view',
|
|
25597
|
+
type: 'function',
|
|
25598
|
+
},
|
|
25599
|
+
{
|
|
25600
|
+
inputs: [],
|
|
25601
|
+
name: 'currentCheckpointBlockNumber',
|
|
25602
|
+
outputs: [
|
|
25603
|
+
{
|
|
25604
|
+
internalType: 'uint256',
|
|
25605
|
+
name: '',
|
|
25606
|
+
type: 'uint256',
|
|
25607
|
+
},
|
|
25608
|
+
],
|
|
25609
|
+
stateMutability: 'view',
|
|
25610
|
+
type: 'function',
|
|
25611
|
+
},
|
|
25612
|
+
{
|
|
25613
|
+
inputs: [],
|
|
25614
|
+
name: 'currentEpoch',
|
|
25615
|
+
outputs: [
|
|
25616
|
+
{
|
|
25617
|
+
internalType: 'uint256',
|
|
25618
|
+
name: '',
|
|
25619
|
+
type: 'uint256',
|
|
25620
|
+
},
|
|
25621
|
+
],
|
|
25622
|
+
stateMutability: 'view',
|
|
25623
|
+
type: 'function',
|
|
25624
|
+
},
|
|
25625
|
+
{
|
|
25626
|
+
inputs: [
|
|
25627
|
+
{
|
|
25628
|
+
internalType: 'uint256',
|
|
25629
|
+
name: '',
|
|
25630
|
+
type: 'uint256',
|
|
25631
|
+
},
|
|
25632
|
+
],
|
|
25633
|
+
name: 'currentValidatorSet',
|
|
25634
|
+
outputs: [
|
|
25635
|
+
{
|
|
25636
|
+
internalType: 'address',
|
|
25637
|
+
name: '_address',
|
|
25638
|
+
type: 'address',
|
|
25639
|
+
},
|
|
25640
|
+
{
|
|
25641
|
+
internalType: 'uint256',
|
|
25642
|
+
name: 'votingPower',
|
|
25643
|
+
type: 'uint256',
|
|
25644
|
+
},
|
|
25645
|
+
],
|
|
25646
|
+
stateMutability: 'view',
|
|
25647
|
+
type: 'function',
|
|
25648
|
+
},
|
|
25649
|
+
{
|
|
25650
|
+
inputs: [],
|
|
25651
|
+
name: 'currentValidatorSetHash',
|
|
25652
|
+
outputs: [
|
|
25653
|
+
{
|
|
25654
|
+
internalType: 'bytes32',
|
|
25655
|
+
name: '',
|
|
25656
|
+
type: 'bytes32',
|
|
25657
|
+
},
|
|
25658
|
+
],
|
|
25659
|
+
stateMutability: 'view',
|
|
25660
|
+
type: 'function',
|
|
25661
|
+
},
|
|
25662
|
+
{
|
|
25663
|
+
inputs: [],
|
|
25664
|
+
name: 'currentValidatorSetLength',
|
|
25665
|
+
outputs: [
|
|
25666
|
+
{
|
|
25667
|
+
internalType: 'uint256',
|
|
25668
|
+
name: '',
|
|
25669
|
+
type: 'uint256',
|
|
25670
|
+
},
|
|
25671
|
+
],
|
|
25672
|
+
stateMutability: 'view',
|
|
25673
|
+
type: 'function',
|
|
25674
|
+
},
|
|
25675
|
+
{
|
|
25676
|
+
inputs: [
|
|
25677
|
+
{
|
|
25678
|
+
internalType: 'uint256',
|
|
25679
|
+
name: 'blockNumber',
|
|
25680
|
+
type: 'uint256',
|
|
25681
|
+
},
|
|
25682
|
+
],
|
|
25683
|
+
name: 'getCheckpointBlock',
|
|
25684
|
+
outputs: [
|
|
25685
|
+
{
|
|
25686
|
+
internalType: 'bool',
|
|
25687
|
+
name: '',
|
|
25688
|
+
type: 'bool',
|
|
25689
|
+
},
|
|
25690
|
+
{
|
|
25691
|
+
internalType: 'uint256',
|
|
25692
|
+
name: '',
|
|
25693
|
+
type: 'uint256',
|
|
25694
|
+
},
|
|
25695
|
+
],
|
|
25696
|
+
stateMutability: 'view',
|
|
25697
|
+
type: 'function',
|
|
25698
|
+
},
|
|
25699
|
+
{
|
|
25700
|
+
inputs: [
|
|
25701
|
+
{
|
|
25702
|
+
internalType: 'uint256',
|
|
25703
|
+
name: 'blockNumber',
|
|
25704
|
+
type: 'uint256',
|
|
25705
|
+
},
|
|
25706
|
+
{
|
|
25707
|
+
internalType: 'bytes32',
|
|
25708
|
+
name: 'leaf',
|
|
25709
|
+
type: 'bytes32',
|
|
25710
|
+
},
|
|
25711
|
+
{
|
|
25712
|
+
internalType: 'uint256',
|
|
25713
|
+
name: 'leafIndex',
|
|
25714
|
+
type: 'uint256',
|
|
25715
|
+
},
|
|
25716
|
+
{
|
|
25717
|
+
internalType: 'bytes32[]',
|
|
25718
|
+
name: 'proof',
|
|
25719
|
+
type: 'bytes32[]',
|
|
25720
|
+
},
|
|
25721
|
+
],
|
|
25722
|
+
name: 'getEventMembershipByBlockNumber',
|
|
25723
|
+
outputs: [
|
|
25724
|
+
{
|
|
25725
|
+
internalType: 'bool',
|
|
25726
|
+
name: '',
|
|
25727
|
+
type: 'bool',
|
|
25728
|
+
},
|
|
25729
|
+
],
|
|
25730
|
+
stateMutability: 'view',
|
|
25731
|
+
type: 'function',
|
|
25732
|
+
},
|
|
25733
|
+
{
|
|
25734
|
+
inputs: [
|
|
25735
|
+
{
|
|
25736
|
+
internalType: 'uint256',
|
|
25737
|
+
name: 'epoch',
|
|
25738
|
+
type: 'uint256',
|
|
25739
|
+
},
|
|
25740
|
+
{
|
|
25741
|
+
internalType: 'bytes32',
|
|
25742
|
+
name: 'leaf',
|
|
25743
|
+
type: 'bytes32',
|
|
25744
|
+
},
|
|
25745
|
+
{
|
|
25746
|
+
internalType: 'uint256',
|
|
25747
|
+
name: 'leafIndex',
|
|
25748
|
+
type: 'uint256',
|
|
25749
|
+
},
|
|
25750
|
+
{
|
|
25751
|
+
internalType: 'bytes32[]',
|
|
25752
|
+
name: 'proof',
|
|
25753
|
+
type: 'bytes32[]',
|
|
25754
|
+
},
|
|
25755
|
+
],
|
|
25756
|
+
name: 'getEventMembershipByEpoch',
|
|
25757
|
+
outputs: [
|
|
25758
|
+
{
|
|
25759
|
+
internalType: 'bool',
|
|
25760
|
+
name: '',
|
|
25761
|
+
type: 'bool',
|
|
25762
|
+
},
|
|
25763
|
+
],
|
|
25764
|
+
stateMutability: 'view',
|
|
25765
|
+
type: 'function',
|
|
25766
|
+
},
|
|
25767
|
+
{
|
|
25768
|
+
inputs: [
|
|
25769
|
+
{
|
|
25770
|
+
internalType: 'uint256',
|
|
25771
|
+
name: 'blockNumber',
|
|
25772
|
+
type: 'uint256',
|
|
25773
|
+
},
|
|
25774
|
+
],
|
|
25775
|
+
name: 'getEventRootByBlock',
|
|
25776
|
+
outputs: [
|
|
25777
|
+
{
|
|
25778
|
+
internalType: 'bytes32',
|
|
25779
|
+
name: '',
|
|
25780
|
+
type: 'bytes32',
|
|
25781
|
+
},
|
|
25782
|
+
],
|
|
25783
|
+
stateMutability: 'view',
|
|
25784
|
+
type: 'function',
|
|
25785
|
+
},
|
|
25786
|
+
{
|
|
25787
|
+
inputs: [
|
|
25788
|
+
{
|
|
25789
|
+
internalType: 'contract IBLS',
|
|
25790
|
+
name: 'newBls',
|
|
25791
|
+
type: 'address',
|
|
25792
|
+
},
|
|
25793
|
+
{
|
|
25794
|
+
internalType: 'contract IBN256G2',
|
|
25795
|
+
name: 'newBn256G2',
|
|
25796
|
+
type: 'address',
|
|
25797
|
+
},
|
|
25798
|
+
{
|
|
25799
|
+
internalType: 'uint256',
|
|
25800
|
+
name: 'chainId_',
|
|
25801
|
+
type: 'uint256',
|
|
25802
|
+
},
|
|
25803
|
+
{
|
|
25804
|
+
components: [
|
|
25805
|
+
{
|
|
25806
|
+
internalType: 'address',
|
|
25807
|
+
name: '_address',
|
|
25808
|
+
type: 'address',
|
|
25809
|
+
},
|
|
25810
|
+
{
|
|
25811
|
+
internalType: 'uint256[4]',
|
|
25812
|
+
name: 'blsKey',
|
|
25813
|
+
type: 'uint256[4]',
|
|
25814
|
+
},
|
|
25815
|
+
{
|
|
25816
|
+
internalType: 'uint256',
|
|
25817
|
+
name: 'votingPower',
|
|
25818
|
+
type: 'uint256',
|
|
25819
|
+
},
|
|
25820
|
+
],
|
|
25821
|
+
internalType: 'struct ICheckpointManager.Validator[]',
|
|
25822
|
+
name: 'newValidatorSet',
|
|
25823
|
+
type: 'tuple[]',
|
|
25824
|
+
},
|
|
25825
|
+
],
|
|
25826
|
+
name: 'initialize',
|
|
25827
|
+
outputs: [],
|
|
25828
|
+
stateMutability: 'nonpayable',
|
|
25829
|
+
type: 'function',
|
|
25830
|
+
},
|
|
25831
|
+
{
|
|
25832
|
+
inputs: [
|
|
25833
|
+
{
|
|
25834
|
+
components: [
|
|
25835
|
+
{
|
|
25836
|
+
internalType: 'bytes32',
|
|
25837
|
+
name: 'blockHash',
|
|
25838
|
+
type: 'bytes32',
|
|
25839
|
+
},
|
|
25840
|
+
{
|
|
25841
|
+
internalType: 'uint256',
|
|
25842
|
+
name: 'blockRound',
|
|
25843
|
+
type: 'uint256',
|
|
25844
|
+
},
|
|
25845
|
+
{
|
|
25846
|
+
internalType: 'bytes32',
|
|
25847
|
+
name: 'currentValidatorSetHash',
|
|
25848
|
+
type: 'bytes32',
|
|
25849
|
+
},
|
|
25850
|
+
],
|
|
25851
|
+
internalType: 'struct ICheckpointManager.CheckpointMetadata',
|
|
25852
|
+
name: 'checkpointMetadata',
|
|
25853
|
+
type: 'tuple',
|
|
25854
|
+
},
|
|
25855
|
+
{
|
|
25856
|
+
components: [
|
|
25857
|
+
{
|
|
25858
|
+
internalType: 'uint256',
|
|
25859
|
+
name: 'epoch',
|
|
25860
|
+
type: 'uint256',
|
|
25861
|
+
},
|
|
25862
|
+
{
|
|
25863
|
+
internalType: 'uint256',
|
|
25864
|
+
name: 'blockNumber',
|
|
25865
|
+
type: 'uint256',
|
|
25866
|
+
},
|
|
25867
|
+
{
|
|
25868
|
+
internalType: 'bytes32',
|
|
25869
|
+
name: 'eventRoot',
|
|
25870
|
+
type: 'bytes32',
|
|
25871
|
+
},
|
|
25872
|
+
],
|
|
25873
|
+
internalType: 'struct ICheckpointManager.Checkpoint',
|
|
25874
|
+
name: 'checkpoint',
|
|
25875
|
+
type: 'tuple',
|
|
25876
|
+
},
|
|
25877
|
+
{
|
|
25878
|
+
internalType: 'uint256[2]',
|
|
25879
|
+
name: 'signature',
|
|
25880
|
+
type: 'uint256[2]',
|
|
25881
|
+
},
|
|
25882
|
+
{
|
|
25883
|
+
components: [
|
|
25884
|
+
{
|
|
25885
|
+
internalType: 'address',
|
|
25886
|
+
name: '_address',
|
|
25887
|
+
type: 'address',
|
|
25888
|
+
},
|
|
25889
|
+
{
|
|
25890
|
+
internalType: 'uint256[4]',
|
|
25891
|
+
name: 'blsKey',
|
|
25892
|
+
type: 'uint256[4]',
|
|
25893
|
+
},
|
|
25894
|
+
{
|
|
25895
|
+
internalType: 'uint256',
|
|
25896
|
+
name: 'votingPower',
|
|
25897
|
+
type: 'uint256',
|
|
25898
|
+
},
|
|
25899
|
+
],
|
|
25900
|
+
internalType: 'struct ICheckpointManager.Validator[]',
|
|
25901
|
+
name: 'newValidatorSet',
|
|
25902
|
+
type: 'tuple[]',
|
|
25903
|
+
},
|
|
25904
|
+
{
|
|
25905
|
+
internalType: 'bytes',
|
|
25906
|
+
name: 'bitmap',
|
|
25907
|
+
type: 'bytes',
|
|
25908
|
+
},
|
|
25909
|
+
],
|
|
25910
|
+
name: 'submit',
|
|
25911
|
+
outputs: [],
|
|
25912
|
+
stateMutability: 'nonpayable',
|
|
25913
|
+
type: 'function',
|
|
25914
|
+
},
|
|
25915
|
+
{
|
|
25916
|
+
inputs: [],
|
|
25917
|
+
name: 'totalVotingPower',
|
|
25918
|
+
outputs: [
|
|
25919
|
+
{
|
|
25920
|
+
internalType: 'uint256',
|
|
25921
|
+
name: '',
|
|
25922
|
+
type: 'uint256',
|
|
25923
|
+
},
|
|
25924
|
+
],
|
|
25925
|
+
stateMutability: 'view',
|
|
25926
|
+
type: 'function',
|
|
25927
|
+
},
|
|
25928
|
+
];
|
|
25929
|
+
|
|
25930
|
+
function decodeExtraData(extraData) {
|
|
25931
|
+
const decoded = decode(`0x${extraData.substring(66)}`);
|
|
25932
|
+
const blockExtraData = {
|
|
25933
|
+
validators: decoded[0],
|
|
25934
|
+
parent: decoded[1],
|
|
25935
|
+
committed: decoded[2],
|
|
25936
|
+
checkpoint: {
|
|
25937
|
+
blockRound: decoded[3][0],
|
|
25938
|
+
epochNumber: parseInt(decoded[3][1], 16),
|
|
25939
|
+
currentValidatorHash: decoded[3][2],
|
|
25940
|
+
nextValidatorHash: decoded[3][3],
|
|
25941
|
+
eventRoot: decoded[3][4],
|
|
25942
|
+
},
|
|
25943
|
+
};
|
|
25944
|
+
return blockExtraData;
|
|
25945
|
+
}
|
|
25946
|
+
|
|
25947
|
+
/**
|
|
25948
|
+
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
25949
|
+
*/
|
|
25950
|
+
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
25951
|
+
/**
|
|
25952
|
+
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
25953
|
+
*/
|
|
25954
|
+
const ETH_MAINNET_CHAIN_ID = '1';
|
|
25955
|
+
/**
|
|
25956
|
+
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
25957
|
+
*/
|
|
25958
|
+
const ZKEVM_DEVNET_CHAIN_ID = '13433';
|
|
25959
|
+
/**
|
|
25960
|
+
/**
|
|
25961
|
+
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
25962
|
+
*/
|
|
25963
|
+
const ZKEVM_TESTNET_CHAIN_ID = '13372';
|
|
25964
|
+
/**
|
|
25965
|
+
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
25966
|
+
*/
|
|
25967
|
+
const ZKEVM_MAINNET_CHAIN_ID = '13371';
|
|
25968
|
+
/**
|
|
25969
|
+
* @constant {string} L2_STATE_SENDER_ADDRESS - Address of bridge contract to the rootchain
|
|
25970
|
+
*/
|
|
25971
|
+
const L2_STATE_SENDER_ADDRESS = '0x0000000000000000000000000000000000001002';
|
|
25972
|
+
/**
|
|
25973
|
+
* The constant value representing the native token in the token bridge context.
|
|
25974
|
+
* The key is used to indicate the native token of a blockchain network (like Ether in Ethereum) in methods that normally require a token address.
|
|
25975
|
+
* @constant {string}
|
|
25976
|
+
*/
|
|
25977
|
+
const NATIVE_TOKEN_BRIDGE_KEY = '0x0000000000000000000000000000000000000001';
|
|
25978
|
+
/**
|
|
25979
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
25980
|
+
*/
|
|
25981
|
+
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
25982
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
25983
|
+
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
25984
|
+
};
|
|
25985
|
+
/**
|
|
25986
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
25987
|
+
*/
|
|
25988
|
+
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
25989
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
25990
|
+
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
25991
|
+
};
|
|
25992
|
+
/**
|
|
25993
|
+
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging between the Ethereum mainnet and the zkEVM mainnet.
|
|
25994
|
+
*/
|
|
25995
|
+
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
25996
|
+
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
25997
|
+
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
25998
|
+
};
|
|
25999
|
+
|
|
26000
|
+
const L2_STATE_SENDER = [
|
|
26001
|
+
{
|
|
26002
|
+
anonymous: false,
|
|
26003
|
+
inputs: [
|
|
26004
|
+
{
|
|
26005
|
+
indexed: true,
|
|
26006
|
+
internalType: 'uint256',
|
|
26007
|
+
name: 'id',
|
|
26008
|
+
type: 'uint256',
|
|
26009
|
+
},
|
|
26010
|
+
{
|
|
26011
|
+
indexed: true,
|
|
26012
|
+
internalType: 'address',
|
|
26013
|
+
name: 'sender',
|
|
26014
|
+
type: 'address',
|
|
26015
|
+
},
|
|
26016
|
+
{
|
|
26017
|
+
indexed: true,
|
|
26018
|
+
internalType: 'address',
|
|
26019
|
+
name: 'receiver',
|
|
26020
|
+
type: 'address',
|
|
26021
|
+
},
|
|
26022
|
+
{
|
|
26023
|
+
indexed: false,
|
|
26024
|
+
internalType: 'bytes',
|
|
26025
|
+
name: 'data',
|
|
26026
|
+
type: 'bytes',
|
|
26027
|
+
},
|
|
26028
|
+
],
|
|
26029
|
+
name: 'L2StateSynced',
|
|
26030
|
+
type: 'event',
|
|
26031
|
+
},
|
|
26032
|
+
{
|
|
26033
|
+
inputs: [],
|
|
26034
|
+
name: 'MAX_LENGTH',
|
|
26035
|
+
outputs: [
|
|
26036
|
+
{
|
|
26037
|
+
internalType: 'uint256',
|
|
26038
|
+
name: '',
|
|
26039
|
+
type: 'uint256',
|
|
26040
|
+
},
|
|
26041
|
+
],
|
|
26042
|
+
stateMutability: 'view',
|
|
26043
|
+
type: 'function',
|
|
26044
|
+
},
|
|
26045
|
+
{
|
|
26046
|
+
inputs: [],
|
|
26047
|
+
name: 'counter',
|
|
26048
|
+
outputs: [
|
|
26049
|
+
{
|
|
26050
|
+
internalType: 'uint256',
|
|
26051
|
+
name: '',
|
|
26052
|
+
type: 'uint256',
|
|
26053
|
+
},
|
|
26054
|
+
],
|
|
26055
|
+
stateMutability: 'view',
|
|
26056
|
+
type: 'function',
|
|
26057
|
+
},
|
|
26058
|
+
{
|
|
26059
|
+
inputs: [
|
|
26060
|
+
{
|
|
26061
|
+
internalType: 'address',
|
|
26062
|
+
name: 'receiver',
|
|
26063
|
+
type: 'address',
|
|
26064
|
+
},
|
|
26065
|
+
{
|
|
26066
|
+
internalType: 'bytes',
|
|
26067
|
+
name: 'data',
|
|
26068
|
+
type: 'bytes',
|
|
26069
|
+
},
|
|
26070
|
+
],
|
|
26071
|
+
name: 'syncState',
|
|
26072
|
+
outputs: [],
|
|
26073
|
+
stateMutability: 'nonpayable',
|
|
26074
|
+
type: 'function',
|
|
26075
|
+
},
|
|
26076
|
+
];
|
|
26077
|
+
|
|
26078
|
+
const EXIT_HELPER = [
|
|
26079
|
+
{
|
|
26080
|
+
anonymous: false,
|
|
26081
|
+
inputs: [
|
|
26082
|
+
{
|
|
26083
|
+
indexed: true,
|
|
26084
|
+
internalType: 'uint256',
|
|
26085
|
+
name: 'id',
|
|
26086
|
+
type: 'uint256',
|
|
26087
|
+
},
|
|
26088
|
+
{
|
|
26089
|
+
indexed: true,
|
|
26090
|
+
internalType: 'bool',
|
|
26091
|
+
name: 'success',
|
|
26092
|
+
type: 'bool',
|
|
26093
|
+
},
|
|
26094
|
+
{
|
|
26095
|
+
indexed: false,
|
|
26096
|
+
internalType: 'bytes',
|
|
26097
|
+
name: 'returnData',
|
|
26098
|
+
type: 'bytes',
|
|
26099
|
+
},
|
|
26100
|
+
],
|
|
26101
|
+
name: 'ExitProcessed',
|
|
26102
|
+
type: 'event',
|
|
26103
|
+
},
|
|
26104
|
+
{
|
|
26105
|
+
anonymous: false,
|
|
26106
|
+
inputs: [
|
|
26107
|
+
{
|
|
26108
|
+
indexed: false,
|
|
26109
|
+
internalType: 'uint8',
|
|
26110
|
+
name: 'version',
|
|
26111
|
+
type: 'uint8',
|
|
26112
|
+
},
|
|
26113
|
+
],
|
|
26114
|
+
name: 'Initialized',
|
|
26115
|
+
type: 'event',
|
|
26116
|
+
},
|
|
26117
|
+
{
|
|
26118
|
+
inputs: [
|
|
26119
|
+
{
|
|
26120
|
+
components: [
|
|
26121
|
+
{
|
|
26122
|
+
internalType: 'uint256',
|
|
26123
|
+
name: 'blockNumber',
|
|
26124
|
+
type: 'uint256',
|
|
26125
|
+
},
|
|
26126
|
+
{
|
|
26127
|
+
internalType: 'uint256',
|
|
26128
|
+
name: 'leafIndex',
|
|
26129
|
+
type: 'uint256',
|
|
26130
|
+
},
|
|
26131
|
+
{
|
|
26132
|
+
internalType: 'bytes',
|
|
26133
|
+
name: 'unhashedLeaf',
|
|
26134
|
+
type: 'bytes',
|
|
26135
|
+
},
|
|
26136
|
+
{
|
|
26137
|
+
internalType: 'bytes32[]',
|
|
26138
|
+
name: 'proof',
|
|
26139
|
+
type: 'bytes32[]',
|
|
26140
|
+
},
|
|
26141
|
+
],
|
|
26142
|
+
internalType: 'struct IExitHelper.BatchExitInput[]',
|
|
26143
|
+
name: 'inputs',
|
|
26144
|
+
type: 'tuple[]',
|
|
26145
|
+
},
|
|
26146
|
+
],
|
|
26147
|
+
name: 'batchExit',
|
|
26148
|
+
outputs: [],
|
|
26149
|
+
stateMutability: 'nonpayable',
|
|
26150
|
+
type: 'function',
|
|
26151
|
+
},
|
|
26152
|
+
{
|
|
26153
|
+
inputs: [],
|
|
26154
|
+
name: 'checkpointManager',
|
|
26155
|
+
outputs: [
|
|
26156
|
+
{
|
|
26157
|
+
internalType: 'contract ICheckpointManager',
|
|
26158
|
+
name: '',
|
|
26159
|
+
type: 'address',
|
|
26160
|
+
},
|
|
26161
|
+
],
|
|
26162
|
+
stateMutability: 'view',
|
|
26163
|
+
type: 'function',
|
|
26164
|
+
},
|
|
26165
|
+
{
|
|
26166
|
+
inputs: [
|
|
26167
|
+
{
|
|
26168
|
+
internalType: 'uint256',
|
|
26169
|
+
name: 'blockNumber',
|
|
26170
|
+
type: 'uint256',
|
|
26171
|
+
},
|
|
26172
|
+
{
|
|
26173
|
+
internalType: 'uint256',
|
|
26174
|
+
name: 'leafIndex',
|
|
26175
|
+
type: 'uint256',
|
|
26176
|
+
},
|
|
26177
|
+
{
|
|
26178
|
+
internalType: 'bytes',
|
|
26179
|
+
name: 'unhashedLeaf',
|
|
26180
|
+
type: 'bytes',
|
|
26181
|
+
},
|
|
26182
|
+
{
|
|
26183
|
+
internalType: 'bytes32[]',
|
|
26184
|
+
name: 'proof',
|
|
26185
|
+
type: 'bytes32[]',
|
|
26186
|
+
},
|
|
26187
|
+
],
|
|
26188
|
+
name: 'exit',
|
|
26189
|
+
outputs: [],
|
|
26190
|
+
stateMutability: 'nonpayable',
|
|
26191
|
+
type: 'function',
|
|
26192
|
+
},
|
|
26193
|
+
{
|
|
26194
|
+
inputs: [
|
|
26195
|
+
{
|
|
26196
|
+
internalType: 'contract ICheckpointManager',
|
|
26197
|
+
name: 'newCheckpointManager',
|
|
26198
|
+
type: 'address',
|
|
26199
|
+
},
|
|
26200
|
+
],
|
|
26201
|
+
name: 'initialize',
|
|
26202
|
+
outputs: [],
|
|
26203
|
+
stateMutability: 'nonpayable',
|
|
26204
|
+
type: 'function',
|
|
26205
|
+
},
|
|
26206
|
+
{
|
|
26207
|
+
inputs: [
|
|
26208
|
+
{
|
|
26209
|
+
internalType: 'uint256',
|
|
26210
|
+
name: '',
|
|
26211
|
+
type: 'uint256',
|
|
26212
|
+
},
|
|
26213
|
+
],
|
|
26214
|
+
name: 'processedExits',
|
|
26215
|
+
outputs: [
|
|
26216
|
+
{
|
|
26217
|
+
internalType: 'bool',
|
|
26218
|
+
name: '',
|
|
26219
|
+
type: 'bool',
|
|
26220
|
+
},
|
|
26221
|
+
],
|
|
26222
|
+
stateMutability: 'view',
|
|
26223
|
+
type: 'function',
|
|
26224
|
+
},
|
|
26225
|
+
];
|
|
26226
|
+
|
|
26227
|
+
const CHILD_ERC20 = [
|
|
26228
|
+
{
|
|
26229
|
+
anonymous: false,
|
|
26230
|
+
inputs: [
|
|
26231
|
+
{
|
|
26232
|
+
indexed: true,
|
|
26233
|
+
internalType: 'address',
|
|
26234
|
+
name: 'owner',
|
|
26235
|
+
type: 'address',
|
|
26236
|
+
},
|
|
26237
|
+
{
|
|
26238
|
+
indexed: true,
|
|
26239
|
+
internalType: 'address',
|
|
26240
|
+
name: 'spender',
|
|
26241
|
+
type: 'address',
|
|
26242
|
+
},
|
|
26243
|
+
{
|
|
26244
|
+
indexed: false,
|
|
26245
|
+
internalType: 'uint256',
|
|
26246
|
+
name: 'value',
|
|
26247
|
+
type: 'uint256',
|
|
26248
|
+
},
|
|
26249
|
+
],
|
|
26250
|
+
name: 'Approval',
|
|
26251
|
+
type: 'event',
|
|
26252
|
+
},
|
|
26253
|
+
{
|
|
26254
|
+
anonymous: false,
|
|
26255
|
+
inputs: [
|
|
26256
|
+
{
|
|
26257
|
+
indexed: false,
|
|
26258
|
+
internalType: 'uint8',
|
|
26259
|
+
name: 'version',
|
|
26260
|
+
type: 'uint8',
|
|
26261
|
+
},
|
|
26262
|
+
],
|
|
26263
|
+
name: 'Initialized',
|
|
26264
|
+
type: 'event',
|
|
26265
|
+
},
|
|
26266
|
+
{
|
|
26267
|
+
anonymous: false,
|
|
26268
|
+
inputs: [
|
|
26269
|
+
{
|
|
26270
|
+
indexed: false,
|
|
26271
|
+
internalType: 'address',
|
|
26272
|
+
name: 'userAddress',
|
|
26273
|
+
type: 'address',
|
|
26274
|
+
},
|
|
26275
|
+
{
|
|
26276
|
+
indexed: false,
|
|
26277
|
+
internalType: 'address',
|
|
26278
|
+
name: 'relayerAddress',
|
|
26279
|
+
type: 'address',
|
|
26280
|
+
},
|
|
26281
|
+
{
|
|
26282
|
+
indexed: false,
|
|
26283
|
+
internalType: 'bytes',
|
|
26284
|
+
name: 'functionSignature',
|
|
26285
|
+
type: 'bytes',
|
|
26286
|
+
},
|
|
26287
|
+
],
|
|
26288
|
+
name: 'MetaTransactionExecuted',
|
|
26289
|
+
type: 'event',
|
|
26290
|
+
},
|
|
26291
|
+
{
|
|
26292
|
+
anonymous: false,
|
|
26293
|
+
inputs: [
|
|
26294
|
+
{
|
|
26295
|
+
indexed: true,
|
|
26296
|
+
internalType: 'address',
|
|
26297
|
+
name: 'from',
|
|
26298
|
+
type: 'address',
|
|
26299
|
+
},
|
|
26300
|
+
{
|
|
26301
|
+
indexed: true,
|
|
26302
|
+
internalType: 'address',
|
|
26303
|
+
name: 'to',
|
|
26304
|
+
type: 'address',
|
|
26305
|
+
},
|
|
26306
|
+
{
|
|
26307
|
+
indexed: false,
|
|
26308
|
+
internalType: 'uint256',
|
|
26309
|
+
name: 'value',
|
|
26310
|
+
type: 'uint256',
|
|
26311
|
+
},
|
|
26312
|
+
],
|
|
26313
|
+
name: 'Transfer',
|
|
26314
|
+
type: 'event',
|
|
26315
|
+
},
|
|
26316
|
+
{
|
|
26317
|
+
inputs: [
|
|
26318
|
+
{
|
|
26319
|
+
internalType: 'address',
|
|
26320
|
+
name: 'owner',
|
|
26321
|
+
type: 'address',
|
|
26322
|
+
},
|
|
26323
|
+
{
|
|
26324
|
+
internalType: 'address',
|
|
26325
|
+
name: 'spender',
|
|
26326
|
+
type: 'address',
|
|
26327
|
+
},
|
|
26328
|
+
],
|
|
26329
|
+
name: 'allowance',
|
|
26330
|
+
outputs: [
|
|
26331
|
+
{
|
|
26332
|
+
internalType: 'uint256',
|
|
26333
|
+
name: '',
|
|
26334
|
+
type: 'uint256',
|
|
26335
|
+
},
|
|
26336
|
+
],
|
|
26337
|
+
stateMutability: 'view',
|
|
26338
|
+
type: 'function',
|
|
26339
|
+
},
|
|
26340
|
+
{
|
|
26341
|
+
inputs: [
|
|
26342
|
+
{
|
|
26343
|
+
internalType: 'address',
|
|
26344
|
+
name: 'spender',
|
|
26345
|
+
type: 'address',
|
|
26346
|
+
},
|
|
26347
|
+
{
|
|
26348
|
+
internalType: 'uint256',
|
|
26349
|
+
name: 'amount',
|
|
26350
|
+
type: 'uint256',
|
|
26351
|
+
},
|
|
26352
|
+
],
|
|
26353
|
+
name: 'approve',
|
|
26354
|
+
outputs: [
|
|
26355
|
+
{
|
|
26356
|
+
internalType: 'bool',
|
|
26357
|
+
name: '',
|
|
26358
|
+
type: 'bool',
|
|
26359
|
+
},
|
|
26360
|
+
],
|
|
26361
|
+
stateMutability: 'nonpayable',
|
|
26362
|
+
type: 'function',
|
|
26363
|
+
},
|
|
26364
|
+
{
|
|
26365
|
+
inputs: [
|
|
26366
|
+
{
|
|
26367
|
+
internalType: 'address',
|
|
26368
|
+
name: 'account',
|
|
26369
|
+
type: 'address',
|
|
26370
|
+
},
|
|
26371
|
+
],
|
|
26372
|
+
name: 'balanceOf',
|
|
26373
|
+
outputs: [
|
|
26374
|
+
{
|
|
26375
|
+
internalType: 'uint256',
|
|
26376
|
+
name: '',
|
|
26377
|
+
type: 'uint256',
|
|
26378
|
+
},
|
|
26379
|
+
],
|
|
26380
|
+
stateMutability: 'view',
|
|
26381
|
+
type: 'function',
|
|
26382
|
+
},
|
|
26383
|
+
{
|
|
26384
|
+
inputs: [
|
|
26385
|
+
{
|
|
26386
|
+
internalType: 'address',
|
|
26387
|
+
name: 'account',
|
|
26388
|
+
type: 'address',
|
|
26389
|
+
},
|
|
26390
|
+
{
|
|
26391
|
+
internalType: 'uint256',
|
|
26392
|
+
name: 'amount',
|
|
26393
|
+
type: 'uint256',
|
|
26394
|
+
},
|
|
26395
|
+
],
|
|
26396
|
+
name: 'burn',
|
|
26397
|
+
outputs: [
|
|
26398
|
+
{
|
|
26399
|
+
internalType: 'bool',
|
|
26400
|
+
name: '',
|
|
26401
|
+
type: 'bool',
|
|
26402
|
+
},
|
|
26403
|
+
],
|
|
26404
|
+
stateMutability: 'nonpayable',
|
|
26405
|
+
type: 'function',
|
|
26406
|
+
},
|
|
26407
|
+
{
|
|
26408
|
+
inputs: [],
|
|
26409
|
+
name: 'decimals',
|
|
26410
|
+
outputs: [
|
|
26411
|
+
{
|
|
26412
|
+
internalType: 'uint8',
|
|
26413
|
+
name: '',
|
|
26414
|
+
type: 'uint8',
|
|
26415
|
+
},
|
|
26416
|
+
],
|
|
26417
|
+
stateMutability: 'view',
|
|
26418
|
+
type: 'function',
|
|
26419
|
+
},
|
|
26420
|
+
{
|
|
26421
|
+
inputs: [
|
|
26422
|
+
{
|
|
26423
|
+
internalType: 'address',
|
|
26424
|
+
name: 'spender',
|
|
26425
|
+
type: 'address',
|
|
26426
|
+
},
|
|
26427
|
+
{
|
|
26428
|
+
internalType: 'uint256',
|
|
26429
|
+
name: 'subtractedValue',
|
|
26430
|
+
type: 'uint256',
|
|
26431
|
+
},
|
|
26432
|
+
],
|
|
26433
|
+
name: 'decreaseAllowance',
|
|
26434
|
+
outputs: [
|
|
26435
|
+
{
|
|
26436
|
+
internalType: 'bool',
|
|
26437
|
+
name: '',
|
|
26438
|
+
type: 'bool',
|
|
26439
|
+
},
|
|
26440
|
+
],
|
|
26441
|
+
stateMutability: 'nonpayable',
|
|
26442
|
+
type: 'function',
|
|
26443
|
+
},
|
|
26444
|
+
{
|
|
26445
|
+
inputs: [
|
|
26446
|
+
{
|
|
26447
|
+
internalType: 'address',
|
|
26448
|
+
name: 'userAddress',
|
|
26449
|
+
type: 'address',
|
|
26450
|
+
},
|
|
26451
|
+
{
|
|
26452
|
+
internalType: 'bytes',
|
|
26453
|
+
name: 'functionSignature',
|
|
26454
|
+
type: 'bytes',
|
|
26455
|
+
},
|
|
26456
|
+
{
|
|
26457
|
+
internalType: 'bytes32',
|
|
26458
|
+
name: 'sigR',
|
|
26459
|
+
type: 'bytes32',
|
|
26460
|
+
},
|
|
26461
|
+
{
|
|
26462
|
+
internalType: 'bytes32',
|
|
26463
|
+
name: 'sigS',
|
|
26464
|
+
type: 'bytes32',
|
|
26465
|
+
},
|
|
26466
|
+
{
|
|
26467
|
+
internalType: 'uint8',
|
|
26468
|
+
name: 'sigV',
|
|
26469
|
+
type: 'uint8',
|
|
26470
|
+
},
|
|
26471
|
+
],
|
|
26472
|
+
name: 'executeMetaTransaction',
|
|
26473
|
+
outputs: [
|
|
26474
|
+
{
|
|
26475
|
+
internalType: 'bytes',
|
|
26476
|
+
name: '',
|
|
26477
|
+
type: 'bytes',
|
|
26478
|
+
},
|
|
26479
|
+
],
|
|
26480
|
+
stateMutability: 'nonpayable',
|
|
26481
|
+
type: 'function',
|
|
26482
|
+
},
|
|
26483
|
+
{
|
|
26484
|
+
inputs: [
|
|
26485
|
+
{
|
|
26486
|
+
internalType: 'address',
|
|
26487
|
+
name: 'user',
|
|
26488
|
+
type: 'address',
|
|
26489
|
+
},
|
|
26490
|
+
],
|
|
26491
|
+
name: 'getNonce',
|
|
26492
|
+
outputs: [
|
|
26493
|
+
{
|
|
26494
|
+
internalType: 'uint256',
|
|
26495
|
+
name: 'nonce',
|
|
26496
|
+
type: 'uint256',
|
|
26497
|
+
},
|
|
26498
|
+
],
|
|
26499
|
+
stateMutability: 'view',
|
|
26500
|
+
type: 'function',
|
|
26501
|
+
},
|
|
26502
|
+
{
|
|
26503
|
+
inputs: [
|
|
26504
|
+
{
|
|
26505
|
+
internalType: 'address',
|
|
26506
|
+
name: 'spender',
|
|
26507
|
+
type: 'address',
|
|
26508
|
+
},
|
|
26509
|
+
{
|
|
26510
|
+
internalType: 'uint256',
|
|
26511
|
+
name: 'addedValue',
|
|
26512
|
+
type: 'uint256',
|
|
26513
|
+
},
|
|
26514
|
+
],
|
|
26515
|
+
name: 'increaseAllowance',
|
|
26516
|
+
outputs: [
|
|
26517
|
+
{
|
|
26518
|
+
internalType: 'bool',
|
|
26519
|
+
name: '',
|
|
26520
|
+
type: 'bool',
|
|
26521
|
+
},
|
|
26522
|
+
],
|
|
26523
|
+
stateMutability: 'nonpayable',
|
|
26524
|
+
type: 'function',
|
|
26525
|
+
},
|
|
26526
|
+
{
|
|
26527
|
+
inputs: [
|
|
26528
|
+
{
|
|
26529
|
+
internalType: 'address',
|
|
26530
|
+
name: 'rootToken_',
|
|
26531
|
+
type: 'address',
|
|
26532
|
+
},
|
|
26533
|
+
{
|
|
26534
|
+
internalType: 'string',
|
|
26535
|
+
name: 'name_',
|
|
26536
|
+
type: 'string',
|
|
26537
|
+
},
|
|
26538
|
+
{
|
|
26539
|
+
internalType: 'string',
|
|
26540
|
+
name: 'symbol_',
|
|
26541
|
+
type: 'string',
|
|
26542
|
+
},
|
|
26543
|
+
{
|
|
26544
|
+
internalType: 'uint8',
|
|
26545
|
+
name: 'decimals_',
|
|
26546
|
+
type: 'uint8',
|
|
26547
|
+
},
|
|
26548
|
+
],
|
|
26549
|
+
name: 'initialize',
|
|
26550
|
+
outputs: [],
|
|
26551
|
+
stateMutability: 'nonpayable',
|
|
26552
|
+
type: 'function',
|
|
26553
|
+
},
|
|
26554
|
+
{
|
|
26555
|
+
inputs: [
|
|
26556
|
+
{
|
|
26557
|
+
internalType: 'uint256',
|
|
26558
|
+
name: 'offset',
|
|
26559
|
+
type: 'uint256',
|
|
26560
|
+
},
|
|
26561
|
+
],
|
|
26562
|
+
name: 'invalidateNext',
|
|
26563
|
+
outputs: [],
|
|
26564
|
+
stateMutability: 'nonpayable',
|
|
26565
|
+
type: 'function',
|
|
26566
|
+
},
|
|
26567
|
+
{
|
|
26568
|
+
inputs: [
|
|
26569
|
+
{
|
|
26570
|
+
internalType: 'address',
|
|
26571
|
+
name: 'account',
|
|
26572
|
+
type: 'address',
|
|
26573
|
+
},
|
|
26574
|
+
{
|
|
26575
|
+
internalType: 'uint256',
|
|
26576
|
+
name: 'amount',
|
|
26577
|
+
type: 'uint256',
|
|
26578
|
+
},
|
|
26579
|
+
],
|
|
26580
|
+
name: 'mint',
|
|
26581
|
+
outputs: [
|
|
26582
|
+
{
|
|
26583
|
+
internalType: 'bool',
|
|
26584
|
+
name: '',
|
|
26585
|
+
type: 'bool',
|
|
26586
|
+
},
|
|
26587
|
+
],
|
|
26588
|
+
stateMutability: 'nonpayable',
|
|
26589
|
+
type: 'function',
|
|
26590
|
+
},
|
|
26591
|
+
{
|
|
26592
|
+
inputs: [],
|
|
26593
|
+
name: 'name',
|
|
26594
|
+
outputs: [
|
|
26595
|
+
{
|
|
26596
|
+
internalType: 'string',
|
|
26597
|
+
name: '',
|
|
26598
|
+
type: 'string',
|
|
26599
|
+
},
|
|
26600
|
+
],
|
|
26601
|
+
stateMutability: 'view',
|
|
26602
|
+
type: 'function',
|
|
26603
|
+
},
|
|
26604
|
+
{
|
|
26605
|
+
inputs: [],
|
|
26606
|
+
name: 'predicate',
|
|
26607
|
+
outputs: [
|
|
26608
|
+
{
|
|
26609
|
+
internalType: 'address',
|
|
26610
|
+
name: '',
|
|
26611
|
+
type: 'address',
|
|
26612
|
+
},
|
|
26613
|
+
],
|
|
26614
|
+
stateMutability: 'view',
|
|
26615
|
+
type: 'function',
|
|
26616
|
+
},
|
|
26617
|
+
{
|
|
26618
|
+
inputs: [],
|
|
26619
|
+
name: 'rootToken',
|
|
26620
|
+
outputs: [
|
|
26621
|
+
{
|
|
26622
|
+
internalType: 'address',
|
|
26623
|
+
name: '',
|
|
26624
|
+
type: 'address',
|
|
26625
|
+
},
|
|
26626
|
+
],
|
|
26627
|
+
stateMutability: 'view',
|
|
26628
|
+
type: 'function',
|
|
26629
|
+
},
|
|
26630
|
+
{
|
|
26631
|
+
inputs: [],
|
|
26632
|
+
name: 'symbol',
|
|
26633
|
+
outputs: [
|
|
26634
|
+
{
|
|
26635
|
+
internalType: 'string',
|
|
26636
|
+
name: '',
|
|
26637
|
+
type: 'string',
|
|
26638
|
+
},
|
|
26639
|
+
],
|
|
26640
|
+
stateMutability: 'view',
|
|
26641
|
+
type: 'function',
|
|
26642
|
+
},
|
|
26643
|
+
{
|
|
26644
|
+
inputs: [],
|
|
26645
|
+
name: 'totalSupply',
|
|
26646
|
+
outputs: [
|
|
26647
|
+
{
|
|
26648
|
+
internalType: 'uint256',
|
|
26649
|
+
name: '',
|
|
26650
|
+
type: 'uint256',
|
|
26651
|
+
},
|
|
26652
|
+
],
|
|
26653
|
+
stateMutability: 'view',
|
|
26654
|
+
type: 'function',
|
|
26655
|
+
},
|
|
26656
|
+
{
|
|
26657
|
+
inputs: [
|
|
26658
|
+
{
|
|
26659
|
+
internalType: 'address',
|
|
26660
|
+
name: 'to',
|
|
26661
|
+
type: 'address',
|
|
26662
|
+
},
|
|
26663
|
+
{
|
|
26664
|
+
internalType: 'uint256',
|
|
26665
|
+
name: 'amount',
|
|
26666
|
+
type: 'uint256',
|
|
26667
|
+
},
|
|
26668
|
+
],
|
|
26669
|
+
name: 'transfer',
|
|
26670
|
+
outputs: [
|
|
26671
|
+
{
|
|
26672
|
+
internalType: 'bool',
|
|
26673
|
+
name: '',
|
|
26674
|
+
type: 'bool',
|
|
26675
|
+
},
|
|
26676
|
+
],
|
|
26677
|
+
stateMutability: 'nonpayable',
|
|
26678
|
+
type: 'function',
|
|
26679
|
+
},
|
|
26680
|
+
{
|
|
26681
|
+
inputs: [
|
|
26682
|
+
{
|
|
26683
|
+
internalType: 'address',
|
|
26684
|
+
name: 'from',
|
|
26685
|
+
type: 'address',
|
|
26686
|
+
},
|
|
26687
|
+
{
|
|
26688
|
+
internalType: 'address',
|
|
26689
|
+
name: 'to',
|
|
26690
|
+
type: 'address',
|
|
26691
|
+
},
|
|
26692
|
+
{
|
|
26693
|
+
internalType: 'uint256',
|
|
26694
|
+
name: 'amount',
|
|
26695
|
+
type: 'uint256',
|
|
26696
|
+
},
|
|
26697
|
+
],
|
|
26698
|
+
name: 'transferFrom',
|
|
26699
|
+
outputs: [
|
|
26700
|
+
{
|
|
26701
|
+
internalType: 'bool',
|
|
26702
|
+
name: '',
|
|
26703
|
+
type: 'bool',
|
|
26704
|
+
},
|
|
26705
|
+
],
|
|
26706
|
+
stateMutability: 'nonpayable',
|
|
26707
|
+
type: 'function',
|
|
26708
|
+
},
|
|
26709
|
+
];
|
|
26710
|
+
|
|
26711
|
+
/**
|
|
26712
|
+
* Represents a token bridge, which manages asset transfers between two chains.
|
|
26713
|
+
*/
|
|
26714
|
+
class TokenBridge {
|
|
26715
|
+
/**
|
|
26716
|
+
* @property {BridgeConfiguration} config - The bridge configuration object.
|
|
26717
|
+
*/
|
|
26718
|
+
config;
|
|
26719
|
+
/**
|
|
26720
|
+
* Constructs a TokenBridge instance.
|
|
26721
|
+
*
|
|
26722
|
+
* @param {BridgeConfiguration} config - The bridge configuration object.
|
|
26723
|
+
*/
|
|
26724
|
+
constructor(config) {
|
|
26725
|
+
this.config = config;
|
|
26726
|
+
}
|
|
26727
|
+
/**
|
|
26728
|
+
* Retrieves the bridge fee for depositing a specific token, used to reimburse the bridge-relayer.
|
|
26729
|
+
* It is clipped from the deposit amount.
|
|
26730
|
+
*
|
|
26731
|
+
* @param {BridgeFeeRequest} req - The fee request object containing the token address for which the fee is required.
|
|
26732
|
+
* @returns {Promise<BridgeFeeResponse>} - A promise that resolves to an object containing the bridge fee for the specified token and a flag indicating if the token is bridgeable.
|
|
26733
|
+
* @throws {BridgeError} - If an error occurs during the fee retrieval, a BridgeError will be thrown with a specific error type.
|
|
26734
|
+
*
|
|
26735
|
+
* Possible BridgeError types include:
|
|
26736
|
+
* - INVALID_ADDRESS: The token address provided in the request is invalid.
|
|
26737
|
+
*
|
|
26738
|
+
* @example
|
|
26739
|
+
* const feeRequest = {
|
|
26740
|
+
* token: '0x123456...', // token
|
|
26741
|
+
* };
|
|
26742
|
+
*
|
|
26743
|
+
* @example
|
|
26744
|
+
* const feeRequest = {
|
|
26745
|
+
* token: 'NATIVE', // token
|
|
26746
|
+
* };
|
|
26747
|
+
*
|
|
26748
|
+
* bridgeSdk.getFee(feeRequest)
|
|
26749
|
+
* .then((feeResponse) => {
|
|
26750
|
+
* console.log('Bridgeable:', feeResponse.bridgeable);
|
|
26751
|
+
* console.log('Fee Amount:', feeResponse.feeAmount.toString());
|
|
26752
|
+
* })
|
|
26753
|
+
* .catch((error) => {
|
|
26754
|
+
* console.error('Error:', error.message);
|
|
26755
|
+
* });
|
|
26756
|
+
*/
|
|
26757
|
+
async getFee(req) {
|
|
26758
|
+
this.validateChainConfiguration();
|
|
26759
|
+
if (req.token !== 'NATIVE' && !isAddress(req.token)) {
|
|
26760
|
+
throw new BridgeError(`token address ${req.token} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
26761
|
+
}
|
|
26762
|
+
return {
|
|
26763
|
+
bridgeable: true,
|
|
26764
|
+
feeAmount: BigNumber.from(0),
|
|
26765
|
+
};
|
|
26766
|
+
}
|
|
26767
|
+
/**
|
|
26768
|
+
* Retrieves the unsigned approval transaction for a deposit to the bridge.
|
|
26769
|
+
* Approval is required before depositing tokens to the bridge using
|
|
26770
|
+
*
|
|
26771
|
+
* @param {ApproveBridgeRequest} req - The approve bridge request object containing the depositor address, token address, and deposit amount.
|
|
26772
|
+
* @returns {Promise<ApproveBridgeResponse>} - A promise that resolves to an object containing the unsigned approval transaction and a flag indicating if the approval is required.
|
|
26773
|
+
* @throws {BridgeError} - If an error occurs during the transaction creation, a BridgeError will be thrown with a specific error type.
|
|
26774
|
+
*
|
|
26775
|
+
* Possible BridgeError types include:
|
|
26776
|
+
* - UNSUPPORTED_ERROR: The operation is not supported. Currently thrown when attempting to deposit native tokens.
|
|
26777
|
+
* - INVALID_ADDRESS: An Ethereum address provided in the request is invalid.
|
|
26778
|
+
* - INVALID_AMOUNT: The deposit amount provided in the request is invalid (less than or equal to 0).
|
|
26779
|
+
* - INTERNAL_ERROR: An unexpected error occurred during the execution, likely due to the bridge SDK implementation.
|
|
26780
|
+
* - PROVIDER_ERROR: An error occurred while interacting with the Ethereum provider. This includes issues calling the ERC20 smart contract
|
|
26781
|
+
*
|
|
26782
|
+
* @example
|
|
26783
|
+
* const approveRequest = {
|
|
26784
|
+
* depositorAddress: '0x123456...', // Depositor's Ethereum address
|
|
26785
|
+
* token: '0xabcdef...', // ERC20 token address
|
|
26786
|
+
* depositAmount: ethers.utils.parseUnits('100', 18), // Deposit amount in token's smallest unit (e.g., wei for Ether)
|
|
26787
|
+
* };
|
|
26788
|
+
*
|
|
26789
|
+
* bridgeSdk.getUnsignedApproveDepositBridgeTx(approveRequest)
|
|
26790
|
+
* .then((approveResponse) => {
|
|
26791
|
+
* if (approveResponse.unsignedTx) {
|
|
26792
|
+
* // Send the unsigned approval transaction to the depositor to sign and send
|
|
26793
|
+
* } else {
|
|
26794
|
+
* // No approval is required
|
|
26795
|
+
* }
|
|
26796
|
+
* })
|
|
26797
|
+
* .catch((error) => {
|
|
26798
|
+
* console.error('Error:', error.message);
|
|
26799
|
+
* });
|
|
26800
|
+
*/
|
|
26801
|
+
async getUnsignedApproveDepositBridgeTx(req) {
|
|
26802
|
+
this.validateChainConfiguration();
|
|
26803
|
+
TokenBridge.validateDepositArgs(req.depositorAddress, req.depositAmount, req.token);
|
|
26804
|
+
// If the token is NATIVE, no approval is required
|
|
26805
|
+
if (req.token === 'NATIVE') {
|
|
26806
|
+
return {
|
|
26807
|
+
unsignedTx: null,
|
|
26808
|
+
};
|
|
26809
|
+
}
|
|
26810
|
+
const erc20Contract = await withBridgeError(async () => new Contract(req.token, ERC20$1, this.config.rootProvider), BridgeErrorType.PROVIDER_ERROR);
|
|
26811
|
+
// Get the current approved allowance of the RootERC20Predicate
|
|
26812
|
+
const rootERC20PredicateAllowance = await withBridgeError(() => erc20Contract.allowance(req.depositorAddress, this.config.bridgeContracts.rootChainERC20Predicate), BridgeErrorType.PROVIDER_ERROR);
|
|
26813
|
+
// If the allowance is greater than or equal to the deposit amount, no approval is required
|
|
26814
|
+
if (rootERC20PredicateAllowance.gte(req.depositAmount)) {
|
|
26815
|
+
return {
|
|
26816
|
+
unsignedTx: null,
|
|
26817
|
+
};
|
|
26818
|
+
}
|
|
26819
|
+
// Calculate the amount of tokens that need to be approved for deposit
|
|
26820
|
+
const approvalAmountRequired = req.depositAmount.sub(rootERC20PredicateAllowance);
|
|
26821
|
+
// Encode the approve function call data for the ERC20 contract
|
|
26822
|
+
const data = await withBridgeError(async () => erc20Contract.interface.encodeFunctionData('approve', [
|
|
26823
|
+
this.config.bridgeContracts.rootChainERC20Predicate,
|
|
26824
|
+
approvalAmountRequired,
|
|
26825
|
+
]), BridgeErrorType.INTERNAL_ERROR);
|
|
26826
|
+
// Create the unsigned transaction for the approval
|
|
26827
|
+
const unsignedTx = {
|
|
26828
|
+
data,
|
|
26829
|
+
to: req.token,
|
|
26830
|
+
value: 0,
|
|
26831
|
+
from: req.depositorAddress,
|
|
26832
|
+
};
|
|
26833
|
+
return {
|
|
26834
|
+
unsignedTx,
|
|
26835
|
+
};
|
|
26836
|
+
}
|
|
26837
|
+
/**
|
|
26838
|
+
* Generates an unsigned deposit transaction for a user to sign and submit to the bridge.
|
|
26839
|
+
* Must be called after bridgeSdk.getUnsignedApproveDepositBridgeTx to ensure user has approved sufficient tokens for deposit.
|
|
26840
|
+
*
|
|
26841
|
+
* @param {BridgeDepositRequest} req - The deposit request object containing the required data for depositing tokens.
|
|
26842
|
+
* @returns {Promise<BridgeDepositResponse>} - A promise that resolves to an object containing the unsigned transaction data.
|
|
26843
|
+
* @throws {BridgeError} - If an error occurs during the generation of the unsigned transaction, a BridgeError will be thrown with a specific error type.
|
|
26844
|
+
*
|
|
26845
|
+
* Possible BridgeError types include:
|
|
26846
|
+
* - UNSUPPORTED_ERROR: The operation is not supported. Currently thrown when attempting to deposit native tokens.
|
|
26847
|
+
* - INVALID_ADDRESS: An Ethereum address provided in the request is invalid. This could be the depositor's, recipient's or the token's address.
|
|
26848
|
+
* - INVALID_AMOUNT: The deposit amount provided in the request is invalid (less than or equal to 0).
|
|
26849
|
+
* - INTERNAL_ERROR: An unexpected error occurred during the execution, likely due to the bridge SDK implementation.
|
|
26850
|
+
*
|
|
26851
|
+
* @example
|
|
26852
|
+
* const depositERC20Request = {
|
|
26853
|
+
* token: '0x123456...', // ERC20 token address
|
|
26854
|
+
* depositorAddress: '0xabcdef...', // User's wallet address
|
|
26855
|
+
* recipientAddress: '0x987654...', // Destination wallet address on the target chain
|
|
26856
|
+
* depositAmount: ethers.utils.parseUnits('100', 18), // Deposit amount in wei
|
|
26857
|
+
* };
|
|
26858
|
+
*
|
|
26859
|
+
* @example
|
|
26860
|
+
* const depositEtherTokenRequest = {
|
|
26861
|
+
* token: 'NATIVE',
|
|
26862
|
+
* depositorAddress: '0xabcdef...', // User's wallet address
|
|
26863
|
+
* recipientAddress: '0x987654...', // Destination wallet address on the target chain
|
|
26864
|
+
* depositAmount: ethers.utils.parseUnits('100', 18), // Deposit amount in wei
|
|
26865
|
+
* };
|
|
26866
|
+
*
|
|
26867
|
+
* bridgeSdk.getUnsignedDepositTx(depositRequest)
|
|
26868
|
+
* .then((depositResponse) => {
|
|
26869
|
+
* console.log(depositResponse.unsignedTx);
|
|
26870
|
+
* })
|
|
26871
|
+
* .catch((error) => {
|
|
26872
|
+
* console.error('Error:', error.message);
|
|
26873
|
+
* });
|
|
26874
|
+
*/
|
|
26875
|
+
async getUnsignedDepositTx(req) {
|
|
26876
|
+
this.validateChainConfiguration();
|
|
26877
|
+
TokenBridge.validateDepositArgs(req.recipientAddress, req.depositAmount, req.token);
|
|
26878
|
+
const rootERC20PredicateContract = await withBridgeError(async () => {
|
|
26879
|
+
const contract = new Contract(this.config.bridgeContracts.rootChainERC20Predicate, ROOT_ERC20_PREDICATE);
|
|
26880
|
+
return contract;
|
|
26881
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
26882
|
+
// Convert the addresses to correct format addresses (e.g. prepend 0x if not already)
|
|
26883
|
+
const receipient = getAddress(req.recipientAddress);
|
|
26884
|
+
// Handle return if it is a native token
|
|
26885
|
+
if (req.token === 'NATIVE') {
|
|
26886
|
+
// Encode the function data into a payload
|
|
26887
|
+
const data = await withBridgeError(async () => rootERC20PredicateContract.interface.encodeFunctionData('depositNativeTo', [receipient]), BridgeErrorType.INTERNAL_ERROR);
|
|
26888
|
+
return {
|
|
26889
|
+
unsignedTx: {
|
|
26890
|
+
data,
|
|
26891
|
+
to: this.config.bridgeContracts.rootChainERC20Predicate,
|
|
26892
|
+
value: req.depositAmount,
|
|
26893
|
+
},
|
|
26894
|
+
};
|
|
26895
|
+
}
|
|
26896
|
+
// Handle return for ERC20
|
|
26897
|
+
const token = getAddress(req.token);
|
|
26898
|
+
// Encode the function data into a payload
|
|
26899
|
+
const data = await withBridgeError(async () => rootERC20PredicateContract.interface.encodeFunctionData('depositTo', [token, receipient, req.depositAmount]), BridgeErrorType.INTERNAL_ERROR);
|
|
26900
|
+
return {
|
|
26901
|
+
unsignedTx: {
|
|
26902
|
+
data,
|
|
26903
|
+
to: this.config.bridgeContracts.rootChainERC20Predicate,
|
|
26904
|
+
value: 0,
|
|
26905
|
+
},
|
|
26906
|
+
};
|
|
25157
26907
|
}
|
|
25158
26908
|
/**
|
|
25159
26909
|
* Waits for the deposit transaction to be confirmed and synced from the root chain to the child chain.
|
|
25160
26910
|
*
|
|
25161
|
-
* @param {
|
|
25162
|
-
* @returns {Promise<
|
|
26911
|
+
* @param {WaitForDepositRequest} req - The wait for request object containing the transaction hash.
|
|
26912
|
+
* @returns {Promise<WaitForDepositResponse>} - A promise that resolves to an object containing the status of the deposit transaction.
|
|
25163
26913
|
* @throws {BridgeError} - If an error occurs during the transaction confirmation or state sync, a BridgeError will be thrown with a specific error type.
|
|
25164
26914
|
*
|
|
25165
26915
|
* Possible BridgeError types include:
|
|
@@ -25180,6 +26930,7 @@ class TokenBridge {
|
|
|
25180
26930
|
* });
|
|
25181
26931
|
*/
|
|
25182
26932
|
async waitForDeposit(req) {
|
|
26933
|
+
this.validateChainConfiguration();
|
|
25183
26934
|
const rootTxReceipt = await withBridgeError(async () => this.config.rootProvider.waitForTransaction(req.transactionHash, this.config.rootChainFinalityBlocks), BridgeErrorType.PROVIDER_ERROR);
|
|
25184
26935
|
// Throw an error if the transaction was reverted
|
|
25185
26936
|
if (rootTxReceipt.status !== 1) {
|
|
@@ -25188,7 +26939,7 @@ class TokenBridge {
|
|
|
25188
26939
|
// Get the state sync ID from the transaction receipt
|
|
25189
26940
|
const stateSyncID = await withBridgeError(async () => this.getRootStateSyncID(rootTxReceipt), BridgeErrorType.PROVIDER_ERROR);
|
|
25190
26941
|
// Get the block for the timestamp
|
|
25191
|
-
const rootBlock = await this.config.rootProvider.getBlock(rootTxReceipt.blockNumber);
|
|
26942
|
+
const rootBlock = await withBridgeError(async () => await this.config.rootProvider.getBlock(rootTxReceipt.blockNumber), BridgeErrorType.PROVIDER_ERROR, `failed to query block ${rootTxReceipt.blockNumber} on rootchain`);
|
|
25192
26943
|
// Get the minimum block on childchain which corresponds with the timestamp on rootchain
|
|
25193
26944
|
const minBlockRange = await withBridgeError(async () => getBlockNumberClosestToTimestamp(this.config.childProvider, rootBlock.timestamp, this.config.blockTime, this.config.clockInaccuracy), BridgeErrorType.PROVIDER_ERROR);
|
|
25194
26945
|
// Get the upper bound for which we expect the StateSync event to occur
|
|
@@ -25199,6 +26950,271 @@ class TokenBridge {
|
|
|
25199
26950
|
status: result,
|
|
25200
26951
|
};
|
|
25201
26952
|
}
|
|
26953
|
+
/**
|
|
26954
|
+
* Retrieves the corresponding child token address for a given root token address.
|
|
26955
|
+
* This function is used to map a root token to its child token in the context of a bridging system between chains.
|
|
26956
|
+
* If the token is native, a special key is used to represent it.
|
|
26957
|
+
*
|
|
26958
|
+
* @param {RootTokenToChildTokenRequest} req - The request object containing the root token address or the string 'NATIVE'.
|
|
26959
|
+
* @returns {Promise<RootTokenToChildTokenResponse>} - A promise that resolves to an object containing the child token address.
|
|
26960
|
+
* @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
|
|
26961
|
+
*
|
|
26962
|
+
* Possible BridgeError types include:
|
|
26963
|
+
* - INVALID_ADDRESS: If the Ethereum address provided in the request is invalid.
|
|
26964
|
+
* - PROVIDER_ERROR: If there's an error in querying the rootTokenToChildToken mapping.
|
|
26965
|
+
* - INTERNAL_ERROR: An unexpected error occurred during the execution.
|
|
26966
|
+
*
|
|
26967
|
+
* @example
|
|
26968
|
+
* const request = {
|
|
26969
|
+
* rootToken: '0x123456...', // Root token address or 'NATIVE'
|
|
26970
|
+
* };
|
|
26971
|
+
*
|
|
26972
|
+
* bridgeSdk.rootTokenToChildToken(request)
|
|
26973
|
+
* .then((response) => {
|
|
26974
|
+
* console.log(response.childToken); // Child token address
|
|
26975
|
+
* })
|
|
26976
|
+
* .catch((error) => {
|
|
26977
|
+
* console.error('Error:', error.message);
|
|
26978
|
+
* });
|
|
26979
|
+
*/
|
|
26980
|
+
async rootTokenToChildToken(req) {
|
|
26981
|
+
// Validate the chain configuration to ensure proper setup
|
|
26982
|
+
this.validateChainConfiguration();
|
|
26983
|
+
// If the root token is native, use the native token key; otherwise, use the provided root token address
|
|
26984
|
+
const reqTokenAddress = (req.rootToken === 'NATIVE') ? NATIVE_TOKEN_BRIDGE_KEY : req.rootToken;
|
|
26985
|
+
// Validate the request token address
|
|
26986
|
+
if (!isAddress(reqTokenAddress)) {
|
|
26987
|
+
throw new BridgeError(`recipient address ${reqTokenAddress} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
26988
|
+
}
|
|
26989
|
+
// Create an instance of the root ERC20 predicate contract
|
|
26990
|
+
const childTokenAddress = await withBridgeError(async () => {
|
|
26991
|
+
const rootERC20Predicate = new Contract(this.config.bridgeContracts.rootChainERC20Predicate, ROOT_ERC20_PREDICATE, this.config.rootProvider);
|
|
26992
|
+
return await rootERC20Predicate.rootTokenToChildToken(reqTokenAddress);
|
|
26993
|
+
}, BridgeErrorType.PROVIDER_ERROR, 'failed to query rootTokenToChildToken mapping');
|
|
26994
|
+
// Return the child token address
|
|
26995
|
+
return {
|
|
26996
|
+
childToken: childTokenAddress,
|
|
26997
|
+
};
|
|
26998
|
+
}
|
|
26999
|
+
/**
|
|
27000
|
+
* Retrieves the corresponding root token address for a given child token address.
|
|
27001
|
+
* This function is used to map a child token back to its root token in the context of a bridging system between chains.
|
|
27002
|
+
*
|
|
27003
|
+
* If the root token address matches the address designated for the native token, the method will return 'NATIVE'.
|
|
27004
|
+
*
|
|
27005
|
+
* @param {ChildTokenToRootTokenRequest} req - The request object containing the child token address.
|
|
27006
|
+
* @returns {Promise<ChildTokenToRootTokenResponse>} - A promise that resolves to an object containing the root token address.
|
|
27007
|
+
* @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
|
|
27008
|
+
*
|
|
27009
|
+
* Possible BridgeError types include:
|
|
27010
|
+
* - PROVIDER_ERROR: If there's an error in querying the root token from the child token contract.
|
|
27011
|
+
* - INVALID_TOKEN: If the token being withdrawed is not a valid bridgeable token
|
|
27012
|
+
*
|
|
27013
|
+
* @example
|
|
27014
|
+
* const request = {
|
|
27015
|
+
* childToken: '0x123456...', // Child token address
|
|
27016
|
+
* };
|
|
27017
|
+
*
|
|
27018
|
+
* bridgeSdk.childTokenToRootToken(request)
|
|
27019
|
+
* .then((response) => {
|
|
27020
|
+
* console.log(response.rootToken); // Outputs: 'NATIVE' or Root token address
|
|
27021
|
+
* })
|
|
27022
|
+
* .catch((error) => {
|
|
27023
|
+
* console.error('Error:', error.message);
|
|
27024
|
+
* });
|
|
27025
|
+
*/
|
|
27026
|
+
async childTokenToRootToken(req) {
|
|
27027
|
+
// Validate the chain configuration to ensure proper setup
|
|
27028
|
+
this.validateChainConfiguration();
|
|
27029
|
+
// Query the corresponding root token address using the child token contract
|
|
27030
|
+
const rootToken = await withBridgeError(async () => {
|
|
27031
|
+
// Create an instance of the child token contract using the given child token address
|
|
27032
|
+
const childToken = new Contract(req.childToken, CHILD_ERC20, this.config.childProvider);
|
|
27033
|
+
return await childToken.rootToken();
|
|
27034
|
+
}, BridgeErrorType.PROVIDER_ERROR, 'failed to query the root token from the child token contract');
|
|
27035
|
+
// Check if the rootToken address is the designated native token address. If it is, return 'NATIVE'. Else, return the root token address.
|
|
27036
|
+
return {
|
|
27037
|
+
rootToken: (rootToken === NATIVE_TOKEN_BRIDGE_KEY) ? 'NATIVE' : rootToken,
|
|
27038
|
+
};
|
|
27039
|
+
}
|
|
27040
|
+
/**
|
|
27041
|
+
* Generates an unsigned transaction that a user can use to initiate a token withdrawal from the bridge.
|
|
27042
|
+
* The user must sign and submit this transaction to execute the withdrawal.
|
|
27043
|
+
*
|
|
27044
|
+
* @param {BridgeWithdrawRequest} req - The withdrawal request object containing the necessary data for withdrawing tokens.
|
|
27045
|
+
* @returns {Promise<BridgeWithdrawResponse>} - A promise that resolves to an object containing the unsigned transaction data.
|
|
27046
|
+
*
|
|
27047
|
+
* @throws {BridgeError} - If an error occurs during the generation of the unsigned transaction, a BridgeError will be thrown with a specific error type.
|
|
27048
|
+
* Possible BridgeError types include:
|
|
27049
|
+
* - INVALID_ADDRESS: The Ethereum address provided in the request is invalid. This could be the user's address or the token's address.
|
|
27050
|
+
* - INVALID_AMOUNT: The withdrawal amount provided in the request is invalid (less than or equal to 0).
|
|
27051
|
+
* - PROVIDER_ERROR: An error occurred when interacting with the Ethereum provider, likely due to a network or connectivity issue.
|
|
27052
|
+
* - INTERNAL_ERROR: An unexpected error occurred during the execution, likely due to the bridge SDK implementation.
|
|
27053
|
+
*
|
|
27054
|
+
* @example
|
|
27055
|
+
* const withdrawRequest = {
|
|
27056
|
+
* token: '0x123456...', // ERC20 token address
|
|
27057
|
+
* recipientAddress: '0xabcdef...', // Address to receive the withdrawn tokens
|
|
27058
|
+
* withdrawAmount: ethers.utils.parseUnits('100', 18), // Withdraw amount in wei
|
|
27059
|
+
* };
|
|
27060
|
+
*
|
|
27061
|
+
* bridgeSdk.getUnsignedWithdrawTx(withdrawRequest)
|
|
27062
|
+
* .then((withdrawalResponse) => {
|
|
27063
|
+
* console.log(withdrawalResponse.unsignedTx);
|
|
27064
|
+
* })
|
|
27065
|
+
* .catch((error) => {
|
|
27066
|
+
* console.error('Error:', error.message);
|
|
27067
|
+
* });
|
|
27068
|
+
*/
|
|
27069
|
+
async getUnsignedWithdrawTx(req) {
|
|
27070
|
+
// Ensure the configuration of chains is valid.
|
|
27071
|
+
this.validateChainConfiguration();
|
|
27072
|
+
// Validate the recipient address, withdrawal amount, and token.
|
|
27073
|
+
TokenBridge.validateWithdrawArgs(req.recipientAddress, req.withdrawAmount, req.token);
|
|
27074
|
+
// Create a contract instance for interacting with the ChildERC20Predicate
|
|
27075
|
+
const childERC20PredicateContract = await withBridgeError(async () => {
|
|
27076
|
+
const contract = new Contract(this.config.bridgeContracts.childChainERC20Predicate, CHILD_ERC20_PREDICATE);
|
|
27077
|
+
return contract;
|
|
27078
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
27079
|
+
// Encode the withdrawTo function call data for the ERC20 contract
|
|
27080
|
+
const data = await withBridgeError(async () => childERC20PredicateContract.interface.encodeFunctionData('withdrawTo', [
|
|
27081
|
+
req.token,
|
|
27082
|
+
req.recipientAddress,
|
|
27083
|
+
req.withdrawAmount,
|
|
27084
|
+
]), BridgeErrorType.INTERNAL_ERROR);
|
|
27085
|
+
// Construct the unsigned transaction for the withdrawal
|
|
27086
|
+
return {
|
|
27087
|
+
unsignedTx: {
|
|
27088
|
+
data,
|
|
27089
|
+
to: this.config.bridgeContracts.childChainERC20Predicate,
|
|
27090
|
+
value: 0,
|
|
27091
|
+
},
|
|
27092
|
+
};
|
|
27093
|
+
}
|
|
27094
|
+
/**
|
|
27095
|
+
* Waits for the withdrawal transaction to be confirmed in the root chain by continuously polling until the transaction is included in a checkpoint.
|
|
27096
|
+
* This function is intended to be used after executing a withdrawal transaction.
|
|
27097
|
+
*
|
|
27098
|
+
* @param {WaitForWithdrawalRequest} req - The request object containing the transaction hash of the withdrawal transaction.
|
|
27099
|
+
* @returns {Promise<WaitForWithdrawalResponse>} - A promise that resolves to an empty object once the withdrawal transaction has been confirmed in the root chain.
|
|
27100
|
+
*
|
|
27101
|
+
* @throws {BridgeError} - If an error occurs during the waiting process, a BridgeError will be thrown with a specific error type.
|
|
27102
|
+
* Possible BridgeError types include:
|
|
27103
|
+
* - PROVIDER_ERROR: An error occurred when interacting with the Ethereum provider, likely due to a network or connectivity issue.
|
|
27104
|
+
*
|
|
27105
|
+
* @example
|
|
27106
|
+
* const waitForWithdrawalRequest = {
|
|
27107
|
+
* transactionHash: '0x123456...', // Transaction hash of the withdrawal transaction
|
|
27108
|
+
* };
|
|
27109
|
+
*
|
|
27110
|
+
* bridgeSdk.waitForWithdrawal(waitForWithdrawalRequest)
|
|
27111
|
+
* .then(() => {
|
|
27112
|
+
* console.log('Withdrawal transaction has been confirmed in the root chain.');
|
|
27113
|
+
* })
|
|
27114
|
+
* .catch((error) => {
|
|
27115
|
+
* console.error('Error:', error.message);
|
|
27116
|
+
* });
|
|
27117
|
+
*/
|
|
27118
|
+
async waitForWithdrawal(req) {
|
|
27119
|
+
// Ensure the configuration of chains is valid.
|
|
27120
|
+
this.validateChainConfiguration();
|
|
27121
|
+
// Helper function to pause execution for a specified interval
|
|
27122
|
+
const pause = () => new Promise((resolve) => {
|
|
27123
|
+
setTimeout(resolve, this.config.pollInterval);
|
|
27124
|
+
});
|
|
27125
|
+
await withBridgeError(async () => {
|
|
27126
|
+
// Fetch the receipt of the withdrawal transaction
|
|
27127
|
+
const transactionReceipt = await this.config.childProvider.getTransactionReceipt(req.transactionHash);
|
|
27128
|
+
// Fetch the block in which the withdrawal transaction was included
|
|
27129
|
+
const block = await this.config.childProvider.getBlock(transactionReceipt.blockNumber);
|
|
27130
|
+
// Decode the extra data field from the block header
|
|
27131
|
+
const decodedExtraData = decodeExtraData(block.extraData);
|
|
27132
|
+
// Instantiate the checkpoint manager contract
|
|
27133
|
+
const checkpointManager = new Contract(this.config.bridgeContracts.rootChainCheckpointManager, CHECKPOINT_MANAGER, this.config.rootProvider);
|
|
27134
|
+
// Recursive function to keep checking for the child deposit event
|
|
27135
|
+
const waitForRootEpoch = async () => {
|
|
27136
|
+
// Fetch the current checkpoint epoch from the root chain
|
|
27137
|
+
const currentEpoch = await checkpointManager.currentEpoch();
|
|
27138
|
+
// If the current epoch is greater than or equal to the epoch number of the checkpoint in which the withdrawal transaction was included, the withdrawal has been confirmed in the root chain
|
|
27139
|
+
if (currentEpoch >= decodedExtraData.checkpoint.epochNumber) {
|
|
27140
|
+
return null;
|
|
27141
|
+
}
|
|
27142
|
+
// Pause execution for a specified interval before checking again
|
|
27143
|
+
await pause();
|
|
27144
|
+
// Recursive call
|
|
27145
|
+
return waitForRootEpoch();
|
|
27146
|
+
};
|
|
27147
|
+
// Start waiting for the withdrawal transaction to be confirmed in the root chain
|
|
27148
|
+
await waitForRootEpoch();
|
|
27149
|
+
}, BridgeErrorType.PROVIDER_ERROR);
|
|
27150
|
+
// Return an empty object once the withdrawal transaction has been confirmed in the root chain
|
|
27151
|
+
return {};
|
|
27152
|
+
}
|
|
27153
|
+
/**
|
|
27154
|
+
* Creates an unsigned exit transaction which, when executed, will exit the assets from the child chain to the root chain.
|
|
27155
|
+
* This function should be used after a withdraw transaction has been executed on the child chain.
|
|
27156
|
+
* It should only be executed after `waitForWithdrawal` has completed successfully.
|
|
27157
|
+
*
|
|
27158
|
+
* @param {ExitRequest} req - The request object containing the transaction hash of the withdraw transaction.
|
|
27159
|
+
* @returns {Promise<ExitResponse>} - A promise that resolves to an object containing the unsigned exit transaction.
|
|
27160
|
+
*
|
|
27161
|
+
* @throws {BridgeError} - If an error occurs during the exit transaction creation process, a BridgeError will be thrown with a specific error type.
|
|
27162
|
+
* Possible BridgeError types include:
|
|
27163
|
+
* - PROVIDER_ERROR: An error occurred when interacting with the Ethereum provider, likely due to a network or connectivity issue.
|
|
27164
|
+
* - INVALID_TRANSACTION: The deposit transaction is invalid or the L2StateSynced event log does not match the expected format.
|
|
27165
|
+
* - INTERNAL_ERROR: An internal error occurred during the function call encoding process.
|
|
27166
|
+
*
|
|
27167
|
+
* @example
|
|
27168
|
+
* const exitRequest = {
|
|
27169
|
+
* transactionHash: '0x123456...', // Transaction hash of the deposit transaction
|
|
27170
|
+
* };
|
|
27171
|
+
*
|
|
27172
|
+
* bridgeSdk.getUnsignedExitTx(exitRequest)
|
|
27173
|
+
* .then((response) => {
|
|
27174
|
+
* console.log('Unsigned exit transaction:', response.unsignedTx);
|
|
27175
|
+
* })
|
|
27176
|
+
* .catch((error) => {
|
|
27177
|
+
* console.error('Error:', error.message);
|
|
27178
|
+
* });
|
|
27179
|
+
*/
|
|
27180
|
+
async getUnsignedExitTx(req) {
|
|
27181
|
+
// Ensure the configuration of chains is valid
|
|
27182
|
+
this.validateChainConfiguration();
|
|
27183
|
+
// Fetch the receipt of the deposit transaction
|
|
27184
|
+
const txReceipt = await withBridgeError(async () => await this.config.childProvider.getTransactionReceipt(req.transactionHash), BridgeErrorType.PROVIDER_ERROR);
|
|
27185
|
+
// Filter out the StateSynced event log from the transaction receipt
|
|
27186
|
+
const stateSenderLogs = txReceipt.logs.filter((log) => log.address.toLowerCase() === L2_STATE_SENDER_ADDRESS);
|
|
27187
|
+
if (stateSenderLogs.length !== 1) {
|
|
27188
|
+
throw new BridgeError(`expected 1 log in tx ${txReceipt.transactionHash} from address ${L2_STATE_SENDER_ADDRESS}`, BridgeErrorType.INVALID_TRANSACTION);
|
|
27189
|
+
}
|
|
27190
|
+
// Parse the StateSynced event log
|
|
27191
|
+
const l2StateSyncEvent = await withBridgeError(async () => {
|
|
27192
|
+
const l2StateSenderInterface = new Interface(L2_STATE_SENDER);
|
|
27193
|
+
const event = l2StateSenderInterface.parseLog(stateSenderLogs[0]);
|
|
27194
|
+
// Throw an error if the event log doesn't match the expected format
|
|
27195
|
+
if (event.signature !== 'L2StateSynced(uint256,address,address,bytes)') {
|
|
27196
|
+
throw new Error(`expected L2StateSynced event in tx ${txReceipt.transactionHash}`);
|
|
27197
|
+
}
|
|
27198
|
+
return event;
|
|
27199
|
+
}, BridgeErrorType.INVALID_TRANSACTION);
|
|
27200
|
+
// Instantiate the exit helper contract
|
|
27201
|
+
const exitHelper = await withBridgeError(async () => new Contract(this.config.bridgeContracts.rootChainExitHelper, EXIT_HELPER, this.config.rootProvider), BridgeErrorType.PROVIDER_ERROR);
|
|
27202
|
+
// Generate the exit proof
|
|
27203
|
+
const exitProof = await withBridgeError(async () => this.config.childProvider.send('bridge_generateExitProof', [l2StateSyncEvent.args.id.toHexString()]), BridgeErrorType.PROVIDER_ERROR);
|
|
27204
|
+
// Encode the exit function call data
|
|
27205
|
+
const encodedExitTx = await withBridgeError(async () => {
|
|
27206
|
+
const exitEventEncoded = defaultAbiCoder.encode(['uint256', 'address', 'address', 'bytes'], l2StateSyncEvent.args);
|
|
27207
|
+
return exitHelper.interface.encodeFunctionData('exit', [exitProof.Metadata.CheckpointBlock, exitProof.Metadata.LeafIndex, exitEventEncoded, exitProof.Data]);
|
|
27208
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
27209
|
+
// Create the unsigned exit transaction
|
|
27210
|
+
const unsignedTx = {
|
|
27211
|
+
data: encodedExitTx,
|
|
27212
|
+
to: this.config.bridgeContracts.rootChainExitHelper,
|
|
27213
|
+
value: 0,
|
|
27214
|
+
};
|
|
27215
|
+
// Return the unsigned exit transaction
|
|
27216
|
+
return { unsignedTx };
|
|
27217
|
+
}
|
|
25202
27218
|
async waitForChildStateSync(stateSyncID, interval, minBlockRange, maxBlockRange) {
|
|
25203
27219
|
const childStateReceiver = new Contract(this.config.bridgeContracts.childChainStateReceiver, CHILD_STATE_RECEIVER, this.config.childProvider);
|
|
25204
27220
|
// Set up an event filter for the StateSyncResult event
|
|
@@ -25249,57 +27265,47 @@ class TokenBridge {
|
|
|
25249
27265
|
const stateSyncID = parseInt(stateSyncEvent.args.id, 10);
|
|
25250
27266
|
return stateSyncID;
|
|
25251
27267
|
}
|
|
25252
|
-
|
|
25253
|
-
|
|
25254
|
-
|
|
25255
|
-
|
|
25256
|
-
|
|
25257
|
-
|
|
25258
|
-
|
|
25259
|
-
}
|
|
25260
|
-
|
|
25261
|
-
|
|
25262
|
-
|
|
25263
|
-
|
|
25264
|
-
|
|
25265
|
-
|
|
25266
|
-
|
|
25267
|
-
|
|
25268
|
-
|
|
25269
|
-
|
|
25270
|
-
|
|
25271
|
-
|
|
25272
|
-
|
|
25273
|
-
|
|
25274
|
-
|
|
25275
|
-
|
|
25276
|
-
|
|
25277
|
-
|
|
25278
|
-
|
|
25279
|
-
|
|
25280
|
-
|
|
25281
|
-
|
|
25282
|
-
|
|
25283
|
-
|
|
25284
|
-
|
|
25285
|
-
|
|
25286
|
-
|
|
25287
|
-
|
|
25288
|
-
|
|
25289
|
-
|
|
25290
|
-
|
|
25291
|
-
|
|
25292
|
-
|
|
25293
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
25294
|
-
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
25295
|
-
};
|
|
25296
|
-
/**
|
|
25297
|
-
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging between the Ethereum mainnet and the zkEVM mainnet.
|
|
25298
|
-
*/
|
|
25299
|
-
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
25300
|
-
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
25301
|
-
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
25302
|
-
};
|
|
27268
|
+
static validateDepositArgs(depositorOrRecipientAddress, depositAmount, token) {
|
|
27269
|
+
if (!isAddress(depositorOrRecipientAddress)) {
|
|
27270
|
+
throw new BridgeError(`address ${depositorOrRecipientAddress} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
27271
|
+
}
|
|
27272
|
+
// The deposit amount cannot be <= 0
|
|
27273
|
+
if (depositAmount.isNegative() || depositAmount.isZero()) {
|
|
27274
|
+
throw new BridgeError(`deposit amount ${depositAmount.toString()} is invalid`, BridgeErrorType.INVALID_AMOUNT);
|
|
27275
|
+
}
|
|
27276
|
+
// If the token is not native, it must be a valid address
|
|
27277
|
+
if (token !== 'NATIVE' && !isAddress(token)) {
|
|
27278
|
+
throw new BridgeError(`token address ${token} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
27279
|
+
}
|
|
27280
|
+
}
|
|
27281
|
+
static validateWithdrawArgs(withdrawerOrRecipientAddress, withdrawAmount, token) {
|
|
27282
|
+
// Validate the withdrawer address
|
|
27283
|
+
if (!isAddress(withdrawerOrRecipientAddress)) {
|
|
27284
|
+
throw new BridgeError(`withdrawer address ${withdrawerOrRecipientAddress} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
27285
|
+
}
|
|
27286
|
+
// Validate the withdrawal amount. It cannot be zero or negative.
|
|
27287
|
+
if (withdrawAmount.isNegative() || withdrawAmount.isZero()) {
|
|
27288
|
+
throw new BridgeError(`withdraw amount ${withdrawAmount.toString()} is invalid`, BridgeErrorType.INVALID_AMOUNT);
|
|
27289
|
+
}
|
|
27290
|
+
// Check if the ERC20 Token is a valid address
|
|
27291
|
+
if (!isAddress(token)) {
|
|
27292
|
+
throw new BridgeError(`token address ${token} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
27293
|
+
}
|
|
27294
|
+
}
|
|
27295
|
+
// Query the rootchain and childchain providers to ensure the chainID is as expected by the SDK.
|
|
27296
|
+
// This is to prevent the SDK from being used on the wrong chain, especially after a chain reset.
|
|
27297
|
+
async validateChainConfiguration() {
|
|
27298
|
+
const errMessage = 'Please upgrade to the latest version of the Bridge SDK or provide valid configuration';
|
|
27299
|
+
const rootNetwork = await withBridgeError(async () => this.config.rootProvider.getNetwork(), BridgeErrorType.PROVIDER_ERROR);
|
|
27300
|
+
if (rootNetwork.chainId.toString() !== this.config.bridgeInstance.rootChainID) {
|
|
27301
|
+
throw new BridgeError(`Rootchain provider chainID ${rootNetwork.chainId} does not match expected chainID ${this.config.bridgeInstance.rootChainID}. ${errMessage}`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
27302
|
+
}
|
|
27303
|
+
const childNetwork = await this.config.childProvider.getNetwork();
|
|
27304
|
+
if (childNetwork.chainId.toString() !== this.config.bridgeInstance.childChainID) {
|
|
27305
|
+
throw new BridgeError(`Childchain provider chainID ${childNetwork.chainId} does not match expected chainID ${this.config.bridgeInstance.childChainID}. ${errMessage}`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
27306
|
+
}
|
|
27307
|
+
}
|
|
27308
|
+
}
|
|
25303
27309
|
|
|
25304
27310
|
var Environment;
|
|
25305
27311
|
(function (Environment) {
|
|
@@ -25327,20 +27333,26 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
|
|
|
25327
27333
|
*/
|
|
25328
27334
|
const CONTRACTS_FOR_BRIDGE = new Map()
|
|
25329
27335
|
.set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
|
|
25330
|
-
rootChainERC20Predicate: '
|
|
25331
|
-
rootChainStateSender: '
|
|
27336
|
+
rootChainERC20Predicate: '0xAC0f2096732D40096B3356AD76ba60a2f02366c8',
|
|
27337
|
+
rootChainStateSender: '0xeA76fcCdD791A9c231CAda787ae7535c8a5E55B5',
|
|
27338
|
+
rootChainCheckpointManager: '0x321A466aa78F5957C6E2375114915EcD14DAdE44',
|
|
27339
|
+
rootChainExitHelper: '0x55cA8C418bbB0aC87414F9ea6FFC6a33860Cf967',
|
|
25332
27340
|
childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
|
|
25333
27341
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
25334
27342
|
})
|
|
25335
27343
|
.set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
|
|
25336
27344
|
rootChainERC20Predicate: '0x0C15a8359865867CdCC44f98b2F3fd5DF098C7E0',
|
|
25337
27345
|
rootChainStateSender: '0x4C80001188db53dbc2eaAb32d5ef825feEedECA5',
|
|
27346
|
+
rootChainCheckpointManager: '0x0F3157bc91f66C350f87172bBB28d9417167074F',
|
|
27347
|
+
rootChainExitHelper: '0xB057A6C4e951a315E9f2DAe6d28B83cD0480e873',
|
|
25338
27348
|
childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
|
|
25339
27349
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
25340
27350
|
})
|
|
25341
27351
|
.set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
|
|
25342
27352
|
rootChainERC20Predicate: '0x',
|
|
25343
27353
|
rootChainStateSender: '0x',
|
|
27354
|
+
rootChainCheckpointManager: '0x',
|
|
27355
|
+
rootChainExitHelper: '0x',
|
|
25344
27356
|
childChainERC20Predicate: '0x',
|
|
25345
27357
|
childChainStateReceiver: '0x',
|
|
25346
27358
|
});
|
|
@@ -25530,7 +27542,7 @@ const calculateGasFee = (gasPriceInWei, gasUsed) => gasUsed.mul(gasPriceInWei);
|
|
|
25530
27542
|
/* Autogenerated file. Do not edit manually. */
|
|
25531
27543
|
/* tslint:disable */
|
|
25532
27544
|
/* eslint-disable */
|
|
25533
|
-
const _abi$
|
|
27545
|
+
const _abi$3 = [
|
|
25534
27546
|
{
|
|
25535
27547
|
constant: true,
|
|
25536
27548
|
inputs: [],
|
|
@@ -25753,12 +27765,12 @@ const _abi$2 = [
|
|
|
25753
27765
|
},
|
|
25754
27766
|
];
|
|
25755
27767
|
let ERC20__factory$1 = class ERC20__factory {
|
|
25756
|
-
static abi = _abi$
|
|
27768
|
+
static abi = _abi$3;
|
|
25757
27769
|
static createInterface() {
|
|
25758
|
-
return new ethers.utils.Interface(_abi$
|
|
27770
|
+
return new ethers.utils.Interface(_abi$3);
|
|
25759
27771
|
}
|
|
25760
27772
|
static connect(address, signerOrProvider) {
|
|
25761
|
-
return new ethers.Contract(address, _abi$
|
|
27773
|
+
return new ethers.Contract(address, _abi$3, signerOrProvider);
|
|
25762
27774
|
}
|
|
25763
27775
|
};
|
|
25764
27776
|
|
|
@@ -25949,6 +27961,8 @@ const DEFAULT_MAX_HOPS = 2;
|
|
|
25949
27961
|
const MAX_MAX_HOPS = 10;
|
|
25950
27962
|
// a max hop of 1 will require a direct swap with no intermediary pools
|
|
25951
27963
|
const MIN_MAX_HOPS = 1;
|
|
27964
|
+
// 10% maximum secondary fee
|
|
27965
|
+
const MAX_SECONDARY_FEE_BASIS_POINTS = 10000;
|
|
25952
27966
|
|
|
25953
27967
|
const quoteReturnMapping = {
|
|
25954
27968
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -26005,37 +28019,377 @@ const tokenInfoToUniswapToken = (tokenInfo) => new sdkCore.Token(tokenInfo.chain
|
|
|
26005
28019
|
/* Autogenerated file. Do not edit manually. */
|
|
26006
28020
|
/* tslint:disable */
|
|
26007
28021
|
/* eslint-disable */
|
|
26008
|
-
const _abi$
|
|
28022
|
+
const _abi$2 = [
|
|
26009
28023
|
{
|
|
26010
28024
|
inputs: [],
|
|
26011
28025
|
name: "getCurrentBlockTimestamp",
|
|
26012
28026
|
outputs: [
|
|
26013
28027
|
{
|
|
26014
28028
|
internalType: "uint256",
|
|
26015
|
-
name: "timestamp",
|
|
28029
|
+
name: "timestamp",
|
|
28030
|
+
type: "uint256",
|
|
28031
|
+
},
|
|
28032
|
+
],
|
|
28033
|
+
stateMutability: "view",
|
|
28034
|
+
type: "function",
|
|
28035
|
+
},
|
|
28036
|
+
{
|
|
28037
|
+
inputs: [
|
|
28038
|
+
{
|
|
28039
|
+
internalType: "address",
|
|
28040
|
+
name: "addr",
|
|
28041
|
+
type: "address",
|
|
28042
|
+
},
|
|
28043
|
+
],
|
|
28044
|
+
name: "getEthBalance",
|
|
28045
|
+
outputs: [
|
|
28046
|
+
{
|
|
28047
|
+
internalType: "uint256",
|
|
28048
|
+
name: "balance",
|
|
28049
|
+
type: "uint256",
|
|
28050
|
+
},
|
|
28051
|
+
],
|
|
28052
|
+
stateMutability: "view",
|
|
28053
|
+
type: "function",
|
|
28054
|
+
},
|
|
28055
|
+
{
|
|
28056
|
+
inputs: [
|
|
28057
|
+
{
|
|
28058
|
+
components: [
|
|
28059
|
+
{
|
|
28060
|
+
internalType: "address",
|
|
28061
|
+
name: "target",
|
|
28062
|
+
type: "address",
|
|
28063
|
+
},
|
|
28064
|
+
{
|
|
28065
|
+
internalType: "uint256",
|
|
28066
|
+
name: "gasLimit",
|
|
28067
|
+
type: "uint256",
|
|
28068
|
+
},
|
|
28069
|
+
{
|
|
28070
|
+
internalType: "bytes",
|
|
28071
|
+
name: "callData",
|
|
28072
|
+
type: "bytes",
|
|
28073
|
+
},
|
|
28074
|
+
],
|
|
28075
|
+
internalType: "struct UniswapInterfaceMulticall.Call[]",
|
|
28076
|
+
name: "calls",
|
|
28077
|
+
type: "tuple[]",
|
|
28078
|
+
},
|
|
28079
|
+
],
|
|
28080
|
+
name: "multicall",
|
|
28081
|
+
outputs: [
|
|
28082
|
+
{
|
|
28083
|
+
internalType: "uint256",
|
|
28084
|
+
name: "blockNumber",
|
|
28085
|
+
type: "uint256",
|
|
28086
|
+
},
|
|
28087
|
+
{
|
|
28088
|
+
components: [
|
|
28089
|
+
{
|
|
28090
|
+
internalType: "bool",
|
|
28091
|
+
name: "success",
|
|
28092
|
+
type: "bool",
|
|
28093
|
+
},
|
|
28094
|
+
{
|
|
28095
|
+
internalType: "uint256",
|
|
28096
|
+
name: "gasUsed",
|
|
28097
|
+
type: "uint256",
|
|
28098
|
+
},
|
|
28099
|
+
{
|
|
28100
|
+
internalType: "bytes",
|
|
28101
|
+
name: "returnData",
|
|
28102
|
+
type: "bytes",
|
|
28103
|
+
},
|
|
28104
|
+
],
|
|
28105
|
+
internalType: "struct UniswapInterfaceMulticall.Result[]",
|
|
28106
|
+
name: "returnData",
|
|
28107
|
+
type: "tuple[]",
|
|
28108
|
+
},
|
|
28109
|
+
],
|
|
28110
|
+
stateMutability: "nonpayable",
|
|
28111
|
+
type: "function",
|
|
28112
|
+
},
|
|
28113
|
+
];
|
|
28114
|
+
const _bytecode$2$1 = "0x608060405234801561001057600080fd5b50610567806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80630f28c97d146100465780631749e1e3146100645780634d2301cc14610085575b600080fd5b61004e610098565b60405161005b919061041f565b60405180910390f35b6100776100723660046102a7565b61009c565b60405161005b929190610428565b61004e610093366004610286565b610220565b4290565b8051439060609067ffffffffffffffff811180156100b957600080fd5b506040519080825280602002602001820160405280156100f357816020015b6100e061023a565b8152602001906001900390816100d85790505b50905060005b835181101561021a57600080600086848151811061011357fe5b60200260200101516000015187858151811061012b57fe5b60200260200101516020015188868151811061014357fe5b60200260200101516040015192509250925060005a90506000808573ffffffffffffffffffffffffffffffffffffffff1685856040516101839190610403565b60006040518083038160008787f1925050503d80600081146101c1576040519150601f19603f3d011682016040523d82523d6000602084013e6101c6565b606091505b509150915060005a8403905060405180606001604052808415158152602001828152602001838152508989815181106101fb57fe5b60200260200101819052505050505050505080806001019150506100f9565b50915091565b73ffffffffffffffffffffffffffffffffffffffff163190565b604051806060016040528060001515815260200160008152602001606081525090565b803573ffffffffffffffffffffffffffffffffffffffff8116811461028157600080fd5b919050565b600060208284031215610297578081fd5b6102a08261025d565b9392505050565b600060208083850312156102b9578182fd5b823567ffffffffffffffff808211156102d0578384fd5b818501915085601f8301126102e3578384fd5b8135818111156102ef57fe5b6102fc8485830201610506565b81815284810190848601875b848110156103f457813587017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0606081838f03011215610346578a8bfd5b60408051606081018181108b8211171561035c57fe5b8252610369848d0161025d565b8152818401358c82015260608401358a811115610384578d8efd5b8085019450508e603f850112610398578c8dfd5b8b8401358a8111156103a657fe5b6103b68d85601f84011601610506565b93508084528f838287010111156103cb578d8efd5b808386018e86013783018c018d9052908101919091528552509287019290870190600101610308565b50909998505050505050505050565b6000825161041581846020870161052a565b9190910192915050565b90815260200190565b600060408083018584526020828186015281865180845260609350838701915083838202880101838901875b838110156104f6578983037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa001855281518051151584528681015187850152880151888401889052805188850181905260806104b582828801858c0161052a565b96880196601f919091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01694909401909301925090850190600101610454565b50909a9950505050505050505050565b60405181810167ffffffffffffffff8111828210171561052257fe5b604052919050565b60005b8381101561054557818101518382015260200161052d565b83811115610554576000848401525b5050505056fea164736f6c6343000706000a";
|
|
28115
|
+
const isSuperArgs$2$1 = (xs) => xs.length > 1;
|
|
28116
|
+
class Multicall__factory extends ethers.ContractFactory {
|
|
28117
|
+
constructor(...args) {
|
|
28118
|
+
if (isSuperArgs$2$1(args)) {
|
|
28119
|
+
super(...args);
|
|
28120
|
+
}
|
|
28121
|
+
else {
|
|
28122
|
+
super(_abi$2, _bytecode$2$1, args[0]);
|
|
28123
|
+
}
|
|
28124
|
+
}
|
|
28125
|
+
deploy(overrides) {
|
|
28126
|
+
return super.deploy(overrides || {});
|
|
28127
|
+
}
|
|
28128
|
+
getDeployTransaction(overrides) {
|
|
28129
|
+
return super.getDeployTransaction(overrides || {});
|
|
28130
|
+
}
|
|
28131
|
+
attach(address) {
|
|
28132
|
+
return super.attach(address);
|
|
28133
|
+
}
|
|
28134
|
+
connect(signer) {
|
|
28135
|
+
return super.connect(signer);
|
|
28136
|
+
}
|
|
28137
|
+
static bytecode = _bytecode$2$1;
|
|
28138
|
+
static abi = _abi$2;
|
|
28139
|
+
static createInterface() {
|
|
28140
|
+
return new ethers.utils.Interface(_abi$2);
|
|
28141
|
+
}
|
|
28142
|
+
static connect(address, signerOrProvider) {
|
|
28143
|
+
return new ethers.Contract(address, _abi$2, signerOrProvider);
|
|
28144
|
+
}
|
|
28145
|
+
}
|
|
28146
|
+
|
|
28147
|
+
/* Autogenerated file. Do not edit manually. */
|
|
28148
|
+
/* tslint:disable */
|
|
28149
|
+
/* eslint-disable */
|
|
28150
|
+
const _abi$1$1 = [
|
|
28151
|
+
{
|
|
28152
|
+
inputs: [
|
|
28153
|
+
{
|
|
28154
|
+
internalType: "address",
|
|
28155
|
+
name: "_uniRouter",
|
|
28156
|
+
type: "address",
|
|
28157
|
+
},
|
|
28158
|
+
],
|
|
28159
|
+
stateMutability: "nonpayable",
|
|
28160
|
+
type: "constructor",
|
|
28161
|
+
},
|
|
28162
|
+
{
|
|
28163
|
+
anonymous: false,
|
|
28164
|
+
inputs: [
|
|
28165
|
+
{
|
|
28166
|
+
indexed: true,
|
|
28167
|
+
internalType: "address",
|
|
28168
|
+
name: "feeToken",
|
|
28169
|
+
type: "address",
|
|
28170
|
+
},
|
|
28171
|
+
{
|
|
28172
|
+
indexed: true,
|
|
28173
|
+
internalType: "address",
|
|
28174
|
+
name: "feePayer",
|
|
28175
|
+
type: "address",
|
|
28176
|
+
},
|
|
28177
|
+
{
|
|
28178
|
+
indexed: true,
|
|
28179
|
+
internalType: "address",
|
|
28180
|
+
name: "feeRecipient",
|
|
28181
|
+
type: "address",
|
|
28182
|
+
},
|
|
28183
|
+
{
|
|
28184
|
+
indexed: false,
|
|
28185
|
+
internalType: "uint256",
|
|
28186
|
+
name: "feeAmount",
|
|
28187
|
+
type: "uint256",
|
|
28188
|
+
},
|
|
28189
|
+
],
|
|
28190
|
+
name: "FeeTaken",
|
|
28191
|
+
type: "event",
|
|
28192
|
+
},
|
|
28193
|
+
{
|
|
28194
|
+
anonymous: false,
|
|
28195
|
+
inputs: [
|
|
28196
|
+
{
|
|
28197
|
+
indexed: true,
|
|
28198
|
+
internalType: "address",
|
|
28199
|
+
name: "previousOwner",
|
|
28200
|
+
type: "address",
|
|
28201
|
+
},
|
|
28202
|
+
{
|
|
28203
|
+
indexed: true,
|
|
28204
|
+
internalType: "address",
|
|
28205
|
+
name: "newOwner",
|
|
28206
|
+
type: "address",
|
|
28207
|
+
},
|
|
28208
|
+
],
|
|
28209
|
+
name: "OwnershipTransferred",
|
|
28210
|
+
type: "event",
|
|
28211
|
+
},
|
|
28212
|
+
{
|
|
28213
|
+
anonymous: false,
|
|
28214
|
+
inputs: [
|
|
28215
|
+
{
|
|
28216
|
+
indexed: false,
|
|
28217
|
+
internalType: "address",
|
|
28218
|
+
name: "account",
|
|
28219
|
+
type: "address",
|
|
28220
|
+
},
|
|
28221
|
+
],
|
|
28222
|
+
name: "Paused",
|
|
28223
|
+
type: "event",
|
|
28224
|
+
},
|
|
28225
|
+
{
|
|
28226
|
+
anonymous: false,
|
|
28227
|
+
inputs: [
|
|
28228
|
+
{
|
|
28229
|
+
indexed: false,
|
|
28230
|
+
internalType: "address",
|
|
28231
|
+
name: "account",
|
|
28232
|
+
type: "address",
|
|
28233
|
+
},
|
|
28234
|
+
],
|
|
28235
|
+
name: "Unpaused",
|
|
28236
|
+
type: "event",
|
|
28237
|
+
},
|
|
28238
|
+
{
|
|
28239
|
+
inputs: [],
|
|
28240
|
+
name: "BASIS_POINT_PRECISION",
|
|
28241
|
+
outputs: [
|
|
28242
|
+
{
|
|
28243
|
+
internalType: "uint16",
|
|
28244
|
+
name: "",
|
|
28245
|
+
type: "uint16",
|
|
28246
|
+
},
|
|
28247
|
+
],
|
|
28248
|
+
stateMutability: "view",
|
|
28249
|
+
type: "function",
|
|
28250
|
+
},
|
|
28251
|
+
{
|
|
28252
|
+
inputs: [],
|
|
28253
|
+
name: "MAX_SERVICE_FEE",
|
|
28254
|
+
outputs: [
|
|
28255
|
+
{
|
|
28256
|
+
internalType: "uint16",
|
|
28257
|
+
name: "",
|
|
28258
|
+
type: "uint16",
|
|
28259
|
+
},
|
|
28260
|
+
],
|
|
28261
|
+
stateMutability: "view",
|
|
28262
|
+
type: "function",
|
|
28263
|
+
},
|
|
28264
|
+
{
|
|
28265
|
+
inputs: [
|
|
28266
|
+
{
|
|
28267
|
+
components: [
|
|
28268
|
+
{
|
|
28269
|
+
internalType: "address",
|
|
28270
|
+
name: "recipient",
|
|
28271
|
+
type: "address",
|
|
28272
|
+
},
|
|
28273
|
+
{
|
|
28274
|
+
internalType: "uint16",
|
|
28275
|
+
name: "feePrcntBasisPoints",
|
|
28276
|
+
type: "uint16",
|
|
28277
|
+
},
|
|
28278
|
+
],
|
|
28279
|
+
internalType: "struct ISecondaryFee.ServiceFeeParams[]",
|
|
28280
|
+
name: "serviceFee",
|
|
28281
|
+
type: "tuple[]",
|
|
28282
|
+
},
|
|
28283
|
+
{
|
|
28284
|
+
components: [
|
|
28285
|
+
{
|
|
28286
|
+
internalType: "address",
|
|
28287
|
+
name: "tokenIn",
|
|
28288
|
+
type: "address",
|
|
28289
|
+
},
|
|
28290
|
+
{
|
|
28291
|
+
internalType: "address",
|
|
28292
|
+
name: "tokenOut",
|
|
28293
|
+
type: "address",
|
|
28294
|
+
},
|
|
28295
|
+
{
|
|
28296
|
+
internalType: "uint24",
|
|
28297
|
+
name: "fee",
|
|
28298
|
+
type: "uint24",
|
|
28299
|
+
},
|
|
28300
|
+
{
|
|
28301
|
+
internalType: "address",
|
|
28302
|
+
name: "recipient",
|
|
28303
|
+
type: "address",
|
|
28304
|
+
},
|
|
28305
|
+
{
|
|
28306
|
+
internalType: "uint256",
|
|
28307
|
+
name: "amountIn",
|
|
28308
|
+
type: "uint256",
|
|
28309
|
+
},
|
|
28310
|
+
{
|
|
28311
|
+
internalType: "uint256",
|
|
28312
|
+
name: "amountOutMinimum",
|
|
28313
|
+
type: "uint256",
|
|
28314
|
+
},
|
|
28315
|
+
{
|
|
28316
|
+
internalType: "uint160",
|
|
28317
|
+
name: "sqrtPriceLimitX96",
|
|
28318
|
+
type: "uint160",
|
|
28319
|
+
},
|
|
28320
|
+
],
|
|
28321
|
+
internalType: "struct IV3SwapRouter.ExactInputSingleParams",
|
|
28322
|
+
name: "params",
|
|
28323
|
+
type: "tuple",
|
|
28324
|
+
},
|
|
28325
|
+
],
|
|
28326
|
+
name: "exactInputSingleWithServiceFee",
|
|
28327
|
+
outputs: [
|
|
28328
|
+
{
|
|
28329
|
+
internalType: "uint256",
|
|
28330
|
+
name: "amountOut",
|
|
26016
28331
|
type: "uint256",
|
|
26017
28332
|
},
|
|
26018
28333
|
],
|
|
26019
|
-
stateMutability: "
|
|
28334
|
+
stateMutability: "payable",
|
|
26020
28335
|
type: "function",
|
|
26021
28336
|
},
|
|
26022
28337
|
{
|
|
26023
28338
|
inputs: [
|
|
26024
28339
|
{
|
|
26025
|
-
|
|
26026
|
-
|
|
26027
|
-
|
|
28340
|
+
components: [
|
|
28341
|
+
{
|
|
28342
|
+
internalType: "address",
|
|
28343
|
+
name: "recipient",
|
|
28344
|
+
type: "address",
|
|
28345
|
+
},
|
|
28346
|
+
{
|
|
28347
|
+
internalType: "uint16",
|
|
28348
|
+
name: "feePrcntBasisPoints",
|
|
28349
|
+
type: "uint16",
|
|
28350
|
+
},
|
|
28351
|
+
],
|
|
28352
|
+
internalType: "struct ISecondaryFee.ServiceFeeParams[]",
|
|
28353
|
+
name: "serviceFee",
|
|
28354
|
+
type: "tuple[]",
|
|
28355
|
+
},
|
|
28356
|
+
{
|
|
28357
|
+
components: [
|
|
28358
|
+
{
|
|
28359
|
+
internalType: "bytes",
|
|
28360
|
+
name: "path",
|
|
28361
|
+
type: "bytes",
|
|
28362
|
+
},
|
|
28363
|
+
{
|
|
28364
|
+
internalType: "address",
|
|
28365
|
+
name: "recipient",
|
|
28366
|
+
type: "address",
|
|
28367
|
+
},
|
|
28368
|
+
{
|
|
28369
|
+
internalType: "uint256",
|
|
28370
|
+
name: "amountIn",
|
|
28371
|
+
type: "uint256",
|
|
28372
|
+
},
|
|
28373
|
+
{
|
|
28374
|
+
internalType: "uint256",
|
|
28375
|
+
name: "amountOutMinimum",
|
|
28376
|
+
type: "uint256",
|
|
28377
|
+
},
|
|
28378
|
+
],
|
|
28379
|
+
internalType: "struct IV3SwapRouter.ExactInputParams",
|
|
28380
|
+
name: "params",
|
|
28381
|
+
type: "tuple",
|
|
26028
28382
|
},
|
|
26029
28383
|
],
|
|
26030
|
-
name: "
|
|
28384
|
+
name: "exactInputWithServiceFee",
|
|
26031
28385
|
outputs: [
|
|
26032
28386
|
{
|
|
26033
28387
|
internalType: "uint256",
|
|
26034
|
-
name: "
|
|
28388
|
+
name: "amountOut",
|
|
26035
28389
|
type: "uint256",
|
|
26036
28390
|
},
|
|
26037
28391
|
],
|
|
26038
|
-
stateMutability: "
|
|
28392
|
+
stateMutability: "payable",
|
|
26039
28393
|
type: "function",
|
|
26040
28394
|
},
|
|
26041
28395
|
{
|
|
@@ -26044,62 +28398,251 @@ const _abi$1$1 = [
|
|
|
26044
28398
|
components: [
|
|
26045
28399
|
{
|
|
26046
28400
|
internalType: "address",
|
|
26047
|
-
name: "
|
|
28401
|
+
name: "recipient",
|
|
28402
|
+
type: "address",
|
|
28403
|
+
},
|
|
28404
|
+
{
|
|
28405
|
+
internalType: "uint16",
|
|
28406
|
+
name: "feePrcntBasisPoints",
|
|
28407
|
+
type: "uint16",
|
|
28408
|
+
},
|
|
28409
|
+
],
|
|
28410
|
+
internalType: "struct ISecondaryFee.ServiceFeeParams[]",
|
|
28411
|
+
name: "serviceFee",
|
|
28412
|
+
type: "tuple[]",
|
|
28413
|
+
},
|
|
28414
|
+
{
|
|
28415
|
+
components: [
|
|
28416
|
+
{
|
|
28417
|
+
internalType: "address",
|
|
28418
|
+
name: "tokenIn",
|
|
28419
|
+
type: "address",
|
|
28420
|
+
},
|
|
28421
|
+
{
|
|
28422
|
+
internalType: "address",
|
|
28423
|
+
name: "tokenOut",
|
|
28424
|
+
type: "address",
|
|
28425
|
+
},
|
|
28426
|
+
{
|
|
28427
|
+
internalType: "uint24",
|
|
28428
|
+
name: "fee",
|
|
28429
|
+
type: "uint24",
|
|
28430
|
+
},
|
|
28431
|
+
{
|
|
28432
|
+
internalType: "address",
|
|
28433
|
+
name: "recipient",
|
|
26048
28434
|
type: "address",
|
|
26049
28435
|
},
|
|
26050
28436
|
{
|
|
26051
28437
|
internalType: "uint256",
|
|
26052
|
-
name: "
|
|
28438
|
+
name: "amountOut",
|
|
26053
28439
|
type: "uint256",
|
|
26054
28440
|
},
|
|
26055
28441
|
{
|
|
26056
|
-
internalType: "
|
|
26057
|
-
name: "
|
|
26058
|
-
type: "
|
|
28442
|
+
internalType: "uint256",
|
|
28443
|
+
name: "amountInMaximum",
|
|
28444
|
+
type: "uint256",
|
|
28445
|
+
},
|
|
28446
|
+
{
|
|
28447
|
+
internalType: "uint160",
|
|
28448
|
+
name: "sqrtPriceLimitX96",
|
|
28449
|
+
type: "uint160",
|
|
26059
28450
|
},
|
|
26060
28451
|
],
|
|
26061
|
-
internalType: "struct
|
|
26062
|
-
name: "
|
|
26063
|
-
type: "tuple
|
|
28452
|
+
internalType: "struct IV3SwapRouter.ExactOutputSingleParams",
|
|
28453
|
+
name: "params",
|
|
28454
|
+
type: "tuple",
|
|
26064
28455
|
},
|
|
26065
28456
|
],
|
|
26066
|
-
name: "
|
|
28457
|
+
name: "exactOutputSingleWithServiceFee",
|
|
26067
28458
|
outputs: [
|
|
26068
28459
|
{
|
|
26069
28460
|
internalType: "uint256",
|
|
26070
|
-
name: "
|
|
28461
|
+
name: "amountIn",
|
|
26071
28462
|
type: "uint256",
|
|
26072
28463
|
},
|
|
28464
|
+
],
|
|
28465
|
+
stateMutability: "payable",
|
|
28466
|
+
type: "function",
|
|
28467
|
+
},
|
|
28468
|
+
{
|
|
28469
|
+
inputs: [
|
|
26073
28470
|
{
|
|
26074
28471
|
components: [
|
|
26075
28472
|
{
|
|
26076
|
-
internalType: "
|
|
26077
|
-
name: "
|
|
26078
|
-
type: "
|
|
28473
|
+
internalType: "address",
|
|
28474
|
+
name: "recipient",
|
|
28475
|
+
type: "address",
|
|
26079
28476
|
},
|
|
26080
28477
|
{
|
|
26081
|
-
internalType: "
|
|
26082
|
-
name: "
|
|
26083
|
-
type: "
|
|
28478
|
+
internalType: "uint16",
|
|
28479
|
+
name: "feePrcntBasisPoints",
|
|
28480
|
+
type: "uint16",
|
|
26084
28481
|
},
|
|
28482
|
+
],
|
|
28483
|
+
internalType: "struct ISecondaryFee.ServiceFeeParams[]",
|
|
28484
|
+
name: "serviceFee",
|
|
28485
|
+
type: "tuple[]",
|
|
28486
|
+
},
|
|
28487
|
+
{
|
|
28488
|
+
components: [
|
|
26085
28489
|
{
|
|
26086
28490
|
internalType: "bytes",
|
|
26087
|
-
name: "
|
|
28491
|
+
name: "path",
|
|
26088
28492
|
type: "bytes",
|
|
26089
28493
|
},
|
|
28494
|
+
{
|
|
28495
|
+
internalType: "address",
|
|
28496
|
+
name: "recipient",
|
|
28497
|
+
type: "address",
|
|
28498
|
+
},
|
|
28499
|
+
{
|
|
28500
|
+
internalType: "uint256",
|
|
28501
|
+
name: "amountOut",
|
|
28502
|
+
type: "uint256",
|
|
28503
|
+
},
|
|
28504
|
+
{
|
|
28505
|
+
internalType: "uint256",
|
|
28506
|
+
name: "amountInMaximum",
|
|
28507
|
+
type: "uint256",
|
|
28508
|
+
},
|
|
26090
28509
|
],
|
|
26091
|
-
internalType: "struct
|
|
26092
|
-
name: "
|
|
26093
|
-
type: "tuple
|
|
28510
|
+
internalType: "struct IV3SwapRouter.ExactOutputParams",
|
|
28511
|
+
name: "params",
|
|
28512
|
+
type: "tuple",
|
|
28513
|
+
},
|
|
28514
|
+
],
|
|
28515
|
+
name: "exactOutputWithServiceFee",
|
|
28516
|
+
outputs: [
|
|
28517
|
+
{
|
|
28518
|
+
internalType: "uint256",
|
|
28519
|
+
name: "amountIn",
|
|
28520
|
+
type: "uint256",
|
|
28521
|
+
},
|
|
28522
|
+
],
|
|
28523
|
+
stateMutability: "payable",
|
|
28524
|
+
type: "function",
|
|
28525
|
+
},
|
|
28526
|
+
{
|
|
28527
|
+
inputs: [
|
|
28528
|
+
{
|
|
28529
|
+
internalType: "uint256",
|
|
28530
|
+
name: "deadline",
|
|
28531
|
+
type: "uint256",
|
|
28532
|
+
},
|
|
28533
|
+
{
|
|
28534
|
+
internalType: "bytes[]",
|
|
28535
|
+
name: "data",
|
|
28536
|
+
type: "bytes[]",
|
|
28537
|
+
},
|
|
28538
|
+
],
|
|
28539
|
+
name: "multicall",
|
|
28540
|
+
outputs: [
|
|
28541
|
+
{
|
|
28542
|
+
internalType: "bytes[]",
|
|
28543
|
+
name: "",
|
|
28544
|
+
type: "bytes[]",
|
|
28545
|
+
},
|
|
28546
|
+
],
|
|
28547
|
+
stateMutability: "payable",
|
|
28548
|
+
type: "function",
|
|
28549
|
+
},
|
|
28550
|
+
{
|
|
28551
|
+
inputs: [
|
|
28552
|
+
{
|
|
28553
|
+
internalType: "bytes[]",
|
|
28554
|
+
name: "data",
|
|
28555
|
+
type: "bytes[]",
|
|
28556
|
+
},
|
|
28557
|
+
],
|
|
28558
|
+
name: "multicall",
|
|
28559
|
+
outputs: [
|
|
28560
|
+
{
|
|
28561
|
+
internalType: "bytes[]",
|
|
28562
|
+
name: "results",
|
|
28563
|
+
type: "bytes[]",
|
|
28564
|
+
},
|
|
28565
|
+
],
|
|
28566
|
+
stateMutability: "nonpayable",
|
|
28567
|
+
type: "function",
|
|
28568
|
+
},
|
|
28569
|
+
{
|
|
28570
|
+
inputs: [],
|
|
28571
|
+
name: "owner",
|
|
28572
|
+
outputs: [
|
|
28573
|
+
{
|
|
28574
|
+
internalType: "address",
|
|
28575
|
+
name: "",
|
|
28576
|
+
type: "address",
|
|
28577
|
+
},
|
|
28578
|
+
],
|
|
28579
|
+
stateMutability: "view",
|
|
28580
|
+
type: "function",
|
|
28581
|
+
},
|
|
28582
|
+
{
|
|
28583
|
+
inputs: [],
|
|
28584
|
+
name: "pause",
|
|
28585
|
+
outputs: [],
|
|
28586
|
+
stateMutability: "nonpayable",
|
|
28587
|
+
type: "function",
|
|
28588
|
+
},
|
|
28589
|
+
{
|
|
28590
|
+
inputs: [],
|
|
28591
|
+
name: "paused",
|
|
28592
|
+
outputs: [
|
|
28593
|
+
{
|
|
28594
|
+
internalType: "bool",
|
|
28595
|
+
name: "",
|
|
28596
|
+
type: "bool",
|
|
28597
|
+
},
|
|
28598
|
+
],
|
|
28599
|
+
stateMutability: "view",
|
|
28600
|
+
type: "function",
|
|
28601
|
+
},
|
|
28602
|
+
{
|
|
28603
|
+
inputs: [],
|
|
28604
|
+
name: "renounceOwnership",
|
|
28605
|
+
outputs: [],
|
|
28606
|
+
stateMutability: "nonpayable",
|
|
28607
|
+
type: "function",
|
|
28608
|
+
},
|
|
28609
|
+
{
|
|
28610
|
+
inputs: [
|
|
28611
|
+
{
|
|
28612
|
+
internalType: "address",
|
|
28613
|
+
name: "newOwner",
|
|
28614
|
+
type: "address",
|
|
28615
|
+
},
|
|
28616
|
+
],
|
|
28617
|
+
name: "transferOwnership",
|
|
28618
|
+
outputs: [],
|
|
28619
|
+
stateMutability: "nonpayable",
|
|
28620
|
+
type: "function",
|
|
28621
|
+
},
|
|
28622
|
+
{
|
|
28623
|
+
inputs: [],
|
|
28624
|
+
name: "uniswapRouter",
|
|
28625
|
+
outputs: [
|
|
28626
|
+
{
|
|
28627
|
+
internalType: "contract IV3SwapRouter",
|
|
28628
|
+
name: "",
|
|
28629
|
+
type: "address",
|
|
26094
28630
|
},
|
|
26095
28631
|
],
|
|
28632
|
+
stateMutability: "view",
|
|
28633
|
+
type: "function",
|
|
28634
|
+
},
|
|
28635
|
+
{
|
|
28636
|
+
inputs: [],
|
|
28637
|
+
name: "unpause",
|
|
28638
|
+
outputs: [],
|
|
26096
28639
|
stateMutability: "nonpayable",
|
|
26097
28640
|
type: "function",
|
|
26098
28641
|
},
|
|
26099
28642
|
];
|
|
26100
|
-
const _bytecode$1$1 = "0x608060405234801561001057600080fd5b50610567806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80630f28c97d146100465780631749e1e3146100645780634d2301cc14610085575b600080fd5b61004e610098565b60405161005b919061041f565b60405180910390f35b6100776100723660046102a7565b61009c565b60405161005b929190610428565b61004e610093366004610286565b610220565b4290565b8051439060609067ffffffffffffffff811180156100b957600080fd5b506040519080825280602002602001820160405280156100f357816020015b6100e061023a565b8152602001906001900390816100d85790505b50905060005b835181101561021a57600080600086848151811061011357fe5b60200260200101516000015187858151811061012b57fe5b60200260200101516020015188868151811061014357fe5b60200260200101516040015192509250925060005a90506000808573ffffffffffffffffffffffffffffffffffffffff1685856040516101839190610403565b60006040518083038160008787f1925050503d80600081146101c1576040519150601f19603f3d011682016040523d82523d6000602084013e6101c6565b606091505b509150915060005a8403905060405180606001604052808415158152602001828152602001838152508989815181106101fb57fe5b60200260200101819052505050505050505080806001019150506100f9565b50915091565b73ffffffffffffffffffffffffffffffffffffffff163190565b604051806060016040528060001515815260200160008152602001606081525090565b803573ffffffffffffffffffffffffffffffffffffffff8116811461028157600080fd5b919050565b600060208284031215610297578081fd5b6102a08261025d565b9392505050565b600060208083850312156102b9578182fd5b823567ffffffffffffffff808211156102d0578384fd5b818501915085601f8301126102e3578384fd5b8135818111156102ef57fe5b6102fc8485830201610506565b81815284810190848601875b848110156103f457813587017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0606081838f03011215610346578a8bfd5b60408051606081018181108b8211171561035c57fe5b8252610369848d0161025d565b8152818401358c82015260608401358a811115610384578d8efd5b8085019450508e603f850112610398578c8dfd5b8b8401358a8111156103a657fe5b6103b68d85601f84011601610506565b93508084528f838287010111156103cb578d8efd5b808386018e86013783018c018d9052908101919091528552509287019290870190600101610308565b50909998505050505050505050565b6000825161041581846020870161052a565b9190910192915050565b90815260200190565b600060408083018584526020828186015281865180845260609350838701915083838202880101838901875b838110156104f6578983037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa001855281518051151584528681015187850152880151888401889052805188850181905260806104b582828801858c0161052a565b96880196601f919091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01694909401909301925090850190600101610454565b50909a9950505050505050505050565b60405181810167ffffffffffffffff8111828210171561052257fe5b604052919050565b60005b8381101561054557818101518382015260200161052d565b83811115610554576000848401525b5050505056fea164736f6c6343000706000a";
|
|
28643
|
+
const _bytecode$1$1 = "0x60806040523480156200001157600080fd5b5060405162002123380380620021238339810160408190526200003491620000c2565b6200003f3362000072565b6000805460ff60a01b19169055600180546001600160a01b0319166001600160a01b0392909216919091179055620000f4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000d557600080fd5b81516001600160a01b0381168114620000ed57600080fd5b9392505050565b61201f80620001046000396000f3fe6080604052600436106100e85760003560e01c8063735de9f71161008a578063ac9650d811610059578063ac9650d814610243578063d9a6f70514610263578063ed921d3c14610279578063f2fde38b1461028c57600080fd5b8063735de9f7146101c5578063742ac944146101fd5780638456cb59146102105780638da5cb5b1461022557600080fd5b80633f4ba83a116100c65780633f4ba83a1461014f5780635ae401dc146101665780635c975abb14610186578063715018a6146101b057600080fd5b80631411734e146100ed57806314d90e1b146101135780631fd168ff1461013c575b600080fd5b6101006100fb366004611a14565b6102ac565b6040519081526020015b60405180910390f35b34801561011f57600080fd5b506101296103e881565b60405161ffff909116815260200161010a565b61010061014a366004611a14565b61040a565b34801561015b57600080fd5b5061016461057a565b005b610179610174366004611ac0565b61058c565b60405161010a9190611b5b565b34801561019257600080fd5b50600054600160a01b900460ff16604051901515815260200161010a565b3480156101bc57600080fd5b506101646105e2565b3480156101d157600080fd5b506001546101e5906001600160a01b031681565b6040516001600160a01b03909116815260200161010a565b61010061020b366004611c50565b6105f4565b34801561021c57600080fd5b50610164610731565b34801561023157600080fd5b506000546001600160a01b03166101e5565b34801561024f57600080fd5b5061017961025e366004611ca5565b610741565b34801561026f57600080fd5b5061012961271081565b610100610287366004611c50565b610836565b34801561029857600080fd5b506101646102a7366004611ce6565b61095e565b60208101516000906001600160a01b031633148015906102d9575060208201516001600160a01b03163014155b156102ff5760405162461bcd60e51b81526004016102f690611d03565b60405180910390fd5b600061030e83600001516109d7565b905060008061037983866040015187602001518a8a808060200260200160405190810160405280939291908181526020016000905b8282101561036f5761036060408302860136819003810190611d50565b81526020019060010190610343565b50505050506109e3565b60408088018390526001600160a01b0380831660208a0152600154915163b858183f60e01b8152939550919350169063b858183f906103bc908890600401611dfc565b6020604051808303816000875af11580156103db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ff9190611e0f565b979650505050505050565b6040810151815160009190829061042090610ac4565b9050600061043185600001516109d7565b90506000806000806104a4868a606001518b604001518c602001518f8f808060200260200160405190810160405280939291908181526020016000905b8282101561049a5761048b60408302860136819003810190611d50565b8152602001906001019061046e565b5050505050610af2565b9350935093509350838960400181815250508289602001906001600160a01b031690816001600160a01b031681525050600160009054906101000a90046001600160a01b03166001600160a01b03166309b813468a6040518263ffffffff1660e01b81526004016105159190611dfc565b6020604051808303816000875af1158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190611e0f565b975061056c8787878c604001518587610bd3565b505050505050509392505050565b610582610e16565b61058a610e70565b565b6060834211156105d05760405162461bcd60e51b815260206004820152600f60248201526e111958591b1a5b99481c185cdcd959608a1b60448201526064016102f6565b6105da8383610741565b949350505050565b6105ea610e16565b61058a6000610ec5565b60608101516000906001600160a01b03163314801590610621575060608201516001600160a01b03163014155b1561063e5760405162461bcd60e51b81526004016102f690611d03565b6000806106a18460000151856080015186606001518989808060200260200160405190810160405280939291908181526020016000905b8282101561036f5761069260408302860136819003810190611d50565b81526020019060010190610675565b608086018290526001600160a01b0380821660608801526001546040516304e45aaf60e01b815293955091935016906304e45aaf906106e4908790600401611e28565b6020604051808303816000875af1158015610703573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107279190611e0f565b9695505050505050565b610739610e16565b61058a610f15565b6060816001600160401b0381111561075b5761075b61189c565b60405190808252806020026020018201604052801561078e57816020015b60608152602001906001900390816107795790505b50905060005b8281101561082e576107fe308585848181106107b2576107b2611e87565b90506020028101906107c49190611e9d565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f5892505050565b82828151811061081057610810611e87565b6020026020010181905250808061082690611ef9565b915050610794565b505b92915050565b600080826080015190506000806000806108ab87600001518860a0015189608001518a606001518d8d808060200260200160405190810160405280939291908181526020016000905b8282101561049a5761089c60408302860136819003810190611d50565b8152602001906001019061087f565b60808b018490526001600160a01b0380841660608d0152600154604051635023b4df60e01b815295995093975091955093501690635023b4df906108f3908a90600401611e28565b6020604051808303816000875af1158015610912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109369190611e0f565b955061095285886000015189602001518a608001518587610bd3565b50505050509392505050565b610966610e16565b6001600160a01b0381166109cb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102f6565b6109d481610ec5565b50565b60006108308282610f84565b600080548190600160a01b900460ff16610a2257600080610a048786610fe9565b9092509050610a138288611f12565b9650610a1f88826111c6565b50505b6040516323b872dd60e01b8152336004820152306024820152604481018690526001600160a01b038716906323b872dd906064016020604051808303816000875af1158015610a75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a999190611f25565b50610aa48686611341565b306001600160a01b03851603610ab8573393505b50929491935090915050565b60008060148351610ad59190611f12565b90506000610ae584836014611438565b90506105da816000610f84565b6000806060818082610b0e60005460ff600160a01b9091041690565b610b2e57610b1c8988610fe9565b9092509050610b2b828a611f47565b98505b6001600160a01b0388163014610b42573097505b610b4c8b8b611341565b6040516323b872dd60e01b8152336004820152306024820152604481018b90526001600160a01b038c16906323b872dd906064016020604051808303816000875af1158015610b9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc39190611f25565b50979a9699509697505050505050565b600054600160a01b900460ff16610bee57610bee8482611545565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015610c35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c599190611e0f565b9050610c658385611f12565b811015610cb45760405162461bcd60e51b815260206004820181905260248201527f696e636f72726563742066656520616d6f756e7420646973747269627574656460448201526064016102f6565b60405163a9059cbb60e01b8152336004820152602481018890526001600160a01b0386169063a9059cbb906044016020604051808303816000875af1158015610d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d259190611f25565b506040516370a0823160e01b81523060048201526000906001600160a01b038816906370a0823190602401602060405180830381865afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190611e0f565b90508015610e0c5760405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0388169063a9059cbb906044016020604051808303816000875af1158015610de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0a9190611f25565b505b5050505050505050565b6000546001600160a01b0316331461058a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102f6565b610e786116b4565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610f1d611704565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610ea83390565b6060610f7d8383604051806060016040528060278152602001611fc360279139611751565b9392505050565b6000610f91826014611f47565b83511015610fd95760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016102f6565b500160200151600160601b900490565b6000606081805b845181101561103a5784818151811061100b5761100b611e87565b60200260200101516020015161ffff16826110269190611f47565b91508061103281611ef9565b915050610ff0565b506103e881111561108d5760405162461bcd60e51b815260206004820152601d60248201527f5365727669636520666565203e204d41585f534552564943455f46454500000060448201526064016102f6565b60008085516001600160401b038111156110a9576110a961189c565b6040519080825280602002602001820160405280156110ee57816020015b60408051808201909152600080825260208201528152602001906001900390816110c75790505b50905060005b86518110156111b757600061271061ffff1688838151811061111857611118611e87565b60200260200101516020015161ffff168a6111339190611f5a565b61113d9190611f71565b9050604051806040016040528089848151811061115c5761115c611e87565b6020026020010151600001516001600160a01b031681526020018281525083838151811061118c5761118c611e87565b60209081029190910101526111a18185611f47565b93505080806111af90611ef9565b9150506110f4565b509093509150505b9250929050565b60005b815181101561133c57826001600160a01b03166323b872dd338484815181106111f4576111f4611e87565b60200260200101516000015185858151811061121257611212611e87565b60209081029190910181015101516040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611274573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112989190611f25565b508181815181106112ab576112ab611e87565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061130757611307611e87565b60200260200101516020015160405161132291815260200190565b60405180910390a48061133481611ef9565b9150506111c9565b505050565b600154604051636eb1769f60e11b81523060048201526001600160a01b039182166024820152829184169063dd62ed3e90604401602060405180830381865afa158015611392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b69190611e0f565b10156114345760015460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529083169063095ea7b3906044016020604051808303816000875af1158015611410573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c9190611f25565b5050565b60608161144681601f611f47565b10156114855760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016102f6565b61148f8284611f47565b845110156114d35760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016102f6565b6060821580156114f2576040519150600082526020820160405261153c565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561152b578051835260209283019201611513565b5050858452601f01601f1916604052505b50949350505050565b60005b815181101561133c57826001600160a01b031663a9059cbb83838151811061157257611572611e87565b60200260200101516000015184848151811061159057611590611e87565b6020026020010151602001516040518363ffffffff1660e01b81526004016115cd9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af11580156115ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116109190611f25565b5081818151811061162357611623611e87565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061167f5761167f611e87565b60200260200101516020015160405161169a91815260200190565b60405180910390a4806116ac81611ef9565b915050611548565b600054600160a01b900460ff1661058a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016102f6565b600054600160a01b900460ff161561058a5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016102f6565b6060600080856001600160a01b03168560405161176e9190611f93565b600060405180830381855af49150503d80600081146117a9576040519150601f19603f3d011682016040523d82523d6000602084013e6117ae565b606091505b50915091506107278683838760608315611829578251600003611822576001600160a01b0385163b6118225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102f6565b50816105da565b6105da838381511561183e5781518083602001fd5b8060405162461bcd60e51b81526004016102f69190611faf565b60008083601f84011261186a57600080fd5b5081356001600160401b0381111561188157600080fd5b6020830191508360208260061b85010111156111bf57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156118d4576118d461189c565b60405290565b60405160e081016001600160401b03811182821017156118d4576118d461189c565b604051601f8201601f191681016001600160401b03811182821017156119245761192461189c565b604052919050565b6001600160a01b03811681146109d457600080fd5b803561194c8161192c565b919050565b60006080828403121561196357600080fd5b61196b6118b2565b905081356001600160401b038082111561198457600080fd5b818401915084601f83011261199857600080fd5b81356020828211156119ac576119ac61189c565b6119be601f8301601f191682016118fc565b925081835286818386010111156119d457600080fd5b818185018285013760008183850101528285526119f2818701611941565b8186015250505050604082013560408201526060820135606082015292915050565b600080600060408486031215611a2957600080fd5b83356001600160401b0380821115611a4057600080fd5b611a4c87838801611858565b90955093506020860135915080821115611a6557600080fd5b50611a7286828701611951565b9150509250925092565b60008083601f840112611a8e57600080fd5b5081356001600160401b03811115611aa557600080fd5b6020830191508360208260051b85010111156111bf57600080fd5b600080600060408486031215611ad557600080fd5b8335925060208401356001600160401b03811115611af257600080fd5b611afe86828701611a7c565b9497909650939450505050565b60005b83811015611b26578181015183820152602001611b0e565b50506000910152565b60008151808452611b47816020860160208601611b0b565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015611bb057603f19888603018452611b9e858351611b2f565b94509285019290850190600101611b82565b5092979650505050505050565b600060e08284031215611bcf57600080fd5b611bd76118da565b90508135611be48161192c565b81526020820135611bf48161192c565b6020820152604082013562ffffff81168114611c0f57600080fd5b6040820152611c2060608301611941565b60608201526080820135608082015260a082013560a0820152611c4560c08301611941565b60c082015292915050565b60008060006101008486031215611c6657600080fd5b83356001600160401b03811115611c7c57600080fd5b611c8886828701611858565b9094509250611c9c90508560208601611bbd565b90509250925092565b60008060208385031215611cb857600080fd5b82356001600160401b03811115611cce57600080fd5b611cda85828601611a7c565b90969095509350505050565b600060208284031215611cf857600080fd5b8135610f7d8161192c565b6020808252602d908201527f726563697069656e74206d757374206265206d73672e73656e646572206f722060408201526c1d1a1a5cc818dbdb9d1c9858dd609a1b606082015260800190565b600060408284031215611d6257600080fd5b604051604081018181106001600160401b0382111715611d8457611d8461189c565b6040528235611d928161192c565b8152602083013561ffff81168114611da957600080fd5b60208201529392505050565b6000815160808452611dca6080850182611b2f565b6020848101516001600160a01b0316908601526040808501519086015260609384015193909401929092525090919050565b602081526000610f7d6020830184611db5565b600060208284031215611e2157600080fd5b5051919050565b60e08101610830828480516001600160a01b03908116835260208083015182169084015260408083015162ffffff16908401526060808301518216908401526080808301519084015260a0828101519084015260c09182015116910152565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611eb457600080fd5b8301803591506001600160401b03821115611ece57600080fd5b6020019150368190038213156111bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611f0b57611f0b611ee3565b5060010190565b8181038181111561083057610830611ee3565b600060208284031215611f3757600080fd5b81518015158114610f7d57600080fd5b8082018082111561083057610830611ee3565b808202811582820484141761083057610830611ee3565b600082611f8e57634e487b7160e01b600052601260045260246000fd5b500490565b60008251611fa5818460208701611b0b565b9190910192915050565b602081526000610f7d6020830184611b2f56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203925f97cd63c2e61736a2a442ff1d4bf966f453350e9df354a849229f69092cf64736f6c63430008130033";
|
|
26101
28644
|
const isSuperArgs$1$1 = (xs) => xs.length > 1;
|
|
26102
|
-
class
|
|
28645
|
+
class SecondaryFee__factory extends ethers.ContractFactory {
|
|
26103
28646
|
constructor(...args) {
|
|
26104
28647
|
if (isSuperArgs$1$1(args)) {
|
|
26105
28648
|
super(...args);
|
|
@@ -26108,11 +28651,11 @@ class Multicall__factory extends ethers.ContractFactory {
|
|
|
26108
28651
|
super(_abi$1$1, _bytecode$1$1, args[0]);
|
|
26109
28652
|
}
|
|
26110
28653
|
}
|
|
26111
|
-
deploy(overrides) {
|
|
26112
|
-
return super.deploy(overrides || {});
|
|
28654
|
+
deploy(_uniRouter, overrides) {
|
|
28655
|
+
return super.deploy(_uniRouter, overrides || {});
|
|
26113
28656
|
}
|
|
26114
|
-
getDeployTransaction(overrides) {
|
|
26115
|
-
return super.getDeployTransaction(overrides || {});
|
|
28657
|
+
getDeployTransaction(_uniRouter, overrides) {
|
|
28658
|
+
return super.getDeployTransaction(_uniRouter, overrides || {});
|
|
26116
28659
|
}
|
|
26117
28660
|
attach(address) {
|
|
26118
28661
|
return super.attach(address);
|
|
@@ -27508,7 +30051,81 @@ maxHops) => {
|
|
|
27508
30051
|
return routes;
|
|
27509
30052
|
};
|
|
27510
30053
|
|
|
27511
|
-
|
|
30054
|
+
const zeroNativeCurrencyValue = '0x00';
|
|
30055
|
+
const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
|
|
30056
|
+
function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
|
|
30057
|
+
const secondaryFeeValues = secondaryFees.map((fee) => ({
|
|
30058
|
+
feePrcntBasisPoints: fee.feeBasisPoints,
|
|
30059
|
+
recipient: fee.feeRecipient,
|
|
30060
|
+
}));
|
|
30061
|
+
if (trade.tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
30062
|
+
return secondaryFeeContract.encodeFunctionData('exactInputSingleWithServiceFee', [secondaryFeeValues, {
|
|
30063
|
+
tokenIn: route.tokenPath[0].address,
|
|
30064
|
+
tokenOut: route.tokenPath[1].address,
|
|
30065
|
+
fee: route.pools[0].fee,
|
|
30066
|
+
recipient: fromAddress,
|
|
30067
|
+
amountIn,
|
|
30068
|
+
amountOutMinimum: amountOut,
|
|
30069
|
+
sqrtPriceLimitX96: 0,
|
|
30070
|
+
}]);
|
|
30071
|
+
}
|
|
30072
|
+
return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithServiceFee', [secondaryFeeValues, {
|
|
30073
|
+
tokenIn: route.tokenPath[0].address,
|
|
30074
|
+
tokenOut: route.tokenPath[1].address,
|
|
30075
|
+
fee: route.pools[0].fee,
|
|
30076
|
+
recipient: fromAddress,
|
|
30077
|
+
amountInMaximum: amountIn,
|
|
30078
|
+
amountOut,
|
|
30079
|
+
sqrtPriceLimitX96: 0,
|
|
30080
|
+
}]);
|
|
30081
|
+
}
|
|
30082
|
+
function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
|
|
30083
|
+
const path = v3Sdk.encodeRouteToPath(route, trade.tradeType === sdkCore.TradeType.EXACT_OUTPUT);
|
|
30084
|
+
const secondaryFeeValues = secondaryFees.map((fee) => ({
|
|
30085
|
+
feePrcntBasisPoints: fee.feeBasisPoints,
|
|
30086
|
+
recipient: fee.feeRecipient,
|
|
30087
|
+
}));
|
|
30088
|
+
if (trade.tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
30089
|
+
return secondaryFeeContract.encodeFunctionData('exactInputWithServiceFee', [secondaryFeeValues, {
|
|
30090
|
+
path,
|
|
30091
|
+
recipient: fromAddress,
|
|
30092
|
+
amountIn,
|
|
30093
|
+
amountOutMinimum: amountOut,
|
|
30094
|
+
}]);
|
|
30095
|
+
}
|
|
30096
|
+
return secondaryFeeContract.encodeFunctionData('exactOutputWithServiceFee', [secondaryFeeValues, {
|
|
30097
|
+
path,
|
|
30098
|
+
recipient: fromAddress,
|
|
30099
|
+
amountInMaximum: amountIn,
|
|
30100
|
+
amountOut,
|
|
30101
|
+
}]);
|
|
30102
|
+
}
|
|
30103
|
+
/**
|
|
30104
|
+
* Builds swap parameters
|
|
30105
|
+
* @param fromAddress the msg.sender of the transaction
|
|
30106
|
+
* @param secondaryFeeAddress the secondary fee contract address
|
|
30107
|
+
* @param trade details of the swap, including the route, input/output tokens and amounts
|
|
30108
|
+
* @param options additional swap options
|
|
30109
|
+
* @returns calldata for the swap
|
|
30110
|
+
*/
|
|
30111
|
+
function buildSwapParameters(fromAddress, trade, options, secondaryFees, secondaryFeeContract) {
|
|
30112
|
+
// @dev we don't support multiple swaps in a single transaction
|
|
30113
|
+
// there will always be only one swap in the trade regardless of the trade type
|
|
30114
|
+
const { route, inputAmount, outputAmount } = trade.swaps[0];
|
|
30115
|
+
const amountIn = v3Sdk.toHex(trade.maximumAmountIn(options.slippageTolerance, inputAmount).quotient);
|
|
30116
|
+
const amountOut = v3Sdk.toHex(trade.minimumAmountOut(options.slippageTolerance, outputAmount).quotient);
|
|
30117
|
+
const isSinglePoolSwap = route.pools.length === 1;
|
|
30118
|
+
if (isSinglePoolSwap) {
|
|
30119
|
+
return buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract);
|
|
30120
|
+
}
|
|
30121
|
+
return buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract);
|
|
30122
|
+
}
|
|
30123
|
+
function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees) {
|
|
30124
|
+
const secondaryFeeContract = SecondaryFee__factory.createInterface();
|
|
30125
|
+
const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract);
|
|
30126
|
+
return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [swapOptions.deadlineOrPreviousBlockhash, [swapWithFeesCalldata]]);
|
|
30127
|
+
}
|
|
30128
|
+
function createSwapParameters(trade, fromAddress, slippage, deadline, secondaryFees) {
|
|
27512
30129
|
// Create an unchecked trade to be used in generating swap parameters.
|
|
27513
30130
|
const uncheckedTrade = v3Sdk.Trade.createUncheckedTrade({
|
|
27514
30131
|
route: trade.route,
|
|
@@ -27522,20 +30139,24 @@ function createSwapParameters(trade, fromAddress, slippage, deadline) {
|
|
|
27522
30139
|
recipient: fromAddress,
|
|
27523
30140
|
deadlineOrPreviousBlockhash: deadline,
|
|
27524
30141
|
};
|
|
27525
|
-
|
|
27526
|
-
|
|
30142
|
+
if (secondaryFees.length === 0) {
|
|
30143
|
+
// Generate swap parameters without secondary fee contract details
|
|
30144
|
+
return routerSdk.SwapRouter.swapCallParameters([uncheckedTrade], options).calldata;
|
|
30145
|
+
}
|
|
30146
|
+
return createSwapCallParametersWithFees(uncheckedTrade, fromAddress, options, secondaryFees);
|
|
27527
30147
|
}
|
|
27528
|
-
function getSwap(nativeToken, routeAndQuote, fromAddress, slippage, deadline, peripheryRouterAddress, gasPrice) {
|
|
27529
|
-
const
|
|
30148
|
+
function getSwap(nativeToken, routeAndQuote, fromAddress, slippage, deadline, peripheryRouterAddress, secondaryFeesAddress, gasPrice, secondaryFees) {
|
|
30149
|
+
const calldata = createSwapParameters(routeAndQuote.trade, fromAddress, slippage, deadline, secondaryFees);
|
|
30150
|
+
// TODO: Add additional gas fee estimates for secondary fees
|
|
27530
30151
|
const gasFeeEstimate = gasPrice ? {
|
|
27531
30152
|
token: nativeToken,
|
|
27532
30153
|
value: calculateGasFee(gasPrice, routeAndQuote.trade.gasEstimate),
|
|
27533
30154
|
} : null;
|
|
27534
30155
|
return {
|
|
27535
30156
|
transaction: {
|
|
27536
|
-
data:
|
|
27537
|
-
to: peripheryRouterAddress,
|
|
27538
|
-
value:
|
|
30157
|
+
data: calldata,
|
|
30158
|
+
to: secondaryFees.length > 0 ? secondaryFeesAddress : peripheryRouterAddress,
|
|
30159
|
+
value: zeroNativeCurrencyValue,
|
|
27539
30160
|
from: fromAddress,
|
|
27540
30161
|
},
|
|
27541
30162
|
gasFeeEstimate,
|
|
@@ -27548,6 +30169,7 @@ const CONTRACTS_FOR_CHAIN_ID = {
|
|
|
27548
30169
|
coreFactory: '0x12739A8f1A8035F439092D016DAE19A2874F30d2',
|
|
27549
30170
|
quoterV2: '0xF674847fBcca5C80315e3AE37043Dce99F6CC529',
|
|
27550
30171
|
peripheryRouter: '0x0Afe6F5f4DC34461A801420634239FFaD50A2e44',
|
|
30172
|
+
secondaryFee: '0x8dBE1f0900C5e92ad87A54521902a33ba1598C51',
|
|
27551
30173
|
},
|
|
27552
30174
|
};
|
|
27553
30175
|
const SUPPORTED_SANDBOX_CHAINS = {
|
|
@@ -27576,29 +30198,36 @@ function validateOverrides(overrides) {
|
|
|
27576
30198
|
throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
|
|
27577
30199
|
}
|
|
27578
30200
|
});
|
|
27579
|
-
|
|
27580
|
-
|
|
27581
|
-
|
|
27582
|
-
for (const secondaryFee of
|
|
30201
|
+
}
|
|
30202
|
+
function validateSecondaryFees(secondaryFees) {
|
|
30203
|
+
let totalSecondaryFeeBasisPoints = 0;
|
|
30204
|
+
for (const secondaryFee of secondaryFees) {
|
|
27583
30205
|
if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
|
|
27584
30206
|
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
|
|
27585
30207
|
}
|
|
27586
|
-
if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints >
|
|
27587
|
-
throw new InvalidConfigurationError(`Invalid secondary fee
|
|
30208
|
+
if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
|
|
30209
|
+
throw new InvalidConfigurationError(`Invalid secondary fee basis points: ${secondaryFee.feeBasisPoints}`);
|
|
27588
30210
|
}
|
|
30211
|
+
totalSecondaryFeeBasisPoints += secondaryFee.feeBasisPoints;
|
|
30212
|
+
}
|
|
30213
|
+
if (totalSecondaryFeeBasisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
|
|
30214
|
+
throw new InvalidConfigurationError(`Invalid total secondary fee basis points: ${totalSecondaryFeeBasisPoints}`);
|
|
27589
30215
|
}
|
|
27590
30216
|
}
|
|
27591
30217
|
/**
|
|
27592
30218
|
* {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
|
|
27593
30219
|
* @param chainId the ID of the chain to configure. {@link SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT} contains the supported chains for each environment.
|
|
27594
30220
|
* @param baseConfig the base {@link ImmutableConfiguration} for the {@link Exchange} class
|
|
30221
|
+
* @param secondaryFees an optional array of {@link SecondaryFee}s to apply to all transactions. Total secondary fees must be less than {@link MAX_SECONDARY_FEE_BASIS_POINTS}.
|
|
27595
30222
|
*/
|
|
27596
30223
|
class ExchangeConfiguration {
|
|
27597
30224
|
baseConfig;
|
|
27598
30225
|
chain;
|
|
27599
|
-
secondaryFees;
|
|
27600
|
-
constructor({ chainId, baseConfig, overrides }) {
|
|
30226
|
+
secondaryFees = [];
|
|
30227
|
+
constructor({ chainId, baseConfig, secondaryFees, overrides, }) {
|
|
27601
30228
|
this.baseConfig = baseConfig;
|
|
30229
|
+
this.secondaryFees = secondaryFees || [];
|
|
30230
|
+
validateSecondaryFees(this.secondaryFees);
|
|
27602
30231
|
if (overrides) {
|
|
27603
30232
|
validateOverrides(overrides);
|
|
27604
30233
|
this.chain = {
|
|
@@ -27608,10 +30237,9 @@ class ExchangeConfiguration {
|
|
|
27608
30237
|
commonRoutingTokens: overrides.commonRoutingTokens,
|
|
27609
30238
|
nativeToken: overrides.nativeToken,
|
|
27610
30239
|
};
|
|
27611
|
-
this.secondaryFees =
|
|
30240
|
+
this.secondaryFees = secondaryFees || [];
|
|
27612
30241
|
return;
|
|
27613
30242
|
}
|
|
27614
|
-
this.secondaryFees = [];
|
|
27615
30243
|
const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
|
|
27616
30244
|
if (!chain) {
|
|
27617
30245
|
throw new ChainNotSupportedError(chainId, baseConfig.environment);
|
|
@@ -27630,13 +30258,14 @@ class Exchange {
|
|
|
27630
30258
|
const config = new ExchangeConfiguration(configuration);
|
|
27631
30259
|
this.chainId = config.chain.chainId;
|
|
27632
30260
|
this.nativeToken = config.chain.nativeToken;
|
|
27633
|
-
this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
|
|
27634
30261
|
this.secondaryFees = config.secondaryFees;
|
|
30262
|
+
this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
|
|
27635
30263
|
this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
|
|
27636
30264
|
multicallAddress: config.chain.contracts.multicall,
|
|
27637
30265
|
factoryAddress: config.chain.contracts.coreFactory,
|
|
27638
30266
|
quoterAddress: config.chain.contracts.quoterV2,
|
|
27639
30267
|
peripheryRouterAddress: config.chain.contracts.peripheryRouter,
|
|
30268
|
+
secondaryFeeAddress: config.chain.contracts.secondaryFee,
|
|
27640
30269
|
});
|
|
27641
30270
|
}
|
|
27642
30271
|
static validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress) {
|
|
@@ -27674,7 +30303,7 @@ class Exchange {
|
|
|
27674
30303
|
const gasPrice = await fetchGasPrice(this.provider);
|
|
27675
30304
|
// we always use the tokenIn address because we are always selling the tokenIn
|
|
27676
30305
|
const approval = await getApproval(this.nativeToken, this.provider, fromAddress, tokenInAddress, ethers.ethers.BigNumber.from(amount), this.router.routingContracts.peripheryRouterAddress, gasPrice);
|
|
27677
|
-
const swap = getSwap(this.nativeToken, routeAndQuote, fromAddress, slippagePercent, deadline, this.router.routingContracts.peripheryRouterAddress, gasPrice);
|
|
30306
|
+
const swap = getSwap(this.nativeToken, routeAndQuote, fromAddress, slippagePercent, deadline, this.router.routingContracts.peripheryRouterAddress, this.router.routingContracts.secondaryFeeAddress, gasPrice, this.secondaryFees);
|
|
27678
30307
|
const quote = getQuote(otherToken, tradeType, routeAndQuote.trade, slippagePercent);
|
|
27679
30308
|
return {
|
|
27680
30309
|
approval,
|
|
@@ -27714,9 +30343,6 @@ class Exchange {
|
|
|
27714
30343
|
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
|
|
27715
30344
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, sdkCore.TradeType.EXACT_OUTPUT);
|
|
27716
30345
|
}
|
|
27717
|
-
thereAreSecondaryFees() {
|
|
27718
|
-
return this.secondaryFees.length > 0;
|
|
27719
|
-
}
|
|
27720
30346
|
}
|
|
27721
30347
|
|
|
27722
30348
|
/* eslint-disable class-methods-use-this */
|
|
@@ -28862,7 +31488,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28862
31488
|
function $parcel$export(e, n, v, s) {
|
|
28863
31489
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28864
31490
|
}
|
|
28865
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.
|
|
31491
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.2-alpha.1";
|
|
28866
31492
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28867
31493
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28868
31494
|
|