@instadapp/avocado-base 0.0.69 → 0.0.70
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/package.json +1 -1
- package/utils/metadata.ts +25 -0
package/package.json
CHANGED
package/utils/metadata.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { toBN } from "./bignumber";
|
|
|
18
18
|
"add-signers": "add-signers",
|
|
19
19
|
"remove-signers": "remove-signers",
|
|
20
20
|
"change-threshold": "change-threshold",
|
|
21
|
+
"import": "import",
|
|
21
22
|
} as const;
|
|
22
23
|
|
|
23
24
|
const multiMetadataTypes = ["bytes[]"];
|
|
@@ -53,6 +54,7 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
|
53
54
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
54
55
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
55
56
|
dapp: ["string name", "string url"],
|
|
57
|
+
"import": ["bytes32 protocol", "uint256 valueInUsd"],
|
|
56
58
|
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
57
59
|
deploy: [],
|
|
58
60
|
permit2: [
|
|
@@ -307,6 +309,24 @@ export const encodeRemoveSignersMetadata = (
|
|
|
307
309
|
return single ? encodeMultipleActions(data) : data;
|
|
308
310
|
};
|
|
309
311
|
|
|
312
|
+
export const encodeImportMetadata = (
|
|
313
|
+
protocol: string,
|
|
314
|
+
valueInUsd: string,
|
|
315
|
+
single = true
|
|
316
|
+
) => {
|
|
317
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
318
|
+
actionMetadataTypes["import"],
|
|
319
|
+
[protocol, valueInUsd]
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const data = encodeMetadata({
|
|
323
|
+
type: MetadataEnums["import"],
|
|
324
|
+
encodedData,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
return single ? encodeMultipleActions(data) : data;
|
|
328
|
+
};
|
|
329
|
+
|
|
310
330
|
export const encodeAddSignersMetadata = (
|
|
311
331
|
addresses: string[],
|
|
312
332
|
single = true
|
|
@@ -390,6 +410,11 @@ const getMetadataFromData = (data: string) => {
|
|
|
390
410
|
|
|
391
411
|
|
|
392
412
|
const typesPayload: IPayload = {
|
|
413
|
+
import: (data, type) => ({
|
|
414
|
+
type,
|
|
415
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
416
|
+
valueInUsd: toBN(data.valueInUsd).toFixed(),
|
|
417
|
+
}),
|
|
393
418
|
transfer: (data, type) => ({
|
|
394
419
|
type,
|
|
395
420
|
token: data.token,
|