wallet/Shared/Ethereum/EthereumNetwork.swift
2021-12-03 16:15:53 +03:00

35 lines
867 B
Swift

// Copyright © 2021 Tokenary. All rights reserved.
import Foundation
import Web3Swift
final class EthereumNetwork: Network {
private static var netwotkForChain = [EthereumChain: Network]()
static func forChain(_ chain: EthereumChain) -> Network {
if let network = netwotkForChain[chain] {
return network
} else {
let network = EthereumNetwork(url: chain.nodeURLString)
netwotkForChain[chain] = network
return network
}
}
private let origin: GethNetwork
init(url: String) {
origin = GethNetwork(url: url)
}
func id() throws -> IntegerScalar {
return try origin.id()
}
func call(method: String, params: [EthParameter]) throws -> Data {
return try origin.call(method: method, params: params)
}
}