Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions clients/js/src/cli/commands/close-buffer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, sequentialInstructionPlan } from '@solana/kit';
import { fetchMaybeBuffer, getCloseInstruction } from '../../generated';
import { Address } from '@solana/kit';
import { fetchMaybeBuffer } from '../../generated';
import { bufferArgument } from '../arguments';
import { logCommand, logErrorAndExit } from '../logs';
import { GlobalOptions } from '../options';
Expand Down Expand Up @@ -31,13 +31,11 @@ export async function doCloseBuffer(buffer: Address, _: Options, cmd: CustomComm
logErrorAndExit(`Buffer account not found: "${buffer}"`);
}

await client.planAndExecute(
sequentialInstructionPlan([
getCloseInstruction({
account: buffer,
authority: client.authority,
destination: options.recipient ?? client.payer.address,
}),
]),
await client.runOrExport(
client.programMetadata.instructions.close({
account: buffer,
authority: client.identity,
destination: options.recipient ?? client.payer.address,
}),
);
}
24 changes: 11 additions & 13 deletions clients/js/src/cli/commands/close.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, sequentialInstructionPlan } from '@solana/kit';
import { getCloseInstruction, Seed } from '../../generated';
import { Address } from '@solana/kit';
import { Seed } from '../../generated';
import { programArgument, seedArgument } from '../arguments';
import { GlobalOptions, NonCanonicalWriteOption, nonCanonicalWriteOption } from '../options';
import { CustomCommand, getClient, getPdaDetailsForWriting } from '../utils';
Expand All @@ -25,18 +25,16 @@ async function doClose(seed: Seed, program: Address, _: Options, cmd: CustomComm
metadata,
program,
seed,
authority: isCanonical ? undefined : client.authority.address,
authority: isCanonical ? undefined : client.identity.address,
});

await client.planAndExecute(
sequentialInstructionPlan([
getCloseInstruction({
account: metadata,
authority: client.authority,
program,
programData,
destination: client.payer.address,
}),
]),
await client.runOrExport(
client.programMetadata.instructions.close({
account: metadata,
authority: client.identity,
program,
programData,
destination: client.payer.address,
}),
);
}
10 changes: 4 additions & 6 deletions clients/js/src/cli/commands/create-buffer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { generateKeyPairSigner } from '@solana/kit';
import { getCreateBufferInstructionPlan } from '../../createBuffer';
import { fileArgument } from '../arguments';
import { GlobalOptions, setWriteOptions, WriteOptions } from '../options';
import { CustomCommand, getClient, getWriteInput } from '../utils';
Expand All @@ -22,14 +21,13 @@ export async function doCreateBuffer(file: string | undefined, _: Options, cmd:

logCommand(`Creating new buffer and setting authority...`, {
buffer: buffer.address,
authority: client.authority.address,
authority: client.identity.address,
});

await client.planAndExecute(
await getCreateBufferInstructionPlan(client, {
await client.runOrExport(
client.programMetadata.instructions.createBuffer({
newBuffer: buffer,
authority: client.authority,
payer: client.payer,
authority: client.identity,
sourceBuffer: writeInput.buffer,
closeSourceBuffer: writeInput.closeBuffer,
data: writeInput.buffer?.data.data ?? writeInput.data,
Expand Down
8 changes: 4 additions & 4 deletions clients/js/src/cli/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function doCreate(seed: Seed, program: Address, file: string | unde
metadata,
program,
seed,
authority: isCanonical ? undefined : client.authority.address,
authority: isCanonical ? undefined : client.identity.address,
});

const [metadataAccount, writeInput] = await Promise.all([
Expand All @@ -47,11 +47,11 @@ export async function doCreate(seed: Seed, program: Address, file: string | unde
logErrorAndExit(`Metadata account ${picocolors.bold(metadataAccount.address)} already exists.`);
}

await client.planAndExecute(
await getCreateMetadataInstructionPlan(client, {
await client.runOrExport(
getCreateMetadataInstructionPlan(client, {
...writeInput,
payer: client.payer,
authority: client.authority,
authority: client.identity,
program,
programData,
seed,
Expand Down
27 changes: 12 additions & 15 deletions clients/js/src/cli/commands/remove-authority.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Address, sequentialInstructionPlan } from '@solana/kit';
import { getSetAuthorityInstruction, Seed } from '../../generated';
import { getPdaDetails } from '../../internals';
import { Address } from '@solana/kit';
import { Seed } from '../../generated';
import { programArgument, seedArgument } from '../arguments';
import { GlobalOptions } from '../options';
import { CustomCommand, getClient } from '../utils';
import { CustomCommand, getClient, getPdaDetails } from '../utils';
import { logCommand } from '../logs';

export function setRemoveAuthorityCommand(program: CustomCommand): void {
Expand All @@ -22,7 +21,7 @@ async function doRemoveAuthority(seed: Seed, program: Address, _: Options, cmd:
const { metadata, programData } = await getPdaDetails({
rpc: client.rpc,
program,
authority: client.authority,
authority: client.identity,
seed,
});

Expand All @@ -32,15 +31,13 @@ async function doRemoveAuthority(seed: Seed, program: Address, _: Options, cmd:
seed,
});

await client.planAndExecute(
sequentialInstructionPlan([
getSetAuthorityInstruction({
account: metadata,
authority: client.authority,
newAuthority: null,
program,
programData,
}),
]),
await client.runOrExport(
client.programMetadata.instructions.setAuthority({
account: metadata,
authority: client.identity,
newAuthority: null,
program,
programData,
}),
);
}
28 changes: 13 additions & 15 deletions clients/js/src/cli/commands/set-authority.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Address, sequentialInstructionPlan } from '@solana/kit';
import { getSetAuthorityInstruction, Seed } from '../../generated';
import { getPdaDetails } from '../../internals';
import { Address } from '@solana/kit';
import { Seed } from '../../generated';
import { programArgument, seedArgument } from '../arguments';
import { logCommand } from '../logs';
import { GlobalOptions, NewAuthorityOption, newAuthorityOption } from '../options';
import { CustomCommand, getClient } from '../utils';
import { CustomCommand, getClient, getPdaDetails } from '../utils';

export function setSetAuthorityCommand(program: CustomCommand): void {
program
Expand All @@ -21,7 +20,8 @@ async function doSetAuthority(seed: Seed, program: Address, _: Options, cmd: Cus
const options = cmd.optsWithGlobals() as GlobalOptions & Options;
const client = await getClient(options);
const { metadata, programData } = await getPdaDetails({
...client,
rpc: client.rpc,
authority: client.identity,
program,
seed,
});
Expand All @@ -33,15 +33,13 @@ async function doSetAuthority(seed: Seed, program: Address, _: Options, cmd: Cus
seed,
});

await client.planAndExecute(
sequentialInstructionPlan([
getSetAuthorityInstruction({
account: metadata,
authority: client.authority,
newAuthority: options.newAuthority,
program,
programData,
}),
]),
await client.runOrExport(
client.programMetadata.instructions.setAuthority({
account: metadata,
authority: client.identity,
newAuthority: options.newAuthority,
program,
programData,
}),
);
}
17 changes: 7 additions & 10 deletions clients/js/src/cli/commands/set-buffer-authority.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Address, sequentialInstructionPlan } from '@solana/kit';
import { getSetAuthorityInstruction } from '../../generated';
import { Address } from '@solana/kit';
import { bufferArgument } from '../arguments';
import { logCommand } from '../logs';
import { GlobalOptions, NewAuthorityOption, newAuthorityOption } from '../options';
Expand All @@ -24,13 +23,11 @@ export async function doSetBufferAuthority(buffer: Address, _: Options, cmd: Cus
'new authority': options.newAuthority,
});

await client.planAndExecute(
sequentialInstructionPlan([
getSetAuthorityInstruction({
account: buffer,
authority: client.authority,
newAuthority: options.newAuthority,
}),
]),
await client.runOrExport(
client.programMetadata.instructions.setAuthority({
account: buffer,
authority: client.identity,
newAuthority: options.newAuthority,
}),
);
}
22 changes: 10 additions & 12 deletions clients/js/src/cli/commands/set-immutable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, sequentialInstructionPlan } from '@solana/kit';
import { getSetImmutableInstruction, Seed } from '../../generated';
import { Address } from '@solana/kit';
import { Seed } from '../../generated';
import { programArgument, seedArgument } from '../arguments';
import { logCommand } from '../logs';
import { GlobalOptions, NonCanonicalWriteOption, nonCanonicalWriteOption } from '../options';
Expand All @@ -25,17 +25,15 @@ async function doSetImmutable(seed: Seed, program: Address, _: Options, cmd: Cus
metadata,
program,
seed,
authority: isCanonical ? undefined : client.authority.address,
authority: isCanonical ? undefined : client.identity.address,
});

await client.planAndExecute(
sequentialInstructionPlan([
getSetImmutableInstruction({
metadata,
authority: client.authority,
program,
programData,
}),
]),
await client.runOrExport(
client.programMetadata.instructions.setImmutable({
metadata,
authority: client.identity,
program,
programData,
}),
);
}
8 changes: 3 additions & 5 deletions clients/js/src/cli/commands/update-buffer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Address } from '@solana/kit';
import { fetchMaybeBuffer } from '../../generated';
import { getUpdateBufferInstructionPlan } from '../../updateBuffer';
import { bufferArgument, fileArgument } from '../arguments';
import { logCommand, logErrorAndExit } from '../logs';
import { GlobalOptions, setWriteOptions, WriteOptions } from '../options';
Expand Down Expand Up @@ -35,11 +34,10 @@ export async function doUpdateBuffer(buffer: Address, file: string | undefined,
const newData = writeInput.buffer?.data.data ?? writeInput.data;
const sizeDifference = newData.length - currentData.length;

await client.planAndExecute(
await getUpdateBufferInstructionPlan(client, {
await client.runOrExport(
client.programMetadata.instructions.updateBuffer({
buffer,
authority: client.authority,
payer: client.payer,
authority: client.identity,
sizeDifference,
sourceBuffer: writeInput.buffer,
closeSourceBuffer: writeInput.closeBuffer,
Expand Down
8 changes: 4 additions & 4 deletions clients/js/src/cli/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function doWrite(seed: Seed, program: Address, file: string | undef
metadata,
program,
seed,
authority: isCanonical ? undefined : client.authority.address,
authority: isCanonical ? undefined : client.identity.address,
});

const [metadataAccount, writeInput] = await Promise.all([
Expand All @@ -47,11 +47,11 @@ export async function doWrite(seed: Seed, program: Address, file: string | undef
logErrorAndExit(`Metadata account ${picocolors.bold(metadataAccount.address)} does not exist.`);
}

await client.planAndExecute(
await getUpdateMetadataInstructionPlan(client, {
await client.runOrExport(
getUpdateMetadataInstructionPlan(client, {
...writeInput,
payer: client.payer,
authority: client.authority,
authority: client.identity,
program,
programData,
metadata: metadataAccount,
Expand Down
8 changes: 4 additions & 4 deletions clients/js/src/cli/commands/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ export async function doWrite(seed: Seed, program: Address, file: string | undef
metadata,
program,
seed,
authority: isCanonical ? undefined : client.authority.address,
authority: isCanonical ? undefined : client.identity.address,
});

const [metadataAccount, writeInput] = await Promise.all([
fetchMaybeMetadata(client.rpc, metadata),
getWriteInput(client, file, options),
]);

await client.planAndExecute(
await getWriteMetadataInstructionPlan(client, {
await client.runOrExport(
getWriteMetadataInstructionPlan(client, {
...writeInput,
payer: client.payer,
authority: client.authority,
authority: client.identity,
program,
programData,
seed,
Expand Down
Loading
Loading