-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler: add ability to generate .abi.json file #916
Conversation
Codecov Report
@@ Coverage Diff @@
## master-2.x #916 +/- ##
==============================================
+ Coverage 67.86% 67.90% +0.04%
==============================================
Files 142 142
Lines 13433 13471 +38
==============================================
+ Hits 9116 9148 +32
- Misses 3900 3906 +6
Partials 417 417
Continue to review full report at Codecov.
|
pkg/compiler/compiler.go
Outdated
ABIInfo string | ||
|
||
// Contract metadata. | ||
ContractDetails *request.ContractDetails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move ContractDetails
out of rpc/request
to smartcontract
, importing anything RPC-related into the compiler is just weird.
pkg/compiler/debug.go
Outdated
@@ -260,3 +298,40 @@ func parsePairJSON(data []byte, sep string) (string, string, error) { | |||
} | |||
return ss[0], ss[1], nil | |||
} | |||
|
|||
func (di *DebugInfo) convertToABI(contract []byte, cd *request.ContractDetails) ABI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some test for it?
51f63fe
to
70cbb7e
Compare
Also as part of #902, for the current moment we have difference in abi.json parameters/variables type format which leads to
However, that's not critical error. |
pkg/compiler/compiler.go
Outdated
@@ -11,6 +11,8 @@ import ( | |||
"path/filepath" | |||
"strings" | |||
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line.
pkg/compiler/debug.go
Outdated
@@ -8,6 +8,11 @@ import ( | |||
"go/types" | |||
"strconv" | |||
"strings" | |||
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor corrections and please port it then to 3.0, we may change it in the future to reuse manifests or absorb some other 3.0-related changes, but still this one lays some nice basis for this work.
pkg/compiler/debug_test.go
Outdated
@@ -3,6 +3,9 @@ package compiler | |||
import ( | |||
"testing" | |||
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" | |||
"github.com/nspcc-dev/neo-go/pkg/smartcontract" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line.
pkg/compiler/debug.go
Outdated
params := make([]DebugParam, 0, ps.NumFields()) | ||
for i := range params { | ||
params := make([]DebugParam, ps.NumFields()) | ||
count := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think append()
style would still look a bit better here (not needing any count
, for example), to fix the original problem you only need to change the range iterator.
70cbb7e
to
5525cf8
Compare
Method `methodInfoFromScope(...)` always returned an empty parameters set, so we were missing this information in both .abi.json and .debug.json files. Fixed now.
A part of integration with NEO Blockchain Toolkit (see #902). To be able to deploy smart-contract compiled with neo-go compiler via NEO Express, we have to generate additional .abi.json file. This file contains the following information: - hash of the compiled contract - smart-contract metadata (title, description, version, author, email, has-storage, has-dynamic-invoke, is-payable) - smart-contract entry point - functions - events However, this .abi.json file is slightly different from the one, described in manifest.go, so we have to add auxilaury stractures for json marshalling. The .abi.json format used by NEO-Express is described [here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
5525cf8
to
99d0baf
Compare
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
email, has-storage, has-dynamic-invoke, is-payable)
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
here.