diff --git a/bridge/standard/pkg/gwcontract/gateway.go b/bridge/standard/pkg/gwcontract/gateway.go index 0a7a09db5..0e20b9699 100644 --- a/bridge/standard/pkg/gwcontract/gateway.go +++ b/bridge/standard/pkg/gwcontract/gateway.go @@ -19,6 +19,7 @@ type GatewayTransactor interface { _recipient common.Address, _amount *big.Int, _counterpartyIdx *big.Int, + _finalizationFee *big.Int, ) (*types.Transaction, error) } @@ -71,6 +72,7 @@ func (g *Gateway[EventType]) FinalizeTransfer( recipient common.Address, amount *big.Int, counterpartyIdx *big.Int, + finalizationFee *big.Int, ) error { switch settled, err := g.store.IsSettled(ctx, counterpartyIdx); { case err != nil: @@ -92,6 +94,7 @@ func (g *Gateway[EventType]) FinalizeTransfer( recipient, amount, counterpartyIdx, + finalizationFee, ) if err != nil { g.logger.Error( diff --git a/bridge/standard/pkg/gwcontract/gateway_test.go b/bridge/standard/pkg/gwcontract/gateway_test.go index 6df1ec45a..71d8a5f8d 100644 --- a/bridge/standard/pkg/gwcontract/gateway_test.go +++ b/bridge/standard/pkg/gwcontract/gateway_test.go @@ -100,6 +100,7 @@ func (t *testGatewayTransactor) FinalizeTransfer( recipient common.Address, amount *big.Int, counterpartyIdx *big.Int, + finalizationFee *big.Int, ) (*types.Transaction, error) { newNonce := t.nonce t.nonce++ @@ -143,22 +144,25 @@ func TestGateway(t *testing.T) { transfers := []*l1gateway.L1gatewayTransferInitiated{ { - Sender: common.HexToAddress("0x1234"), - Recipient: common.HexToAddress("0x5678"), - Amount: big.NewInt(100), - TransferIdx: big.NewInt(1), + Sender: common.HexToAddress("0x1234"), + Recipient: common.HexToAddress("0x5678"), + Amount: big.NewInt(100), + TransferIdx: big.NewInt(1), + CounterpartyFinalizationFee: big.NewInt(10), }, { - Sender: common.HexToAddress("0x5678"), - Recipient: common.HexToAddress("0x1234"), - Amount: big.NewInt(200), - TransferIdx: big.NewInt(2), + Sender: common.HexToAddress("0x5678"), + Recipient: common.HexToAddress("0x1234"), + Amount: big.NewInt(200), + TransferIdx: big.NewInt(2), + CounterpartyFinalizationFee: big.NewInt(20), }, { - Sender: common.HexToAddress("0x1234"), - Recipient: common.HexToAddress("0x5678"), - Amount: big.NewInt(300), - TransferIdx: big.NewInt(3), + Sender: common.HexToAddress("0x1234"), + Recipient: common.HexToAddress("0x5678"), + Amount: big.NewInt(300), + TransferIdx: big.NewInt(3), + CounterpartyFinalizationFee: big.NewInt(30), }, } @@ -208,6 +212,7 @@ func TestGateway(t *testing.T) { transfer.Recipient, transfer.Amount, transfer.TransferIdx, + transfer.CounterpartyFinalizationFee, ); err != nil { t.Fatal(err) } @@ -229,6 +234,7 @@ func TestGateway(t *testing.T) { transfers[0].Recipient, transfers[0].Amount, transfers[0].TransferIdx, + transfers[0].CounterpartyFinalizationFee, ); err != nil { t.Fatal(err) } @@ -241,6 +247,7 @@ func TestGateway(t *testing.T) { common.HexToAddress("0x1234"), big.NewInt(100), big.NewInt(4), + big.NewInt(10), ); err == nil { t.Fatal("expected error") } @@ -254,6 +261,7 @@ func publishTransfer( event := brABI.Events["TransferInitiated"] buf, err := event.Inputs.NonIndexed().Pack( transfer.Amount, + transfer.CounterpartyFinalizationFee, ) if err != nil { return err diff --git a/bridge/standard/pkg/relayer/relayer.go b/bridge/standard/pkg/relayer/relayer.go index 8f87b6770..2a13da47e 100644 --- a/bridge/standard/pkg/relayer/relayer.go +++ b/bridge/standard/pkg/relayer/relayer.go @@ -14,12 +14,12 @@ import ( type L1Gateway interface { Subscribe(ctx context.Context) (<-chan *l1gateway.L1gatewayTransferInitiated, <-chan error) - FinalizeTransfer(ctx context.Context, recipient common.Address, amount *big.Int, transferIdx *big.Int) error + FinalizeTransfer(ctx context.Context, recipient common.Address, amount *big.Int, transferIdx *big.Int, finalizationFee *big.Int) error } type SettlementGateway interface { Subscribe(ctx context.Context) (<-chan *settlementgateway.SettlementgatewayTransferInitiated, <-chan error) - FinalizeTransfer(ctx context.Context, recipient common.Address, amount *big.Int, transferIdx *big.Int) error + FinalizeTransfer(ctx context.Context, recipient common.Address, amount *big.Int, transferIdx *big.Int, finalizationFee *big.Int) error } type Relayer struct { @@ -72,6 +72,7 @@ func (r *Relayer) Start(ctx context.Context) <-chan struct{} { upd.Recipient, upd.Amount, upd.TransferIdx, + upd.CounterpartyFinalizationFee, ) if err != nil { r.logger.Error( @@ -104,6 +105,7 @@ func (r *Relayer) Start(ctx context.Context) <-chan struct{} { upd.Recipient, upd.Amount, upd.TransferIdx, + upd.CounterpartyFinalizationFee, ) if err != nil { r.logger.Error(