@instadapp/avocado-base 0.0.0-dev.eda2183 → 0.0.0-dev.f0b0c4f
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/abi/multisigForwarder.json +697 -0
- package/app.vue +7 -0
- package/assets/images/icons/change-threshold.svg +4 -0
- package/assets/images/icons/cross-transfer.svg +7 -0
- package/assets/images/icons/dapp.svg +4 -0
- package/assets/images/icons/deploy.svg +12 -0
- package/assets/images/icons/gas.svg +12 -5
- package/assets/images/icons/info-2.svg +12 -0
- package/assets/images/icons/instadapp-pro.svg +4 -0
- package/assets/images/icons/multi-send.svg +7 -0
- package/assets/images/icons/permit-sign.svg +11 -0
- package/assets/images/icons/plus-circle.svg +6 -0
- package/assets/images/icons/refresh.svg +4 -4
- package/assets/images/icons/reject-proposal.svg +6 -0
- package/assets/images/icons/transfer.svg +5 -0
- package/assets/images/icons/trash-2.svg +8 -0
- package/assets/images/icons/upgrade.svg +4 -0
- package/components/ActionLogo.vue +38 -0
- package/components/ActionMetadata.vue +27 -5
- package/components/AuthorityAvatar.vue +38 -0
- package/components/ChainLogo.vue +14 -556
- package/components/CopyClipboard.vue +64 -0
- package/components/metadata/Bridge.vue +30 -8
- package/components/metadata/CrossTransfer.vue +8 -2
- package/components/metadata/GasTopup.vue +10 -2
- package/components/metadata/Permit2.vue +6 -1
- package/components/metadata/Signers.vue +62 -0
- package/components/metadata/Swap.vue +12 -4
- package/components/metadata/Transfer.vue +14 -7
- package/contracts/MultisigForwarder.ts +859 -0
- package/contracts/factories/MultisigForwarder__factory.ts +721 -0
- package/contracts/factories/index.ts +1 -0
- package/contracts/index.ts +2 -0
- package/package.json +5 -3
- package/utils/formatter.ts +1 -1
- package/utils/helper.ts +8 -0
- package/utils/metadata.ts +228 -132
- package/utils/network.ts +139 -80
- package/utils/services.ts +8 -1
- package/utils/utils.d.ts +129 -126
package/contracts/index.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.0.0-dev.f0b0c4f",
|
|
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
|
}
|
package/utils/formatter.ts
CHANGED
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,31 @@
|
|
|
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
|
+
} as const;
|
|
3
23
|
|
|
4
24
|
const multiMetadataTypes = ["bytes[]"];
|
|
5
25
|
|
|
6
26
|
const metadataTypes = ["bytes32 type", "uint8 version", "bytes data"];
|
|
7
27
|
|
|
8
|
-
const actionMetadataTypes = {
|
|
28
|
+
const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
9
29
|
transfer: ["address token", "uint256 amount", "address receiver"],
|
|
10
30
|
"cross-transfer": [
|
|
11
31
|
"address fromToken",
|
|
@@ -34,6 +54,7 @@ const actionMetadataTypes = {
|
|
|
34
54
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
35
55
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
36
56
|
dapp: ["string name", "string url"],
|
|
57
|
+
"import": ["bytes32 protocol", "uint256 valueInUsd"],
|
|
37
58
|
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
38
59
|
deploy: [],
|
|
39
60
|
permit2: [
|
|
@@ -43,6 +64,10 @@ const actionMetadataTypes = {
|
|
|
43
64
|
"uint48 expiration",
|
|
44
65
|
],
|
|
45
66
|
"instadapp-pro": ["string castDetails"],
|
|
67
|
+
'add-signers': ['address[] signers'],
|
|
68
|
+
'remove-signers': ['address[] signers'],
|
|
69
|
+
'change-threshold': ['uint8 count'],
|
|
70
|
+
'rejection': ['bytes32 id'],
|
|
46
71
|
};
|
|
47
72
|
|
|
48
73
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -63,7 +88,7 @@ export const encodeDappMetadata = (
|
|
|
63
88
|
);
|
|
64
89
|
|
|
65
90
|
const data = encodeMetadata({
|
|
66
|
-
type:
|
|
91
|
+
type: MetadataEnums.dapp,
|
|
67
92
|
encodedData,
|
|
68
93
|
});
|
|
69
94
|
|
|
@@ -80,7 +105,21 @@ export const encodeTransferMetadata = (
|
|
|
80
105
|
);
|
|
81
106
|
|
|
82
107
|
const data = encodeMetadata({
|
|
83
|
-
type:
|
|
108
|
+
type: MetadataEnums.transfer,
|
|
109
|
+
encodedData,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return single ? encodeMultipleActions(data) : data;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const encodeRejectionMetadata = (id: string, single = true) => {
|
|
116
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
117
|
+
actionMetadataTypes.rejection,
|
|
118
|
+
[id]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const data = encodeMetadata({
|
|
122
|
+
type: MetadataEnums.rejection,
|
|
84
123
|
encodedData,
|
|
85
124
|
});
|
|
86
125
|
|
|
@@ -103,7 +142,7 @@ export const encodeCrossTransferMetadata = (
|
|
|
103
142
|
);
|
|
104
143
|
|
|
105
144
|
const data = encodeMetadata({
|
|
106
|
-
type: "cross-transfer",
|
|
145
|
+
type: MetadataEnums["cross-transfer"],
|
|
107
146
|
encodedData,
|
|
108
147
|
});
|
|
109
148
|
|
|
@@ -120,7 +159,7 @@ export const encodeAuthMetadata = (
|
|
|
120
159
|
);
|
|
121
160
|
|
|
122
161
|
const data = encodeMetadata({
|
|
123
|
-
type:
|
|
162
|
+
type: MetadataEnums.auth,
|
|
124
163
|
encodedData,
|
|
125
164
|
});
|
|
126
165
|
|
|
@@ -129,7 +168,7 @@ export const encodeAuthMetadata = (
|
|
|
129
168
|
|
|
130
169
|
export const encodeDeployMetadata = (single = true) => {
|
|
131
170
|
const data = encodeMetadata({
|
|
132
|
-
type:
|
|
171
|
+
type: MetadataEnums.deploy,
|
|
133
172
|
encodedData: "0x",
|
|
134
173
|
});
|
|
135
174
|
|
|
@@ -146,7 +185,7 @@ export const encodeWCSignMetadata = (
|
|
|
146
185
|
);
|
|
147
186
|
|
|
148
187
|
const data = encodeMetadata({
|
|
149
|
-
type:
|
|
188
|
+
type: MetadataEnums.permit2,
|
|
150
189
|
encodedData,
|
|
151
190
|
});
|
|
152
191
|
|
|
@@ -163,7 +202,7 @@ export const encodeUpgradeMetadata = (
|
|
|
163
202
|
);
|
|
164
203
|
|
|
165
204
|
const data = encodeMetadata({
|
|
166
|
-
type:
|
|
205
|
+
type: MetadataEnums.upgrade,
|
|
167
206
|
encodedData,
|
|
168
207
|
});
|
|
169
208
|
|
|
@@ -187,7 +226,7 @@ export const encodeSwapMetadata = (
|
|
|
187
226
|
);
|
|
188
227
|
|
|
189
228
|
const data = encodeMetadata({
|
|
190
|
-
type:
|
|
229
|
+
type: MetadataEnums.swap,
|
|
191
230
|
encodedData,
|
|
192
231
|
});
|
|
193
232
|
|
|
@@ -203,10 +242,8 @@ export const encodeTopupMetadata = (
|
|
|
203
242
|
[params.amount, params.token, params.onBehalf]
|
|
204
243
|
);
|
|
205
244
|
|
|
206
|
-
console.log(params);
|
|
207
|
-
|
|
208
245
|
const data = encodeMetadata({
|
|
209
|
-
type: "gas-topup",
|
|
246
|
+
type: MetadataEnums["gas-topup"],
|
|
210
247
|
encodedData,
|
|
211
248
|
});
|
|
212
249
|
|
|
@@ -231,7 +268,76 @@ export const encodeBridgeMetadata = (
|
|
|
231
268
|
);
|
|
232
269
|
|
|
233
270
|
const data = encodeMetadata({
|
|
234
|
-
type:
|
|
271
|
+
type: MetadataEnums.bridge,
|
|
272
|
+
encodedData,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return single ? encodeMultipleActions(data) : data;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export const encodeChangeThresholdMetadata = (
|
|
279
|
+
threshold: string | number,
|
|
280
|
+
single = true
|
|
281
|
+
) => {
|
|
282
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
283
|
+
actionMetadataTypes["change-threshold"],
|
|
284
|
+
[toBN(threshold).toNumber()]
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const data = encodeMetadata({
|
|
288
|
+
type: MetadataEnums["change-threshold"],
|
|
289
|
+
encodedData,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
return single ? encodeMultipleActions(data) : data;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export const encodeRemoveSignersMetadata = (
|
|
296
|
+
addresses: string[],
|
|
297
|
+
single = true
|
|
298
|
+
) => {
|
|
299
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
300
|
+
actionMetadataTypes["remove-signers"],
|
|
301
|
+
[addresses]
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
const data = encodeMetadata({
|
|
305
|
+
type: MetadataEnums["remove-signers"],
|
|
306
|
+
encodedData,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
return single ? encodeMultipleActions(data) : data;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export const encodeImportMetadata = (
|
|
313
|
+
protocol: string,
|
|
314
|
+
valueInUsd: string,
|
|
315
|
+
single = true
|
|
316
|
+
) => {
|
|
317
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
318
|
+
actionMetadataTypes["import"],
|
|
319
|
+
[protocol, valueInUsd]
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const data = encodeMetadata({
|
|
323
|
+
type: MetadataEnums["import"],
|
|
324
|
+
encodedData,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
return single ? encodeMultipleActions(data) : data;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export const encodeAddSignersMetadata = (
|
|
331
|
+
addresses: string[],
|
|
332
|
+
single = true
|
|
333
|
+
) => {
|
|
334
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
335
|
+
actionMetadataTypes["add-signers"],
|
|
336
|
+
[addresses]
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const data = encodeMetadata({
|
|
340
|
+
type: MetadataEnums["add-signers"],
|
|
235
341
|
encodedData,
|
|
236
342
|
});
|
|
237
343
|
|
|
@@ -261,8 +367,10 @@ export const decodeMetadata = (metadata: string) => {
|
|
|
261
367
|
}
|
|
262
368
|
};
|
|
263
369
|
|
|
370
|
+
const iface = Forwarder__factory.createInterface();
|
|
371
|
+
const ifaceMultisig = MultisigForwarder__factory.createInterface();
|
|
372
|
+
|
|
264
373
|
const getMetadataFromData = (data: string) => {
|
|
265
|
-
const iface = Forwarder__factory.createInterface();
|
|
266
374
|
let metadata = "0x";
|
|
267
375
|
|
|
268
376
|
if (data.startsWith("0x18e7f485")) {
|
|
@@ -282,37 +390,119 @@ const getMetadataFromData = (data: string) => {
|
|
|
282
390
|
} else {
|
|
283
391
|
metadata = executeDataV2.params_.metadata;
|
|
284
392
|
}
|
|
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
393
|
} else {
|
|
296
|
-
const
|
|
297
|
-
"
|
|
394
|
+
const executeDataMultisig = ifaceMultisig.decodeFunctionData(
|
|
395
|
+
"executeV1",
|
|
298
396
|
data
|
|
299
397
|
);
|
|
300
398
|
if (
|
|
301
|
-
|
|
302
|
-
!
|
|
399
|
+
executeDataMultisig.params_.metadata === "0x" ||
|
|
400
|
+
!executeDataMultisig.params_.metadata
|
|
303
401
|
) {
|
|
304
402
|
return null;
|
|
305
403
|
} else {
|
|
306
|
-
metadata =
|
|
404
|
+
metadata = executeDataMultisig.params_.metadata;
|
|
307
405
|
}
|
|
308
406
|
}
|
|
309
407
|
|
|
310
408
|
return metadata;
|
|
311
409
|
};
|
|
312
410
|
|
|
411
|
+
|
|
412
|
+
const typesPayload: IPayload = {
|
|
413
|
+
import: (data, type) => ({
|
|
414
|
+
type,
|
|
415
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
416
|
+
valueInUsd: toBN(data.valueInUsd).toFixed(),
|
|
417
|
+
}),
|
|
418
|
+
transfer: (data, type) => ({
|
|
419
|
+
type,
|
|
420
|
+
token: data.token,
|
|
421
|
+
amount: toBN(data.amount).toFixed(),
|
|
422
|
+
receiver: data.receiver,
|
|
423
|
+
}),
|
|
424
|
+
bridge: (data, type) => ({
|
|
425
|
+
type,
|
|
426
|
+
amount: toBN(data.amount).toFixed(),
|
|
427
|
+
receiver: data.receiver,
|
|
428
|
+
toToken: data.toToken,
|
|
429
|
+
fromToken: data.fromToken,
|
|
430
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
431
|
+
bridgeFee: toBN(data.bridgeFee).toFixed(),
|
|
432
|
+
}),
|
|
433
|
+
swap: (data, type) => ({
|
|
434
|
+
type,
|
|
435
|
+
buyAmount: toBN(data.buyAmount).toFixed(),
|
|
436
|
+
sellAmount: toBN(data.sellAmount).toFixed(),
|
|
437
|
+
buyToken: data.buyToken,
|
|
438
|
+
sellToken: data.sellToken,
|
|
439
|
+
receiver: data.receiver,
|
|
440
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
441
|
+
}),
|
|
442
|
+
upgrade: (data, type) => ({
|
|
443
|
+
type,
|
|
444
|
+
version: utils.parseBytes32String(data.version || ""),
|
|
445
|
+
walletImpl: data.walletImpl,
|
|
446
|
+
}),
|
|
447
|
+
"gas-topup": (data, type) => ({
|
|
448
|
+
type,
|
|
449
|
+
amount: toBN(data.amount).toFixed(),
|
|
450
|
+
token: data.token,
|
|
451
|
+
onBehalf: data.onBehalf,
|
|
452
|
+
}),
|
|
453
|
+
"dapp": (data, type) => ({
|
|
454
|
+
type,
|
|
455
|
+
name: data.name,
|
|
456
|
+
url: data.url,
|
|
457
|
+
}),
|
|
458
|
+
"deploy": (data, type) => ({
|
|
459
|
+
type,
|
|
460
|
+
}),
|
|
461
|
+
"permit2": (data, type) => ({
|
|
462
|
+
type,
|
|
463
|
+
token: data.token,
|
|
464
|
+
spender: data.spender,
|
|
465
|
+
amount: toBN(data.amount).toFixed(),
|
|
466
|
+
expiration: data.expiration,
|
|
467
|
+
}),
|
|
468
|
+
"cross-transfer": (data, type) => ({
|
|
469
|
+
type,
|
|
470
|
+
fromToken: data.fromToken,
|
|
471
|
+
toToken: data.toToken,
|
|
472
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
473
|
+
amount: toBN(data.amount).toFixed(),
|
|
474
|
+
receiver: data.receiver,
|
|
475
|
+
}),
|
|
476
|
+
"auth": (data) => ({
|
|
477
|
+
type: data.remove ? "remove-authority" : "add-authority",
|
|
478
|
+
address: data.address,
|
|
479
|
+
chainId: data.chainId ? data.chainId.toString() : null,
|
|
480
|
+
remove: data.remove,
|
|
481
|
+
}),
|
|
482
|
+
"instadapp-pro": (data, type) => ({
|
|
483
|
+
type,
|
|
484
|
+
castDetails: data.castDetails,
|
|
485
|
+
}),
|
|
486
|
+
"rejection": (data, type) => ({
|
|
487
|
+
type,
|
|
488
|
+
id: data.id,
|
|
489
|
+
}),
|
|
490
|
+
"add-signers": (data, type) => ({
|
|
491
|
+
type,
|
|
492
|
+
addresses: data.signers,
|
|
493
|
+
}),
|
|
494
|
+
"remove-signers": (data, type) => ({
|
|
495
|
+
type,
|
|
496
|
+
addresses: data.signers,
|
|
497
|
+
}),
|
|
498
|
+
"change-threshold": (data, type) => ({
|
|
499
|
+
type,
|
|
500
|
+
count: data.count,
|
|
501
|
+
}),
|
|
502
|
+
};
|
|
503
|
+
|
|
313
504
|
const parseMetadata = (metadata: string) => {
|
|
314
505
|
const metadataArr = [];
|
|
315
|
-
let payload = {};
|
|
316
506
|
|
|
317
507
|
const [decodedMultiMetadata = []] =
|
|
318
508
|
(ethers.utils.defaultAbiCoder.decode(
|
|
@@ -335,114 +525,20 @@ const parseMetadata = (metadata: string) => {
|
|
|
335
525
|
decodedMetadata.data
|
|
336
526
|
);
|
|
337
527
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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;
|
|
528
|
+
const payloadFunc = typesPayload[type]
|
|
529
|
+
|
|
530
|
+
if (payloadFunc) {
|
|
531
|
+
const payload = payloadFunc(decodedData, type)
|
|
532
|
+
metadataArr.push(payload);
|
|
438
533
|
}
|
|
439
534
|
|
|
440
|
-
metadataArr.push(payload);
|
|
441
535
|
}
|
|
442
536
|
|
|
443
537
|
return metadataArr;
|
|
444
538
|
};
|
|
445
539
|
|
|
540
|
+
|
|
541
|
+
|
|
446
542
|
/**
|
|
447
543
|
* Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
|
|
448
544
|
* @param {string} txType - The input sentence to modify
|