diff --git a/src/components/appBox.tsx b/src/components/appBox.tsx
index 71219e6..855c41c 100644
--- a/src/components/appBox.tsx
+++ b/src/components/appBox.tsx
@@ -49,7 +49,7 @@ export default function AppBox() {
{
+ setTargetChain((prev) => chain ?? prev);
+ targetChainRef.current = chain ?? targetChainRef.current;
+ },
+ [setTargetChain],
+ );
+
+ useEffect(() => {
+ const options = availableTargetChainOptions[sourceChain.network]?.[sourceAsset.symbol] || [];
+ setTargetChainOptions(options);
+ _setTargetChain(options.at(0));
+ }, [sourceChain, sourceAsset, _setTargetChain]);
+
const _setSourceChain = useCallback(
(chain: ChainConfig | undefined) => {
setSourceChain((prev) => chain ?? prev);
@@ -26,6 +50,20 @@ export default function ChainSelectInput() {
},
[setSourceChain],
);
+
+ const _setSourceAsset = useCallback(
+ (asset: Asset | undefined) => {
+ setSourceAsset((prev) => asset ?? prev);
+ sourceAssetRef.current = asset ?? sourceAssetRef.current;
+ },
+ [setSourceAsset],
+ );
+
+ useEffect(() => {
+ const options = availableSourceAssetOptions[sourceChain.network] || [];
+ setSourceAssetOptions(options);
+ _setSourceAsset(options.at(0));
+ }, [sourceChain, _setSourceAsset]);
const [open, setOpen] = useState
(false);
return (
-
-
{sourceChain.name}
+
+
{who === "sender" ? sourceChain.name : targetChain.name}
{open && (
- {sourceChainOptions.map((item) => (
-
_setSourceChain(item)}>
-
-
{item.name}
-
- ))}
+ {who === "sender"
+ ? sourceChainOptions.map((item) => (
+
_setSourceChain(item)}>
+
+
{item.name}
+
+ ))
+ : targetChainOptions.map((item) => (
+
_setTargetChain(item)}>
+
+
{item.name}
+
+ ))}
)}