metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
355 stars 182 forks source link

Allocation guard is not registered in the SDK #506

Open sohrab- opened 1 year ago

sohrab- commented 1 year ago

There is a 20th guard, called allocation, in the on-chain program but it is not registered in the SDK.

Let's say I add a 21st custom guard, below allocation, to the on-chain program and register it with the SDK, when trying to create the Candy Machine, the SDK seems to serialise the settings for this new custom guard into the allocation guard settings, i.e. off-by-one.

sohrab- commented 1 year ago

Here is the manifest if anyone needs the work-around:

import {
  CandyGuardManifest,
  createSerializerFromBeet,
} from "@metaplex-foundation/js";
import {
  Allocation,
  allocationBeet,
} from "@metaplex-foundation/mpl-candy-guard";

export const allocationGuardManifest: CandyGuardManifest<Allocation> = {
  name: "allocation",
  settingsBytes: 5,
  settingsSerializer: createSerializerFromBeet(allocationBeet),
};

Btw this ☝️ is not enough if you are planning to use the allocation guard. That's just enough to skip it to get to our custom guards

lorisleiva commented 1 year ago

Hi there, thanks for that. Would you be able to PR this into the SDK?

sohrab- commented 1 year ago

Lemme see if I can understand what it does. The manifest is easy enough but need to know what it does to write the proper unit tests 😅