Skip to content

Commit

Permalink
fix: use token addr as value to fix broken list
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendan committed Nov 8, 2023
1 parent 93c448d commit 3e551c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
10 changes: 6 additions & 4 deletions packages/frontend/src/components/MultiStepForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ const MultiStepForm = () => {
[registeredSubnets, receivingSubnetId]
)

const { tokens: registeredTokens } = useRegisteredTokens(sendingSubnet)
const { tokens: registeredTokens, loading: registeredTokensLoading } =
useRegisteredTokens(sendingSubnet)

const tokenSymbol =
const tokenAddress =
Form.useWatch('token', form1) || form1.getFieldValue('token')

const token = useMemo(
() => registeredTokens?.find((t) => t.symbol === tokenSymbol),
[registeredTokens, tokenSymbol]
() => registeredTokens?.find((t) => t.addr === tokenAddress),
[registeredTokens, tokenAddress]
)

const recipientAddress =
Expand All @@ -113,6 +114,7 @@ const MultiStepForm = () => {
receivingSubnet,
recipientAddress,
registeredTokens,
registeredTokensLoading,
sendingSubnet,
token,
}}
Expand Down
16 changes: 7 additions & 9 deletions packages/frontend/src/components/steps/Step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const TransactionTypeSelector = styled(Segmented)`
margin-bottom: 1rem;
`

const { Option } = Select

const Step1 = ({ onFinish, onPrev }: StepProps) => {
const { data: registeredSubnets } = useContext(SubnetsContext)
const {
Expand All @@ -46,6 +44,7 @@ const Step1 = ({ onFinish, onPrev }: StepProps) => {
receivingSubnet,
recipientAddress,
registeredTokens,
registeredTokensLoading,
sendingSubnet,
token,
} = useContext(MultiStepFormContext)
Expand Down Expand Up @@ -168,6 +167,7 @@ const Step1 = ({ onFinish, onPrev }: StepProps) => {
>
<Select
size="middle"
loading={registeredTokensLoading}
dropdownRender={(menu) => (
<>
{menu}
Expand All @@ -177,13 +177,11 @@ const Step1 = ({ onFinish, onPrev }: StepProps) => {
</Space>
</>
)}
>
{registeredTokens?.map((token) => (
<Option key={token.symbol} value={token.symbol}>
{token.symbol}
</Option>
))}
</Select>
options={registeredTokens?.map(({ addr, symbol }) => ({
label: symbol,
value: addr,
}))}
/>
</Form.Item>
<Form.Item
name="receivingSubnet"
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/contexts/multiStepForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface MultiStepFormContext {
receivingSubnet?: SubnetWithId
recipientAddress?: string
registeredTokens?: Token[]
registeredTokensLoading?: boolean
sendingSubnet?: SubnetWithId
token?: Token
}
Expand Down

0 comments on commit 3e551c6

Please sign in to comment.