@instadapp/avocado-base 0.0.0-dev.fd1507c → 0.0.0-dev.fd73c5f

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 (41) hide show
  1. package/abi/multisigForwarder.json +697 -0
  2. package/app.vue +7 -0
  3. package/assets/images/icons/change-threshold.svg +4 -0
  4. package/assets/images/icons/cross-transfer.svg +7 -0
  5. package/assets/images/icons/dapp.svg +4 -0
  6. package/assets/images/icons/deploy.svg +12 -0
  7. package/assets/images/icons/gas.svg +12 -5
  8. package/assets/images/icons/hammer.svg +5 -0
  9. package/assets/images/icons/info-2.svg +12 -0
  10. package/assets/images/icons/instadapp-pro.svg +4 -0
  11. package/assets/images/icons/multi-send.svg +7 -0
  12. package/assets/images/icons/permit-sign.svg +11 -0
  13. package/assets/images/icons/plus-circle.svg +6 -0
  14. package/assets/images/icons/refresh.svg +4 -4
  15. package/assets/images/icons/reject-proposal.svg +6 -0
  16. package/assets/images/icons/transfer.svg +5 -0
  17. package/assets/images/icons/trash-2.svg +8 -0
  18. package/assets/images/icons/upgrade.svg +4 -0
  19. package/components/ActionLogo.vue +40 -0
  20. package/components/ActionMetadata.vue +45 -17
  21. package/components/AuthorityAvatar.vue +38 -0
  22. package/components/ChainLogo.vue +14 -556
  23. package/components/CopyClipboard.vue +64 -0
  24. package/components/metadata/Bridge.vue +30 -8
  25. package/components/metadata/CrossTransfer.vue +19 -5
  26. package/components/metadata/GasTopup.vue +10 -2
  27. package/components/metadata/Permit2.vue +6 -1
  28. package/components/metadata/Signers.vue +63 -0
  29. package/components/metadata/Swap.vue +12 -4
  30. package/components/metadata/Transfer.vue +14 -7
  31. package/contracts/MultisigForwarder.ts +859 -0
  32. package/contracts/factories/MultisigForwarder__factory.ts +721 -0
  33. package/contracts/factories/index.ts +1 -0
  34. package/contracts/index.ts +2 -0
  35. package/package.json +5 -3
  36. package/utils/formatter.ts +1 -1
  37. package/utils/helper.ts +8 -0
  38. package/utils/metadata.ts +320 -191
  39. package/utils/network.ts +170 -83
  40. package/utils/services.ts +8 -1
  41. package/utils/utils.d.ts +128 -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.0-dev.fd1507c",
3
+ "version": "0.0.0-dev.fd73c5f",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
@@ -20,11 +20,13 @@
20
20
  "nuxt-svgo": "^3.1.0",
21
21
  "rimraf": "^3.0.2",
22
22
  "typechain": "^8.1.1",
23
- "unplugin-vue-components": "^0.25.1"
23
+ "unplugin-vue-components": "^0.25.1",
24
+ "vue-tippy": "^6.0.0"
24
25
  },
25
26
  "dependencies": {
26
27
  "@vueuse/nuxt": "^10.2.0",
27
28
  "bignumber.js": "^9.1.1",
28
- "ethers": "^5.7.2"
29
+ "ethers": "^5.7.2",
30
+ "xxhashjs": "^0.2.2"
29
31
  }
30
32
  }
@@ -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,32 @@
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
+ 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
+ } as const;
3
24
 
4
25
  const multiMetadataTypes = ["bytes[]"];
5
26
 
6
27
  const metadataTypes = ["bytes32 type", "uint8 version", "bytes data"];
7
28
 
8
- const actionMetadataTypes = {
29
+ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
9
30
  transfer: ["address token", "uint256 amount", "address receiver"],
10
31
  "cross-transfer": [
11
32
  "address fromToken",
@@ -34,8 +55,10 @@ const actionMetadataTypes = {
34
55
  "gas-topup": ["uint256 amount", "address token", "address onBehalf"],
35
56
  upgrade: ["bytes32 version", "address walletImpl"],
36
57
  dapp: ["string name", "string url"],
58
+ import: ["bytes32 protocol", "uint256 valueInUsd"],
37
59
  auth: ["address address", "uint256 chainId", "bool remove"],
38
60
  deploy: [],
61
+ "tx-builder": ["bytes32 actionCount"],
39
62
  permit2: [
40
63
  "address token",
41
64
  "address spender",
@@ -43,6 +66,10 @@ const actionMetadataTypes = {
43
66
  "uint48 expiration",
44
67
  ],
45
68
  "instadapp-pro": ["string castDetails"],
69
+ "add-signers": ["address[] signers"],
70
+ "remove-signers": ["address[] signers"],
71
+ "change-threshold": ["uint8 count"],
72
+ rejection: ["bytes32 id"],
46
73
  };
47
74
 
48
75
  const encodeMetadata = (props: MetadataProps) => {
@@ -63,7 +90,7 @@ export const encodeDappMetadata = (
63
90
  );
64
91
 
65
92
  const data = encodeMetadata({
66
- type: "dapp",
93
+ type: MetadataEnums.dapp,
67
94
  encodedData,
68
95
  });
69
96
 
@@ -80,7 +107,21 @@ export const encodeTransferMetadata = (
80
107
  );
81
108
 
82
109
  const data = encodeMetadata({
83
- type: "transfer",
110
+ type: MetadataEnums.transfer,
111
+ encodedData,
112
+ });
113
+
114
+ return single ? encodeMultipleActions(data) : data;
115
+ };
116
+
117
+ export const encodeRejectionMetadata = (id: string, single = true) => {
118
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
119
+ actionMetadataTypes.rejection,
120
+ [id]
121
+ );
122
+
123
+ const data = encodeMetadata({
124
+ type: MetadataEnums.rejection,
84
125
  encodedData,
85
126
  });
86
127
 
@@ -103,7 +144,7 @@ export const encodeCrossTransferMetadata = (
103
144
  );
104
145
 
105
146
  const data = encodeMetadata({
106
- type: "cross-transfer",
147
+ type: MetadataEnums["cross-transfer"],
107
148
  encodedData,
108
149
  });
109
150
 
@@ -120,7 +161,7 @@ export const encodeAuthMetadata = (
120
161
  );
121
162
 
122
163
  const data = encodeMetadata({
123
- type: "auth",
164
+ type: MetadataEnums.auth,
124
165
  encodedData,
125
166
  });
126
167
 
@@ -129,13 +170,30 @@ export const encodeAuthMetadata = (
129
170
 
130
171
  export const encodeDeployMetadata = (single = true) => {
131
172
  const data = encodeMetadata({
132
- type: "deploy",
173
+ type: MetadataEnums.deploy,
133
174
  encodedData: "0x",
134
175
  });
135
176
 
136
177
  return single ? encodeMultipleActions(data) : data;
137
178
  };
138
179
 
180
+ export const encodeTransactionBuilderMetadata = (
181
+ actionCount: string,
182
+ single = true
183
+ ) => {
184
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
185
+ actionMetadataTypes["tx-builder"],
186
+ [actionCount]
187
+ );
188
+
189
+ const data = encodeMetadata({
190
+ type: MetadataEnums["tx-builder"],
191
+ encodedData,
192
+ });
193
+
194
+ return single ? encodeMultipleActions(data) : data;
195
+ };
196
+
139
197
  export const encodeWCSignMetadata = (
140
198
  params: SignMetadataProps,
141
199
  single = true
@@ -146,7 +204,7 @@ export const encodeWCSignMetadata = (
146
204
  );
147
205
 
148
206
  const data = encodeMetadata({
149
- type: "permit2",
207
+ type: MetadataEnums.permit2,
150
208
  encodedData,
151
209
  });
152
210
 
@@ -163,7 +221,7 @@ export const encodeUpgradeMetadata = (
163
221
  );
164
222
 
165
223
  const data = encodeMetadata({
166
- type: "upgrade",
224
+ type: MetadataEnums.upgrade,
167
225
  encodedData,
168
226
  });
169
227
 
@@ -187,7 +245,7 @@ export const encodeSwapMetadata = (
187
245
  );
188
246
 
189
247
  const data = encodeMetadata({
190
- type: "swap",
248
+ type: MetadataEnums.swap,
191
249
  encodedData,
192
250
  });
193
251
 
@@ -203,10 +261,8 @@ export const encodeTopupMetadata = (
203
261
  [params.amount, params.token, params.onBehalf]
204
262
  );
205
263
 
206
- console.log(params);
207
-
208
264
  const data = encodeMetadata({
209
- type: "gas-topup",
265
+ type: MetadataEnums["gas-topup"],
210
266
  encodedData,
211
267
  });
212
268
 
@@ -231,7 +287,76 @@ export const encodeBridgeMetadata = (
231
287
  );
232
288
 
233
289
  const data = encodeMetadata({
234
- type: "bridge",
290
+ type: MetadataEnums.bridge,
291
+ encodedData,
292
+ });
293
+
294
+ return single ? encodeMultipleActions(data) : data;
295
+ };
296
+
297
+ export const encodeChangeThresholdMetadata = (
298
+ threshold: string | number,
299
+ single = true
300
+ ) => {
301
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
302
+ actionMetadataTypes["change-threshold"],
303
+ [toBN(threshold).toNumber()]
304
+ );
305
+
306
+ const data = encodeMetadata({
307
+ type: MetadataEnums["change-threshold"],
308
+ encodedData,
309
+ });
310
+
311
+ return single ? encodeMultipleActions(data) : data;
312
+ };
313
+
314
+ export const encodeRemoveSignersMetadata = (
315
+ addresses: string[],
316
+ single = true
317
+ ) => {
318
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
319
+ actionMetadataTypes["remove-signers"],
320
+ [addresses]
321
+ );
322
+
323
+ const data = encodeMetadata({
324
+ type: MetadataEnums["remove-signers"],
325
+ encodedData,
326
+ });
327
+
328
+ return single ? encodeMultipleActions(data) : data;
329
+ };
330
+
331
+ export const encodeImportMetadata = (
332
+ protocol: string,
333
+ valueInUsd: string,
334
+ single = true
335
+ ) => {
336
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
337
+ actionMetadataTypes["import"],
338
+ [protocol, valueInUsd]
339
+ );
340
+
341
+ const data = encodeMetadata({
342
+ type: MetadataEnums["import"],
343
+ encodedData,
344
+ });
345
+
346
+ return single ? encodeMultipleActions(data) : data;
347
+ };
348
+
349
+ export const encodeAddSignersMetadata = (
350
+ addresses: string[],
351
+ single = true
352
+ ) => {
353
+ const encodedData = ethers.utils.defaultAbiCoder.encode(
354
+ actionMetadataTypes["add-signers"],
355
+ [addresses]
356
+ );
357
+
358
+ const data = encodeMetadata({
359
+ type: MetadataEnums["add-signers"],
235
360
  encodedData,
236
361
  });
237
362
 
@@ -242,191 +367,195 @@ export const encodeMultipleActions = (...actionData: string[]) => {
242
367
  return ethers.utils.defaultAbiCoder.encode(multiMetadataTypes, [actionData]);
243
368
  };
244
369
 
245
- export const decodeMetadata = (data: string) => {
370
+ export const decodeData = (data: string) => {
371
+ try {
372
+ const metadata = getMetadataFromData(data) || "0x";
373
+
374
+ return parseMetadata(metadata);
375
+ } catch (e) {
376
+ // console.log(e);
377
+ return null;
378
+ }
379
+ };
380
+
381
+ export const decodeMetadata = (metadata: string) => {
246
382
  try {
247
- const iface = Forwarder__factory.createInterface();
248
- let metadata = "0x";
249
- let payload = {};
250
-
251
- if (!data) return payload;
252
-
253
- if (data.startsWith("0x18e7f485")) {
254
- const executeData = iface.decodeFunctionData("execute", data);
255
- if (executeData.metadata_ === "0x" || !executeData.metadata_) {
256
- return null;
257
- } else {
258
- metadata = executeData.metadata_;
259
- }
260
- } else if (data.startsWith("0x14f80a8d")) {
261
- const executeDataV2 = iface.decodeFunctionData("executeV2", data);
262
- if (
263
- executeDataV2.params_.metadata === "0x" ||
264
- !executeDataV2.params_.metadata
265
- ) {
266
- return null;
267
- } else {
268
- metadata = executeDataV2.params_.metadata;
269
- }
270
- } else if (data.startsWith("0x85114d53")) {
271
- const executeDataV3 = iface.decodeFunctionData("executeV3", data);
272
- if (
273
- executeDataV3.params_.metadata === "0x" ||
274
- !executeDataV3.params_.metadata
275
- ) {
276
- return null;
277
- } else {
278
- metadata = executeDataV3.params_.metadata;
279
- }
383
+ return parseMetadata(metadata);
384
+ } catch (e) {
385
+ return null;
386
+ }
387
+ };
388
+
389
+ const iface = Forwarder__factory.createInterface();
390
+ const ifaceMultisig = MultisigForwarder__factory.createInterface();
391
+
392
+ const getMetadataFromData = (data: string) => {
393
+ let metadata = "0x";
394
+
395
+ if (data.startsWith("0x18e7f485")) {
396
+ const executeData = iface.decodeFunctionData("execute", data);
397
+ if (executeData.metadata_ === "0x" || !executeData.metadata_) {
398
+ return null;
280
399
  } else {
281
- const executeDataMultisigV3 = iface.decodeFunctionData(
282
- "executeMultisigV3",
283
- data
284
- );
285
- if (
286
- executeDataMultisigV3.params_.metadata === "0x" ||
287
- !executeDataMultisigV3.params_.metadata
288
- ) {
289
- return null;
290
- } else {
291
- metadata = executeDataMultisigV3.params_.metadata;
292
- }
400
+ metadata = executeData.metadata_;
293
401
  }
402
+ } else if (data.startsWith("0x14f80a8d")) {
403
+ const executeDataV2 = iface.decodeFunctionData("executeV2", data);
404
+ if (
405
+ executeDataV2.params_.metadata === "0x" ||
406
+ !executeDataV2.params_.metadata
407
+ ) {
408
+ return null;
409
+ } else {
410
+ metadata = executeDataV2.params_.metadata;
411
+ }
412
+ } else {
413
+ const executeDataMultisig = ifaceMultisig.decodeFunctionData(
414
+ "executeV1",
415
+ data
416
+ );
417
+ if (
418
+ executeDataMultisig.params_.metadata === "0x" ||
419
+ !executeDataMultisig.params_.metadata
420
+ ) {
421
+ return null;
422
+ } else {
423
+ metadata = executeDataMultisig.params_.metadata;
424
+ }
425
+ }
426
+
427
+ return metadata;
428
+ };
429
+
430
+ const typesPayload: IPayload = {
431
+ import: (data, type) => ({
432
+ type,
433
+ protocol: utils.parseBytes32String(data.protocol || ""),
434
+ valueInUsd: toBN(data.valueInUsd).toFixed(),
435
+ }),
436
+ transfer: (data, type) => ({
437
+ type,
438
+ token: data.token,
439
+ amount: toBN(data.amount).toFixed(),
440
+ receiver: data.receiver,
441
+ }),
442
+ bridge: (data, type) => ({
443
+ type,
444
+ amount: toBN(data.amount).toFixed(),
445
+ receiver: data.receiver,
446
+ toToken: data.toToken,
447
+ fromToken: data.fromToken,
448
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
449
+ bridgeFee: toBN(data.bridgeFee).toFixed(),
450
+ }),
451
+ swap: (data, type) => ({
452
+ type,
453
+ buyAmount: toBN(data.buyAmount).toFixed(),
454
+ sellAmount: toBN(data.sellAmount).toFixed(),
455
+ buyToken: data.buyToken,
456
+ sellToken: data.sellToken,
457
+ receiver: data.receiver,
458
+ protocol: utils.parseBytes32String(data.protocol || ""),
459
+ }),
460
+ upgrade: (data, type) => ({
461
+ type,
462
+ version: utils.parseBytes32String(data.version || ""),
463
+ walletImpl: data.walletImpl,
464
+ }),
465
+ "gas-topup": (data, type) => ({
466
+ type,
467
+ amount: toBN(data.amount).toFixed(),
468
+ token: data.token,
469
+ onBehalf: data.onBehalf,
470
+ }),
471
+ dapp: (data, type) => ({
472
+ type,
473
+ name: data.name,
474
+ url: data.url,
475
+ }),
476
+ deploy: (data, type) => ({
477
+ type,
478
+ }),
479
+ "tx-builder": (data, type) => ({
480
+ type,
481
+ actionCount: utils.parseBytes32String(data.actionCount || ""),
482
+ }),
483
+ permit2: (data, type) => ({
484
+ type,
485
+ token: data.token,
486
+ spender: data.spender,
487
+ amount: toBN(data.amount).toFixed(),
488
+ expiration: data.expiration,
489
+ }),
490
+ "cross-transfer": (data, type) => ({
491
+ type,
492
+ fromToken: data.fromToken,
493
+ toToken: data.toToken,
494
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
495
+ amount: toBN(data.amount).toFixed(),
496
+ receiver: data.receiver,
497
+ }),
498
+ auth: (data) => ({
499
+ type: data.remove ? "remove-authority" : "add-authority",
500
+ address: data.address,
501
+ chainId: data.chainId ? data.chainId.toString() : null,
502
+ remove: data.remove,
503
+ }),
504
+ "instadapp-pro": (data, type) => ({
505
+ type,
506
+ castDetails: data.castDetails,
507
+ }),
508
+ rejection: (data, type) => ({
509
+ type,
510
+ id: data.id,
511
+ }),
512
+ "add-signers": (data, type) => ({
513
+ type,
514
+ addresses: data.signers,
515
+ }),
516
+ "remove-signers": (data, type) => ({
517
+ type,
518
+ addresses: data.signers,
519
+ }),
520
+ "change-threshold": (data, type) => ({
521
+ type,
522
+ count: data.count,
523
+ }),
524
+ };
525
+
526
+ const parseMetadata = (metadata: string) => {
527
+ const metadataArr = [];
528
+
529
+ const [decodedMultiMetadata = []] =
530
+ (ethers.utils.defaultAbiCoder.decode(
531
+ multiMetadataTypes,
532
+ metadata
533
+ ) as string[]) || [];
534
+
535
+ for (let metadata of decodedMultiMetadata) {
536
+ const decodedMetadata = ethers.utils.defaultAbiCoder.decode(
537
+ metadataTypes,
538
+ metadata
539
+ );
540
+
541
+ const type = ethers.utils.parseBytes32String(
542
+ decodedMetadata.type
543
+ ) as keyof typeof actionMetadataTypes;
294
544
 
295
- const metadataArr = [];
296
-
297
- const [decodedMultiMetadata = []] =
298
- (ethers.utils.defaultAbiCoder.decode(
299
- multiMetadataTypes,
300
- metadata
301
- ) as string[]) || [];
302
-
303
- for (let metadata of decodedMultiMetadata) {
304
- const decodedMetadata = ethers.utils.defaultAbiCoder.decode(
305
- metadataTypes,
306
- metadata
307
- );
308
-
309
- const type = ethers.utils.parseBytes32String(
310
- decodedMetadata.type
311
- ) as keyof typeof actionMetadataTypes;
312
-
313
- const decodedData = ethers.utils.defaultAbiCoder.decode(
314
- actionMetadataTypes[type],
315
- decodedMetadata.data
316
- );
317
-
318
- switch (type) {
319
- case "transfer":
320
- payload = {
321
- type,
322
- token: decodedData.token,
323
- amount: toBN(decodedData.amount).toFixed(),
324
- receiver: decodedData.receiver,
325
- };
326
- break;
327
- case "bridge":
328
- payload = {
329
- type,
330
- amount: toBN(decodedData.amount).toFixed(),
331
- receiver: decodedData.receiver,
332
- toToken: decodedData.toToken,
333
- fromToken: decodedData.fromToken,
334
- toChainId: decodedData.toChainId
335
- ? decodedData.toChainId.toString()
336
- : null,
337
- bridgeFee: toBN(decodedData.bridgeFee).toFixed(),
338
- };
339
- break;
340
- case "swap":
341
- payload = {
342
- type,
343
- buyAmount: toBN(decodedData.buyAmount).toFixed(),
344
- sellAmount: toBN(decodedData.sellAmount).toFixed(),
345
- buyToken: decodedData.buyToken,
346
- sellToken: decodedData.sellToken,
347
- receiver: decodedData.receiver,
348
- protocol: utils.parseBytes32String(decodedData?.protocol || ""),
349
- };
350
- break;
351
- case "upgrade":
352
- payload = {
353
- type,
354
- version: utils.parseBytes32String(decodedData?.version || ""),
355
- walletImpl: decodedData?.walletImpl,
356
- };
357
- break;
358
- case "gas-topup":
359
- payload = {
360
- type,
361
- amount: toBN(decodedData.amount).toFixed(),
362
- token: decodedData.token,
363
- onBehalf: decodedData.onBehalf,
364
- };
365
- break;
366
- case "dapp":
367
- payload = {
368
- type,
369
- name: decodedData?.name,
370
- url: decodedData?.url,
371
- };
372
- break;
373
- case "deploy":
374
- payload = {
375
- type,
376
- };
377
- break;
378
-
379
- case "permit2":
380
- payload = {
381
- type,
382
- token: decodedData.token,
383
- spender: decodedData.spender,
384
- amount: toBN(decodedData.amount).toFixed(),
385
- expiration: decodedData.expiration,
386
- };
387
- break;
388
-
389
- case "cross-transfer":
390
- payload = {
391
- type,
392
- fromToken: decodedData.fromToken,
393
- toToken: decodedData.toToken,
394
- toChainId: decodedData.toChainId
395
- ? decodedData.toChainId.toString()
396
- : null,
397
- amount: toBN(decodedData.amount).toFixed(),
398
- receiver: decodedData.receiver,
399
- };
400
-
401
- break;
402
- case "auth":
403
- payload = {
404
- type: decodedData.remove ? "remove-authority" : "add-authority",
405
- address: decodedData.address,
406
- chainId: decodedData.chainId
407
- ? decodedData.chainId.toString()
408
- : null,
409
- remove: decodedData.remove,
410
- };
411
-
412
- break;
413
- case "instadapp-pro":
414
- payload = {
415
- type,
416
- castDetails: decodedData.castDetails,
417
- };
418
-
419
- break;
420
- }
545
+ const decodedData = ethers.utils.defaultAbiCoder.decode(
546
+ actionMetadataTypes[type],
547
+ decodedMetadata.data
548
+ );
421
549
 
550
+ const payloadFunc = typesPayload[type];
551
+
552
+ if (payloadFunc) {
553
+ const payload = payloadFunc(decodedData, type);
422
554
  metadataArr.push(payload);
423
555
  }
424
-
425
- return metadataArr;
426
- } catch (e) {
427
- // console.log(e);
428
- return null;
429
556
  }
557
+
558
+ return metadataArr;
430
559
  };
431
560
 
432
561
  /**