Replace Container ID with a Neo NS address (and remove filePath etc) #99

Open
opened 2025-12-28 18:00:09 +00:00 by sami · 0 comments
Owner

Originally created by @amlwwalker on GitHub (Dec 13, 2024).

Not related to a problem

Describe the solution you'd like

A clean URL thats human readable.

I'm thinking of something where a NNS domain and path could be provided. In such a case it is assumed its a FilePath.

currently

https://rest.fs.neo.org/v1/objects/AX64C7Xdy1gUwPL4RoFJBtkXsCFpmbj93MWHGwQPwrry/by_attribute/FilePath/A/genesis_block

but would be cool if could be something like

bitcoin-wiki.getcassette.rest.fs.neo.org/genesis_block

where bitcoin-wiki.getcassette is the NNS with .neo removed potentially for easier reading.

rest.fs.neo.org being the domain of the gateway and everything after being the FilePath

that would be super clean

If subdomain wildcards weren't possible then could be

rest.fs.neo.org/bitcoin-wiki.getcassette/genesis_block

where it is assumed the parameters after the NNS is a FilePath.

Describe alternatives you've considered

I have been doing something like

func lookupDomain(domain, network string) (string, error) {
	domain = strings.ToLower(domain)
	cli, err := rpcclient.New(context.Background(), network, rpcclient.Options{})
	if err != nil {
		fmt.Println("error creating client ", err)
		return "", err
	}
	if err := cli.Init(); err != nil {
		fmt.Println("error initing client ", err)
		return "", err
	}
	ephemeralAccount, err := wallet.NewAccount()
	if err != nil {
		fmt.Println("error creating wallet ", err)
		return "", err
	}
	emphemeralAddress, err := address.StringToUint160(ephemeralAccount.Address)
	if err != nil {
		fmt.Println("error converting wallet ", err)
	}
	signer := actor.SignerAccount{Account: ephemeralAccount, Signer: transaction.Signer{
		Account: emphemeralAddress,
		Scopes:  transaction.CalledByEntry,
	}}
	neoNameServiceContractHash := "0x50ac1c37690cc2cfc594472833cf57505d5f46de"
	scriptHash := strings.TrimPrefix(neoNameServiceContractHash, "0x")
	neoNamServiceContract, err := util.Uint160DecodeStringLE(scriptHash)
	if err != nil {
		return "", err
	}
	a, err := actor.New(cli, []actor.SignerAccount{signer})
	if err != nil {
		return "", err
	}
	fmt.Println("making call")
	var params = []any{domain, 16}
	res, err := a.Call(neoNamServiceContract, "getRecord", params...)
	if err != nil {
		return "", err
	}
	fmt.Println("call made")
	if res.State != vmstate.Halt.String() {
		return "", errors.New(res.FaultException)
	}
	if len(res.Stack) == 0 {
		return "", errors.New("seems to be no result")
	}
	stack := res.Stack
	received := stack[len(stack)-1]
	if value, ok := received.Value().([]byte); !ok {
		fmt.Println("error converting ", received.Value())
		return "", errors.New("could not convert value to string")
	} else {
		return string(value), nil
	}

to look up NNS domains but this is great just doesn't work on web yet so would be cool if the REST GW offered it.

Originally created by @amlwwalker on GitHub (Dec 13, 2024). ## Is your feature request related to a problem? Please describe. Not related to a problem ## Describe the solution you'd like A clean URL thats human readable. I'm thinking of something where a NNS domain and path could be provided. In such a case it is assumed its a FilePath. currently https://rest.fs.neo.org/v1/objects/AX64C7Xdy1gUwPL4RoFJBtkXsCFpmbj93MWHGwQPwrry/by_attribute/FilePath/A/genesis_block but would be cool if could be something like `bitcoin-wiki.getcassette.rest.fs.neo.org/genesis_block` where `bitcoin-wiki.getcassette` is the NNS with .neo removed potentially for easier reading. `rest.fs.neo.org` being the domain of the gateway and everything after being the FilePath that would be super clean If subdomain wildcards weren't possible then could be `rest.fs.neo.org/bitcoin-wiki.getcassette/genesis_block` where it is assumed the parameters after the NNS is a FilePath. ## Describe alternatives you've considered I have been doing something like ```go func lookupDomain(domain, network string) (string, error) { domain = strings.ToLower(domain) cli, err := rpcclient.New(context.Background(), network, rpcclient.Options{}) if err != nil { fmt.Println("error creating client ", err) return "", err } if err := cli.Init(); err != nil { fmt.Println("error initing client ", err) return "", err } ephemeralAccount, err := wallet.NewAccount() if err != nil { fmt.Println("error creating wallet ", err) return "", err } emphemeralAddress, err := address.StringToUint160(ephemeralAccount.Address) if err != nil { fmt.Println("error converting wallet ", err) } signer := actor.SignerAccount{Account: ephemeralAccount, Signer: transaction.Signer{ Account: emphemeralAddress, Scopes: transaction.CalledByEntry, }} neoNameServiceContractHash := "0x50ac1c37690cc2cfc594472833cf57505d5f46de" scriptHash := strings.TrimPrefix(neoNameServiceContractHash, "0x") neoNamServiceContract, err := util.Uint160DecodeStringLE(scriptHash) if err != nil { return "", err } a, err := actor.New(cli, []actor.SignerAccount{signer}) if err != nil { return "", err } fmt.Println("making call") var params = []any{domain, 16} res, err := a.Call(neoNamServiceContract, "getRecord", params...) if err != nil { return "", err } fmt.Println("call made") if res.State != vmstate.Halt.String() { return "", errors.New(res.FaultException) } if len(res.Stack) == 0 { return "", errors.New("seems to be no result") } stack := res.Stack received := stack[len(stack)-1] if value, ok := received.Value().([]byte); !ok { fmt.Println("error converting ", received.Value()) return "", errors.New("could not convert value to string") } else { return string(value), nil } ``` to look up NNS domains but this is great just doesn't work on web yet so would be cool if the REST GW offered it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-rest-gw#99
No description provided.