Skip to content
Open
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
10 changes: 5 additions & 5 deletions clients/js/src/generated/instructions/createAccountWithSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ export type CreateAccountWithSeedInstructionData = {
discriminator: number;
base: Address;
seed: string;
amount: bigint;
lamports: bigint;
space: bigint;
programAddress: Address;
};

export type CreateAccountWithSeedInstructionDataArgs = {
base: Address;
seed: string;
amount: number | bigint;
lamports: number | bigint;
space: number | bigint;
programAddress: Address;
};
Expand All @@ -95,7 +95,7 @@ export function getCreateAccountWithSeedInstructionDataEncoder(): Encoder<Create
['discriminator', getU32Encoder()],
['base', getAddressEncoder()],
['seed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
['amount', getU64Encoder()],
['lamports', getU64Encoder()],
['space', getU64Encoder()],
['programAddress', getAddressEncoder()],
]),
Expand All @@ -108,7 +108,7 @@ export function getCreateAccountWithSeedInstructionDataDecoder(): Decoder<Create
['discriminator', getU32Decoder()],
['base', getAddressDecoder()],
['seed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
['amount', getU64Decoder()],
['lamports', getU64Decoder()],
['space', getU64Decoder()],
['programAddress', getAddressDecoder()],
]);
Expand All @@ -134,7 +134,7 @@ export type CreateAccountWithSeedInput<
baseAccount?: TransactionSigner<TAccountBaseAccount>;
base: CreateAccountWithSeedInstructionDataArgs['base'];
seed: CreateAccountWithSeedInstructionDataArgs['seed'];
amount: CreateAccountWithSeedInstructionDataArgs['amount'];
lamports: CreateAccountWithSeedInstructionDataArgs['lamports'];
space: CreateAccountWithSeedInstructionDataArgs['space'];
programAddress: CreateAccountWithSeedInstructionDataArgs['programAddress'];
};
Expand Down
4 changes: 2 additions & 2 deletions clients/js/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export * from './authorizeNonceAccount';
export * from './createAccount';
export * from './createAccountWithSeed';
export * from './initializeNonceAccount';
export * from './transferSol';
export * from './transferSolWithSeed';
export * from './transfer';
export * from './transferWithSeed';
export * from './upgradeNonceAccount';
export * from './withdrawNonceAccount';
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import {
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const TRANSFER_SOL_DISCRIMINATOR = 2;
export const TRANSFER_DISCRIMINATOR = 2;

export function getTransferSolDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(TRANSFER_SOL_DISCRIMINATOR);
export function getTransferDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(TRANSFER_DISCRIMINATOR);
}

export type TransferSolInstruction<
export type TransferInstruction<
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
TAccountSource extends string | AccountMeta<string> = string,
TAccountDestination extends string | AccountMeta<string> = string,
Expand All @@ -57,48 +57,48 @@ export type TransferSolInstruction<
]
>;

export type TransferSolInstructionData = { discriminator: number; amount: bigint };
export type TransferInstructionData = { discriminator: number; lamports: bigint };

export type TransferSolInstructionDataArgs = { amount: number | bigint };
export type TransferInstructionDataArgs = { lamports: number | bigint };

export function getTransferSolInstructionDataEncoder(): FixedSizeEncoder<TransferSolInstructionDataArgs> {
export function getTransferInstructionDataEncoder(): FixedSizeEncoder<TransferInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU32Encoder()],
['amount', getU64Encoder()],
['lamports', getU64Encoder()],
]),
value => ({ ...value, discriminator: TRANSFER_SOL_DISCRIMINATOR }),
value => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR }),
);
}

export function getTransferSolInstructionDataDecoder(): FixedSizeDecoder<TransferSolInstructionData> {
export function getTransferInstructionDataDecoder(): FixedSizeDecoder<TransferInstructionData> {
return getStructDecoder([
['discriminator', getU32Decoder()],
['amount', getU64Decoder()],
['lamports', getU64Decoder()],
]);
}

export function getTransferSolInstructionDataCodec(): FixedSizeCodec<
TransferSolInstructionDataArgs,
TransferSolInstructionData
export function getTransferInstructionDataCodec(): FixedSizeCodec<
TransferInstructionDataArgs,
TransferInstructionData
> {
return combineCodec(getTransferSolInstructionDataEncoder(), getTransferSolInstructionDataDecoder());
return combineCodec(getTransferInstructionDataEncoder(), getTransferInstructionDataDecoder());
}

export type TransferSolInput<TAccountSource extends string = string, TAccountDestination extends string = string> = {
export type TransferInput<TAccountSource extends string = string, TAccountDestination extends string = string> = {
source: TransactionSigner<TAccountSource>;
destination: Address<TAccountDestination>;
amount: TransferSolInstructionDataArgs['amount'];
lamports: TransferInstructionDataArgs['lamports'];
};

export function getTransferSolInstruction<
export function getTransferInstruction<
TAccountSource extends string,
TAccountDestination extends string,
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
>(
input: TransferSolInput<TAccountSource, TAccountDestination>,
input: TransferInput<TAccountSource, TAccountDestination>,
config?: { programAddress?: TProgramAddress },
): TransferSolInstruction<TProgramAddress, TAccountSource, TAccountDestination> {
): TransferInstruction<TProgramAddress, TAccountSource, TAccountDestination> {
// Program address.
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;

Expand All @@ -115,12 +115,12 @@ export function getTransferSolInstruction<
const getAccountMeta = getAccountMetaFactory(programAddress, 'omitted');
return Object.freeze({
accounts: [getAccountMeta('source', accounts.source), getAccountMeta('destination', accounts.destination)],
data: getTransferSolInstructionDataEncoder().encode(args as TransferSolInstructionDataArgs),
data: getTransferInstructionDataEncoder().encode(args as TransferInstructionDataArgs),
programAddress,
} as TransferSolInstruction<TProgramAddress, TAccountSource, TAccountDestination>);
} as TransferInstruction<TProgramAddress, TAccountSource, TAccountDestination>);
}

export type ParsedTransferSolInstruction<
export type ParsedTransferInstruction<
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
> = {
Expand All @@ -129,14 +129,14 @@ export type ParsedTransferSolInstruction<
source: TAccountMetas[0];
destination: TAccountMetas[1];
};
data: TransferSolInstructionData;
data: TransferInstructionData;
};

export function parseTransferSolInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(
export function parseTransferInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(
instruction: Instruction<TProgram> &
InstructionWithAccounts<TAccountMetas> &
InstructionWithData<ReadonlyUint8Array>,
): ParsedTransferSolInstruction<TProgram, TAccountMetas> {
): ParsedTransferInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 2) {
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
actualAccountMetas: instruction.accounts.length,
Expand All @@ -152,6 +152,6 @@ export function parseTransferSolInstruction<TProgram extends string, TAccountMet
return {
programAddress: instruction.programAddress,
accounts: { source: getNextAccount(), destination: getNextAccount() },
data: getTransferSolInstructionDataDecoder().decode(instruction.data),
data: getTransferInstructionDataDecoder().decode(instruction.data),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ import {
import { getAccountMetaFactory, type ResolvedInstructionAccount } from '@solana/kit/program-client-core';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const TRANSFER_SOL_WITH_SEED_DISCRIMINATOR = 11;
export const TRANSFER_WITH_SEED_DISCRIMINATOR = 11;

export function getTransferSolWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(TRANSFER_SOL_WITH_SEED_DISCRIMINATOR);
export function getTransferWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(TRANSFER_WITH_SEED_DISCRIMINATOR);
}

export type TransferSolWithSeedInstruction<
export type TransferWithSeedInstruction<
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
TAccountSource extends string | AccountMeta<string> = string,
TAccountBaseAccount extends string | AccountMeta<string> = string,
Expand All @@ -65,65 +65,65 @@ export type TransferSolWithSeedInstruction<
]
>;

export type TransferSolWithSeedInstructionData = {
export type TransferWithSeedInstructionData = {
discriminator: number;
amount: bigint;
lamports: bigint;
fromSeed: string;
fromOwner: Address;
};

export type TransferSolWithSeedInstructionDataArgs = { amount: number | bigint; fromSeed: string; fromOwner: Address };
export type TransferWithSeedInstructionDataArgs = { lamports: number | bigint; fromSeed: string; fromOwner: Address };

export function getTransferSolWithSeedInstructionDataEncoder(): Encoder<TransferSolWithSeedInstructionDataArgs> {
export function getTransferWithSeedInstructionDataEncoder(): Encoder<TransferWithSeedInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU32Encoder()],
['amount', getU64Encoder()],
['lamports', getU64Encoder()],
['fromSeed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
['fromOwner', getAddressEncoder()],
]),
value => ({ ...value, discriminator: TRANSFER_SOL_WITH_SEED_DISCRIMINATOR }),
value => ({ ...value, discriminator: TRANSFER_WITH_SEED_DISCRIMINATOR }),
);
}

export function getTransferSolWithSeedInstructionDataDecoder(): Decoder<TransferSolWithSeedInstructionData> {
export function getTransferWithSeedInstructionDataDecoder(): Decoder<TransferWithSeedInstructionData> {
return getStructDecoder([
['discriminator', getU32Decoder()],
['amount', getU64Decoder()],
['lamports', getU64Decoder()],
['fromSeed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
['fromOwner', getAddressDecoder()],
]);
}

export function getTransferSolWithSeedInstructionDataCodec(): Codec<
TransferSolWithSeedInstructionDataArgs,
TransferSolWithSeedInstructionData
export function getTransferWithSeedInstructionDataCodec(): Codec<
TransferWithSeedInstructionDataArgs,
TransferWithSeedInstructionData
> {
return combineCodec(getTransferSolWithSeedInstructionDataEncoder(), getTransferSolWithSeedInstructionDataDecoder());
return combineCodec(getTransferWithSeedInstructionDataEncoder(), getTransferWithSeedInstructionDataDecoder());
}

export type TransferSolWithSeedInput<
export type TransferWithSeedInput<
TAccountSource extends string = string,
TAccountBaseAccount extends string = string,
TAccountDestination extends string = string,
> = {
source: Address<TAccountSource>;
baseAccount: TransactionSigner<TAccountBaseAccount>;
destination: Address<TAccountDestination>;
amount: TransferSolWithSeedInstructionDataArgs['amount'];
fromSeed: TransferSolWithSeedInstructionDataArgs['fromSeed'];
fromOwner: TransferSolWithSeedInstructionDataArgs['fromOwner'];
lamports: TransferWithSeedInstructionDataArgs['lamports'];
fromSeed: TransferWithSeedInstructionDataArgs['fromSeed'];
fromOwner: TransferWithSeedInstructionDataArgs['fromOwner'];
};

export function getTransferSolWithSeedInstruction<
export function getTransferWithSeedInstruction<
TAccountSource extends string,
TAccountBaseAccount extends string,
TAccountDestination extends string,
TProgramAddress extends Address = typeof SYSTEM_PROGRAM_ADDRESS,
>(
input: TransferSolWithSeedInput<TAccountSource, TAccountBaseAccount, TAccountDestination>,
input: TransferWithSeedInput<TAccountSource, TAccountBaseAccount, TAccountDestination>,
config?: { programAddress?: TProgramAddress },
): TransferSolWithSeedInstruction<TProgramAddress, TAccountSource, TAccountBaseAccount, TAccountDestination> {
): TransferWithSeedInstruction<TProgramAddress, TAccountSource, TAccountBaseAccount, TAccountDestination> {
// Program address.
const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS;

Expand All @@ -145,12 +145,12 @@ export function getTransferSolWithSeedInstruction<
getAccountMeta('baseAccount', accounts.baseAccount),
getAccountMeta('destination', accounts.destination),
],
data: getTransferSolWithSeedInstructionDataEncoder().encode(args as TransferSolWithSeedInstructionDataArgs),
data: getTransferWithSeedInstructionDataEncoder().encode(args as TransferWithSeedInstructionDataArgs),
programAddress,
} as TransferSolWithSeedInstruction<TProgramAddress, TAccountSource, TAccountBaseAccount, TAccountDestination>);
} as TransferWithSeedInstruction<TProgramAddress, TAccountSource, TAccountBaseAccount, TAccountDestination>);
}

export type ParsedTransferSolWithSeedInstruction<
export type ParsedTransferWithSeedInstruction<
TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS,
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
> = {
Expand All @@ -160,17 +160,14 @@ export type ParsedTransferSolWithSeedInstruction<
baseAccount: TAccountMetas[1];
destination: TAccountMetas[2];
};
data: TransferSolWithSeedInstructionData;
data: TransferWithSeedInstructionData;
};

export function parseTransferSolWithSeedInstruction<
TProgram extends string,
TAccountMetas extends readonly AccountMeta[],
>(
export function parseTransferWithSeedInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(
instruction: Instruction<TProgram> &
InstructionWithAccounts<TAccountMetas> &
InstructionWithData<ReadonlyUint8Array>,
): ParsedTransferSolWithSeedInstruction<TProgram, TAccountMetas> {
): ParsedTransferWithSeedInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 3) {
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, {
actualAccountMetas: instruction.accounts.length,
Expand All @@ -186,6 +183,6 @@ export function parseTransferSolWithSeedInstruction<
return {
programAddress: instruction.programAddress,
accounts: { source: getNextAccount(), baseAccount: getNextAccount(), destination: getNextAccount() },
data: getTransferSolWithSeedInstructionDataDecoder().decode(instruction.data),
data: getTransferWithSeedInstructionDataDecoder().decode(instruction.data),
};
}
Loading
Loading