Skip to content

Commit

Permalink
validate contract address
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCherepovskyi committed Oct 4, 2024
1 parent 429d01b commit 3dd8ee8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/bridge/processor/get_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (p *Processor) ProcessGetDepositRequest(req bridgeTypes.GetDepositRequest)
errors.Is(err, bridgeTypes.ErrInvalidDepositedAmount) ||
errors.Is(err, bridgeTypes.ErrUnsupportedEvent) ||
errors.Is(err, bridgeTypes.ErrFailedUnpackLogs) ||
errors.Is(err, bridgeTypes.ErrUnsupportedContract) ||
errors.Is(err, bridgeTypes.ErrInvalidScriptPubKey) {
reprocessable = false
}
Expand Down
4 changes: 4 additions & 0 deletions internal/bridge/proxy/evm/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func (p *proxy) GetDepositData(id data.DepositIdentifier) (*data.DepositData, er
}

log := txReceipt.Logs[id.TxEventId]
if log.Address.Hex() != p.chain.BridgeAddress.Hex() {
return nil, bridgeTypes.ErrUnsupportedContract
}

depositType := p.getDepositLogType(log)
if depositType == "" {
return nil, bridgeTypes.ErrDepositNotFound
Expand Down
1 change: 1 addition & 0 deletions internal/bridge/types/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
ErrInvalidScriptPubKey = errors.New("invalid script pub key")
ErrFailedUnpackLogs = errors.New("failed to unpack logs")
ErrUnsupportedEvent = errors.New("unsupported event")
ErrUnsupportedContract = errors.New("unsupported contract")
)

type ChainType string
Expand Down

0 comments on commit 3dd8ee8

Please sign in to comment.