mirror of https://github.com/certusone/oyster.git
fix: set inital asset
This commit is contained in:
parent
730777f732
commit
65dc091760
|
@ -8,7 +8,7 @@ import { ASSET_CHAIN } from '../../models/bridge/constants';
|
|||
|
||||
const { Option } = Select;
|
||||
|
||||
export function EthereumInput(props: {
|
||||
export function Input(props: {
|
||||
title: string;
|
||||
balance?: number;
|
||||
asset?: string;
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
programIds,
|
||||
formatAmount,
|
||||
} from '@oyster/common';
|
||||
import { EthereumInput } from './../Input';
|
||||
import { Input } from './../Input';
|
||||
|
||||
import './style.less';
|
||||
import { ASSET_CHAIN, chainToName } from '../../utils/assets';
|
||||
|
@ -41,11 +41,19 @@ export const Transfer = () => {
|
|||
const { wallet } = useWallet();
|
||||
const { provider, tokenMap, tokens } = useEthereum();
|
||||
const [request, setRequest] = useState<TransferRequest>({
|
||||
asset: tokens?.[0]?.address,
|
||||
from: ASSET_CHAIN.Ethereum,
|
||||
toChain: ASSET_CHAIN.Solana,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if(tokens && !request.asset) {
|
||||
setRequest({
|
||||
...request,
|
||||
asset: tokens?.[0]?.address,
|
||||
});
|
||||
}
|
||||
}, [request, tokens, setRequest])
|
||||
|
||||
const setAssetInformation = async (asset: string) => {
|
||||
setRequest({
|
||||
...request,
|
||||
|
@ -110,7 +118,7 @@ export const Transfer = () => {
|
|||
return (
|
||||
<>
|
||||
<div className="exchange-card">
|
||||
<EthereumInput
|
||||
<Input
|
||||
title={`From ${chainToName(request.from)}`}
|
||||
asset={request.asset}
|
||||
chain={request.from}
|
||||
|
@ -140,7 +148,7 @@ export const Transfer = () => {
|
|||
>
|
||||
⇅
|
||||
</Button>
|
||||
<EthereumInput
|
||||
<Input
|
||||
title={`To ${chainToName(request.toChain)}`}
|
||||
asset={request.asset}
|
||||
chain={request.toChain}
|
||||
|
|
Loading…
Reference in New Issue