Bonfida / sns-sdk

Solana Name Service SDKs monorepo
https://sns.id/
MIT License
34 stars 28 forks source link

Error: Signature verification failed #12

Closed cryptoguy55 closed 1 year ago

cryptoguy55 commented 1 year ago

I am going to make the script to transfer the domain but I have "Error: Signature verification failed" issue Please help me to fix this issue this is my current code

const { pubkey } = await getDomainKey(domain_sol); let anotherKeypair = Keypair.generate();

// Step 2
// The registry object contains all the info about the domain name
// The NFT owner is of type PublicKey | undefined
const { registry, nftOwner } = await NameRegistryState.retrieve(
  connection,
  pubkey
);
const newOwner = new PublicKey(phantomWalletDestinatiob);

const ix = await transferNameOwnership(
  connection,
  domain_sol,
  newOwner,
  wallet.publicKey,
  registry.class,
  registry.parentName
);
const tx = new Transaction();
tx.add(ix)
tx.feePayer = wallet.publicKey;
tx.recentBlockhash =(await connection.getRecentBlockhash('max')).blockhash;
// await tx.setSigners(wallet.publicKey, anotherKeypair.publicKey);
// await tx.partialSign(anotherKeypair)
console.log(tx)
const result = await sendAndConfirmTransaction (
  connection,
  tx,
  [wallet]
)
dr497 commented 1 year ago

Thanks for opening this issue. I think there is an error with the parameters you give to transferNameOwnership. Here is the definition of the function:

/**
 * Change the owner of a given name account.
 *
 * @param connection The solana connection object to the RPC node
 * @param name The name of the name account
 * @param newOwner The new owner to be set
 * @param curentNameOwner the current name Owner
 * @param nameClass The class of this name, if it exsists
 * @param nameParent The parent name of this name, if it exists
 * @param parentOwner Parent name owner
 * @returns
 */
export declare function transferNameOwnership(connection: Connection, name: string, newOwner: PublicKey, nameClass?: PublicKey, nameParent?: PublicKey, parentOwner?: PublicKey): Promise<TransactionInstruction>;

wallet.publicKey is not the nameClass of the domain

cryptoguy55 commented 1 year ago

I set the wallet.publickey as curentNameOwner I set the registry.class as nameClass

dr497 commented 1 year ago

There was an issue in the typedoc of the function, I think this is where the confusion was coming from https://github.com/Bonfida/sns-sdk/commit/86243f4aa7b33cfba81ad46a483d4fe8c81665e0. Thanks for pointing this out!

In your code it should:

const ix = await transferNameOwnership(
  connection,
  domain_sol,
  newOwner,
  registry.class,
  registry.parentName
);
cryptoguy55 commented 1 year ago

Thank you. But I have same issue yet image

dr497 commented 1 year ago

Is the domain you are trying to transfer a valid .sol domain name? Or is it a subdomain?

If it's a .sol try this:

const ix = await transferNameOwnership(
  connection,
  domain_sol,
  newOwner,
  undefined,
  ROOT_DOMAIN_ACCOUNT
);

If it's a subdomain a and wallet.publicKey owns the subdomain

const ix = await transferNameOwnership(
  connection,
  domain_sol,
  newOwner,
  undefined,
  parentKey
);

If it's a subdomain a and wallet.publicKey owns the parent but not the subdomain

const ix = await transferNameOwnership(
  connection,
  domain_sol,
  newOwner,
  undefined,
  parentKey,
  wallet.publicKey
);

The class is undefined for .sol domain so it should not be passed

cryptoguy55 commented 1 year ago

Hello. I have the issue yet. https://github.com/cryptoguy55/sns-registration/blob/master/index.js It is my code. below is issue I have now Transaction { signatures: [], feePayer: PublicKey [PublicKey(FuG7ErYz8p6xKWbHepEy9t2bNK5J1u5Qe4EJDVhAJkF1)] { _bn: }, instructions: [ TransactionInstruction { keys: [Array], programId: [PublicKey [PublicKey(namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX)]], data: } ], recentBlockhash: undefined, lastValidBlockHeight: undefined, nonceInfo: undefined, minNonceContextSlot: undefined, _message: undefined, _json: undefined } Error: Signature verification failed at Transaction.serialize (/home/centos/API-SOL/node_modules/@solana/web3.js/lib/index.cjs.js:1730:13) at Connection.sendTransaction (/home/centos/API-SOL/node_modules/@solana/web3.js/lib/index.cjs.js:9101:41) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async sendAndConfirmTransaction (/home/centos/API-SOL/node_modules/@solana/web3.js/lib/index.cjs.js:2042:21) at async transferSOLDomain (/home/centos/API-SOL/index.js:106:20) Please help me Thank you

dr497 commented 1 year ago

If you look at the definition of the transfer instruction https://github.com/Bonfida/sns-sdk/blob/main/js/src/instructions.ts#L141 the only account that must be signing in your case is the owner of the domain. According to the error its signature is missing. So there is a mismatch between the domain you are passing, its owner and the signer of the transaction

cryptoguy55 commented 1 year ago

I solved the issues. Thank you for your help