Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/transactions/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (r *transactionResult) JSON() any {
func (r *transactionResult) String() string {
var b bytes.Buffer
writer := util.CreateTabWriter(&b)
const feeEventsCountAppended = 5
const feeEventsCountAppended = 4
const feeDeductedEvent = "FeesDeducted"

if r.result != nil {
Expand Down Expand Up @@ -207,8 +207,12 @@ func (r *transactionResult) String() string {
if r.result != nil && e.Events != nil && !command.ContainsFlag(r.include, "fee-events") {
for _, event := range e.Events {
if strings.Contains(event.Type, feeDeductedEvent) {
// if fee event are present remove them
e.Events = e.Events[:len(e.Events)-feeEventsCountAppended]
// if fee events are present, remove as many as possible (up to 4)
numToRemove := feeEventsCountAppended
if len(e.Events) < feeEventsCountAppended {
numToRemove = len(e.Events)
}
e.Events = e.Events[:len(e.Events)-numToRemove]
break
}
}
Expand Down
28 changes: 8 additions & 20 deletions internal/transactions/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,26 +368,20 @@ func Test_Result(t *testing.T) {
[]cadence.Field{{Type: cadence.StringType, Identifier: "bar"}},
[]cadence.Value{cadence.NewInt(1)},
)
withdrawFungiEvent := tests.NewEvent(
2,
"A.9a0766d93b6608b7.FungibleToken.TokensWithdrawn",
[]cadence.Field{{Type: cadence.StringType, Identifier: "bar"}},
[]cadence.Value{cadence.NewInt(1)},
)
depositFlowEvent := tests.NewEvent(
3,
2,
"A.1654653399040a61.FlowToken.TokensDeposited",
[]cadence.Field{{Type: cadence.StringType, Identifier: "bar"}},
[]cadence.Value{cadence.NewInt(1)},
)
depositFungiEvent := tests.NewEvent(
4,
"A.9a0766d93b6608b7.FungibleToken.TokensDeposited",
storageUsedEvent := tests.NewEvent(
3,
"A.1654653399040a61.FlowStorageFees.StorageCapacityUsed",
[]cadence.Field{{Type: cadence.StringType, Identifier: "bar"}},
[]cadence.Value{cadence.NewInt(1)},
)
feeEvent := tests.NewEvent(
5,
4,
"A.f919ee77447b7497.FlowFees.FeesDeducted",
[]cadence.Field{{Type: cadence.StringType, Identifier: "bar"}},
[]cadence.Value{cadence.NewInt(1)},
Expand All @@ -403,7 +397,7 @@ func Test_Result(t *testing.T) {
txResultFeeEvents := &flow.TransactionResult{
Status: flow.TransactionStatusSealed,
Error: nil,
Events: []flow.Event{*event, *withdrawFlowEvent, *withdrawFungiEvent, *depositFlowEvent, *depositFungiEvent, *feeEvent},
Events: []flow.Event{*event, *withdrawFlowEvent, *depositFlowEvent, *storageUsedEvent, *feeEvent},
BlockID: flow.HexToID("7aa74143741c1c3b837d389fcffa7a5e251b67b4ffef6d6887b40cd9c803f537"),
BlockHeight: 1,
}
Expand Down Expand Up @@ -562,24 +556,18 @@ Events:
- bar (String): 1

Index 2
Type A.9a0766d93b6608b7.FungibleToken.TokensWithdrawn
Type A.1654653399040a61.FlowToken.TokensDeposited
Tx ID 0000000000000000000000000000000000000000000000000000000000000000
Values
- bar (String): 1

Index 3
Type A.1654653399040a61.FlowToken.TokensDeposited
Type A.1654653399040a61.FlowStorageFees.StorageCapacityUsed
Tx ID 0000000000000000000000000000000000000000000000000000000000000000
Values
- bar (String): 1

Index 4
Type A.9a0766d93b6608b7.FungibleToken.TokensDeposited
Tx ID 0000000000000000000000000000000000000000000000000000000000000000
Values
- bar (String): 1

Index 5
Type A.f919ee77447b7497.FlowFees.FeesDeducted
Tx ID 0000000000000000000000000000000000000000000000000000000000000000
Values
Expand Down
Loading