diff --git a/pages/badges/create.tsx b/pages/badges/create.tsx index 8c3c7e4..32c9be4 100644 --- a/pages/badges/create.tsx +++ b/pages/badges/create.tsx @@ -17,8 +17,8 @@ import type { ImageUploadDetailsDataProps, MintRule } from 'components/badges/cr import { ImageUploadDetails } from 'components/badges/creation/ImageUploadDetails' import { Button } from 'components/Button' import { Conditional } from 'components/Conditional' -import { NumberInput, TextInput } from 'components/forms/FormInput' -import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks' +import { TextInput } from 'components/forms/FormInput' +import { useInputState } from 'components/forms/FormInput.hooks' import { Tooltip } from 'components/Tooltip' import { useContracts } from 'contexts/contracts' import { useWallet } from 'contexts/wallet' @@ -63,6 +63,7 @@ const BadgeCreationPage: NextPage = () => { const [createdBadgeKey, setCreatedBadgeKey] = useState(undefined) const [transactionHash, setTransactionHash] = useState(null) const [keyPairs, setKeyPairs] = useState<{ publicKey: string; privateKey: string }[]>([]) + const [numberOfKeys, setNumberOfKeys] = useState(1) const qrRef = useRef(null) const keyState = useInputState({ @@ -72,14 +73,6 @@ const BadgeCreationPage: NextPage = () => { subtitle: 'Part of the key pair to be utilized for post-creation access control', }) - const numberOfKeysState = useNumberInputState({ - id: 'numberOfKeys', - name: 'numberOfKeys', - title: 'Number of Keys', - subtitle: 'The number of key pairs to be generated for post-creation access control', - defaultValue: 1, - }) - const designatedMinterState = useInputState({ id: 'designatedMinter', name: 'designatedMinter', @@ -177,14 +170,18 @@ const BadgeCreationPage: NextPage = () => { type: 'create_badge', } if (mintRule !== 'by_keys') { + setBadgeId(null) + setIsAddingKeysComplete(false) const data = await badgeHubDispatchExecute(payload) console.log(data) setCreatingBadge(false) setTransactionHash(data.split(':')[0]) setBadgeId(data.split(':')[1]) } else { + setBadgeId(null) + setIsAddingKeysComplete(false) setKeyPairs([]) - const generatedKeyPairs = generateKeyPairs(numberOfKeysState.value) + const generatedKeyPairs = generateKeyPairs(numberOfKeys) setKeyPairs(generatedKeyPairs) await badgeHubDispatchExecute(payload) .then(async (data) => { @@ -282,7 +279,15 @@ const BadgeCreationPage: NextPage = () => { }) } - // copy claim url to clipboard + const handleDownloadKeys = () => { + const element = document.createElement('a') + const file = new Blob([JSON.stringify(keyPairs)], { type: 'text/plain' }) + element.href = URL.createObjectURL(file) + element.download = `badge-${badgeId as string}-keys.json` + document.body.appendChild(element) + element.click() + } + const copyClaimURL = async () => { const baseURL = NETWORK === 'testnet' ? 'https://badges.publicawesome.dev' : 'https://badges.stargaze.zone' const claimURL = `${baseURL}/?id=${badgeId as string}&key=${createdBadgeKey as string}` @@ -428,6 +433,65 @@ const BadgeCreationPage: NextPage = () => { + + + +
+ Badge ID:{` ${badgeId as string}`} +
+ Transaction Hash: {' '} + + + {transactionHash} + + + + + {transactionHash} + + +
+
+
+ + You may click{' '} + + here + {' '} + and select Actions {'>'} Add Keys to add (additional) whitelisted keys or select Actions {'>'}{' '} + Mint by Keys to use one of the keys to mint a badge. + +
+ +
+ + Make sure to download the whitelisted keys added during badge creation. + + +
+
+
+
+
+
+
+
@@ -499,6 +563,7 @@ const BadgeCreationPage: NextPage = () => { onClick={() => { setMintRule('by_key') setReadyToCreateBadge(false) + setBadgeId(null) }} type="button" > @@ -521,6 +586,7 @@ const BadgeCreationPage: NextPage = () => { onClick={() => { setMintRule('by_keys') setReadyToCreateBadge(false) + setBadgeId(null) }} type="button" > @@ -543,6 +609,7 @@ const BadgeCreationPage: NextPage = () => { onClick={() => { setMintRule('by_minter') setReadyToCreateBadge(false) + setBadgeId(null) }} type="button" > @@ -568,7 +635,21 @@ const BadgeCreationPage: NextPage = () => {
- +
+
+ Number of Keys + + The number of key pairs to be whitelisted for post-creation access control + +
+ setNumberOfKeys(Number(e.target.value))} + required + type="number" + value={numberOfKeys} + /> +