mirror of
https://github.com/oceanprotocol/react.git
synced 2025-01-05 11:25:18 +01:00
move web3 to provider level, switch hook params
This commit is contained in:
parent
7310bcafc9
commit
00722a4358
12
README.md
12
README.md
@ -17,8 +17,10 @@ import React from 'react'
|
|||||||
import { OceanProvider } from '@oceanprotocol/react'
|
import { OceanProvider } from '@oceanprotocol/react'
|
||||||
|
|
||||||
export default function MyApp({ children }: { children: any }) {
|
export default function MyApp({ children }: { children: any }) {
|
||||||
|
// TODO: setup web3 first
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OceanProvider>
|
<OceanProvider web3={web3}>
|
||||||
<h1>My App</h1>
|
<h1>My App</h1>
|
||||||
{children}
|
{children}
|
||||||
</OceanProvider>
|
</OceanProvider>
|
||||||
@ -39,17 +41,15 @@ const oceanConfig: OceanConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function MyComponent() {
|
export default function MyComponent() {
|
||||||
// TODO: setup web3 first
|
|
||||||
|
|
||||||
// Initialize, get existing, or reinitalize Ocean
|
// Initialize, get existing, or reinitalize Ocean
|
||||||
const { ocean, account } = useOcean(web3, oceanConfig)
|
const { ocean, account } = useOcean(oceanConfig)
|
||||||
|
|
||||||
// consume asset
|
// consume asset
|
||||||
const { consumeAsset, isLoading, step } = useConsume(ocean, account)
|
const { consumeAsset, isLoading, step } = useConsume(ocean)
|
||||||
|
|
||||||
async function handleClick() {
|
async function handleClick() {
|
||||||
const ddo = 'did:op:0x000000000'
|
const ddo = 'did:op:0x000000000'
|
||||||
await consumeAsset(ddo)
|
await consumeAsset(ddo, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user