@sentio/sdk 2.15.5 → 2.15.6-rc.2

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.
Files changed (46) hide show
  1. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +2 -1
  2. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +81 -114
  3. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  4. package/lib/eth/builtin/internal/erc1155-processor.d.ts +2 -1
  5. package/lib/eth/builtin/internal/erc1155-processor.js +29 -36
  6. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  7. package/lib/eth/builtin/internal/erc20-processor.d.ts +2 -1
  8. package/lib/eth/builtin/internal/erc20-processor.js +41 -54
  9. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  10. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +2 -1
  11. package/lib/eth/builtin/internal/erc20bytes-processor.js +33 -42
  12. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  13. package/lib/eth/builtin/internal/erc721-processor.d.ts +2 -1
  14. package/lib/eth/builtin/internal/erc721-processor.js +45 -60
  15. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  16. package/lib/eth/builtin/internal/weth9-processor.d.ts +2 -1
  17. package/lib/eth/builtin/internal/weth9-processor.js +33 -42
  18. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  19. package/lib/eth/codegen/file.js +10 -7
  20. package/lib/eth/codegen/file.js.map +1 -1
  21. package/lib/eth/codegen/view-function.js +4 -6
  22. package/lib/eth/codegen/view-function.js.map +1 -1
  23. package/lib/eth/index.d.ts +1 -1
  24. package/lib/eth/index.js +1 -1
  25. package/lib/eth/index.js.map +1 -1
  26. package/lib/eth/provider.d.ts +0 -2
  27. package/lib/eth/provider.js +9 -10
  28. package/lib/eth/provider.js.map +1 -1
  29. package/lib/eth/provider.test.js.map +1 -1
  30. package/lib/sui/ext/coin.js +3 -0
  31. package/lib/sui/ext/coin.js.map +1 -1
  32. package/lib/utils/token.js +9 -2
  33. package/lib/utils/token.js.map +1 -1
  34. package/package.json +5 -5
  35. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +84 -114
  36. package/src/eth/builtin/internal/erc1155-processor.ts +32 -36
  37. package/src/eth/builtin/internal/erc20-processor.ts +44 -54
  38. package/src/eth/builtin/internal/erc20bytes-processor.ts +36 -42
  39. package/src/eth/builtin/internal/erc721-processor.ts +48 -60
  40. package/src/eth/builtin/internal/weth9-processor.ts +36 -42
  41. package/src/eth/codegen/file.ts +10 -9
  42. package/src/eth/codegen/view-function.ts +4 -6
  43. package/src/eth/index.ts +1 -1
  44. package/src/eth/provider.ts +9 -11
  45. package/src/sui/ext/coin.ts +4 -1
  46. package/src/utils/token.ts +9 -2
@@ -18,7 +18,6 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
@@ -166,48 +165,38 @@ export class ERC20BytesBoundContractView extends BoundContractView<
166
165
  ERC20BytesContractView
167
166
  > {
168
167
  async name(overrides?: Overrides): Promise<string> {
169
- if (!overrides && this.context) {
170
- overrides = {
171
- blockTag: this.context.blockNumber,
172
- };
173
- }
174
- return await this.view.name(overrides || {});
168
+ return await this.view.name({
169
+ blockTag: this.context.blockNumber,
170
+ ...overrides,
171
+ });
175
172
  }
176
173
 
177
174
  async totalSupply(overrides?: Overrides): Promise<bigint> {
178
- if (!overrides && this.context) {
179
- overrides = {
180
- blockTag: this.context.blockNumber,
181
- };
182
- }
183
- return await this.view.totalSupply(overrides || {});
175
+ return await this.view.totalSupply({
176
+ blockTag: this.context.blockNumber,
177
+ ...overrides,
178
+ });
184
179
  }
185
180
 
186
181
  async decimals(overrides?: Overrides): Promise<bigint> {
187
- if (!overrides && this.context) {
188
- overrides = {
189
- blockTag: this.context.blockNumber,
190
- };
191
- }
192
- return await this.view.decimals(overrides || {});
182
+ return await this.view.decimals({
183
+ blockTag: this.context.blockNumber,
184
+ ...overrides,
185
+ });
193
186
  }
194
187
 
195
188
  async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
196
- if (!overrides && this.context) {
197
- overrides = {
198
- blockTag: this.context.blockNumber,
199
- };
200
- }
201
- return await this.view.balanceOf(who, overrides || {});
189
+ return await this.view.balanceOf(who, {
190
+ blockTag: this.context.blockNumber,
191
+ ...overrides,
192
+ });
202
193
  }
203
194
 
204
195
  async symbol(overrides?: Overrides): Promise<string> {
205
- if (!overrides && this.context) {
206
- overrides = {
207
- blockTag: this.context.blockNumber,
208
- };
209
- }
210
- return await this.view.symbol(overrides || {});
196
+ return await this.view.symbol({
197
+ blockTag: this.context.blockNumber,
198
+ ...overrides,
199
+ });
211
200
  }
212
201
 
213
202
  async allowance(
@@ -215,12 +204,10 @@ export class ERC20BytesBoundContractView extends BoundContractView<
215
204
  spender: string,
216
205
  overrides?: Overrides
217
206
  ): Promise<bigint> {
218
- if (!overrides && this.context) {
219
- overrides = {
220
- blockTag: this.context.blockNumber,
221
- };
222
- }
223
- return await this.view.allowance(owner, spender, overrides || {});
207
+ return await this.view.allowance(owner, spender, {
208
+ blockTag: this.context.blockNumber,
209
+ ...overrides,
210
+ });
224
211
  }
225
212
  }
226
213
 
@@ -412,22 +399,29 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
412
399
  }
413
400
 
414
401
  export function getERC20BytesContract(
415
- contextOrNetwork: EthContext | EthChainId,
402
+ chainId: EthChainId,
416
403
  address: string
417
404
  ): ERC20BytesContractView {
418
- const network = getEthChainId(contextOrNetwork);
419
405
  let contract = getContractByABI(
420
406
  "ERC20Bytes",
421
407
  address,
422
- network
408
+ chainId
423
409
  ) as ERC20BytesContractView;
424
410
  if (!contract) {
425
411
  const rawContract = ERC20Bytes__factory.connect(
426
412
  address,
427
- getProvider(network)
413
+ getProvider(chainId)
428
414
  );
429
415
  contract = new ERC20BytesContractView(rawContract);
430
- addContractByABI("ERC20Bytes", address, network, contract);
416
+ addContractByABI("ERC20Bytes", address, chainId, contract);
431
417
  }
432
418
  return contract;
433
419
  }
420
+
421
+ export function getERC20BytesContractOnContext(
422
+ context: EthContext,
423
+ address: string
424
+ ): ERC20BytesBoundContractView {
425
+ const view = getERC20BytesContract(context.getChainId(), address);
426
+ return new ERC20BytesBoundContractView(address, view);
427
+ }
@@ -18,7 +18,6 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
@@ -261,33 +260,27 @@ export class ERC721BoundContractView extends BoundContractView<
261
260
  ERC721ContractView
262
261
  > {
263
262
  async totalSupply(overrides?: Overrides): Promise<bigint> {
264
- if (!overrides && this.context) {
265
- overrides = {
266
- blockTag: this.context.blockNumber,
267
- };
268
- }
269
- return await this.view.totalSupply(overrides || {});
263
+ return await this.view.totalSupply({
264
+ blockTag: this.context.blockNumber,
265
+ ...overrides,
266
+ });
270
267
  }
271
268
 
272
269
  async balanceOf(owner: string, overrides?: Overrides): Promise<bigint> {
273
- if (!overrides && this.context) {
274
- overrides = {
275
- blockTag: this.context.blockNumber,
276
- };
277
- }
278
- return await this.view.balanceOf(owner, overrides || {});
270
+ return await this.view.balanceOf(owner, {
271
+ blockTag: this.context.blockNumber,
272
+ ...overrides,
273
+ });
279
274
  }
280
275
 
281
276
  async getApproved(
282
277
  tokenId: BigNumberish,
283
278
  overrides?: Overrides
284
279
  ): Promise<string> {
285
- if (!overrides && this.context) {
286
- overrides = {
287
- blockTag: this.context.blockNumber,
288
- };
289
- }
290
- return await this.view.getApproved(tokenId, overrides || {});
280
+ return await this.view.getApproved(tokenId, {
281
+ blockTag: this.context.blockNumber,
282
+ ...overrides,
283
+ });
291
284
  }
292
285
 
293
286
  async isApprovedForAll(
@@ -295,63 +288,51 @@ export class ERC721BoundContractView extends BoundContractView<
295
288
  operator: string,
296
289
  overrides?: Overrides
297
290
  ): Promise<boolean> {
298
- if (!overrides && this.context) {
299
- overrides = {
300
- blockTag: this.context.blockNumber,
301
- };
302
- }
303
- return await this.view.isApprovedForAll(owner, operator, overrides || {});
291
+ return await this.view.isApprovedForAll(owner, operator, {
292
+ blockTag: this.context.blockNumber,
293
+ ...overrides,
294
+ });
304
295
  }
305
296
 
306
297
  async name(overrides?: Overrides): Promise<string> {
307
- if (!overrides && this.context) {
308
- overrides = {
309
- blockTag: this.context.blockNumber,
310
- };
311
- }
312
- return await this.view.name(overrides || {});
298
+ return await this.view.name({
299
+ blockTag: this.context.blockNumber,
300
+ ...overrides,
301
+ });
313
302
  }
314
303
 
315
304
  async ownerOf(tokenId: BigNumberish, overrides?: Overrides): Promise<string> {
316
- if (!overrides && this.context) {
317
- overrides = {
318
- blockTag: this.context.blockNumber,
319
- };
320
- }
321
- return await this.view.ownerOf(tokenId, overrides || {});
305
+ return await this.view.ownerOf(tokenId, {
306
+ blockTag: this.context.blockNumber,
307
+ ...overrides,
308
+ });
322
309
  }
323
310
 
324
311
  async supportsInterface(
325
312
  interfaceId: BytesLike,
326
313
  overrides?: Overrides
327
314
  ): Promise<boolean> {
328
- if (!overrides && this.context) {
329
- overrides = {
330
- blockTag: this.context.blockNumber,
331
- };
332
- }
333
- return await this.view.supportsInterface(interfaceId, overrides || {});
315
+ return await this.view.supportsInterface(interfaceId, {
316
+ blockTag: this.context.blockNumber,
317
+ ...overrides,
318
+ });
334
319
  }
335
320
 
336
321
  async symbol(overrides?: Overrides): Promise<string> {
337
- if (!overrides && this.context) {
338
- overrides = {
339
- blockTag: this.context.blockNumber,
340
- };
341
- }
342
- return await this.view.symbol(overrides || {});
322
+ return await this.view.symbol({
323
+ blockTag: this.context.blockNumber,
324
+ ...overrides,
325
+ });
343
326
  }
344
327
 
345
328
  async tokenURI(
346
329
  tokenId: BigNumberish,
347
330
  overrides?: Overrides
348
331
  ): Promise<string> {
349
- if (!overrides && this.context) {
350
- overrides = {
351
- blockTag: this.context.blockNumber,
352
- };
353
- }
354
- return await this.view.tokenURI(tokenId, overrides || {});
332
+ return await this.view.tokenURI(tokenId, {
333
+ blockTag: this.context.blockNumber,
334
+ ...overrides,
335
+ });
355
336
  }
356
337
  }
357
338
 
@@ -627,19 +608,26 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
627
608
  }
628
609
 
629
610
  export function getERC721Contract(
630
- contextOrNetwork: EthContext | EthChainId,
611
+ chainId: EthChainId,
631
612
  address: string
632
613
  ): ERC721ContractView {
633
- const network = getEthChainId(contextOrNetwork);
634
614
  let contract = getContractByABI(
635
615
  "ERC721",
636
616
  address,
637
- network
617
+ chainId
638
618
  ) as ERC721ContractView;
639
619
  if (!contract) {
640
- const rawContract = ERC721__factory.connect(address, getProvider(network));
620
+ const rawContract = ERC721__factory.connect(address, getProvider(chainId));
641
621
  contract = new ERC721ContractView(rawContract);
642
- addContractByABI("ERC721", address, network, contract);
622
+ addContractByABI("ERC721", address, chainId, contract);
643
623
  }
644
624
  return contract;
645
625
  }
626
+
627
+ export function getERC721ContractOnContext(
628
+ context: EthContext,
629
+ address: string
630
+ ): ERC721BoundContractView {
631
+ const view = getERC721Contract(context.getChainId(), address);
632
+ return new ERC721BoundContractView(address, view);
633
+ }
@@ -18,7 +18,6 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
@@ -175,48 +174,38 @@ export class WETH9BoundContractView extends BoundContractView<
175
174
  WETH9ContractView
176
175
  > {
177
176
  async name(overrides?: Overrides): Promise<string> {
178
- if (!overrides && this.context) {
179
- overrides = {
180
- blockTag: this.context.blockNumber,
181
- };
182
- }
183
- return await this.view.name(overrides || {});
177
+ return await this.view.name({
178
+ blockTag: this.context.blockNumber,
179
+ ...overrides,
180
+ });
184
181
  }
185
182
 
186
183
  async totalSupply(overrides?: Overrides): Promise<bigint> {
187
- if (!overrides && this.context) {
188
- overrides = {
189
- blockTag: this.context.blockNumber,
190
- };
191
- }
192
- return await this.view.totalSupply(overrides || {});
184
+ return await this.view.totalSupply({
185
+ blockTag: this.context.blockNumber,
186
+ ...overrides,
187
+ });
193
188
  }
194
189
 
195
190
  async decimals(overrides?: Overrides): Promise<bigint> {
196
- if (!overrides && this.context) {
197
- overrides = {
198
- blockTag: this.context.blockNumber,
199
- };
200
- }
201
- return await this.view.decimals(overrides || {});
191
+ return await this.view.decimals({
192
+ blockTag: this.context.blockNumber,
193
+ ...overrides,
194
+ });
202
195
  }
203
196
 
204
197
  async balanceOf(arg0: string, overrides?: Overrides): Promise<bigint> {
205
- if (!overrides && this.context) {
206
- overrides = {
207
- blockTag: this.context.blockNumber,
208
- };
209
- }
210
- return await this.view.balanceOf(arg0, overrides || {});
198
+ return await this.view.balanceOf(arg0, {
199
+ blockTag: this.context.blockNumber,
200
+ ...overrides,
201
+ });
211
202
  }
212
203
 
213
204
  async symbol(overrides?: Overrides): Promise<string> {
214
- if (!overrides && this.context) {
215
- overrides = {
216
- blockTag: this.context.blockNumber,
217
- };
218
- }
219
- return await this.view.symbol(overrides || {});
205
+ return await this.view.symbol({
206
+ blockTag: this.context.blockNumber,
207
+ ...overrides,
208
+ });
220
209
  }
221
210
 
222
211
  async allowance(
@@ -224,12 +213,10 @@ export class WETH9BoundContractView extends BoundContractView<
224
213
  arg1: string,
225
214
  overrides?: Overrides
226
215
  ): Promise<bigint> {
227
- if (!overrides && this.context) {
228
- overrides = {
229
- blockTag: this.context.blockNumber,
230
- };
231
- }
232
- return await this.view.allowance(arg0, arg1, overrides || {});
216
+ return await this.view.allowance(arg0, arg1, {
217
+ blockTag: this.context.blockNumber,
218
+ ...overrides,
219
+ });
233
220
  }
234
221
  }
235
222
 
@@ -485,19 +472,26 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
485
472
  }
486
473
 
487
474
  export function getWETH9Contract(
488
- contextOrNetwork: EthContext | EthChainId,
475
+ chainId: EthChainId,
489
476
  address: string
490
477
  ): WETH9ContractView {
491
- const network = getEthChainId(contextOrNetwork);
492
478
  let contract = getContractByABI(
493
479
  "WETH9",
494
480
  address,
495
- network
481
+ chainId
496
482
  ) as WETH9ContractView;
497
483
  if (!contract) {
498
- const rawContract = WETH9__factory.connect(address, getProvider(network));
484
+ const rawContract = WETH9__factory.connect(address, getProvider(chainId));
499
485
  contract = new WETH9ContractView(rawContract);
500
- addContractByABI("WETH9", address, network, contract);
486
+ addContractByABI("WETH9", address, chainId, contract);
501
487
  }
502
488
  return contract;
503
489
  }
490
+
491
+ export function getWETH9ContractOnContext(
492
+ context: EthContext,
493
+ address: string
494
+ ): WETH9BoundContractView {
495
+ const view = getWETH9Contract(context.getChainId(), address);
496
+ return new WETH9BoundContractView(address, view);
497
+ }
@@ -106,18 +106,21 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
106
106
  .join('\n')}
107
107
  }
108
108
 
109
- export function get${contract.name}Contract(contextOrNetwork: EthContext | EthChainId, address: string): ${
110
- contract.name
111
- }ContractView {
112
- const network = getEthChainId(contextOrNetwork)
113
- let contract = getContractByABI("${contract.name}", address, network) as ${contract.name}ContractView
109
+ export function get${contract.name}Contract(chainId: EthChainId, address: string): ${contract.name}ContractView {
110
+ let contract = getContractByABI("${contract.name}", address, chainId) as ${contract.name}ContractView
114
111
  if (!contract) {
115
- const rawContract = ${contract.name}__factory.connect(address, getProvider(network))
112
+ const rawContract = ${contract.name}__factory.connect(address, getProvider(chainId))
116
113
  contract = new ${contract.name}ContractView(rawContract)
117
- addContractByABI("${contract.name}", address, network, contract)
114
+ addContractByABI("${contract.name}", address, chainId, contract)
118
115
  }
119
116
  return contract
120
117
  }
118
+
119
+ export function get${contract.name}ContractOnContext(context: EthContext, address: string):
120
+ ${contract.name}BoundContractView {
121
+ const view = get${contract.name}Contract(context.getChainId(), address)
122
+ return new ${contract.name}BoundContractView(address, view)
123
+ }
121
124
  `
122
125
  const eventsImports = Object.values(contract.events).flatMap((events) => {
123
126
  if (events.length === 1) {
@@ -166,8 +169,6 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
166
169
  'DummyProvider',
167
170
  'EthChainId',
168
171
  'TypedCallTrace',
169
- 'getEthChainId',
170
- // 'toBlockTag',
171
172
  'EthContext',
172
173
  'EthFetchConfig',
173
174
  ],
@@ -60,14 +60,12 @@ export function generateBoundViewFunction(fn: FunctionDeclaration, includeArgTyp
60
60
  async ${declName ?? fn.name}(${generateInputTypes(fn.inputs, {
61
61
  useStructs: true,
62
62
  })}overrides?: Overrides): ${generateReturnTypes(fn)} {
63
- if (!overrides && this.context) {
64
- overrides = {
65
- blockTag: this.context.blockNumber,
66
- }
67
- }
68
63
  return await this.view.${declName}(${
69
64
  fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
70
- } overrides || {})
65
+ } {
66
+ blockTag: this.context.blockNumber,
67
+ ...overrides
68
+ })
71
69
  }
72
70
  `
73
71
  }
package/src/eth/index.ts CHANGED
@@ -2,7 +2,7 @@ export { BaseProcessor, GlobalProcessor } from './base-processor.js'
2
2
  export { GenericProcessor } from './generic-processor.js'
3
3
  export { BaseProcessorTemplate } from './base-processor-template.js'
4
4
  export { AccountProcessor } from './account-processor.js'
5
- export { getProvider, DummyProvider, getEthChainId } from './provider.js'
5
+ export { getProvider, DummyProvider } from './provider.js'
6
6
  export { EthContext } from './context.js'
7
7
  export * from './eth.js'
8
8
  export { BindOptions, AccountBindOptions } from './bind-options.js'
@@ -2,23 +2,21 @@ import { JsonRpcProvider, Network, Provider } from 'ethers'
2
2
 
3
3
  import PQueue from 'p-queue'
4
4
  import { Endpoints } from '@sentio/runtime'
5
- import { BaseContext } from '../core/index.js'
6
5
  import { EthChainId } from '../core/chain.js'
7
- import { EthContext } from './context.js'
8
6
 
9
7
  export const DummyProvider = new JsonRpcProvider('', Network.from(1))
10
8
 
11
9
  const providers = new Map<string, JsonRpcProvider>()
12
10
 
13
- export function getEthChainId(networkish?: EthContext | EthChainId): EthChainId {
14
- if (!networkish) {
15
- networkish = EthChainId.ETHEREUM
16
- }
17
- if (networkish instanceof BaseContext) {
18
- networkish = networkish.getChainId()
19
- }
20
- return networkish
21
- }
11
+ // export function getEthChainId(networkish?: EthContext | EthChainId): EthChainId {
12
+ // if (!networkish) {
13
+ // networkish = EthChainId.ETHEREUM
14
+ // }
15
+ // if (networkish instanceof BaseContext) {
16
+ // networkish = networkish.getChainId()
17
+ // }
18
+ // return networkish
19
+ // }
22
20
 
23
21
  export function getProvider(chainId?: EthChainId): Provider {
24
22
  // const network = getNetworkFromCtxOrNetworkish(networkish)
@@ -84,7 +84,7 @@ export function getCoinInfo(type: string): SimpleCoinInfo {
84
84
  return r
85
85
  }
86
86
 
87
- const COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata>>()
87
+ const COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata | null>>()
88
88
 
89
89
  export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo> {
90
90
  const r = WHITELISTED_COINS.get(type)
@@ -98,6 +98,9 @@ export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork
98
98
  COIN_METADATA_CACHE.set(key, promise)
99
99
  }
100
100
  const meta = await promise
101
+ if (meta === null) {
102
+ throw Error('Coin not existed ' + key)
103
+ }
101
104
 
102
105
  const parts = type.split(SPLITTER)
103
106
  return {
@@ -3,7 +3,8 @@ import { getERC20BytesContract } from '../eth/builtin/erc20bytes.js'
3
3
  import { BigDecimal, scaleDown } from '../core/big-decimal.js'
4
4
  import { PromiseOrValue } from '../eth/builtin/internal/common.js'
5
5
  import { decodeBytes32String } from 'ethers'
6
- import { EthChainId, EthContext, getEthChainId } from '../eth/index.js'
6
+ import { EthChainId, EthContext } from '../eth/index.js'
7
+ import { BaseContext } from '../core/index.js'
7
8
 
8
9
  export interface TokenInfo {
9
10
  symbol: string
@@ -35,7 +36,13 @@ export async function getERC20TokenInfo(
35
36
  contextOrNetworkish: EthContext | EthChainId,
36
37
  tokenAddress: string
37
38
  ): Promise<TokenInfo> {
38
- const chainId = getEthChainId(contextOrNetworkish)
39
+ let chainId: EthChainId
40
+ if (contextOrNetworkish instanceof BaseContext) {
41
+ chainId = contextOrNetworkish.getChainId()
42
+ } else {
43
+ chainId = contextOrNetworkish || EthChainId.ETHEREUM
44
+ }
45
+
39
46
  const key = chainId + tokenAddress
40
47
  const res = TOKEN_INFOS.get(key)
41
48
  if (res) {