Skip to content

Commit

Permalink
fix(example): throw signing client
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki committed May 30, 2024
1 parent bffca2a commit 6b17397
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions example/starter/src/pages/send-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SendToken = () => {

const sendToken = async () => {
try {
if (!signingClient) throw new Error("signingClient is not ready");
const result = await sendTokensAsync({
signingClient,
recipientAddress: formData.recipientAddress,
Expand All @@ -56,20 +57,20 @@ const SendToken = () => {
description: (
<Box
as="button"
bg="green.700"
borderRadius={4}
color="white"
noOfLines={1}
onClick={() => {
void navigator.clipboard.writeText(result.transactionHash);
toast({
status: "success",
title: "coppied transactionHash to clipboard",
});
}}
bg="green.700"
py={1}
px={2}
py={1}
textAlign="left"
color="white"
borderRadius={4}
noOfLines={1}
wordBreak="break-all"
>
Copy transactionHash: {result.transactionHash}
Expand All @@ -85,70 +86,70 @@ const SendToken = () => {
};

return (
<Stack w="full" spacing={6}>
<Stack spacing={6} w="full">
<Heading>Send Token</Heading>
{isConnected ? (
<Stack spacing={4} as="form" onSubmit={handleSubmit}>
<Stack as="form" onSubmit={handleSubmit} spacing={4}>
<FormControl isRequired>
<FormLabel>Coin</FormLabel>
<Select
placeholder="Select option"
onChange={(event) =>
setFormData({
...formData,
coin: event.currentTarget.value,
})
}
placeholder="Select option"
value={formData.coin}
>
{activeChains?.[0]?.currencies.map((currency) => (
<option value={currency.coinMinimalDenom} key={currency.coinMinimalDenom}>
<option key={currency.coinMinimalDenom} value={currency.coinMinimalDenom}>
{currency.coinMinimalDenom}
</option>
))}
</Select>
</FormControl>
<FormControl>
<FormLabel>Sender address</FormLabel>
<Input type="text" value={accountData?.bech32Address ?? ""} isDisabled />
<Input isDisabled type="text" value={accountData?.bech32Address ?? ""} />
</FormControl>
<FormControl isRequired>
<FormLabel>Recipient address</FormLabel>
<Input
type="text"
onChange={(event) =>
setFormData({
...formData,
recipientAddress: event.currentTarget.value,
})
}
type="text"
/>
</FormControl>
<FormControl isRequired>
<FormLabel>Amount</FormLabel>
<Input
type="text"
onChange={(event) =>
setFormData({
...formData,
amount: event.currentTarget.value,
})
}
type="text"
/>
</FormControl>
<FormControl>
<FormLabel>Memo</FormLabel>
<Input
type="text"
onChange={(event) =>
setFormData({
...formData,
memo: event.currentTarget.value,
})
}
type="text"
/>
</FormControl>
<Button width="full" mt={4} type="submit" isLoading={isLoading}>
<Button isLoading={isLoading} mt={4} type="submit" width="full">
Send
</Button>
</Stack>
Expand Down

0 comments on commit 6b17397

Please sign in to comment.