From a62a89952aa247dce054e98f3dc5e3390a6f83b4 Mon Sep 17 00:00:00 2001 From: zhi Date: Mon, 4 Nov 2024 13:53:03 +0800 Subject: [PATCH] fix cashier format --- witness-service/witness/tokencashierbase.go | 22 +++++++++---------- .../witness/tokencashieronethereum.go | 10 +++++---- .../witness/tokencashieronsolana.go | 4 ++-- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/witness-service/witness/tokencashierbase.go b/witness-service/witness/tokencashierbase.go index 26922e6..c553788 100644 --- a/witness-service/witness/tokencashierbase.go +++ b/witness-service/witness/tokencashierbase.go @@ -51,8 +51,8 @@ func init() { type ( tokenCashierBase struct { id string - cashierContractAddr string - previousCashierAddr string + cashierContractAddr util.Address + previousCashierAddr util.Address recorder AbstractRecorder relayerURL string validatorContractAddr []byte @@ -76,8 +76,8 @@ type ( func newTokenCashierBase( id string, - cashierContractAddr string, - previousCashierAddr string, + cashierContractAddr util.Address, + previousCashierAddr util.Address, recorder AbstractRecorder, relayerURL string, validatorContractAddr []byte, @@ -231,12 +231,12 @@ func (tc *tokenCashierBase) SubmitTransfers() error { if tc.signHandler == nil { return nil } - transfersToSubmit, err := tc.recorder.TransfersToSubmit(tc.cashierContractAddr) + transfersToSubmit, err := tc.recorder.TransfersToSubmit(tc.cashierContractAddr.String()) if err != nil { return err } - if tc.previousCashierAddr != "" { - transfersFromPreviousCashier, err := tc.recorder.TransfersToSubmit(tc.previousCashierAddr) + if tc.previousCashierAddr != nil { + transfersFromPreviousCashier, err := tc.recorder.TransfersToSubmit(tc.previousCashierAddr.String()) if err != nil { return err } @@ -289,7 +289,7 @@ func (tc *tokenCashierBase) ProcessStales() error { defer conn.Close() relayer := services.NewRelayServiceClient(conn) response, err := relayer.StaleHeights(context.Background(), &services.StaleHeightsRequest{ - Cashier: common.HexToAddress(tc.id).Bytes(), + Cashier: tc.cashierContractAddr.Bytes(), }) if err != nil { return errors.Wrap(err, "failed to fetch stale heights") @@ -303,12 +303,12 @@ func (tc *tokenCashierBase) ProcessStales() error { } func (tc *tokenCashierBase) CheckTransfers() error { - transfersToSettle, err := tc.recorder.TransfersToSettle(tc.cashierContractAddr) + transfersToSettle, err := tc.recorder.TransfersToSettle(tc.cashierContractAddr.String()) if err != nil { return errors.Wrap(err, "failed to fetch transfers to settle") } - if tc.previousCashierAddr != "" { - transfersFromPreviousCashier, err := tc.recorder.TransfersToSettle(tc.previousCashierAddr) + if tc.previousCashierAddr != nil { + transfersFromPreviousCashier, err := tc.recorder.TransfersToSettle(tc.previousCashierAddr.String()) if err != nil { return errors.Wrap(err, "failed to fetch transfers from previous cashier to settle") } diff --git a/witness-service/witness/tokencashieronethereum.go b/witness-service/witness/tokencashieronethereum.go index a2f7614..5955236 100644 --- a/witness-service/witness/tokencashieronethereum.go +++ b/witness-service/witness/tokencashieronethereum.go @@ -238,13 +238,15 @@ func NewTokenCashierOnEthereum( if err != nil { return nil, err } - pa := previousCashierAddr.String() - if pa == "0x0000000000000000000000000000000000000000" { - pa = "" + var pa util.Address + if previousCashierAddr.String() == "0x0000000000000000000000000000000000000000" { + pa = nil + } else { + pa = util.ETHAddressToAddress(previousCashierAddr) } return newTokenCashierBase( id, - cashierContractAddr.String(), + util.ETHAddressToAddress(cashierContractAddr), pa, recorder, relayerURL, diff --git a/witness-service/witness/tokencashieronsolana.go b/witness-service/witness/tokencashieronsolana.go index e318c63..7bbde4b 100644 --- a/witness-service/witness/tokencashieronsolana.go +++ b/witness-service/witness/tokencashieronsolana.go @@ -47,8 +47,8 @@ func NewTokenCashierOnSolana( } return newTokenCashierBase( id, - cashier.String(), - "", + util.SOLAddressToAddress(cashier), + nil, recorder, relayerURL, validatorAddr.Bytes(),