@instadapp/avocado-base 0.1.3 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
package/utils/metadata.ts CHANGED
@@ -13,6 +13,7 @@ export const MetadataEnums = {
13
13
  deploy: "deploy",
14
14
  permit2: "permit2",
15
15
  "cross-transfer": "cross-transfer",
16
+ 'cross-transfer-v2': 'cross-transfer-v2',
16
17
  auth: "auth",
17
18
  rejection: "rejection",
18
19
  "instadapp-pro": "instadapp-pro",
@@ -38,6 +39,14 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
38
39
  "uint256 amount",
39
40
  "address receiver",
40
41
  ],
42
+ "cross-transfer-v2": [
43
+ "address fromToken",
44
+ "address toToken",
45
+ "uint256 toChainId",
46
+ "uint256 amount",
47
+ "address receiver",
48
+ "bytes32 provider",
49
+ ],
41
50
  bridge: [
42
51
  "uint256 amount",
43
52
  "address receiver",
@@ -165,8 +174,21 @@ export const encodeCrossTransferMetadata = (
165
174
  params: CrossSendMetadataProps,
166
175
  single = true
167
176
  ) => {
168
- const encodedData = ethers.utils.defaultAbiCoder.encode(
169
- actionMetadataTypes["cross-transfer"],
177
+
178
+ const type = params.provider ? MetadataEnums["cross-transfer-v2"] : MetadataEnums["cross-transfer"]
179
+
180
+ const encodedData = params.provider ? ethers.utils.defaultAbiCoder.encode(
181
+ actionMetadataTypes[type],
182
+ [
183
+ params.fromToken,
184
+ params.toToken,
185
+ params.toChainId,
186
+ params.amount,
187
+ params.receiver,
188
+ params.provider
189
+ ]
190
+ ) : ethers.utils.defaultAbiCoder.encode(
191
+ actionMetadataTypes[type],
170
192
  [
171
193
  params.fromToken,
172
194
  params.toToken,
@@ -177,7 +199,7 @@ export const encodeCrossTransferMetadata = (
177
199
  );
178
200
 
179
201
  const data = encodeMetadata({
180
- type: MetadataEnums["cross-transfer"],
202
+ type: MetadataEnums[type],
181
203
  encodedData,
182
204
  });
183
205
 
@@ -571,6 +593,15 @@ const typesPayload: IPayload = {
571
593
  amount: toBN(data.amount).toFixed(),
572
594
  receiver: data.receiver,
573
595
  }),
596
+ "cross-transfer-v2": (data, type) => ({
597
+ type: 'cross-transfer',
598
+ fromToken: data.fromToken,
599
+ toToken: data.toToken,
600
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
601
+ amount: toBN(data.amount).toFixed(),
602
+ receiver: data.receiver,
603
+ provider: utils.parseBytes32String(data.provider || ""),
604
+ }),
574
605
  auth: (data) => ({
575
606
  type: data.remove ? "remove-authority" : "add-authority",
576
607
  address: data.address,
package/utils/network.ts CHANGED
@@ -77,7 +77,7 @@ export const networks: Network[] = [
77
77
  balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
78
78
  usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
79
79
  explorerUrl: "https://polygonscan.com",
80
- apiURL: "https://api.polygonscan.com",
80
+ apiURL: "https://api.polygonscan.com/api",
81
81
  fakeTransactionHash:
82
82
  "0x906c551abd5873a428505b6530ac14d91367820706c7ee525f6d7313265d1c92",
83
83
  get serverRpcUrl() {
@@ -106,7 +106,7 @@ export const networks: Network[] = [
106
106
  fakeTransactionHash:
107
107
  "0x9fa291c3b09d31f19b1fa5dd05f30169d1364036d5f7c14b026410bc07bd8843",
108
108
  explorerUrl: "https://arbiscan.io",
109
- apiURL: "https://api.arbiscan.io",
109
+ apiURL: "https://api.arbiscan.io/api",
110
110
  get serverRpcUrl() {
111
111
  return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
112
112
  },
@@ -130,7 +130,7 @@ export const networks: Network[] = [
130
130
  explorerUrl: "https://etherscan.io",
131
131
  fakeTransactionHash:
132
132
  "0x13232dd32cef2f641ead890a507710c96560c8c9c3d5fab6facb5ec563c49433",
133
- apiURL: "https://api.etherscan.io",
133
+ apiURL: "https://api.etherscan.io/api",
134
134
  color: "#5D5FEF",
135
135
  get serverRpcUrl() {
136
136
  return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
@@ -155,7 +155,7 @@ export const networks: Network[] = [
155
155
  explorerUrl: "https://basescan.org",
156
156
  fakeTransactionHash:
157
157
  "0xf7833d80da33730c4fc5d4c64151f0eaa64c0c0535be022af0228a44cc4e9c8e",
158
- apiURL: "https://api.basescan.org",
158
+ apiURL: "https://api.basescan.org/api",
159
159
  get serverRpcUrl() {
160
160
  return process.env?.BASE_RPC_URL || this.params.rpcUrls[0];
161
161
  },
@@ -179,7 +179,7 @@ export const networks: Network[] = [
179
179
  color: "#FF0420",
180
180
  viemChain: optimism,
181
181
  chainId: 10,
182
- apiURL: "https://api-optimistic.etherscan.io",
182
+ apiURL: "https://api-optimistic.etherscan.io/api",
183
183
  usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
184
184
  balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
185
185
  fakeTransactionHash:
@@ -205,7 +205,7 @@ export const networks: Network[] = [
205
205
  ankrName: "polygon_zkevm",
206
206
  viemChain: polygonZkEvm,
207
207
  explorerUrl: "https://zkevm.polygonscan.com",
208
- apiURL: "https://api-zkevm.polygonscan.com",
208
+ apiURL: "https://api-zkevm.polygonscan.com/api",
209
209
  balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
210
210
  fakeTransactionHash:
211
211
  "0x1077130463ade91ad4e9c43c3195298e26a99970975238128912490eea12bf41",
@@ -234,7 +234,7 @@ export const networks: Network[] = [
234
234
  viemChain: bsc,
235
235
  fakeTransactionHash:
236
236
  "0x897d54bf8e492f840bd4d8f1e743bfcab8226ab4d5a899e47ee433dcd6d6abf7",
237
- apiURL: "https://api.bscscan.com",
237
+ apiURL: "https://api.bscscan.com/api",
238
238
  usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
239
239
  balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
240
240
  get serverRpcUrl() {
@@ -263,7 +263,7 @@ export const networks: Network[] = [
263
263
  explorerUrl: "https://snowtrace.io",
264
264
  fakeTransactionHash:
265
265
  "0x233aac7402558dd4e23f938a50f983e67f5c9604233981c7ac74e63737b8294e",
266
- apiURL: "https://api.snowtrace.io",
266
+ apiURL: "https://api.routescan.io/v2/network/mainnet/evm/43114/etherscan/api",
267
267
  get serverRpcUrl() {
268
268
  return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
269
269
  },
@@ -282,6 +282,7 @@ export const networks: Network[] = [
282
282
  chainId: 250,
283
283
  zerionName: "fantom",
284
284
  explorerUrl: "https://ftmscan.com",
285
+ apiURL: 'https://api.ftmscan.com/api',
285
286
  ankrName: "fantom",
286
287
  color: "#1969ff",
287
288
  viemChain: fantom,
@@ -314,7 +315,7 @@ export const networks: Network[] = [
314
315
  explorerUrl: "https://gnosisscan.io",
315
316
  fakeTransactionHash:
316
317
  "0x1513033806310a2c3b29f2276f8aa7388461b0ef9f8499c297e68c12187c179b",
317
- apiURL: "https://api.gnosisscan.io",
318
+ apiURL: "https://api.gnosisscan.io/api",
318
319
  usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
319
320
  get serverRpcUrl() {
320
321
  return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
@@ -336,6 +337,7 @@ export const networks: Network[] = [
336
337
  color: "#78d64b",
337
338
  viemChain: aurora,
338
339
  explorerUrl: "https://explorer.mainnet.aurora.dev",
340
+ apiURL:'https://explorer.mainnet.aurora.dev/api/v2',
339
341
  fakeTransactionHash:
340
342
  "0x0923401c5a80c39a5cd57c098a6c4729edbefd0db6894def7d349493f4ff3ec6",
341
343
  get serverRpcUrl() {
@@ -359,6 +361,7 @@ export const networks: Network[] = [
359
361
  zerionName: "fuse",
360
362
  color: "#78d64b",
361
363
  explorerUrl: "https://explorer.fuse.io",
364
+ apiURL: 'https://explorer.fuse.io/api/v2',
362
365
  viemChain: fuse,
363
366
  fakeTransactionHash:
364
367
  "0xf22a8031de9b978a57c728e18c6b54633356c39db4d0466e53b9b7c3ee7f8def",
@@ -383,6 +386,7 @@ export const networks: Network[] = [
383
386
  color: "#78d64b",
384
387
  ankrName: 'scroll',
385
388
  explorerUrl: "https://scrollscan.com",
389
+ apiURL: 'https://api.scrollscan.com/api',
386
390
  viemChain: scroll,
387
391
  fakeTransactionHash:
388
392
  "0x6bf297c414264fc8cddd47224632b4426a02138df2f50fe891eca87f6aefea01",
@@ -404,6 +408,7 @@ export const networks: Network[] = [
404
408
  chainId: 204,
405
409
  color: "#78d64b",
406
410
  explorerUrl: "https://opbnbscan.com",
411
+ apiURL: null,
407
412
  viemChain: opBNB,
408
413
  fakeTransactionHash:
409
414
  "0xb9438a3eae61442bc7d419d79930370ce09ac0f46e0695025751e3bfe1a931e7",
@@ -426,6 +431,7 @@ export const networks: Network[] = [
426
431
  color: "#d7ff00",
427
432
  explorerUrl: 'https://explorer.mode.network',
428
433
  fakeTransactionHash: '0xb58002db3481f2c51855a91280ec940d0bebec075c4b362b9f90c21a2b14edbe',
434
+ apiURL: 'https://explorer.mode.network/api/v2',
429
435
  params: {
430
436
  rpcUrls: ["https://1rpc.io/mode"],
431
437
  chainName: "Mode",
@@ -445,6 +451,7 @@ export const networks: Network[] = [
445
451
  name: "Blast",
446
452
  color: "#78d64b",
447
453
  explorerUrl: 'https://blastscan.io',
454
+ apiURL:'https://api.blastscan.io/api',
448
455
  fakeTransactionHash: '0x934ed8516242f8c08bb9e0e90bb1f989d92ceb6b0333e86ac2d555f25ac27e58',
449
456
  params: {
450
457
  rpcUrls: ['https://rpc.ankr.com/blast'],
@@ -482,6 +489,7 @@ export const networks: Network[] = [
482
489
  {
483
490
  name: AVO_PROD_CHAIN_NAME,
484
491
  chainId: AVO_PROD_CHAIN_ID,
492
+ apiURL:null,
485
493
  isAvocado: true,
486
494
  balanceResolverAddress: "",
487
495
  fakeTransactionHash: "",
@@ -503,6 +511,7 @@ export const networks: Network[] = [
503
511
  },
504
512
  {
505
513
  name: AVO_STAGING_CHAIN_NAME,
514
+ apiURL: null,
506
515
  chainId: AVO_STAGING_CHAIN_ID,
507
516
  serverRpcUrl: AVO_STAGING_RPC_URL,
508
517
  color: "#16A34A",
package/utils/utils.d.ts CHANGED
@@ -44,7 +44,8 @@ declare global {
44
44
  explorerUrl: string;
45
45
  fakeTransactionHash: string;
46
46
  viemChain: Chain;
47
- apiURL?: string;
47
+ // must start with https://
48
+ apiURL: `https://${string}` | null;
48
49
  params: {
49
50
  chainName?: string;
50
51
  iconUrls?: string[];
@@ -81,8 +82,10 @@ declare global {
81
82
  toChainId: string;
82
83
  amount: string;
83
84
  receiver: string;
85
+ provider?: string;
84
86
  };
85
87
 
88
+
86
89
  type AuthMetadataProps = {
87
90
  address: string;
88
91
  chainId: string;