Hi Rarible team,
I am having some issues instantiating the SDK. I am able to connect my metamask wallet, however passing the created connection to the SDK errs. Below is the error generated.

After some research, seems like this was a problem prior to more recent versions of web3, and is solved in web3 v4+. However, the peerDependencies of rarible's web3ethereum package.json only relies on web3 v1.5.0. I believe this to be the root cause. However, here is my connector code (connects fine, but sdk fails to initialize with metamask wallet):
const App = () => {
const [connector, setConnector] = useState();
const [isConnected, setIsConnected] = useState(false);
useEffect(() => {
if(connector && !isConnected) {
console.log(connector);
connector.connection.subscribe(async (con) => {
console.log("connection", con);
if(con.status === 'disconnected') {
setIsConnected(false);
}
else if (con.status === "connected") {
setIsConnected(true);
//fails at sdk init's ethereumw3 package, at a generator fn yield statement in .getChainId()
const sdk = createRaribleSdk(con.connection.wallet, "prod", { apiKey: MAINNETKEY });
}
});
connector.getOptions().then(options => {
console.log('connector options', options);
connector.connect(options[0]).then(x => console.log('connected', x));
});
}
}, [connector]);
useEffect(() => {
console.log('APP MOUNTED MARKER.');
if(!connector) {
const injected = mapEthereumWallet(new InjectedWeb3ConnectionProvider({
prefer: [DappType.Metamask, DappType.Coinbase]
}));
setConnector(
Connector.create(injected, /*walletState*/)
);
}
return () => {
console.log('APP UNMOUNTED MARKER.');
if(connector) {
connector.disconnect();
}
}
}, []);
return (
<>...</>
);
Additional Notes
- I am using CRA, however I use craco for overriding natural webpack settings
- NodePolyfillPlugin for webpack fixes all other missing options (like Buffer and friends), better and cleaner than installing each individual node-ification module.
- added proper
"browserslist" to package.json, but this didn't solve my issue
- running latest web3 packages, but doesn't fix internal deps from the rarible/sdk module
Let me know if you need more!
Hi Rarible team,
I am having some issues instantiating the SDK. I am able to connect my metamask wallet, however passing the created connection to the SDK errs. Below is the error generated.
After some research, seems like this was a problem prior to more recent versions of web3, and is solved in web3 v4+. However, the peerDependencies of rarible's web3ethereum package.json only relies on web3 v1.5.0. I believe this to be the root cause. However, here is my connector code (connects fine, but sdk fails to initialize with metamask wallet):
Additional Notes
"browserslist"to package.json, but this didn't solve my issueLet me know if you need more!