internal bool Mint(StorageContext storage, BalanceSheet balances, SupplySheet supply, Address target, BigInteger amount) { if (!Flags.HasFlag(TokenFlags.Fungible)) { return(false); } if (amount <= 0) { return(false); } if (IsCapped) { if (this.CurrentSupply + amount > this.MaxSupply) { return(false); } if (!supply.Mint(amount)) { return(false); } } if (!balances.Add(storage, target, amount)) { return(false); } this._supply += amount; return(true); }
internal bool Burn(StorageContext storage, BalanceSheet balances, SupplySheet supply, Address target, BigInteger amount) { if (!Flags.HasFlag(TokenFlags.Fungible)) { return(false); } if (amount <= 0) { return(false); } if (this.CurrentSupply - amount < 0) { return(false); } if (IsCapped && !supply.Burn(amount)) { return(false); } if (!balances.Subtract(storage, target, amount)) { return(false); } this._supply -= amount; return(true); }
internal void Init(StorageContext localStorage, StorageContext parentStorage, SupplySheet parentSupply) { var parentBalance = parentSupply.Get(parentStorage, parentSupply._localName); Set(localStorage, _parentName, parentBalance); }