mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
price data structure additions
This commit is contained in:
parent
b35a11b3bb
commit
5d11416137
2
src/@types/MetaData.d.ts
vendored
2
src/@types/MetaData.d.ts
vendored
@ -25,6 +25,8 @@ export interface MetadataPublishForm {
|
||||
price: {
|
||||
tokensToMint: number
|
||||
type: 'simple' | 'advanced' | string
|
||||
weight: string
|
||||
ownerFee: string
|
||||
}
|
||||
access: 'Download' | 'Compute' | string
|
||||
termsAndConditions: boolean
|
||||
|
@ -77,14 +77,14 @@ export default function Advanced({
|
||||
name="ocean"
|
||||
symbol="OCEAN"
|
||||
value={ocean}
|
||||
weight={`${100 - Number(weightOnDataToken)}%`}
|
||||
weight={`${100 - Number(Number(weightOnDataToken) * 10)}%`}
|
||||
onChange={onChange}
|
||||
/>
|
||||
<Coin
|
||||
name="tokensToMint"
|
||||
symbol="OCEAN-CAV"
|
||||
value={tokensToMint.toString()}
|
||||
weight={`${weightOnDataToken}%`}
|
||||
weight={`${Number(weightOnDataToken) * 10}%`}
|
||||
readOnly
|
||||
/>
|
||||
</div>
|
||||
|
@ -8,8 +8,8 @@ import { useField } from 'formik'
|
||||
|
||||
export default function Price(props: InputProps): ReactElement {
|
||||
const [field, meta, helpers] = useField(props)
|
||||
const { weight } = field.value
|
||||
|
||||
const weightOnDataToken = '90' // in %
|
||||
const [ocean, setOcean] = useState('1')
|
||||
const [tokensToMint, setTokensToMint] = useState<number>()
|
||||
|
||||
@ -24,7 +24,7 @@ export default function Price(props: InputProps): ReactElement {
|
||||
|
||||
// Always update everything when ocean changes
|
||||
useEffect(() => {
|
||||
const tokensToMint = Number(ocean) * (Number(weightOnDataToken) / 10)
|
||||
const tokensToMint = Number(ocean) * Number(weight)
|
||||
setTokensToMint(tokensToMint)
|
||||
console.log(field.value)
|
||||
helpers.setValue({ ...field.value, tokensToMint })
|
||||
@ -41,7 +41,7 @@ export default function Price(props: InputProps): ReactElement {
|
||||
<Advanced
|
||||
ocean={ocean}
|
||||
tokensToMint={tokensToMint}
|
||||
weightOnDataToken={weightOnDataToken}
|
||||
weightOnDataToken={weight}
|
||||
onChange={handleOceanChange}
|
||||
/>
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ export default function PublishPage({
|
||||
`)
|
||||
|
||||
const metadata = transformPublishFormToMetadata(values)
|
||||
const { tokensToMint, type } = values.price
|
||||
const { tokensToMint, type, weight, ownerFee } = values.price
|
||||
const serviceType = values.access === 'Download' ? 'access' : 'compute'
|
||||
|
||||
console.log(`
|
||||
@ -60,8 +60,8 @@ export default function PublishPage({
|
||||
accountId,
|
||||
ddo.dataToken,
|
||||
tokensToMint.toString(),
|
||||
'9',
|
||||
'0.03'
|
||||
weight,
|
||||
ownerFee
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ export const validationSchema = Yup.object().shape<MetadataPublishForm>({
|
||||
tokensToMint: Yup.number().required('Required'),
|
||||
type: Yup.string()
|
||||
.matches(/simple|advanced/g)
|
||||
.required('Required')
|
||||
.required('Required'),
|
||||
weight: Yup.string().required('Required'),
|
||||
ownerFee: Yup.string()
|
||||
}),
|
||||
files: Yup.array<FileMetadata>().required('Required').nullable(),
|
||||
description: Yup.string().required('Required'),
|
||||
@ -31,7 +33,9 @@ export const initialValues: MetadataPublishForm = {
|
||||
author: undefined,
|
||||
price: {
|
||||
type: 'simple',
|
||||
tokensToMint: 1
|
||||
tokensToMint: 1,
|
||||
weight: '9', // 90% on data token
|
||||
ownerFee: '0.03' // in %
|
||||
},
|
||||
files: undefined,
|
||||
description: undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user