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
a4557f10
Commit
a4557f10
authored
Aug 14, 2016
by
Simon de la Rouviere
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for non vanity tokens. Won't err if it does not have decimals, symbol or name.
parent
810dc241
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
23 deletions
+48
-23
tokenpage.jsx
app/javascripts/tokenpage.jsx
+48
-23
No files found.
app/javascripts/tokenpage.jsx
View file @
a4557f10
...
...
@@ -25,7 +25,8 @@ var TokenPage = React.createClass({
allowance_result
:
''
,
token_decimals
:
''
,
token_name
:
''
,
token_symbol
:
''
token_symbol
:
''
,
valid
:
true
};
},
componentDidMount
:
function
()
{
...
...
@@ -41,36 +42,56 @@ var TokenPage = React.createClass({
var
accounts
=
web3
.
eth
.
accounts
;
//get Metamask/Mist address
var
addr
=
accounts
[
0
];
//first account in metamask is one that's active. Might have to swop/change for Mist in the future.
web3_token
.
totalSupply
.
call
({
from
:
addr
},
function
(
err
,
totalSupply
)
{
//expect this. so throw that it is NOT an ERC token.
//TODO ^^
console
.
log
(
totalSupply
);
that
.
setState
({
totalSupply
:
totalSupply
.
toString
()});
//a check that if the address returns 0 here, it's either invalid or not usable and user gets notified.
if
(
totalSupply
.
toString
()
===
"0"
)
{
that
.
setState
({
valid
:
false
});
}
});
that
.
setState
({
current_user_address
:
addr
});
//optionals. So don't throw.
//only omit them
//TODO: For now, this will break for any token that does NOT have decimals, name or symbol.
//One need to do a function signature regex to determine if it's in there or not.
web3_token
.
decimals
.
call
({
from
:
addr
},
function
(
err
,
decimals
)
{
//ABI will force it to expect BigNumber.
//because it throws via fallback function if not present, it gets back 0.
if
(
err
)
{
console
.
log
(
err
);
}
if
(
decimals
)
{
console
.
log
(
decimals
);
that
.
setState
({
token_decimals
:
decimals
});
}
});
web3_token
.
symbol
.
call
({
from
:
addr
},
function
(
err
,
symbol
)
{
//totalSupply is currently used to check if legitimate ERC20.
//optionals currently are the vanity vars: decimals, symbol and name.
//the token can still work, thus if not present they aren't currently shown or added to the UI.
//decimals() signature: 0x313ce567
//name() signature: 0x06fdde03
//symbol() signature: 0x95d89b41
var
decimals_sig
=
"13ce567"
;
var
name_sig
=
"06fdde03"
;
var
symbol_sig
=
"95d89b41"
;
web3
.
eth
.
getCode
(
this
.
props
.
params
.
contract_address
,
function
(
err
,
result
)
{
//console.log(result);
if
(
result
.
indexOf
(
decimals_sig
)
>=
0
)
{
console
.
log
(
"decimals present"
);
web3_token
.
decimals
.
call
({
from
:
addr
},
function
(
err
,
decimals
)
{
//ABI will force it to expect BigNumber.
//because it throws via fallback function if not present, it gets back 0.
if
(
err
)
{
console
.
log
(
err
);
}
if
(
decimals
)
{
console
.
log
(
decimals
);
that
.
setState
({
token_decimals
:
decimals
});
}
});
}
if
(
result
.
indexOf
(
name_sig
)
>=
0
)
{
console
.
log
(
"name present"
);
web3_token
.
name
.
call
({
from
:
addr
},
function
(
err
,
name
)
{
if
(
err
)
{
console
.
log
(
err
);
}
if
(
name
)
{
console
.
log
(
name
);
that
.
setState
({
token_name
:
name
});
}
});
}
if
(
result
.
indexOf
(
symbol_sig
)
>=
0
)
{
console
.
log
(
"symbol present"
);
web3_token
.
symbol
.
call
({
from
:
addr
},
function
(
err
,
symbol
)
{
//ABI expects string here,
if
(
err
)
{
console
.
log
(
"ERROR BRUV"
);
}
if
(
err
)
{
console
.
log
(
err
);
}
if
(
symbol
)
{
console
.
log
(
symbol
);
that
.
setState
({
token_symbol
:
symbol
});
}
});
web3_token
.
name
.
call
({
from
:
addr
},
function
(
err
,
name
)
{
if
(
err
)
{
console
.
log
(
err
);
}
if
(
name
)
{
console
.
log
(
name
);
that
.
setState
({
token_name
:
name
});
}
});
}
});
},
successOnBalance
:
function
(
result
,
args
)
{
...
...
@@ -127,6 +148,10 @@ var TokenPage = React.createClass({
top_header
=
<
span
><
h2
>
{
this
.
state
.
token_name
}
(
{
this
.
state
.
token_symbol
}
)
</
h2
>
<
br
/></
span
>;
}
if
(
this
.
state
.
valid
==
false
)
{
top_header
=
<
span
><
h2
>
There doesn't seem to be a token contract at this address.
</
h2
>
<
br
/></
span
>;
}
/*
TXComponent is from reflux-tx to monitor tx state. Wrapping components with it, means those components can monitor those tx states.
*/
...
...
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