1
1
<script lang =" ts" >
2
2
import Button from " $lib/components/ui/Button.svelte"
3
3
import TokenComponent from " $lib/components/model/TokenComponent.svelte"
4
- import { Effect , Match , Option } from " effect"
4
+ import { Effect , Match , Option , Array , Struct } from " effect"
5
5
import { lockedTransferStore } from " ../locked-transfer.svelte.ts"
6
6
import { ApprovalRequired } from " ../transfer-step.ts"
7
7
import { createViemPublicClient } from " @unionlabs/sdk/evm"
@@ -20,6 +20,7 @@ import {
20
20
} from " $lib/components/Transfer/state/cosmos.ts"
21
21
import { getWalletClient } from " $lib/services/evm/clients.ts"
22
22
import Label from " $lib/components/ui/Label.svelte"
23
+ import { is } from " ../transfer-step.ts"
23
24
24
25
type Props = {
25
26
stepIndex: number
@@ -32,18 +33,15 @@ const { stepIndex, onBack, onApprove, actionButtonText }: Props = $props()
32
33
33
34
const lts = lockedTransferStore .get ()
34
35
35
- // Get the step data from the locked transfer store
36
- const step: Option .Option <ReturnType <typeof ApprovalRequired >> = $derived .by (() => {
37
- if (Option .isNone (lts )) return Option .none ()
38
-
39
- const steps = lts .value .steps
40
- if (stepIndex < 0 || stepIndex >= steps .length ) return Option .none ()
41
-
42
- const step = steps [stepIndex ]
43
- return step ._tag === " ApprovalRequired" ? Option .some (step ) : Option .none ()
44
- })
36
+ const step = $derived (
37
+ lts .pipe (
38
+ Option .map (Struct .get (" steps" )),
39
+ Option .flatMap (Array .get (stepIndex )),
40
+ Option .filter (is (" ApprovalRequired" ))
41
+ )
42
+ )
45
43
46
- const sourceChain = $derived (lts .pipe (Option .map (ltss => ltss . sourceChain )))
44
+ const sourceChain = $derived (lts .pipe (Option .map (Struct . get ( " sourceChain" ) )))
47
45
48
46
let ets = $state <TransactionSubmissionEvm >(TransactionSubmissionEvm .Filling ())
49
47
let cts = $state <TransactionSubmissionCosmos >(TransactionSubmissionCosmos .Filling ())
0 commit comments