@instadapp/avocado-base 0.0.0-dev.17ef354 → 0.0.0-dev.2037715

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.
Files changed (58) hide show
  1. package/abi/forwarder.json +1253 -149
  2. package/assets/images/icons/arrow-left.svg +5 -0
  3. package/assets/images/icons/arrow-right.svg +5 -0
  4. package/assets/images/icons/avocado.svg +4 -0
  5. package/assets/images/icons/bridge-2.svg +3 -0
  6. package/assets/images/icons/bridge.svg +7 -0
  7. package/assets/images/icons/calendar.svg +8 -0
  8. package/assets/images/icons/check-circle.svg +4 -0
  9. package/assets/images/icons/chevron-down.svg +4 -0
  10. package/assets/images/icons/clipboard.svg +7 -0
  11. package/assets/images/icons/clock-circle.svg +5 -0
  12. package/assets/images/icons/copy.svg +5 -0
  13. package/assets/images/icons/error-circle.svg +6 -0
  14. package/assets/images/icons/exclamation-circle.svg +13 -0
  15. package/assets/images/icons/exclamation-octagon.svg +13 -0
  16. package/assets/images/icons/exclamation-triangle.svg +5 -0
  17. package/assets/images/icons/external-link.svg +6 -0
  18. package/assets/images/icons/eye.svg +4 -0
  19. package/assets/images/icons/flowers.svg +8 -0
  20. package/assets/images/icons/gas-emoji.svg +193 -0
  21. package/assets/images/icons/gas.svg +7 -0
  22. package/assets/images/icons/gift.svg +153 -0
  23. package/assets/images/icons/globe.svg +110 -0
  24. package/assets/images/icons/hamburger.svg +6 -0
  25. package/assets/images/icons/logout.svg +3 -0
  26. package/assets/images/icons/moon.svg +3 -0
  27. package/assets/images/icons/network.svg +13 -0
  28. package/assets/images/icons/options.svg +5 -0
  29. package/assets/images/icons/plus.svg +5 -0
  30. package/assets/images/icons/power-off-bg.svg +24 -0
  31. package/assets/images/icons/power-off.svg +19 -0
  32. package/assets/images/icons/power-on.svg +19 -0
  33. package/assets/images/icons/qr.svg +20 -0
  34. package/assets/images/icons/question-circle.svg +14 -0
  35. package/assets/images/icons/refresh.svg +6 -0
  36. package/assets/images/icons/search.svg +12 -0
  37. package/assets/images/icons/sun.svg +3 -0
  38. package/assets/images/icons/wave.svg +214 -0
  39. package/assets/images/icons/x.svg +5 -0
  40. package/components/ActionMetadata.vue +50 -0
  41. package/components/ChainLogo.vue +1 -1
  42. package/components/metadata/Bridge.vue +37 -0
  43. package/components/metadata/CrossTransfer.vue +65 -0
  44. package/components/metadata/GasTopup.vue +31 -0
  45. package/components/metadata/Permit2.vue +37 -0
  46. package/components/metadata/Swap.vue +66 -0
  47. package/components/metadata/Transfer.vue +43 -0
  48. package/components.d.ts +13 -0
  49. package/contracts/Forwarder.ts +856 -2
  50. package/contracts/factories/Forwarder__factory.ts +816 -16
  51. package/nuxt.config.ts +17 -1
  52. package/package.json +6 -3
  53. package/utils/avocado.ts +2 -0
  54. package/utils/bignumber.ts +20 -0
  55. package/utils/metadata.ts +77 -3
  56. package/utils/network.ts +35 -23
  57. package/utils/services.ts +14 -0
  58. package/utils/utils.d.ts +21 -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.17ef354",
3
+ "version": "0.0.0-dev.2037715",
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.3.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
@@ -20,3 +20,5 @@ export const AVO_STAGING_DEPOSIT_ADDRESS =
20
20
  export const AVO_PROD_RPC_URL = "https://rpc.avocado.instadapp.io";
21
21
 
22
22
  export const AVO_STAGING_RPC_URL = "https://rpc.avocado.instad.app";
23
+
24
+ export const blockQueryURL = "https://blockquery.instadapp.io";
@@ -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 "@/contracts";
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,21 @@ 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
  };
431
+
432
+ /**
433
+ * Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
434
+ * @param {string} txType - The input sentence to modify
435
+ *
436
+ * @returns {string} - The modified sentence with hyphens replaced with spaces and the first letter of each word capitalized.
437
+ */
438
+ export const formatTxType = (txType: string) => {
439
+ const finalSentence = txType
440
+ .replace("-", " ")
441
+ .replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
442
+
443
+ return finalSentence;
444
+ };
package/utils/network.ts CHANGED
@@ -4,12 +4,13 @@ export const bridgeDisabledNetworks = [1101];
4
4
 
5
5
  export const networks: Network[] = [
6
6
  {
7
- name: "Mainnet",
7
+ name: "Ethereum",
8
8
  debankName: "eth",
9
9
  ankrName: "eth",
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",
@@ -109,7 +114,7 @@ export const networks: Network[] = [
109
114
  symbol: "AVAX",
110
115
  decimals: 18,
111
116
  },
112
- rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
117
+ rpcUrls: ["https://rpc.ankr.com/avalanche"],
113
118
  },
114
119
  },
115
120
  {
@@ -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",
@@ -166,7 +174,7 @@ export const networks: Network[] = [
166
174
  },
167
175
  params: {
168
176
  chainName: "polygon zkEVM",
169
- rpcUrls: ["https://rpc.ankr.com/polygon_zkevm"],
177
+ rpcUrls: ["https://zkevm-rpc.com"],
170
178
 
171
179
  nativeCurrency: {
172
180
  name: "Ethereum",
@@ -175,32 +183,34 @@ export const networks: Network[] = [
175
183
  },
176
184
  },
177
185
  },
178
- // {
179
- // name: "Aurora",
180
- // chainId: 1313161554,
181
- // zerionName: "aurora",
182
- // explorerUrl: "https://explorer.mainnet.aurora.dev",
183
- // get serverRpcUrl() {
184
- // return process.env?.AURORA_RPC_URL || this.params.rpcUrls[0];
185
- // },
186
- // usdcAddress: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802",
187
- // balanceResolverAddress: "0xdF19Da523DA64bBE82eE0E4DFf00d676A8386474",
188
- // params: {
189
- // rpcUrls: ["https://mainnet.aurora.dev"],
190
- // chainName: "Aurora",
191
- // nativeCurrency: {
192
- // decimals: 18,
193
- // name: "Aurora ETH",
194
- // symbol: "AETH",
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: "",
@@ -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
@@ -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;
@@ -63,6 +64,12 @@ type CrossSendMetadataProps = {
63
64
  receiver: string;
64
65
  };
65
66
 
67
+ type AuthMetadataProps = {
68
+ address: string;
69
+ chainId: string;
70
+ remove: boolean;
71
+ };
72
+
66
73
  type UpgradeMetadataProps = {
67
74
  version: string;
68
75
  walletImpl: string;
@@ -104,7 +111,20 @@ type MetadataProps = {
104
111
  | "dapp"
105
112
  | "deploy"
106
113
  | "permit2"
107
- | "cross-transfer";
114
+ | "cross-transfer"
115
+ | "auth";
108
116
  encodedData: string;
109
117
  version?: string;
110
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
+ }