Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/Web3Core/Structure/Block/Block.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public struct Block {
public var receiptsRoot: Data
public var miner: EthereumAddress? // MARK: This is NOT optional in web3js
public var difficulty: BigUInt
/// by JoshKim: Removed from Ethereum official Blockschema making it optional (https://github.com/ethereum/execution-apis/commit/9e16d5e76a554c733613a2db631130166e2d8725)
/// If decoding of this field has failed it will be set to 0 to avoid breaking changes. Will be made optional in v4 of web3swift.
public var totalDifficulty: BigUInt
public var extraData: Data
public var size: BigUInt
Expand Down Expand Up @@ -83,7 +85,7 @@ extension Block: Decodable {
}

self.difficulty = try container.decodeHex(BigUInt.self, forKey: .difficulty)
self.totalDifficulty = try container.decodeHex(BigUInt.self, forKey: .totalDifficulty)
self.totalDifficulty = (try? container.decodeHex(BigUInt.self, forKey: .totalDifficulty)) ?? .zero
self.extraData = try container.decodeHex(Data.self, forKey: .extraData)
self.size = try container.decodeHex(BigUInt.self, forKey: .size)
self.gasLimit = try container.decodeHex(BigUInt.self, forKey: .gasLimit)
Expand Down