Skip to content

Commit 282f919

Browse files
authored
Merge pull request web3swift-team#187 from barrasso/patch-6
Update ETHRegistrarController.swift
2 parents 041053d + 0ac5243 commit 282f919

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Sources/web3swift/Utils/ENS/ETHRegistrarController.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import Foundation
1010
import BigInt
11-
//import EthereumAddress
1211

1312
public extension ENS {
1413
class ETHRegistrarController {
@@ -51,26 +50,26 @@ public extension ENS {
5150
return available
5251
}
5352

54-
public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: [UInt32]) throws -> [UInt32] {
55-
guard let transaction = self.contract.read("makeCommitment", parameters: [name, owner, secret] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError}
53+
public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: String) throws -> Data {
54+
guard let transaction = self.contract.read("makeCommitment", parameters: [name, owner.address, secret] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError}
5655
guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")}
57-
guard let hash = result["0"] as? [UInt32] else {throw Web3Error.processingError(desc: "Can't get answer")}
56+
guard let hash = result["0"] as? Data else {throw Web3Error.processingError(desc: "Can't get answer")}
5857
return hash
5958
}
6059

61-
public func sumbitCommitment(from: EthereumAddress, commitment: [UInt32]) throws -> WriteTransaction {
60+
public func sumbitCommitment(from: EthereumAddress, commitment: Data) throws -> WriteTransaction {
6261
defaultOptions.from = from
6362
defaultOptions.to = self.address
6463
guard let transaction = self.contract.write("commit", parameters: [commitment as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError}
6564
return transaction
6665
}
6766

68-
public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt32, secret: [UInt32], price: String) throws -> WriteTransaction {
67+
public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt, secret: String, price: String) throws -> WriteTransaction {
6968
guard let amount = Web3.Utils.parseToBigUInt(price, units: .eth) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")}
7069
defaultOptions.value = amount
7170
defaultOptions.from = from
7271
defaultOptions.to = self.address
73-
guard let transaction = self.contract.write("register", parameters: [name, owner, duration, secret] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError}
72+
guard let transaction = self.contract.write("register", parameters: [name, owner.address, duration, secret] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError}
7473
return transaction
7574
}
7675

0 commit comments

Comments
 (0)