File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,11 @@ public protocol ContractProtocol {
173173 /// - Returns: `true` if event is possibly present, `false` if definitely not present and `nil` if event with given name
174174 /// is not part of the ``EthereumContract/abi``.
175175 func testBloomForEventPresence( eventName: String , bloom: EthereumBloomFilter ) -> Bool ?
176+
177+ /// Given the transaction data searches for a match in ``ContractProtocol/methods``.
178+ /// - Parameter data: encoded function call used in transaction data field. Must be at least 4 bytes long.
179+ /// - Returns: function decoded from the ABI of this contract or `nil` if nothing was found.
180+ func getFunctionCalled( _ data: Data ) -> ABI . Element . Function ?
176181}
177182
178183// MARK: - Overloaded ContractProtocol's functions
@@ -333,4 +338,9 @@ extension DefaultContractProtocol {
333338 guard let function = methods [ methodSignature] ? . first else { return nil }
334339 return function. decodeInputData ( Data ( data [ 4 ..< data. count] ) )
335340 }
341+
342+ public func getFunctionCalled( _ data: Data ) -> ABI . Element . Function ? {
343+ guard data. count >= 4 else { return nil }
344+ return methods [ data [ 0 ..< 4 ] . toHexString ( ) . addHexPrefix ( ) ] ? . first
345+ }
336346}
You can’t perform that action at this time.
0 commit comments