Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(provider, options = {}) {
if (provider.constructor.name !== "WebsocketProvider") {
console.warn("subspace: it's recommended to use a websocket provider to react to new events");
}
this.events = new Events();
this.web3 = new Web3Eth(provider);
this.options = {};
this.options.refreshLastNBlocks = options.refreshLastNBlocks || 12;
this.options.callInterval = options.callInterval || 0;
this.options.dbFilename = options.dbFilename || 'subspace.db';
this.latestBlockNumber = undefined;
this.disableDatabase = options.disableDatabase;
this.networkId = undefined;
this.newBlocksSubscription = null;
this.intervalTracker = null;
this.callables = [];
}
constructor (opts = {}) {
this.eth = opts.eth || new Eth(DEFAULT_ETH_NODE)
this.network = opts.network || '1'
}
async initRegistry () {
if (await this.eth.net.getId() !== '1') {
this.eth = new Eth(DEFAULT_ETH_NODE)
}
const address = REGISTRY_MAP[this.network]
if (!address) {
throw new Error('No method registry found on the requested network.')
}
this.registry = new this.eth.Contract(REGISTRY_LOOKUP_ABI, address)
}
constructor(props) {
super(props);
try {
if (window.ethereum) {
this.eth = new Eth(window.ethereum);
} else {
this.eth = new Eth(Eth.givenProvider || "http://localhost:8545");
}
} catch (e) {
this.eth = new Eth("wss://mainnet.infura.io/ws");
}
//Hanle binds
this.handleActionChange = this.handleActionChange.bind(this);
this.handleChange = this.handleChange.bind(this);
const history = createBrowserHistory();
const hash = history.location.hash;
const action = hash && hash.substring(hash.indexOf("/")+1, hash.length);
if (hash !== "#/" && allowedActions.includes(action)) {