Skip to content

Commit

Permalink
fix: include chain as the sender of minted NFTs
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemmsilva committed Sep 7, 2023
1 parent 1a438c1 commit 120ee05
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vm/vmtxbuilder/nfts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 120ee05

Please sign in to comment.