diff --git a/clients/js/src/generated/instructions/createAccountWithSeed.ts b/clients/js/src/generated/instructions/createAccountWithSeed.ts index 3655639..e928acc 100644 --- a/clients/js/src/generated/instructions/createAccountWithSeed.ts +++ b/clients/js/src/generated/instructions/createAccountWithSeed.ts @@ -76,7 +76,7 @@ export type CreateAccountWithSeedInstructionData = { discriminator: number; base: Address; seed: string; - amount: bigint; + lamports: bigint; space: bigint; programAddress: Address; }; @@ -84,7 +84,7 @@ export type CreateAccountWithSeedInstructionData = { export type CreateAccountWithSeedInstructionDataArgs = { base: Address; seed: string; - amount: number | bigint; + lamports: number | bigint; space: number | bigint; programAddress: Address; }; @@ -95,7 +95,7 @@ export function getCreateAccountWithSeedInstructionDataEncoder(): Encoder; base: CreateAccountWithSeedInstructionDataArgs['base']; seed: CreateAccountWithSeedInstructionDataArgs['seed']; - amount: CreateAccountWithSeedInstructionDataArgs['amount']; + lamports: CreateAccountWithSeedInstructionDataArgs['lamports']; space: CreateAccountWithSeedInstructionDataArgs['space']; programAddress: CreateAccountWithSeedInstructionDataArgs['programAddress']; }; diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 56ae69f..42996f6 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -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'; diff --git a/clients/js/src/generated/instructions/transferSol.ts b/clients/js/src/generated/instructions/transfer.ts similarity index 68% rename from clients/js/src/generated/instructions/transferSol.ts rename to clients/js/src/generated/instructions/transfer.ts index 64d76cc..2901d92 100644 --- a/clients/js/src/generated/instructions/transferSol.ts +++ b/clients/js/src/generated/instructions/transfer.ts @@ -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, TAccountDestination extends string | AccountMeta = string, @@ -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 { +export function getTransferInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', getU32Encoder()], - ['amount', getU64Encoder()], + ['lamports', getU64Encoder()], ]), - value => ({ ...value, discriminator: TRANSFER_SOL_DISCRIMINATOR }), + value => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR }), ); } -export function getTransferSolInstructionDataDecoder(): FixedSizeDecoder { +export function getTransferInstructionDataDecoder(): FixedSizeDecoder { 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 = { +export type TransferInput = { source: TransactionSigner; destination: Address; - 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, + input: TransferInput, config?: { programAddress?: TProgramAddress }, -): TransferSolInstruction { +): TransferInstruction { // Program address. const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS; @@ -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); + } as TransferInstruction); } -export type ParsedTransferSolInstruction< +export type ParsedTransferInstruction< TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { @@ -129,14 +129,14 @@ export type ParsedTransferSolInstruction< source: TAccountMetas[0]; destination: TAccountMetas[1]; }; - data: TransferSolInstructionData; + data: TransferInstructionData; }; -export function parseTransferSolInstruction( +export function parseTransferInstruction( instruction: Instruction & InstructionWithAccounts & InstructionWithData, -): ParsedTransferSolInstruction { +): ParsedTransferInstruction { if (instruction.accounts.length < 2) { throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, @@ -152,6 +152,6 @@ export function parseTransferSolInstruction = string, TAccountBaseAccount extends string | AccountMeta = string, @@ -65,44 +65,44 @@ 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 { +export function getTransferWithSeedInstructionDataEncoder(): Encoder { 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 { +export function getTransferWithSeedInstructionDataDecoder(): Decoder { 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, @@ -110,20 +110,20 @@ export type TransferSolWithSeedInput< source: Address; baseAccount: TransactionSigner; destination: Address; - 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, + input: TransferWithSeedInput, config?: { programAddress?: TProgramAddress }, -): TransferSolWithSeedInstruction { +): TransferWithSeedInstruction { // Program address. const programAddress = config?.programAddress ?? SYSTEM_PROGRAM_ADDRESS; @@ -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); + } as TransferWithSeedInstruction); } -export type ParsedTransferSolWithSeedInstruction< +export type ParsedTransferWithSeedInstruction< TProgram extends string = typeof SYSTEM_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { @@ -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( instruction: Instruction & InstructionWithAccounts & InstructionWithData, -): ParsedTransferSolWithSeedInstruction { +): ParsedTransferWithSeedInstruction { if (instruction.accounts.length < 3) { throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, @@ -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), }; } diff --git a/clients/js/src/generated/programs/system.ts b/clients/js/src/generated/programs/system.ts index c0f20ba..d6e2db2 100644 --- a/clients/js/src/generated/programs/system.ts +++ b/clients/js/src/generated/programs/system.ts @@ -42,8 +42,8 @@ import { getCreateAccountInstruction, getCreateAccountWithSeedInstruction, getInitializeNonceAccountInstruction, - getTransferSolInstruction, - getTransferSolWithSeedInstruction, + getTransferInstruction, + getTransferWithSeedInstruction, getUpgradeNonceAccountInstruction, getWithdrawNonceAccountInstruction, parseAdvanceNonceAccountInstruction, @@ -55,8 +55,8 @@ import { parseCreateAccountInstruction, parseCreateAccountWithSeedInstruction, parseInitializeNonceAccountInstruction, - parseTransferSolInstruction, - parseTransferSolWithSeedInstruction, + parseTransferInstruction, + parseTransferWithSeedInstruction, parseUpgradeNonceAccountInstruction, parseWithdrawNonceAccountInstruction, type AdvanceNonceAccountInput, @@ -77,12 +77,12 @@ import { type ParsedCreateAccountInstruction, type ParsedCreateAccountWithSeedInstruction, type ParsedInitializeNonceAccountInstruction, - type ParsedTransferSolInstruction, - type ParsedTransferSolWithSeedInstruction, + type ParsedTransferInstruction, + type ParsedTransferWithSeedInstruction, type ParsedUpgradeNonceAccountInstruction, type ParsedWithdrawNonceAccountInstruction, - type TransferSolInput, - type TransferSolWithSeedInput, + type TransferInput, + type TransferWithSeedInput, type UpgradeNonceAccountInput, type WithdrawNonceAccountInput, } from '../instructions'; @@ -96,7 +96,7 @@ export enum SystemAccount { export enum SystemInstruction { CreateAccount, Assign, - TransferSol, + Transfer, CreateAccountWithSeed, AdvanceNonceAccount, WithdrawNonceAccount, @@ -105,7 +105,7 @@ export enum SystemInstruction { Allocate, AllocateWithSeed, AssignWithSeed, - TransferSolWithSeed, + TransferWithSeed, UpgradeNonceAccount, } @@ -120,7 +120,7 @@ export function identifySystemInstruction( return SystemInstruction.Assign; } if (containsBytes(data, getU32Encoder().encode(2), 0)) { - return SystemInstruction.TransferSol; + return SystemInstruction.Transfer; } if (containsBytes(data, getU32Encoder().encode(3), 0)) { return SystemInstruction.CreateAccountWithSeed; @@ -147,7 +147,7 @@ export function identifySystemInstruction( return SystemInstruction.AssignWithSeed; } if (containsBytes(data, getU32Encoder().encode(11), 0)) { - return SystemInstruction.TransferSolWithSeed; + return SystemInstruction.TransferWithSeed; } if (containsBytes(data, getU32Encoder().encode(12), 0)) { return SystemInstruction.UpgradeNonceAccount; @@ -161,7 +161,7 @@ export function identifySystemInstruction( export type ParsedSystemInstruction = | ({ instructionType: SystemInstruction.CreateAccount } & ParsedCreateAccountInstruction) | ({ instructionType: SystemInstruction.Assign } & ParsedAssignInstruction) - | ({ instructionType: SystemInstruction.TransferSol } & ParsedTransferSolInstruction) + | ({ instructionType: SystemInstruction.Transfer } & ParsedTransferInstruction) | ({ instructionType: SystemInstruction.CreateAccountWithSeed } & ParsedCreateAccountWithSeedInstruction) | ({ instructionType: SystemInstruction.AdvanceNonceAccount } & ParsedAdvanceNonceAccountInstruction) | ({ instructionType: SystemInstruction.WithdrawNonceAccount } & ParsedWithdrawNonceAccountInstruction) @@ -172,7 +172,7 @@ export type ParsedSystemInstruction, ) => ReturnType & SelfPlanAndSendFunctions; assign: (input: AssignInput) => ReturnType & SelfPlanAndSendFunctions; - transferSol: (input: TransferSolInput) => ReturnType & SelfPlanAndSendFunctions; + transfer: (input: TransferInput) => ReturnType & SelfPlanAndSendFunctions; createAccountWithSeed: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; @@ -299,9 +299,9 @@ export type SystemPluginInstructions = { assignWithSeed: ( input: AssignWithSeedInput, ) => ReturnType & SelfPlanAndSendFunctions; - transferSolWithSeed: ( - input: TransferSolWithSeedInput, - ) => ReturnType & SelfPlanAndSendFunctions; + transferWithSeed: ( + input: TransferWithSeedInput, + ) => ReturnType & SelfPlanAndSendFunctions; upgradeNonceAccount: ( input: UpgradeNonceAccountInput, ) => ReturnType & SelfPlanAndSendFunctions; @@ -324,7 +324,7 @@ export function systemProgram() { getCreateAccountInstruction({ ...input, payer: input.payer ?? client.payer }), ), assign: input => addSelfPlanAndSendFunctions(client, getAssignInstruction(input)), - transferSol: input => addSelfPlanAndSendFunctions(client, getTransferSolInstruction(input)), + transfer: input => addSelfPlanAndSendFunctions(client, getTransferInstruction(input)), createAccountWithSeed: input => addSelfPlanAndSendFunctions( client, @@ -342,8 +342,8 @@ export function systemProgram() { allocateWithSeed: input => addSelfPlanAndSendFunctions(client, getAllocateWithSeedInstruction(input)), assignWithSeed: input => addSelfPlanAndSendFunctions(client, getAssignWithSeedInstruction(input)), - transferSolWithSeed: input => - addSelfPlanAndSendFunctions(client, getTransferSolWithSeedInstruction(input)), + transferWithSeed: input => + addSelfPlanAndSendFunctions(client, getTransferWithSeedInstruction(input)), upgradeNonceAccount: input => addSelfPlanAndSendFunctions(client, getUpgradeNonceAccountInstruction(input)), }, diff --git a/clients/js/test/createAccountWithSeed.test.ts b/clients/js/test/createAccountWithSeed.test.ts index 554df07..27e0cab 100644 --- a/clients/js/test/createAccountWithSeed.test.ts +++ b/clients/js/test/createAccountWithSeed.test.ts @@ -26,7 +26,7 @@ it('creates a new empty account when base is not payer', async () => { base: baseAccount.address, seed, space, - amount: rent, + lamports: rent, programAddress: program.address, }) .sendTransaction(); @@ -66,7 +66,7 @@ it('creates a new empty account when base is payer', async () => { base: client.payer.address, seed, space, - amount: rent, + lamports: rent, programAddress: program.address, }) .sendTransaction(); diff --git a/clients/js/test/parseSystemInstruction.test.ts b/clients/js/test/parseSystemInstruction.test.ts index 4badf25..813e77f 100644 --- a/clients/js/test/parseSystemInstruction.test.ts +++ b/clients/js/test/parseSystemInstruction.test.ts @@ -1,10 +1,10 @@ import { AccountRole, address, createNoopSigner } from '@solana/kit'; import { - getTransferSolInstruction, + getTransferInstruction, parseSystemInstruction, SYSTEM_PROGRAM_ADDRESS, SystemInstruction, - TRANSFER_SOL_DISCRIMINATOR, + TRANSFER_DISCRIMINATOR, } from '../src'; import { it, expect } from 'vitest'; @@ -13,17 +13,17 @@ it('parses a transfer SOL instruction', () => { const destination = address('HgnzqSaAXxcw3acG33VRMMjsuDSCVr6oT56iyY9BWmzH'); // Given an instruction that transfers SOL from one account to another. - const transferSolInstruction = getTransferSolInstruction({ + const transferInstruction = getTransferInstruction({ source, destination, - amount: 1_000_000_000, + lamports: 1_000_000_000, }); // When we parse this instruction. - const parsedInstruction = parseSystemInstruction(transferSolInstruction); + const parsedInstruction = parseSystemInstruction(transferInstruction); // Then we expect it to be a transfer SOL instruction with the correct accounts and data. - expect(parsedInstruction.instructionType).toStrictEqual(SystemInstruction.TransferSol); + expect(parsedInstruction.instructionType).toStrictEqual(SystemInstruction.Transfer); expect(parsedInstruction.programAddress).toBe(SYSTEM_PROGRAM_ADDRESS); expect(parsedInstruction.accounts).toStrictEqual({ source: { @@ -37,7 +37,7 @@ it('parses a transfer SOL instruction', () => { }, }); expect(parsedInstruction.data).toStrictEqual({ - amount: 1_000_000_000n, - discriminator: TRANSFER_SOL_DISCRIMINATOR, + lamports: 1_000_000_000n, + discriminator: TRANSFER_DISCRIMINATOR, }); }); diff --git a/clients/js/test/transferSol.test.ts b/clients/js/test/transfer.test.ts similarity index 63% rename from clients/js/test/transferSol.test.ts rename to clients/js/test/transfer.test.ts index d390515..634abe7 100644 --- a/clients/js/test/transferSol.test.ts +++ b/clients/js/test/transfer.test.ts @@ -1,6 +1,6 @@ import { AccountRole, generateKeyPairSigner, lamports } from '@solana/kit'; import { expect, it } from 'vitest'; -import { getTransferSolInstruction, parseTransferSolInstruction } from '../src'; +import { getTransferInstruction, parseTransferInstruction } from '../src'; import { createTestClient } from './_setup'; it('transfers SOL from one account to another', async () => { @@ -13,7 +13,7 @@ it('transfers SOL from one account to another', async () => { await client.airdrop(source.address, lamports(3_000_000_000n)); // When the source account transfers 1 SOL to the destination account. - await client.system.instructions.transferSol({ source, destination, amount: 1_000_000_000 }).sendTransaction(); + await client.system.instructions.transfer({ source, destination, lamports: 1_000_000_000 }).sendTransaction(); // Then the source account now has exactly 2 SOL. const { value: sourceBalance } = await client.rpc.getBalance(source.address, { commitment: 'confirmed' }).send(); @@ -28,21 +28,21 @@ it('parses the accounts and the data of an existing transfer SOL instruction', a // Given a transfer SOL instruction with the following accounts and data. const source = await generateKeyPairSigner(); const destination = (await generateKeyPairSigner()).address; - const transferSol = getTransferSolInstruction({ + const transfer = getTransferInstruction({ source, destination, - amount: 1_000_000_000, + lamports: 1_000_000_000, }); // When we parse this instruction. - const parsedTransferSol = parseTransferSolInstruction(transferSol); + const parsedTransfer = parseTransferInstruction(transfer); // Then we expect the following accounts and data. - expect(parsedTransferSol.accounts.source.address).toBe(source.address); - expect(parsedTransferSol.accounts.source.role).toBe(AccountRole.WRITABLE_SIGNER); - expect(parsedTransferSol.accounts.source.signer).toBe(source); - expect(parsedTransferSol.accounts.destination.address).toBe(destination); - expect(parsedTransferSol.accounts.destination.role).toBe(AccountRole.WRITABLE); - expect(parsedTransferSol.data.amount).toBe(1_000_000_000n); - expect(parsedTransferSol.programAddress).toBe('11111111111111111111111111111111'); + expect(parsedTransfer.accounts.source.address).toBe(source.address); + expect(parsedTransfer.accounts.source.role).toBe(AccountRole.WRITABLE_SIGNER); + expect(parsedTransfer.accounts.source.signer).toBe(source); + expect(parsedTransfer.accounts.destination.address).toBe(destination); + expect(parsedTransfer.accounts.destination.role).toBe(AccountRole.WRITABLE); + expect(parsedTransfer.data.lamports).toBe(1_000_000_000n); + expect(parsedTransfer.programAddress).toBe('11111111111111111111111111111111'); }); diff --git a/clients/rust/src/generated/instructions/create_account_with_seed.rs b/clients/rust/src/generated/instructions/create_account_with_seed.rs index 0d9155e..dc70748 100644 --- a/clients/rust/src/generated/instructions/create_account_with_seed.rs +++ b/clients/rust/src/generated/instructions/create_account_with_seed.rs @@ -88,7 +88,7 @@ impl Default for CreateAccountWithSeedInstructionData { pub struct CreateAccountWithSeedInstructionArgs { pub base: Address, pub seed: U64PrefixedStr, - pub amount: u64, + pub lamports: u64, pub space: u64, pub program_address: Address, } @@ -113,7 +113,7 @@ pub struct CreateAccountWithSeedBuilder { base_account: Option, base: Option
, seed: Option, - amount: Option, + lamports: Option, space: Option, program_address: Option
, __remaining_accounts: Vec, @@ -150,8 +150,8 @@ impl CreateAccountWithSeedBuilder { self } #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } #[inline(always)] @@ -189,7 +189,7 @@ impl CreateAccountWithSeedBuilder { let args = CreateAccountWithSeedInstructionArgs { base: self.base.clone().expect("base is not set"), seed: self.seed.clone().expect("seed is not set"), - amount: self.amount.clone().expect("amount is not set"), + lamports: self.lamports.clone().expect("lamports is not set"), space: self.space.clone().expect("space is not set"), program_address: self .program_address @@ -331,7 +331,7 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { base_account: None, base: None, seed: None, - amount: None, + lamports: None, space: None, program_address: None, __remaining_accounts: Vec::new(), @@ -371,8 +371,8 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } #[inline(always)] @@ -422,7 +422,11 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { let args = CreateAccountWithSeedInstructionArgs { base: self.instruction.base.clone().expect("base is not set"), seed: self.instruction.seed.clone().expect("seed is not set"), - amount: self.instruction.amount.clone().expect("amount is not set"), + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), space: self.instruction.space.clone().expect("space is not set"), program_address: self .instruction @@ -458,7 +462,7 @@ struct CreateAccountWithSeedCpiBuilderInstruction<'a, 'b> { base_account: Option<&'b solana_account_info::AccountInfo<'a>>, base: Option
, seed: Option, - amount: Option, + lamports: Option, space: Option, program_address: Option
, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 85422fd..168c64e 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -14,8 +14,8 @@ pub(crate) mod r#authorize_nonce_account; pub(crate) mod r#create_account; pub(crate) mod r#create_account_with_seed; pub(crate) mod r#initialize_nonce_account; -pub(crate) mod r#transfer_sol; -pub(crate) mod r#transfer_sol_with_seed; +pub(crate) mod r#transfer; +pub(crate) mod r#transfer_with_seed; pub(crate) mod r#upgrade_nonce_account; pub(crate) mod r#withdraw_nonce_account; @@ -28,7 +28,7 @@ pub use self::r#authorize_nonce_account::*; pub use self::r#create_account::*; pub use self::r#create_account_with_seed::*; pub use self::r#initialize_nonce_account::*; -pub use self::r#transfer_sol::*; -pub use self::r#transfer_sol_with_seed::*; +pub use self::r#transfer::*; +pub use self::r#transfer_with_seed::*; pub use self::r#upgrade_nonce_account::*; pub use self::r#withdraw_nonce_account::*; diff --git a/clients/rust/src/generated/instructions/transfer_sol.rs b/clients/rust/src/generated/instructions/transfer.rs similarity index 82% rename from clients/rust/src/generated/instructions/transfer_sol.rs rename to clients/rust/src/generated/instructions/transfer.rs index 6403821..cbd5d6b 100644 --- a/clients/rust/src/generated/instructions/transfer_sol.rs +++ b/clients/rust/src/generated/instructions/transfer.rs @@ -8,25 +8,25 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -pub const TRANSFER_SOL_DISCRIMINATOR: u32 = 2; +pub const TRANSFER_DISCRIMINATOR: u32 = 2; /// Accounts. #[derive(Debug)] -pub struct TransferSol { +pub struct Transfer { pub source: solana_address::Address, pub destination: solana_address::Address, } -impl TransferSol { - pub fn instruction(&self, args: TransferSolInstructionArgs) -> solana_instruction::Instruction { +impl Transfer { + pub fn instruction(&self, args: TransferInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: TransferSolInstructionArgs, + args: TransferInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta], ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); @@ -36,7 +36,7 @@ impl TransferSol { false, )); accounts.extend_from_slice(remaining_accounts); - let mut data = TransferSolInstructionData::new().try_to_vec().unwrap(); + let mut data = TransferInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -49,11 +49,11 @@ impl TransferSol { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -pub struct TransferSolInstructionData { +pub struct TransferInstructionData { discriminator: u32, } -impl TransferSolInstructionData { +impl TransferInstructionData { pub fn new() -> Self { Self { discriminator: 2 } } @@ -63,38 +63,38 @@ impl TransferSolInstructionData { } } -impl Default for TransferSolInstructionData { +impl Default for TransferInstructionData { fn default() -> Self { Self::new() } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -pub struct TransferSolInstructionArgs { - pub amount: u64, +pub struct TransferInstructionArgs { + pub lamports: u64, } -impl TransferSolInstructionArgs { +impl TransferInstructionArgs { pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } } -/// Instruction builder for `TransferSol`. +/// Instruction builder for `Transfer`. /// /// ### Accounts: /// /// 0. `[writable, signer]` source /// 1. `[writable]` destination #[derive(Clone, Debug, Default)] -pub struct TransferSolBuilder { +pub struct TransferBuilder { source: Option, destination: Option, - amount: Option, + lamports: Option, __remaining_accounts: Vec, } -impl TransferSolBuilder { +impl TransferBuilder { pub fn new() -> Self { Self::default() } @@ -109,8 +109,8 @@ impl TransferSolBuilder { self } #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -130,27 +130,27 @@ impl TransferSolBuilder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TransferSol { + let accounts = Transfer { source: self.source.expect("source is not set"), destination: self.destination.expect("destination is not set"), }; - let args = TransferSolInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), + let args = TransferInstructionArgs { + lamports: self.lamports.clone().expect("lamports is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } -/// `transfer_sol` CPI accounts. -pub struct TransferSolCpiAccounts<'a, 'b> { +/// `transfer` CPI accounts. +pub struct TransferCpiAccounts<'a, 'b> { pub source: &'b solana_account_info::AccountInfo<'a>, pub destination: &'b solana_account_info::AccountInfo<'a>, } -/// `transfer_sol` CPI instruction. -pub struct TransferSolCpi<'a, 'b> { +/// `transfer` CPI instruction. +pub struct TransferCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_account_info::AccountInfo<'a>, @@ -158,14 +158,14 @@ pub struct TransferSolCpi<'a, 'b> { pub destination: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. - pub __args: TransferSolInstructionArgs, + pub __args: TransferInstructionArgs, } -impl<'a, 'b> TransferSolCpi<'a, 'b> { +impl<'a, 'b> TransferCpi<'a, 'b> { pub fn new( program: &'b solana_account_info::AccountInfo<'a>, - accounts: TransferSolCpiAccounts<'a, 'b>, - args: TransferSolInstructionArgs, + accounts: TransferCpiAccounts<'a, 'b>, + args: TransferInstructionArgs, ) -> Self { Self { __program: program, @@ -210,7 +210,7 @@ impl<'a, 'b> TransferSolCpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = TransferSolInstructionData::new().try_to_vec().unwrap(); + let mut data = TransferInstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -235,24 +235,24 @@ impl<'a, 'b> TransferSolCpi<'a, 'b> { } } -/// Instruction builder for `TransferSol` via CPI. +/// Instruction builder for `Transfer` via CPI. /// /// ### Accounts: /// /// 0. `[writable, signer]` source /// 1. `[writable]` destination #[derive(Clone, Debug)] -pub struct TransferSolCpiBuilder<'a, 'b> { - instruction: Box>, +pub struct TransferCpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { +impl<'a, 'b> TransferCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TransferSolCpiBuilderInstruction { + let instruction = Box::new(TransferCpiBuilderInstruction { __program: program, source: None, destination: None, - amount: None, + lamports: None, __remaining_accounts: Vec::new(), }); Self { instruction } @@ -271,8 +271,8 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } /// Add an additional account to the instruction. @@ -309,10 +309,14 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = TransferSolInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), + let args = TransferInstructionArgs { + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), }; - let instruction = TransferSolCpi { + let instruction = TransferCpi { __program: self.instruction.__program, source: self.instruction.source.expect("source is not set"), @@ -331,11 +335,11 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { } #[derive(Clone, Debug)] -struct TransferSolCpiBuilderInstruction<'a, 'b> { +struct TransferCpiBuilderInstruction<'a, 'b> { __program: &'b solana_account_info::AccountInfo<'a>, source: Option<&'b solana_account_info::AccountInfo<'a>>, destination: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, + lamports: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/transfer_sol_with_seed.rs b/clients/rust/src/generated/instructions/transfer_with_seed.rs similarity index 84% rename from clients/rust/src/generated/instructions/transfer_sol_with_seed.rs rename to clients/rust/src/generated/instructions/transfer_with_seed.rs index 9e9cbc5..f0bcf5e 100644 --- a/clients/rust/src/generated/instructions/transfer_sol_with_seed.rs +++ b/clients/rust/src/generated/instructions/transfer_with_seed.rs @@ -10,11 +10,11 @@ use borsh::BorshSerialize; use solana_address::Address; use spl_collections::U64PrefixedStr; -pub const TRANSFER_SOL_WITH_SEED_DISCRIMINATOR: u32 = 11; +pub const TRANSFER_WITH_SEED_DISCRIMINATOR: u32 = 11; /// Accounts. #[derive(Debug)] -pub struct TransferSolWithSeed { +pub struct TransferWithSeed { pub source: solana_address::Address, pub base_account: solana_address::Address, @@ -22,10 +22,10 @@ pub struct TransferSolWithSeed { pub destination: solana_address::Address, } -impl TransferSolWithSeed { +impl TransferWithSeed { pub fn instruction( &self, - args: TransferSolWithSeedInstructionArgs, + args: TransferWithSeedInstructionArgs, ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } @@ -33,7 +33,7 @@ impl TransferSolWithSeed { #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - args: TransferSolWithSeedInstructionArgs, + args: TransferWithSeedInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta], ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); @@ -47,9 +47,7 @@ impl TransferSolWithSeed { false, )); accounts.extend_from_slice(remaining_accounts); - let mut data = TransferSolWithSeedInstructionData::new() - .try_to_vec() - .unwrap(); + let mut data = TransferWithSeedInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -62,11 +60,11 @@ impl TransferSolWithSeed { } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -pub struct TransferSolWithSeedInstructionData { +pub struct TransferWithSeedInstructionData { discriminator: u32, } -impl TransferSolWithSeedInstructionData { +impl TransferWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 11 } } @@ -76,26 +74,26 @@ impl TransferSolWithSeedInstructionData { } } -impl Default for TransferSolWithSeedInstructionData { +impl Default for TransferWithSeedInstructionData { fn default() -> Self { Self::new() } } #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] -pub struct TransferSolWithSeedInstructionArgs { - pub amount: u64, +pub struct TransferWithSeedInstructionArgs { + pub lamports: u64, pub from_seed: U64PrefixedStr, pub from_owner: Address, } -impl TransferSolWithSeedInstructionArgs { +impl TransferWithSeedInstructionArgs { pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { borsh::to_vec(self) } } -/// Instruction builder for `TransferSolWithSeed`. +/// Instruction builder for `TransferWithSeed`. /// /// ### Accounts: /// @@ -103,17 +101,17 @@ impl TransferSolWithSeedInstructionArgs { /// 1. `[signer]` base_account /// 2. `[writable]` destination #[derive(Clone, Debug, Default)] -pub struct TransferSolWithSeedBuilder { +pub struct TransferWithSeedBuilder { source: Option, base_account: Option, destination: Option, - amount: Option, + lamports: Option, from_seed: Option, from_owner: Option
, __remaining_accounts: Vec, } -impl TransferSolWithSeedBuilder { +impl TransferWithSeedBuilder { pub fn new() -> Self { Self::default() } @@ -133,8 +131,8 @@ impl TransferSolWithSeedBuilder { self } #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.amount = Some(amount); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.lamports = Some(lamports); self } #[inline(always)] @@ -164,13 +162,13 @@ impl TransferSolWithSeedBuilder { } #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_instruction::Instruction { - let accounts = TransferSolWithSeed { + let accounts = TransferWithSeed { source: self.source.expect("source is not set"), base_account: self.base_account.expect("base_account is not set"), destination: self.destination.expect("destination is not set"), }; - let args = TransferSolWithSeedInstructionArgs { - amount: self.amount.clone().expect("amount is not set"), + let args = TransferWithSeedInstructionArgs { + lamports: self.lamports.clone().expect("lamports is not set"), from_seed: self.from_seed.clone().expect("from_seed is not set"), from_owner: self.from_owner.clone().expect("from_owner is not set"), }; @@ -179,8 +177,8 @@ impl TransferSolWithSeedBuilder { } } -/// `transfer_sol_with_seed` CPI accounts. -pub struct TransferSolWithSeedCpiAccounts<'a, 'b> { +/// `transfer_with_seed` CPI accounts. +pub struct TransferWithSeedCpiAccounts<'a, 'b> { pub source: &'b solana_account_info::AccountInfo<'a>, pub base_account: &'b solana_account_info::AccountInfo<'a>, @@ -188,8 +186,8 @@ pub struct TransferSolWithSeedCpiAccounts<'a, 'b> { pub destination: &'b solana_account_info::AccountInfo<'a>, } -/// `transfer_sol_with_seed` CPI instruction. -pub struct TransferSolWithSeedCpi<'a, 'b> { +/// `transfer_with_seed` CPI instruction. +pub struct TransferWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_account_info::AccountInfo<'a>, @@ -199,14 +197,14 @@ pub struct TransferSolWithSeedCpi<'a, 'b> { pub destination: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. - pub __args: TransferSolWithSeedInstructionArgs, + pub __args: TransferWithSeedInstructionArgs, } -impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { +impl<'a, 'b> TransferWithSeedCpi<'a, 'b> { pub fn new( program: &'b solana_account_info::AccountInfo<'a>, - accounts: TransferSolWithSeedCpiAccounts<'a, 'b>, - args: TransferSolWithSeedInstructionArgs, + accounts: TransferWithSeedCpiAccounts<'a, 'b>, + args: TransferWithSeedInstructionArgs, ) -> Self { Self { __program: program, @@ -259,9 +257,7 @@ impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { is_writable: remaining_account.2, }) }); - let mut data = TransferSolWithSeedInstructionData::new() - .try_to_vec() - .unwrap(); + let mut data = TransferWithSeedInstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -287,7 +283,7 @@ impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { } } -/// Instruction builder for `TransferSolWithSeed` via CPI. +/// Instruction builder for `TransferWithSeed` via CPI. /// /// ### Accounts: /// @@ -295,18 +291,18 @@ impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { /// 1. `[signer]` base_account /// 2. `[writable]` destination #[derive(Clone, Debug)] -pub struct TransferSolWithSeedCpiBuilder<'a, 'b> { - instruction: Box>, +pub struct TransferWithSeedCpiBuilder<'a, 'b> { + instruction: Box>, } -impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { +impl<'a, 'b> TransferWithSeedCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { - let instruction = Box::new(TransferSolWithSeedCpiBuilderInstruction { + let instruction = Box::new(TransferWithSeedCpiBuilderInstruction { __program: program, source: None, base_account: None, destination: None, - amount: None, + lamports: None, from_seed: None, from_owner: None, __remaining_accounts: Vec::new(), @@ -335,8 +331,8 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn amount(&mut self, amount: u64) -> &mut Self { - self.instruction.amount = Some(amount); + pub fn lamports(&mut self, lamports: u64) -> &mut Self { + self.instruction.lamports = Some(lamports); self } #[inline(always)] @@ -383,8 +379,12 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { - let args = TransferSolWithSeedInstructionArgs { - amount: self.instruction.amount.clone().expect("amount is not set"), + let args = TransferWithSeedInstructionArgs { + lamports: self + .instruction + .lamports + .clone() + .expect("lamports is not set"), from_seed: self .instruction .from_seed @@ -396,7 +396,7 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { .clone() .expect("from_owner is not set"), }; - let instruction = TransferSolWithSeedCpi { + let instruction = TransferWithSeedCpi { __program: self.instruction.__program, source: self.instruction.source.expect("source is not set"), @@ -420,12 +420,12 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { } #[derive(Clone, Debug)] -struct TransferSolWithSeedCpiBuilderInstruction<'a, 'b> { +struct TransferWithSeedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_account_info::AccountInfo<'a>, source: Option<&'b solana_account_info::AccountInfo<'a>>, base_account: Option<&'b solana_account_info::AccountInfo<'a>>, destination: Option<&'b solana_account_info::AccountInfo<'a>>, - amount: Option, + lamports: Option, from_seed: Option, from_owner: Option
, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/program/idl.json b/program/idl.json index 44b5c48..27e4499 100644 --- a/program/idl.json +++ b/program/idl.json @@ -211,7 +211,7 @@ }, { "kind": "instructionArgumentNode", - "name": "amount", + "name": "lamports", "type": { "kind": "numberTypeNode", "format": "u64", @@ -227,8 +227,8 @@ "offset": 0 } ], - "name": "transferSol", - "idlName": "TransferSol", + "name": "transfer", + "idlName": "Transfer", "docs": [], "optionalAccountStrategy": "omitted" }, @@ -296,7 +296,7 @@ }, { "kind": "instructionArgumentNode", - "name": "amount", + "name": "lamports", "type": { "kind": "numberTypeNode", "format": "u64", @@ -844,7 +844,7 @@ }, { "kind": "instructionArgumentNode", - "name": "amount", + "name": "lamports", "type": { "kind": "numberTypeNode", "format": "u64", @@ -880,8 +880,8 @@ "offset": 0 } ], - "name": "transferSolWithSeed", - "idlName": "TransferSolWithSeed", + "name": "transferWithSeed", + "idlName": "TransferWithSeed", "docs": [], "optionalAccountStrategy": "omitted" },