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

[BUG] Results with Errors #11

Closed
munanadi opened this issue Jun 13, 2023 · 3 comments
Closed

[BUG] Results with Errors #11

munanadi opened this issue Jun 13, 2023 · 3 comments

Comments

@munanadi
Copy link

munanadi commented Jun 13, 2023

I tried to use the @bonfida/spl-name-service package and tried running the example given in here

const connection = new Connection(clusterApiUrl("mainnet-beta"));
const owner = await resolve(connection, "bonfida");
expect(owner.toBase58()).toBe("HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA");

This runs but there is a error logged in the console as shown below

node index.js
Error: Invalid name account provided
    at G.retrieve (/Users/aadhi/Documents/github/bonfida-trial/node_modules/@bonfida/spl-name-service/dist/index.cjs:1:9672)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ue (/Users/aadhi/Documents/github/bonfida-trial/node_modules/@bonfida/spl-name-service/dist/index.cjs:1:15017)
    at async pe (/Users/aadhi/Documents/github/bonfida-trial/node_modules/@bonfida/spl-name-service/dist/index.cjs:1:15166)
    at async exports.resolve (/Users/aadhi/Documents/github/bonfida-trial/node_modules/@bonfida/spl-name-service/dist/index.cjs:1:23924)
    at async main (/Users/aadhi/Documents/github/bonfida-trial/index.js:11:17)
{
  owner: PublicKey [PublicKey(HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA)] {
    _bn: <BN: f26cb7227020209c2da674948f8f3c330ee4f9a386256bd14f37a6e0c567542b>
  }
} HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA

Looks like this is thrown from here

sns-sdk/js/src/utils.ts

Lines 151 to 161 in e0f96e2

export const getDomainKeySync = (domain: string, record = false) => {
if (domain.endsWith(".sol")) {
domain = domain.slice(0, -4);
}
const splitted = domain.split(".");
if (splitted.length === 2) {
const prefix = Buffer.from([record ? 1 : 0]).toString();
const sub = prefix.concat(splitted[0]);
const { pubkey: parentKey } = _deriveSync(splitted[1]);
const result = _deriveSync(sub, parentKey);
return { ...result, isSub: true, parent: parentKey };

Specifically the line

const result = _deriveSync(sub, parentKey);

produces a pubkey that doesn't exists.

sub however is \x01SOL which indeed matches with what is given in this guide

What could be causing the problem here? Can you please help me out?

@dr497
Copy link
Contributor

dr497 commented Jun 14, 2023

Hi @munanadi! Thanks for opening this issue.

As far as I understand no error is being thrown by resolve with this example, it's simply logged. As you have rightly pointed out, the resolution of a domain involves checking if the SOL record exists or not. In the case of bonfida.sol, it does not exist and this information is logged on this line which produces the output you have put above.

I agree that it might be confusing to log the error this way and we should probably replace the information that is logged to make things clearer.

@munanadi
Copy link
Author

@dr497 but the error is thrown from inside this

const { registry, nftOwner } = await NameRegistryState.retrieve(...

@dr497
Copy link
Contributor

dr497 commented Jun 14, 2023

You are right, NameRegistryState.retrieve throws this error but it's caught by resolve and logged instead of thrown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants