1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

added schema to MarketContext

This commit is contained in:
EnzoVezzaro 2022-09-21 10:29:01 -04:00
parent 6992a8f437
commit dc54ba3b93
2 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,3 @@
import { Asset } from '@oceanprotocol/lib'
import { CancelToken } from 'axios'
import { ShaclSchema } from './_shaclType'
export interface OpcFee {
@ -54,5 +52,5 @@ export interface MarketMetadataProviderValue {
siteContent: SiteContent
appConfig: AppConfig
getOpcFeeForToken: (tokenAddress: string, chainId: number) => string
getShaclSchema: (token?: CancelToken) => Promise<Asset>
shaclSchema: ShaclSchema
}

View File

@ -27,6 +27,7 @@ function MarketMetadataProvider({
children: ReactNode
}): ReactElement {
const [opcFees, setOpcFees] = useState<OpcFee[]>()
const [shaclSchema, setShaclSchema] = useState<ShaclSchema>()
useEffect(() => {
async function getOpcData() {
@ -55,6 +56,12 @@ function MarketMetadataProvider({
setOpcFees(opcData)
}
getOpcData()
async function getShaclSchema() {
const schema = await retrieveShaclSchema()
setShaclSchema(schema)
}
getShaclSchema()
}, [])
const getOpcFeeForToken = useCallback(
@ -68,11 +75,6 @@ function MarketMetadataProvider({
[opcFees]
)
const getShaclSchema = useCallback(async (token?: CancelToken) => {
const schema = await retrieveShaclSchema()
return schema
}, [])
return (
<MarketMetadataContext.Provider
value={
@ -81,7 +83,7 @@ function MarketMetadataProvider({
siteContent,
appConfig,
getOpcFeeForToken,
getShaclSchema
shaclSchema
} as MarketMetadataProviderValue
}
>