Skip to content

Commit 8f21f33

Browse files
fix: fixed warnings pointing out the use of deprecated 'encode' function
1 parent 6869702 commit 8f21f33

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Sources/web3swift/EthereumAPICalls/Ethereum/Eth+SendRawTransaction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension web3.Eth {
1717
}
1818

1919
public func send(raw transaction: EthereumTransaction) async throws -> TransactionSendingResult {
20-
guard let transactionHexData = transaction.encode()?.toHexString().addHexPrefix() else { throw Web3Error.dataError }
20+
guard let transactionHexData = transaction.encode(for: .transaction)?.toHexString().addHexPrefix() else { throw Web3Error.dataError }
2121
let request: APIRequest = .sendRawTransaction(transactionHexData)
2222
let response: APIResponse<Hash> = try await APIRequest.sendRequest(with: self.provider, for: request)
2323

Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ extension web3.BrowserFunctions {
207207
guard let keystore = keystoreManager.walletForAddress(from) else {return nil}
208208
try Web3Signer.signTX(transaction: &transaction, keystore: keystore, account: from, password: password)
209209
print(transaction)
210-
let signedData = transaction.encode()?.toHexString().addHexPrefix()
210+
let signedData = transaction.encode(for: .transaction)?.toHexString().addHexPrefix()
211211
return signedData
212212
} catch {
213213
return nil

Tests/web3swiftTests/localTests/TransactionsTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class TransactionsTests: XCTestCase {
235235

236236
// now sign the transaction with the private key
237237
try jsonTxn.sign(privateKey: privateKeyData, useExtraEntropy: false)
238-
let rawTxn = jsonTxn.encode()!.toHexString().addHexPrefix()
238+
let rawTxn = jsonTxn.encode(for: .transaction)!.toHexString().addHexPrefix()
239239

240240
// check the hash, if they match everything was parsed, and re-encoded correctly
241241
XCTAssertEqual(rawTxn, vector.RLP, "Transaction Encoding Mismatch")
@@ -304,7 +304,7 @@ class TransactionsTests: XCTestCase {
304304

305305
// now sign the transaction with the private key
306306
try jsonTxn.sign(privateKey: privateKeyData, useExtraEntropy: false)
307-
let rawTxn = jsonTxn.encode()!.toHexString().addHexPrefix()
307+
let rawTxn = jsonTxn.encode(for: .transaction)!.toHexString().addHexPrefix()
308308

309309
// check the hash, if they match everything was parsed, and re-encoded correctly
310310
XCTAssertEqual(rawTxn, vector.RLP, "Transaction Encoding Mismatch")
@@ -373,7 +373,7 @@ class TransactionsTests: XCTestCase {
373373

374374
// now sign the transaction with the private key
375375
try jsonTxn.sign(privateKey: privateKeyData, useExtraEntropy: false)
376-
let rawTxn = jsonTxn.encode()!.toHexString().addHexPrefix()
376+
let rawTxn = jsonTxn.encode(for: .transaction)!.toHexString().addHexPrefix()
377377

378378
// check the hash, if they match everything was parsed, and re-encoded correctly
379379
XCTAssertEqual(rawTxn, vector.RLP, "Transaction Encoding Mismatch")
@@ -442,7 +442,7 @@ class TransactionsTests: XCTestCase {
442442

443443
// now sign the transaction with the private key
444444
try jsonTxn.sign(privateKey: privateKeyData, useExtraEntropy: false)
445-
let rawTxn = jsonTxn.encode()!.toHexString().addHexPrefix()
445+
let rawTxn = jsonTxn.encode(for: .transaction)!.toHexString().addHexPrefix()
446446

447447
// check the hash, if they match everything was parsed, and re-encoded correctly
448448
XCTAssertEqual(rawTxn, vector.RLP, "Transaction Encoding Mismatch")
@@ -511,7 +511,7 @@ class TransactionsTests: XCTestCase {
511511

512512
// now sign the transaction with the private key
513513
try jsonTxn.sign(privateKey: privateKeyData, useExtraEntropy: false)
514-
let rawTxn = jsonTxn.encode()!.toHexString().addHexPrefix()
514+
let rawTxn = jsonTxn.encode(for: .transaction)!.toHexString().addHexPrefix()
515515

516516
// check the hash, if they match everything was parsed, and re-encoded correctly
517517
XCTAssertEqual(rawTxn, vector.RLP, "Transaction Encoding Mismatch")
@@ -580,7 +580,7 @@ class TransactionsTests: XCTestCase {
580580

581581
// now sign the transaction with the private key
582582
try jsonTxn.sign(privateKey: privateKeyData, useExtraEntropy: false)
583-
let rawTxn = jsonTxn.encode()!.toHexString().addHexPrefix()
583+
let rawTxn = jsonTxn.encode(for: .transaction)!.toHexString().addHexPrefix()
584584

585585
// check the hash, if they match everything was parsed, and re-encoded correctly
586586
XCTAssertEqual(rawTxn, vector.RLP, "Transaction Encoding Mismatch")

0 commit comments

Comments
 (0)