diff --git a/src/hooks/useConsume/useConsume.ts b/src/hooks/useConsume/useConsume.ts index c54eafd..339023d 100644 --- a/src/hooks/useConsume/useConsume.ts +++ b/src/hooks/useConsume/useConsume.ts @@ -19,8 +19,6 @@ export const consumeFeedback: { [key in number]: string } = { } function useConsume(): UseConsume { - // TODO: figure out if a hook within a hook could lead to problems. - // Otherwise we could just require `ocean` to be passed to `useConsume()` const { ocean, account, accountId } = useOcean() const [consumeStep, setConsumeStep] = useState() const [consumeStepText, setConsumeStepText] = useState() @@ -36,19 +34,20 @@ function useConsume(): UseConsume { accountId ) const agreement = agreements.find((el: { did: string }) => el.did === did) - console.log('existing agre',agreement) + console.log('existing agre', agreements) const agreementId = agreement ? agreement.agreementId : await ocean.assets .order(did as string, account) - .next((step: number) => { setConsumeStep(step); setConsumeStepText(consumeFeedback[step]) }) - console.log('aggrement ok', agreementId) + .next((step: number) => { setConsumeStep(step); setConsumeStepText(consumeFeedback[step]); }) + // manually add another step here for better UX setConsumeStep(4) setConsumeStepText(consumeFeedback[4]) await ocean.assets.consume(agreementId, did as string, account, '') console.log('consume ok') } catch (error) { + console.log(error) setConsumeError(error.message) } finally { setConsumeStep(undefined) diff --git a/src/providers/OceanProvider/OceanProvider.tsx b/src/providers/OceanProvider/OceanProvider.tsx index eb44efc..51c2631 100644 --- a/src/providers/OceanProvider/OceanProvider.tsx +++ b/src/providers/OceanProvider/OceanProvider.tsx @@ -57,7 +57,7 @@ function OceanProvider({ // 2. Once `web3` becomes available, connect to the whole network // ------------------------------------------------------------- useEffect(() => { - console.log('ocean', web3) + if (!web3) return async function init(): Promise {