Skip to content

Commit

Permalink
Update torus.js and fetch-node-details
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jan 16, 2020
1 parent c848fc3 commit 277e599
Show file tree
Hide file tree
Showing 6 changed files with 624 additions and 473 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ server.js
.eslintignore
.prettierignore
.prettierrc.yaml
.github
.github
toruslabs-torus-embed*
12 changes: 8 additions & 4 deletions examples/react-basic-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class App extends React.Component {
componentDidMount() {
const isTorus = sessionStorage.getItem('pageUsingTorus')
if (isTorus) {
web3Obj.initialize().then(() => {
web3Obj.initialize(isTorus).then(() => {
this.setStateInfo()
})
}
Expand All @@ -32,9 +32,10 @@ class App extends React.Component {
}

enableTorus = async e => {
const { buildEnv } = this.state;
e.preventDefault()
try {
await web3Obj.initialize()
await web3Obj.initialize(buildEnv)
this.setStateInfo()
} catch (error) {
console.error(error)
Expand All @@ -52,7 +53,10 @@ class App extends React.Component {
}

logout = () => {
web3Obj.torus.cleanUp().then(() => this.setState({ account: '', balance: 0 }))
web3Obj.torus.cleanUp().then(() => {
this.setState({ account: '', balance: 0 })
sessionStorage.setItem('pageUsingTorus', false)
})
}

signMessage = () => {
Expand Down Expand Up @@ -293,7 +297,7 @@ class App extends React.Component {
<button>Login</button>
</form>
)}
{account !== null && (
{account && (
<div>
<div>Account: {account}</div>
<div>Balance: {balance}</div>
Expand Down
6 changes: 3 additions & 3 deletions examples/react-basic-app/src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const web3Obj = {
setweb3: function(provider) {
const web3Inst = new Web3(provider)
web3Obj.web3 = web3Inst
sessionStorage.setItem('pageUsingTorus', true)
},
initialize: async function() {
initialize: async function(buildEnv) {
const torus = new Torus()
await torus.init()
await torus.init({ buildEnv: buildEnv || 'production' })
await torus.login()
web3Obj.setweb3(torus.provider)
web3Obj.torus = torus
sessionStorage.setItem('pageUsingTorus', buildEnv)
}
}
export default web3Obj
Loading

0 comments on commit 277e599

Please sign in to comment.