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
b7cf41e4
Commit
b7cf41e4
authored
Jan 06, 2020
by
Sylvain Laurent
Committed by
Felix Lange
Jan 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi: fix method constant flag for solidity 6.0 (#20482)
parent
3bb6815f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
7 deletions
+64
-7
abi.go
accounts/abi/abi.go
+9
-7
bind_test.go
accounts/abi/bind/bind_test.go
+55
-0
No files found.
accounts/abi/abi.go
View file @
b7cf41e4
...
@@ -111,6 +111,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
...
@@ -111,6 +111,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
Type
string
Type
string
Name
string
Name
string
Constant
bool
Constant
bool
StateMutability
string
Anonymous
bool
Anonymous
bool
Inputs
[]
Argument
Inputs
[]
Argument
Outputs
[]
Argument
Outputs
[]
Argument
...
@@ -134,10 +135,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
...
@@ -134,10 +135,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
name
=
fmt
.
Sprintf
(
"%s%d"
,
field
.
Name
,
idx
)
name
=
fmt
.
Sprintf
(
"%s%d"
,
field
.
Name
,
idx
)
_
,
ok
=
abi
.
Methods
[
name
]
_
,
ok
=
abi
.
Methods
[
name
]
}
}
isConst
:=
field
.
Constant
||
field
.
StateMutability
==
"pure"
||
field
.
StateMutability
==
"view"
abi
.
Methods
[
name
]
=
Method
{
abi
.
Methods
[
name
]
=
Method
{
Name
:
name
,
Name
:
name
,
RawName
:
field
.
Name
,
RawName
:
field
.
Name
,
Const
:
field
.
Constan
t
,
Const
:
isCons
t
,
Inputs
:
field
.
Inputs
,
Inputs
:
field
.
Inputs
,
Outputs
:
field
.
Outputs
,
Outputs
:
field
.
Outputs
,
}
}
...
...
accounts/abi/bind/bind_test.go
View file @
b7cf41e4
...
@@ -1530,6 +1530,61 @@ var bindTests = []struct {
...
@@ -1530,6 +1530,61 @@ var bindTests = []struct {
nil
,
nil
,
[]
string
{
"ContractOne"
,
"ContractTwo"
,
"ExternalLib"
},
[]
string
{
"ContractOne"
,
"ContractTwo"
,
"ExternalLib"
},
},
},
// Test the existence of the free retrieval calls
{
`PureAndView`
,
`pragma solidity >=0.6.0;
contract PureAndView {
function PureFunc() public pure returns (uint) {
return 42;
}
function ViewFunc() public view returns (uint) {
return block.number;
}
}
`
,
[]
string
{
`608060405234801561001057600080fd5b5060b68061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806376b5686a146037578063bb38c66c146053575b600080fd5b603d606f565b6040518082815260200191505060405180910390f35b60596077565b6040518082815260200191505060405180910390f35b600043905090565b6000602a90509056fea2646970667358221220d158c2ab7fdfce366a7998ec79ab84edd43b9815630bbaede2c760ea77f29f7f64736f6c63430006000033`
},
[]
string
{
`[{"inputs": [],"name": "PureFunc","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "pure","type": "function"},{"inputs": [],"name": "ViewFunc","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"}]`
},
`
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
`
,
`
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
defer sim.Close()
// Deploy a tester contract and execute a structured call on it
_, _, pav, err := DeployPureAndView(auth, sim)
if err != nil {
t.Fatalf("Failed to deploy PureAndView contract: %v", err)
}
sim.Commit()
// This test the existence of the free retreiver call for view and pure functions
if num, err := pav.PureFunc(nil); err != nil {
t.Fatalf("Failed to call anonymous field retriever: %v", err)
} else if num.Cmp(big.NewInt(42)) != 0 {
t.Fatalf("Retrieved value mismatch: have %v, want %v", num, 42)
}
if num, err := pav.ViewFunc(nil); err != nil {
t.Fatalf("Failed to call anonymous field retriever: %v", err)
} else if num.Cmp(big.NewInt(1)) != 0 {
t.Fatalf("Retrieved value mismatch: have %v, want %v", num, 1)
}
`
,
nil
,
nil
,
nil
,
nil
,
},
}
}
// Tests that packages generated by the binder can be successfully compiled and
// Tests that packages generated by the binder can be successfully compiled and
...
...
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