Skip to content

Commit

Permalink
add bridge contract example (#113)
Browse files Browse the repository at this point in the history
* update

* update name

* update

* update

* fix

* fmt code

* update event

* add amount decimals transfer

* fix bug

* remove decimals check

* fix

* fix decimal transfer bug

* update

Co-authored-by: laizy <[email protected]>
  • Loading branch information
lucas7788 and laizy authored Jul 8, 2021
1 parent 0f8fe4a commit ace97b8
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 95 deletions.
22 changes: 20 additions & 2 deletions examples/bridge/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
use crate::{Address, U128};
use ontio_std::abi::EventBuilder;

pub fn new_pending_admin_event(new_pending_admin: &Address) {
EventBuilder::new().string("setPendingAdmin").address(new_pending_admin).notify();
}

pub fn new_admin_event(old_admin: &Address, new_pending_admin: &Address) {
EventBuilder::new()
.string("acceptAdmin")
.address(old_admin)
.address(new_pending_admin)
.notify();
}

pub fn oep4_to_erc20_event(
ont_acct: &Address, eth_acct: &Address, amount: U128, oep4_addr: &Address, erc20_addr: &Address,
ont_acct: &Address, eth_acct: &Address, amount: U128, erc20_amt: U128, oep4_addr: &Address,
erc20_addr: &Address,
) {
EventBuilder::new()
.string("oep4ToErc20")
.address(ont_acct)
.address(eth_acct)
.number(amount)
.number(erc20_amt)
.address(oep4_addr)
.address(erc20_addr)
.notify();
}

pub fn erc20_to_oep4_event(
ont_acct: &Address, eth_acct: &Address, amount: U128, oep4_addr: &Address, erc20_addr: &Address,
ont_acct: &Address, eth_acct: &Address, amount: U128, oep4_amt: U128, oep4_addr: &Address,
erc20_addr: &Address,
) {
EventBuilder::new()
.string("erc20ToOep4")
.address(eth_acct)
.address(ont_acct)
.number(amount)
.number(oep4_amt)
.address(oep4_addr)
.address(erc20_addr)
.notify();
Expand Down
Loading

0 comments on commit ace97b8

Please sign in to comment.