diff --git a/Sources/web3swift/Utils/ENS/ENS.swift b/Sources/web3swift/Utils/ENS/ENS.swift index 7c4f8d00e..18910e7e0 100755 --- a/Sources/web3swift/Utils/ENS/ENS.swift +++ b/Sources/web3swift/Utils/ENS/ENS.swift @@ -96,7 +96,7 @@ public class ENS { } // FIXME: Rewrite this to CodableTransaction - public func setAddress(forNode node: String, address: EthereumAddress, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + public func setAddress(forNode node: String, address: EthereumAddress, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } @@ -106,9 +106,9 @@ public class ENS { guard isAddrSupports else { throw Web3Error.processingError(desc: "Address isn't supported") } - var options = options ?? defaultTransaction + var options = transaction ?? defaultTransaction options.to = resolver.resolverContractAddress - guard let result = try? await resolver.setAddress(forNode: node, address: address, options: options, password: password) else { + guard let result = try? await resolver.setAddress(forNode: node, address: address, transaction: options, password: password) else { throw Web3Error.processingError(desc: "Can't get result") } return result @@ -131,7 +131,7 @@ public class ENS { } // FIXME: Rewrite this to CodableTransaction - public func setName(forNode node: String, name: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + public func setName(forNode node: String, name: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } @@ -141,9 +141,9 @@ public class ENS { guard isNameSupports else { throw Web3Error.processingError(desc: "Name isn't supported") } - var options = options ?? defaultTransaction + var options = transaction ?? defaultTransaction options.to = resolver.resolverContractAddress - guard let result = try? await resolver.setCanonicalName(forNode: node, name: name, options: options, password: password) else { + guard let result = try? await resolver.setCanonicalName(forNode: node, name: name, transaction: options, password: password) else { throw Web3Error.processingError(desc: "Can't get result") } return result @@ -167,7 +167,7 @@ public class ENS { } // FIXME: Rewrite this to CodableTransaction - public func setContent(forNode node: String, hash: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + public func setContent(forNode node: String, hash: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } @@ -177,9 +177,9 @@ public class ENS { guard isContentSupports else { throw Web3Error.processingError(desc: "Content isn't supported") } - var options = options ?? defaultTransaction + var options = transaction ?? defaultTransaction options.to = resolver.resolverContractAddress - guard let result = try? await resolver.setContentHash(forNode: node, hash: hash, options: options, password: password) else { + guard let result = try? await resolver.setContentHash(forNode: node, hash: hash, transaction: options, password: password) else { throw Web3Error.processingError(desc: "Can't get result") } return result @@ -202,7 +202,7 @@ public class ENS { } // FIXME: Rewrite this to CodableTransaction - public func setABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + public func setABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } @@ -212,9 +212,9 @@ public class ENS { guard isABISupports else { throw Web3Error.processingError(desc: "ABI isn't supported") } - var options = options ?? defaultTransaction + var options = transaction ?? defaultTransaction options.to = resolver.resolverContractAddress - guard let result = try? await resolver.setContractABI(forNode: node, contentType: contentType, data: data, options: options, password: password) else { + guard let result = try? await resolver.setContractABI(forNode: node, contentType: contentType, data: data, transaction: options, password: password) else { throw Web3Error.processingError(desc: "Can't get result") } return result @@ -237,7 +237,7 @@ public class ENS { } // FIXME: Rewrite this to CodableTransaction - public func setPublicKey(forNode node: String, publicKey: PublicKey, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + public func setPublicKey(forNode node: String, publicKey: PublicKey, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } @@ -247,9 +247,9 @@ public class ENS { guard isPKSupports else { throw Web3Error.processingError(desc: "Public Key isn't supported") } - var options = options ?? defaultTransaction + var options = transaction ?? defaultTransaction options.to = resolver.resolverContractAddress - guard let result = try? await resolver.setPublicKey(forNode: node, publicKey: publicKey, options: options, password: password) else { + guard let result = try? await resolver.setPublicKey(forNode: node, publicKey: publicKey, transaction: options, password: password) else { throw Web3Error.processingError(desc: "Can't get result") } return result @@ -272,7 +272,7 @@ public class ENS { } // FIXME: Rewrite this to CodableTransaction - public func setText(forNode node: String, key: String, value: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + public func setText(forNode node: String, key: String, value: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { guard let resolver = try? await self.registry.getResolver(forDomain: node) else { throw Web3Error.processingError(desc: "Failed to get resolver for domain") } @@ -282,9 +282,9 @@ public class ENS { guard isTextSupports else { throw Web3Error.processingError(desc: "Text isn't supported") } - var options = options ?? defaultTransaction + var options = transaction ?? defaultTransaction options.to = resolver.resolverContractAddress - guard let result = try? await resolver.setTextData(forNode: node, key: key, value: value, options: options, password: password) else { + guard let result = try? await resolver.setTextData(forNode: node, key: key, value: value, transaction: options, password: password) else { throw Web3Error.processingError(desc: "Can't get result") } return result diff --git a/Sources/web3swift/Utils/ENS/ENSRegistry.swift b/Sources/web3swift/Utils/ENS/ENSRegistry.swift index 7abd04757..88f759efd 100644 --- a/Sources/web3swift/Utils/ENS/ENSRegistry.swift +++ b/Sources/web3swift/Utils/ENS/ENSRegistry.swift @@ -70,8 +70,8 @@ public extension ENS { } // FIXME: Rewrite this to CodableTransaction - public func setOwner(node: String, owner: EthereumAddress, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setOwner(node: String, owner: EthereumAddress, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction if let contractAddress = self.registryContractAddress { options.to = contractAddress } @@ -82,8 +82,8 @@ public extension ENS { } // FIXME: Rewrite this to CodableTransaction - public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction if let contractAddress = self.registryContractAddress { options.to = contractAddress } @@ -95,8 +95,8 @@ public extension ENS { } // FIXME: Rewrite this to CodableTransaction - public func setResolver(node: String, resolver: EthereumAddress, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setResolver(node: String, resolver: EthereumAddress, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction if let contractAddress = self.registryContractAddress { options.to = contractAddress } @@ -107,8 +107,8 @@ public extension ENS { } // FIXME: Rewrite this to CodableTransaction - public func setTTL(node: String, ttl: BigUInt, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setTTL(node: String, ttl: BigUInt, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction if let contractAddress = self.registryContractAddress { options.to = contractAddress } diff --git a/Sources/web3swift/Utils/ENS/ENSResolver.swift b/Sources/web3swift/Utils/ENS/ENSResolver.swift index e594a499c..724889a96 100755 --- a/Sources/web3swift/Utils/ENS/ENSResolver.swift +++ b/Sources/web3swift/Utils/ENS/ENSResolver.swift @@ -105,8 +105,8 @@ public extension ENS { // FIXME: Rewrite this to CodableTransaction @available(*, message: "Available for only owner") - public func setAddress(forNode node: String, address: EthereumAddress, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setAddress(forNode node: String, address: EthereumAddress, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} guard let transaction = self.resolverContract.createWriteOperation("setAddr", parameters: [nameHash, address] as [AnyObject]) else {throw Web3Error.transactionSerializationError} @@ -124,8 +124,8 @@ public extension ENS { // FIXME: Rewrite this to CodableTransaction @available(*, message: "Available for only owner") - func setCanonicalName(forNode node: String, name: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + func setCanonicalName(forNode node: String, name: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} guard let transaction = self.resolverContract.createWriteOperation("setName", parameters: [nameHash, name] as [AnyObject]) else {throw Web3Error.transactionSerializationError} @@ -143,8 +143,8 @@ public extension ENS { // FIXME: Rewrite this to CodableTransaction @available(*, message: "Available for only owner") - func setContentHash(forNode node: String, hash: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + func setContentHash(forNode node: String, hash: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} guard let transaction = self.resolverContract.createWriteOperation("setContenthash", parameters: [nameHash, hash] as [AnyObject]) else {throw Web3Error.transactionSerializationError} @@ -164,8 +164,8 @@ public extension ENS { // FIXME: Rewrite this to CodableTransaction @available(*, message: "Available for only owner") - func setContractABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + func setContractABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} guard let transaction = self.resolverContract.createWriteOperation("setABI", parameters: [nameHash, contentType.rawValue, data] as [AnyObject]) else {throw Web3Error.transactionSerializationError} @@ -185,8 +185,8 @@ public extension ENS { // FIXME: Rewrite this to CodableTransaction @available(*, message: "Available for only owner") - public func setPublicKey(forNode node: String, publicKey: PublicKey, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setPublicKey(forNode node: String, publicKey: PublicKey, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction options.to = self.resolverContractAddress let pubkeyWithoutPrefix = publicKey.getComponentsWithoutPrefix() guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} @@ -205,8 +205,8 @@ public extension ENS { // FIXME: Rewrite this to CodableTransaction @available(*, message: "Available for only owner") - public func setTextData(forNode node: String, key: String, value: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { - var options = options ?? defaultTransaction + public func setTextData(forNode node: String, key: String, value: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult { + var options = transaction ?? defaultTransaction options.to = self.resolverContractAddress guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} guard let transaction = self.resolverContract.createWriteOperation("setText", parameters: [nameHash, key, value] as [AnyObject]) else {throw Web3Error.transactionSerializationError}