@instadapp/avocado-base 0.0.0-dev.02731e3 → 0.0.0-dev.0cd0f72
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/assets/images/icons/arrow-left.svg +5 -0
- package/assets/images/icons/arrow-right.svg +5 -0
- package/assets/images/icons/avocado.svg +4 -0
- package/assets/images/icons/bridge-2.svg +3 -0
- package/assets/images/icons/bridge.svg +7 -0
- package/assets/images/icons/calendar.svg +8 -0
- package/assets/images/icons/check-circle.svg +4 -0
- package/assets/images/icons/chevron-down.svg +4 -0
- package/assets/images/icons/clipboard.svg +7 -0
- package/assets/images/icons/clock-circle.svg +5 -0
- package/assets/images/icons/copy.svg +5 -0
- package/assets/images/icons/error-circle.svg +6 -0
- package/assets/images/icons/exclamation-circle.svg +13 -0
- package/assets/images/icons/exclamation-octagon.svg +13 -0
- package/assets/images/icons/exclamation-triangle.svg +5 -0
- package/assets/images/icons/external-link.svg +6 -0
- package/assets/images/icons/eye.svg +4 -0
- package/assets/images/icons/flowers.svg +8 -0
- package/assets/images/icons/gas-emoji.svg +193 -0
- package/assets/images/icons/gas.svg +7 -0
- package/assets/images/icons/gift.svg +153 -0
- package/assets/images/icons/globe.svg +110 -0
- package/assets/images/icons/hamburger.svg +6 -0
- package/assets/images/icons/logout.svg +3 -0
- package/assets/images/icons/moon.svg +3 -0
- package/assets/images/icons/network.svg +13 -0
- package/assets/images/icons/options.svg +5 -0
- package/assets/images/icons/plus.svg +5 -0
- package/assets/images/icons/power-off-bg.svg +24 -0
- package/assets/images/icons/power-off.svg +19 -0
- package/assets/images/icons/power-on.svg +19 -0
- package/assets/images/icons/qr.svg +20 -0
- package/assets/images/icons/question-circle.svg +14 -0
- package/assets/images/icons/refresh.svg +6 -0
- package/assets/images/icons/search.svg +12 -0
- package/assets/images/icons/sun.svg +3 -0
- package/assets/images/icons/wave.svg +214 -0
- package/assets/images/icons/x.svg +5 -0
- package/components/ActionMetadata.vue +50 -0
- package/components/ChainLogo.vue +1 -1
- package/components/metadata/Bridge.vue +37 -0
- package/components/metadata/CrossTransfer.vue +65 -0
- package/components/metadata/GasTopup.vue +31 -0
- package/components/metadata/Permit2.vue +37 -0
- package/components/metadata/Swap.vue +66 -0
- package/components/metadata/Transfer.vue +43 -0
- package/components.d.ts +13 -0
- package/contracts/Forwarder.ts +856 -2
- package/contracts/factories/Forwarder__factory.ts +816 -16
- package/nuxt.config.ts +17 -1
- package/package.json +6 -3
- package/utils/avocado.ts +2 -0
- package/utils/bignumber.ts +20 -0
- package/utils/metadata.ts +63 -3
- package/utils/network.ts +24 -23
- package/utils/services.ts +14 -0
- package/utils/utils.d.ts +20 -1
package/nuxt.config.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
2
|
+
import ViteComponents from "unplugin-vue-components/vite";
|
|
3
|
+
|
|
2
4
|
export default defineNuxtConfig({
|
|
3
|
-
modules: ["@nuxtjs/tailwindcss"],
|
|
5
|
+
modules: ["@nuxtjs/tailwindcss", "nuxt-svgo", "@vueuse/nuxt"],
|
|
6
|
+
svgo: {
|
|
7
|
+
defaultImport: "component",
|
|
8
|
+
autoImportPath: "./assets/images/icons",
|
|
9
|
+
svgoConfig: {
|
|
10
|
+
plugins: ["prefixIds"],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
vite: {
|
|
14
|
+
plugins: [
|
|
15
|
+
ViteComponents({
|
|
16
|
+
dts: true,
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
},
|
|
4
20
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instadapp/avocado-base",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.0cd0f72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"types": "global.d.ts",
|
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
"@instadapp/avocado-dev": "npm:@instadapp/avocado@dev",
|
|
17
17
|
"@nuxtjs/tailwindcss": "^6.6.5",
|
|
18
18
|
"@typechain/ethers-v5": "^10.2.0",
|
|
19
|
-
"nuxt": "^3.
|
|
19
|
+
"nuxt": "^3.6.1",
|
|
20
|
+
"nuxt-svgo": "^3.1.0",
|
|
20
21
|
"rimraf": "^3.0.2",
|
|
21
|
-
"typechain": "^8.1.1"
|
|
22
|
+
"typechain": "^8.1.1",
|
|
23
|
+
"unplugin-vue-components": "^0.25.1"
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
26
|
+
"@vueuse/nuxt": "^10.2.0",
|
|
24
27
|
"bignumber.js": "^9.1.1",
|
|
25
28
|
"ethers": "^5.7.2"
|
|
26
29
|
}
|
package/utils/avocado.ts
CHANGED
package/utils/bignumber.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import { BigNumber as BN } from "ethers";
|
|
3
3
|
|
|
4
|
+
type CombinedBigNumber = BigNumber | string | number;
|
|
5
|
+
|
|
4
6
|
export const toBN = (value: BigNumber.Value | BN) =>
|
|
5
7
|
new BigNumber(BN.isBigNumber(value) ? value.toString() : value);
|
|
6
8
|
export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero();
|
|
@@ -29,3 +31,21 @@ export const ensureValue = (value: any) => {
|
|
|
29
31
|
export const max = (...args: BigNumber.Value[]) => {
|
|
30
32
|
return BigNumber.max(...args);
|
|
31
33
|
};
|
|
34
|
+
|
|
35
|
+
export function pow(value: CombinedBigNumber, exponent: string | number) {
|
|
36
|
+
return toBN(value).pow(toBN(exponent));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function toWei(val: CombinedBigNumber, decimals: number): string {
|
|
40
|
+
const num = toBN(val);
|
|
41
|
+
const multiplier = pow(10, decimals);
|
|
42
|
+
return times(num, multiplier).toFixed(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function fromWei(val: CombinedBigNumber, decimal = 18) {
|
|
46
|
+
return toBN(val).div(new BigNumber(10).pow(decimal));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function abs(value: CombinedBigNumber) {
|
|
50
|
+
return toBN(value).abs();
|
|
51
|
+
}
|
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
|
+
"instadapp-pro": ["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,29 @@ export const decodeMetadata = (data: string) => {
|
|
|
248
267
|
} else {
|
|
249
268
|
metadata = executeDataV2.params_.metadata;
|
|
250
269
|
}
|
|
270
|
+
} else if (data.startsWith("0x85114d53")) {
|
|
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
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
const executeDataMultisigV3 = iface.decodeFunctionData(
|
|
282
|
+
"executeMultisigV3",
|
|
283
|
+
data
|
|
284
|
+
);
|
|
285
|
+
if (
|
|
286
|
+
executeDataMultisigV3.params_.metadata === "0x" ||
|
|
287
|
+
!executeDataMultisigV3.params_.metadata
|
|
288
|
+
) {
|
|
289
|
+
return null;
|
|
290
|
+
} else {
|
|
291
|
+
metadata = executeDataMultisigV3.params_.metadata;
|
|
292
|
+
}
|
|
251
293
|
}
|
|
252
294
|
|
|
253
295
|
const metadataArr = [];
|
|
@@ -356,6 +398,24 @@ export const decodeMetadata = (data: string) => {
|
|
|
356
398
|
receiver: decodedData.receiver,
|
|
357
399
|
};
|
|
358
400
|
|
|
401
|
+
break;
|
|
402
|
+
case "auth":
|
|
403
|
+
payload = {
|
|
404
|
+
type: decodedData.remove ? "remove-authority" : "add-authority",
|
|
405
|
+
address: decodedData.address,
|
|
406
|
+
chainId: decodedData.chainId
|
|
407
|
+
? decodedData.chainId.toString()
|
|
408
|
+
: null,
|
|
409
|
+
remove: decodedData.remove,
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
break;
|
|
413
|
+
case "instadapp-pro":
|
|
414
|
+
payload = {
|
|
415
|
+
type,
|
|
416
|
+
castDetails: decodedData.castDetails,
|
|
417
|
+
};
|
|
418
|
+
|
|
359
419
|
break;
|
|
360
420
|
}
|
|
361
421
|
|
|
@@ -364,7 +424,7 @@ export const decodeMetadata = (data: string) => {
|
|
|
364
424
|
|
|
365
425
|
return metadataArr;
|
|
366
426
|
} catch (e) {
|
|
367
|
-
console.log(e);
|
|
427
|
+
// console.log(e);
|
|
368
428
|
return null;
|
|
369
429
|
}
|
|
370
430
|
};
|
package/utils/network.ts
CHANGED
|
@@ -4,7 +4,7 @@ export const bridgeDisabledNetworks = [1101];
|
|
|
4
4
|
|
|
5
5
|
export const networks: Network[] = [
|
|
6
6
|
{
|
|
7
|
-
name: "
|
|
7
|
+
name: "Ethereum",
|
|
8
8
|
debankName: "eth",
|
|
9
9
|
ankrName: "eth",
|
|
10
10
|
zerionName: "ethereum",
|
|
@@ -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",
|
|
@@ -183,26 +183,27 @@ export const networks: Network[] = [
|
|
|
183
183
|
},
|
|
184
184
|
},
|
|
185
185
|
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
+
},
|
|
206
207
|
{
|
|
207
208
|
name: "Fantom",
|
|
208
209
|
chainId: 250,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const fetchTokenByAddress = async (
|
|
2
|
+
address: string,
|
|
3
|
+
chainId: string | number
|
|
4
|
+
) => {
|
|
5
|
+
if (!address || !chainId) return null;
|
|
6
|
+
const [token] = (await $fetch(`${blockQueryURL}/${chainId}/tokens`, {
|
|
7
|
+
params: {
|
|
8
|
+
sparkline: false,
|
|
9
|
+
"addresses[]": [address],
|
|
10
|
+
},
|
|
11
|
+
})) as ITokenPrice[];
|
|
12
|
+
|
|
13
|
+
return token;
|
|
14
|
+
};
|
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,20 @@ 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
|
};
|
|
119
|
+
|
|
120
|
+
interface ITokenPrice {
|
|
121
|
+
address: string;
|
|
122
|
+
chain_id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
symbol: string;
|
|
125
|
+
decimals: number;
|
|
126
|
+
logo_url: string;
|
|
127
|
+
price: string;
|
|
128
|
+
coingecko_id: string;
|
|
129
|
+
sparkline_price_7d: number[];
|
|
130
|
+
}
|