An advanced Ethereum/EVM mobile wallet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
alpha-wallet-ios/Trust/Models/Block.swift

39 lines
970 B

// Copyright SIX DAY LLC. All rights reserved.
import Foundation
struct ParsedBlock {
let number: String
let timestamp: String
}
struct Block {
let number: String
let timestamp: String
let transactions: [ParsedTransaction]
}
extension Block {
static func from(json: [String: AnyObject]) -> Block? {
if
let transactionsJSON = json["transactions"] as? [[String: AnyObject]] {
let number = json["number"] as? String ?? ""
let timestamp = json["timestamp"] as? String ?? ""
let block = ParsedBlock(
number: number,
timestamp: timestamp
)
let transactions: [ParsedTransaction] = transactionsJSON.map { .from(block: block, transaction: $0) }
return Block(
number: number,
timestamp: timestamp,
transactions: transactions
)
}
return nil
}
}