Skip to content
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

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

Open
amlwwalker opened this issue Dec 13, 2024 · 0 comments
Open
Labels
feature Completely new functionality I2 Regular impact S3 Minimally significant U4 Nothing urgent

Comments

@amlwwalker
Copy link

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

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.

@amlwwalker amlwwalker added feature Completely new functionality I2 Regular impact labels Dec 13, 2024
@roman-khimov roman-khimov added U4 Nothing urgent S3 Minimally significant labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Completely new functionality I2 Regular impact S3 Minimally significant U4 Nothing urgent
Projects
None yet
Development

No branches or pull requests

2 participants