Allow override of sol wallet address (#431)

* Allow specifying a different sol wallet address to receive mint funds

* remove debug logging
This commit is contained in:
Richard Fisher 2021-09-19 22:46:04 +08:00 committed by GitHub
parent 68bb26d64d
commit 1bf4c7fff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 6 deletions

View File

@ -193,9 +193,10 @@ programCommand('verify_price')
programCommand('create_candy_machine')
.option('-p, --price <string>', 'Price denominated in SOL or spl-token override', '1')
.option('-t, --spl-token <string>', 'SPL token used to price NFT mint. To use SOL leave this empty.')
.option('-t, --spl-token-account <string>', 'SPL token account that receives mint payments. Only required if spl-token is specified.')
.option('-a, --spl-token-account <string>', 'SPL token account that receives mint payments. Only required if spl-token is specified.')
.option('-s, --sol-treasury-account <string>', 'SOL account that receives mint payments.')
.action(async (directory, cmd) => {
const { keypair, env, price, cacheName, splToken, splTokenAccount } = cmd.opts();
const { keypair, env, price, cacheName, splToken, splTokenAccount, solTreasuryAccount } = cmd.opts();
let parsedPrice = parsePrice(price);
const cacheContent = loadCache(cacheName, env);
@ -206,6 +207,9 @@ programCommand('create_candy_machine')
let wallet = walletKeyPair.publicKey;
const remainingAccounts = [];
if (splToken || splTokenAccount) {
if (solTreasuryAccount) {
throw new Error("If spl-token-account or spl-token is set then sol-treasury-account cannot be set")
}
if (!splToken) {
throw new Error("If spl-token-account is set, spl-token must also be set")
}
@ -239,6 +243,11 @@ programCommand('create_candy_machine')
remainingAccounts.push({ pubkey: splTokenKey, isWritable: false, isSigner: false });
}
if (solTreasuryAccount) {
const solAccountKey = new PublicKey(solTreasuryAccount);
wallet = solAccountKey;
}
const config = new PublicKey(cacheContent.program.config);
const [candyMachine, bump] = await getCandyMachineAddress(
config,