Skip to content

Commit 318f8da

Browse files
API update: input argument renaming and potentially expansion of allowed input #786
2 parents 0e19adb + 2f0cedb commit 318f8da

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

Sources/web3swift/Utils/ENS/ENS.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public class ENS {
9696
}
9797

9898
// FIXME: Rewrite this to CodableTransaction
99-
public func setAddress(forNode node: String, address: EthereumAddress, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
99+
public func setAddress(forNode node: String, address: EthereumAddress, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
100100
guard let resolver = try? await self.registry.getResolver(forDomain: node) else {
101101
throw Web3Error.processingError(desc: "Failed to get resolver for domain")
102102
}
@@ -106,9 +106,9 @@ public class ENS {
106106
guard isAddrSupports else {
107107
throw Web3Error.processingError(desc: "Address isn't supported")
108108
}
109-
var options = options ?? defaultTransaction
109+
var options = transaction ?? defaultTransaction
110110
options.to = resolver.resolverContractAddress
111-
guard let result = try? await resolver.setAddress(forNode: node, address: address, options: options, password: password) else {
111+
guard let result = try? await resolver.setAddress(forNode: node, address: address, transaction: options, password: password) else {
112112
throw Web3Error.processingError(desc: "Can't get result")
113113
}
114114
return result
@@ -131,7 +131,7 @@ public class ENS {
131131
}
132132

133133
// FIXME: Rewrite this to CodableTransaction
134-
public func setName(forNode node: String, name: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
134+
public func setName(forNode node: String, name: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
135135
guard let resolver = try? await self.registry.getResolver(forDomain: node) else {
136136
throw Web3Error.processingError(desc: "Failed to get resolver for domain")
137137
}
@@ -141,9 +141,9 @@ public class ENS {
141141
guard isNameSupports else {
142142
throw Web3Error.processingError(desc: "Name isn't supported")
143143
}
144-
var options = options ?? defaultTransaction
144+
var options = transaction ?? defaultTransaction
145145
options.to = resolver.resolverContractAddress
146-
guard let result = try? await resolver.setCanonicalName(forNode: node, name: name, options: options, password: password) else {
146+
guard let result = try? await resolver.setCanonicalName(forNode: node, name: name, transaction: options, password: password) else {
147147
throw Web3Error.processingError(desc: "Can't get result")
148148
}
149149
return result
@@ -167,7 +167,7 @@ public class ENS {
167167
}
168168

169169
// FIXME: Rewrite this to CodableTransaction
170-
public func setContent(forNode node: String, hash: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
170+
public func setContent(forNode node: String, hash: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
171171
guard let resolver = try? await self.registry.getResolver(forDomain: node) else {
172172
throw Web3Error.processingError(desc: "Failed to get resolver for domain")
173173
}
@@ -177,9 +177,9 @@ public class ENS {
177177
guard isContentSupports else {
178178
throw Web3Error.processingError(desc: "Content isn't supported")
179179
}
180-
var options = options ?? defaultTransaction
180+
var options = transaction ?? defaultTransaction
181181
options.to = resolver.resolverContractAddress
182-
guard let result = try? await resolver.setContentHash(forNode: node, hash: hash, options: options, password: password) else {
182+
guard let result = try? await resolver.setContentHash(forNode: node, hash: hash, transaction: options, password: password) else {
183183
throw Web3Error.processingError(desc: "Can't get result")
184184
}
185185
return result
@@ -202,7 +202,7 @@ public class ENS {
202202
}
203203

204204
// FIXME: Rewrite this to CodableTransaction
205-
public func setABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
205+
public func setABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
206206
guard let resolver = try? await self.registry.getResolver(forDomain: node) else {
207207
throw Web3Error.processingError(desc: "Failed to get resolver for domain")
208208
}
@@ -212,9 +212,9 @@ public class ENS {
212212
guard isABISupports else {
213213
throw Web3Error.processingError(desc: "ABI isn't supported")
214214
}
215-
var options = options ?? defaultTransaction
215+
var options = transaction ?? defaultTransaction
216216
options.to = resolver.resolverContractAddress
217-
guard let result = try? await resolver.setContractABI(forNode: node, contentType: contentType, data: data, options: options, password: password) else {
217+
guard let result = try? await resolver.setContractABI(forNode: node, contentType: contentType, data: data, transaction: options, password: password) else {
218218
throw Web3Error.processingError(desc: "Can't get result")
219219
}
220220
return result
@@ -237,7 +237,7 @@ public class ENS {
237237
}
238238

239239
// FIXME: Rewrite this to CodableTransaction
240-
public func setPublicKey(forNode node: String, publicKey: PublicKey, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
240+
public func setPublicKey(forNode node: String, publicKey: PublicKey, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
241241
guard let resolver = try? await self.registry.getResolver(forDomain: node) else {
242242
throw Web3Error.processingError(desc: "Failed to get resolver for domain")
243243
}
@@ -247,9 +247,9 @@ public class ENS {
247247
guard isPKSupports else {
248248
throw Web3Error.processingError(desc: "Public Key isn't supported")
249249
}
250-
var options = options ?? defaultTransaction
250+
var options = transaction ?? defaultTransaction
251251
options.to = resolver.resolverContractAddress
252-
guard let result = try? await resolver.setPublicKey(forNode: node, publicKey: publicKey, options: options, password: password) else {
252+
guard let result = try? await resolver.setPublicKey(forNode: node, publicKey: publicKey, transaction: options, password: password) else {
253253
throw Web3Error.processingError(desc: "Can't get result")
254254
}
255255
return result
@@ -272,7 +272,7 @@ public class ENS {
272272
}
273273

274274
// FIXME: Rewrite this to CodableTransaction
275-
public func setText(forNode node: String, key: String, value: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
275+
public func setText(forNode node: String, key: String, value: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
276276
guard let resolver = try? await self.registry.getResolver(forDomain: node) else {
277277
throw Web3Error.processingError(desc: "Failed to get resolver for domain")
278278
}
@@ -282,9 +282,9 @@ public class ENS {
282282
guard isTextSupports else {
283283
throw Web3Error.processingError(desc: "Text isn't supported")
284284
}
285-
var options = options ?? defaultTransaction
285+
var options = transaction ?? defaultTransaction
286286
options.to = resolver.resolverContractAddress
287-
guard let result = try? await resolver.setTextData(forNode: node, key: key, value: value, options: options, password: password) else {
287+
guard let result = try? await resolver.setTextData(forNode: node, key: key, value: value, transaction: options, password: password) else {
288288
throw Web3Error.processingError(desc: "Can't get result")
289289
}
290290
return result

Sources/web3swift/Utils/ENS/ENSRegistry.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public extension ENS {
7070
}
7171

7272
// FIXME: Rewrite this to CodableTransaction
73-
public func setOwner(node: String, owner: EthereumAddress, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
74-
var options = options ?? defaultTransaction
73+
public func setOwner(node: String, owner: EthereumAddress, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
74+
var options = transaction ?? defaultTransaction
7575
if let contractAddress = self.registryContractAddress {
7676
options.to = contractAddress
7777
}
@@ -82,8 +82,8 @@ public extension ENS {
8282
}
8383

8484
// FIXME: Rewrite this to CodableTransaction
85-
public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
86-
var options = options ?? defaultTransaction
85+
public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
86+
var options = transaction ?? defaultTransaction
8787
if let contractAddress = self.registryContractAddress {
8888
options.to = contractAddress
8989
}
@@ -95,8 +95,8 @@ public extension ENS {
9595
}
9696

9797
// FIXME: Rewrite this to CodableTransaction
98-
public func setResolver(node: String, resolver: EthereumAddress, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
99-
var options = options ?? defaultTransaction
98+
public func setResolver(node: String, resolver: EthereumAddress, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
99+
var options = transaction ?? defaultTransaction
100100
if let contractAddress = self.registryContractAddress {
101101
options.to = contractAddress
102102
}
@@ -107,8 +107,8 @@ public extension ENS {
107107
}
108108

109109
// FIXME: Rewrite this to CodableTransaction
110-
public func setTTL(node: String, ttl: BigUInt, options: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
111-
var options = options ?? defaultTransaction
110+
public func setTTL(node: String, ttl: BigUInt, transaction: CodableTransaction?, password: String) async throws -> TransactionSendingResult {
111+
var options = transaction ?? defaultTransaction
112112
if let contractAddress = self.registryContractAddress {
113113
options.to = contractAddress
114114
}

Sources/web3swift/Utils/ENS/ENSResolver.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public extension ENS {
105105

106106
// FIXME: Rewrite this to CodableTransaction
107107
@available(*, message: "Available for only owner")
108-
public func setAddress(forNode node: String, address: EthereumAddress, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
109-
var options = options ?? defaultTransaction
108+
public func setAddress(forNode node: String, address: EthereumAddress, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
109+
var options = transaction ?? defaultTransaction
110110
options.to = self.resolverContractAddress
111111
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
112112
guard let transaction = self.resolverContract.createWriteOperation("setAddr", parameters: [nameHash, address] as [AnyObject]) else {throw Web3Error.transactionSerializationError}
@@ -124,8 +124,8 @@ public extension ENS {
124124

125125
// FIXME: Rewrite this to CodableTransaction
126126
@available(*, message: "Available for only owner")
127-
func setCanonicalName(forNode node: String, name: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
128-
var options = options ?? defaultTransaction
127+
func setCanonicalName(forNode node: String, name: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
128+
var options = transaction ?? defaultTransaction
129129
options.to = self.resolverContractAddress
130130
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
131131
guard let transaction = self.resolverContract.createWriteOperation("setName", parameters: [nameHash, name] as [AnyObject]) else {throw Web3Error.transactionSerializationError}
@@ -143,8 +143,8 @@ public extension ENS {
143143

144144
// FIXME: Rewrite this to CodableTransaction
145145
@available(*, message: "Available for only owner")
146-
func setContentHash(forNode node: String, hash: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
147-
var options = options ?? defaultTransaction
146+
func setContentHash(forNode node: String, hash: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
147+
var options = transaction ?? defaultTransaction
148148
options.to = self.resolverContractAddress
149149
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
150150
guard let transaction = self.resolverContract.createWriteOperation("setContenthash", parameters: [nameHash, hash] as [AnyObject]) else {throw Web3Error.transactionSerializationError}
@@ -164,8 +164,8 @@ public extension ENS {
164164

165165
// FIXME: Rewrite this to CodableTransaction
166166
@available(*, message: "Available for only owner")
167-
func setContractABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
168-
var options = options ?? defaultTransaction
167+
func setContractABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
168+
var options = transaction ?? defaultTransaction
169169
options.to = self.resolverContractAddress
170170
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
171171
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 {
185185

186186
// FIXME: Rewrite this to CodableTransaction
187187
@available(*, message: "Available for only owner")
188-
public func setPublicKey(forNode node: String, publicKey: PublicKey, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
189-
var options = options ?? defaultTransaction
188+
public func setPublicKey(forNode node: String, publicKey: PublicKey, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
189+
var options = transaction ?? defaultTransaction
190190
options.to = self.resolverContractAddress
191191
let pubkeyWithoutPrefix = publicKey.getComponentsWithoutPrefix()
192192
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
@@ -205,8 +205,8 @@ public extension ENS {
205205

206206
// FIXME: Rewrite this to CodableTransaction
207207
@available(*, message: "Available for only owner")
208-
public func setTextData(forNode node: String, key: String, value: String, options: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
209-
var options = options ?? defaultTransaction
208+
public func setTextData(forNode node: String, key: String, value: String, transaction: CodableTransaction? = nil, password: String) async throws -> TransactionSendingResult {
209+
var options = transaction ?? defaultTransaction
210210
options.to = self.resolverContractAddress
211211
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
212212
guard let transaction = self.resolverContract.createWriteOperation("setText", parameters: [nameHash, key, value] as [AnyObject]) else {throw Web3Error.transactionSerializationError}

0 commit comments

Comments
 (0)