good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b7cf41e4
Commit
b7cf41e4
authored
Jan 6, 2020
by
Sylvain Laurent
Committed by
Felix Lange
Jan 6, 2020
Browse files
Options
Downloads
Patches
Plain Diff
accounts/abi: fix method constant flag for solidity 6.0 (#20482)
parent
3bb6815f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
accounts/abi/abi.go
+9
-7
9 additions, 7 deletions
accounts/abi/abi.go
accounts/abi/bind/bind_test.go
+55
-0
55 additions, 0 deletions
accounts/abi/bind/bind_test.go
with
64 additions
and
7 deletions
accounts/abi/abi.go
+
9
−
7
View file @
b7cf41e4
...
...
@@ -111,6 +111,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
Type
string
Name
string
Constant
bool
StateMutability
string
Anonymous
bool
Inputs
[]
Argument
Outputs
[]
Argument
...
...
@@ -134,10 +135,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
name
=
fmt
.
Sprintf
(
"%s%d"
,
field
.
Name
,
idx
)
_
,
ok
=
abi
.
Methods
[
name
]
}
isConst
:=
field
.
Constant
||
field
.
StateMutability
==
"pure"
||
field
.
StateMutability
==
"view"
abi
.
Methods
[
name
]
=
Method
{
Name
:
name
,
RawName
:
field
.
Name
,
Const
:
field
.
Const
ant
,
Const
:
is
Const
,
Inputs
:
field
.
Inputs
,
Outputs
:
field
.
Outputs
,
}
...
...
This diff is collapsed.
Click to expand it.
accounts/abi/bind/bind_test.go
+
55
−
0
View file @
b7cf41e4
...
...
@@ -1530,6 +1530,61 @@ var bindTests = []struct {
nil
,
[]
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment