2018-04-06 14:52:10 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2018 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2018-01-17 12:57:50 +00:00
|
|
|
import
|
2018-07-05 12:41:01 +00:00
|
|
|
constants, errors, eth_common
|
2018-01-17 12:57:50 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
BaseTransaction* = ref object
|
|
|
|
nonce*: Int256
|
2018-05-30 16:11:15 +00:00
|
|
|
gasPrice*: GasInt
|
|
|
|
gas*: GasInt
|
2018-01-31 12:57:05 +00:00
|
|
|
to*: string
|
2018-02-20 17:27:43 +00:00
|
|
|
value*: UInt256
|
2018-01-31 12:57:05 +00:00
|
|
|
data*: string
|
2018-01-17 12:57:50 +00:00
|
|
|
v*: Int256
|
|
|
|
r*: Int256
|
|
|
|
s*: Int256
|
|
|
|
|
2018-05-30 16:11:15 +00:00
|
|
|
proc intrinsicGas*(t: BaseTransaction): GasInt =
|
2018-01-17 12:57:50 +00:00
|
|
|
# Compute the baseline gas cost for this transaction. This is the amount
|
|
|
|
# of gas needed to send this transaction (but that is not actually used
|
|
|
|
# for computation)
|
|
|
|
raise newException(ValueError, "not implemented intrinsicGas")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc validate*(t: BaseTransaction) =
|
|
|
|
# Hook called during instantiation to ensure that all transaction
|
|
|
|
# parameters pass validation rules
|
2018-01-22 22:23:07 +00:00
|
|
|
if t.intrinsicGas() > t.gas:
|
2018-01-17 12:57:50 +00:00
|
|
|
raise newException(ValidationError, "Insufficient gas")
|
|
|
|
# self.check_signature_validity()
|
2018-01-17 14:16:00 +00:00
|
|
|
|
2018-01-31 12:57:05 +00:00
|
|
|
proc sender*(t: BaseTransaction): string =
|
2018-01-17 14:16:00 +00:00
|
|
|
# TODO
|
2018-04-06 14:52:10 +00:00
|
|
|
""
|