-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added utils tab and random key generator
- Loading branch information
Showing
4 changed files
with
93 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import ApiCard from './apiCard' | ||
|
||
const CreateRandomKeyPart = ({wasm, onResponse, onWaiting}) => { | ||
|
||
const clickFunction = () => { | ||
onWaiting(true) | ||
try { | ||
const wasmSK = wasm.Bip32PrivateKey.generate_ed25519_bip32(); | ||
const wasmPK = wasmSK.to_public(); | ||
const hash = wasmPK.to_raw_key().hash(); | ||
const cred = wasm.Credential.from_keyhash(hash); | ||
const mainnetAddress = wasm.EnterpriseAddress.new(1, cred).to_address().to_bech32(); | ||
const testnetAddress = wasm.EnterpriseAddress.new(0, cred).to_address().to_bech32(); | ||
onResponse({ | ||
privateKeyHex: wasmSK.to_raw_key().to_hex(), | ||
publicKeyHex: wasmPK.to_raw_key().to_hex(), | ||
pubKeyHash: hash.to_hex(), | ||
mainnetAddress, | ||
testnetAddress, | ||
}); | ||
} finally { | ||
onWaiting(false); | ||
} | ||
} | ||
|
||
return <ApiCard | ||
apiName="Random Key" | ||
clickFunction={clickFunction} | ||
/> | ||
} | ||
|
||
export default CreateRandomKeyPart |
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,52 @@ | ||
import React, {useState} from 'react' | ||
import useYoroi from '../../../hooks/yoroiProvider' | ||
import useWasm from '../../../hooks/useWasm' | ||
import ExperimentalPart from './experimentalPart' | ||
import ResponsesPart from './responsesPart' | ||
import OfficialPart from './officialPart' | ||
import {CONNECTED} from '../../../utils/connectionStates' | ||
import IsEnabledCard from '../../cards/isEnabledCard'; | ||
import GetNetworkIdCard from '../../cards/getNetworkIdCard'; | ||
import GetExtensionsCard from '../../cards/getExtensionsCard'; | ||
import GetBalanceCard from '../../cards/getBalanceCard'; | ||
import GetUnusedAddressesCard from '../../cards/getUnusedAddressCard'; | ||
import GetUsedAddresses from '../../cards/getUsedAddressCard'; | ||
import GetChangeAddressCard from '../../cards/getChangeAddressCard'; | ||
import GetRewardAddressesCard from '../../cards/getRewardAddressesCard'; | ||
import GetUtxosCard from '../../cards/getUtxosCard'; | ||
import GetCollateralUtxosCard from '../../cards/getCollateralUtxosCard'; | ||
import SignDataCard from '../../cards/signDataCard'; | ||
import BuildTransactionCard from '../../cards/buildTransactionCard'; | ||
import SignTransactionCard from '../../cards/signTransactionCard'; | ||
import SubmitTransactionCard from '../../cards/submitTransactionCard'; | ||
import CreateRandomKeyCard from '../../cards/createRandomKeyCard'; | ||
|
||
const UtilsTab = () => { | ||
const {api} = useYoroi() | ||
const wasm = useWasm() | ||
const [currentText, setCurrentText] = useState('') | ||
const [rawCurrentText, setRawCurrentText] = useState('') | ||
const [waiterState, setWaiterState] = useState(false) | ||
|
||
const setResponse = (response, stringifyIt = true) => { | ||
setCurrentText(stringifyIt ? JSON.stringify(response, undefined, 2) : response) | ||
} | ||
|
||
return ( | ||
<div className="py-5 px-5 text-gray-300"> | ||
<div className="grid grid-cols-3 gap-2"> | ||
<div className="grid justify-items-stretch grid-cols-1 lg:grid-cols-2 gap-2"> | ||
<div> | ||
<CreateRandomKeyCard | ||
wasm={wasm} | ||
onResponse={setResponse} | ||
onWaiting={setWaiterState} /> | ||
</div> | ||
</div> | ||
<ResponsesPart rawCurrentText={rawCurrentText} currentText={currentText} currentWaiterState={waiterState} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default UtilsTab |