@instadapp/avocado-base 0.0.0-dev.19925f5 → 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 (77) hide show
  1. package/abi/avoFactoryProxy.json +109 -0
  2. package/abi/balanceResolver.json +110 -0
  3. package/abi/erc20.json +350 -0
  4. package/abi/forwarder.json +1435 -0
  5. package/abi/gaslessWallet.json +289 -0
  6. package/app.vue +20 -0
  7. package/assets/images/icons/arrow-left.svg +5 -0
  8. package/assets/images/icons/arrow-right.svg +5 -0
  9. package/assets/images/icons/avocado.svg +4 -0
  10. package/assets/images/icons/bridge-2.svg +3 -0
  11. package/assets/images/icons/bridge.svg +7 -0
  12. package/assets/images/icons/calendar.svg +8 -0
  13. package/assets/images/icons/check-circle.svg +4 -0
  14. package/assets/images/icons/chevron-down.svg +4 -0
  15. package/assets/images/icons/clipboard.svg +7 -0
  16. package/assets/images/icons/clock-circle.svg +5 -0
  17. package/assets/images/icons/copy.svg +5 -0
  18. package/assets/images/icons/error-circle.svg +6 -0
  19. package/assets/images/icons/exclamation-circle.svg +13 -0
  20. package/assets/images/icons/exclamation-octagon.svg +13 -0
  21. package/assets/images/icons/exclamation-triangle.svg +5 -0
  22. package/assets/images/icons/external-link.svg +6 -0
  23. package/assets/images/icons/eye.svg +4 -0
  24. package/assets/images/icons/flowers.svg +8 -0
  25. package/assets/images/icons/gas-emoji.svg +193 -0
  26. package/assets/images/icons/gas.svg +7 -0
  27. package/assets/images/icons/gift.svg +153 -0
  28. package/assets/images/icons/globe.svg +110 -0
  29. package/assets/images/icons/hamburger.svg +6 -0
  30. package/assets/images/icons/logout.svg +3 -0
  31. package/assets/images/icons/moon.svg +3 -0
  32. package/assets/images/icons/network.svg +13 -0
  33. package/assets/images/icons/options.svg +5 -0
  34. package/assets/images/icons/plus.svg +5 -0
  35. package/assets/images/icons/power-off-bg.svg +24 -0
  36. package/assets/images/icons/power-off.svg +19 -0
  37. package/assets/images/icons/power-on.svg +19 -0
  38. package/assets/images/icons/qr.svg +20 -0
  39. package/assets/images/icons/question-circle.svg +14 -0
  40. package/assets/images/icons/refresh.svg +6 -0
  41. package/assets/images/icons/search.svg +12 -0
  42. package/assets/images/icons/sun.svg +3 -0
  43. package/assets/images/icons/wave.svg +214 -0
  44. package/assets/images/icons/x.svg +5 -0
  45. package/components/ActionMetadata.vue +50 -0
  46. package/components/ChainLogo.vue +141 -1
  47. package/components/metadata/Bridge.vue +37 -0
  48. package/components/metadata/CrossTransfer.vue +65 -0
  49. package/components/metadata/GasTopup.vue +31 -0
  50. package/components/metadata/Permit2.vue +37 -0
  51. package/components/metadata/Swap.vue +66 -0
  52. package/components/metadata/Transfer.vue +43 -0
  53. package/components.d.ts +13 -0
  54. package/contracts/AvoFactoryProxy.ts +302 -0
  55. package/contracts/BalanceResolver.ts +321 -0
  56. package/contracts/Erc20.ts +526 -0
  57. package/contracts/Forwarder.ts +1644 -0
  58. package/contracts/GaslessWallet.ts +660 -0
  59. package/contracts/common.ts +46 -0
  60. package/contracts/factories/AvoFactoryProxy__factory.ts +181 -0
  61. package/contracts/factories/BalanceResolver__factory.ts +212 -0
  62. package/contracts/factories/Erc20__factory.ts +368 -0
  63. package/contracts/factories/Forwarder__factory.ts +1456 -0
  64. package/contracts/factories/GaslessWallet__factory.ts +499 -0
  65. package/contracts/factories/index.ts +8 -0
  66. package/contracts/index.ts +14 -0
  67. package/nuxt.config.ts +18 -2
  68. package/package.json +14 -5
  69. package/server/utils/index.ts +2 -0
  70. package/utils/avocado.ts +2 -0
  71. package/utils/bignumber.ts +51 -0
  72. package/utils/formatter.ts +94 -0
  73. package/utils/helper.ts +54 -0
  74. package/utils/metadata.ts +444 -0
  75. package/utils/network.ts +165 -26
  76. package/utils/services.ts +14 -0
  77. package/utils/utils.d.ts +116 -3
package/utils/network.ts CHANGED
@@ -1,19 +1,21 @@
1
1
  import { ethers } from "ethers";
2
- import {
3
- AVO_PROD_CHAIN_NAME,
4
- AVO_PROD_CHAIN_ID,
5
- AVO_STAGING_CHAIN_NAME,
6
- AVO_STAGING_RPC_URL,
7
- AVO_PROD_RPC_URL,
8
- AVO_STAGING_CHAIN_ID,
9
- } from "./avocado";
10
2
 
11
3
  export const bridgeDisabledNetworks = [1101];
12
4
 
13
5
  export const networks: Network[] = [
14
6
  {
15
- name: "Mainnet",
7
+ name: "Ethereum",
8
+ debankName: "eth",
9
+ ankrName: "eth",
10
+ zerionName: "ethereum",
16
11
  chainId: 1,
12
+ explorerUrl: "https://etherscan.io",
13
+ color: "#5D5FEF",
14
+ get serverRpcUrl() {
15
+ return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
16
+ },
17
+ balanceResolverAddress: "0x5b7D61b389D12e1f5873d0cCEe7E675915AB5F43",
18
+ usdcAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
17
19
  params: {
18
20
  rpcUrls: ["https://rpc.ankr.com/eth"],
19
21
  nativeCurrency: {
@@ -25,7 +27,17 @@ export const networks: Network[] = [
25
27
  },
26
28
  {
27
29
  name: "Polygon",
30
+ debankName: "matic",
31
+ ankrName: "polygon",
32
+ zerionName: "polygon",
33
+ color: "#7A4ADD",
28
34
  chainId: 137,
35
+ balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
36
+ usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
37
+ explorerUrl: "https://polygonscan.com",
38
+ get serverRpcUrl() {
39
+ return process.env?.POLYGON_RPC_URL || this.params.rpcUrls[0];
40
+ },
29
41
  params: {
30
42
  chainName: "Matic(Polygon) Mainnet",
31
43
  nativeCurrency: {
@@ -34,12 +46,21 @@ export const networks: Network[] = [
34
46
  decimals: 18,
35
47
  },
36
48
  rpcUrls: ["https://polygon-rpc.com"],
37
- blockExplorerUrls: ["https://polygonscan.com/"],
38
49
  },
39
50
  },
40
51
  {
41
52
  name: "Arbitrum",
53
+ debankName: "arb",
54
+ ankrName: "arbitrum",
55
+ zerionName: "arbitrum",
56
+ color: "#2D374B",
42
57
  chainId: 42161,
58
+ usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
59
+ balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
60
+ explorerUrl: "https://arbiscan.io",
61
+ get serverRpcUrl() {
62
+ return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
63
+ },
43
64
  params: {
44
65
  chainName: "Arbitrum One",
45
66
  nativeCurrency: {
@@ -48,12 +69,21 @@ export const networks: Network[] = [
48
69
  decimals: 18,
49
70
  },
50
71
  rpcUrls: ["https://arb1.arbitrum.io/rpc"],
51
- blockExplorerUrls: ["https://arbiscan.io"],
52
72
  },
53
73
  },
54
74
  {
55
75
  name: "Optimism",
76
+ debankName: "op",
77
+ ankrName: "optimism",
78
+ zerionName: "optimism",
79
+ color: "#FF0420",
56
80
  chainId: 10,
81
+ usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
82
+ balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
83
+ explorerUrl: "https://optimistic.etherscan.io",
84
+ get serverRpcUrl() {
85
+ return process.env?.OPTIMISM_RPC_URL || this.params.rpcUrls[0];
86
+ },
57
87
  params: {
58
88
  chainName: "Optimistic Ethereum",
59
89
  nativeCurrency: {
@@ -61,13 +91,22 @@ export const networks: Network[] = [
61
91
  symbol: "ETH",
62
92
  decimals: 18,
63
93
  },
64
- rpcUrls: ["https://mainnet.optimism.io"],
65
- blockExplorerUrls: ["https://optimistic.etherscan.io"],
94
+ rpcUrls: ["https://rpc.ankr.com/optimism"],
66
95
  },
67
96
  },
68
97
  {
69
98
  name: "Avalanche",
99
+ debankName: "avax",
100
+ ankrName: "avalanche",
101
+ zerionName: "avalanche",
102
+ color: "#EB5757",
70
103
  chainId: 43114,
104
+ usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
105
+ balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
106
+ explorerUrl: "https://snowtrace.io",
107
+ get serverRpcUrl() {
108
+ return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
109
+ },
71
110
  params: {
72
111
  chainName: "Avalanche Network",
73
112
  nativeCurrency: {
@@ -75,13 +114,22 @@ export const networks: Network[] = [
75
114
  symbol: "AVAX",
76
115
  decimals: 18,
77
116
  },
78
- rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
79
- blockExplorerUrls: ["https://snowtrace.io/"],
117
+ rpcUrls: ["https://rpc.ankr.com/avalanche"],
80
118
  },
81
119
  },
82
120
  {
83
121
  name: "BSC",
122
+ debankName: "bsc",
123
+ ankrName: "bsc",
124
+ zerionName: "binance-smart-chain",
125
+ color: "#F3BA2F",
84
126
  chainId: 56,
127
+ explorerUrl: "https://bscscan.com",
128
+ usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
129
+ balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
130
+ get serverRpcUrl() {
131
+ return process.env?.BSC_RPC_URL || this.params.rpcUrls[0];
132
+ },
85
133
  params: {
86
134
  chainName: "Binance Smart Chain",
87
135
  rpcUrls: ["https://rpc.ankr.com/bsc"],
@@ -94,7 +142,16 @@ export const networks: Network[] = [
94
142
  },
95
143
  {
96
144
  name: "Gnosis",
145
+ debankName: "xdai",
146
+ zerionName: "xdai",
147
+ color: "#04795C",
97
148
  chainId: 100,
149
+ balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
150
+ explorerUrl: "https://gnosisscan.io",
151
+ usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
152
+ get serverRpcUrl() {
153
+ return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
154
+ },
98
155
  params: {
99
156
  chainName: "Gnosis Safe",
100
157
  rpcUrls: ["https://rpc.ankr.com/gnosis"],
@@ -108,9 +165,17 @@ export const networks: Network[] = [
108
165
  {
109
166
  name: "Polygon zkEVM",
110
167
  chainId: 1101,
168
+ color: "#8544f6",
169
+ explorerUrl: "https://zkevm.polygonscan.com",
170
+ balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
171
+ usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
172
+ get serverRpcUrl() {
173
+ return process.env?.POLYGON_ZKEVM_RPC_URL || this.params.rpcUrls[0];
174
+ },
111
175
  params: {
112
176
  chainName: "polygon zkEVM",
113
- rpcUrls: ["https://rpc.ankr.com/polygon_zkevm"],
177
+ rpcUrls: ["https://zkevm-rpc.com"],
178
+
114
179
  nativeCurrency: {
115
180
  name: "Ethereum",
116
181
  symbol: "ETH",
@@ -118,9 +183,58 @@ export const networks: Network[] = [
118
183
  },
119
184
  },
120
185
  },
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
+ },
207
+ {
208
+ name: "Fantom",
209
+ chainId: 250,
210
+ zerionName: "fantom",
211
+ explorerUrl: "https://ftmscan.com",
212
+ ankrName: "fantom",
213
+ color: "#1969ff",
214
+ get serverRpcUrl() {
215
+ return process.env?.FANTOM_RPC_URL || this.params.rpcUrls[0];
216
+ },
217
+ usdcAddress: "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
218
+ balanceResolverAddress: "0x929376c77a2fb8152375a089a4fccf84ff481479",
219
+ params: {
220
+ rpcUrls: ["https://rpc.ankr.com/fantom"],
221
+ chainName: "Fantom",
222
+ nativeCurrency: {
223
+ name: "Fantom",
224
+ symbol: "FTM",
225
+ decimals: 18,
226
+ },
227
+ },
228
+ },
121
229
  {
122
230
  name: AVO_PROD_CHAIN_NAME,
123
231
  chainId: AVO_PROD_CHAIN_ID,
232
+ isAvocado: true,
233
+ balanceResolverAddress: "",
234
+ color: "#16A34A",
235
+ usdcAddress: "",
236
+ serverRpcUrl: AVO_PROD_RPC_URL,
237
+ explorerUrl: AVO_PROD_EXPLORER_URL,
124
238
  params: {
125
239
  chainName: AVO_PROD_CHAIN_NAME,
126
240
  nativeCurrency: {
@@ -130,12 +244,17 @@ export const networks: Network[] = [
130
244
  },
131
245
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
132
246
  rpcUrls: [AVO_PROD_RPC_URL],
133
- blockExplorerUrls: ["https://avocado.instadapp.io"],
134
247
  },
135
248
  },
136
249
  {
137
250
  name: AVO_STAGING_CHAIN_NAME,
138
251
  chainId: AVO_STAGING_CHAIN_ID,
252
+ serverRpcUrl: AVO_STAGING_RPC_URL,
253
+ color: "#16A34A",
254
+ explorerUrl: AVO_STAGING_EXPLORER_URL,
255
+ isAvocado: true,
256
+ balanceResolverAddress: "",
257
+ usdcAddress: "",
139
258
  params: {
140
259
  chainName: AVO_STAGING_CHAIN_NAME,
141
260
  nativeCurrency: {
@@ -145,21 +264,18 @@ export const networks: Network[] = [
145
264
  },
146
265
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
147
266
  rpcUrls: [AVO_STAGING_RPC_URL],
148
- blockExplorerUrls: ["https://avocado.instadapp.io"],
149
267
  },
150
268
  },
151
269
  ];
152
270
 
153
271
  export const getNetworkByChainId = (
154
- chainId: Network["chainId"] | number | string
155
- ) => {
156
- return networks.find((i) => i.chainId === Number(chainId))!;
272
+ chainId: ChainId | number | string
273
+ ): Network => {
274
+ return networks.find((i) => i.chainId == chainId)!;
157
275
  };
158
276
 
159
277
  export const availableNetworks = networks.filter(
160
- (network) =>
161
- network.chainId != AVO_STAGING_CHAIN_ID &&
162
- network.chainId != AVO_PROD_CHAIN_ID
278
+ (network) => !network.isAvocado
163
279
  );
164
280
 
165
281
  export const chainIdToName = (chainId: ChainId | number | string) => {
@@ -179,14 +295,37 @@ export const RPCMap = networks.reduce((acc, network) => {
179
295
 
180
296
  export const networkIds = networks.map((network) => network.chainId);
181
297
 
182
- const rpcInstances: Record<string, ethers.providers.JsonRpcProvider> = {};
298
+ const rpcInstances: Record<string, ethers.providers.StaticJsonRpcProvider> = {};
299
+ const serverRpcInstances: Record<
300
+ string,
301
+ ethers.providers.StaticJsonRpcProvider
302
+ > = {};
303
+
304
+ export const getServerRpcProvider = (chainId: number | string) => {
305
+ if (!rpcInstances[chainId]) {
306
+ const network = networks.find((n) => n.chainId == chainId);
307
+ serverRpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
308
+ network?.serverRpcUrl
309
+ );
310
+ }
311
+
312
+ return serverRpcInstances[chainId];
313
+ };
183
314
 
184
315
  export const getRpcProvider = (chainId: number | string) => {
185
316
  if (!rpcInstances[chainId]) {
186
- rpcInstances[chainId] = new ethers.providers.JsonRpcProvider(
317
+ rpcInstances[chainId] = new ethers.providers.StaticJsonRpcProvider(
187
318
  getRpcURLByChainId(Number(chainId))
188
319
  );
189
320
  }
190
321
 
191
322
  return rpcInstances[chainId];
192
323
  };
324
+
325
+ export const getExplorerUrl = (
326
+ chainId: ChainId | number | string,
327
+ suffix: `/${string}` = "/"
328
+ ) => {
329
+ const network = getNetworkByChainId(chainId);
330
+ return `${network.explorerUrl}${suffix}`;
331
+ };
@@ -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
@@ -1,13 +1,35 @@
1
- type ChainId = 1 | 137 | 42161 | 10 | 56 | 43114 | 100 | 1101 | 634 | 63400;
1
+ type ChainId =
2
+ | 1
3
+ | 137
4
+ | 42161
5
+ | 10
6
+ | 56
7
+ | 43114
8
+ | 100
9
+ | 1101
10
+ | 250
11
+ | 634
12
+ | 1313161554
13
+ | 63400;
14
+
15
+ type ISlackMessageType = "danger" | "error" | "success" | "banner";
2
16
 
3
17
  interface Network {
4
18
  name: string;
19
+ debankName?: string;
20
+ ankrName?: string;
21
+ zerionName?: string;
5
22
  chainId: ChainId;
23
+ color: string;
24
+ isAvocado?: boolean;
25
+ serverRpcUrl: string | undefined;
26
+ balanceResolverAddress?: string;
27
+ usdcAddress: string;
28
+ explorerUrl: string;
6
29
  params: {
7
30
  chainName?: string;
8
- rpcUrls: string[];
9
- blockExplorerUrls?: string[];
10
31
  iconUrls?: string[];
32
+ rpcUrls: string[];
11
33
  nativeCurrency?: {
12
34
  name: string;
13
35
  symbol: string;
@@ -15,3 +37,94 @@ interface Network {
15
37
  };
16
38
  };
17
39
  }
40
+
41
+ type SignMetadataProps = {
42
+ token: string;
43
+ spender: string;
44
+ amount: string;
45
+ expiration: string;
46
+ };
47
+
48
+ type DappMetadataProps = {
49
+ name: string;
50
+ url: string;
51
+ };
52
+
53
+ type SendMetadataProps = {
54
+ token: string;
55
+ amount: string;
56
+ receiver: string;
57
+ };
58
+
59
+ type CrossSendMetadataProps = {
60
+ fromToken: string;
61
+ toToken: string;
62
+ toChainId: string;
63
+ amount: string;
64
+ receiver: string;
65
+ };
66
+
67
+ type AuthMetadataProps = {
68
+ address: string;
69
+ chainId: string;
70
+ remove: boolean;
71
+ };
72
+
73
+ type UpgradeMetadataProps = {
74
+ version: string;
75
+ walletImpl: string;
76
+ };
77
+
78
+ type TopupMetadataProps = {
79
+ amount: string;
80
+ token: string;
81
+ onBehalf: string;
82
+ };
83
+
84
+ type BridgeMetadataProps = {
85
+ amount: string;
86
+ receiver: string;
87
+ fromToken: string;
88
+ toToken: string;
89
+ toChainId: string;
90
+ bridgeFee: string;
91
+ nativeToken: string;
92
+ };
93
+
94
+ type SwapMetadataProps = {
95
+ sellToken: string;
96
+ buyToken: string;
97
+ sellAmount: string;
98
+ buyAmount: string;
99
+ receiver: string;
100
+ protocol?: string;
101
+ };
102
+
103
+ type MetadataProps = {
104
+ type:
105
+ | "transfer"
106
+ | "bridge"
107
+ | "swap"
108
+ | "multi"
109
+ | "gas-topup"
110
+ | "upgrade"
111
+ | "dapp"
112
+ | "deploy"
113
+ | "permit2"
114
+ | "cross-transfer"
115
+ | "auth";
116
+ encodedData: string;
117
+ version?: string;
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
+ }