-
Notifications
You must be signed in to change notification settings - Fork 99
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
Jeesun Kim
authored and
Jeesun Kim
committed
Mar 13, 2024
1 parent
d915bc8
commit 023d01d
Showing
6 changed files
with
259 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Button, Icon, Input } from "@stellar/design-system"; | ||
import { Keypair } from "stellar-sdk"; | ||
import { useStore } from "@/store/useStore"; | ||
|
||
export const GenerateKeypair = () => { | ||
const { account } = useStore(); | ||
|
||
const generateKeypair = () => { | ||
let keypair = Keypair.random(); | ||
|
||
account.updateKeypair({ | ||
publicKey: keypair.publicKey(), | ||
secretKey: keypair.secret(), | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="Account__keypair"> | ||
<Button size="md" variant="tertiary" onClick={generateKeypair}> | ||
Generate keypair | ||
</Button> | ||
|
||
{account.keypair.publicKey && ( | ||
<Input | ||
readOnly | ||
id="generate-keypair-publickey" | ||
fieldSize="md" | ||
label="Public Key" | ||
value={account.keypair.publicKey} | ||
rightElement={ | ||
<Icon.Copy01 | ||
onClick={() => { | ||
navigator.clipboard.writeText(account.keypair.publicKey); | ||
}} | ||
/> | ||
} | ||
/> | ||
)} | ||
{account.keypair.secretKey && ( | ||
<Input | ||
readOnly | ||
id="generate-keypair-secretkey" | ||
fieldSize="md" | ||
label="Secret Key" | ||
value={account.keypair.secretKey} | ||
rightElement={ | ||
<Icon.Copy01 | ||
onClick={() => { | ||
navigator.clipboard.writeText(account.keypair.secretKey); | ||
}} | ||
/> | ||
} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; |
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.