Skip to content

Commit ef06fbf

Browse files
fix: data field in CodableTransaction must be passed into the envelope
1 parent 76b3eba commit ef06fbf

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Sources/Core/Transaction/CodableTransaction.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ public struct CodableTransaction {
5656
set { envelope.value = newValue }
5757
}
5858

59-
// MARK: - Ruins signing and decoding tests if tied to envelop
60-
/// any additional data for the transaction
61-
public var data: Data
59+
public var data: Data {
60+
get { return envelope.data }
61+
set { envelope.data = newValue }
62+
}
6263

6364
// MARK: - Properties transaction type related either sends to a node if exist
6465

@@ -174,8 +175,6 @@ public struct CodableTransaction {
174175
public init?(rawValue: Data) {
175176
guard let env = EnvelopeFactory.createEnvelope(rawValue: rawValue) else { return nil }
176177
self.envelope = env
177-
// FIXME: This is duplication and should be fixed.
178-
data = Data()
179178
noncePolicy = .latest
180179
gasLimitPolicy = .automatic
181180
gasPricePolicy = .automatic
@@ -233,9 +232,6 @@ extension CodableTransaction: Codable {
233232
public init(from decoder: Decoder) throws {
234233
guard let env = try EnvelopeFactory.createEnvelope(from: decoder) else { throw Web3Error.dataError }
235234
self.envelope = env
236-
// FIXME: This is duplication and should be fixed.
237-
data = Data()
238-
239235
noncePolicy = .latest
240236
gasLimitPolicy = .automatic
241237
gasPricePolicy = .automatic
@@ -420,8 +416,6 @@ extension CodableTransaction {
420416
chainID: BigUInt = 0, value: BigUInt = 0, data: Data = Data(),
421417
gasLimit: BigUInt = 0, maxFeePerGas: BigUInt? = nil, maxPriorityFeePerGas: BigUInt? = nil, gasPrice: BigUInt? = nil,
422418
accessList: [AccessListEntry]? = nil, v: BigUInt = 1, r: BigUInt = 0, s: BigUInt = 0) {
423-
// FIXME: This is duplication and should be fixed.
424-
self.data = data
425419
self.accessList = accessList
426420
self.gasLimitPolicy = .automatic
427421
self.noncePolicy = .pending

0 commit comments

Comments
 (0)