2018-01-17 12:57:50 +00:00
|
|
|
import
|
2018-02-07 16:16:04 +00:00
|
|
|
constants, ttmath, errors
|
2018-01-17 12:57:50 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
BaseTransaction* = ref object
|
|
|
|
nonce*: Int256
|
|
|
|
gasPrice*: Int256
|
|
|
|
gas*: Int256
|
2018-01-31 12:57:05 +00:00
|
|
|
to*: string
|
2018-01-17 12:57:50 +00:00
|
|
|
value*: Int256
|
2018-01-31 12:57:05 +00:00
|
|
|
data*: string
|
2018-01-17 12:57:50 +00:00
|
|
|
v*: Int256
|
|
|
|
r*: Int256
|
|
|
|
s*: Int256
|
|
|
|
|
|
|
|
proc intrinsicGas*(t: BaseTransaction): Int256 =
|
|
|
|
# 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-01-31 12:57:05 +00:00
|
|
|
""
|