From 88e8faa3f6bda7286ae6d70004b0fdf8c6895829 Mon Sep 17 00:00:00 2001 From: sh-cha Date: Mon, 18 Nov 2024 21:39:56 +0900 Subject: [PATCH] allow fee granter to free lane --- x/opchild/lanes/free.go | 10 +++++++++- x/opchild/lanes/free_test.go | 22 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/x/opchild/lanes/free.go b/x/opchild/lanes/free.go index 344ec450..da6cab73 100644 --- a/x/opchild/lanes/free.go +++ b/x/opchild/lanes/free.go @@ -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 + } + } + for _, addr := range whitelist { - if addr == payer { + if addr == payer || addr == granter { return true } } diff --git a/x/opchild/lanes/free_test.go b/x/opchild/lanes/free_test.go index c18fcdf9..a35d4c8b 100644 --- a/x/opchild/lanes/free_test.go +++ b/x/opchild/lanes/free_test.go @@ -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) { @@ -82,5 +98,5 @@ func (tx MockTx) FeePayer() []byte { return tx.feePayer } func (tx MockTx) FeeGranter() []byte { - return nil + return tx.feeGranter }