@instadapp/avocado-base 0.0.0-dev.822475d → 0.0.0-dev.83b0911

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 (43) hide show
  1. package/.github/workflows/npm-publish-dev.yml +2 -5
  2. package/abi/multisigForwarder.json +697 -0
  3. package/app.vue +7 -0
  4. package/assets/images/icons/change-threshold.svg +4 -0
  5. package/assets/images/icons/cross-transfer.svg +7 -0
  6. package/assets/images/icons/dapp.svg +4 -0
  7. package/assets/images/icons/deploy.svg +12 -0
  8. package/assets/images/icons/gas.svg +12 -5
  9. package/assets/images/icons/hammer.svg +5 -0
  10. package/assets/images/icons/info-2.svg +12 -0
  11. package/assets/images/icons/instadapp-pro.svg +4 -0
  12. package/assets/images/icons/multi-send.svg +7 -0
  13. package/assets/images/icons/permit-sign.svg +11 -0
  14. package/assets/images/icons/plus-circle.svg +6 -0
  15. package/assets/images/icons/refresh.svg +4 -4
  16. package/assets/images/icons/reject-proposal.svg +6 -0
  17. package/assets/images/icons/stars.svg +4 -0
  18. package/assets/images/icons/transfer.svg +5 -0
  19. package/assets/images/icons/trash-2.svg +8 -0
  20. package/assets/images/icons/upgrade.svg +4 -0
  21. package/components/ActionLogo.vue +42 -0
  22. package/components/ActionMetadata.vue +50 -18
  23. package/components/AuthorityAvatar.vue +37 -0
  24. package/components/ChainLogo.vue +14 -563
  25. package/components/CopyClipboard.vue +58 -0
  26. package/components/metadata/Bridge.vue +30 -8
  27. package/components/metadata/CrossTransfer.vue +19 -5
  28. package/components/metadata/GasTopup.vue +10 -2
  29. package/components/metadata/Permit2.vue +6 -1
  30. package/components/metadata/Signers.vue +66 -0
  31. package/components/metadata/Swap.vue +26 -25
  32. package/components/metadata/Transfer.vue +14 -7
  33. package/contracts/MultisigForwarder.ts +859 -0
  34. package/contracts/factories/MultisigForwarder__factory.ts +721 -0
  35. package/contracts/factories/index.ts +1 -0
  36. package/contracts/index.ts +2 -0
  37. package/package.json +14 -9
  38. package/utils/formatter.ts +2 -2
  39. package/utils/helper.ts +8 -0
  40. package/utils/metadata.ts +329 -135
  41. package/utils/network.ts +356 -74
  42. package/utils/services.ts +8 -1
  43. package/utils/utils.d.ts +139 -126
@@ -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,30 +1,35 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.0-dev.822475d",
3
+ "version": "0.0.0-dev.83b0911",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
7
+ "engines": {
8
+ "node": ">=v18.18.0"
9
+ },
7
10
  "scripts": {
8
11
  "build": "nuxt build",
9
12
  "dev": "nuxt dev",
10
13
  "generate": "nuxt generate",
11
14
  "preview": "nuxt preview",
12
- "generate:contracts": "rimraf contracts && typechain --target=ethers-v5 'abi/*.json' --out-dir 'contracts'"
15
+ "generate:contracts": "rimraf contracts && typechain --target=ethers-v5 'abi/*.json' --out-dir 'contracts'",
16
+ "typecheck": "nuxi typecheck"
13
17
  },
14
18
  "devDependencies": {
15
- "@instadapp/avocado": "^0.1.10",
16
- "@instadapp/avocado-dev": "npm:@instadapp/avocado@dev",
17
- "@nuxtjs/tailwindcss": "^6.6.5",
19
+ "@nuxtjs/tailwindcss": "^6.11.3",
18
20
  "@typechain/ethers-v5": "^10.2.0",
19
- "nuxt": "^3.6.1",
20
- "nuxt-svgo": "^3.1.0",
21
+ "nuxt": "^3.10.1",
22
+ "nuxt-svgo": "^4.0.0",
21
23
  "rimraf": "^3.0.2",
22
24
  "typechain": "^8.1.1",
23
- "unplugin-vue-components": "^0.25.1"
25
+ "unplugin-vue-components": "^0.25.1",
26
+ "vue-tippy": "^6.0.0"
24
27
  },
25
28
  "dependencies": {
26
29
  "@vueuse/nuxt": "^10.2.0",
27
30
  "bignumber.js": "^9.1.1",
28
- "ethers": "^5.7.2"
31
+ "ethers": "^5.7.2",
32
+ "viem": "^2.10.5",
33
+ "xxhashjs": "^0.2.2"
29
34
  }
30
35
  }
@@ -19,7 +19,7 @@ export function formatPercent(
19
19
  return formatter.format(valueAsNumber);
20
20
  }
21
21
 
22
- export function shortenHash(hash: string, length: number = 4) {
22
+ export function shortenHash(hash: string | `0x${string}`, length: number = 4) {
23
23
  if (!hash) return;
24
24
  if (hash.length < 12) return hash;
25
25
  const beginningChars = hash.startsWith("0x") ? length + 2 : length;
@@ -72,7 +72,7 @@ export function formatDecimal(value: string | number, fractionDigits?: number) {
72
72
  let decimals;
73
73
 
74
74
  if (num.lt(1)) {
75
- decimals = 8;
75
+ decimals = 4;
76
76
  } else if (num.lt(10)) {
77
77
  decimals = 6;
78
78
  } else if (num.lt(100)) {
package/utils/helper.ts CHANGED
@@ -52,3 +52,11 @@ export function onImageError(this: HTMLImageElement) {
52
52
  parentElement.classList.add("bg-gray-300");
53
53
  }
54
54
  }
55
+
56
+ export function formatMultipleAddresses(addresses: string[], shorten = true) {
57
+ const formatter = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' })
58
+ const formattedString = formatter.format(addresses.map(i => shorten ? shortenHash(i) || '' : i))
59
+
60
+ return formattedString
61
+ }
62
+
package/utils/metadata.ts CHANGED
@@ -1,11 +1,35 @@
1
1
  import { ethers, utils } from "ethers";
2
- import { Forwarder__factory } from "../contracts";
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
+ 'bridge-v2': 'bridge-v2',
9
+ swap: "swap",
10
+ "gas-topup": "gas-topup",
11
+ upgrade: "upgrade",
12
+ dapp: "dapp",
13
+ deploy: "deploy",
14
+ permit2: "permit2",
15
+ "cross-transfer": "cross-transfer",
16
+ auth: "auth",
17
+ rejection: "rejection",
18
+ "instadapp-pro": "instadapp-pro",
19
+ "add-signers": "add-signers",
20
+ "remove-signers": "remove-signers",
21
+ "change-threshold": "change-threshold",
22
+ import: "import",
23
+ mass: "mass",
24
+ "tx-builder": "tx-builder",
25
+ "avocado-bridge": "avocado-bridge",
26
+ } as const;
3
27
 
4
28
  const multiMetadataTypes = ["bytes[]"];
5
29
 
6
30
  const metadataTypes = ["bytes32 type", "uint8 version", "bytes data"];
7
31
 
8
- const actionMetadataTypes = {
32
+ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
9
33
  transfer: ["address token", "uint256 amount", "address receiver"],
10
34
  "cross-transfer": [
11
35
  "address fromToken",
@@ -23,6 +47,16 @@ const actionMetadataTypes = {
23
47
  "uint256 bridgeFee",
24
48
  "address nativeToken",
25
49
  ],
50
+ 'bridge-v2': [
51
+ "uint256 amount",
52
+ "address receiver",
53
+ "address fromToken",
54
+ "address toToken",
55
+ "uint256 toChainId",
56
+ "uint256 bridgeFee",
57
+ "address nativeToken",
58
+ "bytes32 provider",
59
+ ],
26
60
  swap: [
27
61
  "address sellToken",
28
62
  "address buyToken",
@@ -34,8 +68,10 @@ const actionMetadataTypes = {
34
68
  "gas-topup": ["uint256 amount", "address token", "address onBehalf"],
35
69
  upgrade: ["bytes32 version", "address walletImpl"],
36
70
  dapp: ["string name", "string url"],
71
+ import: ["bytes32 protocol", "uint256 valueInUsd"],
37
72
  auth: ["address address", "uint256 chainId", "bool remove"],
38
73
  deploy: [],
74
+ "tx-builder": ["bytes32 actionCount"],
39
75
  permit2: [
40
76
  "address token",
41
77
  "address spender",
@@ -43,6 +79,12 @@ const actionMetadataTypes = {
43
79
  "uint48 expiration",
44
80
  ],
45
81
  "instadapp-pro": ["string castDetails"],
82
+ "add-signers": ["address[] signers"],
83
+ "remove-signers": ["address[] signers"],
84
+ "change-threshold": ["uint8 count"],
85
+ rejection: ["bytes32 id"],
86
+ "avocado-bridge": ["bytes32 id", "uint256 toChainId"],
87
+ mass: ["bool isMass"],
46
88
  };
47
89
 
48
90
  const encodeMetadata = (props: MetadataProps) => {
@@ -63,7 +105,25 @@ export const encodeDappMetadata = (
63
105
  );
64
106
 
65
107
  const data = encodeMetadata({
66
- type: "dapp",
108
+ type: MetadataEnums.dapp,
109
+ encodedData,
110
+ });
111
+
112
+ return single ? encodeMultipleActions(data) : data;
113
+ };
114
+
115
+ export const encodeAvocadoBridgeMetadata = (
116
+ id: string,
117
+ toChainId: string | number,
118
+ single = true
119
+ ) => {
120
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
121
+ actionMetadataTypes["avocado-bridge"],
122
+ [id, toChainId]
123
+ );
124
+
125
+ const data = encodeMetadata({
126
+ type: MetadataEnums["avocado-bridge"],
67
127
  encodedData,
68
128
  });
69
129
 
@@ -80,7 +140,21 @@ export const encodeTransferMetadata = (
80
140
  );
81
141
 
82
142
  const data = encodeMetadata({
83
- type: "transfer",
143
+ type: MetadataEnums.transfer,
144
+ encodedData,
145
+ });
146
+
147
+ return single ? encodeMultipleActions(data) : data;
148
+ };
149
+
150
+ export const encodeRejectionMetadata = (id: string, single = true) => {
151
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
152
+ actionMetadataTypes.rejection,
153
+ [id]
154
+ );
155
+
156
+ const data = encodeMetadata({
157
+ type: MetadataEnums.rejection,
84
158
  encodedData,
85
159
  });
86
160
 
@@ -103,7 +177,7 @@ export const encodeCrossTransferMetadata = (
103
177
  );
104
178
 
105
179
  const data = encodeMetadata({
106
- type: "cross-transfer",
180
+ type: MetadataEnums["cross-transfer"],
107
181
  encodedData,
108
182
  });
109
183
 
@@ -120,7 +194,7 @@ export const encodeAuthMetadata = (
120
194
  );
121
195
 
122
196
  const data = encodeMetadata({
123
- type: "auth",
197
+ type: MetadataEnums.auth,
124
198
  encodedData,
125
199
  });
126
200
 
@@ -129,13 +203,30 @@ export const encodeAuthMetadata = (
129
203
 
130
204
  export const encodeDeployMetadata = (single = true) => {
131
205
  const data = encodeMetadata({
132
- type: "deploy",
206
+ type: MetadataEnums.deploy,
133
207
  encodedData: "0x",
134
208
  });
135
209
 
136
210
  return single ? encodeMultipleActions(data) : data;
137
211
  };
138
212
 
213
+ export const encodeTransactionBuilderMetadata = (
214
+ actionCount: string,
215
+ single = true
216
+ ) => {
217
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
218
+ actionMetadataTypes["tx-builder"],
219
+ [actionCount]
220
+ );
221
+
222
+ const data = encodeMetadata({
223
+ type: MetadataEnums["tx-builder"],
224
+ encodedData,
225
+ });
226
+
227
+ return single ? encodeMultipleActions(data) : data;
228
+ };
229
+
139
230
  export const encodeWCSignMetadata = (
140
231
  params: SignMetadataProps,
141
232
  single = true
@@ -146,7 +237,7 @@ export const encodeWCSignMetadata = (
146
237
  );
147
238
 
148
239
  const data = encodeMetadata({
149
- type: "permit2",
240
+ type: MetadataEnums.permit2,
150
241
  encodedData,
151
242
  });
152
243
 
@@ -163,7 +254,7 @@ export const encodeUpgradeMetadata = (
163
254
  );
164
255
 
165
256
  const data = encodeMetadata({
166
- type: "upgrade",
257
+ type: MetadataEnums.upgrade,
167
258
  encodedData,
168
259
  });
169
260
 
@@ -187,7 +278,7 @@ export const encodeSwapMetadata = (
187
278
  );
188
279
 
189
280
  const data = encodeMetadata({
190
- type: "swap",
281
+ type: MetadataEnums.swap,
191
282
  encodedData,
192
283
  });
193
284
 
@@ -203,10 +294,8 @@ export const encodeTopupMetadata = (
203
294
  [params.amount, params.token, params.onBehalf]
204
295
  );
205
296
 
206
- console.log(params);
207
-
208
297
  const data = encodeMetadata({
209
- type: "gas-topup",
298
+ type: MetadataEnums["gas-topup"],
210
299
  encodedData,
211
300
  });
212
301
 
@@ -217,7 +306,21 @@ export const encodeBridgeMetadata = (
217
306
  params: BridgeMetadataProps,
218
307
  single = true
219
308
  ) => {
220
- const encodedData = ethers.utils.defaultAbiCoder.encode(
309
+ const type = params.version === '2' ? MetadataEnums["bridge-v2"] : MetadataEnums.bridge
310
+
311
+ const encodedData = params.version === '2' ? ethers.utils.defaultAbiCoder.encode(
312
+ actionMetadataTypes["bridge-v2"],
313
+ [
314
+ params.amount,
315
+ params.receiver,
316
+ params.fromToken,
317
+ params.toToken,
318
+ params.toChainId,
319
+ params.bridgeFee,
320
+ params.nativeToken,
321
+ params.provider
322
+ ]
323
+ ): ethers.utils.defaultAbiCoder.encode(
221
324
  actionMetadataTypes.bridge,
222
325
  [
223
326
  params.amount,
@@ -231,7 +334,85 @@ export const encodeBridgeMetadata = (
231
334
  );
232
335
 
233
336
  const data = encodeMetadata({
234
- type: "bridge",
337
+ type,
338
+ encodedData,
339
+ });
340
+
341
+ return single ? encodeMultipleActions(data) : data;
342
+ };
343
+
344
+ export const encodeChangeThresholdMetadata = (
345
+ threshold: string | number,
346
+ single = true
347
+ ) => {
348
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
349
+ actionMetadataTypes["change-threshold"],
350
+ [toBN(threshold).toNumber()]
351
+ );
352
+
353
+ const data = encodeMetadata({
354
+ type: MetadataEnums["change-threshold"],
355
+ encodedData,
356
+ });
357
+
358
+ return single ? encodeMultipleActions(data) : data;
359
+ };
360
+
361
+ export const encodeRemoveSignersMetadata = (
362
+ addresses: string[],
363
+ single = true
364
+ ) => {
365
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
366
+ actionMetadataTypes["remove-signers"],
367
+ [addresses]
368
+ );
369
+
370
+ const data = encodeMetadata({
371
+ type: MetadataEnums["remove-signers"],
372
+ encodedData,
373
+ });
374
+
375
+ return single ? encodeMultipleActions(data) : data;
376
+ };
377
+
378
+ export const encodeImportMetadata = (
379
+ protocol: string,
380
+ valueInUsd: string,
381
+ single = true
382
+ ) => {
383
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
384
+ actionMetadataTypes["import"],
385
+ [protocol, valueInUsd]
386
+ );
387
+
388
+ const data = encodeMetadata({
389
+ type: MetadataEnums["import"],
390
+ encodedData,
391
+ });
392
+
393
+ return single ? encodeMultipleActions(data) : data;
394
+ };
395
+
396
+ export const encodeMassMetadata = (single = true) => {
397
+ const data = encodeMetadata({
398
+ type: MetadataEnums.mass,
399
+ encodedData: '0x',
400
+ });
401
+
402
+ return single ? encodeMultipleActions(data) : data;
403
+ }
404
+
405
+ export const encodeAddSignersMetadata = (
406
+ addresses: string[],
407
+ single = true
408
+ ) => {
409
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
410
+ actionMetadataTypes["add-signers"],
411
+ [addresses]
412
+ );
413
+
414
+ const data = encodeMetadata({
415
+ type: MetadataEnums["add-signers"],
235
416
  encodedData,
236
417
  });
237
418
 
@@ -261,8 +442,10 @@ export const decodeMetadata = (metadata: string) => {
261
442
  }
262
443
  };
263
444
 
445
+ const iface = Forwarder__factory.createInterface();
446
+ const ifaceMultisig = MultisigForwarder__factory.createInterface();
447
+
264
448
  const getMetadataFromData = (data: string) => {
265
- const iface = Forwarder__factory.createInterface();
266
449
  let metadata = "0x";
267
450
 
268
451
  if (data.startsWith("0x18e7f485")) {
@@ -282,37 +465,141 @@ const getMetadataFromData = (data: string) => {
282
465
  } else {
283
466
  metadata = executeDataV2.params_.metadata;
284
467
  }
285
- } else if (data.startsWith("0x85114d53")) {
286
- const executeDataV3 = iface.decodeFunctionData("executeV3", data);
287
- if (
288
- executeDataV3.params_.metadata === "0x" ||
289
- !executeDataV3.params_.metadata
290
- ) {
291
- return null;
292
- } else {
293
- metadata = executeDataV3.params_.metadata;
294
- }
295
468
  } else {
296
- const executeDataMultisigV3 = iface.decodeFunctionData(
297
- "executeMultisigV3",
469
+ const executeDataMultisig = ifaceMultisig.decodeFunctionData(
470
+ "executeV1",
298
471
  data
299
472
  );
300
473
  if (
301
- executeDataMultisigV3.params_.metadata === "0x" ||
302
- !executeDataMultisigV3.params_.metadata
474
+ executeDataMultisig.params_.metadata === "0x" ||
475
+ !executeDataMultisig.params_.metadata
303
476
  ) {
304
477
  return null;
305
478
  } else {
306
- metadata = executeDataMultisigV3.params_.metadata;
479
+ metadata = executeDataMultisig.params_.metadata;
307
480
  }
308
481
  }
309
482
 
310
483
  return metadata;
311
484
  };
312
485
 
486
+ const typesPayload: IPayload = {
487
+ import: (data, type) => ({
488
+ type,
489
+ protocol: utils.parseBytes32String(data.protocol || ""),
490
+ valueInUsd: toBN(data.valueInUsd).toFixed(),
491
+ }),
492
+ transfer: (data, type) => ({
493
+ type,
494
+ token: data.token,
495
+ amount: toBN(data.amount).toFixed(),
496
+ receiver: data.receiver,
497
+ }),
498
+ bridge: (data, type) => ({
499
+ type,
500
+ amount: toBN(data.amount).toFixed(),
501
+ receiver: data.receiver,
502
+ toToken: data.toToken,
503
+ fromToken: data.fromToken,
504
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
505
+ bridgeFee: toBN(data.bridgeFee).toFixed(),
506
+ }),
507
+ 'bridge-v2': (data, type) => ({
508
+ type: 'bridge',
509
+ amount: toBN(data.amount).toFixed(),
510
+ receiver: data.receiver,
511
+ toToken: data.toToken,
512
+ fromToken: data.fromToken,
513
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
514
+ bridgeFee: toBN(data.bridgeFee).toFixed(),
515
+ provider: utils.parseBytes32String(data.provider || ""),
516
+ }),
517
+ swap: (data, type) => ({
518
+ type,
519
+ buyAmount: toBN(data.buyAmount).toFixed(),
520
+ sellAmount: toBN(data.sellAmount).toFixed(),
521
+ buyToken: data.buyToken,
522
+ sellToken: data.sellToken,
523
+ receiver: data.receiver,
524
+ protocol: utils.parseBytes32String(data.protocol || ""),
525
+ }),
526
+ upgrade: (data, type) => ({
527
+ type,
528
+ version: utils.parseBytes32String(data.version || ""),
529
+ walletImpl: data.walletImpl,
530
+ }),
531
+ "gas-topup": (data, type) => ({
532
+ type,
533
+ amount: toBN(data.amount).toFixed(),
534
+ token: data.token,
535
+ onBehalf: data.onBehalf,
536
+ }),
537
+ dapp: (data, type) => ({
538
+ type,
539
+ name: data.name,
540
+ url: data.url,
541
+ }),
542
+ deploy: (data, type) => ({
543
+ type,
544
+ }),
545
+ "tx-builder": (data, type) => ({
546
+ type,
547
+ actionCount: utils.parseBytes32String(data.actionCount || ""),
548
+ }),
549
+ permit2: (data, type) => ({
550
+ type,
551
+ token: data.token,
552
+ spender: data.spender,
553
+ amount: toBN(data.amount).toFixed(),
554
+ expiration: data.expiration,
555
+ }),
556
+ "cross-transfer": (data, type) => ({
557
+ type,
558
+ fromToken: data.fromToken,
559
+ toToken: data.toToken,
560
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
561
+ amount: toBN(data.amount).toFixed(),
562
+ receiver: data.receiver,
563
+ }),
564
+ auth: (data) => ({
565
+ type: data.remove ? "remove-authority" : "add-authority",
566
+ address: data.address,
567
+ chainId: data.chainId ? data.chainId.toString() : null,
568
+ remove: data.remove,
569
+ }),
570
+ "instadapp-pro": (data, type) => ({
571
+ type,
572
+ castDetails: data.castDetails,
573
+ }),
574
+ rejection: (data, type) => ({
575
+ type,
576
+ id: data.id,
577
+ }),
578
+ "add-signers": (data, type) => ({
579
+ type,
580
+ addresses: data.signers,
581
+ }),
582
+ "remove-signers": (data, type) => ({
583
+ type,
584
+ addresses: data.signers,
585
+ }),
586
+ "change-threshold": (data, type) => ({
587
+ type,
588
+ count: data.count,
589
+ }),
590
+ "avocado-bridge": (data, type) => ({
591
+ type,
592
+ id: data.id,
593
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
594
+ }),
595
+ mass: (data, type) => ({
596
+ type,
597
+ data,
598
+ }),
599
+ };
600
+
313
601
  const parseMetadata = (metadata: string) => {
314
602
  const metadataArr = [];
315
- let payload = {};
316
603
 
317
604
  const [decodedMultiMetadata = []] =
318
605
  (ethers.utils.defaultAbiCoder.decode(
@@ -330,114 +617,17 @@ const parseMetadata = (metadata: string) => {
330
617
  decodedMetadata.type
331
618
  ) as keyof typeof actionMetadataTypes;
332
619
 
333
- const decodedData = ethers.utils.defaultAbiCoder.decode(
620
+ const decodedData = decodedMetadata?.data === '0x' ? '' : ethers.utils.defaultAbiCoder.decode(
334
621
  actionMetadataTypes[type],
335
622
  decodedMetadata.data
336
623
  );
337
624
 
338
- switch (type) {
339
- case "transfer":
340
- payload = {
341
- type,
342
- token: decodedData.token,
343
- amount: toBN(decodedData.amount).toFixed(),
344
- receiver: decodedData.receiver,
345
- };
346
- break;
347
- case "bridge":
348
- payload = {
349
- type,
350
- amount: toBN(decodedData.amount).toFixed(),
351
- receiver: decodedData.receiver,
352
- toToken: decodedData.toToken,
353
- fromToken: decodedData.fromToken,
354
- toChainId: decodedData.toChainId
355
- ? decodedData.toChainId.toString()
356
- : null,
357
- bridgeFee: toBN(decodedData.bridgeFee).toFixed(),
358
- };
359
- break;
360
- case "swap":
361
- payload = {
362
- type,
363
- buyAmount: toBN(decodedData.buyAmount).toFixed(),
364
- sellAmount: toBN(decodedData.sellAmount).toFixed(),
365
- buyToken: decodedData.buyToken,
366
- sellToken: decodedData.sellToken,
367
- receiver: decodedData.receiver,
368
- protocol: utils.parseBytes32String(decodedData?.protocol || ""),
369
- };
370
- break;
371
- case "upgrade":
372
- payload = {
373
- type,
374
- version: utils.parseBytes32String(decodedData?.version || ""),
375
- walletImpl: decodedData?.walletImpl,
376
- };
377
- break;
378
- case "gas-topup":
379
- payload = {
380
- type,
381
- amount: toBN(decodedData.amount).toFixed(),
382
- token: decodedData.token,
383
- onBehalf: decodedData.onBehalf,
384
- };
385
- break;
386
- case "dapp":
387
- payload = {
388
- type,
389
- name: decodedData?.name,
390
- url: decodedData?.url,
391
- };
392
- break;
393
- case "deploy":
394
- payload = {
395
- type,
396
- };
397
- break;
398
-
399
- case "permit2":
400
- payload = {
401
- type,
402
- token: decodedData.token,
403
- spender: decodedData.spender,
404
- amount: toBN(decodedData.amount).toFixed(),
405
- expiration: decodedData.expiration,
406
- };
407
- break;
408
-
409
- case "cross-transfer":
410
- payload = {
411
- type,
412
- fromToken: decodedData.fromToken,
413
- toToken: decodedData.toToken,
414
- toChainId: decodedData.toChainId
415
- ? decodedData.toChainId.toString()
416
- : null,
417
- amount: toBN(decodedData.amount).toFixed(),
418
- receiver: decodedData.receiver,
419
- };
420
-
421
- break;
422
- case "auth":
423
- payload = {
424
- type: decodedData.remove ? "remove-authority" : "add-authority",
425
- address: decodedData.address,
426
- chainId: decodedData.chainId ? decodedData.chainId.toString() : null,
427
- remove: decodedData.remove,
428
- };
429
-
430
- break;
431
- case "instadapp-pro":
432
- payload = {
433
- type,
434
- castDetails: decodedData.castDetails,
435
- };
436
-
437
- break;
438
- }
625
+ const payloadFunc = typesPayload[type];
439
626
 
440
- metadataArr.push(payload);
627
+ if (payloadFunc) {
628
+ const payload = payloadFunc(decodedData, type);
629
+ metadataArr.push(payload);
630
+ }
441
631
  }
442
632
 
443
633
  return metadataArr;
@@ -450,6 +640,10 @@ const parseMetadata = (metadata: string) => {
450
640
  * @returns {string} - The modified sentence with hyphens replaced with spaces and the first letter of each word capitalized.
451
641
  */
452
642
  export const formatTxType = (txType: string) => {
643
+ if(txType === 'mass') {
644
+ return 'Chain Agnostic Payments'
645
+ }
646
+
453
647
  const finalSentence = txType
454
648
  .replace("-", " ")
455
649
  .replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());