mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
new value: oceanAmount
This commit is contained in:
parent
d0c65a6935
commit
c3b4bcec66
1
src/@types/MetaData.d.ts
vendored
1
src/@types/MetaData.d.ts
vendored
@ -21,6 +21,7 @@ export interface MetadataMarket extends Metadata {
|
|||||||
export interface PriceOptionsMarket extends PriceOptions {
|
export interface PriceOptionsMarket extends PriceOptions {
|
||||||
// easier to keep this as number for Yup input validation
|
// easier to keep this as number for Yup input validation
|
||||||
swapFee: number
|
swapFee: number
|
||||||
|
oceanAmount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MetadataPublishForm {
|
export interface MetadataPublishForm {
|
||||||
|
@ -82,7 +82,7 @@ export default function Dynamic({
|
|||||||
|
|
||||||
<div className={styles.tokens}>
|
<div className={styles.tokens}>
|
||||||
<Coin
|
<Coin
|
||||||
name="price"
|
name="oceanAmount"
|
||||||
datatokenOptions={{ symbol: 'OCEAN', name: 'Ocean Token' }}
|
datatokenOptions={{ symbol: 'OCEAN', name: 'Ocean Token' }}
|
||||||
weight={`${100 - Number(Number(weightOnDataToken) * 10)}%`}
|
weight={`${100 - Number(Number(weightOnDataToken) * 10)}%`}
|
||||||
/>
|
/>
|
||||||
|
@ -23,7 +23,7 @@ export default function FormPricing({
|
|||||||
|
|
||||||
// Connect with form
|
// Connect with form
|
||||||
const { values, setFieldValue, submitForm } = useFormikContext()
|
const { values, setFieldValue, submitForm } = useFormikContext()
|
||||||
const { price, weightOnDataToken, type } = values as PriceOptionsMarket
|
const { oceanAmount, weightOnDataToken, type } = values as PriceOptionsMarket
|
||||||
|
|
||||||
// Switch type value upon tab change
|
// Switch type value upon tab change
|
||||||
function handleTabChange(tabName: string) {
|
function handleTabChange(tabName: string) {
|
||||||
@ -33,9 +33,9 @@ export default function FormPricing({
|
|||||||
|
|
||||||
// Always update everything when price value changes
|
// Always update everything when price value changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dtAmount = Number(price) * Number(weightOnDataToken)
|
const dtAmount = Number(oceanAmount) * Number(weightOnDataToken)
|
||||||
setFieldValue('dtAmount', dtAmount)
|
setFieldValue('dtAmount', dtAmount)
|
||||||
}, [price, weightOnDataToken])
|
}, [oceanAmount, weightOnDataToken])
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,9 @@ import * as Yup from 'yup'
|
|||||||
export const validationSchema = Yup.object().shape<PriceOptionsMarket>({
|
export const validationSchema = Yup.object().shape<PriceOptionsMarket>({
|
||||||
price: Yup.number().min(1, 'Must be greater than 0').required('Required'),
|
price: Yup.number().min(1, 'Must be greater than 0').required('Required'),
|
||||||
dtAmount: Yup.number().min(1, 'Must be greater than 0').required('Required'),
|
dtAmount: Yup.number().min(1, 'Must be greater than 0').required('Required'),
|
||||||
|
oceanAmount: Yup.number()
|
||||||
|
.min(1, 'Must be greater than 0')
|
||||||
|
.required('Required'),
|
||||||
type: Yup.string()
|
type: Yup.string()
|
||||||
.matches(/fixed|dynamic/g)
|
.matches(/fixed|dynamic/g)
|
||||||
.required('Required'),
|
.required('Required'),
|
||||||
@ -18,7 +21,8 @@ export const validationSchema = Yup.object().shape<PriceOptionsMarket>({
|
|||||||
export const initialValues: PriceOptionsMarket = {
|
export const initialValues: PriceOptionsMarket = {
|
||||||
price: 1,
|
price: 1,
|
||||||
type: 'dynamic',
|
type: 'dynamic',
|
||||||
dtAmount: 1,
|
dtAmount: 9,
|
||||||
|
oceanAmount: 1,
|
||||||
weightOnDataToken: '9', // 90% on data token
|
weightOnDataToken: '9', // 90% on data token
|
||||||
swapFee: 0.1 // in %
|
swapFee: 0.1 // in %
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user