@@ -22,7 +22,6 @@ import (
2222 "github.com/iotaledger/hive.go/lo"
2323 "github.com/iotaledger/hive.go/runtime/options"
2424 "github.com/iotaledger/iota-core/pkg/protocol"
25- "github.com/iotaledger/iota-core/pkg/testsuite/depositcalculator"
2625 "github.com/iotaledger/iota-core/pkg/testsuite/snapshotcreator"
2726 iotago "github.com/iotaledger/iota.go/v4"
2827 "github.com/iotaledger/iota.go/v4/api"
@@ -486,6 +485,8 @@ func (d *DockerTestFramework) AllotManaTo(from *Account, to *Account, manaToAllo
486485
487486// CreateNativeToken request faucet funds then use it to create native token for the account, and returns the updated Account.
488487func (d * DockerTestFramework ) CreateNativeToken (from * Account , mintedAmount iotago.BaseToken , maxSupply iotago.BaseToken ) (updatedAccount * Account ) {
488+ require .GreaterOrEqual (d .Testing , maxSupply , mintedAmount )
489+
489490 // requesting faucet funds for native token creation
490491 ctx := context .TODO ()
491492 fundsAddr , privateKey := d .getAddress (iotago .AddressEd25519 )
@@ -495,15 +496,6 @@ func (d *DockerTestFramework) CreateNativeToken(from *Account, mintedAmount iota
495496 currentSlot := clt .LatestAPI ().TimeProvider ().SlotFromTime (time .Now ())
496497 apiForSlot := clt .APIForSlot (currentSlot )
497498
498- minMintedAmount , err := depositcalculator .MinDeposit (apiForSlot .ProtocolParameters (), iotago .OutputFoundry , depositcalculator .WithHasNativeToken ())
499- require .NoError (d .Testing , err )
500-
501- mintedAmount = lo .Max (minMintedAmount , mintedAmount )
502- require .GreaterOrEqual (d .Testing , mintedAmount , fundsUTXOOutput .BaseTokenAmount ())
503- maxSupply = lo .Max (maxSupply , mintedAmount )
504-
505- remainderAmount := fundsUTXOOutput .BaseTokenAmount () - mintedAmount
506-
507499 // increase foundry counter
508500 accTransitionOutput := builder .NewAccountOutputBuilderFromPrevious (from .AccountOutput ).
509501 FoundriesToGenerate (1 ).MustBuild ()
@@ -517,34 +509,22 @@ func (d *DockerTestFramework) CreateNativeToken(from *Account, mintedAmount iota
517509 MeltedTokens : big .NewInt (0 ),
518510 }
519511
520- foundryOutput := builder .NewFoundryOutputBuilder (from .AccountAddress , mintedAmount , accTransitionOutput .FoundryCounter , tokenScheme ).
512+ foundryOutput := builder .NewFoundryOutputBuilder (from .AccountAddress , fundsUTXOOutput . BaseTokenAmount () , accTransitionOutput .FoundryCounter , tokenScheme ).
521513 NativeToken (& iotago.NativeTokenFeature {
522514 ID : foundryID ,
523515 Amount : big .NewInt (int64 (mintedAmount )),
524516 }).MustBuild ()
525517
526- addressKeys := []iotago.AddressKeys {
527- iotago .NewAddressKeysForEd25519Address (fundsAddr .(* iotago.Ed25519Address ), privateKey ),
528- iotago .NewAddressKeysForEd25519Address (from .AccountOutput .UnlockConditionSet ().Address ().Address .(* iotago.Ed25519Address ), from .BlockIssuerKey ),
529- }
530-
531- signedTxBuilder := builder .NewTransactionBuilder (apiForSlot )
532-
533- // prepare remainder output if needed
534- if remainderAmount > 0 {
535- receiveAddr , privKey := d .getAddress (iotago .AddressEd25519 )
536- remainderOutput := builder .NewBasicOutputBuilder (receiveAddr , remainderAmount ).MustBuild ()
537- addressKeys = append (addressKeys , iotago .NewAddressKeysForEd25519Address (receiveAddr .(* iotago.Ed25519Address ), privKey ))
538- signedTxBuilder = signedTxBuilder .AddOutput (remainderOutput )
539- }
518+ signer := iotago .NewInMemoryAddressSigner (iotago .NewAddressKeysForEd25519Address (fundsAddr .(* iotago.Ed25519Address ), privateKey ),
519+ iotago .NewAddressKeysForEd25519Address (from .AccountOutput .UnlockConditionSet ().Address ().Address .(* iotago.Ed25519Address ), from .BlockIssuerKey ))
540520
541521 issuerResp , err := clt .BlockIssuance (ctx )
542522 require .NoError (d .Testing , err )
543523
544524 congestionResp , err := clt .Congestion (ctx , from .AccountAddress , lo .PanicOnErr (issuerResp .LatestCommitment .ID ()))
545525 require .NoError (d .Testing , err )
546526
547- signedTx , err := signedTxBuilder .
527+ signedTx , err := builder . NewTransactionBuilder ( apiForSlot ) .
548528 AddInput (& builder.TxInput {
549529 UnlockTarget : fundsAddr ,
550530 InputID : fundsOutputID ,
@@ -562,7 +542,7 @@ func (d *DockerTestFramework) CreateNativeToken(from *Account, mintedAmount iota
562542 AddCommitmentInput (& iotago.CommitmentInput {CommitmentID : lo .Return1 (issuerResp .LatestCommitment .ID ())}).
563543 WithTransactionCapabilities (iotago .TransactionCapabilitiesBitMaskWithCapabilities (iotago .WithTransactionCanDoAnything ())).
564544 AllotAllMana (currentSlot , from .AccountID ).
565- Build (iotago . NewInMemoryAddressSigner ( addressKeys ... ) )
545+ Build (signer )
566546 require .NoError (d .Testing , err )
567547
568548 blkID := d .SubmitPayload (ctx , signedTx , wallet .NewEd25519Account (from .AccountID , from .BlockIssuerKey ), congestionResp , issuerResp )
0 commit comments