Skip to content

Commit 13181b4

Browse files
chore: comments + docs
1 parent fa0edd3 commit 13181b4

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Sources/web3swift/HookedFunctions/Web3+Wallet.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import Web3Core
99

1010
extension Web3.Web3Wallet {
1111

12+
/// A list of addresses available in the attached keystore.
13+
/// - Returns: a list of addresses or an error.
1214
public func getAccounts() throws -> [EthereumAddress] {
1315
guard let keystoreManager = self.web3.provider.attachedKeystoreManager else {
16+
// TODO: add the following error message: Missing `attachedKeystoreManager`.
1417
throw Web3Error.walletError
1518
}
1619
guard let ethAddresses = keystoreManager.addresses else {
20+
// TODO: add the following error message: Missing attached keystore is empty.
1721
throw Web3Error.walletError
1822
}
1923
return ethAddresses
@@ -42,6 +46,12 @@ extension Web3.Web3Wallet {
4246
}
4347
}
4448

49+
/// Execute `personal_sign` for given arbitrary message.
50+
/// - Parameters:
51+
/// - personalMessage: message. Must be HEX formatted: message -> to 'UTF-8 bytes' -> to hex string!
52+
/// - account: signer address.
53+
/// - password: web3 attached keystore password.
54+
/// - Returns: signature for the given message or throws an error.
4555
public func signPersonalMessage(_ personalMessage: String, account: EthereumAddress, password: String ) throws -> Data {
4656
guard let data = Data.fromHex(personalMessage) else {
4757
throw Web3Error.dataError

Sources/web3swift/Web3/Web3+Contract.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension Web3 {
4747

4848
// MARK: Writing Data flow
4949
// FIXME: Rewrite this to CodableTransaction
50-
/// Deploys a constact instance using the previously provided ABI, some bytecode, constructor parameters and options.
50+
/// Deploys a contract instance using the previously provided ABI, some bytecode, constructor parameters and options.
5151
/// If extraData is supplied it is appended to encoded bytecode and constructor parameters.
5252
///
5353
/// Returns a "Transaction intermediate" object.

Tests/web3swiftTests/localTests/PersonalSignatureTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ class PersonalSignatureTests: XCTestCase {
6969
let expectedAddress = keystoreManager.addresses![0]
7070

7171
let signature = try await web3.personal.signPersonalMessage(message: Data.fromHex(messageToSign)!, from: expectedAddress, password: "")
72-
// ATTENTION: web3.wallet.signPersonalMessage accepts a raw string instead but expects it
73-
// ATTENTION: to be a hex string!
72+
// ATTENTION: web3.wallet.signPersonalMessage accepts a raw string
73+
// ATTENTION: instead of the message hash but expects it to be
74+
// ATTENTION: 'string' -> to 'UTF-8 bytes' -> to hex string converted!
7475
let signature_walletObj = try web3.wallet.signPersonalMessage(messageToSign, account: expectedAddress, password: "")
7576
let signer = web3.personal.recoverAddress(message: Data.fromHex(messageToSign)!, signature: signature)
7677

0 commit comments

Comments
 (0)