fix: crossbell.js connect on load

This commit is contained in:
DIYgod
2022-08-07 17:00:03 +01:00
parent b12f22d67d
commit 51f4c0e627
2 changed files with 18 additions and 11 deletions
+10 -7
View File
@@ -1,12 +1,15 @@
import { Contract, Indexer } from "crossbell.js"
const indexer = new Indexer()
const contract =
typeof window !== "undefined"
? new Contract((<any>window).ethereum)
: undefined
if (contract) {
contract.connect()
let contract: Contract | undefined
const getContract = () => {
if (!contract && typeof window !== "undefined") {
contract = new Contract((<any>window).ethereum)
contract.connect()
}
return contract
}
export { indexer, contract }
export { indexer, getContract }