Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

js/v0.17.0

Choose a tag to compare

@lorisleiva lorisleiva released this 10 Oct 09:55
· 98 commits to main since this release
a983309

What's Changed

Breaking Changes

The .run() suffix was removed from every operation call. That means you must now call operation as shown below. You can read more about this decision in PR #335.

// Before.
const { nft } = await metaplex.nfts().create({...}).run();

// After.
const { nft } = await metaplex.nfts().create({...});

All operations now accept a second object argument which is the same for all operations. It enables us to provide more generic information such as the fee payer and the commitment levels to use when querying the blockchain. PR #335 also contains information about this change.

export type OperationOptions = {
  /** The wallet that should pay for transaction fees and, potentially, rent-exempt fees to create accounts.*/
  payer?: Signer;

  /** The level of commitment desired when querying the state of the blockchain. */
  commitment?: Commitment;

  /** Options for confirming transactions as defined by the Solana web3.js library.*/
  confirmOptions?: ConfirmOptions;

  /** An optional set of programs that override the registered ones. */
  programs?: Program[];

  /** An abort signal that can be used to cancel the operation. */
  signal?: AbortSignal;
};

This means, if you were providing some of these generic parameters as part of the first argument, you will need to pass them in the second argument instead.

// Before.
const { nft } = await metaplex.nfts().create({ ..., payer: someOtherPayer }).run();

// After, locally.
const { nft } = await metaplex.nfts().create({...}, { payer: someOtherPayer });

// After, globally (default to the current identity).
metaplex.rpc().setDefaultFeePayer(someOtherPayer);
const { nft } = await metaplex.nfts().create({...});

Additionally, if you were using abort signals within the run() method before, you must now provide them within the second argument of the operation directly like so.

const abortController = new AbortController();

// Before.
const { nft } = await metaplex.nfts().create({...}).run({
  signal: abortController.signal,
});

// After.
const { nft } = await metaplex.nfts().create({...}, {
  signal: abortController.signal,
});

PDA helper methods have also been refactored to make use of Metaplex’s Program Repository which allows you to override default programs and register your own.

// Before.
const metadataAddress = findMetadataPda(mintAddress);

// After.
const metadataAddress = metaplex.nfts().pdas().metadata({
  mint: mintAddress
});

Whilst the new way is more lengthy, it ensures the computed PDAs are using the programs you registered via metaplex.programs().register(). You may even provide local overrides via the programs property like so.

// After, with local program overrides.
const metadataAddress = metaplex.nfts().pdas().metadata({
  mint: mintAddress,
  programs,
});

Last but not least, the Candy Machine V2 module has been renamed to be explicitly called CandyMachineV2 to allow the latest Candy Machine V3 iteration to become the main Candy Machine module on the SDK. Therefore, if you were using the Candy Machine V2 module before, you will need to rename your clients like this.

// Before.
const candyMachineV2 = metaplex.candyMachines().create({...}).run();

// After.
const candyMachineV2 = metaplex.candyMachinesV2().create({...});
const candyMachineV3 = metaplex.candyMachines().create({...});

New Contributors

Full Changelog: js/v0.16.1...js/v0.17.0