Skip to content

Commit d036483

Browse files
Merge pull request #701 from JeneaVranceanu/feat/remote-tests-mocking
2 parents b9ac465 + 3707ca4 commit d036483

23 files changed

+398
-326
lines changed

Sources/Core/Contract/ContractProtocol.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+Call.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+EstimateGas.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+FeeHistory.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetAccounts.swift

Lines changed: 0 additions & 17 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBalance.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockByHash.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockByNumber.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetBlockNumber.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+GetCode.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)