Pass ETH signer only if it can actually sign #67
+12
-10
@@ -38,36 +38,38 @@ export default Service.extend({
|
|||||||
);
|
);
|
||||||
ethProvider.listAccounts().then((accounts) => {
|
ethProvider.listAccounts().then((accounts) => {
|
||||||
this.set('currentUserAccounts', accounts);
|
this.set('currentUserAccounts', accounts);
|
||||||
resolve(ethProvider);
|
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
||||||
|
resolve({
|
||||||
|
ethProvider,
|
||||||
|
ethSigner
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.debug('[kredits] Creating new instance from npm module class');
|
console.debug('[kredits] Creating new instance from npm module class');
|
||||||
networkId = parseInt(config.contractMetadata.networkId);
|
networkId = parseInt(config.contractMetadata.networkId);
|
||||||
|
console.debug(`[kredits] networkId=${networkId} providerURL: ${config.web3ProviderUrl}`);
|
||||||
ethProvider = new ethers.providers.JsonRpcProvider(
|
ethProvider = new ethers.providers.JsonRpcProvider(
|
||||||
config.web3ProviderUrl,
|
config.web3ProviderUrl,
|
||||||
{ chainId: networkId }
|
{ chainId: networkId }
|
||||||
);
|
);
|
||||||
resolve(ethProvider);
|
resolve({
|
||||||
|
ethProvider: ethProvider,
|
||||||
|
ethSigner: null
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
return this.getEthProvider().then((ethProvider) => {
|
return this.getEthProvider().then((providerAndSigner) => {
|
||||||
let ethSigner;
|
|
||||||
|
|
||||||
if (ethProvider.getSigner) {
|
let kredits = new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, {
|
||||||
ethSigner = ethProvider.getSigner();
|
|
||||||
}
|
|
||||||
|
|
||||||
let kredits = new Kredits(ethProvider, ethSigner, {
|
|
||||||
ipfsConfig: config.ipfs
|
ipfsConfig: config.ipfs
|
||||||
});
|
});
|
||||||
return kredits
|
return kredits
|
||||||
.init()
|
.init()
|
||||||
.then((kredits) => {
|
.then((kredits) => {
|
||||||
this.set('kredits', kredits);
|
this.set('kredits', kredits);
|
||||||
|
|
||||||
if (this.currentUserAccounts && this.currentUserAccounts.length > 0) {
|
if (this.currentUserAccounts && this.currentUserAccounts.length > 0) {
|
||||||
this.getCurrentUser.then((contributorData) => {
|
this.getCurrentUser.then((contributorData) => {
|
||||||
this.set('currentUser', contributorData);
|
this.set('currentUser', contributorData);
|
||||||
|
|||||||
Reference in New Issue
Block a user