-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathXETH.move
46 lines (36 loc) · 1.24 KB
/
XETH.move
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Bridge::XETH {
use StarcoinFramework::Token;
use StarcoinFramework::Account;
// XETH token marker.
struct XETH has copy, drop, store {}
// precision of XETH token.
const PRECISION: u8 = 18;
// XETH initialization.
public fun init(account: &signer) {
Token::register_token<XETH>(account, PRECISION);
Account::do_accept_token<XETH>(account);
}
public fun mint(account: &signer, amount: u128) {
let token = Token::mint<XETH>(account, amount);
Account::deposit_to_self<XETH>(account, token);
}
public fun burn(account: &signer, amount: u128) {
Token::burn(account, Account::withdraw<XETH>(account, amount));
}
}
module Bridge::XETHScripts {
use Bridge::XETH;
use Bridge::LockProxy;
public entry fun init(account: signer) {
XETH::init(&account);
}
/// Only called with someone who have burn capability
public entry fun mint(account: signer, amount: u128) {
XETH::mint(&account, amount);
LockProxy::move_to_treasury<XETH::XETH>(&account, amount);
}
/// Only called with someone who have burn capability
public entry fun burn(account: signer, amount: u128) {
XETH::burn(&account, amount);
}
}