mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
add basic specs
This commit is contained in:
parent
00722a4358
commit
fc566e0766
37
README.md
37
README.md
@ -18,6 +18,8 @@ import { OceanProvider } from '@oceanprotocol/react'
|
|||||||
|
|
||||||
export default function MyApp({ children }: { children: any }) {
|
export default function MyApp({ children }: { children: any }) {
|
||||||
// TODO: setup web3 first
|
// TODO: setup web3 first
|
||||||
|
// or fallback to injected providers by default
|
||||||
|
// so it works with any browser wallet out of the box
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OceanProvider web3={web3}>
|
<OceanProvider web3={web3}>
|
||||||
@ -41,7 +43,7 @@ const oceanConfig: OceanConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function MyComponent() {
|
export default function MyComponent() {
|
||||||
// Initialize, get existing, or reinitalize Ocean
|
// Initialize, get existing, or reinitialize Ocean
|
||||||
const { ocean, account } = useOcean(oceanConfig)
|
const { ocean, account } = useOcean(oceanConfig)
|
||||||
|
|
||||||
// consume asset
|
// consume asset
|
||||||
@ -63,3 +65,36 @@ export default function MyComponent() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Specs
|
||||||
|
|
||||||
|
#### `useOcean()`
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
interface UseOcean {
|
||||||
|
ocean: Ocean
|
||||||
|
account: string
|
||||||
|
balance: { ocean: string, eth: string }
|
||||||
|
status: OceanConnectionStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: UseOcean = useOcean(config: OceanConfig)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### `useConsume()`
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
interface ConsumeOptions {
|
||||||
|
ocean: Ocean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UseConsume {
|
||||||
|
consumeAsset: (ddo: DDO, account: string) => void
|
||||||
|
isLoading: boolean
|
||||||
|
step: number
|
||||||
|
error: string | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: UseConsume = useConsume(options: ConsumeOptions)
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user