From 120ee058f23ca1c82d9b87eccd163cd7a9d773c1 Mon Sep 17 00:00:00 2001 From: Jorge Silva Date: Thu, 7 Sep 2023 11:36:25 +0100 Subject: [PATCH] fix: include chain as the sender of minted NFTs --- packages/vm/vmtxbuilder/nfts.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vm/vmtxbuilder/nfts.go b/packages/vm/vmtxbuilder/nfts.go index e7919f64dc..3dcbdc1a93 100644 --- a/packages/vm/vmtxbuilder/nfts.go +++ b/packages/vm/vmtxbuilder/nfts.go @@ -90,7 +90,7 @@ func (txb *AnchorTransactionBuilder) NFTOutputsToBeUpdated() (toBeAdded, toBeRem func (txb *AnchorTransactionBuilder) internalNFTOutputFromRequest(nftOutput *iotago.NFTOutput, outputID iotago.OutputID) *nftIncluded { out := nftOutput.Clone().(*iotago.NFTOutput) out.Amount = 0 - chainAddr := txb.anchorOutput.AliasID.ToAddress() + chainAddr := txb.chainAddress() out.NativeTokens = nil out.Conditions = iotago.UnlockConditions{ &iotago.AddressUnlockCondition{ @@ -154,6 +154,7 @@ func (txb *AnchorTransactionBuilder) sendNFT(o *iotago.NFTOutput) int64 { } func (txb *AnchorTransactionBuilder) MintNFT(addr iotago.Address, immutableMetadata []byte, issuer iotago.Address) (uint16, *iotago.NFTOutput) { + chainAddr := txb.chainAddress() if !issuer.Equal(txb.anchorOutput.Chain().ToAddress()) { // include collection issuer NFT output in the txbuilder nftAddr, ok := issuer.(*iotago.NFTAddress) @@ -193,6 +194,11 @@ func (txb *AnchorTransactionBuilder) MintNFT(addr iotago.Address, immutableMetad Conditions: iotago.UnlockConditions{ &iotago.AddressUnlockCondition{Address: addr}, }, + Features: iotago.Features{ + &iotago.SenderFeature{ + Address: chainAddr, // must set the chainID as the sender (so its recognized as an internalUTXO) + }, + }, ImmutableFeatures: iotago.Features{ &iotago.IssuerFeature{Address: issuer}, &iotago.MetadataFeature{Data: immutableMetadata},