Skip to content

Commit

Permalink
Merge pull request #393 from iotaledger/fix/native-tokens-simplification
Browse files Browse the repository at this point in the history
Fix native token and tx capabilities simpification.
  • Loading branch information
muXxer authored Oct 2, 2023
2 parents bf81329 + 6a80296 commit d1eae31
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 176 deletions.
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/iotaledger/hive.go/ads v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/app v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/constraints v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20230928074706-d58e32f86729
github.com/iotaledger/hive.go/crypto v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/constraints v0.0.0-20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/crypto v0.0.0-20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/ds v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/ierrors v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/ierrors v0.0.0-20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/kvstore v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/lo v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/lo v0.0.0-20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/logger v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/runtime v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230928074706-d58e32f86729
github.com/iotaledger/hive.go/stringify v0.0.0-20230928074706-d58e32f86729
github.com/iotaledger/hive.go/runtime v0.0.0-20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230929122509-67f34bfed40d
github.com/iotaledger/hive.go/stringify v0.0.0-20230929122509-67f34bfed40d
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd
github.com/iotaledger/iota.go/v4 v4.0.0-20230929090257-1620d009ba8c
github.com/iotaledger/iota.go/v4 v4.0.0-20231002120511-9ab88bf44daf
github.com/labstack/echo/v4 v4.11.1
github.com/labstack/gommon v0.4.0
github.com/libp2p/go-libp2p v0.30.0
Expand Down
36 changes: 18 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -279,34 +279,34 @@ github.com/iotaledger/hive.go/ads v0.0.0-20230928074706-d58e32f86729 h1:HHxgNhbt
github.com/iotaledger/hive.go/ads v0.0.0-20230928074706-d58e32f86729/go.mod h1:IAWZ/5It5P8B41mWyJXJVcG0vuikVRaTFKQnr2D2q+c=
github.com/iotaledger/hive.go/app v0.0.0-20230928074706-d58e32f86729 h1:rBADf+IZDKkDOuZznwIdonxF9jcOSQJU/qOYSNInX84=
github.com/iotaledger/hive.go/app v0.0.0-20230928074706-d58e32f86729/go.mod h1:eiZgbcwTDZ7d9hEait2EAwAhixWhceW4MXmuVk2EcEw=
github.com/iotaledger/hive.go/constraints v0.0.0-20230928074706-d58e32f86729 h1:PQ9TFyXBrV6LLTOzE43CV/vz+ItN5v6lcA7ms0YOvcE=
github.com/iotaledger/hive.go/constraints v0.0.0-20230928074706-d58e32f86729/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20230928074706-d58e32f86729 h1:mwIZhduBiOD4rG4hqrPhW616EU1wX4eD2zHu26be5Yc=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20230928074706-d58e32f86729/go.mod h1:jn3TNmiNRIiQm/rS4VD+7wFHI2+UXABHvCA3PbQxBqI=
github.com/iotaledger/hive.go/crypto v0.0.0-20230928074706-d58e32f86729 h1:FpFlPNOHcvHDyk1gN3OuL/hgvTKVsc5IN+q8U1YF9P4=
github.com/iotaledger/hive.go/crypto v0.0.0-20230928074706-d58e32f86729/go.mod h1:jP68na941d9uq7RtnA8aQ/FtIGRGz/51cU4uXrInQFU=
github.com/iotaledger/hive.go/constraints v0.0.0-20230929122509-67f34bfed40d h1:bZXrxulDoDBsNg0wtXowrAyltjfgZahiGYuAoS5GKU4=
github.com/iotaledger/hive.go/constraints v0.0.0-20230929122509-67f34bfed40d/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20230929122509-67f34bfed40d h1:pRcB0wfWAlfDJ10ZZ6LK1ukRXcPaL299LLU/zbYWnsQ=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20230929122509-67f34bfed40d/go.mod h1:jn3TNmiNRIiQm/rS4VD+7wFHI2+UXABHvCA3PbQxBqI=
github.com/iotaledger/hive.go/crypto v0.0.0-20230929122509-67f34bfed40d h1:Vn8BY/hLTcKJWh8LCw6PDTbCK2562wq93MPynV1pHjE=
github.com/iotaledger/hive.go/crypto v0.0.0-20230929122509-67f34bfed40d/go.mod h1:jP68na941d9uq7RtnA8aQ/FtIGRGz/51cU4uXrInQFU=
github.com/iotaledger/hive.go/ds v0.0.0-20230928074706-d58e32f86729 h1:hHdIZn95+HdP1JdjV8TAsuL5kU4eb4gncehyjXo/feQ=
github.com/iotaledger/hive.go/ds v0.0.0-20230928074706-d58e32f86729/go.mod h1:ZrqsjIJS2QCgGp7Ki+l4hWJQgzfBObUCemb5Upwlx18=
github.com/iotaledger/hive.go/ierrors v0.0.0-20230928074706-d58e32f86729 h1:+/OtOAx2tMy8ER3XBt9RpnspWyDrVqW6kQGAd24jT0k=
github.com/iotaledger/hive.go/ierrors v0.0.0-20230928074706-d58e32f86729/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
github.com/iotaledger/hive.go/ierrors v0.0.0-20230929122509-67f34bfed40d h1:tmaZvkBCP/OrQrwC728AEFtRAW8YUHBVNE8IXxtd4C4=
github.com/iotaledger/hive.go/ierrors v0.0.0-20230929122509-67f34bfed40d/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
github.com/iotaledger/hive.go/kvstore v0.0.0-20230928074706-d58e32f86729 h1:XCYvP8XwETTXF5LNz8q9X3EajDut7+UwTwqJ2TQ0TJo=
github.com/iotaledger/hive.go/kvstore v0.0.0-20230928074706-d58e32f86729/go.mod h1:DeP4JF4N995LteD0+/o7NsW1bO5IXURIJ27A69Ca5+Y=
github.com/iotaledger/hive.go/lo v0.0.0-20230928074706-d58e32f86729 h1:hW4r9no+03ufp2fyx4IjTFwINkEz3OI3LqvSjv7SJ1c=
github.com/iotaledger/hive.go/lo v0.0.0-20230928074706-d58e32f86729/go.mod h1:4oKCdMEhHMLCudBz79kuvJmgSY/DhfVePNIyJhew/80=
github.com/iotaledger/hive.go/lo v0.0.0-20230929122509-67f34bfed40d h1:qNmg1DUvge8zPvygQEoulQjLG7gFzWKqPMJ3r7ZESm0=
github.com/iotaledger/hive.go/lo v0.0.0-20230929122509-67f34bfed40d/go.mod h1:4oKCdMEhHMLCudBz79kuvJmgSY/DhfVePNIyJhew/80=
github.com/iotaledger/hive.go/logger v0.0.0-20230928074706-d58e32f86729 h1:FOQetJY2scpCtCGrZQWGw3RwB3lRIDdyu+M6P1NACM4=
github.com/iotaledger/hive.go/logger v0.0.0-20230928074706-d58e32f86729/go.mod h1:sxqWRdZ1OOxwkxVczuGcW034Mpt2vFh5ebJHO++ZYeI=
github.com/iotaledger/hive.go/runtime v0.0.0-20230928074706-d58e32f86729 h1:4aRR9UG4dHpdlTcMN1Px++eaxlGXXk1n6co8t/WlchM=
github.com/iotaledger/hive.go/runtime v0.0.0-20230928074706-d58e32f86729/go.mod h1:fXVyQ1MAwxe/EmjAnG8WcQqbzGk9EW/FsJ/n16H/f/w=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230928074706-d58e32f86729 h1:mPmP3/0XJAf0ZkCzQenpoQPMv+m56Z8+A1i/UO18Hdw=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230928074706-d58e32f86729/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I=
github.com/iotaledger/hive.go/stringify v0.0.0-20230928074706-d58e32f86729 h1:gZlIK1OzdA3aZ78PsiWe3poVzawyw4S3zboMHE1TrY0=
github.com/iotaledger/hive.go/stringify v0.0.0-20230928074706-d58e32f86729/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/hive.go/runtime v0.0.0-20230929122509-67f34bfed40d h1:mn2Gax95UuUpuzEi4osLk+1IBjv5q56LwcxF/lAxk38=
github.com/iotaledger/hive.go/runtime v0.0.0-20230929122509-67f34bfed40d/go.mod h1:fXVyQ1MAwxe/EmjAnG8WcQqbzGk9EW/FsJ/n16H/f/w=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230929122509-67f34bfed40d h1:1839CFkegKrSvTfWkgYHpH1pudehOXxX05Mzy1KSR7I=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230929122509-67f34bfed40d/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I=
github.com/iotaledger/hive.go/stringify v0.0.0-20230929122509-67f34bfed40d h1:ekHWRypoaiCXgrJVUQS7rCewsK3FuG1gTbPxu5jYn9c=
github.com/iotaledger/hive.go/stringify v0.0.0-20230929122509-67f34bfed40d/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 h1:lQiktl3Q0B+cHbVum7WzJikOEP+buw686oSrw5Unyz8=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182/go.mod h1:q24QEsS887ZWJVX76w2kwSgC84KS7wIKOy1otuqZ2ZM=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd h1:nFG3Zq/zFA4KhBYFX2IezX1C74zfE0DqCt0LrgTa9Ig=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd/go.mod h1:c5778OnWpLq108YE+Eb2m8Ri/t/4ydV0TvI/Sy5YivQ=
github.com/iotaledger/iota.go/v4 v4.0.0-20230929090257-1620d009ba8c h1:faTwv2r4EZ6FixcFtaSD5M02YRm+/kmQKsLBsYSJl3I=
github.com/iotaledger/iota.go/v4 v4.0.0-20230929090257-1620d009ba8c/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo=
github.com/iotaledger/iota.go/v4 v4.0.0-20231002120511-9ab88bf44daf h1:TNt6qra1H62HctwYhoxujPml/uN2AtnE1zMkB5kkVfI=
github.com/iotaledger/iota.go/v4 v4.0.0-20231002120511-9ab88bf44daf/go.mod h1:+e3bsJFDr9HxmUMe+eQOLNut5wfcB/ivhJdouOJgOnE=
github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY=
github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down
4 changes: 0 additions & 4 deletions pkg/protocol/engine/ledger/tests/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ func (m *MockedOutput) StoredMana() iotago.Mana {
panic("implement me")
}

func (m *MockedOutput) NativeTokenList() iotago.NativeTokens {
panic("implement me")
}

func (m *MockedOutput) UnlockConditionSet() iotago.UnlockConditionSet {
panic("implement me")
}
Expand Down
23 changes: 9 additions & 14 deletions pkg/protocol/engine/utxoledger/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func TestExtendedOutputOnEd25519WithoutSpendConstraintsSerialization(t *testing.
index := utils.RandSlotIndex()

iotaOutput := &iotago.BasicOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
Amount: amount,
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{
Address: address,
Expand Down Expand Up @@ -156,8 +155,7 @@ func TestExtendedOutputOnEd25519WithSpendConstraintsSerialization(t *testing.T)
timeLockUnlockSlot := utils.RandSlotIndex()

iotaOutput := &iotago.BasicOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
Amount: amount,
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{
Address: address,
Expand Down Expand Up @@ -189,9 +187,8 @@ func TestNFTOutputSerialization(t *testing.T) {
index := utils.RandSlotIndex()

iotaOutput := &iotago.NFTOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
NFTID: nftID,
Amount: amount,
NFTID: nftID,
Conditions: iotago.NFTOutputUnlockConditions{
&iotago.AddressUnlockCondition{
Address: address,
Expand Down Expand Up @@ -223,9 +220,8 @@ func TestNFTOutputWithSpendConstraintsSerialization(t *testing.T) {
expirationUnlockSlot := utils.RandSlotIndex()

iotaOutput := &iotago.NFTOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
NFTID: nftID,
Amount: amount,
NFTID: nftID,
Conditions: iotago.NFTOutputUnlockConditions{
&iotago.AddressUnlockCondition{
Address: address.ToAddress(),
Expand Down Expand Up @@ -265,9 +261,8 @@ func TestAccountOutputSerialization(t *testing.T) {
index := utils.RandSlotIndex()

iotaOutput := &iotago.AccountOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
AccountID: aliasID,
Amount: amount,
AccountID: aliasID,
Conditions: iotago.AccountOutputUnlockConditions{
&iotago.StateControllerAddressUnlockCondition{
Address: stateController.ToAddress(),
Expand All @@ -276,6 +271,7 @@ func TestAccountOutputSerialization(t *testing.T) {
Address: governor,
},
},
StateMetadata: make([]byte, 0),
Features: iotago.AccountOutputFeatures{
&iotago.SenderFeature{
Address: sender.ToAddress(),
Expand Down Expand Up @@ -305,7 +301,6 @@ func TestFoundryOutputSerialization(t *testing.T) {

iotaOutput := &iotago.FoundryOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
SerialNumber: utils.RandUint32(math.MaxUint32),
TokenScheme: &iotago.SimpleTokenScheme{
MintedTokens: supply,
Expand Down
3 changes: 1 addition & 2 deletions pkg/protocol/engine/utxoledger/slot_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ func TestSimpleSlotDiffSerialization(t *testing.T) {
address := utils.RandAddress(iotago.AddressEd25519)
amount := iotago.BaseToken(832493)
iotaOutput := &iotago.BasicOutput{
Amount: amount,
NativeTokens: iotago.NativeTokens{},
Amount: amount,
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{
Address: address,
Expand Down
7 changes: 3 additions & 4 deletions pkg/protocol/snapshotcreator/snapshotcreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ func createOutput(address iotago.Address, tokenAmount iotago.BaseToken) (output

func createAccount(accountID iotago.AccountID, address iotago.Address, tokenAmount iotago.BaseToken, mana iotago.Mana, blockIssuerKey iotago.BlockIssuerKey, expirySlot iotago.SlotIndex, stakedAmount iotago.BaseToken, stakeEndEpoch iotago.EpochIndex, stakeFixedCost iotago.Mana) (output iotago.Output) {
accountOutput := &iotago.AccountOutput{
Amount: tokenAmount,
Mana: mana,
NativeTokens: iotago.NativeTokens{},
AccountID: accountID,
Amount: tokenAmount,
Mana: mana,
AccountID: accountID,
Conditions: iotago.AccountOutputUnlockConditions{
&iotago.StateControllerAddressUnlockCondition{Address: address},
&iotago.GovernorAddressUnlockCondition{Address: address},
Expand Down
5 changes: 2 additions & 3 deletions pkg/retainer/retainer/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ var txErrorsFailureReasonMap = map[error]apimodels.TransactionFailureReason{
iotago.ErrInputAlreadySpent: apimodels.TxFailureUTXOInputAlreadySpent,

// native token errors
iotago.ErrNativeTokenSetInvalid: apimodels.TxFailureGivenNativeTokensInvalid,
iotago.ErrMaxNativeTokensCountExceeded: apimodels.TxFailureGivenNativeTokensInvalid,
iotago.ErrNativeTokenSumUnbalanced: apimodels.TxFailureGivenNativeTokensInvalid,
iotago.ErrNativeTokenSetInvalid: apimodels.TxFailureGivenNativeTokensInvalid,
iotago.ErrNativeTokenSumUnbalanced: apimodels.TxFailureGivenNativeTokensInvalid,

// vm errors
iotago.ErrInputOutputSumMismatch: apimodels.TxFailureSumOfInputAndOutputValuesDoesNotMatch,
Expand Down
10 changes: 3 additions & 7 deletions pkg/testsuite/mock/hdwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,9 @@ func (hd *HDWallet) PrintStatus() {
status += "Outputs: \n"
for _, u := range hd.utxo {
nativeTokenDescription := ""
nativeTokens := u.Output().NativeTokenList().MustSet()
if len(nativeTokens) > 0 {
nativeTokenDescription = "["
for id, amount := range nativeTokens {
nativeTokenDescription += fmt.Sprintf("%s: %s, ", id.ToHex(), amount.Amount)
}
nativeTokenDescription += "]"
nativeTokenFeature := u.Output().FeatureSet().NativeToken()
if nativeTokenFeature != nil {
nativeTokenDescription += fmt.Sprintf("%s: %s, ", nativeTokenFeature.ID.ToHex(), nativeTokenFeature.Amount)
}
status += fmt.Sprintf("\t%s [%s] = %d %v\n", u.OutputID().ToHex(), u.OutputType(), u.BaseTokenAmount(), nativeTokenDescription)
}
Expand Down
38 changes: 13 additions & 25 deletions pkg/testsuite/transactions_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (t *TransactionFramework) CreateTransactionWithOptions(alias string, signin
}

txBuilder := builder.NewTransactionBuilder(currentAPI)

txBuilder.WithTransactionCapabilities(iotago.TransactionCapabilitiesBitMaskWithCapabilities(iotago.WithTransactionCanDoAnything()))
// Always add a random payload to randomize transaction ID.
randomPayload := tpkg.Rand12ByteArray()
txBuilder.AddTaggedDataPayload(&iotago.TaggedData{Tag: randomPayload[:], Data: randomPayload[:]})
Expand Down Expand Up @@ -130,9 +130,8 @@ func (t *TransactionFramework) CreateBasicOutputsEqually(outputCount int, inputA
remainderMana -= manaAmount

outputStates = append(outputStates, &iotago.BasicOutput{
Amount: tokenAmount,
Mana: manaAmount,
NativeTokens: iotago.NativeTokens{},
Amount: tokenAmount,
Mana: manaAmount,
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{Address: t.DefaultAddress()},
},
Expand Down Expand Up @@ -166,9 +165,8 @@ func (t *TransactionFramework) CreateBasicOutputs(amountDistribution []iotago.Ba
outputStates := make(iotago.Outputs[iotago.Output], 0, len(amountDistribution))
for idx, outputAmount := range amountDistribution {
outputStates = append(outputStates, &iotago.BasicOutput{
Amount: outputAmount,
Mana: manaDistribution[idx],
NativeTokens: iotago.NativeTokens{},
Amount: outputAmount,
Mana: manaDistribution[idx],
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{Address: t.DefaultAddress()},
},
Expand All @@ -193,9 +191,8 @@ func (t *TransactionFramework) CreateAccountFromInput(inputAlias string, opts ..
// if amount was set by options, a remainder output needs to be created
if accountOutput.Amount != input.BaseTokenAmount() {
outputStates = append(outputStates, &iotago.BasicOutput{
Amount: input.BaseTokenAmount() - accountOutput.Amount,
Mana: input.StoredMana() - accountOutput.Mana,
NativeTokens: iotago.NativeTokens{},
Amount: input.BaseTokenAmount() - accountOutput.Amount,
Mana: input.StoredMana() - accountOutput.Mana,
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{Address: t.DefaultAddress()},
},
Expand All @@ -214,9 +211,8 @@ func (t *TransactionFramework) CreateImplicitAccountFromInput(inputAlias string)
implicitAccountAddress := t.DefaultAddress(iotago.AddressImplicitAccountCreation).(*iotago.ImplicitAccountCreationAddress)

basicOutput := &iotago.BasicOutput{
Amount: input.BaseTokenAmount(),
Mana: input.StoredMana(),
NativeTokens: iotago.NativeTokens{},
Amount: input.BaseTokenAmount(),
Mana: input.StoredMana(),
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{Address: implicitAccountAddress},
},
Expand Down Expand Up @@ -247,9 +243,8 @@ func (t *TransactionFramework) CreateDelegationFromInput(inputAlias string, opts
// if options set an Amount, a remainder output needs to be created
if delegationOutput.Amount != input.BaseTokenAmount() {
outputStates = append(outputStates, &iotago.BasicOutput{
Amount: input.BaseTokenAmount() - delegationOutput.Amount,
Mana: input.StoredMana(),
NativeTokens: iotago.NativeTokens{},
Amount: input.BaseTokenAmount() - delegationOutput.Amount,
Mana: input.StoredMana(),
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{Address: t.DefaultAddress()},
},
Expand Down Expand Up @@ -284,9 +279,8 @@ func (t *TransactionFramework) DestroyAccount(alias string) (consumedInputs *utx
output := t.Output(alias)

outputStates := iotago.Outputs[iotago.Output]{&iotago.BasicOutput{
Amount: output.BaseTokenAmount(),
Mana: output.StoredMana(),
NativeTokens: iotago.NativeTokens{},
Amount: output.BaseTokenAmount(),
Mana: output.StoredMana(),
Conditions: iotago.BasicOutputUnlockConditions{
&iotago.AddressUnlockCondition{Address: t.DefaultAddress()},
},
Expand Down Expand Up @@ -496,12 +490,6 @@ func WithAccountConditions(conditions iotago.AccountOutputUnlockConditions) opti
}
}

func WithAccountNativeTokens(nativeTokens iotago.NativeTokens) options.Option[builder.AccountOutputBuilder] {
return func(accountBuilder *builder.AccountOutputBuilder) {
accountBuilder.NativeTokens(nativeTokens)
}
}

// TransactionBuilder options

func WithInputs(inputs utxoledger.Outputs) options.Option[builder.TransactionBuilder] {
Expand Down
Loading

0 comments on commit d1eae31

Please sign in to comment.