Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Token-Factory
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bitsoko services
Token-Factory
Commits
6dbf1fce
Commit
6dbf1fce
authored
Jul 22, 2016
by
Simon de la Rouviere
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switched to async.
parent
b9f511b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
34 deletions
+28
-34
main.jsx
app/javascripts/main.jsx
+9
-18
tokenpage.jsx
app/javascripts/tokenpage.jsx
+17
-14
web3_bootstrap.js
app/javascripts/web3_bootstrap.js
+2
-2
No files found.
app/javascripts/main.jsx
View file @
6dbf1fce
...
...
@@ -5,10 +5,12 @@ import ReactDOM from "react-dom";
import
ReactRouter
from
"react-router"
;
import
{
Router
,
Route
,
IndexRoute
,
Link
}
from
'react-router'
;
import
{
TXActions
}
from
'reflux-tx'
;
import
{
TXComponent
}
from
"reflux-tx"
;
//import TXActions from "reflux-tx".TXActions;
//import TXComponent from "reflux-tx".TXComponent;
//import AccountBadge from "react-account-badge";
var
web3
=
require
(
"./web3_bootstrap.js"
);
window
.
web3
=
web3
;
//hacky way to force checked web3 to be used everywhere vs accidentally using injected web3.
//import Web3 from "web3";
//web3? Apparently it is "provided"?
...
...
@@ -31,7 +33,7 @@ var $ = require('jquery');
//window.TXActions = refluxTX.TXActions;
//window.TXComponent = refluxTX.TXComponent;
console
.
log
(
TXActions
);
//
console.log(TXActions);
TXActions
.
connect
(
web3
,
{
confirmCount
:
1
,
bufferSize
:
5
})
//window.web3_rab = new Web3();
...
...
@@ -54,41 +56,30 @@ let history = createHistory({
let
App
=
React
.
createClass
({
getInitialState
:
function
()
{
return
{
blockNumber
:
web3
.
eth
.
blockNumber
,
blockNumber
:
0
,
offline_msg
:
''
};
},
componentDidMount
:
function
()
{
var
that
=
this
;
if
(
window
.
offline
==
true
)
{
console
.
log
(
'offline'
);
this
.
setState
({
offline_msg
:
"YOU ARE OFFLINE."
});
this
.
setState
({
blockNumber
:
'OFFLINE'
});
}
//filter here seems like "non"-react way to do things.
//TXComponent inherits blocknumber. Use that instead.
web3
.
eth
.
filter
(
'latest'
,
function
(
error
,
result
){
if
(
!
error
)
console
.
log
(
'app watcher'
);
setTimeout
(
that
.
checkBlockNumber
,
1000
);
//wait a bit
});
//TODO: log current address in here instead with a timeout
},
checkBlockNumber
:
function
()
{
//console.log(web3);
var
nbn
=
web3
.
eth
.
blockNumber
;
if
(
nbn
>
this
.
state
.
blockNumber
)
{
console
.
log
(
nbn
);
this
.
setState
({
blockNumber
:
nbn
});
}
},
render
:
function
()
{
return
(
<
div
className=
"container"
>
<
div
className=
"row"
>
<
div
className=
"col-md-6 col-md-offset-3"
>
<
NavBar
blockNumber=
{
this
.
state
.
blockNumber
}
offline_msg=
{
this
.
state
.
offline_msg
}
/>
<
TXComponent
>
<
NavBar
offline_msg=
{
this
.
state
.
offline_msg
}
/>
</
TXComponent
>
{
this
.
props
.
children
}
</
div
>
</
div
>
...
...
app/javascripts/tokenpage.jsx
View file @
6dbf1fce
...
...
@@ -26,21 +26,24 @@ var TokenPage = React.createClass({
window
.
token_c
=
web3_token
;
this
.
setState
({
web3_token
:
web3_token
});
var
that
=
this
;
web3
.
eth
.
getAccounts
(
function
(
err
,
accounts
){
var
addr
=
accounts
[
0
];
console
.
log
(
addr
);
var
totalSupply
=
web3_token
.
totalSupply
.
call
({
from
:
addr
});
console
.
log
(
totalSupply
);
that
.
setState
({
totalSupply
:
totalSupply
.
c
[
0
]});
that
.
setState
({
current_user_address
:
addr
});
var
decimals
=
web3_token
.
decimals
.
call
({
from
:
addr
});
var
symbol
=
web3_token
.
symbol
.
call
({
from
:
addr
});
var
name
=
web3_token
.
name
.
call
({
from
:
addr
});
if
(
decimals
)
{
that
.
setState
({
token_decimals
:
decimals
});
}
if
(
symbol
)
{
that
.
setState
({
token_symbol
:
symbol
});
}
if
(
name
)
{
that
.
setState
({
token_name
:
name
});
}
console
.
log
(
decimals
+
symbol
+
name
);
var
accounts
=
web3
.
eth
.
accounts
;
var
addr
=
accounts
[
0
];
web3_token
.
totalSupply
.
call
({
from
:
addr
},
function
(
err
,
totalSupply
)
{
console
.
log
(
totalSupply
);
that
.
setState
({
totalSupply
:
totalSupply
.
c
[
0
]});
});
that
.
setState
({
current_user_address
:
addr
});
web3_token
.
decimals
.
call
({
from
:
addr
},
function
(
err
,
decimals
)
{
if
(
decimals
)
{
that
.
setState
({
token_decimals
:
decimals
});
}
});
web3_token
.
symbol
.
call
({
from
:
addr
},
function
(
err
,
symbol
)
{
if
(
symbol
)
{
that
.
setState
({
token_symbol
:
symbol
});
}
});
web3_token
.
name
.
call
({
from
:
addr
},
function
(
err
,
name
)
{
if
(
name
)
{
that
.
setState
({
token_name
:
name
});
}
});
},
successOnBalance
:
function
(
result
,
args
)
{
...
...
app/javascripts/web3_bootstrap.js
View file @
6dbf1fce
...
...
@@ -12,8 +12,8 @@ if (typeof web3 !== 'undefined') {
exported
=
new
Web3
(
web3
.
currentProvider
);
window
.
offline
=
false
;
//there is a web3 available.
var
other_web3
=
new
Web3
(
new
Web3
.
providers
.
HttpProvider
(
'https://rpc.metamask.io'
));
window
.
web_l
=
other_web3
;
//
var other_web3 = new Web3(new Web3.providers.HttpProvider('https://rpc.metamask.io'));
//
window.web_l = other_web3;
}
else
{
// Use the provider from the config.
// ENV and WEB3_PROVIDER_LOCATION are rewritten by webpack during build
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment