-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flow EVM] Adding FLOW token bridge event #5538
Changes from 4 commits
83bb106
4bc1795
7a89034
3d25ad2
592c51c
0928491
eda7709
45d51e2
3f9a12c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,18 @@ contract EVM { | |
access(all) | ||
event CadenceOwnedAccountCreated(addressBytes: [UInt8; 20]) | ||
|
||
/// FLOWTokenDeposit is emitted when FLOW tokens is bridged | ||
/// into the EVM environment. Note that this event is not emitted | ||
/// for transfer of flow tokens between two EVM addresses. | ||
access(all) | ||
event FLOWTokenDeposit(addressBytes: [UInt8; 20], amount: UFix64) | ||
|
||
/// FLOWTokenWithdraw is emitted when FLOW tokens are bridged | ||
/// out of the EVM environment. Note that this event is not emitted | ||
/// for transfer of flow tokens between two EVM addresses. | ||
access(all) | ||
event FLOWTokenWithdraw(addressBytes: [UInt8; 20], amount: UFix64) | ||
|
||
/// EVMAddress is an EVM-compatible address | ||
access(all) | ||
struct EVMAddress { | ||
|
@@ -56,10 +68,12 @@ contract EVM { | |
/// Deposits the given vault into the EVM account with the given address | ||
access(all) | ||
fun deposit(from: @FlowToken.Vault) { | ||
let amount = from.balance | ||
InternalEVM.deposit( | ||
from: <-from, | ||
to: self.bytes | ||
) | ||
emit FLOWTokenDeposit(addressBytes: self.bytes, amount: amount) | ||
} | ||
} | ||
|
||
|
@@ -224,6 +238,7 @@ contract EVM { | |
from: self.addressBytes, | ||
amount: balance.attoflow | ||
) as! @FlowToken.Vault | ||
emit FLOWTokenWithdraw(addressBytes: self.addressBytes, amount: balance.inFLOW()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not emit an event if the balance is 0. I think I would prefer the whole function just exiting early if the balance is 0. same with deposit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added protection |
||
return <-vault | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are using past tense for events.
FLOWTokensDeposited
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update those to use past participle.