Skip to content

Commit

Permalink
fix(app): transfers clear asset on chain change
Browse files Browse the repository at this point in the history
  • Loading branch information
cor committed Jun 8, 2024
1 parent ca6fb64 commit 43e8b3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ $: if (
$cosmosStore.rawAddress?.length !== undefined &&
$cosmosStore.rawAddress?.length > 0
) {
console.log($cosmosChains)
cosmosBalances = cosmosBalancesQuery({
// https://stackoverflow.com/questions/77206461/type-guard-function-is-not-narrowing-the-type-in-array-filter
//@ts-ignore
Expand Down
16 changes: 14 additions & 2 deletions app/src/routes/transfer/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ $: if (
chains: $cosmosChains,
address: $cosmosStore.rawAddress
})
}
const queryParams = queryParameters(
Expand All @@ -89,7 +87,16 @@ const queryParams = queryParameters(
)
let unionClient: UnionClient
let prevFromChain = $queryParams["from-chain-id"];
onMount(() => {
queryParams.subscribe((params) => {
if (prevFromChain !== params["from-chain-id"]) {
prevFromChain = params["from-chain-id"];
params["asset"] = "";
}
});
const cosmosOfflineSigner = (
$cosmosStore.connectedWallet === "keplr"
? window?.keplr?.getOfflineSigner("union-testnet-8", {
Expand Down Expand Up @@ -117,6 +124,7 @@ onMount(() => {
// rpcUrl: 'https://rpc.testnet.bonlulu.uno',
rpcUrl: "https://union-testnet-rpc.polkachu.com"
})
})
let dialogOpenToken = false
Expand All @@ -135,6 +143,8 @@ $: {
let sendableBalances: null | Readable<Array<{balance: bigint, address: string, symbol: string, decimals: number}>> = null;
let subscribed = false;
$: if (queryParams && evmBalances && cosmosBalances && evmBalances !== null && cosmosBalances !== null && $cosmosChains !== null) {
sendableBalances = derived([queryParams, evmBalances, cosmosBalances], ([$queryParams, $evmBalances, $cosmosBalances]) => {
const fromChain = $queryParams["from-chain-id"];
Expand All @@ -155,6 +165,8 @@ $: if (queryParams && evmBalances && cosmosBalances && evmBalances !== null &&
return cosmosBalance.data.map((balance) => ({ ...balance, balance: BigInt(balance.balance)}))
});
}
Expand Down

0 comments on commit 43e8b3c

Please sign in to comment.