Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
ink
Commits
ef20c62f
Commit
ef20c62f
authored
Nov 22, 2019
by
Weiliang Li
Committed by
Hero Bird
Nov 22, 2019
Browse files
Fix erc20 transferring bug (#255)
* Update lib.rs Fix #254 * Update lib.rs
parent
6689bb13
Pipeline
#69742
passed with stages
in 26 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
examples/lang/erc20/src/lib.rs
View file @
ef20c62f
...
...
@@ -129,11 +129,11 @@ contract! {
/// Transfers token from a specified AccountId to another AccountId.
fn
transfer_impl
(
&
mut
self
,
env
:
&
mut
EnvHandler
<
ink_core
::
env
::
ContractEnv
<
DefaultSrmlTypes
>>
,
from
:
AccountId
,
to
:
AccountId
,
value
:
Balance
)
->
bool
{
let
balance_from
=
self
.balance_of_or_zero
(
&
from
);
let
balance_to
=
self
.balance_of_or_zero
(
&
to
);
if
balance_from
<
value
{
return
false
}
self
.balances
.insert
(
from
,
balance_from
-
value
);
let
balance_to
=
self
.balance_of_or_zero
(
&
to
);
self
.balances
.insert
(
to
,
balance_to
+
value
);
env
.emit
(
Transfer
{
from
:
Some
(
from
),
...
...
examples/lang2/erc20/src/lib.rs
View file @
ef20c62f
...
...
@@ -119,8 +119,8 @@ mod erc20 {
if
from_balance
<
value
{
return
false
}
let
to_balance
=
self
.balance_of_or_zero
(
&
to
);
self
.balances
.insert
(
from
.clone
(),
from_balance
-
value
);
let
to_balance
=
self
.balance_of_or_zero
(
&
to
);
self
.balances
.insert
(
to
.clone
(),
to_balance
+
value
);
self
.env
()
.emit_event
(
Transfer
{
from
:
Some
(
from
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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