@instadapp/avocado-base 0.0.0-dev.9853aa2 → 0.0.0-dev.9dbd5b5
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/hammer.svg +5 -0
- 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 +40 -0
- package/components/ActionMetadata.vue +30 -4
- package/components/AuthorityAvatar.vue +38 -0
- package/components/ChainLogo.vue +14 -556
- package/components/CopyClipboard.vue +64 -0
- package/components/metadata/Bridge.vue +26 -6
- package/components/metadata/CrossTransfer.vue +5 -1
- package/components/metadata/GasTopup.vue +7 -1
- package/components/metadata/Permit2.vue +6 -1
- package/components/metadata/Signers.vue +63 -0
- package/components/metadata/Swap.vue +9 -2
- package/components/metadata/Transfer.vue +6 -2
- 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 +238 -145
- package/utils/network.ts +163 -80
- package/utils/services.ts +8 -1
- package/utils/utils.d.ts +128 -127
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.9dbd5b5",
|
|
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,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
|
+
"transaction-builder": "transaction-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
|
+
"transaction-builder": ["bytes32 actionCount"],
|
|
39
62
|
permit2: [
|
|
40
63
|
"address token",
|
|
41
64
|
"address spender",
|
|
@@ -43,7 +66,10 @@ const actionMetadataTypes = {
|
|
|
43
66
|
"uint48 expiration",
|
|
44
67
|
],
|
|
45
68
|
"instadapp-pro": ["string castDetails"],
|
|
46
|
-
|
|
69
|
+
"add-signers": ["address[] signers"],
|
|
70
|
+
"remove-signers": ["address[] signers"],
|
|
71
|
+
"change-threshold": ["uint8 count"],
|
|
72
|
+
rejection: ["bytes32 id"],
|
|
47
73
|
};
|
|
48
74
|
|
|
49
75
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -64,7 +90,7 @@ export const encodeDappMetadata = (
|
|
|
64
90
|
);
|
|
65
91
|
|
|
66
92
|
const data = encodeMetadata({
|
|
67
|
-
type:
|
|
93
|
+
type: MetadataEnums.dapp,
|
|
68
94
|
encodedData,
|
|
69
95
|
});
|
|
70
96
|
|
|
@@ -81,21 +107,21 @@ export const encodeTransferMetadata = (
|
|
|
81
107
|
);
|
|
82
108
|
|
|
83
109
|
const data = encodeMetadata({
|
|
84
|
-
type:
|
|
110
|
+
type: MetadataEnums.transfer,
|
|
85
111
|
encodedData,
|
|
86
112
|
});
|
|
87
113
|
|
|
88
114
|
return single ? encodeMultipleActions(data) : data;
|
|
89
115
|
};
|
|
90
116
|
|
|
91
|
-
export const
|
|
117
|
+
export const encodeRejectionMetadata = (id: string, single = true) => {
|
|
92
118
|
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
93
|
-
actionMetadataTypes.
|
|
94
|
-
[
|
|
119
|
+
actionMetadataTypes.rejection,
|
|
120
|
+
[id]
|
|
95
121
|
);
|
|
96
122
|
|
|
97
123
|
const data = encodeMetadata({
|
|
98
|
-
type:
|
|
124
|
+
type: MetadataEnums.rejection,
|
|
99
125
|
encodedData,
|
|
100
126
|
});
|
|
101
127
|
|
|
@@ -118,7 +144,7 @@ export const encodeCrossTransferMetadata = (
|
|
|
118
144
|
);
|
|
119
145
|
|
|
120
146
|
const data = encodeMetadata({
|
|
121
|
-
type: "cross-transfer",
|
|
147
|
+
type: MetadataEnums["cross-transfer"],
|
|
122
148
|
encodedData,
|
|
123
149
|
});
|
|
124
150
|
|
|
@@ -135,7 +161,7 @@ export const encodeAuthMetadata = (
|
|
|
135
161
|
);
|
|
136
162
|
|
|
137
163
|
const data = encodeMetadata({
|
|
138
|
-
type:
|
|
164
|
+
type: MetadataEnums.auth,
|
|
139
165
|
encodedData,
|
|
140
166
|
});
|
|
141
167
|
|
|
@@ -144,13 +170,30 @@ export const encodeAuthMetadata = (
|
|
|
144
170
|
|
|
145
171
|
export const encodeDeployMetadata = (single = true) => {
|
|
146
172
|
const data = encodeMetadata({
|
|
147
|
-
type:
|
|
173
|
+
type: MetadataEnums.deploy,
|
|
148
174
|
encodedData: "0x",
|
|
149
175
|
});
|
|
150
176
|
|
|
151
177
|
return single ? encodeMultipleActions(data) : data;
|
|
152
178
|
};
|
|
153
179
|
|
|
180
|
+
export const encodeTransactionBuilderMetadata = (
|
|
181
|
+
actionCount: string,
|
|
182
|
+
single = true
|
|
183
|
+
) => {
|
|
184
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
185
|
+
actionMetadataTypes["transaction-builder"],
|
|
186
|
+
[actionCount]
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const data = encodeMetadata({
|
|
190
|
+
type: MetadataEnums["transaction-builder"],
|
|
191
|
+
encodedData,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return single ? encodeMultipleActions(data) : data;
|
|
195
|
+
};
|
|
196
|
+
|
|
154
197
|
export const encodeWCSignMetadata = (
|
|
155
198
|
params: SignMetadataProps,
|
|
156
199
|
single = true
|
|
@@ -161,7 +204,7 @@ export const encodeWCSignMetadata = (
|
|
|
161
204
|
);
|
|
162
205
|
|
|
163
206
|
const data = encodeMetadata({
|
|
164
|
-
type:
|
|
207
|
+
type: MetadataEnums.permit2,
|
|
165
208
|
encodedData,
|
|
166
209
|
});
|
|
167
210
|
|
|
@@ -178,7 +221,7 @@ export const encodeUpgradeMetadata = (
|
|
|
178
221
|
);
|
|
179
222
|
|
|
180
223
|
const data = encodeMetadata({
|
|
181
|
-
type:
|
|
224
|
+
type: MetadataEnums.upgrade,
|
|
182
225
|
encodedData,
|
|
183
226
|
});
|
|
184
227
|
|
|
@@ -202,7 +245,7 @@ export const encodeSwapMetadata = (
|
|
|
202
245
|
);
|
|
203
246
|
|
|
204
247
|
const data = encodeMetadata({
|
|
205
|
-
type:
|
|
248
|
+
type: MetadataEnums.swap,
|
|
206
249
|
encodedData,
|
|
207
250
|
});
|
|
208
251
|
|
|
@@ -218,10 +261,8 @@ export const encodeTopupMetadata = (
|
|
|
218
261
|
[params.amount, params.token, params.onBehalf]
|
|
219
262
|
);
|
|
220
263
|
|
|
221
|
-
console.log(params);
|
|
222
|
-
|
|
223
264
|
const data = encodeMetadata({
|
|
224
|
-
type: "gas-topup",
|
|
265
|
+
type: MetadataEnums["gas-topup"],
|
|
225
266
|
encodedData,
|
|
226
267
|
});
|
|
227
268
|
|
|
@@ -246,7 +287,76 @@ export const encodeBridgeMetadata = (
|
|
|
246
287
|
);
|
|
247
288
|
|
|
248
289
|
const data = encodeMetadata({
|
|
249
|
-
type:
|
|
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"],
|
|
250
360
|
encodedData,
|
|
251
361
|
});
|
|
252
362
|
|
|
@@ -276,8 +386,10 @@ export const decodeMetadata = (metadata: string) => {
|
|
|
276
386
|
}
|
|
277
387
|
};
|
|
278
388
|
|
|
389
|
+
const iface = Forwarder__factory.createInterface();
|
|
390
|
+
const ifaceMultisig = MultisigForwarder__factory.createInterface();
|
|
391
|
+
|
|
279
392
|
const getMetadataFromData = (data: string) => {
|
|
280
|
-
const iface = Forwarder__factory.createInterface();
|
|
281
393
|
let metadata = "0x";
|
|
282
394
|
|
|
283
395
|
if (data.startsWith("0x18e7f485")) {
|
|
@@ -297,37 +409,122 @@ const getMetadataFromData = (data: string) => {
|
|
|
297
409
|
} else {
|
|
298
410
|
metadata = executeDataV2.params_.metadata;
|
|
299
411
|
}
|
|
300
|
-
} else if (data.startsWith("0x85114d53")) {
|
|
301
|
-
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
302
|
-
if (
|
|
303
|
-
executeDataV3.params_.metadata === "0x" ||
|
|
304
|
-
!executeDataV3.params_.metadata
|
|
305
|
-
) {
|
|
306
|
-
return null;
|
|
307
|
-
} else {
|
|
308
|
-
metadata = executeDataV3.params_.metadata;
|
|
309
|
-
}
|
|
310
412
|
} else {
|
|
311
|
-
const
|
|
312
|
-
"
|
|
413
|
+
const executeDataMultisig = ifaceMultisig.decodeFunctionData(
|
|
414
|
+
"executeV1",
|
|
313
415
|
data
|
|
314
416
|
);
|
|
315
417
|
if (
|
|
316
|
-
|
|
317
|
-
!
|
|
418
|
+
executeDataMultisig.params_.metadata === "0x" ||
|
|
419
|
+
!executeDataMultisig.params_.metadata
|
|
318
420
|
) {
|
|
319
421
|
return null;
|
|
320
422
|
} else {
|
|
321
|
-
metadata =
|
|
423
|
+
metadata = executeDataMultisig.params_.metadata;
|
|
322
424
|
}
|
|
323
425
|
}
|
|
324
426
|
|
|
325
427
|
return metadata;
|
|
326
428
|
};
|
|
327
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
|
+
"transaction-builder": (data, type) => ({
|
|
480
|
+
type,
|
|
481
|
+
actionCount: data.actionCount ? toBN(data.actionCount).toNumber() : 0,
|
|
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
|
+
|
|
328
526
|
const parseMetadata = (metadata: string) => {
|
|
329
527
|
const metadataArr = [];
|
|
330
|
-
let payload = {};
|
|
331
528
|
|
|
332
529
|
const [decodedMultiMetadata = []] =
|
|
333
530
|
(ethers.utils.defaultAbiCoder.decode(
|
|
@@ -350,116 +547,12 @@ const parseMetadata = (metadata: string) => {
|
|
|
350
547
|
decodedMetadata.data
|
|
351
548
|
);
|
|
352
549
|
|
|
353
|
-
|
|
354
|
-
case "transfer":
|
|
355
|
-
payload = {
|
|
356
|
-
type,
|
|
357
|
-
token: decodedData.token,
|
|
358
|
-
amount: toBN(decodedData.amount).toFixed(),
|
|
359
|
-
receiver: decodedData.receiver,
|
|
360
|
-
};
|
|
361
|
-
break;
|
|
362
|
-
case "bridge":
|
|
363
|
-
payload = {
|
|
364
|
-
type,
|
|
365
|
-
amount: toBN(decodedData.amount).toFixed(),
|
|
366
|
-
receiver: decodedData.receiver,
|
|
367
|
-
toToken: decodedData.toToken,
|
|
368
|
-
fromToken: decodedData.fromToken,
|
|
369
|
-
toChainId: decodedData.toChainId
|
|
370
|
-
? decodedData.toChainId.toString()
|
|
371
|
-
: null,
|
|
372
|
-
bridgeFee: toBN(decodedData.bridgeFee).toFixed(),
|
|
373
|
-
};
|
|
374
|
-
break;
|
|
375
|
-
case "swap":
|
|
376
|
-
payload = {
|
|
377
|
-
type,
|
|
378
|
-
buyAmount: toBN(decodedData.buyAmount).toFixed(),
|
|
379
|
-
sellAmount: toBN(decodedData.sellAmount).toFixed(),
|
|
380
|
-
buyToken: decodedData.buyToken,
|
|
381
|
-
sellToken: decodedData.sellToken,
|
|
382
|
-
receiver: decodedData.receiver,
|
|
383
|
-
protocol: utils.parseBytes32String(decodedData?.protocol || ""),
|
|
384
|
-
};
|
|
385
|
-
break;
|
|
386
|
-
case "upgrade":
|
|
387
|
-
payload = {
|
|
388
|
-
type,
|
|
389
|
-
version: utils.parseBytes32String(decodedData?.version || ""),
|
|
390
|
-
walletImpl: decodedData?.walletImpl,
|
|
391
|
-
};
|
|
392
|
-
break;
|
|
393
|
-
case "gas-topup":
|
|
394
|
-
payload = {
|
|
395
|
-
type,
|
|
396
|
-
amount: toBN(decodedData.amount).toFixed(),
|
|
397
|
-
token: decodedData.token,
|
|
398
|
-
onBehalf: decodedData.onBehalf,
|
|
399
|
-
};
|
|
400
|
-
break;
|
|
401
|
-
case "dapp":
|
|
402
|
-
payload = {
|
|
403
|
-
type,
|
|
404
|
-
name: decodedData?.name,
|
|
405
|
-
url: decodedData?.url,
|
|
406
|
-
};
|
|
407
|
-
break;
|
|
408
|
-
case "deploy":
|
|
409
|
-
payload = {
|
|
410
|
-
type,
|
|
411
|
-
};
|
|
412
|
-
break;
|
|
413
|
-
|
|
414
|
-
case "permit2":
|
|
415
|
-
payload = {
|
|
416
|
-
type,
|
|
417
|
-
token: decodedData.token,
|
|
418
|
-
spender: decodedData.spender,
|
|
419
|
-
amount: toBN(decodedData.amount).toFixed(),
|
|
420
|
-
expiration: decodedData.expiration,
|
|
421
|
-
};
|
|
422
|
-
break;
|
|
423
|
-
|
|
424
|
-
case "cross-transfer":
|
|
425
|
-
payload = {
|
|
426
|
-
type,
|
|
427
|
-
fromToken: decodedData.fromToken,
|
|
428
|
-
toToken: decodedData.toToken,
|
|
429
|
-
toChainId: decodedData.toChainId
|
|
430
|
-
? decodedData.toChainId.toString()
|
|
431
|
-
: null,
|
|
432
|
-
amount: toBN(decodedData.amount).toFixed(),
|
|
433
|
-
receiver: decodedData.receiver,
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
break;
|
|
437
|
-
case "auth":
|
|
438
|
-
payload = {
|
|
439
|
-
type: decodedData.remove ? "remove-authority" : "add-authority",
|
|
440
|
-
address: decodedData.address,
|
|
441
|
-
chainId: decodedData.chainId ? decodedData.chainId.toString() : null,
|
|
442
|
-
remove: decodedData.remove,
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
break;
|
|
446
|
-
case "instadapp-pro":
|
|
447
|
-
payload = {
|
|
448
|
-
type,
|
|
449
|
-
castDetails: decodedData.castDetails,
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
break;
|
|
453
|
-
|
|
454
|
-
case "reject":
|
|
455
|
-
payload = {
|
|
456
|
-
type,
|
|
457
|
-
reason: decodedData.reason,
|
|
458
|
-
};
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
550
|
+
const payloadFunc = typesPayload[type];
|
|
461
551
|
|
|
462
|
-
|
|
552
|
+
if (payloadFunc) {
|
|
553
|
+
const payload = payloadFunc(decodedData, type);
|
|
554
|
+
metadataArr.push(payload);
|
|
555
|
+
}
|
|
463
556
|
}
|
|
464
557
|
|
|
465
558
|
return metadataArr;
|