metaplex-foundation / metaplex

A directory of what the Metaplex Foundation works on!
https://metaplex.com
Apache License 2.0
3.31k stars 6.27k forks source link

[Bug]: Configuration Issues with End Setting Type #2095

Closed statikdev closed 2 years ago

statikdev commented 2 years ago

Which package is this bug report for?

candy machine cli

Issue description

When using the endSettingType, it is possible to incorrectly configure candy machine where minting is not live even though the configuration looks right.

Issue

The core issue is that the CLI does not check the configuration option thoroughly. This can lead to the wrong option being set in the Candy Machine and users unable to mint.

This issue was discovered before https://github.com/metaplex-foundation/metaplex-program-library/pull/417. Prior, CM would throw the 0x177b (Not Live) error. With the bot prevention logic, the CM transaction will now succeed and take 0.01 sol from the user even though it is a configuration error.

Example Transaction (devnet post bot prevention): https://solscan.io/tx/2rmmtZSVHKm8hS7qTVQyzqhyX6QUX7UUySWPK1PBxxnitCGSP7NzCcrLdCsV632V9v1qPupiaR3dv9xGbAPSDFxf?cluster=devnet Example Transaction (mainnet pre bot prevention): https://solscan.io/tx/25n8XDsAGsayoymQ1KjxhK47WMETUGSe9TiDhvraWbV38HXrPyz6Eo9TFj8AUGixiSAkZpVJxep2EC8hcz5ftoP3

Reproduction Steps:

Use the following configuration for create:

{
  "price": 1.0,
  "number": 6,
  "gatekeeper": null,
  "solTreasuryAccount": null,
  "splTokenAccount": null,
  "splToken": null,
  "goLiveDate": "15 April 2022 11:00:00 EDT",
  "endSettings": {
    "value": 3,
    "endSettingType": {
      "date": false,
      "amount": true
    }
  },
  "whitelistMintSettings": null,
  "hiddenSettings": null,
  "storage": "arweave-sol",
  "ipfsInfuraProjectId": null,
  "ipfsInfuraSecret": null,
  "awsS3Bucket": null,
  "noRetainAuthority": false,
  "noMutable": false
}

Case 1:

  1. upload new candy machine on devnet with a few assets and configuration above
  2. run show command
  3. note the endSettings configuration
End settings: 
{ endSettingType: { date: {} }, number: <BN: 3e8> }
End on 1970-01-01T00:16:40.000Z

Given that the configuration set the endSettingType.date to false and endSettingType.amount to true, it is expected that the Candy Machine configuration would return:

End settings: 
{ endSettingType: { amount: {} }, number: <BN: 3> }
End when 3 sold

Command

ts-node ./packages/cli/src/candy-machine-v2-cli.ts upload \
-e devnet \
-k ~/.config/solana/wallet.json \
-cp ./devnet.json \
-c devnet \
./assets

Relevant log output

No response

Operating system

Mac OS X

Priority this issue should have

Medium (should be fixed soon)

Check the Docs First

github-actions[bot] commented 2 years ago

This Issue has received no activity for 30 days. We will close it in 2 days, please reopen if you are still experiencing this issue.