@@ -22,7 +22,6 @@ import (
22
22
"github.com/iotaledger/hive.go/lo"
23
23
"github.com/iotaledger/hive.go/runtime/options"
24
24
"github.com/iotaledger/iota-core/pkg/protocol"
25
- "github.com/iotaledger/iota-core/pkg/testsuite/depositcalculator"
26
25
"github.com/iotaledger/iota-core/pkg/testsuite/snapshotcreator"
27
26
iotago "github.com/iotaledger/iota.go/v4"
28
27
"github.com/iotaledger/iota.go/v4/api"
@@ -486,6 +485,8 @@ func (d *DockerTestFramework) AllotManaTo(from *Account, to *Account, manaToAllo
486
485
487
486
// CreateNativeToken request faucet funds then use it to create native token for the account, and returns the updated Account.
488
487
func (d * DockerTestFramework ) CreateNativeToken (from * Account , mintedAmount iotago.BaseToken , maxSupply iotago.BaseToken ) (updatedAccount * Account ) {
488
+ require .GreaterOrEqual (d .Testing , maxSupply , mintedAmount )
489
+
489
490
// requesting faucet funds for native token creation
490
491
ctx := context .TODO ()
491
492
fundsAddr , privateKey := d .getAddress (iotago .AddressEd25519 )
@@ -495,15 +496,6 @@ func (d *DockerTestFramework) CreateNativeToken(from *Account, mintedAmount iota
495
496
currentSlot := clt .LatestAPI ().TimeProvider ().SlotFromTime (time .Now ())
496
497
apiForSlot := clt .APIForSlot (currentSlot )
497
498
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
-
507
499
// increase foundry counter
508
500
accTransitionOutput := builder .NewAccountOutputBuilderFromPrevious (from .AccountOutput ).
509
501
FoundriesToGenerate (1 ).MustBuild ()
@@ -517,34 +509,22 @@ func (d *DockerTestFramework) CreateNativeToken(from *Account, mintedAmount iota
517
509
MeltedTokens : big .NewInt (0 ),
518
510
}
519
511
520
- foundryOutput := builder .NewFoundryOutputBuilder (from .AccountAddress , mintedAmount , accTransitionOutput .FoundryCounter , tokenScheme ).
512
+ foundryOutput := builder .NewFoundryOutputBuilder (from .AccountAddress , fundsUTXOOutput . BaseTokenAmount () , accTransitionOutput .FoundryCounter , tokenScheme ).
521
513
NativeToken (& iotago.NativeTokenFeature {
522
514
ID : foundryID ,
523
515
Amount : big .NewInt (int64 (mintedAmount )),
524
516
}).MustBuild ()
525
517
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 ))
540
520
541
521
issuerResp , err := clt .BlockIssuance (ctx )
542
522
require .NoError (d .Testing , err )
543
523
544
524
congestionResp , err := clt .Congestion (ctx , from .AccountAddress , lo .PanicOnErr (issuerResp .LatestCommitment .ID ()))
545
525
require .NoError (d .Testing , err )
546
526
547
- signedTx , err := signedTxBuilder .
527
+ signedTx , err := builder . NewTransactionBuilder ( apiForSlot ) .
548
528
AddInput (& builder.TxInput {
549
529
UnlockTarget : fundsAddr ,
550
530
InputID : fundsOutputID ,
@@ -562,7 +542,7 @@ func (d *DockerTestFramework) CreateNativeToken(from *Account, mintedAmount iota
562
542
AddCommitmentInput (& iotago.CommitmentInput {CommitmentID : lo .Return1 (issuerResp .LatestCommitment .ID ())}).
563
543
WithTransactionCapabilities (iotago .TransactionCapabilitiesBitMaskWithCapabilities (iotago .WithTransactionCanDoAnything ())).
564
544
AllotAllMana (currentSlot , from .AccountID ).
565
- Build (iotago . NewInMemoryAddressSigner ( addressKeys ... ) )
545
+ Build (signer )
566
546
require .NoError (d .Testing , err )
567
547
568
548
blkID := d .SubmitPayload (ctx , signedTx , wallet .NewEd25519Account (from .AccountID , from .BlockIssuerKey ), congestionResp , issuerResp )
0 commit comments