Update ethers.js to latest version v4
The main change is how ethers loads the networkId which is now async. Thus the init process had to change a bit
This commit is contained in:
@@ -17,11 +17,7 @@ class Base {
|
||||
}
|
||||
|
||||
on(type, callback) {
|
||||
let eventMethod = `on${type.toLowerCase()}`;
|
||||
// Don't use this.contract.events here. Seems to be a bug in ethers.js
|
||||
this.contract[eventMethod] = callback;
|
||||
|
||||
return this;
|
||||
return this.contract.on(type, callback);
|
||||
}
|
||||
}
|
||||
module.exports = Base;
|
||||
|
||||
@@ -12,7 +12,9 @@ class Kernel extends Base {
|
||||
}
|
||||
|
||||
appNamehash(appName) {
|
||||
return AppIds[this.contract.provider.chainId.toString()][appName];
|
||||
// actually provider.network is an asynchronous property.
|
||||
// but when we call this function kredits is already initialized and the network is already loaded
|
||||
return AppIds[this.contract.provider.network.chainId.toString()][appName];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user