MCPcopy Create free account
hub / github.com/cairoeth/preconfirmations / ProcessRequest

Method ProcessRequest

rpc/server/request_processor.go:83–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81}
82
83func (r *RPCRequest) ProcessRequest() *types.JSONRPCResponse {
84 r.logRequest()
85
86 switch {
87 case r.jsonReq.Method == "eth_sendRawTransaction":
88 // r.ethSendRawTxEntry.WhiteHatBundleID = r.whitehatBundleID
89 r.handleSendRawTransaction()
90 case r.jsonReq.Method == "eth_getTransactionCount" && r.interceptMmEthGetTransactionCount(): // intercept if MM needs to show an error to user
91 case r.jsonReq.Method == "eth_call" && r.interceptEthCallToFlashRPCContract(): // intercept if Flashbots isRPC contract
92 case r.jsonReq.Method == "net_version":
93 r.writeRPCResult(json.RawMessage(r.chainID))
94 case r.isWhitehatBundleCollection && r.jsonReq.Method == "eth_getBalance":
95 r.writeRPCResult("0x56bc75e2d63100000") // 100 ETH, same as the eth_call SC call above returns
96 default:
97 if r.isWhitehatBundleCollection && r.jsonReq.Method == "eth_call" {
98 r.WhitehatBalanceCheckerRewrite()
99 }
100 // Proxy the request to a node
101 readJSONRPCSuccess := r.proxyRequestRead()
102 if !readJSONRPCSuccess {
103 r.logger.Info("[ProcessRequest] Proxy to node failed", zap.String("method", r.jsonReq.Method))
104 r.writeRPCError("internal server error", types.JSONRPCInternalError)
105 return r.jsonRes
106 }
107
108 // After proxy, perhaps check backend [MM fix #3 step 2]
109 if r.jsonReq.Method == "eth_getTransactionReceipt" {
110 requestCompleted := r.checkPostGetTransactionReceipt(r.jsonRes)
111 if requestCompleted {
112 return r.jsonRes
113 }
114 }
115 }
116 return r.jsonRes
117}
118
119// Proxies the incoming request to the target URL, and tries to parse JSON-RPC response (and check for specific)
120func (r *RPCRequest) proxyRequestRead() (readJSONRpsResponseSuccess bool) {

Callers 1

processRequestMethod · 0.95

Calls 10

logRequestMethod · 0.95
writeRPCResultMethod · 0.95
proxyRequestReadMethod · 0.95
writeRPCErrorMethod · 0.95
StringMethod · 0.80

Tested by

no test coverage detected