solana-mint-ui icon indicating copy to clipboard operation
solana-mint-ui copied to clipboard

TokenGate Guard disconnects Guard ID

Open S4tyras opened this issue 10 months ago • 0 comments

As we try to add a TokenGate to it we get a "Account does not have correct owner" warning from the UI

creating the config.json guard in sugar seems to disconnect the guard from the candy-machine: "guards": { "default": {

  "mintLimit": {
    "id": 1,
    "limit": 1
  },
  "startDate": {
    "date": "2024-04-01 06:00:00 +0000"
  },
  "endDate": {
    "date": "2024-04-02 18:00:00 +0000"
  },
  "tokenGate": {
    "amount": 100000,
    "mint": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
  }
}

}

For now we ended up in adding the token Gate at the end and define the public key, but I am not sure if this is correct. If we only define the tokenGate in the index.tsx and not in the candy-machine config in suger, we get another error: "Public Key mismatch"

const enabledGuardsKeys =
  guards && Object.keys(guards).filter((guardKey) => guards[guardKey])

let mintArgs: Partial<DefaultGuardSetMintArgs> = {}


const tokenMintPublicKeyString = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
const tokenMint = publicKey(tokenMintPublicKeyString);

// If there are enabled guards, set the mintArgs
if (enabledGuardsKeys.length) {
  // Map enabled guards and set mintArgs automatically based on the fields defined in each guard
  enabledGuardsKeys.forEach((guardKey) => {
    const guardObject = unwrapOption(candyGuard.guards[guardKey]);
    if (!guardObject) return null;

    mintArgs = { ...mintArgs, [guardKey]: some(guardObject) };
  });
}

mintArgs.tokenGate = some({ mint: tokenMint });

S4tyras avatar Apr 01 '24 06:04 S4tyras