Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
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
俞永鹏
openzeppelin-contracts-upgradeable
Commits
17884e91
Commit
17884e91
authored
Jan 09, 2018
by
Facundo Spagnuolo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit Trasnfer event on SimpleToken creation
parent
59cd714b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
SimpleToken.sol
contracts/examples/SimpleToken.sol
+1
-0
SimpleToken.test.js
test/SimpleToken.test.js
+41
-0
decodeLogs.js
test/helpers/decodeLogs.js
+8
-0
No files found.
contracts/examples/SimpleToken.sol
View file @
17884e91
...
...
@@ -24,6 +24,7 @@ contract SimpleToken is StandardToken {
function SimpleToken() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
}
test/SimpleToken.test.js
0 → 100644
View file @
17884e91
import
decodeLogs
from
'./helpers/decodeLogs'
;
const
SimpleToken
=
artifacts
.
require
(
'examples/SimpleToken.sol'
);
contract
(
'SimpleToken'
,
accounts
=>
{
let
token
;
const
creator
=
accounts
[
0
];
beforeEach
(
async
function
()
{
token
=
await
SimpleToken
.
new
({
from
:
creator
});
});
it
(
'has a name'
,
async
function
()
{
const
name
=
await
token
.
name
();
assert
.
equal
(
name
,
'SimpleToken'
);
});
it
(
'has a symbol'
,
async
function
()
{
const
symbol
=
await
token
.
symbol
();
assert
.
equal
(
symbol
,
'SIM'
);
});
it
(
'has 18 decimals'
,
async
function
()
{
const
decimals
=
await
token
.
decimals
();
assert
(
decimals
.
eq
(
18
));
});
it
(
'assigns the initial total supply to the creator'
,
async
function
()
{
const
totalSupply
=
await
token
.
totalSupply
();
const
creatorBalance
=
await
token
.
balanceOf
(
creator
);
assert
(
creatorBalance
.
eq
(
totalSupply
));
const
receipt
=
web3
.
eth
.
getTransactionReceipt
(
token
.
transactionHash
);
const
logs
=
decodeLogs
(
receipt
.
logs
,
SimpleToken
,
token
.
address
);
assert
.
equal
(
logs
.
length
,
1
);
assert
.
equal
(
logs
[
0
].
event
,
'Transfer'
);
assert
.
equal
(
logs
[
0
].
args
.
from
.
valueOf
(),
0x0
);
assert
.
equal
(
logs
[
0
].
args
.
to
.
valueOf
(),
creator
);
assert
(
logs
[
0
].
args
.
value
.
eq
(
totalSupply
));
});
});
test/helpers/decodeLogs.js
0 → 100644
View file @
17884e91
const
SolidityEvent
=
require
(
'web3/lib/web3/event.js'
);
export
default
function
decodeLogs
(
logs
,
contract
,
address
)
{
return
logs
.
map
(
log
=>
{
const
event
=
new
SolidityEvent
(
null
,
contract
.
events
[
log
.
topics
[
0
]],
address
);
return
event
.
decode
(
log
);
});
}
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