@instadapp/avocado-base 0.0.0-dev.9853aa2 → 0.0.0-dev.9d62a67
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/.github/workflows/npm-publish-dev.yml +2 -5
- 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 +45 -16
- package/components/AuthorityAvatar.vue +37 -0
- package/components/ChainLogo.vue +14 -563
- package/components/CopyClipboard.vue +58 -0
- package/components/metadata/Bridge.vue +26 -6
- package/components/metadata/CrossTransfer.vue +16 -4
- package/components/metadata/GasTopup.vue +7 -1
- package/components/metadata/Permit2.vue +6 -1
- package/components/metadata/Signers.vue +66 -0
- package/components/metadata/Swap.vue +25 -25
- 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 +14 -9
- package/utils/formatter.ts +2 -2
- package/utils/helper.ts +8 -0
- package/utils/metadata.ts +277 -145
- package/utils/network.ts +335 -74
- package/utils/services.ts +8 -1
- package/utils/utils.d.ts +136 -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,30 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instadapp/avocado-base",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.9d62a67",
|
|
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
|
-
"@
|
|
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.
|
|
20
|
-
"nuxt-svgo": "^
|
|
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.7.16",
|
|
33
|
+
"xxhashjs": "^0.2.2"
|
|
29
34
|
}
|
|
30
35
|
}
|
package/utils/formatter.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function formatPercent(
|
|
|
19
19
|
return formatter.format(valueAsNumber);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function shortenHash(hash: string
|
|
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 =
|
|
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,34 @@
|
|
|
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
|
+
mass: "mass",
|
|
23
|
+
"tx-builder": "tx-builder",
|
|
24
|
+
"avocado-bridge": "avocado-bridge",
|
|
25
|
+
} as const;
|
|
3
26
|
|
|
4
27
|
const multiMetadataTypes = ["bytes[]"];
|
|
5
28
|
|
|
6
29
|
const metadataTypes = ["bytes32 type", "uint8 version", "bytes data"];
|
|
7
30
|
|
|
8
|
-
const actionMetadataTypes = {
|
|
31
|
+
const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
9
32
|
transfer: ["address token", "uint256 amount", "address receiver"],
|
|
10
33
|
"cross-transfer": [
|
|
11
34
|
"address fromToken",
|
|
@@ -34,8 +57,10 @@ const actionMetadataTypes = {
|
|
|
34
57
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
35
58
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
36
59
|
dapp: ["string name", "string url"],
|
|
60
|
+
import: ["bytes32 protocol", "uint256 valueInUsd"],
|
|
37
61
|
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
38
62
|
deploy: [],
|
|
63
|
+
"tx-builder": ["bytes32 actionCount"],
|
|
39
64
|
permit2: [
|
|
40
65
|
"address token",
|
|
41
66
|
"address spender",
|
|
@@ -43,7 +68,12 @@ const actionMetadataTypes = {
|
|
|
43
68
|
"uint48 expiration",
|
|
44
69
|
],
|
|
45
70
|
"instadapp-pro": ["string castDetails"],
|
|
46
|
-
|
|
71
|
+
"add-signers": ["address[] signers"],
|
|
72
|
+
"remove-signers": ["address[] signers"],
|
|
73
|
+
"change-threshold": ["uint8 count"],
|
|
74
|
+
rejection: ["bytes32 id"],
|
|
75
|
+
"avocado-bridge": ["bytes32 id", "uint256 toChainId"],
|
|
76
|
+
mass: ["bool isMass"],
|
|
47
77
|
};
|
|
48
78
|
|
|
49
79
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -64,7 +94,25 @@ export const encodeDappMetadata = (
|
|
|
64
94
|
);
|
|
65
95
|
|
|
66
96
|
const data = encodeMetadata({
|
|
67
|
-
type:
|
|
97
|
+
type: MetadataEnums.dapp,
|
|
98
|
+
encodedData,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return single ? encodeMultipleActions(data) : data;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const encodeAvocadoBridgeMetadata = (
|
|
105
|
+
id: string,
|
|
106
|
+
toChainId: string | number,
|
|
107
|
+
single = true
|
|
108
|
+
) => {
|
|
109
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
110
|
+
actionMetadataTypes["avocado-bridge"],
|
|
111
|
+
[id, toChainId]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const data = encodeMetadata({
|
|
115
|
+
type: MetadataEnums["avocado-bridge"],
|
|
68
116
|
encodedData,
|
|
69
117
|
});
|
|
70
118
|
|
|
@@ -81,21 +129,21 @@ export const encodeTransferMetadata = (
|
|
|
81
129
|
);
|
|
82
130
|
|
|
83
131
|
const data = encodeMetadata({
|
|
84
|
-
type:
|
|
132
|
+
type: MetadataEnums.transfer,
|
|
85
133
|
encodedData,
|
|
86
134
|
});
|
|
87
135
|
|
|
88
136
|
return single ? encodeMultipleActions(data) : data;
|
|
89
137
|
};
|
|
90
138
|
|
|
91
|
-
export const
|
|
139
|
+
export const encodeRejectionMetadata = (id: string, single = true) => {
|
|
92
140
|
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
93
|
-
actionMetadataTypes.
|
|
94
|
-
[
|
|
141
|
+
actionMetadataTypes.rejection,
|
|
142
|
+
[id]
|
|
95
143
|
);
|
|
96
144
|
|
|
97
145
|
const data = encodeMetadata({
|
|
98
|
-
type:
|
|
146
|
+
type: MetadataEnums.rejection,
|
|
99
147
|
encodedData,
|
|
100
148
|
});
|
|
101
149
|
|
|
@@ -118,7 +166,7 @@ export const encodeCrossTransferMetadata = (
|
|
|
118
166
|
);
|
|
119
167
|
|
|
120
168
|
const data = encodeMetadata({
|
|
121
|
-
type: "cross-transfer",
|
|
169
|
+
type: MetadataEnums["cross-transfer"],
|
|
122
170
|
encodedData,
|
|
123
171
|
});
|
|
124
172
|
|
|
@@ -135,7 +183,7 @@ export const encodeAuthMetadata = (
|
|
|
135
183
|
);
|
|
136
184
|
|
|
137
185
|
const data = encodeMetadata({
|
|
138
|
-
type:
|
|
186
|
+
type: MetadataEnums.auth,
|
|
139
187
|
encodedData,
|
|
140
188
|
});
|
|
141
189
|
|
|
@@ -144,13 +192,30 @@ export const encodeAuthMetadata = (
|
|
|
144
192
|
|
|
145
193
|
export const encodeDeployMetadata = (single = true) => {
|
|
146
194
|
const data = encodeMetadata({
|
|
147
|
-
type:
|
|
195
|
+
type: MetadataEnums.deploy,
|
|
148
196
|
encodedData: "0x",
|
|
149
197
|
});
|
|
150
198
|
|
|
151
199
|
return single ? encodeMultipleActions(data) : data;
|
|
152
200
|
};
|
|
153
201
|
|
|
202
|
+
export const encodeTransactionBuilderMetadata = (
|
|
203
|
+
actionCount: string,
|
|
204
|
+
single = true
|
|
205
|
+
) => {
|
|
206
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
207
|
+
actionMetadataTypes["tx-builder"],
|
|
208
|
+
[actionCount]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const data = encodeMetadata({
|
|
212
|
+
type: MetadataEnums["tx-builder"],
|
|
213
|
+
encodedData,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return single ? encodeMultipleActions(data) : data;
|
|
217
|
+
};
|
|
218
|
+
|
|
154
219
|
export const encodeWCSignMetadata = (
|
|
155
220
|
params: SignMetadataProps,
|
|
156
221
|
single = true
|
|
@@ -161,7 +226,7 @@ export const encodeWCSignMetadata = (
|
|
|
161
226
|
);
|
|
162
227
|
|
|
163
228
|
const data = encodeMetadata({
|
|
164
|
-
type:
|
|
229
|
+
type: MetadataEnums.permit2,
|
|
165
230
|
encodedData,
|
|
166
231
|
});
|
|
167
232
|
|
|
@@ -178,7 +243,7 @@ export const encodeUpgradeMetadata = (
|
|
|
178
243
|
);
|
|
179
244
|
|
|
180
245
|
const data = encodeMetadata({
|
|
181
|
-
type:
|
|
246
|
+
type: MetadataEnums.upgrade,
|
|
182
247
|
encodedData,
|
|
183
248
|
});
|
|
184
249
|
|
|
@@ -202,7 +267,7 @@ export const encodeSwapMetadata = (
|
|
|
202
267
|
);
|
|
203
268
|
|
|
204
269
|
const data = encodeMetadata({
|
|
205
|
-
type:
|
|
270
|
+
type: MetadataEnums.swap,
|
|
206
271
|
encodedData,
|
|
207
272
|
});
|
|
208
273
|
|
|
@@ -218,10 +283,8 @@ export const encodeTopupMetadata = (
|
|
|
218
283
|
[params.amount, params.token, params.onBehalf]
|
|
219
284
|
);
|
|
220
285
|
|
|
221
|
-
console.log(params);
|
|
222
|
-
|
|
223
286
|
const data = encodeMetadata({
|
|
224
|
-
type: "gas-topup",
|
|
287
|
+
type: MetadataEnums["gas-topup"],
|
|
225
288
|
encodedData,
|
|
226
289
|
});
|
|
227
290
|
|
|
@@ -246,7 +309,85 @@ export const encodeBridgeMetadata = (
|
|
|
246
309
|
);
|
|
247
310
|
|
|
248
311
|
const data = encodeMetadata({
|
|
249
|
-
type:
|
|
312
|
+
type: MetadataEnums.bridge,
|
|
313
|
+
encodedData,
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
return single ? encodeMultipleActions(data) : data;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export const encodeChangeThresholdMetadata = (
|
|
320
|
+
threshold: string | number,
|
|
321
|
+
single = true
|
|
322
|
+
) => {
|
|
323
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
324
|
+
actionMetadataTypes["change-threshold"],
|
|
325
|
+
[toBN(threshold).toNumber()]
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const data = encodeMetadata({
|
|
329
|
+
type: MetadataEnums["change-threshold"],
|
|
330
|
+
encodedData,
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
return single ? encodeMultipleActions(data) : data;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export const encodeRemoveSignersMetadata = (
|
|
337
|
+
addresses: string[],
|
|
338
|
+
single = true
|
|
339
|
+
) => {
|
|
340
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
341
|
+
actionMetadataTypes["remove-signers"],
|
|
342
|
+
[addresses]
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
const data = encodeMetadata({
|
|
346
|
+
type: MetadataEnums["remove-signers"],
|
|
347
|
+
encodedData,
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
return single ? encodeMultipleActions(data) : data;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
export const encodeImportMetadata = (
|
|
354
|
+
protocol: string,
|
|
355
|
+
valueInUsd: string,
|
|
356
|
+
single = true
|
|
357
|
+
) => {
|
|
358
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
359
|
+
actionMetadataTypes["import"],
|
|
360
|
+
[protocol, valueInUsd]
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
const data = encodeMetadata({
|
|
364
|
+
type: MetadataEnums["import"],
|
|
365
|
+
encodedData,
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
return single ? encodeMultipleActions(data) : data;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export const encodeMassMetadata = (single = true) => {
|
|
372
|
+
const data = encodeMetadata({
|
|
373
|
+
type: MetadataEnums.mass,
|
|
374
|
+
encodedData: '0x',
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
return single ? encodeMultipleActions(data) : data;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export const encodeAddSignersMetadata = (
|
|
381
|
+
addresses: string[],
|
|
382
|
+
single = true
|
|
383
|
+
) => {
|
|
384
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
385
|
+
actionMetadataTypes["add-signers"],
|
|
386
|
+
[addresses]
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
const data = encodeMetadata({
|
|
390
|
+
type: MetadataEnums["add-signers"],
|
|
250
391
|
encodedData,
|
|
251
392
|
});
|
|
252
393
|
|
|
@@ -276,8 +417,10 @@ export const decodeMetadata = (metadata: string) => {
|
|
|
276
417
|
}
|
|
277
418
|
};
|
|
278
419
|
|
|
420
|
+
const iface = Forwarder__factory.createInterface();
|
|
421
|
+
const ifaceMultisig = MultisigForwarder__factory.createInterface();
|
|
422
|
+
|
|
279
423
|
const getMetadataFromData = (data: string) => {
|
|
280
|
-
const iface = Forwarder__factory.createInterface();
|
|
281
424
|
let metadata = "0x";
|
|
282
425
|
|
|
283
426
|
if (data.startsWith("0x18e7f485")) {
|
|
@@ -297,37 +440,130 @@ const getMetadataFromData = (data: string) => {
|
|
|
297
440
|
} else {
|
|
298
441
|
metadata = executeDataV2.params_.metadata;
|
|
299
442
|
}
|
|
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
443
|
} else {
|
|
311
|
-
const
|
|
312
|
-
"
|
|
444
|
+
const executeDataMultisig = ifaceMultisig.decodeFunctionData(
|
|
445
|
+
"executeV1",
|
|
313
446
|
data
|
|
314
447
|
);
|
|
315
448
|
if (
|
|
316
|
-
|
|
317
|
-
!
|
|
449
|
+
executeDataMultisig.params_.metadata === "0x" ||
|
|
450
|
+
!executeDataMultisig.params_.metadata
|
|
318
451
|
) {
|
|
319
452
|
return null;
|
|
320
453
|
} else {
|
|
321
|
-
metadata =
|
|
454
|
+
metadata = executeDataMultisig.params_.metadata;
|
|
322
455
|
}
|
|
323
456
|
}
|
|
324
457
|
|
|
325
458
|
return metadata;
|
|
326
459
|
};
|
|
327
460
|
|
|
461
|
+
const typesPayload: IPayload = {
|
|
462
|
+
import: (data, type) => ({
|
|
463
|
+
type,
|
|
464
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
465
|
+
valueInUsd: toBN(data.valueInUsd).toFixed(),
|
|
466
|
+
}),
|
|
467
|
+
transfer: (data, type) => ({
|
|
468
|
+
type,
|
|
469
|
+
token: data.token,
|
|
470
|
+
amount: toBN(data.amount).toFixed(),
|
|
471
|
+
receiver: data.receiver,
|
|
472
|
+
}),
|
|
473
|
+
bridge: (data, type) => ({
|
|
474
|
+
type,
|
|
475
|
+
amount: toBN(data.amount).toFixed(),
|
|
476
|
+
receiver: data.receiver,
|
|
477
|
+
toToken: data.toToken,
|
|
478
|
+
fromToken: data.fromToken,
|
|
479
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
480
|
+
bridgeFee: toBN(data.bridgeFee).toFixed(),
|
|
481
|
+
}),
|
|
482
|
+
swap: (data, type) => ({
|
|
483
|
+
type,
|
|
484
|
+
buyAmount: toBN(data.buyAmount).toFixed(),
|
|
485
|
+
sellAmount: toBN(data.sellAmount).toFixed(),
|
|
486
|
+
buyToken: data.buyToken,
|
|
487
|
+
sellToken: data.sellToken,
|
|
488
|
+
receiver: data.receiver,
|
|
489
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
490
|
+
}),
|
|
491
|
+
upgrade: (data, type) => ({
|
|
492
|
+
type,
|
|
493
|
+
version: utils.parseBytes32String(data.version || ""),
|
|
494
|
+
walletImpl: data.walletImpl,
|
|
495
|
+
}),
|
|
496
|
+
"gas-topup": (data, type) => ({
|
|
497
|
+
type,
|
|
498
|
+
amount: toBN(data.amount).toFixed(),
|
|
499
|
+
token: data.token,
|
|
500
|
+
onBehalf: data.onBehalf,
|
|
501
|
+
}),
|
|
502
|
+
dapp: (data, type) => ({
|
|
503
|
+
type,
|
|
504
|
+
name: data.name,
|
|
505
|
+
url: data.url,
|
|
506
|
+
}),
|
|
507
|
+
deploy: (data, type) => ({
|
|
508
|
+
type,
|
|
509
|
+
}),
|
|
510
|
+
"tx-builder": (data, type) => ({
|
|
511
|
+
type,
|
|
512
|
+
actionCount: utils.parseBytes32String(data.actionCount || ""),
|
|
513
|
+
}),
|
|
514
|
+
permit2: (data, type) => ({
|
|
515
|
+
type,
|
|
516
|
+
token: data.token,
|
|
517
|
+
spender: data.spender,
|
|
518
|
+
amount: toBN(data.amount).toFixed(),
|
|
519
|
+
expiration: data.expiration,
|
|
520
|
+
}),
|
|
521
|
+
"cross-transfer": (data, type) => ({
|
|
522
|
+
type,
|
|
523
|
+
fromToken: data.fromToken,
|
|
524
|
+
toToken: data.toToken,
|
|
525
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
526
|
+
amount: toBN(data.amount).toFixed(),
|
|
527
|
+
receiver: data.receiver,
|
|
528
|
+
}),
|
|
529
|
+
auth: (data) => ({
|
|
530
|
+
type: data.remove ? "remove-authority" : "add-authority",
|
|
531
|
+
address: data.address,
|
|
532
|
+
chainId: data.chainId ? data.chainId.toString() : null,
|
|
533
|
+
remove: data.remove,
|
|
534
|
+
}),
|
|
535
|
+
"instadapp-pro": (data, type) => ({
|
|
536
|
+
type,
|
|
537
|
+
castDetails: data.castDetails,
|
|
538
|
+
}),
|
|
539
|
+
rejection: (data, type) => ({
|
|
540
|
+
type,
|
|
541
|
+
id: data.id,
|
|
542
|
+
}),
|
|
543
|
+
"add-signers": (data, type) => ({
|
|
544
|
+
type,
|
|
545
|
+
addresses: data.signers,
|
|
546
|
+
}),
|
|
547
|
+
"remove-signers": (data, type) => ({
|
|
548
|
+
type,
|
|
549
|
+
addresses: data.signers,
|
|
550
|
+
}),
|
|
551
|
+
"change-threshold": (data, type) => ({
|
|
552
|
+
type,
|
|
553
|
+
count: data.count,
|
|
554
|
+
}),
|
|
555
|
+
"avocado-bridge": (data, type) => ({
|
|
556
|
+
type,
|
|
557
|
+
id: data.id,
|
|
558
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
559
|
+
}),
|
|
560
|
+
mass: (data, type) => ({
|
|
561
|
+
type,
|
|
562
|
+
}),
|
|
563
|
+
};
|
|
564
|
+
|
|
328
565
|
const parseMetadata = (metadata: string) => {
|
|
329
566
|
const metadataArr = [];
|
|
330
|
-
let payload = {};
|
|
331
567
|
|
|
332
568
|
const [decodedMultiMetadata = []] =
|
|
333
569
|
(ethers.utils.defaultAbiCoder.decode(
|
|
@@ -350,116 +586,12 @@ const parseMetadata = (metadata: string) => {
|
|
|
350
586
|
decodedMetadata.data
|
|
351
587
|
);
|
|
352
588
|
|
|
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
|
-
}
|
|
589
|
+
const payloadFunc = typesPayload[type];
|
|
461
590
|
|
|
462
|
-
|
|
591
|
+
if (payloadFunc) {
|
|
592
|
+
const payload = payloadFunc(decodedData, type);
|
|
593
|
+
metadataArr.push(payload);
|
|
594
|
+
}
|
|
463
595
|
}
|
|
464
596
|
|
|
465
597
|
return metadataArr;
|