@instadapp/avocado-base 0.0.0-dev.d36b11d → 0.0.0-dev.d695dce
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/forwarder.json +1253 -149
- package/contracts/Forwarder.ts +856 -2
- package/contracts/factories/Forwarder__factory.ts +816 -16
- package/package.json +1 -1
- package/utils/metadata.ts +49 -2
- package/utils/network.ts +2 -2
- package/utils/utils.d.ts +8 -1
package/package.json
CHANGED
package/utils/metadata.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers, utils } from "ethers";
|
|
2
|
-
import { Forwarder__factory } from "
|
|
2
|
+
import { Forwarder__factory } from "../contracts";
|
|
3
3
|
|
|
4
4
|
const multiMetadataTypes = ["bytes[]"];
|
|
5
5
|
|
|
@@ -34,6 +34,7 @@ const actionMetadataTypes = {
|
|
|
34
34
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
35
35
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
36
36
|
dapp: ["string name", "string url"],
|
|
37
|
+
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
37
38
|
deploy: [],
|
|
38
39
|
permit2: [
|
|
39
40
|
"address token",
|
|
@@ -41,6 +42,7 @@ const actionMetadataTypes = {
|
|
|
41
42
|
"uint160 amount",
|
|
42
43
|
"uint48 expiration",
|
|
43
44
|
],
|
|
45
|
+
castDetails: ["string castDetails"],
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -108,6 +110,23 @@ export const encodeCrossTransferMetadata = (
|
|
|
108
110
|
return single ? encodeMultipleActions(data) : data;
|
|
109
111
|
};
|
|
110
112
|
|
|
113
|
+
export const encodeAuthMetadata = (
|
|
114
|
+
params: AuthMetadataProps,
|
|
115
|
+
single = true
|
|
116
|
+
) => {
|
|
117
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
118
|
+
actionMetadataTypes["auth"],
|
|
119
|
+
[params.address, params.chainId, params.remove]
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const data = encodeMetadata({
|
|
123
|
+
type: "auth",
|
|
124
|
+
encodedData,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return single ? encodeMultipleActions(data) : data;
|
|
128
|
+
};
|
|
129
|
+
|
|
111
130
|
export const encodeDeployMetadata = (single = true) => {
|
|
112
131
|
const data = encodeMetadata({
|
|
113
132
|
type: "deploy",
|
|
@@ -238,7 +257,7 @@ export const decodeMetadata = (data: string) => {
|
|
|
238
257
|
} else {
|
|
239
258
|
metadata = executeData.metadata_;
|
|
240
259
|
}
|
|
241
|
-
} else {
|
|
260
|
+
} else if (data.startsWith("0x14f80a8d")) {
|
|
242
261
|
const executeDataV2 = iface.decodeFunctionData("executeV2", data);
|
|
243
262
|
if (
|
|
244
263
|
executeDataV2.params_.metadata === "0x" ||
|
|
@@ -248,6 +267,16 @@ export const decodeMetadata = (data: string) => {
|
|
|
248
267
|
} else {
|
|
249
268
|
metadata = executeDataV2.params_.metadata;
|
|
250
269
|
}
|
|
270
|
+
} else {
|
|
271
|
+
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
272
|
+
if (
|
|
273
|
+
executeDataV3.params_.metadata === "0x" ||
|
|
274
|
+
!executeDataV3.params_.metadata
|
|
275
|
+
) {
|
|
276
|
+
return null;
|
|
277
|
+
} else {
|
|
278
|
+
metadata = executeDataV3.params_.metadata;
|
|
279
|
+
}
|
|
251
280
|
}
|
|
252
281
|
|
|
253
282
|
const metadataArr = [];
|
|
@@ -356,6 +385,24 @@ export const decodeMetadata = (data: string) => {
|
|
|
356
385
|
receiver: decodedData.receiver,
|
|
357
386
|
};
|
|
358
387
|
|
|
388
|
+
break;
|
|
389
|
+
case "auth":
|
|
390
|
+
payload = {
|
|
391
|
+
type: decodedData.remove ? "remove-authority" : "add-authority",
|
|
392
|
+
address: decodedData.address,
|
|
393
|
+
chainId: decodedData.chainId
|
|
394
|
+
? decodedData.chainId.toString()
|
|
395
|
+
: null,
|
|
396
|
+
remove: decodedData.remove,
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
break;
|
|
400
|
+
case "castDetails":
|
|
401
|
+
payload = {
|
|
402
|
+
type,
|
|
403
|
+
castDetails: decodedData.castDetails,
|
|
404
|
+
};
|
|
405
|
+
|
|
359
406
|
break;
|
|
360
407
|
}
|
|
361
408
|
|
package/utils/network.ts
CHANGED
|
@@ -114,7 +114,7 @@ export const networks: Network[] = [
|
|
|
114
114
|
symbol: "AVAX",
|
|
115
115
|
decimals: 18,
|
|
116
116
|
},
|
|
117
|
-
rpcUrls: ["https://
|
|
117
|
+
rpcUrls: ["https://rpc.ankr.com/avalanche"],
|
|
118
118
|
},
|
|
119
119
|
},
|
|
120
120
|
{
|
|
@@ -174,7 +174,7 @@ export const networks: Network[] = [
|
|
|
174
174
|
},
|
|
175
175
|
params: {
|
|
176
176
|
chainName: "polygon zkEVM",
|
|
177
|
-
rpcUrls: ["https://rpc.
|
|
177
|
+
rpcUrls: ["https://zkevm-rpc.com"],
|
|
178
178
|
|
|
179
179
|
nativeCurrency: {
|
|
180
180
|
name: "Ethereum",
|
package/utils/utils.d.ts
CHANGED
|
@@ -64,6 +64,12 @@ type CrossSendMetadataProps = {
|
|
|
64
64
|
receiver: string;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
type AuthMetadataProps = {
|
|
68
|
+
address: string;
|
|
69
|
+
chainId: string;
|
|
70
|
+
remove: boolean;
|
|
71
|
+
};
|
|
72
|
+
|
|
67
73
|
type UpgradeMetadataProps = {
|
|
68
74
|
version: string;
|
|
69
75
|
walletImpl: string;
|
|
@@ -105,7 +111,8 @@ type MetadataProps = {
|
|
|
105
111
|
| "dapp"
|
|
106
112
|
| "deploy"
|
|
107
113
|
| "permit2"
|
|
108
|
-
| "cross-transfer"
|
|
114
|
+
| "cross-transfer"
|
|
115
|
+
| "auth";
|
|
109
116
|
encodedData: string;
|
|
110
117
|
version?: string;
|
|
111
118
|
};
|