Skip to content

Commit 10e4b61

Browse files
All tests are green.
1 parent b9055ee commit 10e4b61

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Sources/Core/Transaction/EncodableTransaction.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,22 @@ extension EncodableTransaction: Codable {
229229
}
230230

231231
public func encode(to encoder: Encoder) throws {
232+
// FIXME: There's a huge mess here, please take a look here at code review if any.
232233
var containier = encoder.container(keyedBy: CodingKeys.self)
233-
try containier.encode(type.rawValue.hexString, forKey: .type)
234234
try containier.encode(nonce.hexString, forKey: .nonce)
235235
try containier.encode(accessList, forKey: .accessList)
236236
try containier.encode(data.toHexString().addHexPrefix(), forKey: .data)
237237
try containier.encode(value.hexString, forKey: .value)
238238

239239
// Encoding only fields with value.
240240
// TODO: Rewrite me somehow better.
241-
if let chainID = chainID {
242-
// try containier.encode(chainID.hexString, forKey: .chainID)
241+
if type != .legacy {
242+
try containier.encode(type.rawValue.hexString, forKey: .type)
243+
if let chainID = chainID, !chainID.isZero {
244+
try containier.encode(chainID.hexString, forKey: .chainID)
245+
}
243246
}
247+
244248
if !gasLimit.isZero {
245249
try containier.encode(gasLimit.hexString, forKey: .gasLimit)
246250
}

0 commit comments

Comments
 (0)