diff --git a/common/errors.ts b/common/errors.ts
index 11b8242f6..d96a35bae 100644
--- a/common/errors.ts
+++ b/common/errors.ts
@@ -61,6 +61,10 @@ export const NATIVE_ERRORS: ErrorCode[] = [
message:
'Insufficient funds. User does not have enough balance of token to complete the transaction',
},
+ {
+ code: '0',
+ message: 'Address already in use',
+ },
// token program errors
{
code: '0x1',
diff --git a/components/Admin.tsx b/components/Admin.tsx
index 753411091..ef70eeb21 100644
--- a/components/Admin.tsx
+++ b/components/Admin.tsx
@@ -54,7 +54,7 @@ function Admin() {
defer
data-domain="stake.cardinal.so"
src="https://plausible.io/js/plausible.js"
- >
+ />
diff --git a/components/StakePoolForm.tsx b/components/StakePoolForm.tsx
index 77f15042d..f80c5e39c 100644
--- a/components/StakePoolForm.tsx
+++ b/components/StakePoolForm.tsx
@@ -15,6 +15,7 @@ import { tryFormatInput, tryParseInput } from 'common/units'
import { tryPublicKey } from 'common/utils'
import { asWallet } from 'common/Wallets'
import { useFormik } from 'formik'
+import { validPoolIdentifier } from 'handlers/useHandleCreatePool'
import { useEnvironmentCtx } from 'providers/EnvironmentProvider'
import { useMemo, useState } from 'react'
import type { Account, Mint } from 'spl-token-v3'
@@ -25,6 +26,13 @@ export const publicKeyValidationTest = (value: string | undefined): boolean => {
return tryPublicKey(value) ? true : false
}
+export const optionalPublicKeyValidationTest = (
+ value: string | undefined
+): boolean => {
+ if (!value || value.length === 0) return true
+ return publicKeyValidationTest(value)
+}
+
export const bnValidationTest = (value: string | undefined): boolean => {
if (value === undefined) return false
try {
@@ -38,7 +46,11 @@ export const bnValidationTest = (value: string | undefined): boolean => {
}
const creationFormSchema = Yup.object({
- // overlayText: Yup.string(),
+ identifier: Yup.string().test(
+ 'url-safe',
+ 'Invalid identifier',
+ (value: string | undefined) => validPoolIdentifier(value ?? '')
+ ),
requireCollections: Yup.array()
.of(
Yup.string().test(
@@ -68,7 +80,7 @@ const creationFormSchema = Yup.object({
rewardMintAddress: Yup.string().test(
'is-public-key',
'Invalid reward mint address',
- publicKeyValidationTest
+ optionalPublicKeyValidationTest
),
rewardAmount: Yup.string()
.optional()
@@ -107,7 +119,7 @@ export function StakePoolForm({
const { connection } = useEnvironmentCtx()
const wallet = useWallet()
const initialValues: CreationForm = {
- // overlayText: stakePoolData?.parsed.overlayText ?? 'STAKED',
+ identifier: stakePoolData?.parsed?.identifier ?? undefined,
requireCollections: (stakePoolData?.parsed?.allowedCollections ?? []).map(
(pk) => pk.toString()
),
@@ -237,22 +249,24 @@ export function StakePoolForm({
return (