Skip to content

Commit

Permalink
add: parse rollback message
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Jun 6, 2024
1 parent af58db2 commit 96256ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 7 additions & 2 deletions relayer/chains/evm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ type IClient interface {
ClaimFee(opts *bind.TransactOpts) (*ethTypes.Transaction, error)

// abiContract for xcall
ParseXcallMessage(log ethTypes.Log) (*bridgeContract.XcallCallMessage, error)
ParseCallMessage(log ethTypes.Log) (*bridgeContract.XcallCallMessage, error)
ParseRollbackMessage(log ethTypes.Log) (*bridgeContract.XcallRollbackMessage, error)
ExecuteCall(opts *bind.TransactOpts, reqID *big.Int, data []byte) (*ethTypes.Transaction, error)
ExecuteRollback(opts *bind.TransactOpts, sn *big.Int) (*ethTypes.Transaction, error)
}
Expand Down Expand Up @@ -281,10 +282,14 @@ func (c *Client) RevertMessage(opts *bind.TransactOpts, sn *big.Int) (*ethTypes.
return c.connection.RevertMessage(opts, sn)
}

func (c *Client) ParseXcallMessage(log ethTypes.Log) (*bridgeContract.XcallCallMessage, error) {
func (c *Client) ParseCallMessage(log ethTypes.Log) (*bridgeContract.XcallCallMessage, error) {
return c.xcall.ParseCallMessage(log)
}

func (c *Client) ParseRollbackMessage(log ethTypes.Log) (*bridgeContract.XcallRollbackMessage, error) {
return c.xcall.ParseRollbackMessage(log)
}

func (c *Client) ExecuteCall(opts *bind.TransactOpts, reqID *big.Int, data []byte) (*ethTypes.Transaction, error) {
return c.xcall.ExecuteCall(opts, reqID, data)
}
Expand Down
14 changes: 13 additions & 1 deletion relayer/chains/evm/event_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (p *Provider) getRelayMessageFromLog(log types.Log) (*providerTypes.Message
Data: msg.Msg,
}, nil
case crypto.Keccak256Hash([]byte(CallMessage)):
msg, err := p.client.ParseXcallMessage(log)
msg, err := p.client.ParseCallMessage(log)
if err != nil {
return nil, fmt.Errorf("error parsing message:%v ", err)
}
Expand All @@ -42,6 +42,18 @@ func (p *Provider) getRelayMessageFromLog(log types.Log) (*providerTypes.Message
Data: msg.Data,
ReqID: msg.ReqId.Uint64(),
}, nil
case crypto.Keccak256Hash([]byte(ExecuteRollback)):
msg, err := p.client.ParseRollbackMessage(log)
if err != nil {
return nil, fmt.Errorf("error parsing message:%v ", err)
}
return &providerTypes.Message{
Dst: p.NID(),
Src: p.NID(),
Sn: msg.Sn.Uint64(),
MessageHeight: log.BlockNumber,
EventType: p.GetEventName(ExecuteRollback),
}, nil
default:
return nil, fmt.Errorf("unknown topic")
}
Expand Down

0 comments on commit 96256ef

Please sign in to comment.