Compare commits

...

3 Commits

Author SHA1 Message Date
Tommy Verrall 1b6f7294b7 removed duplicate line - still can't validate though. 2021-12-07 14:03:08 +00:00
Tommy Verrall 3f08e31fb3 can't validate if this is correct yet - but pushing anyway. 2021-12-07 14:01:14 +00:00
Tommy Verrall 1365ea97f1 update validation on mixnode - gateways
- we have a new owner signature parameter in the form
- provide some base line validation (this can be improved) based upon the input
- bs58 decode?
2021-12-07 13:12:15 +00:00
4 changed files with 25 additions and 2 deletions
+3 -1
View File
@@ -65,12 +65,14 @@ export const checkGatewayOwnership = async (): Promise<boolean> =>
export const bond = async ({ export const bond = async ({
type, type,
data, data,
ownerSignature,
amount, amount,
}: { }: {
type: EnumNodeType type: EnumNodeType
data: MixNode | Gateway data: MixNode | Gateway
ownerSignature: String
amount: Coin amount: Coin
}): Promise<any> => await invoke(`bond_${type}`, { [type]: data, bond: amount }) }): Promise<any> => await invoke(`bond_${type}`, { [type]: data, sign: ownerSignature, bond: amount })
export const unbond = async (type: EnumNodeType) => export const unbond = async (type: EnumNodeType) =>
await invoke(`unbond_${type}`) await invoke(`unbond_${type}`)
+3 -1
View File
@@ -41,6 +41,7 @@ const defaultValues = {
withAdvancedOptions: false, withAdvancedOptions: false,
nodeType: EnumNodeType.mixnode, nodeType: EnumNodeType.mixnode,
identityKey: '', identityKey: '',
ownerSignature: '',
sphinxKey: '', sphinxKey: '',
amount: '', amount: '',
host: '', host: '',
@@ -58,6 +59,7 @@ const formatData = (data: TBondFormFields) => {
sphinx_key: data.sphinxKey, sphinx_key: data.sphinxKey,
host: data.host, host: data.host,
version: data.version, version: data.version,
owner_signature: data.ownerSignature,
mix_port: data.mixPort, mix_port: data.mixPort,
} }
@@ -112,7 +114,7 @@ export const BondForm = ({
const formattedData = formatData(data) const formattedData = formatData(data)
const amount = await majorToMinor(data.amount) const amount = await majorToMinor(data.amount)
await bond({ type: data.nodeType, data: formattedData, amount }) await bond({ type: data.nodeType, data: formattedData, ownerSignature: data.ownerSignature, amount })
.then(() => { .then(() => {
userBalance.fetchBalance() userBalance.fetchBalance()
onSuccess(`Successfully bonded to ${data.identityKey}`) onSuccess(`Successfully bonded to ${data.identityKey}`)
@@ -6,6 +6,7 @@ import {
validateLocation, validateLocation,
validateRawPort, validateRawPort,
validateVersion, validateVersion,
validateOwnerSignature
} from '../../utils' } from '../../utils'
export const validationSchema = Yup.object().shape({ export const validationSchema = Yup.object().shape({
@@ -58,11 +59,17 @@ export const validationSchema = Yup.object().shape({
} }
return Yup.mixed().notRequired() return Yup.mixed().notRequired()
}), }),
mixPort: Yup.number() mixPort: Yup.number()
.required('A mixport is required') .required('A mixport is required')
.test('valid-mixport', 'A valid mixport is required', function (value) { .test('valid-mixport', 'A valid mixport is required', function (value) {
return !!value ? validateRawPort(value) : false return !!value ? validateRawPort(value) : false
}), }),
ownerSignature: Yup.string()
.required('The owners signature is required')
.test('valid-version', 'The owners signature is required', function (value) {
return !!value ? validateOwnerSignature(value) : false
}),
verlocPort: Yup.number() verlocPort: Yup.number()
.required('A verloc port is required') .required('A verloc port is required')
.test('valid-verloc', 'A valid verloc port is required', function (value) { .test('valid-verloc', 'A valid verloc port is required', function (value) {
+12
View File
@@ -70,6 +70,18 @@ export const isValidHostname = (value: string) => {
return hostnameRegex.test(value) return hostnameRegex.test(value)
} }
export const validateOwnerSignature = (value: string) => {
try {
//better validation required here
const signature = value.trim()
if(typeof signature === 'string')
return true
} catch (e) {
console.log(e)
return false
}
}
export const validateVersion = (version: string): boolean => { export const validateVersion = (version: string): boolean => {
try { try {
const minorVersion = minor(version) const minorVersion = minor(version)