Skip to content

Commit

Permalink
use actionID throughout chain/transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Apr 21, 2024
1 parent 32abc4b commit c5e4963
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions chain/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (t *Transaction) Digest() ([]byte, error) {
t.Base.Marshal(p)
p.PackBytes(warpBytes)
p.PackInt(len(t.Actions))
for _, action := range t.Actions {
actionID := action.GetTypeID()
for idx, action := range t.Actions {
actionID := action.GetActionID(idx, t.id)

Check failure on line 86 in chain/transaction.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use idx (variable of type int) as uint8 value in argument to action.GetActionID

Check failure on line 86 in chain/transaction.go

View workflow job for this annotation

GitHub Actions / hypersdk-unit-tests

cannot use idx (variable of type int) as uint8 value in argument to action.GetActionID
p.PackByte(actionID)

Check failure on line 87 in chain/transaction.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actionID (variable of type "github.com/ava-labs/hypersdk/codec".Address) as byte value in argument to p.PackByte

Check failure on line 87 in chain/transaction.go

View workflow job for this annotation

GitHub Actions / hypersdk-unit-tests

cannot use actionID (variable of type "github.com/ava-labs/hypersdk/codec".Address) as byte value in argument to p.PackByte
action.Marshal(p)
}
Expand Down Expand Up @@ -580,21 +580,24 @@ func (t *Transaction) Marshal(p *codec.Packer) error {
return p.Err()
}

actionID := t.Action.GetTypeID()
authID := t.Auth.GetTypeID()
t.Base.Marshal(p)
var warpBytes []byte
if t.WarpMessage != nil {
warpBytes = t.WarpMessage.Bytes()
if len(warpBytes) == 0 {
return ErrWarpMessageNotInitialized
// TODO: do I need all this within the loop?
for idx, action := range t.Action {

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of action is never used.
actionID := t.Action.GetActionID(idx, t.id)
authID := t.Auth.GetTypeID()
t.Base.Marshal(p)
var warpBytes []byte
if t.WarpMessage != nil {
warpBytes = t.WarpMessage.Bytes()
if len(warpBytes) == 0 {
return ErrWarpMessageNotInitialized
}
}
p.PackBytes(warpBytes)
p.PackByte(actionID)
t.Action.Marshal(p)
p.PackByte(authID)
t.Auth.Marshal(p)
}
p.PackBytes(warpBytes)
p.PackByte(actionID)
t.Action.Marshal(p)
p.PackByte(authID)
t.Auth.Marshal(p)
return p.Err()
}

Expand Down

0 comments on commit c5e4963

Please sign in to comment.