diff --git a/app/src/lib/components/TransferFrom/components/Cube/FaceWrapper.svelte b/app/src/lib/components/TransferFrom/components/Cube/FaceWrapper.svelte
index 05e44ff759..531d6b86f9 100644
--- a/app/src/lib/components/TransferFrom/components/Cube/FaceWrapper.svelte
+++ b/app/src/lib/components/TransferFrom/components/Cube/FaceWrapper.svelte
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/lib/components/TransferFrom/components/Cube/faces/Assets.svelte b/app/src/lib/components/TransferFrom/components/Cube/faces/Assets.svelte
index d44299c058..c4c10ca611 100644
--- a/app/src/lib/components/TransferFrom/components/Cube/faces/Assets.svelte
+++ b/app/src/lib/components/TransferFrom/components/Cube/faces/Assets.svelte
@@ -4,6 +4,11 @@
import type {Readable} from "svelte/store";
import type {ContextStore} from "$lib/components/TransferFrom/transfer/context.ts";
import type {CubeFaces} from "$lib/components/TransferFrom/types.ts";
+ import {showUnsupported} from "$lib/stores/user.ts";
+ import {getSupportedAsset} from "$lib/utilities/helpers.ts";
+ import {truncate} from "$lib/utilities/format.ts";
+ import {formatUnits} from "viem";
+ import {Button} from "$lib/components/ui/button";
interface Props {
stores: {
@@ -17,7 +22,41 @@
export let stores: Props["stores"]
export let rotateTo: Props["rotateTo"]
- $: ({intents, validation, context} = stores)
+ let {intents, validation, context} = stores
+
+ function setAsset(address: string) {
+ intents.updateField('asset', address)
+ rotateTo("intentFace")
+ }
+
- rotateTo("intentFace")}>Select asset
\ No newline at end of file
+
+
+ {#each $context.balances as asset}
+ {@const supportedAsset = getSupportedAsset($context.sourceChain, asset.address)}
+ {#if $showUnsupported || supportedAsset}
+
+
setAsset(asset.address)}
+ >
+
+ {truncate((supportedAsset?.display_symbol || asset?.symbol || ''), 6) || 'Unknown symbol'}
+
+
+ {formatUnits(asset.balance, supportedAsset?.decimals ?? 0)}
+
+
+
+ {/if}
+ {/each}
+
+
+
+ rotateTo("intentFace")} class="w-full">
+ Back
+
+
+
diff --git a/app/src/lib/components/TransferFrom/components/Cube/faces/Chains.svelte b/app/src/lib/components/TransferFrom/components/Cube/faces/Chains.svelte
index f83fdc7bc7..2c165ce769 100644
--- a/app/src/lib/components/TransferFrom/components/Cube/faces/Chains.svelte
+++ b/app/src/lib/components/TransferFrom/components/Cube/faces/Chains.svelte
@@ -4,6 +4,9 @@
import type {Readable} from "svelte/store";
import type {ContextStore} from "$lib/components/TransferFrom/transfer/context.ts";
import type {CubeFaces} from "$lib/components/TransferFrom/types.ts";
+ import {Button} from "$lib/components/ui/button";
+ import {truncate} from "$lib/utilities/format.ts";
+ import {formatUnits} from "viem";
interface Props {
stores: {
@@ -12,17 +15,31 @@
context: Readable
}
rotateTo: (face: CubeFaces) => void
- select: "source" | "destination"
+ selected: "source" | "destination"
}
- export let stores: Props["stores"]
- export let rotateTo: Props["rotateTo"]
- export let select: Props["select"]
+ export let stores: Props["stores"];
+ export let rotateTo: Props["rotateTo"];
+ export let selected: Props["selected"];
- $: ({intents, validation, context} = stores)
+ $: ({intents, validation, context} = stores);
+
+ function setChain(selected: "source" | "destination", chainId: string) {
+ intents.updateField(selected, chainId);
+ console.log(selected, chainId);
+ rotateTo("intentFace");
+ }
-Select chain
-{#each $context.chains as chain}
- rotateTo("intentFace")}>{chain.display_name}
-{/each}
\ No newline at end of file
+
+
+ {#each $context.chains as chain}
+ setChain(selected, chain.chain_id)}
+ >{chain.display_name}
+
+ {/each}
+
+
rotateTo("intentFace")}>Back
+
diff --git a/app/src/lib/components/TransferFrom/components/Cube/faces/Intent.svelte b/app/src/lib/components/TransferFrom/components/Cube/faces/Intent.svelte
index cb7b0ffabb..6481bbd0f2 100644
--- a/app/src/lib/components/TransferFrom/components/Cube/faces/Intent.svelte
+++ b/app/src/lib/components/TransferFrom/components/Cube/faces/Intent.svelte
@@ -1,6 +1,6 @@
-
+
-
+
diff --git a/app/src/lib/components/TransferFrom/transfer/context.ts b/app/src/lib/components/TransferFrom/transfer/context.ts
index e521329631..883f96f2d0 100644
--- a/app/src/lib/components/TransferFrom/transfer/context.ts
+++ b/app/src/lib/components/TransferFrom/transfer/context.ts
@@ -8,32 +8,24 @@ import type { Chain, UserAddresses } from "$lib/types"
import { useQueryClient } from "@tanstack/svelte-query"
import type { Address } from "$lib/wallet/types"
-export type AddressBalance = {
+type BalanceRecord = {
balance: bigint
gasToken: boolean
address: Address
symbol: string
}
-export type NamedBalance = {
- balance: bigint
- address: string
- name: string | null
- symbol: string
- gasToken: boolean
-}
-
-export type EmptyBalance = {}
-
-export type Balance = AddressBalance | NamedBalance | EmptyBalance
+type BalancesList = BalanceRecord[]
export interface ContextStore {
chains: Array
userAddress: UserAddresses
- sourceChain: Chain | undefined
+ sourceChain: Chain
destinationChain: Chain | undefined
- balances: Array
- assetInfo: Balance | undefined
+ // Changed from Array to just BalancesList
+ balances: BalancesList
+ // Changed from BalancesStore to single BalanceRecord
+ assetInfo: BalanceRecord | undefined
}
export function createContextStore(intents: IntentStore): Readable {
@@ -47,19 +39,20 @@ export function createContextStore(intents: IntentStore): Readable
return (filter ? data.filter(filter) : data) as T
}
- // Chain data
const chains = queryData>(["chains"], chain => chain.enabled_staging)
- // User address data
const userAddress = derived(
[userAddrCosmos, userAddrEvm, userAddressAptos],
([cosmos, evm, aptos]) => ({ evm, aptos, cosmos })
) as Readable
- // Chain selections
- const sourceChain = derived(intents, intentsValue =>
- chains.find(chain => chain.chain_id === intentsValue.source)
- )
+ const sourceChain = derived(intents, intentsValue => {
+ const chain = chains.find(chain => chain.chain_id === intentsValue.source)
+ if (!chain) {
+ throw new Error(`No chain found for source ${intentsValue.source}`)
+ }
+ return chain
+ })
const destinationChain = derived(intents, intentsValue =>
chains.find(chain => chain.chain_id === intentsValue.destination)
@@ -88,7 +81,7 @@ export function createContextStore(intents: IntentStore): Readable
balance: BigInt(balance.balance)
}))
}
- )
+ ) as Readable
const assetInfo = derived([balances, intents], ([balancesValue, intentsValue]) =>
balancesValue.find(x => x?.address === intentsValue.asset)
@@ -105,4 +98,4 @@ export function createContextStore(intents: IntentStore): Readable
assetInfo: $assetInfo
})
)
-}
+}
\ No newline at end of file
diff --git a/app/src/lib/components/TransferFrom/transfer/validation.ts b/app/src/lib/components/TransferFrom/transfer/validation.ts
index 684086b4b6..e9451dfe06 100644
--- a/app/src/lib/components/TransferFrom/transfer/validation.ts
+++ b/app/src/lib/components/TransferFrom/transfer/validation.ts
@@ -111,7 +111,6 @@ export function createValidationStore(
}
const errors: FieldErrors = {}
- //Example
if (formFields.source && formFields.destination && formFields.source === formFields.destination) {
errors.destination = "Source and destination chains must be different"
}
diff --git a/app/src/lib/queries/balance/index.ts b/app/src/lib/queries/balance/index.ts
index 3aea0d924d..bf355cf543 100644
--- a/app/src/lib/queries/balance/index.ts
+++ b/app/src/lib/queries/balance/index.ts
@@ -9,15 +9,7 @@ import type { Chain, UserAddresses } from "$lib/types.ts"
import { getBalancesFromAlchemy } from "./evm/alchemy.ts"
import { getBalancesFromRoutescan } from "./evm/routescan.ts"
-export function userBalancesQuery({
- userAddr,
- chains,
- connected = true
-}: {
- userAddr: UserAddresses
- chains: Array
- connected?: boolean
-}) {
+export function userBalancesQuery({userAddr, chains, connected = true}: { userAddr: UserAddresses, chains: Array, connected?: boolean }) {
return createQueries({
queries: chains.map(chain => ({
queryKey: [