// NFT version internal bool BurnToken(string symbol, StorageContext storage, Address target, BigInteger tokenID) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } var chain = RootChain; var supply = new SupplySheet(symbol, chain, this); if (!supply.Burn(storage, 1)) { return(false); } var ownerships = new OwnershipSheet(symbol); if (!ownerships.Take(storage, target, tokenID)) { return(false); } return(true); }
// NFT version internal bool BurnToken(RuntimeVM runtimeVM, string symbol, Address target, BigInteger tokenID) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } var chain = RootChain; var supply = new SupplySheet(symbol, chain, this); if (!supply.Burn(runtimeVM.ChangeSet, 1)) { return(false); } var ownerships = new OwnershipSheet(symbol); if (!ownerships.Take(runtimeVM.ChangeSet, target, tokenID)) { return(false); } var tokenTriggerResult = SmartContract.InvokeTrigger(runtimeVM, tokenInfo.Script, TokenContract.TriggerBurn, target, tokenID); if (!tokenTriggerResult) { return(false); } var accountScript = this.LookUpAddressScript(target); var accountTriggerResult = SmartContract.InvokeTrigger(runtimeVM, accountScript, AccountContract.TriggerBurn, target, tokenID); if (!accountTriggerResult) { return(false); } return(true); }
internal bool TransferToken(string symbol, StorageContext storage, Chain chain, Address source, Address destination, BigInteger tokenID) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (!tokenInfo.Flags.HasFlag(TokenFlags.Transferable)) { throw new Exception("Not transferable"); } if (tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { throw new Exception("Should be non-fungible"); } if (tokenID <= 0) { return(false); } var ownerships = new OwnershipSheet(symbol); if (!ownerships.Take(storage, source, tokenID)) { return(false); } if (!ownerships.Give(storage, destination, tokenID)) { return(false); } EditNFTLocation(symbol, tokenID, chain.Address, destination); return(true); }
internal bool TransferToken(RuntimeVM runtimeVM, string symbol, Address source, Address destination, BigInteger tokenID) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (!tokenInfo.Flags.HasFlag(TokenFlags.Transferable)) { throw new Exception("Not transferable"); } if (tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { throw new Exception("Should be non-fungible"); } if (tokenID <= 0) { return(false); } var ownerships = new OwnershipSheet(symbol); if (!ownerships.Take(runtimeVM.ChangeSet, source, tokenID)) { return(false); } if (!ownerships.Give(runtimeVM.ChangeSet, destination, tokenID)) { return(false); } var tokenTriggerResult = SmartContract.InvokeTrigger(runtimeVM, tokenInfo.Script, TokenContract.TriggerSend, source, tokenID); if (!tokenTriggerResult) { return(false); } tokenTriggerResult = SmartContract.InvokeTrigger(runtimeVM, tokenInfo.Script, TokenContract.TriggerReceive, destination, tokenID); if (!tokenTriggerResult) { return(false); } var accountScript = this.LookUpAddressScript(source); var accountTriggerResult = SmartContract.InvokeTrigger(runtimeVM, accountScript, AccountContract.TriggerSend, source, tokenID); if (!accountTriggerResult) { return(false); } accountScript = this.LookUpAddressScript(destination); accountTriggerResult = SmartContract.InvokeTrigger(runtimeVM, accountScript, AccountContract.TriggerSend, destination, tokenID); if (!accountTriggerResult) { return(false); } EditNFTLocation(symbol, tokenID, runtimeVM.Chain.Address, destination); return(true); }