@instadapp/avocado-base 0.0.0-dev.8d2b9ac → 0.0.0-dev.8f35916

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.
@@ -6,9 +6,11 @@ export type { BalanceResolver } from "./BalanceResolver";
6
6
  export type { Erc20 } from "./Erc20";
7
7
  export type { Forwarder } from "./Forwarder";
8
8
  export type { GaslessWallet } from "./GaslessWallet";
9
+ export type { MultisigForwarder } from "./MultisigForwarder";
9
10
  export * as factories from "./factories";
10
11
  export { AvoFactoryProxy__factory } from "./factories/AvoFactoryProxy__factory";
11
12
  export { BalanceResolver__factory } from "./factories/BalanceResolver__factory";
12
13
  export { Erc20__factory } from "./factories/Erc20__factory";
13
14
  export { Forwarder__factory } from "./factories/Forwarder__factory";
14
15
  export { GaslessWallet__factory } from "./factories/GaslessWallet__factory";
16
+ export { MultisigForwarder__factory } from "./factories/MultisigForwarder__factory";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.0-dev.8d2b9ac",
3
+ "version": "0.0.0-dev.8f35916",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
package/utils/helper.ts CHANGED
@@ -1,5 +1,3 @@
1
- import * as XXH from 'xxhashjs';
2
-
3
1
  export const indexSorter = (aIndex: number, bIndex: number) => {
4
2
  if (aIndex === -1 && bIndex === -1) {
5
3
  return 0; // fallback to other sorting criteria
@@ -62,12 +60,3 @@ export function formatMultipleAddresses(addresses: string[], shorten = true) {
62
60
  return formattedString
63
61
  }
64
62
 
65
- export function generateColor(address: string): string {
66
- const hash = XXH.h32(address, 0xABCD).toNumber()
67
-
68
- const hue = hash % 360
69
- const saturation = 80 + (hash % 30)
70
- const lightness = 70 + (hash % 20)
71
-
72
- return `hsl(${hue}, ${saturation}%, ${lightness}%)`
73
- }
package/utils/metadata.ts CHANGED
@@ -1,23 +1,27 @@
1
1
  import { ethers, utils } from "ethers";
2
- import { Forwarder__factory } from "../contracts";
3
-
4
- export const MetadataEnums = {
5
- "transfer": "transfer",
6
- "bridge": "bridge",
7
- "swap": "swap",
8
- "gas-topup": "gas-topup",
9
- "upgrade": "upgrade",
10
- "dapp": "dapp",
11
- "deploy": "deploy",
12
- "permit2": "permit2",
13
- "cross-transfer": "cross-transfer",
14
- "auth": "auth",
15
- "rejection": "rejection",
16
- "instadapp-pro": "instadapp-pro",
17
- "add-signers": "add-signers",
18
- "remove-signers": "remove-signers",
19
- "change-threshold": "change-threshold",
20
- } as const;
2
+ import { Forwarder__factory, MultisigForwarder__factory } from "../contracts";
3
+ import { toBN } from "./bignumber";
4
+
5
+ export const MetadataEnums = {
6
+ transfer: "transfer",
7
+ bridge: "bridge",
8
+ swap: "swap",
9
+ "gas-topup": "gas-topup",
10
+ upgrade: "upgrade",
11
+ dapp: "dapp",
12
+ deploy: "deploy",
13
+ permit2: "permit2",
14
+ "cross-transfer": "cross-transfer",
15
+ auth: "auth",
16
+ rejection: "rejection",
17
+ "instadapp-pro": "instadapp-pro",
18
+ "add-signers": "add-signers",
19
+ "remove-signers": "remove-signers",
20
+ "change-threshold": "change-threshold",
21
+ import: "import",
22
+ "tx-builder": "tx-builder",
23
+ "avocado-bridge": "avocado-bridge",
24
+ } as const;
21
25
 
22
26
  const multiMetadataTypes = ["bytes[]"];
23
27
 
@@ -52,8 +56,10 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
52
56
  "gas-topup": ["uint256 amount", "address token", "address onBehalf"],
53
57
  upgrade: ["bytes32 version", "address walletImpl"],
54
58
  dapp: ["string name", "string url"],
59
+ import: ["bytes32 protocol", "uint256 valueInUsd"],
55
60
  auth: ["address address", "uint256 chainId", "bool remove"],
56
61
  deploy: [],
62
+ "tx-builder": ["bytes32 actionCount"],
57
63
  permit2: [
58
64
  "address token",
59
65
  "address spender",
@@ -61,10 +67,11 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
61
67
  "uint48 expiration",
62
68
  ],
63
69
  "instadapp-pro": ["string castDetails"],
64
- 'add-signers': ['address[] signers'],
65
- 'remove-signers': ['address[] signers'],
66
- 'change-threshold': ['uint8 count'],
67
- 'rejection': ['bytes32 id'],
70
+ "add-signers": ["address[] signers"],
71
+ "remove-signers": ["address[] signers"],
72
+ "change-threshold": ["uint8 count"],
73
+ rejection: ["bytes32 id"],
74
+ "avocado-bridge": ["bytes32 id", "uint256 toChainId"],
68
75
  };
69
76
 
70
77
  const encodeMetadata = (props: MetadataProps) => {
@@ -92,6 +99,24 @@ export const encodeDappMetadata = (
92
99
  return single ? encodeMultipleActions(data) : data;
93
100
  };
94
101
 
102
+ export const encodeAvocadoBridgeMetadata = (
103
+ id: string,
104
+ toChainId: string | number,
105
+ single = true
106
+ ) => {
107
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
108
+ actionMetadataTypes["avocado-bridge"],
109
+ [id, toChainId]
110
+ );
111
+
112
+ const data = encodeMetadata({
113
+ type: MetadataEnums["avocado-bridge"],
114
+ encodedData,
115
+ });
116
+
117
+ return single ? encodeMultipleActions(data) : data;
118
+ };
119
+
95
120
  export const encodeTransferMetadata = (
96
121
  params: SendMetadataProps,
97
122
  single = true
@@ -172,6 +197,23 @@ export const encodeDeployMetadata = (single = true) => {
172
197
  return single ? encodeMultipleActions(data) : data;
173
198
  };
174
199
 
200
+ export const encodeTransactionBuilderMetadata = (
201
+ actionCount: string,
202
+ single = true
203
+ ) => {
204
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
205
+ actionMetadataTypes["tx-builder"],
206
+ [actionCount]
207
+ );
208
+
209
+ const data = encodeMetadata({
210
+ type: MetadataEnums["tx-builder"],
211
+ encodedData,
212
+ });
213
+
214
+ return single ? encodeMultipleActions(data) : data;
215
+ };
216
+
175
217
  export const encodeWCSignMetadata = (
176
218
  params: SignMetadataProps,
177
219
  single = true
@@ -306,6 +348,24 @@ export const encodeRemoveSignersMetadata = (
306
348
  return single ? encodeMultipleActions(data) : data;
307
349
  };
308
350
 
351
+ export const encodeImportMetadata = (
352
+ protocol: string,
353
+ valueInUsd: string,
354
+ single = true
355
+ ) => {
356
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
357
+ actionMetadataTypes["import"],
358
+ [protocol, valueInUsd]
359
+ );
360
+
361
+ const data = encodeMetadata({
362
+ type: MetadataEnums["import"],
363
+ encodedData,
364
+ });
365
+
366
+ return single ? encodeMultipleActions(data) : data;
367
+ };
368
+
309
369
  export const encodeAddSignersMetadata = (
310
370
  addresses: string[],
311
371
  single = true
@@ -346,8 +406,10 @@ export const decodeMetadata = (metadata: string) => {
346
406
  }
347
407
  };
348
408
 
409
+ const iface = Forwarder__factory.createInterface();
410
+ const ifaceMultisig = MultisigForwarder__factory.createInterface();
411
+
349
412
  const getMetadataFromData = (data: string) => {
350
- const iface = Forwarder__factory.createInterface();
351
413
  let metadata = "0x";
352
414
 
353
415
  if (data.startsWith("0x18e7f485")) {
@@ -367,36 +429,30 @@ const getMetadataFromData = (data: string) => {
367
429
  } else {
368
430
  metadata = executeDataV2.params_.metadata;
369
431
  }
370
- } else if (data.startsWith("0x85114d53")) {
371
- const executeDataV3 = iface.decodeFunctionData("executeV3", data);
372
- if (
373
- executeDataV3.params_.metadata === "0x" ||
374
- !executeDataV3.params_.metadata
375
- ) {
376
- return null;
377
- } else {
378
- metadata = executeDataV3.params_.metadata;
379
- }
380
432
  } else {
381
- const executeDataMultisigV3 = iface.decodeFunctionData(
382
- "executeMultisigV3",
433
+ const executeDataMultisig = ifaceMultisig.decodeFunctionData(
434
+ "executeV1",
383
435
  data
384
436
  );
385
437
  if (
386
- executeDataMultisigV3.params_.metadata === "0x" ||
387
- !executeDataMultisigV3.params_.metadata
438
+ executeDataMultisig.params_.metadata === "0x" ||
439
+ !executeDataMultisig.params_.metadata
388
440
  ) {
389
441
  return null;
390
442
  } else {
391
- metadata = executeDataMultisigV3.params_.metadata;
443
+ metadata = executeDataMultisig.params_.metadata;
392
444
  }
393
445
  }
394
446
 
395
447
  return metadata;
396
448
  };
397
449
 
398
-
399
450
  const typesPayload: IPayload = {
451
+ import: (data, type) => ({
452
+ type,
453
+ protocol: utils.parseBytes32String(data.protocol || ""),
454
+ valueInUsd: toBN(data.valueInUsd).toFixed(),
455
+ }),
400
456
  transfer: (data, type) => ({
401
457
  type,
402
458
  token: data.token,
@@ -432,15 +488,19 @@ const typesPayload: IPayload = {
432
488
  token: data.token,
433
489
  onBehalf: data.onBehalf,
434
490
  }),
435
- "dapp": (data, type) => ({
491
+ dapp: (data, type) => ({
436
492
  type,
437
493
  name: data.name,
438
494
  url: data.url,
439
495
  }),
440
- "deploy": (data, type) => ({
496
+ deploy: (data, type) => ({
441
497
  type,
442
498
  }),
443
- "permit2": (data, type) => ({
499
+ "tx-builder": (data, type) => ({
500
+ type,
501
+ actionCount: utils.parseBytes32String(data.actionCount || ""),
502
+ }),
503
+ permit2: (data, type) => ({
444
504
  type,
445
505
  token: data.token,
446
506
  spender: data.spender,
@@ -455,7 +515,7 @@ const typesPayload: IPayload = {
455
515
  amount: toBN(data.amount).toFixed(),
456
516
  receiver: data.receiver,
457
517
  }),
458
- "auth": (data) => ({
518
+ auth: (data) => ({
459
519
  type: data.remove ? "remove-authority" : "add-authority",
460
520
  address: data.address,
461
521
  chainId: data.chainId ? data.chainId.toString() : null,
@@ -465,7 +525,7 @@ const typesPayload: IPayload = {
465
525
  type,
466
526
  castDetails: data.castDetails,
467
527
  }),
468
- "rejection": (data, type) => ({
528
+ rejection: (data, type) => ({
469
529
  type,
470
530
  id: data.id,
471
531
  }),
@@ -481,6 +541,11 @@ const typesPayload: IPayload = {
481
541
  type,
482
542
  count: data.count,
483
543
  }),
544
+ "avocado-bridge": (data, type) => ({
545
+ type,
546
+ id: data.id,
547
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
548
+ }),
484
549
  };
485
550
 
486
551
  const parseMetadata = (metadata: string) => {
@@ -507,20 +572,17 @@ const parseMetadata = (metadata: string) => {
507
572
  decodedMetadata.data
508
573
  );
509
574
 
510
- const payloadFunc = typesPayload[type]
511
-
575
+ const payloadFunc = typesPayload[type];
576
+
512
577
  if (payloadFunc) {
513
- const payload = payloadFunc(decodedData, type)
578
+ const payload = payloadFunc(decodedData, type);
514
579
  metadataArr.push(payload);
515
580
  }
516
-
517
581
  }
518
582
 
519
583
  return metadataArr;
520
584
  };
521
585
 
522
-
523
-
524
586
  /**
525
587
  * Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
526
588
  * @param {string} txType - The input sentence to modify
package/utils/network.ts CHANGED
@@ -8,9 +8,11 @@ import {
8
8
  AVO_STAGING_CHAIN_ID,
9
9
  AVO_STAGING_RPC_URL,
10
10
  AVO_STAGING_EXPLORER_URL,
11
- } from './avocado'
11
+ } from "./avocado";
12
12
 
13
- export const bridgeDisabledNetworks = [1101];
13
+ export const bridgeDisabledNetworks = [];
14
+
15
+ export const networksSimulationNotSupported = [1313161554, 1101];
14
16
 
15
17
  export const networks: Network[] = [
16
18
  {
@@ -23,6 +25,9 @@ export const networks: Network[] = [
23
25
  balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
24
26
  usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
25
27
  explorerUrl: "https://polygonscan.com",
28
+ apiURL: "https://api.polygonscan.com",
29
+ fakeTransactionHash:
30
+ "0x906c551abd5873a428505b6530ac14d91367820706c7ee525f6d7313265d1c92",
26
31
  get serverRpcUrl() {
27
32
  return process.env?.POLYGON_RPC_URL || this.params.rpcUrls[0];
28
33
  },
@@ -45,7 +50,10 @@ export const networks: Network[] = [
45
50
  chainId: 42161,
46
51
  usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
47
52
  balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
53
+ fakeTransactionHash:
54
+ "0x9fa291c3b09d31f19b1fa5dd05f30169d1364036d5f7c14b026410bc07bd8843",
48
55
  explorerUrl: "https://arbiscan.io",
56
+ apiURL: "https://api.arbiscan.io",
49
57
  get serverRpcUrl() {
50
58
  return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
51
59
  },
@@ -66,6 +74,9 @@ export const networks: Network[] = [
66
74
  zerionName: "ethereum",
67
75
  chainId: 1,
68
76
  explorerUrl: "https://etherscan.io",
77
+ fakeTransactionHash:
78
+ "0x13232dd32cef2f641ead890a507710c96560c8c9c3d5fab6facb5ec563c49433",
79
+ apiURL: "https://api.etherscan.io",
69
80
  color: "#5D5FEF",
70
81
  get serverRpcUrl() {
71
82
  return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
@@ -80,26 +91,30 @@ export const networks: Network[] = [
80
91
  decimals: 18,
81
92
  },
82
93
  },
83
- },
94
+ },
84
95
  {
85
- name: 'Base',
96
+ name: "Base",
86
97
  chainId: 8453,
87
- color: '#1E2024',
88
- explorerUrl: 'https://basescan.org',
98
+ color: "#1E2024",
99
+ ankrName: "base",
100
+ explorerUrl: "https://basescan.org",
101
+ fakeTransactionHash:
102
+ "0xf7833d80da33730c4fc5d4c64151f0eaa64c0c0535be022af0228a44cc4e9c8e",
103
+ apiURL: "https://api.basescan.org",
89
104
  get serverRpcUrl() {
90
105
  return process.env?.BASE_RPC_URL || this.params.rpcUrls[0];
91
- },
92
- usdcAddress: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',
93
- balanceResolverAddress: '0x23c8EAb8a4373dD16b0947Ebe8bf76Ff7A49d13C',
94
- params: {
95
- rpcUrls: ['https://rpc.ankr.com/base'],
106
+ },
107
+ usdcAddress: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
108
+ balanceResolverAddress: "0x23c8EAb8a4373dD16b0947Ebe8bf76Ff7A49d13C",
109
+ params: {
110
+ rpcUrls: ["https://rpc.ankr.com/base"],
96
111
  chainName: "Base",
97
112
  nativeCurrency: {
98
113
  name: "Ethereum",
99
114
  symbol: "ETH",
100
115
  decimals: 18,
101
116
  },
102
- }
117
+ },
103
118
  },
104
119
  {
105
120
  name: "Optimism",
@@ -108,8 +123,11 @@ export const networks: Network[] = [
108
123
  zerionName: "optimism",
109
124
  color: "#FF0420",
110
125
  chainId: 10,
126
+ apiURL: "https://api-optimistic.etherscan.io",
111
127
  usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
112
128
  balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
129
+ fakeTransactionHash:
130
+ "0xee7311d68059732b05088f2144dfec6c7a4f5fd0433eb85306afcd6bdf17cebc",
113
131
  explorerUrl: "https://optimistic.etherscan.io",
114
132
  get serverRpcUrl() {
115
133
  return process.env?.OPTIMISM_RPC_URL || this.params.rpcUrls[0];
@@ -128,8 +146,12 @@ export const networks: Network[] = [
128
146
  name: "Polygon zkEVM",
129
147
  chainId: 1101,
130
148
  color: "#8544f6",
149
+ ankrName: "polygon_zkevm",
131
150
  explorerUrl: "https://zkevm.polygonscan.com",
151
+ apiURL: "https://api-zkevm.polygonscan.com",
132
152
  balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
153
+ fakeTransactionHash:
154
+ "0x1077130463ade91ad4e9c43c3195298e26a99970975238128912490eea12bf41",
133
155
  usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
134
156
  get serverRpcUrl() {
135
157
  return process.env?.POLYGON_ZKEVM_RPC_URL || this.params.rpcUrls[0];
@@ -152,6 +174,9 @@ export const networks: Network[] = [
152
174
  color: "#F3BA2F",
153
175
  chainId: 56,
154
176
  explorerUrl: "https://bscscan.com",
177
+ fakeTransactionHash:
178
+ "0x897d54bf8e492f840bd4d8f1e743bfcab8226ab4d5a899e47ee433dcd6d6abf7",
179
+ apiURL: "https://api.bscscan.com",
155
180
  usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
156
181
  balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
157
182
  get serverRpcUrl() {
@@ -177,6 +202,9 @@ export const networks: Network[] = [
177
202
  usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
178
203
  balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
179
204
  explorerUrl: "https://snowtrace.io",
205
+ fakeTransactionHash:
206
+ "0x233aac7402558dd4e23f938a50f983e67f5c9604233981c7ac74e63737b8294e",
207
+ apiURL: "https://api.snowtrace.io",
180
208
  get serverRpcUrl() {
181
209
  return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
182
210
  },
@@ -202,6 +230,8 @@ export const networks: Network[] = [
202
230
  },
203
231
  usdcAddress: "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
204
232
  balanceResolverAddress: "0x929376c77a2fb8152375a089a4fccf84ff481479",
233
+ fakeTransactionHash:
234
+ "0x1e9a8405d660172314124e06896212c0786d7fb1550b89410d4bc87e9e8054e4",
205
235
  params: {
206
236
  rpcUrls: ["https://rpc.ankr.com/fantom"],
207
237
  chainName: "Fantom",
@@ -217,9 +247,13 @@ export const networks: Network[] = [
217
247
  debankName: "xdai",
218
248
  zerionName: "xdai",
219
249
  color: "#04795C",
250
+ ankrName: "gnosis",
220
251
  chainId: 100,
221
252
  balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
222
253
  explorerUrl: "https://gnosisscan.io",
254
+ fakeTransactionHash:
255
+ "0x1513033806310a2c3b29f2276f8aa7388461b0ef9f8499c297e68c12187c179b",
256
+ apiURL: "https://api.gnosisscan.io",
223
257
  usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
224
258
  get serverRpcUrl() {
225
259
  return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
@@ -240,6 +274,8 @@ export const networks: Network[] = [
240
274
  zerionName: "aurora",
241
275
  color: "#78d64b",
242
276
  explorerUrl: "https://explorer.mainnet.aurora.dev",
277
+ fakeTransactionHash:
278
+ "0x0923401c5a80c39a5cd57c098a6c4729edbefd0db6894def7d349493f4ff3ec6",
243
279
  get serverRpcUrl() {
244
280
  return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
245
281
  },
@@ -255,11 +291,75 @@ export const networks: Network[] = [
255
291
  },
256
292
  },
257
293
  },
294
+ {
295
+ name: "Fuse",
296
+ chainId: 122,
297
+ zerionName: "fuse",
298
+ color: "#78d64b",
299
+ explorerUrl: "https://explorer.fuse.io",
300
+ fakeTransactionHash:
301
+ "0xf22a8031de9b978a57c728e18c6b54633356c39db4d0466e53b9b7c3ee7f8def",
302
+ get serverRpcUrl() {
303
+ return process.env?.FUSE_RPC_URL || this.params.rpcUrls[0];
304
+ },
305
+ usdcAddress: "",
306
+ balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
307
+ params: {
308
+ rpcUrls: ["https://fuse-mainnet.chainstacklabs.com"],
309
+ chainName: "Fuse",
310
+ nativeCurrency: {
311
+ decimals: 18,
312
+ name: "Fuse",
313
+ symbol: "fuse",
314
+ },
315
+ },
316
+ },
317
+ // {
318
+ // name: "Scroll",
319
+ // chainId: 534352,
320
+ // color: "#78d64b",
321
+ // explorerUrl: "https://scrollscan.com",
322
+ // fakeTransactionHash:
323
+ // "0x6bf297c414264fc8cddd47224632b4426a02138df2f50fe891eca87f6aefea01",
324
+ // get serverRpcUrl() {
325
+ // return process.env?.SCROLL_RPC_URL || this.params.rpcUrls[0];
326
+ // },
327
+ // params: {
328
+ // rpcUrls: ["https://rpc.scroll.io"],
329
+ // chainName: "Scroll",
330
+ // nativeCurrency: {
331
+ // name: "Ethereum",
332
+ // symbol: "ETH",
333
+ // decimals: 18,
334
+ // },
335
+ // },
336
+ // },
337
+ // {
338
+ // name: "opBNB",
339
+ // chainId: 204,
340
+ // color: "#78d64b",
341
+ // explorerUrl: "https://opbnbscan.com",
342
+ // fakeTransactionHash:
343
+ // "0xb9438a3eae61442bc7d419d79930370ce09ac0f46e0695025751e3bfe1a931e7",
344
+ // get serverRpcUrl() {
345
+ // return process.env?.OPBNB_RPC_URL || this.params.rpcUrls[0];
346
+ // },
347
+ // params: {
348
+ // rpcUrls: ["https://opbnb-mainnet-rpc.bnbchain.org"],
349
+ // chainName: "opBNB",
350
+ // nativeCurrency: {
351
+ // name: "BNB",
352
+ // symbol: "BNB",
353
+ // decimals: 18,
354
+ // },
355
+ // },
356
+ // },
258
357
  {
259
358
  name: AVO_PROD_CHAIN_NAME,
260
359
  chainId: AVO_PROD_CHAIN_ID,
261
360
  isAvocado: true,
262
361
  balanceResolverAddress: "",
362
+ fakeTransactionHash: "",
263
363
  color: "#16A34A",
264
364
  usdcAddress: "",
265
365
  serverRpcUrl: AVO_PROD_RPC_URL,
@@ -281,6 +381,7 @@ export const networks: Network[] = [
281
381
  serverRpcUrl: AVO_STAGING_RPC_URL,
282
382
  color: "#16A34A",
283
383
  explorerUrl: AVO_STAGING_EXPLORER_URL,
384
+ fakeTransactionHash: "",
284
385
  isAvocado: true,
285
386
  balanceResolverAddress: "",
286
387
  usdcAddress: "",
@@ -298,19 +399,22 @@ export const networks: Network[] = [
298
399
  ];
299
400
 
300
401
  export const chainUsdcAddresses = [
301
- { chainId: 1, address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' },
302
- { chainId: 10, address: '0x7f5c764cbc14f9669b88837ca1490cca17c31607' },
303
- { chainId: 56, address: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d' },
304
- { chainId: 100, address: '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83' },
305
- { chainId: 137, address: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' },
306
- { chainId: 250, address: '0x04068da6c83afcfa0e13ba15a6696662335d5b75' },
307
- { chainId: 42161, address: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' },
308
- { chainId: 42161, address: '0xaf88d065e77c8cc2239327c5edb3a432268e5831' },
309
- { chainId: 43114, address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' },
310
- { chainId: 43114, address: '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664' },
311
- { chainId: 1101, address: '0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035' },
312
- { chainId: 1313161554, address: '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802' },
313
- { chainId: 8453, address: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA'}
402
+ { chainId: 1, address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" },
403
+ { chainId: 10, address: "0x7f5c764cbc14f9669b88837ca1490cca17c31607" },
404
+ { chainId: 56, address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d" },
405
+ { chainId: 100, address: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83" },
406
+ { chainId: 137, address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" },
407
+ { chainId: 250, address: "0x04068da6c83afcfa0e13ba15a6696662335d5b75" },
408
+ { chainId: 42161, address: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8" },
409
+ { chainId: 42161, address: "0xaf88d065e77c8cc2239327c5edb3a432268e5831" },
410
+ { chainId: 43114, address: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e" },
411
+ { chainId: 43114, address: "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664" },
412
+ { chainId: 1101, address: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035" },
413
+ {
414
+ chainId: 1313161554,
415
+ address: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
416
+ },
417
+ { chainId: 8453, address: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" },
314
418
  ];
315
419
 
316
420
  export const getNetworkByChainId = (
@@ -325,12 +429,16 @@ export const availableNetworks = networks.filter(
325
429
 
326
430
  export const chainIdToName = (chainId: ChainId | number | string) => {
327
431
  const network = getNetworkByChainId(chainId);
328
- return network.name;
432
+ return network?.name;
329
433
  };
330
434
 
331
435
  export const getRpcURLByChainId = (chainId: ChainId | number | string) => {
332
- const network = getNetworkByChainId(chainId);
333
- return network.params.rpcUrls[0];
436
+ try {
437
+ const network = getNetworkByChainId(chainId);
438
+ return network.params.rpcUrls[0];
439
+ } catch (e) {
440
+ return "";
441
+ }
334
442
  };
335
443
 
336
444
  export const RPCMap = networks.reduce((acc, network) => {
@@ -372,5 +480,6 @@ export const getExplorerUrl = (
372
480
  suffix: `/${string}` = "/"
373
481
  ) => {
374
482
  const network = getNetworkByChainId(chainId);
483
+ if (!network) return "";
375
484
  return `${network.explorerUrl}${suffix}`;
376
485
  };
package/utils/utils.d.ts CHANGED
@@ -12,8 +12,11 @@ declare global {
12
12
  | 634
13
13
  | 1313161554
14
14
  | 8453
15
+ | 122
16
+ | 534352
17
+ | 204
15
18
  | 63400;
16
-
19
+
17
20
  type ISlackMessageType = "danger" | "error" | "success" | "banner";
18
21
 
19
22
  type MetadataTypes = keyof typeof MetadataEnums;
@@ -32,8 +35,10 @@ declare global {
32
35
  isAvocado?: boolean;
33
36
  serverRpcUrl: string | undefined;
34
37
  balanceResolverAddress?: string;
35
- usdcAddress: string;
38
+ usdcAddress?: string;
36
39
  explorerUrl: string;
40
+ fakeTransactionHash: string;
41
+ apiURL?: string;
37
42
  params: {
38
43
  chainName?: string;
39
44
  iconUrls?: string[];
@@ -109,7 +114,7 @@ declare global {
109
114
  };
110
115
 
111
116
  type MetadataProps = {
112
- type: MetadataTypes,
117
+ type: MetadataTypes;
113
118
  encodedData: string;
114
119
  version?: string;
115
120
  };
@@ -125,8 +130,6 @@ declare global {
125
130
  coingecko_id: string;
126
131
  sparkline_price_7d: number[];
127
132
  }
128
-
129
133
  }
130
134
 
131
- export { }
132
-
135
+ export {};