-
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
manifest: add NEP-24 #3560
base: master
Are you sure you want to change the base?
manifest: add NEP-24 #3560
Conversation
40c7142
to
3a9fdda
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3560 +/- ##
==========================================
- Coverage 85.79% 85.74% -0.05%
==========================================
Files 330 331 +1
Lines 38536 38617 +81
==========================================
+ Hits 33062 33113 +51
- Misses 3928 3943 +15
- Partials 1546 1561 +15 ☔ View full report in Codecov by Sentry. |
Close #3451 Signed-off-by: Ekaterina Pavlova <[email protected]>
3a9fdda
to
317b65d
Compare
@@ -0,0 +1,182 @@ | |||
// Package nep24 provides RPC wrappers for NEP-24 contracts, which define NFT royalties. | |||
package nep24 |
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.
manifest: add NEP-24
manifest: support NEP-24?
@@ -0,0 +1,182 @@ | |||
// Package nep24 provides RPC wrappers for NEP-24 contracts, which define NFT royalties. |
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.
Take a look at documentation of nep17
and nep11
packages. Extend documentation for nep24
in compatible way.
NFT
NEP-11
Amount *big.Int | ||
} | ||
|
||
// RoyaltiesTransferredEvent represents a RoyaltiesTransferred event as defined in the NEP-24 standard. |
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.
Line width.
// RoyaltyReader is an interface for contracts implementing NEP-24 royalties. | ||
type RoyaltyReader struct { |
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's not just an interface. Documentation should be meaningful.
neo-go/pkg/rpcclient/nep17/nep17.go
Lines 36 to 38 in 14ea5a8
// TokenReader represents safe (read-only) methods of NEP-17 token. It can be | |
// used to query various data. | |
type TokenReader struct { |
neptoken.Base | ||
Invoker nep11.Invoker |
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 should not work like this, because the base for NEP24 is either NEP11 divisible or NEP11 non-divisible. I'd suggest:
- Remove
neptoken.Base
fromRoyaltyReader
. - Replace
nep11.Invoker
withInvoker
. - Adjust RPC binding in the following way: if contract implements NEP-11, then only structures from the
nep11
package to the contract reader. If contract implements both NEP-11 and NEP-24, then include bothnep11
andnep24
structures.
return errors.New("invalid event structure: expected array of 5 items") | ||
} | ||
|
||
// Decoding RoyaltyToken |
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.
Where did you get these comments from? They are not a part of generator.
func (t *testAct) Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error) { | ||
return t.res, t.err | ||
} | ||
|
||
func (t *testAct) SendRun(script []byte) (util.Uint256, uint32, error) { | ||
return t.txh, t.vub, t.err | ||
} | ||
|
||
func (t *testAct) CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...any) (*result.Invoke, error) { | ||
return t.res, t.err | ||
} | ||
|
||
func (t *testAct) TerminateSession(sessionID uuid.UUID) error { | ||
return t.err | ||
} | ||
|
||
func (t *testAct) TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error) { | ||
return t.res.Stack, t.err | ||
} |
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.
No actor should be needed, this standard has a single method that is safe.
@@ -0,0 +1,330 @@ | |||
package nep24 |
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.
Include doc_test.go
, create example with documentation based on https://github.com/nspcc-dev/neo-go/blob/master/pkg/rpcclient/nep17/doc_test.go.
|
||
// Nep24Royalty is a NEP-24 Standard for NFT royalties. | ||
var Nep24Royalty = &Standard{ | ||
//Base: DecimalTokenBase, |
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.
Remove it.
@@ -413,6 +413,10 @@ func Generate(cfg binding.Config) error { | |||
mfst.ABI.Methods = dropStdMethods(mfst.ABI.Methods, standard.Nep11NonDivisible) | |||
ctr.IsNep11ND = true | |||
} | |||
if standard.ComplyABI(cfg.Manifest, standard.Nep24Royalty) == nil { | |||
mfst.ABI.Methods = dropStdMethods(mfst.ABI.Methods, standard.Nep24Royalty) | |||
ctr.IsNep11ND = true |
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.
ctr.IsNep11ND = true
It's not.
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.
And you need to fix RPC bindings generator. Based on ctr.IsNep24
flag RPC bindings generator must include package nep24
to the generated contract reader.
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.
And you need to adjust
func comply(m *manifest.Manifest, checkNames bool, st *Standard) error { |
- Extend
standard.Standard
structure withRequired []string
field. This field includes standards required by this standard. - In
comply()
check that standards marked as "Required" are present in the manifest. No compliance check is needed for them, the presence check is enough since compliance is checked by the calling code for all standards.
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.
Also, the test of RPC bindings generator based on the existing NEP contract is missing, we discussed it in DM.
Close #3451
wrapper generates:
but it should be different.
add tests with
smartcontact/testdata/