Issue with metaplex.nfts().lock
nash90 opened this issue · comments
Issue
metaplex.nfts().lock throws following error
Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]
Caused By: InvalidAuthorityType: Invalid authority type
Program Logs:
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]
| Program log: IX: Lock
| Program log: Invalid authority type
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 19276 of 200000 compute units
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x9e
Regenerate
const addDelegate = async (
metaplex: Metaplex,
nft: Nft,
type: DELEGATE_TYPE,
delegate: PublicKey,
owner: PublicKey,
) => {
return metaplex.nfts().delegate({
nftOrSft: nft,
delegate: {
type: type,
delegate: delegate,
owner: owner,
data: {amount: 1 },
},
});
}
const lockNft = async (
metaplex: Metaplex,
nft: Nft,
type: DELEGATE_TYPE,
delegate: Keypair | Signer,
owner: PublicKey
) => {
await metaplex.nfts().lock({
nftOrSft: nft,
authority: {
__kind: 'tokenDelegate',
type: type,
delegate: delegate,
owner: owner,
}
});
}
const metaplex = getMetaplex(adminKeypair)
const delegateType = 'UtilityV1'
const nft = await metaplex.nfts().findByMint({ mintAddress: nftPubKey });
await addDelegate(metaplex, nft, delegateType, delegatePubKey, adminPubKey)
await lockNft(metaplex, nft, delegateType, delegateKeyPair, adminPubKey)
UPDATE::
Found the Issue which was on my part. The error was because the pubKey passed in delegate was not same as the one in delegateKeyPair used to lock. It worked fine after fixing it.