@instadapp/avocado-base 0.0.73 → 0.0.74
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/assets/images/icons/hammer.svg +5 -0
- package/components/ActionLogo.vue +2 -0
- package/components/ActionMetadata.vue +3 -0
- package/package.json +1 -1
- package/utils/metadata.ts +54 -35
- package/utils/network.ts +21 -21
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M16.0678 8.64793L17.2102 9.79039C17.4404 10.0205 17.4334 10.4006 17.1947 10.6393L14.169 13.6651C13.9302 13.9038 13.5501 13.9108 13.32 13.6806L12.0532 12.4139C11.8231 12.1837 11.83 11.8036 12.0687 11.5649C12.6078 11.0259 12.9103 10.7041 12.4882 9.98816C12.128 9.37711 10.7867 8.04387 9.9829 8.84766L9.026 9.80457C8.79152 10.0391 8.42065 10.0499 8.18946 9.83216C8.18527 9.82822 8.18113 9.8242 8.17704 9.82011C7.60427 9.24734 6.86936 8.69159 6.39943 8.03122C6.20623 7.75971 6.27917 7.35876 6.56293 7.14058C7.13082 6.70394 7.83604 6.05667 7.51626 5.73688C7.00756 5.22819 6.64232 4.84336 6.00502 4.36291C4.84749 3.49024 2.98873 2.86307 1.68669 2.5009C1.49898 2.44869 1.54877 2.11407 1.74553 2.11091C1.74865 2.11086 1.74938 2.1109 1.7525 2.11067C1.8512 2.10361 5.1158 1.87459 7.10771 2.35491C8.41273 2.66961 9.17363 2.87223 10.3122 3.56383C11.7706 4.44979 12.9611 5.54124 13.3465 6.69684C13.732 7.85244 12.8562 8.45813 13.6146 8.8618C14.0693 9.10386 14.6271 9.08774 15.0305 8.72253C15.3277 8.4534 15.7944 8.37456 16.0678 8.64793Z" fill="currentColor"/>
|
|
4
|
+
<path d="M8.17704 9.82011C8.18113 9.8242 8.18527 9.82822 8.18946 9.83216M8.17704 9.82011L8.18946 9.83216M8.17704 9.82011C7.60427 9.24734 6.86936 8.69159 6.39943 8.03122M8.18946 9.83216C8.42065 10.0499 8.79152 10.0391 9.026 9.80457L9.9829 8.84766C10.7867 8.04387 12.128 9.37711 12.4882 9.98816C12.9103 10.7041 12.6078 11.0259 12.0687 11.5649C11.83 11.8036 11.8231 12.1837 12.0532 12.4139L13.32 13.6806C13.5501 13.9108 13.9302 13.9038 14.169 13.6651L17.1947 10.6393C17.4334 10.4006 17.4404 10.0205 17.2102 9.79039L16.0678 8.64793C15.7944 8.37456 15.3277 8.4534 15.0305 8.72253C14.6271 9.08774 14.0693 9.10386 13.6146 8.8618C12.8562 8.45813 13.732 7.85244 13.3465 6.69684C12.9611 5.54124 11.7706 4.44979 10.3122 3.56383C9.17363 2.87223 8.41273 2.66961 7.10771 2.35492C5.1158 1.87459 1.8512 2.10361 1.7525 2.11067C1.74938 2.1109 1.74865 2.11086 1.74553 2.11091C1.54877 2.11407 1.49898 2.44869 1.68669 2.5009C2.98873 2.86307 4.84749 3.49024 6.00502 4.36291C6.64232 4.84336 7.00756 5.22819 7.51626 5.73688C7.83604 6.05667 7.13082 6.70394 6.56293 7.14058C6.27917 7.35876 6.20623 7.75971 6.39943 8.03122M8.18946 9.83216L2.8021 15.2195C2.47839 15.5432 1.97213 15.6105 1.60516 15.3369C1.46424 15.2318 1.32499 15.1183 1.2164 15.0097C1.1078 14.9011 0.994378 14.7619 0.889279 14.621C0.615587 14.254 0.682904 13.7477 1.00661 13.424L6.39943 8.03122" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
</svg>
|
|
@@ -13,6 +13,7 @@ import InstadappProSVG from '~/assets/images/icons/instadapp-pro.svg'
|
|
|
13
13
|
import PermitSignSVG from '~/assets/images/icons/permit-sign.svg'
|
|
14
14
|
import RejectProposalSVG from '~/assets/images/icons/reject-proposal.svg'
|
|
15
15
|
import UpgradeSVG from '~/assets/images/icons/upgrade.svg'
|
|
16
|
+
import HammerSVG from '~/assets/images/icons/hammer.svg'
|
|
16
17
|
|
|
17
18
|
defineProps<{
|
|
18
19
|
action: MetadataTypes
|
|
@@ -35,4 +36,5 @@ defineProps<{
|
|
|
35
36
|
<InstadappProSVG v-else-if="action === 'instadapp-pro'"/>
|
|
36
37
|
<PermitSignSVG v-else-if="action === 'permit2'"/>
|
|
37
38
|
<UpgradeSVG v-else-if="action === 'upgrade'"/>
|
|
39
|
+
<HammerSVG v-else-if="action === 'transaction-builder'"/>
|
|
38
40
|
</template>
|
|
@@ -53,6 +53,9 @@ provide('tokens', props.tokens);
|
|
|
53
53
|
{{ chainIdToName(metadata.chainId) }}
|
|
54
54
|
</div>
|
|
55
55
|
</div>
|
|
56
|
+
<div v-if="metadata.type === 'transaction-builder'" class="self-start capitalize flex gap-3">
|
|
57
|
+
Transaction Builder ({{ metadata?.actionCount }} actions)
|
|
58
|
+
</div>
|
|
56
59
|
<div v-if="metadata.type === 'instadapp-pro'" class="self-start capitalize flex gap-3">
|
|
57
60
|
Instadapp Pro |
|
|
58
61
|
{{ metadata?.castDetails }}
|
package/package.json
CHANGED
package/utils/metadata.ts
CHANGED
|
@@ -2,24 +2,25 @@ import { ethers, utils } from "ethers";
|
|
|
2
2
|
import { Forwarder__factory, MultisigForwarder__factory } from "../contracts";
|
|
3
3
|
import { toBN } from "./bignumber";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
|
23
24
|
|
|
24
25
|
const multiMetadataTypes = ["bytes[]"];
|
|
25
26
|
|
|
@@ -54,9 +55,10 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
54
55
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
55
56
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
56
57
|
dapp: ["string name", "string url"],
|
|
57
|
-
|
|
58
|
+
import: ["bytes32 protocol", "uint256 valueInUsd"],
|
|
58
59
|
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
59
60
|
deploy: [],
|
|
61
|
+
"transaction-builder": ["bytes32 actionCount"],
|
|
60
62
|
permit2: [
|
|
61
63
|
"address token",
|
|
62
64
|
"address spender",
|
|
@@ -64,10 +66,10 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
64
66
|
"uint48 expiration",
|
|
65
67
|
],
|
|
66
68
|
"instadapp-pro": ["string castDetails"],
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
"add-signers": ["address[] signers"],
|
|
70
|
+
"remove-signers": ["address[] signers"],
|
|
71
|
+
"change-threshold": ["uint8 count"],
|
|
72
|
+
rejection: ["bytes32 id"],
|
|
71
73
|
};
|
|
72
74
|
|
|
73
75
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -175,6 +177,23 @@ export const encodeDeployMetadata = (single = true) => {
|
|
|
175
177
|
return single ? encodeMultipleActions(data) : data;
|
|
176
178
|
};
|
|
177
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
|
+
|
|
178
197
|
export const encodeWCSignMetadata = (
|
|
179
198
|
params: SignMetadataProps,
|
|
180
199
|
single = true
|
|
@@ -408,7 +427,6 @@ const getMetadataFromData = (data: string) => {
|
|
|
408
427
|
return metadata;
|
|
409
428
|
};
|
|
410
429
|
|
|
411
|
-
|
|
412
430
|
const typesPayload: IPayload = {
|
|
413
431
|
import: (data, type) => ({
|
|
414
432
|
type,
|
|
@@ -450,15 +468,19 @@ const typesPayload: IPayload = {
|
|
|
450
468
|
token: data.token,
|
|
451
469
|
onBehalf: data.onBehalf,
|
|
452
470
|
}),
|
|
453
|
-
|
|
471
|
+
dapp: (data, type) => ({
|
|
454
472
|
type,
|
|
455
473
|
name: data.name,
|
|
456
474
|
url: data.url,
|
|
457
475
|
}),
|
|
458
|
-
|
|
476
|
+
deploy: (data, type) => ({
|
|
477
|
+
type,
|
|
478
|
+
}),
|
|
479
|
+
"transaction-builder": (data, type) => ({
|
|
459
480
|
type,
|
|
481
|
+
actionCount: data.actionCount ? toBN(data.actionCount).toNumber() : 0,
|
|
460
482
|
}),
|
|
461
|
-
|
|
483
|
+
permit2: (data, type) => ({
|
|
462
484
|
type,
|
|
463
485
|
token: data.token,
|
|
464
486
|
spender: data.spender,
|
|
@@ -473,7 +495,7 @@ const typesPayload: IPayload = {
|
|
|
473
495
|
amount: toBN(data.amount).toFixed(),
|
|
474
496
|
receiver: data.receiver,
|
|
475
497
|
}),
|
|
476
|
-
|
|
498
|
+
auth: (data) => ({
|
|
477
499
|
type: data.remove ? "remove-authority" : "add-authority",
|
|
478
500
|
address: data.address,
|
|
479
501
|
chainId: data.chainId ? data.chainId.toString() : null,
|
|
@@ -483,7 +505,7 @@ const typesPayload: IPayload = {
|
|
|
483
505
|
type,
|
|
484
506
|
castDetails: data.castDetails,
|
|
485
507
|
}),
|
|
486
|
-
|
|
508
|
+
rejection: (data, type) => ({
|
|
487
509
|
type,
|
|
488
510
|
id: data.id,
|
|
489
511
|
}),
|
|
@@ -525,20 +547,17 @@ const parseMetadata = (metadata: string) => {
|
|
|
525
547
|
decodedMetadata.data
|
|
526
548
|
);
|
|
527
549
|
|
|
528
|
-
const payloadFunc = typesPayload[type]
|
|
529
|
-
|
|
550
|
+
const payloadFunc = typesPayload[type];
|
|
551
|
+
|
|
530
552
|
if (payloadFunc) {
|
|
531
|
-
const payload = payloadFunc(decodedData, type)
|
|
553
|
+
const payload = payloadFunc(decodedData, type);
|
|
532
554
|
metadataArr.push(payload);
|
|
533
555
|
}
|
|
534
|
-
|
|
535
556
|
}
|
|
536
557
|
|
|
537
558
|
return metadataArr;
|
|
538
559
|
};
|
|
539
560
|
|
|
540
|
-
|
|
541
|
-
|
|
542
561
|
/**
|
|
543
562
|
* Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
|
|
544
563
|
* @param {string} txType - The input sentence to modify
|
package/utils/network.ts
CHANGED
|
@@ -269,27 +269,27 @@ export const networks: Network[] = [
|
|
|
269
269
|
},
|
|
270
270
|
},
|
|
271
271
|
},
|
|
272
|
-
{
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
},
|
|
272
|
+
// {
|
|
273
|
+
// name: "Fuse",
|
|
274
|
+
// chainId: 122,
|
|
275
|
+
// zerionName: "fuse",
|
|
276
|
+
// color: "#78d64b",
|
|
277
|
+
// explorerUrl: "https://explorer.fuse.io",
|
|
278
|
+
// get serverRpcUrl() {
|
|
279
|
+
// return process.env?.FUSE_RPC_URL || this.params.rpcUrls[0];
|
|
280
|
+
// },
|
|
281
|
+
// usdcAddress: "",
|
|
282
|
+
// balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
|
|
283
|
+
// params: {
|
|
284
|
+
// rpcUrls: ["https://fuse-mainnet.chainstacklabs.com"],
|
|
285
|
+
// chainName: "Fuse",
|
|
286
|
+
// nativeCurrency: {
|
|
287
|
+
// decimals: 18,
|
|
288
|
+
// name: "Fuse",
|
|
289
|
+
// symbol: "fuse",
|
|
290
|
+
// },
|
|
291
|
+
// },
|
|
292
|
+
// },
|
|
293
293
|
{
|
|
294
294
|
name: AVO_PROD_CHAIN_NAME,
|
|
295
295
|
chainId: AVO_PROD_CHAIN_ID,
|