|
|
@ -1,129 +1,23 @@ |
|
|
|
// import "@stdlib/jetton"; |
|
|
|
// import "@stdlib/jetton"; |
|
|
|
import "@stdlib/ownable"; |
|
|
|
|
|
|
|
import "./messages"; |
|
|
|
import "./messages"; |
|
|
|
import "./wallet"; |
|
|
|
import "./wallet"; |
|
|
|
import "./linker"; |
|
|
|
import "./linker"; |
|
|
|
|
|
|
|
import "./jetton_trait"; |
|
|
|
|
|
|
|
|
|
|
|
message Mint { |
|
|
|
message Mint { |
|
|
|
amount: Int; |
|
|
|
amount: Int; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface("org.ton.jetton.master") |
|
|
|
|
|
|
|
trait Jetton with Ownable { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// Storage |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
totalSupply: Int; |
|
|
|
|
|
|
|
mintable: Bool; |
|
|
|
|
|
|
|
owner: Address; |
|
|
|
|
|
|
|
content: Cell?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// Receivers |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
receive(msg: TokenUpdateContent) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Allow changing content only by owner |
|
|
|
|
|
|
|
self.requireOwner(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update content |
|
|
|
|
|
|
|
self.content = msg.content; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
receive(msg: TokenBurnNotification) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check wallet |
|
|
|
|
|
|
|
self.requireWallet(msg.owner); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update supply |
|
|
|
|
|
|
|
self.totalSupply = self.totalSupply - msg.amount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cashback |
|
|
|
|
|
|
|
if (msg.responseAddress != null) { |
|
|
|
|
|
|
|
send(SendParameters{ |
|
|
|
|
|
|
|
to: msg.responseAddress!!, |
|
|
|
|
|
|
|
value: 0, |
|
|
|
|
|
|
|
bounce: false, |
|
|
|
|
|
|
|
mode: SendRemainingValue + SendIgnoreErrors, |
|
|
|
|
|
|
|
body: TokenExcesses{ |
|
|
|
|
|
|
|
queryId: msg.queryId |
|
|
|
|
|
|
|
}.toCell() |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// Get Methods |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get fun get_wallet_address(owner: Address): Address { |
|
|
|
|
|
|
|
let winit: StateInit = self.getJettonWalletInit(owner); |
|
|
|
|
|
|
|
return contractAddress(winit); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get fun get_jetton_data(): JettonData { |
|
|
|
|
|
|
|
let code: Cell = self.getJettonWalletInit(myAddress()).code; |
|
|
|
|
|
|
|
return JettonData{ |
|
|
|
|
|
|
|
totalSupply: self.totalSupply, |
|
|
|
|
|
|
|
mintable: self.mintable, |
|
|
|
|
|
|
|
owner: self.owner, |
|
|
|
|
|
|
|
content: self.content, |
|
|
|
|
|
|
|
walletCode: code |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// Private Methods |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun mint(to: Address, amount: Int, responseAddress: Address?) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update total supply |
|
|
|
|
|
|
|
self.totalSupply = self.totalSupply + amount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create message |
|
|
|
|
|
|
|
let winit: StateInit = self.getJettonWalletInit(to); |
|
|
|
|
|
|
|
let walletAddress: Address = contractAddress(winit); |
|
|
|
|
|
|
|
send(SendParameters{ |
|
|
|
|
|
|
|
to: walletAddress, |
|
|
|
|
|
|
|
value: 0, |
|
|
|
|
|
|
|
bounce: false, |
|
|
|
|
|
|
|
mode: SendRemainingValue, |
|
|
|
|
|
|
|
body: TokenTransferInternal{ |
|
|
|
|
|
|
|
amount: amount, |
|
|
|
|
|
|
|
queryId: 0, |
|
|
|
|
|
|
|
from: myAddress(), |
|
|
|
|
|
|
|
responseAddress: responseAddress, |
|
|
|
|
|
|
|
forwardTonAmount: 0, |
|
|
|
|
|
|
|
forwardPayload: emptySlice() |
|
|
|
|
|
|
|
}.toCell(), |
|
|
|
|
|
|
|
code: winit.code, |
|
|
|
|
|
|
|
data: winit.data |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun requireWallet(owner: Address) { |
|
|
|
|
|
|
|
let ctx: Context = context(); |
|
|
|
|
|
|
|
let winit: StateInit = self.getJettonWalletInit(owner); |
|
|
|
|
|
|
|
require(contractAddress(winit) == ctx.sender, "Invalid sender"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual fun getJettonWalletInit(address: Address): StateInit { |
|
|
|
|
|
|
|
return initOf TONBWallet(myAddress(), address); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract TONB with Jetton { |
|
|
|
contract TONB with Jetton { |
|
|
|
|
|
|
|
|
|
|
|
totalSupply: Int as coins; |
|
|
|
totalSupply: Int as coins; |
|
|
|
owner: Address; |
|
|
|
owner: Address; |
|
|
|
content: Cell?; |
|
|
|
content: Cell?; |
|
|
|
mintable: Bool; |
|
|
|
mintable: Bool; |
|
|
|
|
|
|
|
first_linker: Address?; |
|
|
|
|
|
|
|
last_linker: Address?; |
|
|
|
|
|
|
|
n_linkers: Int = 0; |
|
|
|
|
|
|
|
|
|
|
|
init(owner: Address, content: Cell?) { |
|
|
|
init(owner: Address, content: Cell?) { |
|
|
|
self.totalSupply = 0; |
|
|
|
self.totalSupply = 0; |
|
|
|