This repository has been archived by the owner on Apr 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
127 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = function(privateKey) { | ||
const filterPrivateKey = require('./filterPrivateKey'); | ||
privateKey = filterPrivateKey(privateKey); | ||
const web3 = require('./getWeb3')(); | ||
const web3 = require('./web3Store').get(); | ||
|
||
return web3.eth.accounts.privateKeyToAccount(privateKey).address; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const Web3 = require('web3'); | ||
|
||
let web3; | ||
const voidWeb3 = new Web3(); | ||
module.exports = (function() { | ||
return { | ||
/** | ||
@dev setWithProvider set web3 with provider | ||
*/ | ||
setWithProvider: provider => { | ||
web3 = new Web3(provider); | ||
}, | ||
/** | ||
@dev setWithURL set web3 with http url | ||
*/ | ||
setWithURL: url => { | ||
web3 = new Web3(new Web3.providers.HttpProvider(url)); | ||
}, | ||
/** | ||
@dev get getter of stored web3, if there isn't, return void web3 | ||
*/ | ||
get: () => { | ||
if (!web3) { | ||
return voidWeb3; | ||
} | ||
return web3; | ||
}, | ||
/** | ||
@dev delete delete stored web3 for test | ||
*/ | ||
delete: () => { | ||
web3 = undefined; | ||
} | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"mnemonic": "piano garage flag neglect spare title drill basic strong aware enforce fury", | ||
"url": "http://localhost:8545" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
chai.use(require('chai-as-promised')).should(); | ||
|
||
const Web3 = require('web3'); | ||
const { web3Store } = require('../src'); | ||
|
||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const testEnv = fs.readJsonSync(path.join(__dirname, 'test.env.json')); | ||
|
||
describe('web3Store', function() { | ||
beforeEach(function() { | ||
web3Store.delete(); | ||
}); | ||
|
||
after(function() { | ||
web3Store.delete(); | ||
}); | ||
|
||
describe('#setWithProvider()', function() { | ||
it('should set with provider', async function() { | ||
web3Store.setWithProvider(new Web3.providers.HttpProvider(testEnv.url)); | ||
const web3 = web3Store.get(); | ||
expect(web3).to.be.an.instanceOf(Web3); | ||
await web3.eth.getCoinbase().should.be.fulfilled; | ||
}); | ||
}); | ||
|
||
describe('#setWithURL()', function() { | ||
it('should set with url', async function() { | ||
web3Store.setWithURL(testEnv.url); | ||
const web3 = web3Store.get(); | ||
expect(web3).to.be.an.instanceOf(Web3); | ||
await web3.eth.getCoinbase().should.be.fulfilled; | ||
}); | ||
}); | ||
|
||
describe('#get()', function() { | ||
it('should return void web3 when it is not set', async function() { | ||
const web3 = web3Store.get(); | ||
expect(web3).to.be.an.instanceOf(Web3); | ||
await web3.eth.getCoinbase().should.be.rejected; | ||
}); | ||
}); | ||
|
||
describe('#delete()', function() { | ||
it('should delete stored web3', async function() { | ||
web3Store.setWithURL(testEnv.url); | ||
web3Store.delete(); | ||
|
||
const web3 = web3Store.get(); | ||
expect(web3).to.be.an.instanceOf(Web3); | ||
await web3.eth.getCoinbase().should.be.rejected; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
packages/vvisp/scripts/deploy-service/utils/pathToInstance.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters