Hey
I’ve set up react-moralis and authentication is working fine + I can enable web3 after a user is logged in but the web3
object i get from calling const { web3 } = useMoralis()
appears to be the global web3 rather than the Moralis.Web3 class.
For example:
import React from 'react';
import { useMoralis } from "react-moralis";
const App = () => {
const { web3, enableWeb3, isWeb3Enabled, authenticate, isAuthenticated, user } = useMoralis();
if (!isAuthenticated) {
return (
<div>
<button onClick={() => authenticate()}>Authenticate</button>
</div>
);
}
const getTokens = async () => {
const tokens = web3.getTokenBalances();
console.log(tokens); // I get an error "web3.getTokenBalances is not a function"
}
return (
<div>
<h1>Welcome {user.get("username")}</h1>
{isWeb3Enabled ? (
<button onClick={() => getTokens()}>
GET TOKENS
</button>
): (
<button onClick = { () => enableWeb3() }>
ENABLE WEB3
</button>
)}
</div>
);
}
export default App;