Skip to content

Commit 82a9089

Browse files
fix: renamed new functions from ecrecover to recoverAddress
1 parent 7b2e03a commit 82a9089

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Sources/web3swift/Web3/Web3+Personal.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ extension Web3.Personal {
3535
/// Recovers a signer of some personal message. Message will be first prepended by special prefix
3636
/// (check the "signPersonalMessage" method description) and then hashed before the recovery attempt.
3737
///
38-
/// If you have a hash instead of a message use ``Web3/Personal/ecrecover(hash:signature:)``
38+
/// If you have a hash instead of a message use ``Web3/Personal/recoverAddress(hash:signature:)``
3939
///
4040
/// - Parameters:
41-
/// - personalMessage: raw message as bytes (e.g. UTF-8 bytes of a string);
41+
/// - message: raw personal message as bytes (e.g. UTF-8 bytes of a string);
4242
/// - signature: signature that is the result of signing the `personalMessage`;
4343
/// - Returns: address of the signer or `nil`.
44-
public func ecrecover(personalMessage: Data, signature: Data) -> EthereumAddress? {
45-
Utilities.personalECRecover(personalMessage, signature: signature)
44+
public func recoverAddress(message: Data, signature: Data) -> EthereumAddress? {
45+
Utilities.personalECRecover(message, signature: signature)
4646
}
4747

48-
@available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func ecrecover(personalMessage: Data, signature: Data) -> EthereumAddress?` instead.")
48+
@available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func recoverAddress(message: Data, signature: Data) -> EthereumAddress?` instead.")
4949
public func ecrecover(personalMessage: Data, signature: Data) throws -> EthereumAddress {
50-
if let address = ecrecover(personalMessage: personalMessage, signature: signature) {
50+
if let address = recoverAddress(message: personalMessage, signature: signature) {
5151
return address
5252
}
5353
throw Web3Error.dataError
@@ -58,13 +58,13 @@ extension Web3.Personal {
5858
/// - hash: some hash, e.g. hashed personal message;
5959
/// - signature: 65 bytes serialized signature;
6060
/// - Returns: address of the signer or `nil`.
61-
public func ecrecover(hash: Data, signature: Data) -> EthereumAddress? {
61+
public func recoverAddress(hash: Data, signature: Data) -> EthereumAddress? {
6262
Utilities.hashECRecover(hash: hash, signature: signature)
6363
}
6464

65-
@available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func ecrecover(hash: Data, signature: Data) -> EthereumAddress?` instead.")
65+
@available(*, deprecated, message: "Will be removed in Web3Swift v4. Please, use `func recoverAddress(hash: Data, signature: Data) -> EthereumAddress?` instead.")
6666
public func ecrecover(hash: Data, signature: Data) throws -> EthereumAddress {
67-
if let address = ecrecover(hash: hash, signature: signature) {
67+
if let address = recoverAddress(hash: hash, signature: signature) {
6868
return address
6969
}
7070
throw Web3Error.dataError

Tests/web3swiftTests/localTests/PersonalSignatureTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PersonalSignatureTests: XCTestCase {
2222

2323
let signature = try await web3.personal.signPersonalMessage(message: message.data(using: .utf8)!, from: expectedAddress, password: "")
2424
let unmarshalledSignature = SECP256K1.unmarshalSignature(signatureData: signature)!
25-
let signer = try web3.personal.ecrecover(personalMessage: message.data(using: .utf8)!, signature: signature)
25+
let signer = web3.personal.recoverAddress(message: message.data(using: .utf8)!, signature: signature)
2626
XCTAssert(expectedAddress == signer, "Failed to sign personal message")
2727
}
2828

0 commit comments

Comments
 (0)