1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-23 02:00:27 +01:00
This commit is contained in:
mihaisc 2020-05-11 18:43:02 +03:00
parent 4d932e7a58
commit 78c271f95c
2 changed files with 6 additions and 8 deletions

View File

@ -21,7 +21,7 @@ function useMetadata(did?: DID | string): UseMetadata {
const [title, setTitle] = useState<string | undefined>()
async function getDDO(did: DID | string): Promise<DDO> {
if(status!=OceanConnectionStatus.CONNECTED) return
if (status !== OceanConnectionStatus.CONNECTED) return
const ddo = await aquarius.retrieveDDO(did)
return ddo
@ -29,7 +29,7 @@ function useMetadata(did?: DID | string): UseMetadata {
async function getMetadata(did: DID | string): Promise<MetaData> {
const ddo = await getDDO(did)
if(!ddo) return
if (!ddo) return
const metadata = ddo.findServiceByType('metadata')
return metadata.attributes
}
@ -41,7 +41,6 @@ function useMetadata(did?: DID | string): UseMetadata {
async function getTitle(did: DID | string): Promise<string> {
const metadata = await getMetadata(did)
console.log(metadata)
return metadata.main.name
}
@ -52,7 +51,7 @@ function useMetadata(did?: DID | string): UseMetadata {
useEffect(() => {
async function init(): Promise<void> {
if(!did) return
if (!did) return
const ddo = await getDDO(did)
setDDO(ddo)

View File

@ -40,7 +40,7 @@ function OceanProvider({
const [status, setStatus] = useState<OceanConnectionStatus>(
OceanConnectionStatus.NOT_CONNECTED
)
const { web3,ethProviderStatus } = useWeb3()
const { web3, ethProviderStatus } = useWeb3()
// -------------------------------------------------------------
// 1. On mount, connect to Aquarius instance right away
@ -54,8 +54,7 @@ function OceanProvider({
// 2. Once `web3` becomes available, connect to the whole network
// -------------------------------------------------------------
useEffect(() => {
if (!web3 || ethProviderStatus!= InjectedProviderStatus.CONNECTED ) return
console.log(ethProviderStatus)
if (!web3 || ethProviderStatus !== InjectedProviderStatus.CONNECTED) return
async function init(): Promise<void> {
const { ocean, account, accountId, balance } = await connectOcean(
web3,