-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,742 additions
and
503 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {Box, Text} from 'ink'; | ||
import {TextInput} from '@inkjs/ui'; | ||
|
||
import {useBridgeWizardStore} from '@/bridge-wizard/bridgeWizardStore'; | ||
import {useState} from 'react'; | ||
import {isAddress} from 'viem'; | ||
import {zodAddress} from '@/validators/schemas'; | ||
|
||
export const EnterRecipient = () => { | ||
const {submitEnterRecipient} = useBridgeWizardStore(); | ||
|
||
const [errorMessage, setErrorMessage] = useState<string>(''); | ||
const [resetKey, setResetKey] = useState(0); | ||
|
||
return ( | ||
<Box flexDirection="column"> | ||
<Box> | ||
<Text>Enter the recipient address:</Text> | ||
</Box> | ||
<TextInput | ||
key={resetKey} | ||
onSubmit={address => { | ||
if (!isAddress(address)) { | ||
setErrorMessage('Invalid address: must start with 0x'); | ||
setResetKey(prev => prev + 1); | ||
return; | ||
} | ||
|
||
const result = zodAddress.safeParse(address); | ||
|
||
if (!result.success) { | ||
setErrorMessage(result.error.message); | ||
setResetKey(prev => prev + 1); | ||
return; | ||
} | ||
|
||
submitEnterRecipient({recipient: result.data}); | ||
}} | ||
/> | ||
{errorMessage && ( | ||
<Box> | ||
<Text color="red">{errorMessage ? `❌ ${errorMessage}` : ' '}</Text> | ||
</Box> | ||
)} | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.