Skip to content

Commit

Permalink
Also add String() method for contract events
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Nov 14, 2023
1 parent b478260 commit eb2984b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions xdr/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package xdr

import (
"encoding/hex"
"fmt"
)

func (ce ContractEvent) String() string {
result := ce.Type.String() + "("
if ce.ContractId != nil {
result += hex.EncodeToString(ce.ContractId[:]) + ","
}
result += ce.Body.String()
return result
}

func (eb ContractEventBody) String() string {
return fmt.Sprintf("%+v", *eb.V0)
}

func (de DiagnosticEvent) String() string {
return fmt.Sprintf("%s, successful call: %t", de.Event, de.InSuccessfulContractCall)
}
2 changes: 1 addition & 1 deletion xdr/scval.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (s ScVal) String() string {
case ScValTypeScvI64:
return fmt.Sprintf("%d", *s.I64)
case ScValTypeScvTimepoint:
return fmt.Sprintf("%s", time.Unix(int64(*s.Timepoint), 0))
return time.Unix(int64(*s.Timepoint), 0).String()
case ScValTypeScvDuration:
return fmt.Sprintf("%d", *s.Duration)
case ScValTypeScvU128:
Expand Down

0 comments on commit eb2984b

Please sign in to comment.