@@ -91,15 +91,12 @@ public extension ENS {
91
91
92
92
// FIXME: Rewrite this to CodableTransaction
93
93
@available ( * , message: " Available for only owner " )
94
- public func setAddress( forNode node: String , address: EthereumAddress , options: CodableTransaction ? = nil , password: String ? = nil ) async throws -> TransactionSendingResult {
94
+ public func setAddress( forNode node: String , address: EthereumAddress , options: CodableTransaction ? = nil , password: String ) async throws -> TransactionSendingResult {
95
95
var options = options ?? defaultOptions
96
96
options. to = self . resolverContractAddress
97
97
guard let nameHash = NameHash . nameHash ( node) else { throw Web3Error . processingError ( desc: " Failed to get name hash " ) }
98
98
guard let transaction = self . resolverContract. createWriteOperation ( " setAddr " , parameters: [ nameHash, address] as [ AnyObject ] , extraData: Data ( ) ) else { throw Web3Error . transactionSerializationError}
99
- guard let result = await password == nil
100
- ? try ? transaction. writeToChain ( password: " web3swift " )
101
- : try ? transaction. writeToChain ( password: password!)
102
- else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
99
+ guard let result = try ? await transaction. writeToChain ( password: password) else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
103
100
return result
104
101
}
105
102
@@ -113,15 +110,12 @@ public extension ENS {
113
110
114
111
// FIXME: Rewrite this to CodableTransaction
115
112
@available ( * , message: " Available for only owner " )
116
- func setCanonicalName( forNode node: String , name: String , options: CodableTransaction ? = nil , password: String ? = nil ) async throws -> TransactionSendingResult {
113
+ func setCanonicalName( forNode node: String , name: String , options: CodableTransaction ? = nil , password: String ) async throws -> TransactionSendingResult {
117
114
var options = options ?? defaultOptions
118
115
options. to = self . resolverContractAddress
119
116
guard let nameHash = NameHash . nameHash ( node) else { throw Web3Error . processingError ( desc: " Failed to get name hash " ) }
120
117
guard let transaction = self . resolverContract. createWriteOperation ( " setName " , parameters: [ nameHash, name] as [ AnyObject ] , extraData: Data ( ) ) else { throw Web3Error . transactionSerializationError}
121
- guard let result = await password == nil
122
- ? try ? transaction. writeToChain ( password: " web3swift " )
123
- : try ? transaction. writeToChain ( password: password!)
124
- else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
118
+ guard let result = try ? await transaction. writeToChain ( password: password) else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
125
119
return result
126
120
}
127
121
@@ -135,14 +129,12 @@ public extension ENS {
135
129
136
130
// FIXME: Rewrite this to CodableTransaction
137
131
@available ( * , message: " Available for only owner " )
138
- func setContentHash( forNode node: String , hash: String , options: CodableTransaction ? = nil , password: String ? = nil ) async throws -> TransactionSendingResult {
132
+ func setContentHash( forNode node: String , hash: String , options: CodableTransaction ? = nil , password: String ) async throws -> TransactionSendingResult {
139
133
var options = options ?? defaultOptions
140
134
options. to = self . resolverContractAddress
141
135
guard let nameHash = NameHash . nameHash ( node) else { throw Web3Error . processingError ( desc: " Failed to get name hash " ) }
142
136
guard let transaction = self . resolverContract. createWriteOperation ( " setContenthash " , parameters: [ nameHash, hash] as [ AnyObject ] , extraData: Data ( ) ) else { throw Web3Error . transactionSerializationError}
143
- guard let result = await password == nil
144
- ? try ? transaction. writeToChain ( password: " web3swift " )
145
- : try ? transaction. writeToChain ( password: password!)
137
+ guard let result = try ? await transaction. writeToChain ( password: password)
146
138
else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
147
139
return result
148
140
}
@@ -158,15 +150,12 @@ public extension ENS {
158
150
159
151
// FIXME: Rewrite this to CodableTransaction
160
152
@available ( * , message: " Available for only owner " )
161
- func setContractABI( forNode node: String , contentType: ENS . Resolver . ContentType , data: Data , options: CodableTransaction ? = nil , password: String ? = nil ) async throws -> TransactionSendingResult {
153
+ func setContractABI( forNode node: String , contentType: ENS . Resolver . ContentType , data: Data , options: CodableTransaction ? = nil , password: String ) async throws -> TransactionSendingResult {
162
154
var options = options ?? defaultOptions
163
155
options. to = self . resolverContractAddress
164
156
guard let nameHash = NameHash . nameHash ( node) else { throw Web3Error . processingError ( desc: " Failed to get name hash " ) }
165
157
guard let transaction = self . resolverContract. createWriteOperation ( " setABI " , parameters: [ nameHash, contentType. rawValue, data] as [ AnyObject ] , extraData: Data ( ) ) else { throw Web3Error . transactionSerializationError}
166
- guard let result = await password == nil
167
- ? try ? transaction. writeToChain ( password: " web3swift " )
168
- : try ? transaction. writeToChain ( password: password!)
169
- else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
158
+ guard let result = try ? await transaction. writeToChain ( password: password) else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
170
159
return result
171
160
}
172
161
@@ -182,16 +171,13 @@ public extension ENS {
182
171
183
172
// FIXME: Rewrite this to CodableTransaction
184
173
@available ( * , message: " Available for only owner " )
185
- public func setPublicKey( forNode node: String , publicKey: PublicKey , options: CodableTransaction ? = nil , password: String ? = nil ) async throws -> TransactionSendingResult {
174
+ public func setPublicKey( forNode node: String , publicKey: PublicKey , options: CodableTransaction ? = nil , password: String ) async throws -> TransactionSendingResult {
186
175
var options = options ?? defaultOptions
187
176
options. to = self . resolverContractAddress
188
177
let pubkeyWithoutPrefix = publicKey. getComponentsWithoutPrefix ( )
189
178
guard let nameHash = NameHash . nameHash ( node) else { throw Web3Error . processingError ( desc: " Failed to get name hash " ) }
190
179
guard let transaction = self . resolverContract. createWriteOperation ( " setPubkey " , parameters: [ nameHash, pubkeyWithoutPrefix. x, pubkeyWithoutPrefix. y] as [ AnyObject ] , extraData: Data ( ) ) else { throw Web3Error . transactionSerializationError}
191
- guard let result = await password == nil
192
- ? try ? transaction. writeToChain ( password: " web3swift " )
193
- : try ? transaction. writeToChain ( password: password!)
194
- else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
180
+ guard let result = try ? await transaction. writeToChain ( password: password) else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
195
181
return result
196
182
}
197
183
@@ -205,15 +191,12 @@ public extension ENS {
205
191
206
192
// FIXME: Rewrite this to CodableTransaction
207
193
@available ( * , message: " Available for only owner " )
208
- public func setTextData( forNode node: String , key: String , value: String , options: CodableTransaction ? = nil , password: String ? = nil ) async throws -> TransactionSendingResult {
194
+ public func setTextData( forNode node: String , key: String , value: String , options: CodableTransaction ? = nil , password: String ) async throws -> TransactionSendingResult {
209
195
var options = options ?? defaultOptions
210
196
options. to = self . resolverContractAddress
211
197
guard let nameHash = NameHash . nameHash ( node) else { throw Web3Error . processingError ( desc: " Failed to get name hash " ) }
212
198
guard let transaction = self . resolverContract. createWriteOperation ( " setText " , parameters: [ nameHash, key, value] as [ AnyObject ] , extraData: Data ( ) ) else { throw Web3Error . transactionSerializationError}
213
- guard let result = await password == nil
214
- ? try ? transaction. writeToChain ( password: " web3swift " )
215
- : try ? transaction. writeToChain ( password: password!)
216
- else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
199
+ guard let result = try ? await transaction. writeToChain ( password: password) else { throw Web3Error . processingError ( desc: " Can't send transaction " ) }
217
200
return result
218
201
}
219
202
}
0 commit comments