@instadapp/avocado-base 0.0.44 → 0.0.47

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
 
@@ -61,15 +63,13 @@ provide('compact', props.compact);
61
63
  Change Threshold to {{ metadata.count }}
62
64
  </div>
63
65
 
64
- <div class="flex items-center gap-2.5" v-if="metadata.type === 'rejection'">
65
- <div v-tippy="{
66
+ <div v-tippy="{
66
67
  content: metadata.id,
67
68
  maxWidth: 'none',
69
+ interactive: true,
68
70
  }"
69
- class="text-left w-fit">
70
- {{ shortenHash(metadata.id) }}
71
- </div>
72
- <CopyClipboard icon-only :text="metadata.id" />
71
+ v-if="metadata.type === 'rejection'" class="text-left w-fit">
72
+ {{ shortenHash(metadata.id) }}
73
73
  </div>
74
74
  </div>
75
- </template>
75
+ </template>
@@ -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.44",
3
+ "version": "0.0.47",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
@@ -71,11 +71,8 @@ export function formatDecimal(value: string | number, fractionDigits?: number) {
71
71
  const num = toBN(value);
72
72
  let decimals;
73
73
 
74
- if (num.lt(0.01)) {
74
+ if (num.lt(1)) {
75
75
  decimals = 4;
76
- }
77
- else if (num.lt(1)) {
78
- decimals = 8;
79
76
  } else if (num.lt(10)) {
80
77
  decimals = 6;
81
78
  } else if (num.lt(100)) {
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 || token?.chainId) == chainId);
10
+ if (token) return token;
11
+ }
12
+
6
13
  const [token] = (await $fetch(`${blockQueryURL}/${chainId}/tokens`, {
7
14
  params: {
8
15
  sparkline: false,