-
Notifications
You must be signed in to change notification settings - Fork 17
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
Simplify resolving NNS hashes via RPC binding #361
Conversation
4f5f6eb
to
8cf565f
Compare
// names (like "container" or "netmap") and extracts the hash for the | ||
// respective NNS record in any of the formats (of which historically there's | ||
// been a few). | ||
func (c *ContractReader) ResolveFSContract(name string) (util.Uint160, error) { |
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 would be perfect to have some enum for "container", "netmap" and other possible contract names.
If it already exists, the reference in the comment will be useful
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 doesn't, at least not in some common space (various utilities like adm do know about them).
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.
cant we add some constants? as a user i would be more glad not to figure names out myself
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.
OK, let's try them this way.
Refs. #348 Signed-off-by: Roman Khimov <[email protected]>
Fix #348. Signed-off-by: Roman Khimov <[email protected]>
8cf565f
to
65c4086
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.
good candidate to provide code example like
// Resolve addresses of the NeoFS smart contracts deployed in the particular
// NeoFS Sidechain by their NNS domain names.
func ExampleContractReader_ResolveFSContract() {
const sidechainRPCEndpoint = "https://rpc1.morph.fs.neo.org:40341"
c, err := rpcclient.New(context.Background(), sidechainRPCEndpoint, rpcclient.Options{})
if err != nil {
log.Fatal(err)
}
err = c.Init()
if err != nil {
log.Fatal(err)
}
nnsAddress, err := nns.InferHash(c)
if err != nil {
log.Fatal(err)
}
nnsContract := nns.NewReader(invoker.New(c, nil), nnsAddress)
for _, name := range []string{
nns.NameAudit,
nns.NameBalance,
nns.NameContainer,
nns.NameNeoFSID,
nns.NameNetmap,
nns.NameProxy,
nns.NameReputation,
} {
addr, err := nnsContract.ResolveFSContract(name)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s: %s\n", name, addr)
}
}
Signed-off-by: Roman Khimov <[email protected]>
By @cthulhu-rider, thanks. Signed-off-by: Roman Khimov <[email protected]>
65c4086
to
14a2984
Compare
No description provided.