@instadapp/avocado-base 0.0.0-dev.e144f0f → 0.0.0-dev.f34fbf6
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 +64 -4
- package/utils/network.ts +32 -20
- package/utils/utils.d.ts +11 -2
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
|
|
|
@@ -10,6 +10,7 @@ const actionMetadataTypes = {
|
|
|
10
10
|
"cross-transfer": [
|
|
11
11
|
"address fromToken",
|
|
12
12
|
"address toToken",
|
|
13
|
+
"uint256 toChainId",
|
|
13
14
|
"uint256 amount",
|
|
14
15
|
"address receiver",
|
|
15
16
|
],
|
|
@@ -33,6 +34,7 @@ const actionMetadataTypes = {
|
|
|
33
34
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
34
35
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
35
36
|
dapp: ["string name", "string url"],
|
|
37
|
+
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
36
38
|
deploy: [],
|
|
37
39
|
permit2: [
|
|
38
40
|
"address token",
|
|
@@ -85,12 +87,18 @@ export const encodeTransferMetadata = (
|
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
export const encodeCrossTransferMetadata = (
|
|
88
|
-
params:
|
|
90
|
+
params: CrossSendMetadataProps,
|
|
89
91
|
single = true
|
|
90
92
|
) => {
|
|
91
93
|
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
92
94
|
actionMetadataTypes["cross-transfer"],
|
|
93
|
-
[
|
|
95
|
+
[
|
|
96
|
+
params.fromToken,
|
|
97
|
+
params.toToken,
|
|
98
|
+
params.toChainId,
|
|
99
|
+
params.amount,
|
|
100
|
+
params.receiver,
|
|
101
|
+
]
|
|
94
102
|
);
|
|
95
103
|
|
|
96
104
|
const data = encodeMetadata({
|
|
@@ -101,6 +109,23 @@ export const encodeCrossTransferMetadata = (
|
|
|
101
109
|
return single ? encodeMultipleActions(data) : data;
|
|
102
110
|
};
|
|
103
111
|
|
|
112
|
+
export const encodeAuthMetadata = (
|
|
113
|
+
params: AuthMetadataProps,
|
|
114
|
+
single = true
|
|
115
|
+
) => {
|
|
116
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
117
|
+
actionMetadataTypes["auth"],
|
|
118
|
+
[params.address, params.chainId, params.remove]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const data = encodeMetadata({
|
|
122
|
+
type: "auth",
|
|
123
|
+
encodedData,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return single ? encodeMultipleActions(data) : data;
|
|
127
|
+
};
|
|
128
|
+
|
|
104
129
|
export const encodeDeployMetadata = (single = true) => {
|
|
105
130
|
const data = encodeMetadata({
|
|
106
131
|
type: "deploy",
|
|
@@ -231,7 +256,7 @@ export const decodeMetadata = (data: string) => {
|
|
|
231
256
|
} else {
|
|
232
257
|
metadata = executeData.metadata_;
|
|
233
258
|
}
|
|
234
|
-
} else {
|
|
259
|
+
} else if (data.startsWith("0x14f80a8d")) {
|
|
235
260
|
const executeDataV2 = iface.decodeFunctionData("executeV2", data);
|
|
236
261
|
if (
|
|
237
262
|
executeDataV2.params_.metadata === "0x" ||
|
|
@@ -241,6 +266,16 @@ export const decodeMetadata = (data: string) => {
|
|
|
241
266
|
} else {
|
|
242
267
|
metadata = executeDataV2.params_.metadata;
|
|
243
268
|
}
|
|
269
|
+
} else {
|
|
270
|
+
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
271
|
+
if (
|
|
272
|
+
executeDataV3.params_.metadata === "0x" ||
|
|
273
|
+
!executeDataV3.params_.metadata
|
|
274
|
+
) {
|
|
275
|
+
return null;
|
|
276
|
+
} else {
|
|
277
|
+
metadata = executeDataV3.params_.metadata;
|
|
278
|
+
}
|
|
244
279
|
}
|
|
245
280
|
|
|
246
281
|
const metadataArr = [];
|
|
@@ -325,6 +360,7 @@ export const decodeMetadata = (data: string) => {
|
|
|
325
360
|
payload = {
|
|
326
361
|
type,
|
|
327
362
|
};
|
|
363
|
+
break;
|
|
328
364
|
|
|
329
365
|
case "permit2":
|
|
330
366
|
payload = {
|
|
@@ -334,6 +370,30 @@ export const decodeMetadata = (data: string) => {
|
|
|
334
370
|
amount: toBN(decodedData.amount).toFixed(),
|
|
335
371
|
expiration: decodedData.expiration,
|
|
336
372
|
};
|
|
373
|
+
break;
|
|
374
|
+
|
|
375
|
+
case "cross-transfer":
|
|
376
|
+
payload = {
|
|
377
|
+
type,
|
|
378
|
+
fromToken: decodedData.fromToken,
|
|
379
|
+
toToken: decodedData.toToken,
|
|
380
|
+
toChainId: decodedData.toChainId
|
|
381
|
+
? decodedData.toChainId.toString()
|
|
382
|
+
: null,
|
|
383
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
384
|
+
receiver: decodedData.receiver,
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
break;
|
|
388
|
+
case "auth":
|
|
389
|
+
payload = {
|
|
390
|
+
type: decodedData.remove ? "remove-authority" : "add-authority",
|
|
391
|
+
address: decodedData.address,
|
|
392
|
+
chainId: decodedData.chainId
|
|
393
|
+
? decodedData.chainId.toString()
|
|
394
|
+
: null,
|
|
395
|
+
remove: decodedData.remove,
|
|
396
|
+
};
|
|
337
397
|
|
|
338
398
|
break;
|
|
339
399
|
}
|
package/utils/network.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const networks: Network[] = [
|
|
|
10
10
|
zerionName: "ethereum",
|
|
11
11
|
chainId: 1,
|
|
12
12
|
explorerUrl: "https://etherscan.io",
|
|
13
|
+
color: "#5D5FEF",
|
|
13
14
|
get serverRpcUrl() {
|
|
14
15
|
return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
|
|
15
16
|
},
|
|
@@ -29,6 +30,7 @@ export const networks: Network[] = [
|
|
|
29
30
|
debankName: "matic",
|
|
30
31
|
ankrName: "polygon",
|
|
31
32
|
zerionName: "polygon",
|
|
33
|
+
color: "#7A4ADD",
|
|
32
34
|
chainId: 137,
|
|
33
35
|
balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
|
|
34
36
|
usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
@@ -51,6 +53,7 @@ export const networks: Network[] = [
|
|
|
51
53
|
debankName: "arb",
|
|
52
54
|
ankrName: "arbitrum",
|
|
53
55
|
zerionName: "arbitrum",
|
|
56
|
+
color: "#2D374B",
|
|
54
57
|
chainId: 42161,
|
|
55
58
|
usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
|
56
59
|
balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
|
|
@@ -73,6 +76,7 @@ export const networks: Network[] = [
|
|
|
73
76
|
debankName: "op",
|
|
74
77
|
ankrName: "optimism",
|
|
75
78
|
zerionName: "optimism",
|
|
79
|
+
color: "#FF0420",
|
|
76
80
|
chainId: 10,
|
|
77
81
|
usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
|
|
78
82
|
balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
|
|
@@ -95,6 +99,7 @@ export const networks: Network[] = [
|
|
|
95
99
|
debankName: "avax",
|
|
96
100
|
ankrName: "avalanche",
|
|
97
101
|
zerionName: "avalanche",
|
|
102
|
+
color: "#EB5757",
|
|
98
103
|
chainId: 43114,
|
|
99
104
|
usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
|
|
100
105
|
balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
|
|
@@ -117,6 +122,7 @@ export const networks: Network[] = [
|
|
|
117
122
|
debankName: "bsc",
|
|
118
123
|
ankrName: "bsc",
|
|
119
124
|
zerionName: "binance-smart-chain",
|
|
125
|
+
color: "#F3BA2F",
|
|
120
126
|
chainId: 56,
|
|
121
127
|
explorerUrl: "https://bscscan.com",
|
|
122
128
|
usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
@@ -138,6 +144,7 @@ export const networks: Network[] = [
|
|
|
138
144
|
name: "Gnosis",
|
|
139
145
|
debankName: "xdai",
|
|
140
146
|
zerionName: "xdai",
|
|
147
|
+
color: "#04795C",
|
|
141
148
|
chainId: 100,
|
|
142
149
|
balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
|
|
143
150
|
explorerUrl: "https://gnosisscan.io",
|
|
@@ -158,6 +165,7 @@ export const networks: Network[] = [
|
|
|
158
165
|
{
|
|
159
166
|
name: "Polygon zkEVM",
|
|
160
167
|
chainId: 1101,
|
|
168
|
+
color: "#8544f6",
|
|
161
169
|
explorerUrl: "https://zkevm.polygonscan.com",
|
|
162
170
|
balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
|
|
163
171
|
usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
|
|
@@ -175,32 +183,34 @@ export const networks: Network[] = [
|
|
|
175
183
|
},
|
|
176
184
|
},
|
|
177
185
|
},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
186
|
+
{
|
|
187
|
+
name: "Aurora",
|
|
188
|
+
chainId: 1313161554,
|
|
189
|
+
zerionName: "aurora",
|
|
190
|
+
color: "#78d64b",
|
|
191
|
+
explorerUrl: "https://explorer.mainnet.aurora.dev",
|
|
192
|
+
get serverRpcUrl() {
|
|
193
|
+
return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
|
|
194
|
+
},
|
|
195
|
+
usdcAddress: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
|
|
196
|
+
balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
|
|
197
|
+
params: {
|
|
198
|
+
rpcUrls: ["https://mainnet.aurora.dev"],
|
|
199
|
+
chainName: "Aurora",
|
|
200
|
+
nativeCurrency: {
|
|
201
|
+
decimals: 18,
|
|
202
|
+
name: "Aurora ETH",
|
|
203
|
+
symbol: "AETH",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
198
207
|
{
|
|
199
208
|
name: "Fantom",
|
|
200
209
|
chainId: 250,
|
|
201
210
|
zerionName: "fantom",
|
|
202
211
|
explorerUrl: "https://ftmscan.com",
|
|
203
212
|
ankrName: "fantom",
|
|
213
|
+
color: "#1969ff",
|
|
204
214
|
get serverRpcUrl() {
|
|
205
215
|
return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0];
|
|
206
216
|
},
|
|
@@ -221,6 +231,7 @@ export const networks: Network[] = [
|
|
|
221
231
|
chainId: AVO_PROD_CHAIN_ID,
|
|
222
232
|
isAvocado: true,
|
|
223
233
|
balanceResolverAddress: "",
|
|
234
|
+
color: "#16A34A",
|
|
224
235
|
usdcAddress: "",
|
|
225
236
|
serverRpcUrl: AVO_PROD_RPC_URL,
|
|
226
237
|
explorerUrl: AVO_PROD_EXPLORER_URL,
|
|
@@ -239,6 +250,7 @@ export const networks: Network[] = [
|
|
|
239
250
|
name: AVO_STAGING_CHAIN_NAME,
|
|
240
251
|
chainId: AVO_STAGING_CHAIN_ID,
|
|
241
252
|
serverRpcUrl: AVO_STAGING_RPC_URL,
|
|
253
|
+
color: "#16A34A",
|
|
242
254
|
explorerUrl: AVO_STAGING_EXPLORER_URL,
|
|
243
255
|
isAvocado: true,
|
|
244
256
|
balanceResolverAddress: "",
|
package/utils/utils.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface Network {
|
|
|
20
20
|
ankrName?: string;
|
|
21
21
|
zerionName?: string;
|
|
22
22
|
chainId: ChainId;
|
|
23
|
+
color: string;
|
|
23
24
|
isAvocado?: boolean;
|
|
24
25
|
serverRpcUrl: string | undefined;
|
|
25
26
|
balanceResolverAddress?: string;
|
|
@@ -55,13 +56,20 @@ type SendMetadataProps = {
|
|
|
55
56
|
receiver: string;
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
type
|
|
59
|
+
type CrossSendMetadataProps = {
|
|
59
60
|
fromToken: string;
|
|
60
61
|
toToken: string;
|
|
62
|
+
toChainId: string;
|
|
61
63
|
amount: string;
|
|
62
64
|
receiver: string;
|
|
63
65
|
};
|
|
64
66
|
|
|
67
|
+
type AuthMetadataProps = {
|
|
68
|
+
address: string;
|
|
69
|
+
chainId: string;
|
|
70
|
+
remove: boolean;
|
|
71
|
+
};
|
|
72
|
+
|
|
65
73
|
type UpgradeMetadataProps = {
|
|
66
74
|
version: string;
|
|
67
75
|
walletImpl: string;
|
|
@@ -103,7 +111,8 @@ type MetadataProps = {
|
|
|
103
111
|
| "dapp"
|
|
104
112
|
| "deploy"
|
|
105
113
|
| "permit2"
|
|
106
|
-
| "cross-transfer"
|
|
114
|
+
| "cross-transfer"
|
|
115
|
+
| "auth";
|
|
107
116
|
encodedData: string;
|
|
108
117
|
version?: string;
|
|
109
118
|
};
|