Skip to content

Transfer submission state machine and encoding fixes #4167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Apr 8, 2025
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e0070f4
feat(app2): wip - transfer state
Swepool Apr 4, 2025
43e8569
feat(app2): wip - transfer state
Swepool Apr 4, 2025
bb98b58
feat(app2): wip - transfer state
Swepool Apr 5, 2025
24c5aa5
feat(app2): wip - transfer state
Swepool Apr 5, 2025
3ef2234
feat(app2): wip - transfer state
Swepool Apr 5, 2025
b5f762c
fix(app2): hardcode channel for bob -> babylon
cor Apr 6, 2025
067ba28
fix(app2): timeout heights and hardcoded channels
cor Apr 7, 2025
9815960
fix(app2): use tokencomponent in transferasset
cor Apr 7, 2025
3204dc0
fix(app2): timeout height
Swepool Apr 7, 2025
b8802f9
fix(app2): better approval page
cor Apr 7, 2025
59adb15
fix(app2): cleanup approval page
cor Apr 7, 2025
0d38edd
fix(app2): cleanup submit page
cor Apr 7, 2025
b28a429
fix(app2): use transactionhashcomponent
cor Apr 7, 2025
31219ec
fix(app2): wip - cw20
Swepool Apr 7, 2025
ab90050
fix(app2): hardcoded fix for cw20
Swepool Apr 7, 2025
2229508
fix(app2): to hex
Swepool Apr 7, 2025
2d8924e
fix(app2): to hex
Swepool Apr 7, 2025
ce94af0
chore(ts-sdk): enable static analysis for examples/
ehegnes Apr 7, 2025
1c5cb46
chore(ts-sdk): fix examples/ imports
ehegnes Apr 7, 2025
ce3f0d1
fix(ts-sdk): fix examples/ type checking and deps
ehegnes Apr 7, 2025
2f54930
fix(ts-sdk): migrate examples/ to new Instruction ADT
ehegnes Apr 7, 2025
cbc054c
feat(ts-sdk): add bob -> babylon example
ehegnes Apr 7, 2025
efe567a
fix(ts-sdk,app2): bob -> babylon example; address formatting
ehegnes Apr 7, 2025
92ed07f
chore: cleanup example
ehegnes Apr 7, 2025
4749232
fix(ts-sdk): declare export type paths
ehegnes Apr 7, 2025
9002cfb
feat(ts-sdk): add corn -> babylon example
ehegnes Apr 8, 2025
1eac038
feat(app2): add WBTCN for corn (WETH)
cor Apr 8, 2025
6e4eb3f
fix(app2): disable hardcoded channels
cor Apr 8, 2025
0b26477
fix(app2): temporarily disable weth quote token
cor Apr 8, 2025
055ad8b
fix(app2): filter bitcoin chains
cor Apr 8, 2025
0a8335f
fix(app2): fix approvalpage denom formatting
ehegnes Apr 8, 2025
b05a789
fix(app2): from chain formatting
cor Apr 8, 2025
58b111d
feat(app2): looping background video
cor Apr 8, 2025
b033571
feat(app2): btc edition styling
cor Apr 8, 2025
0eda2d0
fix(app2): approval denom display formatting
ehegnes Apr 8, 2025
e00f8a9
feat(app2): copy url button in header
cor Apr 8, 2025
57987c9
feat(app2): packethashcomponent and cleanup
cor Apr 8, 2025
e119f08
fix(app2): remove faucet
cor Apr 8, 2025
ff0bb7c
chore(app2,ts-sdk): fix nix fmt
ehegnes Apr 8, 2025
396de50
fix(ts-sdk): preserve promise type, overriding linter
ehegnes Apr 8, 2025
c4bad66
chore: fmt
cor Apr 8, 2025
eace82e
fix(ts-sdk): fao test case
ehegnes Apr 8, 2025
4b3221e
fix(app2,ts-sdk): flake derivation deps hash
ehegnes Apr 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 64 additions & 5 deletions app/src/generated/graphql-env.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app2/app2.nix
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ _: {
../typescript-sdk
../ts-sdk
];
hash = "sha256-5ha02SZhT3J7I+KFphc1KdcpMbJb5UHa3oUlyiXduqU=";
hash = "sha256-v5h5l2fwD01PlcrSzKWIk6swc3m6wqgjDzbti3DnAxI=";
buildInputs = deps;
nativeBuildInputs = buildInputs;
pnpmWorkspaces = [
1 change: 1 addition & 0 deletions app2/src/app.css
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@

@theme {
--color-zinc-925: oklch(0.1755 0.0055 285.854);
--color-babylon-orange: #cf6533;
--color-union: oklch(0.84 0.1281 215.6);
--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", "Courier New", monospace;
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ async function toggleSearch() {
<div class="flex flex-col gap-1 p-2 pb-16">
{#each filteredTokens as token}
{#key token.denom}
<TransferAsset {token} {selectAsset} />
<TransferAsset chain={transfer.sourceChain.value} {token} {selectAsset} />
{/key}
{/each}
</div>
@@ -145,4 +145,4 @@ async function toggleSearch() {
</button>
</div>
</div>
</div>
</div>
23 changes: 19 additions & 4 deletions app2/src/lib/components/Transfer/ChainAsset/ChainSelector.svelte
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import { tokensStore } from "$lib/stores/tokens.svelte.ts"
import { transfer } from "$lib/components/Transfer/transfer.svelte.ts"
import type { Chain } from "@unionlabs/sdk/schema"
import { chainLogoMap } from "$lib/constants/chain-logos.ts"
import { Array as Arr } from "effect"

type Props = {
type: "source" | "destination"
@@ -29,12 +30,26 @@ function selectChain(chain: Chain) {

onSelect()
}

// For btc.union.build, only show bitcoin chains
const filteredChains = $derived(
chains.data.pipe(
Option.map(
Arr.filter(c =>
["corn.21000001", "bob.60808", "bob.808813", "babylon.bbn-test-5"].includes(
c.universal_chain_id
)
)
)
)
)
</script>

<div class="p-4">
{#if Option.isSome(chains.data)}
{#if Option.isSome(filteredChains)}
{@const chainss = filteredChains.value}
<div class="grid grid-cols-3 gap-2">
{#each chains.data.value as chain}
{#each chainss as chain}
{@const isSelected = (type === "source" && transfer.raw.source === chain.chain_id) ||
(type === "destination" && transfer.raw.destination === chain.chain_id)}
{@const isDisabled = type === "destination" && transfer.raw.source === chain.chain_id}
@@ -63,7 +78,7 @@ function selectChain(chain: Chain) {
<span class="text-xs text-center truncate w-fit">{chain.display_name}</span>

{#if isDisabled}
<span class="text-xs text-sky-400">From chain</span>
<span class="text-xs text-sky-400 -mt-2">From Chain</span>
{/if}
</button>
{/each}
@@ -73,4 +88,4 @@ function selectChain(chain: Chain) {
<span class="inline-block animate-pulse">Loading chains...</span>
</div>
{/if}
</div>
</div>
48 changes: 12 additions & 36 deletions app2/src/lib/components/Transfer/ChainAsset/TransferAsset.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<script lang="ts">
import { cn } from "$lib/utils/index.js"
import { transfer } from "$lib/components/Transfer/transfer.svelte.js"
import type { Chain, Token } from "@unionlabs/sdk/schema"
import { TokenRawAmount, type Chain, type Token } from "@unionlabs/sdk/schema"
import { Option } from "effect"
import Skeleton from "$lib/components/ui/Skeleton.svelte"
import { formatUnits } from "viem"
import { chains } from "$lib/stores/chains.svelte.ts"
import SharpArrowLeft from "$lib/components/icons/SharpArrowLeft.svelte"
import TokenComponent from "$lib/components/model/TokenComponent.svelte"

type Props = {
token: Token
chain: Chain
selectAsset: (token: Token) => void
}

let { token, selectAsset }: Props = $props()
let { token, chain, selectAsset }: Props = $props()

let isSelected = $derived(transfer.raw.asset === token.denom)

@@ -23,19 +24,6 @@ let tokenBalance = $derived.by(() => {
return found ? Option.some(found) : Option.none()
})

let displayAmount = $derived.by(() => {
if (Option.isNone(tokenBalance)) return "0.00"

const balanceInfo = tokenBalance.value

if (Option.isNone(balanceInfo.balance)) return "0.00"

const decimals = balanceInfo.decimals || token.representations[0]?.decimals || 0

const balanceValue = Option.getOrElse(balanceInfo.balance, () => "0")
return formatUnits(BigInt(balanceValue), decimals)
})

let isLoading = $derived(Option.isSome(transfer.sortedBalances) && Option.isNone(tokenBalance))

export const toDisplayName = (
@@ -54,31 +42,19 @@ export const toDisplayName = (
selectAsset(token)
}}
>
<div class="flex items-center flex gap-1 items-center overflow-x-scroll text-sm text-zinc-200">
<div class="flex items-center gap-1 overflow-x-scroll text-sm text-zinc-200">
<div class="mr-1">
{#if isLoading}
<Skeleton class="h-3 w-16"/>
{:else if Option.isSome(tokenBalance) && Option.isSome(tokenBalance.value.error)}
<span class="text-red-400">Error</span>
{:else}
{displayAmount}
{:else if Option.isSome(tokenBalance)}
{#if Option.isSome(tokenBalance.value.balance)}
<TokenComponent {chain} denom={token.denom} amount={tokenBalance.value.balance.value} />
{:else}
<TokenComponent {chain} denom={token.denom} amount={TokenRawAmount.make(0n)} />
{/if}
{/if}
</div>
<div class="font-medium">
{token.representations[0]?.symbol ?? token.denom}
</div>
</div>
<div class="text-zinc-400 text-nowrap text-xs flex items-center gap-1">
{#if Option.isSome(chains.data)}
{#each token.wrapping as wrapping, i}
{#if i !== 0}
<SharpArrowLeft class="text-sky-300"/>
{/if}
{toDisplayName(
wrapping.unwrapped_chain.universal_chain_id,
chains.data.value,
)}
{/each}
{/if}
</div>
</button>
</button>
Loading