Skip to content

Commit

Permalink
program name transform
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Aug 1, 2024
1 parent 912fab8 commit 3bdbc3d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
12 changes: 6 additions & 6 deletions clients/js/src/generated/instructions/revokePendingActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import {
type WritableAccount,
type WritableSignerAccount,
} from '@solana/web3.js';
import { SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS } from '../programs';
import { SOLANA_FEATURE_GATE_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

export type RevokePendingActivationInstruction<
TProgram extends string = typeof SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS,
TProgram extends string = typeof SOLANA_FEATURE_GATE_PROGRAM_ADDRESS,
TAccountFeature extends string | IAccountMeta<string> = string,
TAccountIncinerator extends string | IAccountMeta<string> = string,
TAccountSystemProgram extends
Expand Down Expand Up @@ -105,13 +105,13 @@ export function getRevokePendingActivationInstruction<
TAccountSystemProgram
>
): RevokePendingActivationInstruction<
typeof SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS,
typeof SOLANA_FEATURE_GATE_PROGRAM_ADDRESS,
TAccountFeature,
TAccountIncinerator,
TAccountSystemProgram
> {
// Program address.
const programAddress = SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS;
const programAddress = SOLANA_FEATURE_GATE_PROGRAM_ADDRESS;

// Original accounts.
const originalAccounts = {
Expand Down Expand Up @@ -140,7 +140,7 @@ export function getRevokePendingActivationInstruction<
programAddress,
data: getRevokePendingActivationInstructionDataEncoder().encode({}),
} as RevokePendingActivationInstruction<
typeof SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS,
typeof SOLANA_FEATURE_GATE_PROGRAM_ADDRESS,
TAccountFeature,
TAccountIncinerator,
TAccountSystemProgram
Expand All @@ -150,7 +150,7 @@ export function getRevokePendingActivationInstruction<
}

export type ParsedRevokePendingActivationInstruction<
TProgram extends string = typeof SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS,
TProgram extends string = typeof SOLANA_FEATURE_GATE_PROGRAM_ADDRESS,
TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
> = {
programAddress: Address<TProgram>;
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/programs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* @see https://github.com/kinobi-so/kinobi
*/

export * from './solanaFeatureGateProgram';
export * from './solanaFeatureGate';
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ import {
} from '@solana/web3.js';
import { type ParsedRevokePendingActivationInstruction } from '../instructions';

export const SOLANA_FEATURE_GATE_PROGRAM_PROGRAM_ADDRESS =
export const SOLANA_FEATURE_GATE_PROGRAM_ADDRESS =
'Feature111111111111111111111111111111111111' as Address<'Feature111111111111111111111111111111111111'>;

export enum SolanaFeatureGateProgramInstruction {
export enum SolanaFeatureGateInstruction {
RevokePendingActivation,
}

export function identifySolanaFeatureGateProgramInstruction(
export function identifySolanaFeatureGateInstruction(
instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array
): SolanaFeatureGateProgramInstruction {
): SolanaFeatureGateInstruction {
const data = 'data' in instruction ? instruction.data : instruction;
if (containsBytes(data, getU8Encoder().encode(0), 0)) {
return SolanaFeatureGateProgramInstruction.RevokePendingActivation;
return SolanaFeatureGateInstruction.RevokePendingActivation;
}
throw new Error(
'The provided instruction could not be identified as a solanaFeatureGateProgram instruction.'
'The provided instruction could not be identified as a solanaFeatureGate instruction.'
);
}

export type ParsedSolanaFeatureGateProgramInstruction<
export type ParsedSolanaFeatureGateInstruction<
TProgram extends string = 'Feature111111111111111111111111111111111111',
> = {
instructionType: SolanaFeatureGateProgramInstruction.RevokePendingActivation;
instructionType: SolanaFeatureGateInstruction.RevokePendingActivation;
} & ParsedRevokePendingActivationInstruction<TProgram>;
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl RevokePendingActivation {
.unwrap();

solana_program::instruction::Instruction {
program_id: crate::SOLANA_FEATURE_GATE_PROGRAM_ID,
program_id: crate::SOLANA_FEATURE_GATE_ID,
accounts,
data,
}
Expand Down Expand Up @@ -231,7 +231,7 @@ impl<'a, 'b> RevokePendingActivationCpi<'a, 'b> {
.unwrap();

let instruction = solana_program::instruction::Instruction {
program_id: crate::SOLANA_FEATURE_GATE_PROGRAM_ID,
program_id: crate::SOLANA_FEATURE_GATE_ID,
accounts,
data,
};
Expand Down
5 changes: 2 additions & 3 deletions clients/rust/src/generated/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
use solana_program::{pubkey, pubkey::Pubkey};

/// `solana_feature_gate_program` program ID.
pub const SOLANA_FEATURE_GATE_PROGRAM_ID: Pubkey =
pubkey!("Feature111111111111111111111111111111111111");
/// `solana_feature_gate` program ID.
pub const SOLANA_FEATURE_GATE_ID: Pubkey = pubkey!("Feature111111111111111111111111111111111111");
2 changes: 1 addition & 1 deletion clients/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod generated;

pub use generated::{programs::SOLANA_FEATURE_GATE_PROGRAM_ID as ID, *};
pub use generated::{programs::SOLANA_FEATURE_GATE_ID as ID, *};
7 changes: 7 additions & 0 deletions scripts/generate-clients.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { getAllProgramIdls, getToolchainArgument } from "./utils.mjs";
const [idl, ...additionalIdls] = getAllProgramIdls().map(idl => rootNodeFromAnchor(require(idl)))
const kinobi = k.createFromRoot(idl, additionalIdls);

// Update programs.
kinobi.update(
k.updateProgramsVisitor({
"solanaFeatureGateProgram": { name: "solanaFeatureGate" },
})
);

// Render JavaScript.
const jsClient = path.join(__dirname, "..", "clients", "js");
kinobi.accept(
Expand Down

0 comments on commit 3bdbc3d

Please sign in to comment.