@instadapp/avocado-base 0.0.0-dev.9dbd5b5 → 0.0.0-dev.9df0ab2
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/multisigAgnosticForwarder.json +1 -0
- package/assets/images/icons/stars.svg +4 -0
- package/components/ActionLogo.vue +32 -30
- package/components/ActionMetadata.vue +28 -25
- package/components/AuthorityAvatar.vue +4 -5
- package/components/ChainLogo.vue +10 -17
- package/components/CopyClipboard.vue +5 -11
- package/components/metadata/CrossTransfer.vue +11 -3
- package/components/metadata/Signers.vue +26 -23
- package/components/metadata/Swap.vue +22 -29
- package/contracts/MultisigAgnosticForwarder.ts +1413 -0
- package/contracts/factories/MultisigAgnosticForwarder__factory.ts +2051 -0
- package/contracts/factories/index.ts +1 -0
- package/contracts/index.ts +2 -0
- package/package.json +10 -7
- package/utils/formatter.ts +1 -1
- package/utils/metadata.ts +134 -14
- package/utils/network.ts +254 -23
- package/utils/utils.d.ts +18 -3
|
@@ -6,4 +6,5 @@ export { BalanceResolver__factory } from "./BalanceResolver__factory";
|
|
|
6
6
|
export { Erc20__factory } from "./Erc20__factory";
|
|
7
7
|
export { Forwarder__factory } from "./Forwarder__factory";
|
|
8
8
|
export { GaslessWallet__factory } from "./GaslessWallet__factory";
|
|
9
|
+
export { MultisigAgnosticForwarder__factory } from "./MultisigAgnosticForwarder__factory";
|
|
9
10
|
export { MultisigForwarder__factory } from "./MultisigForwarder__factory";
|
package/contracts/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ 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 { MultisigAgnosticForwarder } from "./MultisigAgnosticForwarder";
|
|
9
10
|
export type { MultisigForwarder } from "./MultisigForwarder";
|
|
10
11
|
export * as factories from "./factories";
|
|
11
12
|
export { AvoFactoryProxy__factory } from "./factories/AvoFactoryProxy__factory";
|
|
@@ -13,4 +14,5 @@ export { BalanceResolver__factory } from "./factories/BalanceResolver__factory";
|
|
|
13
14
|
export { Erc20__factory } from "./factories/Erc20__factory";
|
|
14
15
|
export { Forwarder__factory } from "./factories/Forwarder__factory";
|
|
15
16
|
export { GaslessWallet__factory } from "./factories/GaslessWallet__factory";
|
|
17
|
+
export { MultisigAgnosticForwarder__factory } from "./factories/MultisigAgnosticForwarder__factory";
|
|
16
18
|
export { MultisigForwarder__factory } from "./factories/MultisigForwarder__factory";
|
package/package.json
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instadapp/avocado-base",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.9df0ab2",
|
|
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
25
|
"unplugin-vue-components": "^0.25.1",
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
"@vueuse/nuxt": "^10.2.0",
|
|
28
30
|
"bignumber.js": "^9.1.1",
|
|
29
31
|
"ethers": "^5.7.2",
|
|
32
|
+
"viem": "^2.10.5",
|
|
30
33
|
"xxhashjs": "^0.2.2"
|
|
31
34
|
}
|
|
32
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;
|
package/utils/metadata.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ethers, utils } from "ethers";
|
|
2
|
-
import { Forwarder__factory, MultisigForwarder__factory } from "../contracts";
|
|
2
|
+
import { Forwarder__factory, MultisigForwarder__factory, MultisigAgnosticForwarder__factory } from "../contracts";
|
|
3
3
|
import { toBN } from "./bignumber";
|
|
4
4
|
|
|
5
5
|
export const MetadataEnums = {
|
|
6
6
|
transfer: "transfer",
|
|
7
7
|
bridge: "bridge",
|
|
8
|
+
'bridge-v2': 'bridge-v2',
|
|
8
9
|
swap: "swap",
|
|
9
10
|
"gas-topup": "gas-topup",
|
|
10
11
|
upgrade: "upgrade",
|
|
@@ -12,6 +13,7 @@ export const MetadataEnums = {
|
|
|
12
13
|
deploy: "deploy",
|
|
13
14
|
permit2: "permit2",
|
|
14
15
|
"cross-transfer": "cross-transfer",
|
|
16
|
+
'cross-transfer-v2': 'cross-transfer-v2',
|
|
15
17
|
auth: "auth",
|
|
16
18
|
rejection: "rejection",
|
|
17
19
|
"instadapp-pro": "instadapp-pro",
|
|
@@ -19,7 +21,9 @@ export const MetadataEnums = {
|
|
|
19
21
|
"remove-signers": "remove-signers",
|
|
20
22
|
"change-threshold": "change-threshold",
|
|
21
23
|
import: "import",
|
|
22
|
-
|
|
24
|
+
mass: "mass",
|
|
25
|
+
"tx-builder": "tx-builder",
|
|
26
|
+
"avocado-bridge": "avocado-bridge",
|
|
23
27
|
} as const;
|
|
24
28
|
|
|
25
29
|
const multiMetadataTypes = ["bytes[]"];
|
|
@@ -35,6 +39,14 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
35
39
|
"uint256 amount",
|
|
36
40
|
"address receiver",
|
|
37
41
|
],
|
|
42
|
+
"cross-transfer-v2": [
|
|
43
|
+
"address fromToken",
|
|
44
|
+
"address toToken",
|
|
45
|
+
"uint256 toChainId",
|
|
46
|
+
"uint256 amount",
|
|
47
|
+
"address receiver",
|
|
48
|
+
"bytes32 provider",
|
|
49
|
+
],
|
|
38
50
|
bridge: [
|
|
39
51
|
"uint256 amount",
|
|
40
52
|
"address receiver",
|
|
@@ -44,6 +56,16 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
44
56
|
"uint256 bridgeFee",
|
|
45
57
|
"address nativeToken",
|
|
46
58
|
],
|
|
59
|
+
'bridge-v2': [
|
|
60
|
+
"uint256 amount",
|
|
61
|
+
"address receiver",
|
|
62
|
+
"address fromToken",
|
|
63
|
+
"address toToken",
|
|
64
|
+
"uint256 toChainId",
|
|
65
|
+
"uint256 bridgeFee",
|
|
66
|
+
"address nativeToken",
|
|
67
|
+
"bytes32 provider",
|
|
68
|
+
],
|
|
47
69
|
swap: [
|
|
48
70
|
"address sellToken",
|
|
49
71
|
"address buyToken",
|
|
@@ -58,7 +80,7 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
58
80
|
import: ["bytes32 protocol", "uint256 valueInUsd"],
|
|
59
81
|
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
60
82
|
deploy: [],
|
|
61
|
-
"
|
|
83
|
+
"tx-builder": ["bytes32 actionCount"],
|
|
62
84
|
permit2: [
|
|
63
85
|
"address token",
|
|
64
86
|
"address spender",
|
|
@@ -70,6 +92,8 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
70
92
|
"remove-signers": ["address[] signers"],
|
|
71
93
|
"change-threshold": ["uint8 count"],
|
|
72
94
|
rejection: ["bytes32 id"],
|
|
95
|
+
"avocado-bridge": ["bytes32 id", "uint256 toChainId"],
|
|
96
|
+
mass: ["bool isMass"],
|
|
73
97
|
};
|
|
74
98
|
|
|
75
99
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -97,6 +121,24 @@ export const encodeDappMetadata = (
|
|
|
97
121
|
return single ? encodeMultipleActions(data) : data;
|
|
98
122
|
};
|
|
99
123
|
|
|
124
|
+
export const encodeAvocadoBridgeMetadata = (
|
|
125
|
+
id: string,
|
|
126
|
+
toChainId: string | number,
|
|
127
|
+
single = true
|
|
128
|
+
) => {
|
|
129
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
130
|
+
actionMetadataTypes["avocado-bridge"],
|
|
131
|
+
[id, toChainId]
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const data = encodeMetadata({
|
|
135
|
+
type: MetadataEnums["avocado-bridge"],
|
|
136
|
+
encodedData,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return single ? encodeMultipleActions(data) : data;
|
|
140
|
+
};
|
|
141
|
+
|
|
100
142
|
export const encodeTransferMetadata = (
|
|
101
143
|
params: SendMetadataProps,
|
|
102
144
|
single = true
|
|
@@ -132,8 +174,21 @@ export const encodeCrossTransferMetadata = (
|
|
|
132
174
|
params: CrossSendMetadataProps,
|
|
133
175
|
single = true
|
|
134
176
|
) => {
|
|
135
|
-
|
|
136
|
-
|
|
177
|
+
|
|
178
|
+
const type = params.provider ? MetadataEnums["cross-transfer-v2"] : MetadataEnums["cross-transfer"]
|
|
179
|
+
|
|
180
|
+
const encodedData = params.provider ? ethers.utils.defaultAbiCoder.encode(
|
|
181
|
+
actionMetadataTypes[type],
|
|
182
|
+
[
|
|
183
|
+
params.fromToken,
|
|
184
|
+
params.toToken,
|
|
185
|
+
params.toChainId,
|
|
186
|
+
params.amount,
|
|
187
|
+
params.receiver,
|
|
188
|
+
params.provider
|
|
189
|
+
]
|
|
190
|
+
) : ethers.utils.defaultAbiCoder.encode(
|
|
191
|
+
actionMetadataTypes[type],
|
|
137
192
|
[
|
|
138
193
|
params.fromToken,
|
|
139
194
|
params.toToken,
|
|
@@ -144,7 +199,7 @@ export const encodeCrossTransferMetadata = (
|
|
|
144
199
|
);
|
|
145
200
|
|
|
146
201
|
const data = encodeMetadata({
|
|
147
|
-
type: MetadataEnums[
|
|
202
|
+
type: MetadataEnums[type],
|
|
148
203
|
encodedData,
|
|
149
204
|
});
|
|
150
205
|
|
|
@@ -182,12 +237,12 @@ export const encodeTransactionBuilderMetadata = (
|
|
|
182
237
|
single = true
|
|
183
238
|
) => {
|
|
184
239
|
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
185
|
-
actionMetadataTypes["
|
|
240
|
+
actionMetadataTypes["tx-builder"],
|
|
186
241
|
[actionCount]
|
|
187
242
|
);
|
|
188
243
|
|
|
189
244
|
const data = encodeMetadata({
|
|
190
|
-
type: MetadataEnums["
|
|
245
|
+
type: MetadataEnums["tx-builder"],
|
|
191
246
|
encodedData,
|
|
192
247
|
});
|
|
193
248
|
|
|
@@ -273,7 +328,21 @@ export const encodeBridgeMetadata = (
|
|
|
273
328
|
params: BridgeMetadataProps,
|
|
274
329
|
single = true
|
|
275
330
|
) => {
|
|
276
|
-
const
|
|
331
|
+
const type = params.version === '2' ? MetadataEnums["bridge-v2"] : MetadataEnums.bridge
|
|
332
|
+
|
|
333
|
+
const encodedData = params.version === '2' ? ethers.utils.defaultAbiCoder.encode(
|
|
334
|
+
actionMetadataTypes["bridge-v2"],
|
|
335
|
+
[
|
|
336
|
+
params.amount,
|
|
337
|
+
params.receiver,
|
|
338
|
+
params.fromToken,
|
|
339
|
+
params.toToken,
|
|
340
|
+
params.toChainId,
|
|
341
|
+
params.bridgeFee,
|
|
342
|
+
params.nativeToken,
|
|
343
|
+
params.provider
|
|
344
|
+
]
|
|
345
|
+
): ethers.utils.defaultAbiCoder.encode(
|
|
277
346
|
actionMetadataTypes.bridge,
|
|
278
347
|
[
|
|
279
348
|
params.amount,
|
|
@@ -287,7 +356,7 @@ export const encodeBridgeMetadata = (
|
|
|
287
356
|
);
|
|
288
357
|
|
|
289
358
|
const data = encodeMetadata({
|
|
290
|
-
type
|
|
359
|
+
type,
|
|
291
360
|
encodedData,
|
|
292
361
|
});
|
|
293
362
|
|
|
@@ -346,6 +415,15 @@ export const encodeImportMetadata = (
|
|
|
346
415
|
return single ? encodeMultipleActions(data) : data;
|
|
347
416
|
};
|
|
348
417
|
|
|
418
|
+
export const encodeMassMetadata = (single = true) => {
|
|
419
|
+
const data = encodeMetadata({
|
|
420
|
+
type: MetadataEnums.mass,
|
|
421
|
+
encodedData: '0x',
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
return single ? encodeMultipleActions(data) : data;
|
|
425
|
+
}
|
|
426
|
+
|
|
349
427
|
export const encodeAddSignersMetadata = (
|
|
350
428
|
addresses: string[],
|
|
351
429
|
single = true
|
|
@@ -388,11 +466,21 @@ export const decodeMetadata = (metadata: string) => {
|
|
|
388
466
|
|
|
389
467
|
const iface = Forwarder__factory.createInterface();
|
|
390
468
|
const ifaceMultisig = MultisigForwarder__factory.createInterface();
|
|
469
|
+
const ifaceAgnostic = MultisigAgnosticForwarder__factory.createInterface();
|
|
391
470
|
|
|
392
471
|
const getMetadataFromData = (data: string) => {
|
|
393
472
|
let metadata = "0x";
|
|
394
473
|
|
|
395
|
-
|
|
474
|
+
|
|
475
|
+
if(data.startsWith('0xc5e15557')) {
|
|
476
|
+
const executeData = ifaceAgnostic.decodeFunctionData("executeChainAgnosticV1", data);
|
|
477
|
+
|
|
478
|
+
const metadata = executeData?.params_?.params?.metadata
|
|
479
|
+
|
|
480
|
+
return metadata === '0x' || !metadata ? null : metadata
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
else if (data.startsWith("0x18e7f485")) {
|
|
396
484
|
const executeData = iface.decodeFunctionData("execute", data);
|
|
397
485
|
if (executeData.metadata_ === "0x" || !executeData.metadata_) {
|
|
398
486
|
return null;
|
|
@@ -448,6 +536,16 @@ const typesPayload: IPayload = {
|
|
|
448
536
|
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
449
537
|
bridgeFee: toBN(data.bridgeFee).toFixed(),
|
|
450
538
|
}),
|
|
539
|
+
'bridge-v2': (data, type) => ({
|
|
540
|
+
type: 'bridge',
|
|
541
|
+
amount: toBN(data.amount).toFixed(),
|
|
542
|
+
receiver: data.receiver,
|
|
543
|
+
toToken: data.toToken,
|
|
544
|
+
fromToken: data.fromToken,
|
|
545
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
546
|
+
bridgeFee: toBN(data.bridgeFee).toFixed(),
|
|
547
|
+
provider: utils.parseBytes32String(data.provider || ""),
|
|
548
|
+
}),
|
|
451
549
|
swap: (data, type) => ({
|
|
452
550
|
type,
|
|
453
551
|
buyAmount: toBN(data.buyAmount).toFixed(),
|
|
@@ -476,9 +574,9 @@ const typesPayload: IPayload = {
|
|
|
476
574
|
deploy: (data, type) => ({
|
|
477
575
|
type,
|
|
478
576
|
}),
|
|
479
|
-
"
|
|
577
|
+
"tx-builder": (data, type) => ({
|
|
480
578
|
type,
|
|
481
|
-
actionCount:
|
|
579
|
+
actionCount: utils.parseBytes32String(data.actionCount || ""),
|
|
482
580
|
}),
|
|
483
581
|
permit2: (data, type) => ({
|
|
484
582
|
type,
|
|
@@ -495,6 +593,15 @@ const typesPayload: IPayload = {
|
|
|
495
593
|
amount: toBN(data.amount).toFixed(),
|
|
496
594
|
receiver: data.receiver,
|
|
497
595
|
}),
|
|
596
|
+
"cross-transfer-v2": (data, type) => ({
|
|
597
|
+
type: 'cross-transfer',
|
|
598
|
+
fromToken: data.fromToken,
|
|
599
|
+
toToken: data.toToken,
|
|
600
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
601
|
+
amount: toBN(data.amount).toFixed(),
|
|
602
|
+
receiver: data.receiver,
|
|
603
|
+
provider: utils.parseBytes32String(data.provider || ""),
|
|
604
|
+
}),
|
|
498
605
|
auth: (data) => ({
|
|
499
606
|
type: data.remove ? "remove-authority" : "add-authority",
|
|
500
607
|
address: data.address,
|
|
@@ -521,6 +628,15 @@ const typesPayload: IPayload = {
|
|
|
521
628
|
type,
|
|
522
629
|
count: data.count,
|
|
523
630
|
}),
|
|
631
|
+
"avocado-bridge": (data, type) => ({
|
|
632
|
+
type,
|
|
633
|
+
id: data.id,
|
|
634
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
635
|
+
}),
|
|
636
|
+
mass: (data, type) => ({
|
|
637
|
+
type,
|
|
638
|
+
data,
|
|
639
|
+
}),
|
|
524
640
|
};
|
|
525
641
|
|
|
526
642
|
const parseMetadata = (metadata: string) => {
|
|
@@ -542,7 +658,7 @@ const parseMetadata = (metadata: string) => {
|
|
|
542
658
|
decodedMetadata.type
|
|
543
659
|
) as keyof typeof actionMetadataTypes;
|
|
544
660
|
|
|
545
|
-
const decodedData = ethers.utils.defaultAbiCoder.decode(
|
|
661
|
+
const decodedData = decodedMetadata?.data === '0x' ? '' : ethers.utils.defaultAbiCoder.decode(
|
|
546
662
|
actionMetadataTypes[type],
|
|
547
663
|
decodedMetadata.data
|
|
548
664
|
);
|
|
@@ -565,6 +681,10 @@ const parseMetadata = (metadata: string) => {
|
|
|
565
681
|
* @returns {string} - The modified sentence with hyphens replaced with spaces and the first letter of each word capitalized.
|
|
566
682
|
*/
|
|
567
683
|
export const formatTxType = (txType: string) => {
|
|
684
|
+
if(txType === 'mass') {
|
|
685
|
+
return 'Chain Agnostic Payments'
|
|
686
|
+
}
|
|
687
|
+
|
|
568
688
|
const finalSentence = txType
|
|
569
689
|
.replace("-", " ")
|
|
570
690
|
.replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
|