@instadapp/avocado-base 0.0.46 → 0.0.48

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.
@@ -7,9 +7,11 @@ const props = defineProps<{
7
7
  };
8
8
  chain_id: number | string;
9
9
  compact?: boolean;
10
+ tokens?: ITokenPrice[];
10
11
  }>();
11
12
 
12
13
  provide('compact', props.compact);
14
+ provide('tokens', props.tokens);
13
15
 
14
16
  </script>
15
17
 
@@ -6,9 +6,13 @@ const props = defineProps<{
6
6
  }>();
7
7
 
8
8
  const compact = inject('compact');
9
+ const tokens = inject<ITokenPrice[]>('tokens');
9
10
 
10
11
  const toToken = asyncComputed(() =>
11
- fetchTokenByAddress(props.metadata?.toToken, props.metadata?.toChainId)
12
+ {
13
+ if (Array.isArray(tokens) && !tokens.length) return null;
14
+ return fetchTokenByAddress(props.metadata?.toToken, props.metadata?.toChainId, tokens)
15
+ }
12
16
  );
13
17
 
14
18
  const bridgeAmountFormatted = computed(() =>
@@ -6,13 +6,17 @@ const props = defineProps<{
6
6
  }>();
7
7
 
8
8
  const compact = inject('compact');
9
+ const tokens = inject<ITokenPrice[]>('tokens');
9
10
 
10
11
  const fromToken = asyncComputed(() => {
11
12
  if (!props?.chain_id) return null;
12
13
 
14
+ if (Array.isArray(tokens) && !tokens.length) return null;
15
+
13
16
  return fetchTokenByAddress(
14
17
  props.metadata?.fromToken,
15
- props?.chain_id
18
+ props?.chain_id,
19
+ tokens
16
20
  );
17
21
  });
18
22
 
@@ -5,8 +5,14 @@ const props = defineProps<{
5
5
  chain_id: number | string
6
6
  }>();
7
7
 
8
+ const tokens = inject<ITokenPrice[]>('tokens');
9
+
8
10
  const token = asyncComputed(() =>
9
- fetchTokenByAddress(props.metadata?.token, props?.chain_id)
11
+ {
12
+ if (Array.isArray(tokens) && !tokens.length) return null;
13
+
14
+ return fetchTokenByAddress(props.metadata?.token, props?.chain_id, tokens)
15
+ }
10
16
  );
11
17
 
12
18
  const compact = inject('compact');
@@ -5,8 +5,13 @@ const props = defineProps<{
5
5
  chain_id: number | string
6
6
  }>();
7
7
 
8
+ const tokens = inject<ITokenPrice[]>('tokens');
9
+
8
10
  const token = asyncComputed(() =>
9
- fetchTokenByAddress(props.metadata?.token, props?.chain_id)
11
+ {
12
+ if (Array.isArray(tokens) && !tokens.length) return null;
13
+ return fetchTokenByAddress(props.metadata?.token, props?.chain_id, tokens)
14
+ }
10
15
  );
11
16
 
12
17
  const calculateDate = (timestamp: number) => {
@@ -6,12 +6,19 @@ const props = defineProps<{
6
6
  }>();
7
7
 
8
8
  const compact = inject('compact');
9
+ const tokens = inject<ITokenPrice[]>('tokens');
9
10
 
10
11
  const buyToken = asyncComputed(() =>
11
- fetchTokenByAddress(props.metadata?.buyToken, props?.chain_id)
12
+ {
13
+ if (Array.isArray(tokens) && !tokens.length) return null;
14
+ return fetchTokenByAddress(props.metadata?.buyToken, props?.chain_id, tokens)
15
+ }
12
16
  );
13
17
  const sellToken = asyncComputed(() =>
14
- fetchTokenByAddress(props.metadata?.sellToken, props?.chain_id)
18
+ {
19
+ if (Array.isArray(tokens) && !tokens.length) return null;
20
+ return fetchTokenByAddress(props.metadata?.sellToken, props?.chain_id, tokens)
21
+ }
15
22
  );
16
23
 
17
24
  const sellAmountFormatted = computed(() =>
@@ -6,13 +6,17 @@ const props = defineProps<{
6
6
  }>();
7
7
 
8
8
  const compact = inject('compact');
9
+ const tokens = inject<ITokenPrice[]>('tokens');
9
10
 
10
11
  const token = asyncComputed(() => {
11
12
  if (!props?.chain_id) return null;
12
13
 
14
+ if (Array.isArray(tokens) && !tokens.length) return null;
15
+
13
16
  return fetchTokenByAddress(
14
17
  props.metadata?.token,
15
- props?.chain_id
18
+ props?.chain_id,
19
+ tokens
16
20
  );
17
21
  });
18
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
package/utils/network.ts CHANGED
@@ -175,7 +175,6 @@ export const networks: Network[] = [
175
175
  params: {
176
176
  chainName: "polygon zkEVM",
177
177
  rpcUrls: ["https://zkevm-rpc.com"],
178
-
179
178
  nativeCurrency: {
180
179
  name: "Ethereum",
181
180
  symbol: "ETH",
@@ -225,6 +224,26 @@ export const networks: Network[] = [
225
224
  decimals: 18,
226
225
  },
227
226
  },
227
+ },
228
+ {
229
+ name: 'Base',
230
+ chainId: 8453,
231
+ color: '#1E2024',
232
+ explorerUrl: 'https://basescan.org',
233
+ get serverRpcUrl() {
234
+ return process.env?.BASE_RPC_URL || this.params.rpcUrls[0];
235
+ },
236
+ usdcAddress: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',
237
+ balanceResolverAddress: '0x23c8EAb8a4373dD16b0947Ebe8bf76Ff7A49d13C',
238
+ params: {
239
+ rpcUrls: ['https://rpc.ankr.com/base'],
240
+ chainName: "Base",
241
+ nativeCurrency: {
242
+ name: "Ethereum",
243
+ symbol: "ETH",
244
+ decimals: 18,
245
+ },
246
+ }
228
247
  },
229
248
  {
230
249
  name: AVO_PROD_CHAIN_NAME,
@@ -281,6 +300,7 @@ export const chainUsdcAddresses = [
281
300
  { chainId: 43114, address: '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664' },
282
301
  { chainId: 1101, address: '0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035' },
283
302
  { chainId: 1313161554, address: '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802' },
303
+ { chainId: 8453, address: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA'}
284
304
  ];
285
305
 
286
306
  export const getNetworkByChainId = (
package/utils/services.ts CHANGED
@@ -1,8 +1,15 @@
1
1
  export const fetchTokenByAddress = async (
2
2
  address: string,
3
- chainId: string | number
3
+ chainId: string | number,
4
+ tokens?: ITokenPrice[]
4
5
  ) => {
5
6
  if (!address || !chainId) return null;
7
+
8
+ if (tokens?.length) {
9
+ const token = tokens.find((token) => token.address?.toLocaleLowerCase() === address?.toLocaleLowerCase() && token.chain_id == chainId);
10
+ if (token) return token;
11
+ }
12
+
6
13
  const [token] = (await $fetch(`${blockQueryURL}/${chainId}/tokens`, {
7
14
  params: {
8
15
  sparkline: false,
package/utils/utils.d.ts CHANGED
@@ -11,6 +11,7 @@ declare global {
11
11
  | 250
12
12
  | 634
13
13
  | 1313161554
14
+ | 8453
14
15
  | 63400;
15
16
 
16
17
  type ISlackMessageType = "danger" | "error" | "success" | "banner";