forked from cerc-io/plugeth
Move transact gas check to XEth
This commit is contained in:
parent
e038a42d7a
commit
aa3918efa7
10
rpc/api.go
10
rpc/api.go
@ -48,16 +48,6 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: align default values to have the same type, e.g. not depend on
|
|
||||||
// common.Value conversions later on
|
|
||||||
if args.Gas.Cmp(big.NewInt(0)) == 0 {
|
|
||||||
args.Gas = p.xeth().DefaultGas()
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.GasPrice.Cmp(big.NewInt(0)) == 0 {
|
|
||||||
args.GasPrice = p.xeth().DefaultGasPrice()
|
|
||||||
}
|
|
||||||
|
|
||||||
*reply, err = p.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data)
|
*reply, err = p.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
18
xeth/xeth.go
18
xeth/xeth.go
@ -521,8 +521,8 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
|
|||||||
from []byte
|
from []byte
|
||||||
to []byte
|
to []byte
|
||||||
value = common.NewValue(valueStr)
|
value = common.NewValue(valueStr)
|
||||||
gas = common.NewValue(gasStr)
|
gas = common.Big(gasStr)
|
||||||
price = common.NewValue(gasPriceStr)
|
price = common.Big(gasPriceStr)
|
||||||
data []byte
|
data []byte
|
||||||
contractCreation bool
|
contractCreation bool
|
||||||
)
|
)
|
||||||
@ -549,6 +549,16 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: align default values to have the same type, e.g. not depend on
|
||||||
|
// common.Value conversions later on
|
||||||
|
if gas.Cmp(big.NewInt(0)) == 0 {
|
||||||
|
gas = defaultGas
|
||||||
|
}
|
||||||
|
|
||||||
|
if price.Cmp(big.NewInt(0)) == 0 {
|
||||||
|
price = defaultGasPrice
|
||||||
|
}
|
||||||
|
|
||||||
from = common.FromHex(fromStr)
|
from = common.FromHex(fromStr)
|
||||||
data = common.FromHex(codeStr)
|
data = common.FromHex(codeStr)
|
||||||
to = common.FromHex(toStr)
|
to = common.FromHex(toStr)
|
||||||
@ -558,9 +568,9 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
|
|||||||
|
|
||||||
var tx *types.Transaction
|
var tx *types.Transaction
|
||||||
if contractCreation {
|
if contractCreation {
|
||||||
tx = types.NewContractCreationTx(value.BigInt(), gas.BigInt(), price.BigInt(), data)
|
tx = types.NewContractCreationTx(value.BigInt(), gas, price, data)
|
||||||
} else {
|
} else {
|
||||||
tx = types.NewTransactionMessage(to, value.BigInt(), gas.BigInt(), price.BigInt(), data)
|
tx = types.NewTransactionMessage(to, value.BigInt(), gas, price, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
state := self.chainManager.TxState()
|
state := self.chainManager.TxState()
|
||||||
|
Loading…
Reference in New Issue
Block a user