Skip to content

Commit 94d2520

Browse files
committed
Check if chainId is not nil before constructing EIP155 signer
EIP155 signer does not perform chain ID validation and if chain ID is nil, transaction is rejected by Ethereum client as not being EIP155 compliant. A simple chainId nil check was added in this commit. A similar check is performed in the original go-ethereum code in NewKeyedTransactorWithChainID function.
1 parent 67241db commit 94d2520

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

tools/generators/ethlike/contract.go.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func New{{.Class}}(
6161
// FIXME bumps beyond 1.9.25.
6262
key := accountKey.PrivateKey
6363
keyAddress := crypto.PubkeyToAddress(key.PublicKey)
64+
if chainId == nil {
65+
return nil, fmt.Errorf("no chain id specified")
66+
}
6467
transactorOptions := &bind.TransactOpts{
6568
From: keyAddress,
6669
Signer: func(_ types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {

tools/generators/ethlike/contract_template_content.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ func New{{.Class}}(
6464
// FIXME bumps beyond 1.9.25.
6565
key := accountKey.PrivateKey
6666
keyAddress := crypto.PubkeyToAddress(key.PublicKey)
67+
if chainId == nil {
68+
return nil, fmt.Errorf("no chain id specified")
69+
}
6770
transactorOptions := &bind.TransactOpts{
6871
From: keyAddress,
6972
Signer: func(_ types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {

0 commit comments

Comments
 (0)