@instadapp/avocado-base 0.0.0-dev.d63c845 → 0.0.0-dev.d8050bd
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/assets/images/icons/hammer.svg +5 -0
- package/assets/images/icons/info-2.svg +12 -0
- package/components/ActionLogo.vue +2 -0
- package/components/ActionMetadata.vue +29 -24
- package/components/AuthorityAvatar.vue +38 -0
- package/components/ChainLogo.vue +14 -556
- 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 +63 -0
- package/components/metadata/Swap.vue +9 -2
- package/components/metadata/Transfer.vue +5 -1
- 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 +2 -2
- package/utils/helper.ts +2 -1
- package/utils/metadata.ts +113 -51
- package/utils/network.ts +224 -86
- package/utils/services.ts +8 -1
- package/utils/utils.d.ts +10 -6
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.d8050bd",
|
|
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
|
@@ -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)) {
|
|
@@ -84,7 +84,7 @@ export function formatDecimal(value: string | number, fractionDigits?: number) {
|
|
|
84
84
|
} else if (num.lt(100000)) {
|
|
85
85
|
decimals = 1;
|
|
86
86
|
} else {
|
|
87
|
-
decimals =
|
|
87
|
+
decimals = 0;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const formattedNumber = num.toFixed(fractionDigits || decimals);
|
package/utils/helper.ts
CHANGED
package/utils/metadata.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { ethers, utils } from "ethers";
|
|
2
|
-
import { Forwarder__factory } from "../contracts";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
"avocado-bridge": "avocado-bridge",
|
|
24
|
+
} as const;
|
|
21
25
|
|
|
22
26
|
const multiMetadataTypes = ["bytes[]"];
|
|
23
27
|
|
|
@@ -52,8 +56,10 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
52
56
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
53
57
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
54
58
|
dapp: ["string name", "string url"],
|
|
59
|
+
import: ["bytes32 protocol", "uint256 valueInUsd"],
|
|
55
60
|
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
56
61
|
deploy: [],
|
|
62
|
+
"tx-builder": ["bytes32 actionCount"],
|
|
57
63
|
permit2: [
|
|
58
64
|
"address token",
|
|
59
65
|
"address spender",
|
|
@@ -61,10 +67,11 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
61
67
|
"uint48 expiration",
|
|
62
68
|
],
|
|
63
69
|
"instadapp-pro": ["string castDetails"],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
"add-signers": ["address[] signers"],
|
|
71
|
+
"remove-signers": ["address[] signers"],
|
|
72
|
+
"change-threshold": ["uint8 count"],
|
|
73
|
+
rejection: ["bytes32 id"],
|
|
74
|
+
"avocado-bridge": ["bytes32 id", "uint256 toChainId"],
|
|
68
75
|
};
|
|
69
76
|
|
|
70
77
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -92,6 +99,24 @@ export const encodeDappMetadata = (
|
|
|
92
99
|
return single ? encodeMultipleActions(data) : data;
|
|
93
100
|
};
|
|
94
101
|
|
|
102
|
+
export const encodeAvocadoBridgeMetadata = (
|
|
103
|
+
id: string,
|
|
104
|
+
toChainId: string | number,
|
|
105
|
+
single = true
|
|
106
|
+
) => {
|
|
107
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
108
|
+
actionMetadataTypes["avocado-bridge"],
|
|
109
|
+
[id, toChainId]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const data = encodeMetadata({
|
|
113
|
+
type: MetadataEnums["avocado-bridge"],
|
|
114
|
+
encodedData,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return single ? encodeMultipleActions(data) : data;
|
|
118
|
+
};
|
|
119
|
+
|
|
95
120
|
export const encodeTransferMetadata = (
|
|
96
121
|
params: SendMetadataProps,
|
|
97
122
|
single = true
|
|
@@ -172,6 +197,23 @@ export const encodeDeployMetadata = (single = true) => {
|
|
|
172
197
|
return single ? encodeMultipleActions(data) : data;
|
|
173
198
|
};
|
|
174
199
|
|
|
200
|
+
export const encodeTransactionBuilderMetadata = (
|
|
201
|
+
actionCount: string,
|
|
202
|
+
single = true
|
|
203
|
+
) => {
|
|
204
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
205
|
+
actionMetadataTypes["tx-builder"],
|
|
206
|
+
[actionCount]
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const data = encodeMetadata({
|
|
210
|
+
type: MetadataEnums["tx-builder"],
|
|
211
|
+
encodedData,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
return single ? encodeMultipleActions(data) : data;
|
|
215
|
+
};
|
|
216
|
+
|
|
175
217
|
export const encodeWCSignMetadata = (
|
|
176
218
|
params: SignMetadataProps,
|
|
177
219
|
single = true
|
|
@@ -306,6 +348,24 @@ export const encodeRemoveSignersMetadata = (
|
|
|
306
348
|
return single ? encodeMultipleActions(data) : data;
|
|
307
349
|
};
|
|
308
350
|
|
|
351
|
+
export const encodeImportMetadata = (
|
|
352
|
+
protocol: string,
|
|
353
|
+
valueInUsd: string,
|
|
354
|
+
single = true
|
|
355
|
+
) => {
|
|
356
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
357
|
+
actionMetadataTypes["import"],
|
|
358
|
+
[protocol, valueInUsd]
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const data = encodeMetadata({
|
|
362
|
+
type: MetadataEnums["import"],
|
|
363
|
+
encodedData,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
return single ? encodeMultipleActions(data) : data;
|
|
367
|
+
};
|
|
368
|
+
|
|
309
369
|
export const encodeAddSignersMetadata = (
|
|
310
370
|
addresses: string[],
|
|
311
371
|
single = true
|
|
@@ -346,8 +406,10 @@ export const decodeMetadata = (metadata: string) => {
|
|
|
346
406
|
}
|
|
347
407
|
};
|
|
348
408
|
|
|
409
|
+
const iface = Forwarder__factory.createInterface();
|
|
410
|
+
const ifaceMultisig = MultisigForwarder__factory.createInterface();
|
|
411
|
+
|
|
349
412
|
const getMetadataFromData = (data: string) => {
|
|
350
|
-
const iface = Forwarder__factory.createInterface();
|
|
351
413
|
let metadata = "0x";
|
|
352
414
|
|
|
353
415
|
if (data.startsWith("0x18e7f485")) {
|
|
@@ -367,36 +429,30 @@ const getMetadataFromData = (data: string) => {
|
|
|
367
429
|
} else {
|
|
368
430
|
metadata = executeDataV2.params_.metadata;
|
|
369
431
|
}
|
|
370
|
-
} else if (data.startsWith("0x85114d53")) {
|
|
371
|
-
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
372
|
-
if (
|
|
373
|
-
executeDataV3.params_.metadata === "0x" ||
|
|
374
|
-
!executeDataV3.params_.metadata
|
|
375
|
-
) {
|
|
376
|
-
return null;
|
|
377
|
-
} else {
|
|
378
|
-
metadata = executeDataV3.params_.metadata;
|
|
379
|
-
}
|
|
380
432
|
} else {
|
|
381
|
-
const
|
|
382
|
-
"
|
|
433
|
+
const executeDataMultisig = ifaceMultisig.decodeFunctionData(
|
|
434
|
+
"executeV1",
|
|
383
435
|
data
|
|
384
436
|
);
|
|
385
437
|
if (
|
|
386
|
-
|
|
387
|
-
!
|
|
438
|
+
executeDataMultisig.params_.metadata === "0x" ||
|
|
439
|
+
!executeDataMultisig.params_.metadata
|
|
388
440
|
) {
|
|
389
441
|
return null;
|
|
390
442
|
} else {
|
|
391
|
-
metadata =
|
|
443
|
+
metadata = executeDataMultisig.params_.metadata;
|
|
392
444
|
}
|
|
393
445
|
}
|
|
394
446
|
|
|
395
447
|
return metadata;
|
|
396
448
|
};
|
|
397
449
|
|
|
398
|
-
|
|
399
450
|
const typesPayload: IPayload = {
|
|
451
|
+
import: (data, type) => ({
|
|
452
|
+
type,
|
|
453
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
454
|
+
valueInUsd: toBN(data.valueInUsd).toFixed(),
|
|
455
|
+
}),
|
|
400
456
|
transfer: (data, type) => ({
|
|
401
457
|
type,
|
|
402
458
|
token: data.token,
|
|
@@ -432,15 +488,19 @@ const typesPayload: IPayload = {
|
|
|
432
488
|
token: data.token,
|
|
433
489
|
onBehalf: data.onBehalf,
|
|
434
490
|
}),
|
|
435
|
-
|
|
491
|
+
dapp: (data, type) => ({
|
|
436
492
|
type,
|
|
437
493
|
name: data.name,
|
|
438
494
|
url: data.url,
|
|
439
495
|
}),
|
|
440
|
-
|
|
496
|
+
deploy: (data, type) => ({
|
|
441
497
|
type,
|
|
442
498
|
}),
|
|
443
|
-
"
|
|
499
|
+
"tx-builder": (data, type) => ({
|
|
500
|
+
type,
|
|
501
|
+
actionCount: utils.parseBytes32String(data.actionCount || ""),
|
|
502
|
+
}),
|
|
503
|
+
permit2: (data, type) => ({
|
|
444
504
|
type,
|
|
445
505
|
token: data.token,
|
|
446
506
|
spender: data.spender,
|
|
@@ -455,7 +515,7 @@ const typesPayload: IPayload = {
|
|
|
455
515
|
amount: toBN(data.amount).toFixed(),
|
|
456
516
|
receiver: data.receiver,
|
|
457
517
|
}),
|
|
458
|
-
|
|
518
|
+
auth: (data) => ({
|
|
459
519
|
type: data.remove ? "remove-authority" : "add-authority",
|
|
460
520
|
address: data.address,
|
|
461
521
|
chainId: data.chainId ? data.chainId.toString() : null,
|
|
@@ -465,7 +525,7 @@ const typesPayload: IPayload = {
|
|
|
465
525
|
type,
|
|
466
526
|
castDetails: data.castDetails,
|
|
467
527
|
}),
|
|
468
|
-
|
|
528
|
+
rejection: (data, type) => ({
|
|
469
529
|
type,
|
|
470
530
|
id: data.id,
|
|
471
531
|
}),
|
|
@@ -481,6 +541,11 @@ const typesPayload: IPayload = {
|
|
|
481
541
|
type,
|
|
482
542
|
count: data.count,
|
|
483
543
|
}),
|
|
544
|
+
"avocado-bridge": (data, type) => ({
|
|
545
|
+
type,
|
|
546
|
+
id: data.id,
|
|
547
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
548
|
+
}),
|
|
484
549
|
};
|
|
485
550
|
|
|
486
551
|
const parseMetadata = (metadata: string) => {
|
|
@@ -507,20 +572,17 @@ const parseMetadata = (metadata: string) => {
|
|
|
507
572
|
decodedMetadata.data
|
|
508
573
|
);
|
|
509
574
|
|
|
510
|
-
const payloadFunc = typesPayload[type]
|
|
511
|
-
|
|
575
|
+
const payloadFunc = typesPayload[type];
|
|
576
|
+
|
|
512
577
|
if (payloadFunc) {
|
|
513
|
-
const payload = payloadFunc(decodedData, type)
|
|
578
|
+
const payload = payloadFunc(decodedData, type);
|
|
514
579
|
metadataArr.push(payload);
|
|
515
580
|
}
|
|
516
|
-
|
|
517
581
|
}
|
|
518
582
|
|
|
519
583
|
return metadataArr;
|
|
520
584
|
};
|
|
521
585
|
|
|
522
|
-
|
|
523
|
-
|
|
524
586
|
/**
|
|
525
587
|
* Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
|
|
526
588
|
* @param {string} txType - The input sentence to modify
|