Fallback to provider if no contract signer is given

No signing functions will be available then.
This commit is contained in:
bumi 2018-04-19 01:30:27 +02:00
parent 555cf1e12c
commit 42bfb3d24e

View File

@ -106,7 +106,8 @@ class Kredits {
if (!address || !abis[contractName]) { if (!address || !abis[contractName]) {
throw new Error(`Address or ABI not found for ${contractName}`); throw new Error(`Address or ABI not found for ${contractName}`);
} }
let contract = new ethers.Contract(address, abis[contractName], this.signer); let signerOrProvider = this.signer || this.provider;
let contract = new ethers.Contract(address, abis[contractName], signerOrProvider);
this.contracts[name] = new contracts[contractName](contract); this.contracts[name] = new contracts[contractName](contract);
this.contracts[name].ipfs = this.ipfs; this.contracts[name].ipfs = this.ipfs;