'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var web3_js = require('@solarti/web3.js');
var GpaBuilder = require('../../utils/GpaBuilder.cjs');

// TODO(thlorenz): copied from candy machine SDK
// SDK should either provide a GPA builder or expose this discriminator
const candyMachineV2Discriminator = [51, 173, 177, 113, 25, 241, 109, 189];
const AUTHORITY = candyMachineV2Discriminator.length;
const WALLET = AUTHORITY + web3_js.PublicKey.default.toBytes().byteLength;
class CandyMachineV2GpaBuilder extends GpaBuilder.GpaBuilder {
  whereDiscriminator(discrimator) {
    return this.where(0, Buffer.from(discrimator));
  }
  candyMachineAccounts() {
    return this.whereDiscriminator(candyMachineV2Discriminator);
  }

  // wallet same as solTreasury
  candyMachineAccountsForWallet(wallet) {
    return this.candyMachineAccounts().where(WALLET, wallet.toBase58());
  }
  candyMachineAccountsForAuthority(authority) {
    return this.candyMachineAccounts().where(AUTHORITY, authority.toBase58());
  }
}

exports.CandyMachineV2GpaBuilder = CandyMachineV2GpaBuilder;
//# sourceMappingURL=gpaBuilders.cjs.map
