Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
7a00378e
Unverified
Commit
7a00378e
authored
Jun 09, 2021
by
Martin Holst Swende
Committed by
GitHub
Jun 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/clef, signer: support for eip-1559 txs in clef (#22966)
parent
c503f98f
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
177 additions
and
58 deletions
+177
-58
backend.go
accounts/external/backend.go
+12
-7
main.go
cmd/clef/main.go
+3
-3
sign_1559_missing_field_exp_fail.json
cmd/clef/testdata/sign_1559_missing_field_exp_fail.json
+16
-0
sign_1559_missing_maxfeepergas_exp_fail.json
...lef/testdata/sign_1559_missing_maxfeepergas_exp_fail.json
+16
-0
sign_1559_tx.json
cmd/clef/testdata/sign_1559_tx.json
+17
-0
sign_bad_checksum_exp_fail.json
cmd/clef/testdata/sign_bad_checksum_exp_fail.json
+17
-0
sign_normal_exp_ok.json
cmd/clef/testdata/sign_normal_exp_ok.json
+17
-0
transaction_args.go
internal/ethapi/transaction_args.go
+6
-0
api.go
signer/core/api.go
+20
-2
api_test.go
signer/core/api_test.go
+1
-1
cliui.go
signer/core/cliui.go
+9
-4
gnosis_safe.go
signer/core/gnosis_safe.go
+2
-1
types.go
signer/core/types.go
+29
-38
validation.go
signer/fourbyte/validation.go
+10
-0
validation_test.go
signer/fourbyte/validation_test.go
+1
-1
rules_test.go
signer/rules/rules_test.go
+1
-1
No files found.
accounts/external/backend.go
View file @
7a00378e
...
@@ -204,13 +204,18 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
...
@@ -204,13 +204,18 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
to
=
&
t
to
=
&
t
}
}
args
:=
&
core
.
SendTxArgs
{
args
:=
&
core
.
SendTxArgs
{
Data
:
&
data
,
Data
:
&
data
,
Nonce
:
hexutil
.
Uint64
(
tx
.
Nonce
()),
Nonce
:
hexutil
.
Uint64
(
tx
.
Nonce
()),
Value
:
hexutil
.
Big
(
*
tx
.
Value
()),
Value
:
hexutil
.
Big
(
*
tx
.
Value
()),
Gas
:
hexutil
.
Uint64
(
tx
.
Gas
()),
Gas
:
hexutil
.
Uint64
(
tx
.
Gas
()),
GasPrice
:
hexutil
.
Big
(
*
tx
.
GasPrice
()),
To
:
to
,
To
:
to
,
From
:
common
.
NewMixedcaseAddress
(
account
.
Address
),
From
:
common
.
NewMixedcaseAddress
(
account
.
Address
),
}
if
tx
.
GasFeeCap
()
!=
nil
{
args
.
MaxFeePerGas
=
(
*
hexutil
.
Big
)(
tx
.
GasFeeCap
())
args
.
MaxPriorityFeePerGas
=
(
*
hexutil
.
Big
)(
tx
.
GasTipCap
())
}
else
{
args
.
GasPrice
=
(
*
hexutil
.
Big
)(
tx
.
GasPrice
())
}
}
// We should request the default chain id that we're operating with
// We should request the default chain id that we're operating with
// (the chain we're executing on)
// (the chain we're executing on)
...
...
cmd/clef/main.go
View file @
7a00378e
...
@@ -929,7 +929,7 @@ func testExternalUI(api *core.SignerAPI) {
...
@@ -929,7 +929,7 @@ func testExternalUI(api *core.SignerAPI) {
Value
:
hexutil
.
Big
(
*
big
.
NewInt
(
6
)),
Value
:
hexutil
.
Big
(
*
big
.
NewInt
(
6
)),
From
:
common
.
NewMixedcaseAddress
(
a
),
From
:
common
.
NewMixedcaseAddress
(
a
),
To
:
&
to
,
To
:
&
to
,
GasPrice
:
hexutil
.
Big
(
*
big
.
NewInt
(
5
)),
GasPrice
:
(
*
hexutil
.
Big
)(
big
.
NewInt
(
5
)),
Gas
:
1000
,
Gas
:
1000
,
Input
:
nil
,
Input
:
nil
,
}
}
...
@@ -1065,7 +1065,7 @@ func GenDoc(ctx *cli.Context) {
...
@@ -1065,7 +1065,7 @@ func GenDoc(ctx *cli.Context) {
Value
:
hexutil
.
Big
(
*
big
.
NewInt
(
6
)),
Value
:
hexutil
.
Big
(
*
big
.
NewInt
(
6
)),
From
:
common
.
NewMixedcaseAddress
(
a
),
From
:
common
.
NewMixedcaseAddress
(
a
),
To
:
nil
,
To
:
nil
,
GasPrice
:
hexutil
.
Big
(
*
big
.
NewInt
(
5
)),
GasPrice
:
(
*
hexutil
.
Big
)(
big
.
NewInt
(
5
)),
Gas
:
1000
,
Gas
:
1000
,
Input
:
nil
,
Input
:
nil
,
}})
}})
...
@@ -1081,7 +1081,7 @@ func GenDoc(ctx *cli.Context) {
...
@@ -1081,7 +1081,7 @@ func GenDoc(ctx *cli.Context) {
Value
:
hexutil
.
Big
(
*
big
.
NewInt
(
6
)),
Value
:
hexutil
.
Big
(
*
big
.
NewInt
(
6
)),
From
:
common
.
NewMixedcaseAddress
(
a
),
From
:
common
.
NewMixedcaseAddress
(
a
),
To
:
nil
,
To
:
nil
,
GasPrice
:
hexutil
.
Big
(
*
big
.
NewInt
(
5
)),
GasPrice
:
(
*
hexutil
.
Big
)(
big
.
NewInt
(
5
)),
Gas
:
1000
,
Gas
:
1000
,
Input
:
nil
,
Input
:
nil
,
}})
}})
...
...
cmd/clef/testdata/sign_1559_missing_field_exp_fail.json
0 → 100644
View file @
7a00378e
{
"jsonrpc"
:
"2.0"
,
"method"
:
"account_signTransaction"
,
"params"
:
[
{
"from"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"to"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"gas"
:
"0x333"
,
"maxFeePerGas"
:
"0x123"
,
"nonce"
:
"0x0"
,
"value"
:
"0x10"
,
"data"
:
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
}
],
"id"
:
67
}
cmd/clef/testdata/sign_1559_missing_maxfeepergas_exp_fail.json
0 → 100644
View file @
7a00378e
{
"jsonrpc"
:
"2.0"
,
"method"
:
"account_signTransaction"
,
"params"
:
[
{
"from"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"to"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"gas"
:
"0x333"
,
"maxPriorityFeePerGas"
:
"0x123"
,
"nonce"
:
"0x0"
,
"value"
:
"0x10"
,
"data"
:
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
}
],
"id"
:
67
}
cmd/clef/testdata/sign_1559_tx.json
0 → 100644
View file @
7a00378e
{
"jsonrpc"
:
"2.0"
,
"method"
:
"account_signTransaction"
,
"params"
:
[
{
"from"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"to"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"gas"
:
"0x333"
,
"maxPriorityFeePerGas"
:
"0x123"
,
"maxFeePerGas"
:
"0x123"
,
"nonce"
:
"0x0"
,
"value"
:
"0x10"
,
"data"
:
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
}
],
"id"
:
67
}
cmd/clef/testdata/sign_bad_checksum_exp_fail.json
0 → 100644
View file @
7a00378e
{
"jsonrpc"
:
"2.0"
,
"method"
:
"account_signTransaction"
,
"params"
:
[
{
"from"
:
"0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192"
,
"to"
:
"0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192"
,
"gas"
:
"0x333"
,
"gasPrice"
:
"0x123"
,
"nonce"
:
"0x0"
,
"value"
:
"0x10"
,
"data"
:
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
}
],
"id"
:
67
}
cmd/clef/testdata/sign_normal_exp_ok.json
0 → 100644
View file @
7a00378e
{
"jsonrpc"
:
"2.0"
,
"method"
:
"account_signTransaction"
,
"params"
:
[
{
"from"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"to"
:
"0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192"
,
"gas"
:
"0x333"
,
"gasPrice"
:
"0x123"
,
"nonce"
:
"0x0"
,
"value"
:
"0x10"
,
"data"
:
"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
}
],
"id"
:
67
}
internal/ethapi/transaction_args.go
View file @
7a00378e
...
@@ -265,3 +265,9 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
...
@@ -265,3 +265,9 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
}
}
return
types
.
NewTx
(
data
)
return
types
.
NewTx
(
data
)
}
}
// ToTransaction converts the arguments to a transaction.
// This assumes that setDefaults has been called.
func
(
args
*
TransactionArgs
)
ToTransaction
()
*
types
.
Transaction
{
return
args
.
toTransaction
()
}
signer/core/api.go
View file @
7a00378e
...
@@ -456,6 +456,16 @@ func (api *SignerAPI) newAccount() (common.Address, error) {
...
@@ -456,6 +456,16 @@ func (api *SignerAPI) newAccount() (common.Address, error) {
// it also returns 'true' if the transaction was modified, to make it possible to configure the signer not to allow
// it also returns 'true' if the transaction was modified, to make it possible to configure the signer not to allow
// UI-modifications to requests
// UI-modifications to requests
func
logDiff
(
original
*
SignTxRequest
,
new
*
SignTxResponse
)
bool
{
func
logDiff
(
original
*
SignTxRequest
,
new
*
SignTxResponse
)
bool
{
var
intPtrModified
=
func
(
a
,
b
*
hexutil
.
Big
)
bool
{
aBig
:=
(
*
big
.
Int
)(
a
)
bBig
:=
(
*
big
.
Int
)(
b
)
if
aBig
!=
nil
&&
bBig
!=
nil
{
return
aBig
.
Cmp
(
bBig
)
!=
0
}
// One or both of them are nil
return
a
!=
b
}
modified
:=
false
modified
:=
false
if
f0
,
f1
:=
original
.
Transaction
.
From
,
new
.
Transaction
.
From
;
!
reflect
.
DeepEqual
(
f0
,
f1
)
{
if
f0
,
f1
:=
original
.
Transaction
.
From
,
new
.
Transaction
.
From
;
!
reflect
.
DeepEqual
(
f0
,
f1
)
{
log
.
Info
(
"Sender-account changed by UI"
,
"was"
,
f0
,
"is"
,
f1
)
log
.
Info
(
"Sender-account changed by UI"
,
"was"
,
f0
,
"is"
,
f1
)
...
@@ -469,9 +479,17 @@ func logDiff(original *SignTxRequest, new *SignTxResponse) bool {
...
@@ -469,9 +479,17 @@ func logDiff(original *SignTxRequest, new *SignTxResponse) bool {
modified
=
true
modified
=
true
log
.
Info
(
"Gas changed by UI"
,
"was"
,
g0
,
"is"
,
g1
)
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
{
if
a
,
b
:=
original
.
Transaction
.
GasPrice
,
new
.
Transaction
.
GasPrice
;
intPtrModified
(
a
,
b
)
{
log
.
Info
(
"GasPrice changed by UI"
,
"was"
,
a
,
"is"
,
b
)
modified
=
true
}
if
a
,
b
:=
original
.
Transaction
.
MaxPriorityFeePerGas
,
new
.
Transaction
.
MaxPriorityFeePerGas
;
intPtrModified
(
a
,
b
)
{
log
.
Info
(
"maxPriorityFeePerGas changed by UI"
,
"was"
,
a
,
"is"
,
b
)
modified
=
true
}
if
a
,
b
:=
original
.
Transaction
.
MaxFeePerGas
,
new
.
Transaction
.
MaxFeePerGas
;
intPtrModified
(
a
,
b
)
{
log
.
Info
(
"maxFeePerGas changed by UI"
,
"was"
,
a
,
"is"
,
b
)
modified
=
true
modified
=
true
log
.
Info
(
"GasPrice changed by UI"
,
"was"
,
g0
,
"is"
,
g1
)
}
}
if
v0
,
v1
:=
big
.
Int
(
original
.
Transaction
.
Value
),
big
.
Int
(
new
.
Transaction
.
Value
);
v0
.
Cmp
(
&
v1
)
!=
0
{
if
v0
,
v1
:=
big
.
Int
(
original
.
Transaction
.
Value
),
big
.
Int
(
new
.
Transaction
.
Value
);
v0
.
Cmp
(
&
v1
)
!=
0
{
modified
=
true
modified
=
true
...
...
signer/core/api_test.go
View file @
7a00378e
...
@@ -234,7 +234,7 @@ func mkTestTx(from common.MixedcaseAddress) core.SendTxArgs {
...
@@ -234,7 +234,7 @@ func mkTestTx(from common.MixedcaseAddress) core.SendTxArgs {
From
:
from
,
From
:
from
,
To
:
&
to
,
To
:
&
to
,
Gas
:
gas
,
Gas
:
gas
,
GasPrice
:
gasPrice
,
GasPrice
:
&
gasPrice
,
Value
:
value
,
Value
:
value
,
Data
:
&
data
,
Data
:
&
data
,
Nonce
:
nonce
}
Nonce
:
nonce
}
...
...
signer/core/cliui.go
View file @
7a00378e
...
@@ -113,10 +113,15 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
...
@@ -113,10 +113,15 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
}
else
{
}
else
{
fmt
.
Printf
(
"to: <contact creation>
\n
"
)
fmt
.
Printf
(
"to: <contact creation>
\n
"
)
}
}
fmt
.
Printf
(
"from: %v
\n
"
,
request
.
Transaction
.
From
.
String
())
fmt
.
Printf
(
"from: %v
\n
"
,
request
.
Transaction
.
From
.
String
())
fmt
.
Printf
(
"value: %v wei
\n
"
,
weival
)
fmt
.
Printf
(
"value: %v wei
\n
"
,
weival
)
fmt
.
Printf
(
"gas: %v (%v)
\n
"
,
request
.
Transaction
.
Gas
,
uint64
(
request
.
Transaction
.
Gas
))
fmt
.
Printf
(
"gas: %v (%v)
\n
"
,
request
.
Transaction
.
Gas
,
uint64
(
request
.
Transaction
.
Gas
))
fmt
.
Printf
(
"gasprice: %v wei
\n
"
,
request
.
Transaction
.
GasPrice
.
ToInt
())
if
request
.
Transaction
.
MaxFeePerGas
!=
nil
{
fmt
.
Printf
(
"maxFeePerGas: %v wei
\n
"
,
request
.
Transaction
.
MaxFeePerGas
.
ToInt
())
fmt
.
Printf
(
"maxPriorityFeePerGas: %v wei
\n
"
,
request
.
Transaction
.
MaxPriorityFeePerGas
.
ToInt
())
}
else
{
fmt
.
Printf
(
"gasprice: %v wei
\n
"
,
request
.
Transaction
.
GasPrice
.
ToInt
())
}
fmt
.
Printf
(
"nonce: %v (%v)
\n
"
,
request
.
Transaction
.
Nonce
,
uint64
(
request
.
Transaction
.
Nonce
))
fmt
.
Printf
(
"nonce: %v (%v)
\n
"
,
request
.
Transaction
.
Nonce
,
uint64
(
request
.
Transaction
.
Nonce
))
if
chainId
:=
request
.
Transaction
.
ChainID
;
chainId
!=
nil
{
if
chainId
:=
request
.
Transaction
.
ChainID
;
chainId
!=
nil
{
fmt
.
Printf
(
"chainid: %v
\n
"
,
chainId
)
fmt
.
Printf
(
"chainid: %v
\n
"
,
chainId
)
...
...
signer/core/gnosis_safe.go
View file @
7a00378e
...
@@ -77,11 +77,12 @@ func (tx *GnosisSafeTx) ToTypedData() TypedData {
...
@@ -77,11 +77,12 @@ func (tx *GnosisSafeTx) ToTypedData() TypedData {
// ArgsForValidation returns a SendTxArgs struct, which can be used for the
// ArgsForValidation returns a SendTxArgs struct, which can be used for the
// common validations, e.g. look up 4byte destinations
// common validations, e.g. look up 4byte destinations
func
(
tx
*
GnosisSafeTx
)
ArgsForValidation
()
*
SendTxArgs
{
func
(
tx
*
GnosisSafeTx
)
ArgsForValidation
()
*
SendTxArgs
{
gp
:=
hexutil
.
Big
(
tx
.
GasPrice
)
args
:=
&
SendTxArgs
{
args
:=
&
SendTxArgs
{
From
:
tx
.
Safe
,
From
:
tx
.
Safe
,
To
:
&
tx
.
To
,
To
:
&
tx
.
To
,
Gas
:
hexutil
.
Uint64
(
tx
.
SafeTxGas
.
Uint64
()),
Gas
:
hexutil
.
Uint64
(
tx
.
SafeTxGas
.
Uint64
()),
GasPrice
:
hexutil
.
Big
(
tx
.
GasPrice
)
,
GasPrice
:
&
gp
,
Value
:
hexutil
.
Big
(
tx
.
Value
),
Value
:
hexutil
.
Big
(
tx
.
Value
),
Nonce
:
hexutil
.
Uint64
(
tx
.
Nonce
.
Uint64
()),
Nonce
:
hexutil
.
Uint64
(
tx
.
Nonce
.
Uint64
()),
Data
:
tx
.
Data
,
Data
:
tx
.
Data
,
...
...
signer/core/types.go
View file @
7a00378e
...
@@ -19,12 +19,12 @@ package core
...
@@ -19,12 +19,12 @@ package core
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"math/big"
"strings"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/ethapi"
)
)
type
ValidationInfo
struct
{
type
ValidationInfo
struct
{
...
@@ -66,14 +66,21 @@ func (v *ValidationMessages) getWarnings() error {
...
@@ -66,14 +66,21 @@ func (v *ValidationMessages) getWarnings() error {
}
}
// SendTxArgs represents the arguments to submit a transaction
// SendTxArgs represents the arguments to submit a transaction
// This struct is identical to ethapi.TransactionArgs, except for the usage of
// common.MixedcaseAddress in From and To
type
SendTxArgs
struct
{
type
SendTxArgs
struct
{
From
common
.
MixedcaseAddress
`json:"from"`
From
common
.
MixedcaseAddress
`json:"from"`
To
*
common
.
MixedcaseAddress
`json:"to"`
To
*
common
.
MixedcaseAddress
`json:"to"`
Gas
hexutil
.
Uint64
`json:"gas"`
Gas
hexutil
.
Uint64
`json:"gas"`
GasPrice
hexutil
.
Big
`json:"gasPrice"`
GasPrice
*
hexutil
.
Big
`json:"gasPrice"`
Value
hexutil
.
Big
`json:"value"`
MaxFeePerGas
*
hexutil
.
Big
`json:"maxFeePerGas"`
Nonce
hexutil
.
Uint64
`json:"nonce"`
MaxPriorityFeePerGas
*
hexutil
.
Big
`json:"maxPriorityFeePerGas"`
Value
hexutil
.
Big
`json:"value"`
Nonce
hexutil
.
Uint64
`json:"nonce"`
// We accept "data" and "input" for backwards-compatibility reasons.
// We accept "data" and "input" for backwards-compatibility reasons.
// "input" is the newer name and should be preferred by clients.
// Issue detail: https://github.com/ethereum/go-ethereum/issues/15628
Data
*
hexutil
.
Bytes
`json:"data"`
Data
*
hexutil
.
Bytes
`json:"data"`
Input
*
hexutil
.
Bytes
`json:"input,omitempty"`
Input
*
hexutil
.
Bytes
`json:"input,omitempty"`
...
@@ -91,38 +98,22 @@ func (args SendTxArgs) String() string {
...
@@ -91,38 +98,22 @@ func (args SendTxArgs) String() string {
}
}
func
(
args
*
SendTxArgs
)
toTransaction
()
*
types
.
Transaction
{
func
(
args
*
SendTxArgs
)
toTransaction
()
*
types
.
Transaction
{
var
input
[]
byte
txArgs
:=
ethapi
.
TransactionArgs
{
if
args
.
Data
!=
nil
{
Gas
:
&
args
.
Gas
,
input
=
*
args
.
Data
GasPrice
:
args
.
GasPrice
,
}
else
if
args
.
Input
!=
nil
{
MaxFeePerGas
:
args
.
MaxFeePerGas
,
input
=
*
args
.
Input
MaxPriorityFeePerGas
:
args
.
MaxPriorityFeePerGas
,
Value
:
&
args
.
Value
,
Nonce
:
&
args
.
Nonce
,
Data
:
args
.
Data
,
Input
:
args
.
Input
,
AccessList
:
args
.
AccessList
,
ChainID
:
args
.
ChainID
,
}
}
var
to
*
common
.
Address
// Add the To-field, if specified
if
args
.
To
!=
nil
{
if
args
.
To
!=
nil
{
_to
:=
args
.
To
.
Address
()
to
:=
args
.
To
.
Address
()
to
=
&
_to
txArgs
.
To
=
&
to
}
var
data
types
.
TxData
if
args
.
AccessList
==
nil
{
data
=
&
types
.
LegacyTx
{
To
:
to
,
Nonce
:
uint64
(
args
.
Nonce
),
Gas
:
uint64
(
args
.
Gas
),
GasPrice
:
(
*
big
.
Int
)(
&
args
.
GasPrice
),
Value
:
(
*
big
.
Int
)(
&
args
.
Value
),
Data
:
input
,
}
}
else
{
data
=
&
types
.
AccessListTx
{
To
:
to
,
ChainID
:
(
*
big
.
Int
)(
args
.
ChainID
),
Nonce
:
uint64
(
args
.
Nonce
),
Gas
:
uint64
(
args
.
Gas
),
GasPrice
:
(
*
big
.
Int
)(
&
args
.
GasPrice
),
Value
:
(
*
big
.
Int
)(
&
args
.
Value
),
Data
:
input
,
AccessList
:
*
args
.
AccessList
,
}
}
}
return
t
ypes
.
NewTx
(
data
)
return
t
xArgs
.
ToTransaction
(
)
}
}
signer/fourbyte/validation.go
View file @
7a00378e
...
@@ -73,6 +73,16 @@ func (db *Database) ValidateTransaction(selector *string, tx *core.SendTxArgs) (
...
@@ -73,6 +73,16 @@ func (db *Database) ValidateTransaction(selector *string, tx *core.SendTxArgs) (
if
bytes
.
Equal
(
tx
.
To
.
Address
()
.
Bytes
(),
common
.
Address
{}
.
Bytes
())
{
if
bytes
.
Equal
(
tx
.
To
.
Address
()
.
Bytes
(),
common
.
Address
{}
.
Bytes
())
{
messages
.
Crit
(
"Transaction recipient is the zero address"
)
messages
.
Crit
(
"Transaction recipient is the zero address"
)
}
}
switch
{
case
tx
.
GasPrice
==
nil
&&
tx
.
MaxFeePerGas
==
nil
:
messages
.
Crit
(
"Neither 'gasPrice' nor 'maxFeePerGas' specified."
)
case
tx
.
GasPrice
==
nil
&&
tx
.
MaxPriorityFeePerGas
==
nil
:
messages
.
Crit
(
"Neither 'gasPrice' nor 'maxPriorityFeePerGas' specified."
)
case
tx
.
GasPrice
!=
nil
&&
tx
.
MaxFeePerGas
!=
nil
:
messages
.
Crit
(
"Both 'gasPrice' and 'maxFeePerGas' specified."
)
case
tx
.
GasPrice
!=
nil
&&
tx
.
MaxPriorityFeePerGas
!=
nil
:
messages
.
Crit
(
"Both 'gasPrice' and 'maxPriorityFeePerGas' specified."
)
}
// Semantic fields validated, try to make heads or tails of the call data
// Semantic fields validated, try to make heads or tails of the call data
db
.
ValidateCallData
(
selector
,
data
,
messages
)
db
.
ValidateCallData
(
selector
,
data
,
messages
)
return
messages
,
nil
return
messages
,
nil
...
...
signer/fourbyte/validation_test.go
View file @
7a00378e
...
@@ -60,7 +60,7 @@ func dummyTxArgs(t txtestcase) *core.SendTxArgs {
...
@@ -60,7 +60,7 @@ func dummyTxArgs(t txtestcase) *core.SendTxArgs {
To
:
to
,
To
:
to
,
Value
:
value
,
Value
:
value
,
Nonce
:
n
,
Nonce
:
n
,
GasPrice
:
gasPrice
,
GasPrice
:
&
gasPrice
,
Gas
:
gas
,
Gas
:
gas
,
Data
:
data
,
Data
:
data
,
Input
:
input
,
Input
:
input
,
...
...
signer/rules/rules_test.go
View file @
7a00378e
...
@@ -437,7 +437,7 @@ func dummyTx(value hexutil.Big) *core.SignTxRequest {
...
@@ -437,7 +437,7 @@ func dummyTx(value hexutil.Big) *core.SignTxRequest {
To
:
to
,
To
:
to
,
Value
:
value
,
Value
:
value
,
Nonce
:
n
,
Nonce
:
n
,
GasPrice
:
gasPrice
,
GasPrice
:
&
gasPrice
,
Gas
:
gas
,
Gas
:
gas
,
},
},
Callinfo
:
[]
core
.
ValidationInfo
{
Callinfo
:
[]
core
.
ValidationInfo
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment