@instadapp/avocado-base 0.0.0-dev.8d2b9ac → 0.0.0-dev.8ed8fca

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.
@@ -1,56 +1,26 @@
1
1
  <script setup lang="ts">
2
- import CopySVG from '~/assets/images/icons/copy.svg'
3
- import CheckCircle from '~/assets/images/icons/check-circle.svg'
2
+ import CopySVG from '../assets/images/icons/copy.svg'
3
+ import CheckSVG from '../assets/images/icons/check-circle.svg'
4
4
 
5
5
  defineProps<{
6
6
  text: string
7
- iconOnly?: boolean
8
- successText?: string
9
7
  }>()
10
8
  const { copy, copied } = useClipboard()
11
- const slots = useSlots()
12
9
  </script>
13
10
 
14
11
  <template>
15
- <button
16
- class="text-slate-400 font-semibold inline-flex items-center gap-2.5"
17
- @click.stop="copy(text)"
18
- >
19
- <Transition mode="out-in" name="slide-left">
20
- <span v-if="copied && !iconOnly"> {{ successText || 'Copied' }} </span>
21
- <span v-else-if="slots.content">
22
- <slot name="content" />
23
- </span>
24
- </Transition>
25
-
12
+ <button type="button" class="inline-flex copy-btn" @click.stop="copy(text)">
26
13
  <Transition mode="out-in" name="slide">
27
- <CheckCircle
28
- v-if="copied"
29
- class="w-4 h-4 shrink-0 dark:text-slate-900 text-white svg-circle"
30
- />
31
- <slot v-else-if="slots.copy" name="copy" />
32
- <slot v-else name="copy-icon">
33
- <CopySVG />
34
- </slot>
14
+ <CheckSVG v-if="copied" v-tippy="{ content: 'Copied!' }" class="svg-circle text-slate-850 size-[1em]" />
15
+ <CopySVG v-else v-tippy="{ content: 'Copy Address' }" class="text-slate-400 size-[1em]" />
35
16
  </Transition>
36
17
  </button>
37
18
  </template>
38
19
 
39
20
  <style scoped>
40
- .slide-left-enter-active,
41
- .slide-left-leave-active {
42
- transition: all 0.1s ease-out;
43
- }
44
-
45
- .slide-left-enter-from {
46
- opacity: 0;
47
- transform: translateX(30px);
48
- }
49
-
50
- .slide-left-leave-to {
51
- opacity: 0;
52
- transform: translateX(-30px);
53
- }
21
+ .copy-btn:focus:not(:focus-visible) {
22
+ outline: none;
23
+ }
54
24
 
55
25
  .slide-enter-active,
56
26
  .slide-leave-active {
@@ -61,4 +31,12 @@ const slots = useSlots()
61
31
  .slide-leave-to {
62
32
  opacity: 0;
63
33
  }
34
+
35
+ .svg-circle > path:first-child {
36
+ @apply stroke-gray-400 fill-gray-400;
37
+ }
38
+
39
+ .svg-circle.darker > path:first-child {
40
+ @apply fill-gray-700 stroke-none text-gray-500;
41
+ }
64
42
  </style>
@@ -20,9 +20,17 @@ const fromToken = asyncComputed(() => {
20
20
  );
21
21
  });
22
22
 
23
- 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(() =>
24
32
  formatDecimal(
25
- fromWei(props.metadata?.amount, fromToken?.value?.decimals).toFixed()
33
+ fromWei(props.metadata?.amount, toToken?.value?.decimals).toFixed()
26
34
  )
27
35
  );
28
36
  </script>
@@ -36,7 +44,7 @@ const formattedFromAmount = computed(() =>
36
44
  <span v-if="!compact" class="capitalize text-xs sm:text-sm">Cross-chain send</span>
37
45
  <span class="inline-flex gap-2.5 items-center">
38
46
  <img width="20" height="20" class="w-5 h-5" :src="fromToken?.logo_url" />
39
- {{ formattedFromAmount }}
47
+ {{ formattedToAmount }}
40
48
  <span class="uppercase">{{ fromToken?.symbol }}</span>
41
49
  </span>
42
50
  </div>
@@ -1,45 +1,19 @@
1
1
  <script setup lang="ts">
2
- import { Tippy } from 'vue-tippy'
3
- const props = defineProps<{
2
+ defineProps<{
3
+ chain_id: number | string
4
4
  metadata: {
5
- type: MetadataTypes,
5
+ type: MetadataTypes
6
6
  [key: string]: any
7
- };
8
- compact?: boolean;
9
- }>();
7
+ }
8
+ compact?: boolean
9
+ }>()
10
10
  </script>
11
11
 
12
12
  <template>
13
- <div>
14
- <div v-if="!compact || metadata.addresses.length < 3" class="flex gap-[14px] flex-wrap">
15
- <div v-for="address of metadata.addresses" :key="address" class="flex gap-[8px] rounded-full bg-slate-50 dark:bg-gray-850 justify-start items-center px-[8px] py-[6px]">
16
- <AuthorityAvatar :address="address" class="w-[18px] h-[18px]" />
17
- <p class="text-xs leading-5">
18
- {{ shortenHash(address, compact ? 2 : 4) }}
19
- </p>
20
- </div>
21
- </div>
22
- <div v-else class="flex gap-2 flex-wrap items-center">
23
- <div v-for="address of [metadata.addresses[0], metadata.addresses[1]]" :key="address" class="flex gap-[8px] rounded-full bg-slate-50 dark:bg-gray-850 justify-start items-center px-[8px] py-[6px]">
24
- <AuthorityAvatar :address="address" class="w-[18px] h-[18px]" />
25
- <p class="text-xs leading-5">
26
- {{ shortenHash(address, 2) }}
27
- </p>
28
- </div>
29
- ...
30
- <Tippy max-width="none" interactive tag="button" content-tag="div" content-class="content-wrapper">
31
- <template #default>
32
- <SvgoInfo2 class="w-[16px] h-[16px] text-slate-500 rounded-full" />
33
- </template>
34
- <template #content>
35
- <ul class="flex flex-col gap-2.5">
36
- <li v-for="address in metadata.addresses" :key="address" class="flex text-xs items-center gap-2.5">
37
- <AuthorityAvatar class="shrink-0 w-5 h-5" :address="address" />
38
- {{ address }}
39
- </li>
40
- </ul>
41
- </template>
42
- </Tippy>
43
- </div>
44
- </div>
13
+ <ul class="flex gap-2 flex-wrap">
14
+ <li v-for="address in metadata.addresses" :key="address" class="flex rounded-2xl gap-2 bg-gray-900 w-fit items-center py-1.5 px-2.5">
15
+ <AuthorityAvatar class="size-5" :address="address" />
16
+ <Address hide-contact hide-copy :address="address" />
17
+ </li>
18
+ </ul>
45
19
  </template>
@@ -1,74 +1,66 @@
1
1
  <script setup lang="ts">
2
-
3
2
  const props = defineProps<{
4
- metadata: any;
3
+ metadata: any
5
4
  chain_id: number | string
6
- }>();
5
+ }>()
7
6
 
8
- const compact = inject('compact');
9
- const tokens = inject<ITokenPrice[]>('tokens');
7
+ const compact = inject('compact')
8
+ const tokens = inject<ITokenPrice[]>('tokens')
10
9
 
11
- const buyToken = asyncComputed(() =>
12
- {
13
- if (Array.isArray(tokens) && !tokens.length) return null;
14
- return fetchTokenByAddress(props.metadata?.buyToken, props?.chain_id, tokens)
15
- }
16
- );
17
- const sellToken = asyncComputed(() =>
18
- {
19
- if (Array.isArray(tokens) && !tokens.length) return null;
20
- return fetchTokenByAddress(props.metadata?.sellToken, props?.chain_id, tokens)
21
- }
22
- );
10
+ const buyToken = asyncComputed(() => {
11
+ if (Array.isArray(tokens) && !tokens.length)
12
+ return null
13
+ return fetchTokenByAddress(props.metadata?.buyToken, props?.chain_id, tokens)
14
+ },
15
+ )
16
+ const sellToken = asyncComputed(() => {
17
+ if (Array.isArray(tokens) && !tokens.length)
18
+ return null
19
+ return fetchTokenByAddress(props.metadata?.sellToken, props?.chain_id, tokens)
20
+ },
21
+ )
23
22
 
24
23
  const sellAmountFormatted = computed(() =>
25
24
  formatDecimal(
26
- fromWei(props.metadata?.sellAmount, sellToken?.value?.decimals).toFixed()
27
- )
28
- );
25
+ fromWei(props.metadata?.sellAmount, sellToken?.value?.decimals).toFixed(),
26
+ ),
27
+ )
29
28
 
30
29
  const buyAmountFormatted = computed(() =>
31
30
  formatDecimal(
32
- fromWei(props.metadata?.buyAmount, buyToken?.value?.decimals).toFixed()
33
- )
34
- );
31
+ fromWei(props.metadata?.buyAmount, buyToken?.value?.decimals).toFixed(),
32
+ ),
33
+ )
35
34
 
36
- const formatProtocol = (protocol: string) => {
35
+ function formatProtocol(protocol: string) {
37
36
  return (
38
37
  new Map([
39
- ["1inch-v5", "1inch"],
40
- ["0x-v1", "0x"],
41
- ["paraswap-v5", "Paraswap"],
42
- ["kyber-v1", "Kyber Network"],
38
+ ['1inch-v5', '1inch'],
39
+ ['0x-v1', '0x'],
40
+ ['paraswap-v5', 'Paraswap'],
41
+ ['kyber-v1', 'Kyber Network'],
43
42
  ]).get(protocol) || protocol
44
- );
45
- };
46
-
47
-
43
+ )
44
+ }
48
45
  </script>
49
46
 
50
47
  <template>
51
48
  <div v-if="!sellToken || !buyToken" class="rounded-5 w-24 h-4 loading-box" />
52
- <div
53
- class="flex items-center gap-5"
54
- v-else
55
- >
56
- <span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
57
- <span class="inline-flex gap-2.5 items-center">
58
- <img width="20" height="20" class="w-5 h-5" :src="sellToken?.logo_url" />
59
- {{ sellAmountFormatted }}
60
- <span class="uppercase">{{ sellToken?.symbol }}</span>
61
- <SvgoRefresh class="w-4 h-4 text-slate-400 mx-2" />
62
- <img width="20" height="20" class="w-5 h-5" :src="buyToken?.logo_url" />
63
- {{ buyAmountFormatted }}
64
- <span class="uppercase">{{ buyToken?.symbol }}</span>
65
- <span
66
- class="capitalize hidden sm:flex items-center gap-2.5"
67
- v-if="metadata.protocol && !compact"
68
- >
69
- On <ProtocolLogo class="w-5 h-5" :name="metadata.protocol" />
70
- {{ formatProtocol(metadata.protocol) }}
71
- </span>
49
+ <div v-else class="flex items-center gap-5">
50
+ <span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
51
+ <span class="inline-flex gap-2.5 items-center">
52
+ <img width="20" height="20" class="w-5 h-5" :src="sellToken?.logo_url">
53
+ {{ sellAmountFormatted }}
54
+ <span class="uppercase">{{ sellToken?.symbol }}</span>
55
+ <SvgoRefresh class="w-4 h-4 text-slate-400 mx-2" />
56
+ <img width="20" height="20" class="w-5 h-5" :src="buyToken?.logo_url">
57
+ ~ {{ buyAmountFormatted }}
58
+ <span class="uppercase">{{ buyToken?.symbol }}</span>
59
+ <span v-if="metadata.protocol && !compact" class="capitalize hidden sm:flex items-center gap-2.5">
60
+ On
61
+ <ProtocolLogo class="w-5 h-5" :name="metadata.protocol" />
62
+ {{ formatProtocol(metadata.protocol) }}
72
63
  </span>
73
- </div>
64
+ </span>
65
+ </div>
74
66
  </template>
@@ -1,50 +1,48 @@
1
1
  <script setup lang="ts">
2
-
3
2
  const props = defineProps<{
4
- metadata: any;
3
+ metadata: any
5
4
  chain_id: number | string
6
- }>();
5
+ }>()
7
6
 
8
- const compact = inject('compact');
9
- const tokens = inject<ITokenPrice[]>('tokens');
7
+ const compact = inject('compact')
8
+ const tokens = inject<ITokenPrice[]>('tokens')
10
9
 
11
10
  const token = asyncComputed(() => {
12
- if (!props?.chain_id) return null;
11
+ if (!props?.chain_id)
12
+ return null
13
13
 
14
- if (Array.isArray(tokens) && !tokens.length) return null;
14
+ if (Array.isArray(tokens) && !tokens.length)
15
+ return null
15
16
 
16
17
  return fetchTokenByAddress(
17
18
  props.metadata?.token,
18
19
  props?.chain_id,
19
- tokens
20
- );
21
- });
20
+ tokens,
21
+ )
22
+ })
22
23
 
23
24
  const formattedAmount = computed(() =>
24
25
  formatDecimal(
25
- fromWei(props.metadata?.amount, token?.value?.decimals).toFixed()
26
- )
27
- );
26
+ fromWei(props.metadata?.amount, token?.value?.decimals).toFixed(),
27
+ ),
28
+ )
28
29
  </script>
29
30
 
30
31
  <template>
31
32
  <div v-if="!token" class="rounded-5 w-24 h-4 loading-box" />
32
- <div class="flex items-center gap-5" v-else>
33
+ <div v-else class="flex items-center gap-5">
33
34
  <span v-if="!compact" class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
34
35
  <span class="inline-flex gap-2.5 items-center">
35
- {{ formattedAmount }}
36
- <span class="uppercase">{{ token?.symbol }}</span>
37
- <img width="20" height="20" class="w-5 h-5" :src="token?.logo_url" />
38
- <SvgoArrowRight class="w-4 h-4 text-slate-400 mx-2" />
39
- <NuxtLink
40
- class="text-primary"
41
- target="_blank"
42
- external
43
- :to="
44
- getExplorerUrl(chain_id, `/address/${metadata.receiver}`)
45
- "
46
- >{{ shortenHash(metadata.receiver) }}
47
- </NuxtLink>
36
+ <span class="w-[8em]">
37
+ {{ formattedAmount }}
38
+ <span class="uppercase">{{ token?.symbol }}</span>
39
+ </span>
40
+ <img width="20" height="20" class="w-5 h-5" :src="token?.logo_url">
41
+ <SvgoArrowRight class="w-4 h-4 text-slate-400" />
42
+ <Address
43
+ :to="getExplorerUrl(chain_id, `/address/${metadata.receiver}`)"
44
+ :address="metadata.receiver"
45
+ />
48
46
  </span>
49
47
  </div>
50
48
  </template>