docs updates

This commit is contained in:
Matthias Kretschmann 2020-10-19 13:18:18 +02:00
parent bf689e7c02
commit bc62cbc22e
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 18 additions and 4 deletions

View File

@ -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')
}

View File

@ -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)

View File

@ -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,

View File

@ -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