@instadapp/avocado-base 0.0.50 → 0.0.52

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.
@@ -15,6 +15,17 @@ const toToken = asyncComputed(() =>
15
15
  }
16
16
  );
17
17
 
18
+ const fromToken = asyncComputed(() =>
19
+ {
20
+ if (Array.isArray(tokens) && !tokens.length) return null;
21
+ return fetchTokenByAddress(props.metadata?.fromToken, props.chain_id, tokens)
22
+ }
23
+ );
24
+
25
+ const isTokensSame = computed(() => {
26
+ return toToken.value?.symbol === fromToken.value?.symbol
27
+ })
28
+
18
29
  const bridgeAmountFormatted = computed(() =>
19
30
  formatDecimal(
20
31
  fromWei(props.metadata?.amount, toToken?.value?.decimals).toFixed()
@@ -23,18 +34,23 @@ const bridgeAmountFormatted = computed(() =>
23
34
  </script>
24
35
 
25
36
  <template>
26
- <div v-if="!toToken" class="rounded-5 w-24 h-4 loading-box" />
37
+ <div v-if="!toToken || !fromToken" class="rounded-5 w-24 h-4 loading-box" />
27
38
  <div
28
39
  class="flex gap-5 items-center"
29
- v-if="metadata.type === 'bridge' && toToken"
40
+ v-if="toToken && fromToken"
30
41
  >
31
42
  <span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
32
43
  <span class="inline-flex gap-2.5 items-center">
33
- <img width="20" height="20" class="w-5 h-5" :src="toToken.logo_url" />
44
+ <img width="20" height="20" class="w-5 h-5" :src="fromToken.logo_url" />
34
45
  {{ bridgeAmountFormatted }}
35
- <span class="uppercase">{{ toToken?.symbol }}</span>
46
+ <span class="uppercase">{{ fromToken?.symbol }}</span>
36
47
  <SvgoBridge class="text-slate-400 w-4 h-4" />
48
+ <template v-if="!isTokensSame">
49
+ <img width="20" height="20" class="w-5 h-5" :src="toToken.logo_url" />
50
+ <span class="uppercase">{{ toToken?.symbol }}</span>
51
+ </template>
37
52
  <span class="flex items-center gap-2.5">
53
+ on
38
54
  <ChainLogo class="w-5" :chain="metadata.toChainId" />
39
55
  <span>{{ chainIdToName(metadata.toChainId) }}</span>
40
56
  </span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@vueuse/nuxt": "^10.2.0",
28
28
  "bignumber.js": "^9.1.1",
29
- "ethers": "^5.7.2",
30
- "xxhashjs": "^0.2.2"
29
+ "crypto-js": "^4.1.1",
30
+ "ethers": "^5.7.2"
31
31
  }
32
32
  }
package/utils/helper.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as XXH from 'xxhashjs';
1
+ import * as CryptoJS from 'crypto-js';
2
2
 
3
3
  export const indexSorter = (aIndex: number, bIndex: number) => {
4
4
  if (aIndex === -1 && bIndex === -1) {
@@ -62,12 +62,12 @@ export function formatMultipleAddresses(addresses: string[], shorten = true) {
62
62
  return formattedString
63
63
  }
64
64
 
65
- export function generateColor(address: string): string {
66
- const hash = XXH.h32(address, 0xABCD).toNumber()
65
+ export function generateColor(address: string) {
66
+ const hash = parseInt(CryptoJS.MD5(address).toString().substr(0, 8), 16);
67
67
 
68
- const hue = hash % 360
69
- const saturation = 80 + (hash % 30)
70
- const lightness = 70 + (hash % 20)
68
+ const hue = hash % 360;
69
+ const saturation = 80 + (hash % 30);
70
+ const lightness = 70 + (hash % 20);
71
71
 
72
- return `hsl(${hue}, ${saturation}%, ${lightness}%)`
72
+ return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
73
73
  }