Skip to content

Commit

Permalink
allow fee granter to free lane
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha committed Nov 18, 2024
1 parent ffef9b9 commit 88e8faa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
10 changes: 9 additions & 1 deletion x/opchild/lanes/free.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ func (h FreeLaneMatchHandler) MatchHandler() base.MatchHandler {
} else if payer, err := h.ac.BytesToString(feeTx.FeePayer()); err != nil {
return false
} else {
var granter string
if feeTx.FeeGranter() != nil {
granter, err = h.ac.BytesToString(feeTx.FeeGranter())
if err != nil {
return false
}

Check warning on line 47 in x/opchild/lanes/free.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/lanes/free.go#L46-L47

Added lines #L46 - L47 were not covered by tests
}

for _, addr := range whitelist {
if addr == payer {
if addr == payer || addr == granter {
return true
}
}
Expand Down
22 changes: 19 additions & 3 deletions x/opchild/lanes/free_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,30 @@ func Test_FreeLaneMatchHandler(t *testing.T) {
require.True(t, handler(ctx, MockTx{
feePayer: []byte{3, 4, 5, 6},
}))

require.True(t, handler(ctx, MockTx{
feePayer: []byte{2, 3, 4, 5},
feeGranter: []byte{0, 1, 2, 3},
}))

require.True(t, handler(ctx, MockTx{
feePayer: []byte{2, 3, 4, 5},
feeGranter: []byte{3, 4, 5, 6},
}))

require.False(t, handler(ctx, MockTx{
feePayer: []byte{2, 3, 4, 5},
feeGranter: []byte{2, 3, 5, 6},
}))
}

var _ sdk.Tx = MockTx{}
var _ sdk.FeeTx = &MockTx{}

type MockTx struct {
msgs []sdk.Msg
feePayer []byte
msgs []sdk.Msg
feePayer []byte
feeGranter []byte
}

func (tx MockTx) GetMsgsV2() ([]protov2.Message, error) {
Expand All @@ -82,5 +98,5 @@ func (tx MockTx) FeePayer() []byte {
return tx.feePayer
}
func (tx MockTx) FeeGranter() []byte {
return nil
return tx.feeGranter
}

0 comments on commit 88e8faa

Please sign in to comment.