mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
docs updates
This commit is contained in:
parent
bf689e7c02
commit
bc62cbc22e
@ -9,6 +9,7 @@ import React from 'react'
|
||||
import { useOcean, useConsume } from '@oceanprotocol/react'
|
||||
|
||||
const did = 'did:op:0x000000000'
|
||||
const dtBalance = 20
|
||||
|
||||
export default function MyComponent() {
|
||||
const { accountId } = useOcean()
|
||||
@ -16,10 +17,16 @@ export default function MyComponent() {
|
||||
// Get metadata for this asset
|
||||
const { title, price, ddo } = useMetadata(did)
|
||||
|
||||
// Pricing helpers
|
||||
const { buyDT } = usePricing(ddo)
|
||||
|
||||
// Consume helpers
|
||||
const { consume, consumeStep } = useConsume()
|
||||
|
||||
const hasDatatoken = dtBalance >= 1
|
||||
|
||||
async function handleDownload() {
|
||||
!hasDatatoken && (await buyDT('1'))
|
||||
await consume(did, ddo.dataToken, 'access')
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ export const consumeFeedback: { [key in number]: string } = {
|
||||
}
|
||||
|
||||
function useConsume(): UseConsume {
|
||||
const { ocean, account, accountId, config } = useOcean()
|
||||
const { ocean, account, accountId } = useOcean()
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [consumeStep, setConsumeStep] = useState<number | undefined>()
|
||||
const [consumeStepText, setConsumeStepText] = useState<string | undefined>()
|
||||
@ -43,6 +43,7 @@ function useConsume(): UseConsume {
|
||||
marketFeeAddress: string
|
||||
): Promise<void> {
|
||||
if (!ocean || !account || !accountId) return
|
||||
|
||||
setIsLoading(true)
|
||||
setConsumeError(undefined)
|
||||
|
||||
|
@ -12,8 +12,14 @@ import { Metadata, DDO } from '@oceanprotocol/lib'
|
||||
export default function MyComponent({ ddo }: { ddo: DDO }) {
|
||||
const { accountId } = useOcean()
|
||||
|
||||
// Publish helpers
|
||||
const { createPricing } = usePricing(ddo)
|
||||
// Pricing helpers
|
||||
const {
|
||||
createPricing,
|
||||
buyDT,
|
||||
sellDT,
|
||||
pricingStepText,
|
||||
pricingError
|
||||
} = usePricing(ddo)
|
||||
|
||||
const priceOptions = {
|
||||
price: 10,
|
||||
|
@ -137,7 +137,7 @@ function OceanProvider({
|
||||
}
|
||||
async function logout() {
|
||||
// TODO: #67 check how is the proper way to logout
|
||||
if (web3Modal) web3Modal.clearCachedProvider()
|
||||
web3Modal?.clearCachedProvider()
|
||||
}
|
||||
|
||||
// TODO: #68 Refetch balance periodically, or figure out some event to subscribe to
|
||||
|
Loading…
Reference in New Issue
Block a user