Skip to content

Commit

Permalink
fix cashier format
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderZhi committed Nov 4, 2024
1 parent b134b2a commit a62a899
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
22 changes: 11 additions & 11 deletions witness-service/witness/tokencashierbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand All @@ -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")
}
Expand Down
10 changes: 6 additions & 4 deletions witness-service/witness/tokencashieronethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions witness-service/witness/tokencashieronsolana.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func NewTokenCashierOnSolana(
}
return newTokenCashierBase(
id,
cashier.String(),
"",
util.SOLAddressToAddress(cashier),
nil,
recorder,
relayerURL,
validatorAddr.Bytes(),
Expand Down

0 comments on commit a62a899

Please sign in to comment.