Skip to content

Commit e0a5c0c

Browse files
committed
feat(app): add loading state
1 parent 27234e7 commit e0a5c0c

File tree

5 files changed

+58
-26
lines changed

5 files changed

+58
-26
lines changed

app/src/lib/components/TransferFrom/components/Cube/faces/Intent.svelte

+18-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Address from "$lib/components/address.svelte"
1212
import type { Intents } from "$lib/components/TransferFrom/transfer/types.ts"
1313
import type { Chain } from "$lib/types.ts"
1414
import TokenBalance from "$lib/components/TransferFrom/components/TokenBalance.svelte"
15+
import InlineLoadingDots from "$lib/components/InlineLoadingDots.svelte"
1516
1617
interface Props {
1718
rawIntents: RawIntentsStore
@@ -26,6 +27,7 @@ export let intents: Props["intents"]
2627
export let validation: Props["validation"]
2728
export let chains: Props["chains"]
2829
export let rotateTo: Props["rotateTo"]
30+
$: console.log(intents.quoteToken)
2931
</script>
3032

3133
<div class="flex flex-col w-full h-full">
@@ -105,23 +107,28 @@ export let rotateTo: Props["rotateTo"]
105107
<div>
106108
{#if !intents.channel}
107109
<div class="flex justify-center">
108-
<p class="text-xs text-center max-w-[230px]">No recommended UCS03 channel to go from {toDisplayName($rawIntents.source, chains)}
109-
to {toDisplayName($rawIntents.destination, chains)}</p>
110+
<p class="text-xs text-center max-w-[230px]">
111+
No recommended UCS03 channel to go from {toDisplayName($rawIntents.source, chains)}
112+
to {toDisplayName($rawIntents.destination, chains)}
113+
</p>
110114
</div>
111115
{:else}
112116
<div class="flex flex-col gap-1 justify-end items-center">
113-
<div class="flex gap-4 text-muted-foreground text-xs">{intents.channel.source_connection_id}
114-
| {intents.channel.source_channel_id}
115-
<ArrowRightIcon/>{intents.channel.destination_connection_id} | {intents.channel.destination_channel_id}
117+
<div class="flex gap-4 text-muted-foreground text-xs">
118+
{intents.channel.source_connection_id} | {intents.channel.source_channel_id}
119+
<ArrowRightIcon /> {intents.channel.destination_connection_id} | {intents.channel.destination_channel_id}
116120
</div>
121+
117122
{#if !$rawIntents.asset}
118123
<p class="text-xs">Select an asset</p>
119124
{:else if !$rawIntents.source || !$rawIntents.destination}
120125
<p class="text-xs">Select source and destination</p>
121-
{:else if validation.args === "NO_QUOTE_AVAILABLE"}
122-
<div class="text-xs text-center">No Quote Token available for this transfer. Sending new assets to Cosmos is
123-
currently not supported and will be enabled in an update soon.
126+
{:else if intents.quoteToken === "NO_QUOTE_AVAILABLE"}
127+
<div class="text-xs text-center">
128+
No Quote Token available for this transfer. Sending new assets to Cosmos is currently not supported and will be enabled in an update soon.
124129
</div>
130+
{:else if intents.quoteToken === "QUOTE_LOADING"}
131+
<InlineLoadingDots />
125132
{:else if intents.quoteToken}
126133
<div class="flex-1 flex flex-col items-center text-xs">
127134
<Token chainId={$rawIntents.destination} denom={intents.quoteToken} {chains}/>
@@ -132,8 +139,10 @@ export let rotateTo: Props["rotateTo"]
132139
{/if}
133140
</div>
134141
{/if}
135-
<Button class="w-full mt-2" disabled={!validation.isValid} on:click={() => rotateTo("verifyFace")}>Transfer
142+
<Button class="w-full mt-2" disabled={!validation.isValid} on:click={() => rotateTo("verifyFace")}>
143+
Transfer
136144
</Button>
137145
</div>
146+
138147
</div>
139148
</div>

app/src/lib/components/TransferFrom/index.svelte

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const quoteToken: Readable<Nullable<QuoteData>> = derived<
7070
return
7171
}
7272
73+
set({ type: "QUOTE_LOADING" })
74+
7375
//@ts-ignore
7476
getQuoteToken($source, $asset, channel)
7577
.then(result => {

app/src/lib/components/TransferFrom/transfer/intents.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ export const createIntents = (
7979
}
8080

8181
const quoteTokenDenom =
82-
quoteToken && quoteToken.type === "NO_QUOTE_AVAILABLE"
83-
? "NO_QUOTE_AVAILABLE"
84-
: (quoteToken?.quote_token ?? null)
82+
quoteToken?.type === "QUOTE_LOADING"
83+
? "QUOTE_LOADING"
84+
: quoteToken?.type === "NO_QUOTE_AVAILABLE"
85+
? "NO_QUOTE_AVAILABLE"
86+
: (quoteToken?.quote_token ?? null)
8587

8688
console.log(
8789
`[QuoteToken] quote for ${baseToken?.denom} from ${sourceChain?.chain_id} -> ${destinationChain?.chain_id}:`,

app/src/lib/components/TransferFrom/transfer/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ export type QuoteTokenType = "UNWRAPPED" | "NEW_WRAPPED" | "NO_QUOTE_AVAILABLE"
5656
export type QuoteData =
5757
| { quote_token: string; type: Extract<QuoteTokenType, "UNWRAPPED" | "NEW_WRAPPED"> }
5858
| { type: Extract<QuoteTokenType, "NO_QUOTE_AVAILABLE"> }
59+
| { type: "QUOTE_LOADING" }

0 commit comments

Comments
 (0)