@instadapp/avocado-base 0.0.0-dev.d831e20 → 0.0.0-dev.df0e2f2

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.
@@ -6,31 +6,51 @@ 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
 
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
+
14
29
  const bridgeAmountFormatted = computed(() =>
15
30
  formatDecimal(
16
- fromWei(props.metadata?.amount, toToken?.value?.decimals).toFixed()
31
+ fromWei(props.metadata?.amount, fromToken?.value?.decimals).toFixed()
17
32
  )
18
33
  );
19
34
  </script>
20
35
 
21
36
  <template>
22
- <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" />
23
38
  <div
24
39
  class="flex gap-5 items-center"
25
- v-if="metadata.type === 'bridge' && toToken"
40
+ v-if="toToken && fromToken"
26
41
  >
27
42
  <span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
28
43
  <span class="inline-flex gap-2.5 items-center">
29
- <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" />
30
45
  {{ bridgeAmountFormatted }}
31
- <span class="uppercase">{{ toToken?.symbol }}</span>
46
+ <span class="uppercase">{{ fromToken?.symbol }}</span>
32
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>
33
52
  <span class="flex items-center gap-2.5">
53
+ on
34
54
  <ChainLogo class="w-5" :chain="metadata.toChainId" />
35
55
  <span>{{ chainIdToName(metadata.toChainId) }}</span>
36
56
  </span>
@@ -6,19 +6,31 @@ 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
 
19
- const formattedFromAmount = computed(() =>
23
+ const toToken = asyncComputed(() => {
24
+ if (!props?.metadata?.toChainId) return null;
25
+
26
+ if (Array.isArray(tokens) && !tokens.length) return null;
27
+
28
+ return fetchTokenByAddress(props.metadata?.toToken, props?.metadata?.toChainId, tokens);
29
+ });
30
+
31
+ const formattedToAmount = computed(() =>
20
32
  formatDecimal(
21
- fromWei(props.metadata?.amount, fromToken?.value?.decimals).toFixed()
33
+ fromWei(props.metadata?.amount, toToken?.value?.decimals).toFixed()
22
34
  )
23
35
  );
24
36
  </script>
@@ -32,7 +44,7 @@ const formattedFromAmount = computed(() =>
32
44
  <span v-if="!compact" class="capitalize text-xs sm:text-sm">Cross-chain send</span>
33
45
  <span class="inline-flex gap-2.5 items-center">
34
46
  <img width="20" height="20" class="w-5 h-5" :src="fromToken?.logo_url" />
35
- {{ formattedFromAmount }}
47
+ {{ formattedToAmount }}
36
48
  <span class="uppercase">{{ fromToken?.symbol }}</span>
37
49
  </span>
38
50
  </div>
@@ -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) => {
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ import { Tippy } from 'vue-tippy'
3
+ import Info2 from '~/assets/images/icons/info-2.svg'
4
+
5
+ defineProps<{
6
+ metadata: {
7
+ type: MetadataTypes,
8
+ [key: string]: any
9
+ };
10
+ compact?: boolean;
11
+ }>();
12
+ </script>
13
+
14
+ <template>
15
+ <div class="font-medium">
16
+ <div v-if="!compact || metadata.addresses.length < 3" class="flex gap-[14px] flex-wrap items-end">
17
+ <p v-if="!compact" class="text-xs"> {{ formatTxType(metadata.type) }} </p>
18
+ <div v-for="address of metadata.addresses" :key="address" class="flex gap-2 rounded-full bg-slate-100 dark:bg-slate-800 justify-start items-center px-2 py-1.5">
19
+ <AuthorityAvatar :address="address" class="w-[18px] h-[18px]" />
20
+ <Tippy max-width="none" interactive>
21
+ <template #default>
22
+ <p class="text-xs leading-5 text-slate-500 dark:text-slate-400">
23
+ {{ shortenHash(address, compact ? 2 : 4) }}
24
+ </p>
25
+ </template>
26
+ <template #content>
27
+ {{ address }}
28
+ </template>
29
+ </Tippy>
30
+ </div>
31
+ </div>
32
+ <div v-else class="flex gap-2 flex-wrap items-center">
33
+ <div v-for="address of [metadata.addresses[0], metadata.addresses[1]].filter(Boolean)" :key="address" class="flex gap-2 rounded-full bg-slate-100 dark:bg-slate-800 justify-start items-center px-2 py-1.5">
34
+ <AuthorityAvatar :address="address" class="w-[18px] h-[18px]" />
35
+
36
+ <Tippy max-width="none" interactive>
37
+ <template #default>
38
+ <p class="text-xs leading-5 text-slate-400">
39
+ {{ shortenHash(address, 2) }}
40
+ </p>
41
+ </template>
42
+ <template #content>
43
+ {{ address }}
44
+ </template>
45
+ </Tippy>
46
+ </div>
47
+
48
+ <Tippy max-width="none" interactive tag="button" content-tag="div" content-class="content-wrapper">
49
+ <template #default>
50
+ <Info2 class="w-[16px] h-[16px] text-slate-500 rounded-full" />
51
+ </template>
52
+ <template #content>
53
+ <ul class="flex flex-col gap-2.5">
54
+ <li v-for="address in metadata.addresses" :key="address" class="flex text-xs text-slate-400 items-center gap-2.5">
55
+ <AuthorityAvatar class="shrink-0 w-5 h-5" :address="address" />
56
+ {{ address }}
57
+ </li>
58
+ </ul>
59
+ </template>
60
+ </Tippy>
61
+ </div>
62
+ </div>
63
+ </template>
@@ -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