|
|
|
// import "@stdlib/jetton";
|
|
|
|
import "./messages";
|
|
|
|
import "./wallet";
|
|
|
|
import "./linker";
|
|
|
|
import "./jetton_trait";
|
|
|
|
|
|
|
|
message Deposit {
|
|
|
|
amount: Int;
|
|
|
|
}
|
|
|
|
|
|
|
|
message Withdraw {
|
|
|
|
amount: Int;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct WithdrawalRequests {
|
|
|
|
addresses: map[Int]Address;
|
|
|
|
amounts: map[Int]Int;
|
|
|
|
n_requests: Int;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const gas_consumption: Int = ton("0.01");
|
|
|
|
const withdraw_gas_consumption: Int = ton("0.05");
|
|
|
|
const deposit_gas_consumption: Int = ton("0.05");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract TONB with Jetton {
|
|
|
|
|
|
|
|
totalSupply: Int as coins;
|
|
|
|
owner: Address;
|
|
|
|
content: Cell?;
|
|
|
|
mintable: Bool;
|
|
|
|
first_linker: Address?;
|
|
|
|
last_linker: Address?;
|
|
|
|
n_linkers: Int = 0;
|
|
|
|
|
|
|
|
init(owner: Address, content: Cell?) {
|
|
|
|
self.totalSupply = 0;
|
|
|
|
self.owner = owner;
|
|
|
|
self.mintable = true;
|
|
|
|
self.content = content;
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: Deposit) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
require(ctx.value >= deposit_gas_consumption, "not enough money for deposit");
|
|
|
|
self.mint(ctx.sender, msg.amount, ctx.sender);
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: Withdraw) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
require(ctx.value >= withdraw_gas_consumption, "not enough money for withdraw");
|
|
|
|
self.burn(ctx.sender, msg.amount, ctx.sender);
|
|
|
|
}
|
|
|
|
}
|