mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-14 22:45:54 +03:00
56 lines
1.1 KiB
Swift
56 lines
1.1 KiB
Swift
//
|
|
// This source file is part of the Web3Swift.io open source project
|
|
// Copyright 2018 The Web3Swift Authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// EstimateGasProcedure.swift
|
|
//
|
|
// Created by Timofey Solonin on 10/05/2018
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftyJSON
|
|
|
|
public final class EstimateGasProcedure: RemoteProcedure {
|
|
|
|
private let network: Network
|
|
private let parameters: [String: EthParameter]
|
|
|
|
/**
|
|
Ctor
|
|
|
|
- parameters:
|
|
- network: network to call
|
|
- parameters: arguments of the estimate
|
|
*/
|
|
public init(
|
|
network: Network,
|
|
parameters: [String: EthParameter]
|
|
) {
|
|
self.network = network
|
|
self.parameters = parameters
|
|
}
|
|
|
|
|
|
/**
|
|
- returns:
|
|
`JSON` for the gas estimate
|
|
|
|
- throws:
|
|
`DescribedError` if something went wrong
|
|
*/
|
|
public func call() throws -> JSON {
|
|
return try JSON(
|
|
data: network.call(
|
|
method: "eth_estimateGas",
|
|
params: [
|
|
ObjectParameter(
|
|
dictionary: parameters
|
|
)
|
|
]
|
|
)
|
|
)
|
|
}
|
|
|
|
}
|