EIP1559 updates for SendTxArgs in signer pkg
This commit is contained in:
+27
-1
@@ -455,10 +455,36 @@ func logDiff(original *SignTxRequest, new *SignTxResponse) bool {
|
||||
modified = true
|
||||
log.Info("Gas changed by UI", "was", g0, "is", g1)
|
||||
}
|
||||
if g0, g1 := big.Int(original.Transaction.GasPrice), big.Int(new.Transaction.GasPrice); g0.Cmp(&g1) != 0 {
|
||||
g0, g1 := (*big.Int)(original.Transaction.GasPrice), (*big.Int)(new.Transaction.GasPrice)
|
||||
if g0 == nil || g1 == nil {
|
||||
if g0 != g1 {
|
||||
modified = true
|
||||
log.Info("GasPrice changed by UI", "was", g0, "is", g1)
|
||||
}
|
||||
} else if g0.Cmp(g1) != 0 {
|
||||
modified = true
|
||||
log.Info("GasPrice changed by UI", "was", g0, "is", g1)
|
||||
}
|
||||
gp0, gp1 := (*big.Int)(original.Transaction.GasPremium), (*big.Int)(new.Transaction.GasPremium)
|
||||
if gp0 == nil || gp1 == nil {
|
||||
if gp0 != gp1 {
|
||||
modified = true
|
||||
log.Info("GasPremium changed by UI", "was", gp0, "is", gp1)
|
||||
}
|
||||
} else if gp0.Cmp(gp1) != 0 {
|
||||
modified = true
|
||||
log.Info("GasPremium changed by UI", "was", gp0, "is", gp1)
|
||||
}
|
||||
f0, f1 := (*big.Int)(original.Transaction.FeeCap), (*big.Int)(new.Transaction.FeeCap)
|
||||
if f0 == nil || f1 == nil {
|
||||
if f0 != f1 {
|
||||
modified = true
|
||||
log.Info("GasFee changed by UI", "was", f0, "is", f1)
|
||||
}
|
||||
} else if f0.Cmp(f1) != 0 {
|
||||
modified = true
|
||||
log.Info("GasFee changed by UI", "was", f0, "is", f1)
|
||||
}
|
||||
if v0, v1 := big.Int(original.Transaction.Value), big.Int(new.Transaction.Value); v0.Cmp(&v1) != 0 {
|
||||
modified = true
|
||||
log.Info("Value changed by UI", "was", v0, "is", v1)
|
||||
|
||||
@@ -226,7 +226,7 @@ func TestNewAcc(t *testing.T) {
|
||||
func mkTestTx(from common.MixedcaseAddress) core.SendTxArgs {
|
||||
to := common.NewMixedcaseAddress(common.HexToAddress("0x1337"))
|
||||
gas := hexutil.Uint64(21000)
|
||||
gasPrice := (hexutil.Big)(*big.NewInt(2000000000))
|
||||
gasPrice := (*hexutil.Big)(big.NewInt(2000000000))
|
||||
value := (hexutil.Big)(*big.NewInt(1e18))
|
||||
nonce := (hexutil.Uint64)(0)
|
||||
data := hexutil.Bytes(common.Hex2Bytes("01020304050607080a"))
|
||||
|
||||
@@ -70,12 +70,15 @@ type SendTxArgs struct {
|
||||
From common.MixedcaseAddress `json:"from"`
|
||||
To *common.MixedcaseAddress `json:"to"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasPrice hexutil.Big `json:"gasPrice"`
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
Value hexutil.Big `json:"value"`
|
||||
Nonce hexutil.Uint64 `json:"nonce"`
|
||||
// We accept "data" and "input" for backwards-compatibility reasons.
|
||||
Data *hexutil.Bytes `json:"data"`
|
||||
Input *hexutil.Bytes `json:"input,omitempty"`
|
||||
// EIP1559 fields
|
||||
GasPremium *hexutil.Big `json:"gasPremium"`
|
||||
FeeCap *hexutil.Big `json:"feeCap"`
|
||||
}
|
||||
|
||||
func (args SendTxArgs) String() string {
|
||||
@@ -94,7 +97,7 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
|
||||
input = *args.Input
|
||||
}
|
||||
if args.To == nil {
|
||||
return types.NewContractCreation(uint64(args.Nonce), (*big.Int)(&args.Value), uint64(args.Gas), (*big.Int)(&args.GasPrice), input, nil, nil)
|
||||
return types.NewContractCreation(uint64(args.Nonce), (*big.Int)(&args.Value), uint64(args.Gas), (*big.Int)(args.GasPrice), input, (*big.Int)(args.GasPremium), (*big.Int)(args.FeeCap))
|
||||
}
|
||||
return types.NewTransaction(uint64(args.Nonce), args.To.Address(), (*big.Int)(&args.Value), (uint64)(args.Gas), (*big.Int)(&args.GasPrice), input, nil, nil)
|
||||
return types.NewTransaction(uint64(args.Nonce), args.To.Address(), (*big.Int)(&args.Value), (uint64)(args.Gas), (*big.Int)(args.GasPrice), input, (*big.Int)(args.GasPremium), (*big.Int)(args.FeeCap))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user