-
Notifications
You must be signed in to change notification settings - Fork 81
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
native: implement StdLib and CryptoLib contracts #1824
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1824 +/- ##
==========================================
+ Coverage 83.42% 83.46% +0.04%
==========================================
Files 283 281 -2
Lines 22194 22271 +77
==========================================
+ Hits 18515 18589 +74
+ Misses 2549 2545 -4
- Partials 1130 1137 +7
Continue to review full report at Codecov.
|
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.
Why are last 2 commits in this PR?
pkg/core/native/std.go
Outdated
s.AddMethod(md, desc) | ||
|
||
desc = newDescriptor("jsonSerialize", smartcontract.ByteArrayType, | ||
manifest.NewParameter("data", smartcontract.AnyType)) |
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.
The name is "item"
.
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.
Fixed. I forgot about the names.
pkg/core/native/std.go
Outdated
s.AddMethod(md, desc) | ||
|
||
desc = newDescriptor("jsonDeserialize", smartcontract.AnyType, | ||
manifest.NewParameter("data", smartcontract.ByteArrayType)) |
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.
The name is "json"
.
pkg/core/native/std.go
Outdated
s.AddMethod(md, desc) | ||
|
||
desc = newDescriptor("base64Decode", smartcontract.ByteArrayType, | ||
manifest.NewParameter("data", smartcontract.StringType)) |
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.
The name is "s"
.
pkg/core/native/std.go
Outdated
s.AddMethod(md, desc) | ||
|
||
desc = newDescriptor("base58Decode", smartcontract.ByteArrayType, | ||
manifest.NewParameter("data", smartcontract.StringType)) |
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.
The name is "s"
.
pkg/core/native/std.go
Outdated
} | ||
|
||
func (s *Std) atoi(_ *interop.Context, args []stackitem.Item) stackitem.Item { | ||
numBytes, err := args[0].TryBytes() |
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.
toString(args[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.
Fixed here and in all other places.
pkg/core/native/std.go
Outdated
panic(fmt.Errorf("invalid value stackitem: %w", err)) | ||
} | ||
num := string(numBytes) | ||
base, err := args[1].TryInteger() |
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.
toBigInt(args[1])
?
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline" | ||
func Main() int { | ||
sum := 0 | ||
values := []int{10, 11} | ||
for _, v := range values { | ||
binary.Itoa(v, 10) |
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.
It needs to be replaced with another syscall returning some value (Notify
returns nothing).
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline" | ||
func Main() int { | ||
sum := 0 | ||
values := []int{10, 11} | ||
for _, v := range values { | ||
binary.Itoa(v, 10) |
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.
Same here.
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline" | ||
func Main() int { | ||
sum := 0 | ||
values := []int{10, 11} | ||
for _, v := range values { | ||
binary.Itoa(v, 10) | ||
sum += inline.VarSum(1, 2, 3, binary.Atoi("4", 10)) |
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.
Here we need some syscall which returns integer.
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.
Replaced with runtime.GetTime
.
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline" | ||
func Main() int { | ||
values := []int{10, 11, 12} | ||
for _, v := range values { | ||
binary.Itoa(v, 10) |
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.
Again, it was here because it's returned value is dropped.
623a5f5
to
2d86f5a
Compare
pkg/compiler/inline_test.go
Outdated
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline" | ||
func Main() int { | ||
sum := 0 | ||
values := []int{10, 11} | ||
for _, v := range values { | ||
binary.Itoa(v, 10) | ||
sum += inline.VarSum(1, 2, 3, 4) | ||
if v != 0 { // use 'v' |
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.
if
creates another scope. We better just use e.g. _ = v
.
2d86f5a
to
87212d6
Compare
They were in neo-modules#517 along with the changes related to this PR. Removed them. |
413dbe7
to
75c65c3
Compare
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.
Looks like native contract coverage can be improved for erroneous cases.
30e149e
to
e4ce23a
Compare
And move their tests to native StdLib.
And move their tests to native StdLib.
And move their tests to native StdLib.
And move their tests to native StdLib.
e4ce23a
to
cbce17a
Compare
Another PR for them? |
Rename it to Neo.Crypto.CheckMultisig and remove `message` parameter.
cbce17a
to
9015e50
Compare
Close #1740