Skip to content

Commit 4d42149

Browse files
Delete default password from ReadTransaction.send() method.
1 parent d19010a commit 4d42149

File tree

9 files changed

+25
-22
lines changed

9 files changed

+25
-22
lines changed

Sources/web3swift/Utils/ENS/ENSRegistry.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public extension ENS {
7979
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
8080
guard let transaction = self.registryContract.write("setOwner", parameters: [nameHash, owner] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
8181
guard let result = await password == nil
82-
? try? transaction.send()
82+
? try? transaction.send(password: "web3swift")
8383
: try? transaction.send(password: password!)
8484
else {throw Web3Error.processingError(desc: "Can't send transaction")}
8585
return result
@@ -95,7 +95,7 @@ public extension ENS {
9595
guard let labelHash = NameHash.nameHash(label) else {throw Web3Error.processingError(desc: "Failed to get label hash")}
9696
guard let transaction = self.registryContract.write("setSubnodeOwner", parameters: [nameHash, labelHash, owner] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
9797
guard let result = await password == nil
98-
? try? transaction.send()
98+
? try? transaction.send(password: "web3swift")
9999
: try? transaction.send(password: password!)
100100
else {throw Web3Error.processingError(desc: "Can't send transaction")}
101101
return result
@@ -110,7 +110,7 @@ public extension ENS {
110110
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
111111
guard let transaction = self.registryContract.write("setResolver", parameters: [nameHash, resolver] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
112112
guard let result = await password == nil
113-
? try? transaction.send()
113+
? try? transaction.send(password: "web3swift")
114114
: try? transaction.send(password: password!)
115115
else {throw Web3Error.processingError(desc: "Can't send transaction")}
116116
return result
@@ -125,7 +125,7 @@ public extension ENS {
125125
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
126126
guard let transaction = self.registryContract.write("setTTL", parameters: [nameHash, ttl] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
127127
guard let result = await password == nil
128-
? try? transaction.send()
128+
? try? transaction.send(password: "web3swift")
129129
: try? transaction.send(password: password!)
130130
else {throw Web3Error.processingError(desc: "Can't send transaction")}
131131
return result

Sources/web3swift/Utils/ENS/ENSResolver.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ public extension ENS {
9696
options.to = self.resolverContractAddress
9797
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
9898
guard let transaction = self.resolverContract.write("setAddr", parameters: [nameHash, address] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
99-
guard let result = await password == nil ? try? transaction.send(): try? transaction.send(password: password!) else {throw Web3Error.processingError(desc: "Can't send transaction")}
99+
guard let result = await password == nil
100+
? try? transaction.send(password: "web3swift")
101+
: try? transaction.send(password: password!)
102+
else {throw Web3Error.processingError(desc: "Can't send transaction")}
100103
return result
101104
}
102105

@@ -116,7 +119,7 @@ public extension ENS {
116119
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
117120
guard let transaction = self.resolverContract.write("setName", parameters: [nameHash, name] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
118121
guard let result = await password == nil
119-
? try? transaction.send()
122+
? try? transaction.send(password: "web3swift")
120123
: try? transaction.send(password: password!)
121124
else {throw Web3Error.processingError(desc: "Can't send transaction")}
122125
return result
@@ -138,7 +141,7 @@ public extension ENS {
138141
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
139142
guard let transaction = self.resolverContract.write("setContenthash", parameters: [nameHash, hash] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
140143
guard let result = await password == nil
141-
? try? transaction.send()
144+
? try? transaction.send(password: "web3swift")
142145
: try? transaction.send(password: password!)
143146
else {throw Web3Error.processingError(desc: "Can't send transaction")}
144147
return result
@@ -161,7 +164,7 @@ public extension ENS {
161164
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
162165
guard let transaction = self.resolverContract.write("setABI", parameters: [nameHash, contentType.rawValue, data] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
163166
guard let result = await password == nil
164-
? try? transaction.send()
167+
? try? transaction.send(password: "web3swift")
165168
: try? transaction.send(password: password!)
166169
else {throw Web3Error.processingError(desc: "Can't send transaction")}
167170
return result
@@ -186,7 +189,7 @@ public extension ENS {
186189
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
187190
guard let transaction = self.resolverContract.write("setPubkey", parameters: [nameHash, pubkeyWithoutPrefix.x, pubkeyWithoutPrefix.y] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
188191
guard let result = await password == nil
189-
? try? transaction.send()
192+
? try? transaction.send(password: "web3swift")
190193
: try? transaction.send(password: password!)
191194
else {throw Web3Error.processingError(desc: "Can't send transaction")}
192195
return result
@@ -208,7 +211,7 @@ public extension ENS {
208211
guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")}
209212
guard let transaction = self.resolverContract.write("setText", parameters: [nameHash, key, value] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError}
210213
guard let result = await password == nil
211-
? try? transaction.send()
214+
? try? transaction.send(password: "web3swift")
212215
: try? transaction.send(password: password!)
213216
else {throw Web3Error.processingError(desc: "Can't send transaction")}
214217
return result

Sources/web3swift/Web3/Web3+MutatingTransaction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public class WriteTransaction: ReadTransaction {
179179
}
180180

181181
// FIXME: Rewrite this to CodableTransaction
182-
public func send(password: String = "web3swift") async throws -> TransactionSendingResult {
182+
public func send(password: String) async throws -> TransactionSendingResult {
183183
if let attachedKeystoreManager = self.web3.provider.attachedKeystoreManager {
184184
do {
185185
try Web3Signer.signTX(transaction: &transaction,

Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AdvancedABIv2Tests: LocalTestCase {
2525
deployTx.transactionOptions.from = allAddresses[0]
2626
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
2727
// MARK: Sending Data flow
28-
let result = try await deployTx.send()
28+
let result = try await deployTx.send(password: "web3swift")
2929
let txHash = result.hash
3030
print("Transaction with hash " + txHash)
3131

@@ -62,7 +62,7 @@ class AdvancedABIv2Tests: LocalTestCase {
6262
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
6363
deployTx.transactionOptions.from = allAddresses[0]
6464
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
65-
let result = try await deployTx.send()
65+
let result = try await deployTx.send(password: "web3swift")
6666
let txHash = result.hash
6767
print("Transaction with hash " + txHash)
6868

@@ -99,7 +99,7 @@ class AdvancedABIv2Tests: LocalTestCase {
9999
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
100100
deployTx.transactionOptions.from = allAddresses[0]
101101
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
102-
let result = try await deployTx.send()
102+
let result = try await deployTx.send(password: "web3swift")
103103
let txHash = result.hash
104104
print("Transaction with hash " + txHash)
105105

@@ -135,7 +135,7 @@ class AdvancedABIv2Tests: LocalTestCase {
135135
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
136136
deployTx.transactionOptions.from = allAddresses[0]
137137
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
138-
let result = try await deployTx.send()
138+
let result = try await deployTx.send(password: "web3swift")
139139
let txHash = result.hash
140140
print("Transaction with hash " + txHash)
141141

@@ -172,7 +172,7 @@ class AdvancedABIv2Tests: LocalTestCase {
172172
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
173173
deployTx.transactionOptions.from = allAddresses[0]
174174
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
175-
let result = try await deployTx.send()
175+
let result = try await deployTx.send(password: "web3swift")
176176
let txHash = result.hash
177177
print("Transaction with hash " + txHash)
178178

Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BasicLocalNodeTests: LocalTestCase {
2727
deployTx.transactionOptions.from = allAddresses[0]
2828
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
2929

30-
let result = try await deployTx.send()
30+
let result = try await deployTx.send(password: "web3swift")
3131
let txHash = result.hash
3232
print("Transaction with hash " + txHash)
3333

@@ -65,7 +65,7 @@ class BasicLocalNodeTests: LocalTestCase {
6565
print("Balance before to: " + balanceBeforeTo.description)
6666
print("Balance before from: " + balanceBeforeFrom.description)
6767

68-
let result = try await sendTx.send()
68+
let result = try await sendTx.send(password: "web3swift")
6969
let txHash = result.hash
7070
print("Transaction with hash " + txHash)
7171

Tests/web3swiftTests/localTests/PersonalSignatureTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PersonalSignatureTests: XCTestCase {
4242
let allAddresses = try await web3.eth.ownedAccounts()
4343
deployTx.transactionOptions.from = allAddresses[0]
4444
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
45-
let deployResult = try await deployTx.send()
45+
let deployResult = try await deployTx.send(password: "web3swift")
4646
let txHash = deployResult.hash
4747
print("Transaction with hash " + txHash)
4848

Tests/web3swiftTests/localTests/PromisesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class web3swiftPromisesTests: XCTestCase {
4545
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
4646
deployTx.transactionOptions.from = allAddresses[0]
4747
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
48-
let result = try await deployTx.send()
48+
let result = try await deployTx.send(password: "web3swift")
4949
let txHash = result.hash
5050
print("Transaction with hash " + txHash)
5151

Tests/web3swiftTests/localTests/TestHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TestHelpers {
3232
parameters: parameters)!
3333
deployTx.transactionOptions.from = allAddresses[0]
3434
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
35-
let result = try await deployTx.send()
35+
let result = try await deployTx.send(password: "web3swift")
3636
let txHash = result.hash
3737
print("Transaction with hash " + txHash)
3838

Tests/web3swiftTests/localTests/UserCases.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class UserCases: XCTestCase {
8080
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
8181
deployTx.transactionOptions.from = allAddresses[0]
8282
deployTx.transactionOptions.gasLimitPolicy = .manual(3000000)
83-
let result = try await deployTx.send()
83+
let result = try await deployTx.send(password: "web3swift")
8484
let txHash = result.hash
8585
print("Transaction with hash " + txHash)
8686

0 commit comments

Comments
 (0)