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 {
173
173
/// - Returns: `true` if event is possibly present, `false` if definitely not present and `nil` if event with given name
174
174
/// is not part of the ``EthereumContract/abi``.
175
175
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 ?
176
181
}
177
182
178
183
// MARK: - Overloaded ContractProtocol's functions
@@ -333,4 +338,9 @@ extension DefaultContractProtocol {
333
338
guard let function = methods [ methodSignature] ? . first else { return nil }
334
339
return function. decodeInputData ( Data ( data [ 4 ..< data. count] ) )
335
340
}
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
+ }
336
346
}
You can’t perform that action at this time.
0 commit comments