oceanprotocol/react

change useWeb3 implementation

Closed this issue · 1 comments

Currently I changed the useWeb3 implementation to lets say a hardcoded one, meaning you can't plug in a different web3 provider ( this was the fastest fix at the time)

 <Web3Provider>
        <OceanProvider config={config}>
          <h1>My App</h1>
          {children}
        </OceanProvider>
 </Web3Provider>

This was because you couldn't get web3 and injected directly in OceanProvider like

<Web3Provider>
      {({ web3 }) => (
        <OceanProvider config={config} web3={web3}>
          <h1>My App</h1>
          {children}
        </OceanProvider>
      )}
</Web3Provider>

We can split this in 2 function components main and app ( Layout and app )

function Main() {
return (
    <Web3Provider>
        <App/>
    </Web3Provider>
)}

and

function App(){
     const { web3 }  =useWeb3()

return (
    <OceanProvider web3={web3} config={config}>
        <component/>
    </OceanProvider>
)}

This way we can use another web3 provider, but does this make sense? Will this happen? I think this discussion should be after looking at web3connect

working pretty great right now! Maybe reopen when somebody requests to have different web3 provider