From cea12c6fd51aec8fc0e2fca4c25b61fb827043d6 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/vm/vmtxbuilder/nfts.go b/packages/vm/vmtxbuilder/nfts.go index e7919f64dc..01ac16a35b 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,7 +154,8 @@ func (txb *AnchorTransactionBuilder) sendNFT(o *iotago.NFTOutput) int64 { } func (txb *AnchorTransactionBuilder) MintNFT(addr iotago.Address, immutableMetadata []byte, issuer iotago.Address) (uint16, *iotago.NFTOutput) { - if !issuer.Equal(txb.anchorOutput.Chain().ToAddress()) { + chainAddr := txb.chainAddress() + if !issuer.Equal(chainAddr) { // include collection issuer NFT output in the txbuilder nftAddr, ok := issuer.(*iotago.NFTAddress) if !ok { @@ -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},