Skip to content

Commit 1b35b44

Browse files
committed
rename amount to lamports
1 parent aea6e05 commit 1b35b44

10 files changed

Lines changed: 67 additions & 55 deletions

File tree

clients/js/src/generated/instructions/createAccountWithSeed.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export type CreateAccountWithSeedInstructionData = {
7676
discriminator: number;
7777
base: Address;
7878
seed: string;
79-
amount: bigint;
79+
lamports: bigint;
8080
space: bigint;
8181
programAddress: Address;
8282
};
8383

8484
export type CreateAccountWithSeedInstructionDataArgs = {
8585
base: Address;
8686
seed: string;
87-
amount: number | bigint;
87+
lamports: number | bigint;
8888
space: number | bigint;
8989
programAddress: Address;
9090
};
@@ -95,7 +95,7 @@ export function getCreateAccountWithSeedInstructionDataEncoder(): Encoder<Create
9595
['discriminator', getU32Encoder()],
9696
['base', getAddressEncoder()],
9797
['seed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
98-
['amount', getU64Encoder()],
98+
['lamports', getU64Encoder()],
9999
['space', getU64Encoder()],
100100
['programAddress', getAddressEncoder()],
101101
]),
@@ -108,7 +108,7 @@ export function getCreateAccountWithSeedInstructionDataDecoder(): Decoder<Create
108108
['discriminator', getU32Decoder()],
109109
['base', getAddressDecoder()],
110110
['seed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
111-
['amount', getU64Decoder()],
111+
['lamports', getU64Decoder()],
112112
['space', getU64Decoder()],
113113
['programAddress', getAddressDecoder()],
114114
]);
@@ -134,7 +134,7 @@ export type CreateAccountWithSeedInput<
134134
baseAccount?: TransactionSigner<TAccountBaseAccount>;
135135
base: CreateAccountWithSeedInstructionDataArgs['base'];
136136
seed: CreateAccountWithSeedInstructionDataArgs['seed'];
137-
amount: CreateAccountWithSeedInstructionDataArgs['amount'];
137+
lamports: CreateAccountWithSeedInstructionDataArgs['lamports'];
138138
space: CreateAccountWithSeedInstructionDataArgs['space'];
139139
programAddress: CreateAccountWithSeedInstructionDataArgs['programAddress'];
140140
};

clients/js/src/generated/instructions/transfer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ export type TransferInstruction<
5757
]
5858
>;
5959

60-
export type TransferInstructionData = { discriminator: number; amount: bigint };
60+
export type TransferInstructionData = { discriminator: number; lamports: bigint };
6161

62-
export type TransferInstructionDataArgs = { amount: number | bigint };
62+
export type TransferInstructionDataArgs = { lamports: number | bigint };
6363

6464
export function getTransferInstructionDataEncoder(): FixedSizeEncoder<TransferInstructionDataArgs> {
6565
return transformEncoder(
6666
getStructEncoder([
6767
['discriminator', getU32Encoder()],
68-
['amount', getU64Encoder()],
68+
['lamports', getU64Encoder()],
6969
]),
7070
value => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR }),
7171
);
@@ -74,7 +74,7 @@ export function getTransferInstructionDataEncoder(): FixedSizeEncoder<TransferIn
7474
export function getTransferInstructionDataDecoder(): FixedSizeDecoder<TransferInstructionData> {
7575
return getStructDecoder([
7676
['discriminator', getU32Decoder()],
77-
['amount', getU64Decoder()],
77+
['lamports', getU64Decoder()],
7878
]);
7979
}
8080

@@ -88,7 +88,7 @@ export function getTransferInstructionDataCodec(): FixedSizeCodec<
8888
export type TransferInput<TAccountSource extends string = string, TAccountDestination extends string = string> = {
8989
source: TransactionSigner<TAccountSource>;
9090
destination: Address<TAccountDestination>;
91-
amount: TransferInstructionDataArgs['amount'];
91+
lamports: TransferInstructionDataArgs['lamports'];
9292
};
9393

9494
export function getTransferInstruction<

clients/js/src/generated/instructions/transferWithSeed.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ export type TransferWithSeedInstruction<
6767

6868
export type TransferWithSeedInstructionData = {
6969
discriminator: number;
70-
amount: bigint;
70+
lamports: bigint;
7171
fromSeed: string;
7272
fromOwner: Address;
7373
};
7474

75-
export type TransferWithSeedInstructionDataArgs = { amount: number | bigint; fromSeed: string; fromOwner: Address };
75+
export type TransferWithSeedInstructionDataArgs = { lamports: number | bigint; fromSeed: string; fromOwner: Address };
7676

7777
export function getTransferWithSeedInstructionDataEncoder(): Encoder<TransferWithSeedInstructionDataArgs> {
7878
return transformEncoder(
7979
getStructEncoder([
8080
['discriminator', getU32Encoder()],
81-
['amount', getU64Encoder()],
81+
['lamports', getU64Encoder()],
8282
['fromSeed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
8383
['fromOwner', getAddressEncoder()],
8484
]),
@@ -89,7 +89,7 @@ export function getTransferWithSeedInstructionDataEncoder(): Encoder<TransferWit
8989
export function getTransferWithSeedInstructionDataDecoder(): Decoder<TransferWithSeedInstructionData> {
9090
return getStructDecoder([
9191
['discriminator', getU32Decoder()],
92-
['amount', getU64Decoder()],
92+
['lamports', getU64Decoder()],
9393
['fromSeed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
9494
['fromOwner', getAddressDecoder()],
9595
]);
@@ -110,7 +110,7 @@ export type TransferWithSeedInput<
110110
source: Address<TAccountSource>;
111111
baseAccount: TransactionSigner<TAccountBaseAccount>;
112112
destination: Address<TAccountDestination>;
113-
amount: TransferWithSeedInstructionDataArgs['amount'];
113+
lamports: TransferWithSeedInstructionDataArgs['lamports'];
114114
fromSeed: TransferWithSeedInstructionDataArgs['fromSeed'];
115115
fromOwner: TransferWithSeedInstructionDataArgs['fromOwner'];
116116
};

clients/js/test/createAccountWithSeed.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ it('creates a new empty account when base is not payer', async () => {
2626
base: baseAccount.address,
2727
seed,
2828
space,
29-
amount: rent,
29+
lamports: rent,
3030
programAddress: program.address,
3131
})
3232
.sendTransaction();
@@ -66,7 +66,7 @@ it('creates a new empty account when base is payer', async () => {
6666
base: client.payer.address,
6767
seed,
6868
space,
69-
amount: rent,
69+
lamports: rent,
7070
programAddress: program.address,
7171
})
7272
.sendTransaction();

clients/js/test/parseSystemInstruction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ it('parses a transfer SOL instruction', () => {
1616
const transferInstruction = getTransferInstruction({
1717
source,
1818
destination,
19-
amount: 1_000_000_000,
19+
lamports: 1_000_000_000,
2020
});
2121

2222
// When we parse this instruction.
@@ -37,7 +37,7 @@ it('parses a transfer SOL instruction', () => {
3737
},
3838
});
3939
expect(parsedInstruction.data).toStrictEqual({
40-
amount: 1_000_000_000n,
40+
lamports: 1_000_000_000n,
4141
discriminator: TRANSFER_DISCRIMINATOR,
4242
});
4343
});

clients/js/test/transfer.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ it('transfers SOL from one account to another', async () => {
1313
await client.airdrop(source.address, lamports(3_000_000_000n));
1414

1515
// When the source account transfers 1 SOL to the destination account.
16-
await client.system.instructions.transfer({ source, destination, amount: 1_000_000_000 }).sendTransaction();
16+
await client.system.instructions.transfer({ source, destination, lamports: 1_000_000_000 }).sendTransaction();
1717

1818
// Then the source account now has exactly 2 SOL.
1919
const { value: sourceBalance } = await client.rpc.getBalance(source.address, { commitment: 'confirmed' }).send();
@@ -31,7 +31,7 @@ it('parses the accounts and the data of an existing transfer SOL instruction', a
3131
const transfer = getTransferInstruction({
3232
source,
3333
destination,
34-
amount: 1_000_000_000,
34+
lamports: 1_000_000_000,
3535
});
3636

3737
// When we parse this instruction.
@@ -43,6 +43,6 @@ it('parses the accounts and the data of an existing transfer SOL instruction', a
4343
expect(parsedTransfer.accounts.source.signer).toBe(source);
4444
expect(parsedTransfer.accounts.destination.address).toBe(destination);
4545
expect(parsedTransfer.accounts.destination.role).toBe(AccountRole.WRITABLE);
46-
expect(parsedTransfer.data.amount).toBe(1_000_000_000n);
46+
expect(parsedTransfer.data.lamports).toBe(1_000_000_000n);
4747
expect(parsedTransfer.programAddress).toBe('11111111111111111111111111111111');
4848
});

clients/rust/src/generated/instructions/create_account_with_seed.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Default for CreateAccountWithSeedInstructionData {
8888
pub struct CreateAccountWithSeedInstructionArgs {
8989
pub base: Address,
9090
pub seed: U64PrefixedStr,
91-
pub amount: u64,
91+
pub lamports: u64,
9292
pub space: u64,
9393
pub program_address: Address,
9494
}
@@ -113,7 +113,7 @@ pub struct CreateAccountWithSeedBuilder {
113113
base_account: Option<solana_address::Address>,
114114
base: Option<Address>,
115115
seed: Option<U64PrefixedStr>,
116-
amount: Option<u64>,
116+
lamports: Option<u64>,
117117
space: Option<u64>,
118118
program_address: Option<Address>,
119119
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
@@ -150,8 +150,8 @@ impl CreateAccountWithSeedBuilder {
150150
self
151151
}
152152
#[inline(always)]
153-
pub fn amount(&mut self, amount: u64) -> &mut Self {
154-
self.amount = Some(amount);
153+
pub fn lamports(&mut self, lamports: u64) -> &mut Self {
154+
self.lamports = Some(lamports);
155155
self
156156
}
157157
#[inline(always)]
@@ -189,7 +189,7 @@ impl CreateAccountWithSeedBuilder {
189189
let args = CreateAccountWithSeedInstructionArgs {
190190
base: self.base.clone().expect("base is not set"),
191191
seed: self.seed.clone().expect("seed is not set"),
192-
amount: self.amount.clone().expect("amount is not set"),
192+
lamports: self.lamports.clone().expect("lamports is not set"),
193193
space: self.space.clone().expect("space is not set"),
194194
program_address: self
195195
.program_address
@@ -331,7 +331,7 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> {
331331
base_account: None,
332332
base: None,
333333
seed: None,
334-
amount: None,
334+
lamports: None,
335335
space: None,
336336
program_address: None,
337337
__remaining_accounts: Vec::new(),
@@ -371,8 +371,8 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> {
371371
self
372372
}
373373
#[inline(always)]
374-
pub fn amount(&mut self, amount: u64) -> &mut Self {
375-
self.instruction.amount = Some(amount);
374+
pub fn lamports(&mut self, lamports: u64) -> &mut Self {
375+
self.instruction.lamports = Some(lamports);
376376
self
377377
}
378378
#[inline(always)]
@@ -422,7 +422,11 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> {
422422
let args = CreateAccountWithSeedInstructionArgs {
423423
base: self.instruction.base.clone().expect("base is not set"),
424424
seed: self.instruction.seed.clone().expect("seed is not set"),
425-
amount: self.instruction.amount.clone().expect("amount is not set"),
425+
lamports: self
426+
.instruction
427+
.lamports
428+
.clone()
429+
.expect("lamports is not set"),
426430
space: self.instruction.space.clone().expect("space is not set"),
427431
program_address: self
428432
.instruction
@@ -458,7 +462,7 @@ struct CreateAccountWithSeedCpiBuilderInstruction<'a, 'b> {
458462
base_account: Option<&'b solana_account_info::AccountInfo<'a>>,
459463
base: Option<Address>,
460464
seed: Option<U64PrefixedStr>,
461-
amount: Option<u64>,
465+
lamports: Option<u64>,
462466
space: Option<u64>,
463467
program_address: Option<Address>,
464468
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.

clients/rust/src/generated/instructions/transfer.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Default for TransferInstructionData {
7171

7272
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
7373
pub struct TransferInstructionArgs {
74-
pub amount: u64,
74+
pub lamports: u64,
7575
}
7676

7777
impl TransferInstructionArgs {
@@ -90,7 +90,7 @@ impl TransferInstructionArgs {
9090
pub struct TransferBuilder {
9191
source: Option<solana_address::Address>,
9292
destination: Option<solana_address::Address>,
93-
amount: Option<u64>,
93+
lamports: Option<u64>,
9494
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
9595
}
9696

@@ -109,8 +109,8 @@ impl TransferBuilder {
109109
self
110110
}
111111
#[inline(always)]
112-
pub fn amount(&mut self, amount: u64) -> &mut Self {
113-
self.amount = Some(amount);
112+
pub fn lamports(&mut self, lamports: u64) -> &mut Self {
113+
self.lamports = Some(lamports);
114114
self
115115
}
116116
/// Add an additional account to the instruction.
@@ -135,7 +135,7 @@ impl TransferBuilder {
135135
destination: self.destination.expect("destination is not set"),
136136
};
137137
let args = TransferInstructionArgs {
138-
amount: self.amount.clone().expect("amount is not set"),
138+
lamports: self.lamports.clone().expect("lamports is not set"),
139139
};
140140

141141
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
@@ -252,7 +252,7 @@ impl<'a, 'b> TransferCpiBuilder<'a, 'b> {
252252
__program: program,
253253
source: None,
254254
destination: None,
255-
amount: None,
255+
lamports: None,
256256
__remaining_accounts: Vec::new(),
257257
});
258258
Self { instruction }
@@ -271,8 +271,8 @@ impl<'a, 'b> TransferCpiBuilder<'a, 'b> {
271271
self
272272
}
273273
#[inline(always)]
274-
pub fn amount(&mut self, amount: u64) -> &mut Self {
275-
self.instruction.amount = Some(amount);
274+
pub fn lamports(&mut self, lamports: u64) -> &mut Self {
275+
self.instruction.lamports = Some(lamports);
276276
self
277277
}
278278
/// Add an additional account to the instruction.
@@ -310,7 +310,11 @@ impl<'a, 'b> TransferCpiBuilder<'a, 'b> {
310310
#[allow(clippy::vec_init_then_push)]
311311
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
312312
let args = TransferInstructionArgs {
313-
amount: self.instruction.amount.clone().expect("amount is not set"),
313+
lamports: self
314+
.instruction
315+
.lamports
316+
.clone()
317+
.expect("lamports is not set"),
314318
};
315319
let instruction = TransferCpi {
316320
__program: self.instruction.__program,
@@ -335,7 +339,7 @@ struct TransferCpiBuilderInstruction<'a, 'b> {
335339
__program: &'b solana_account_info::AccountInfo<'a>,
336340
source: Option<&'b solana_account_info::AccountInfo<'a>>,
337341
destination: Option<&'b solana_account_info::AccountInfo<'a>>,
338-
amount: Option<u64>,
342+
lamports: Option<u64>,
339343
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
340344
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
341345
}

0 commit comments

Comments
 (0)