Skip to content

Commit

Permalink
Fix nonce args
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Dec 12, 2023
1 parent e2d436f commit 90dea2e
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 64 deletions.
20 changes: 7 additions & 13 deletions clients/js/src/generated/instructions/authorizeNonceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
Context,
ResolvedAccount,
accountMetaWithDefault,
expectAddress,
getAccountMetasWithSigners,
getProgramAddress,
} from '../shared';
Expand Down Expand Up @@ -83,18 +82,18 @@ export type AuthorizeNonceAccountInstructionWithSigners<

export type AuthorizeNonceAccountInstructionData = {
discriminator: number;
nonceAccountArg: Address;
newNonceAuthority: Address;
};

export type AuthorizeNonceAccountInstructionDataArgs = {
nonceAccountArg: Address;
newNonceAuthority: Address;
};

export function getAuthorizeNonceAccountInstructionDataEncoder() {
return mapEncoder(
getStructEncoder<{ discriminator: number; nonceAccountArg: Address }>([
getStructEncoder<{ discriminator: number; newNonceAuthority: Address }>([
['discriminator', getU32Encoder()],
['nonceAccountArg', getAddressEncoder()],
['newNonceAuthority', getAddressEncoder()],
]),
(value) => ({ ...value, discriminator: 7 })
) satisfies Encoder<AuthorizeNonceAccountInstructionDataArgs>;
Expand All @@ -103,7 +102,7 @@ export function getAuthorizeNonceAccountInstructionDataEncoder() {
export function getAuthorizeNonceAccountInstructionDataDecoder() {
return getStructDecoder<AuthorizeNonceAccountInstructionData>([
['discriminator', getU32Decoder()],
['nonceAccountArg', getAddressDecoder()],
['newNonceAuthority', getAddressDecoder()],
]) satisfies Decoder<AuthorizeNonceAccountInstructionData>;
}

Expand All @@ -123,7 +122,7 @@ export type AuthorizeNonceAccountInput<
> = {
nonceAccount: Address<TAccountNonceAccount>;
nonceAuthority: Address<TAccountNonceAuthority>;
nonceAccountArg?: AuthorizeNonceAccountInstructionDataArgs['nonceAccountArg'];
newNonceAuthority: AuthorizeNonceAccountInstructionDataArgs['newNonceAuthority'];
};

export type AuthorizeNonceAccountInputWithSigners<
Expand All @@ -132,7 +131,7 @@ export type AuthorizeNonceAccountInputWithSigners<
> = {
nonceAccount: Address<TAccountNonceAccount>;
nonceAuthority: TransactionSigner<TAccountNonceAuthority>;
nonceAccountArg?: AuthorizeNonceAccountInstructionDataArgs['nonceAccountArg'];
newNonceAuthority: AuthorizeNonceAccountInstructionDataArgs['newNonceAuthority'];
};

export function getAuthorizeNonceAccountInstruction<
Expand Down Expand Up @@ -238,11 +237,6 @@ export function getAuthorizeNonceAccountInstruction<
// Original args.
const args = { ...input };

// Resolve default values.
if (!args.nonceAccountArg) {
args.nonceAccountArg = expectAddress(accounts.nonceAccount.value);
}

// Get account metas and signers.
const accountMetas = getAccountMetasWithSigners(
accounts,
Expand Down
18 changes: 7 additions & 11 deletions clients/js/src/generated/instructions/initializeNonceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
Context,
ResolvedAccount,
accountMetaWithDefault,
expectAddress,
getAccountMetasWithSigners,
getProgramAddress,
} from '../shared';
Expand Down Expand Up @@ -97,18 +96,18 @@ export type InitializeNonceAccountInstructionWithSigners<

export type InitializeNonceAccountInstructionData = {
discriminator: number;
nonceAccountArg: Address;
nonceAuthority: Address;
};

export type InitializeNonceAccountInstructionDataArgs = {
nonceAccountArg: Address;
nonceAuthority: Address;
};

export function getInitializeNonceAccountInstructionDataEncoder() {
return mapEncoder(
getStructEncoder<{ discriminator: number; nonceAccountArg: Address }>([
getStructEncoder<{ discriminator: number; nonceAuthority: Address }>([
['discriminator', getU32Encoder()],
['nonceAccountArg', getAddressEncoder()],
['nonceAuthority', getAddressEncoder()],
]),
(value) => ({ ...value, discriminator: 6 })
) satisfies Encoder<InitializeNonceAccountInstructionDataArgs>;
Expand All @@ -117,7 +116,7 @@ export function getInitializeNonceAccountInstructionDataEncoder() {
export function getInitializeNonceAccountInstructionDataDecoder() {
return getStructDecoder<InitializeNonceAccountInstructionData>([
['discriminator', getU32Decoder()],
['nonceAccountArg', getAddressDecoder()],
['nonceAuthority', getAddressDecoder()],
]) satisfies Decoder<InitializeNonceAccountInstructionData>;
}

Expand All @@ -139,7 +138,7 @@ export type InitializeNonceAccountInput<
nonceAccount: Address<TAccountNonceAccount>;
recentBlockhashesSysvar?: Address<TAccountRecentBlockhashesSysvar>;
rentSysvar?: Address<TAccountRentSysvar>;
nonceAccountArg?: InitializeNonceAccountInstructionDataArgs['nonceAccountArg'];
nonceAuthority: InitializeNonceAccountInstructionDataArgs['nonceAuthority'];
};

export type InitializeNonceAccountInputWithSigners<
Expand All @@ -150,7 +149,7 @@ export type InitializeNonceAccountInputWithSigners<
nonceAccount: Address<TAccountNonceAccount>;
recentBlockhashesSysvar?: Address<TAccountRecentBlockhashesSysvar>;
rentSysvar?: Address<TAccountRentSysvar>;
nonceAccountArg?: InitializeNonceAccountInstructionDataArgs['nonceAccountArg'];
nonceAuthority: InitializeNonceAccountInstructionDataArgs['nonceAuthority'];
};

export function getInitializeNonceAccountInstruction<
Expand Down Expand Up @@ -292,9 +291,6 @@ export function getInitializeNonceAccountInstruction<
accounts.rentSysvar.value =
'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>;
}
if (!args.nonceAccountArg) {
args.nonceAccountArg = expectAddress(accounts.nonceAccount.value);
}

// Get account metas and signers.
const accountMetas = getAccountMetasWithSigners(
Expand Down
28 changes: 14 additions & 14 deletions clients/rust/src/generated/instructions/authorize_nonce_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl AuthorizeNonceAccountInstructionData {
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AuthorizeNonceAccountInstructionArgs {
pub nonce_account_arg: Pubkey,
pub new_nonce_authority: Pubkey,
}

/// Instruction builder for `AuthorizeNonceAccount`.
Expand All @@ -80,7 +80,7 @@ pub struct AuthorizeNonceAccountInstructionArgs {
pub struct AuthorizeNonceAccountBuilder {
nonce_account: Option<solana_program::pubkey::Pubkey>,
nonce_authority: Option<solana_program::pubkey::Pubkey>,
nonce_account_arg: Option<Pubkey>,
new_nonce_authority: Option<Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}

Expand All @@ -102,8 +102,8 @@ impl AuthorizeNonceAccountBuilder {
self
}
#[inline(always)]
pub fn nonce_account_arg(&mut self, nonce_account_arg: Pubkey) -> &mut Self {
self.nonce_account_arg = Some(nonce_account_arg);
pub fn new_nonce_authority(&mut self, new_nonce_authority: Pubkey) -> &mut Self {
self.new_nonce_authority = Some(new_nonce_authority);
self
}
/// Add an aditional account to the instruction.
Expand Down Expand Up @@ -131,10 +131,10 @@ impl AuthorizeNonceAccountBuilder {
nonce_authority: self.nonce_authority.expect("nonce_authority is not set"),
};
let args = AuthorizeNonceAccountInstructionArgs {
nonce_account_arg: self
.nonce_account_arg
new_nonce_authority: self
.new_nonce_authority
.clone()
.expect("nonce_account_arg is not set"),
.expect("new_nonce_authority is not set"),
};

accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> {
__program: program,
nonce_account: None,
nonce_authority: None,
nonce_account_arg: None,
new_nonce_authority: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
Expand All @@ -287,8 +287,8 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn nonce_account_arg(&mut self, nonce_account_arg: Pubkey) -> &mut Self {
self.instruction.nonce_account_arg = Some(nonce_account_arg);
pub fn new_nonce_authority(&mut self, new_nonce_authority: Pubkey) -> &mut Self {
self.instruction.new_nonce_authority = Some(new_nonce_authority);
self
}
/// Add an additional account to the instruction.
Expand Down Expand Up @@ -333,11 +333,11 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> {
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
let args = AuthorizeNonceAccountInstructionArgs {
nonce_account_arg: self
new_nonce_authority: self
.instruction
.nonce_account_arg
.new_nonce_authority
.clone()
.expect("nonce_account_arg is not set"),
.expect("new_nonce_authority is not set"),
};
let instruction = AuthorizeNonceAccountCpi {
__program: self.instruction.__program,
Expand All @@ -364,7 +364,7 @@ struct AuthorizeNonceAccountCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
nonce_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
nonce_account_arg: Option<Pubkey>,
new_nonce_authority: Option<Pubkey>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
Expand Down
28 changes: 14 additions & 14 deletions clients/rust/src/generated/instructions/initialize_nonce_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl InitializeNonceAccountInstructionData {
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializeNonceAccountInstructionArgs {
pub nonce_account_arg: Pubkey,
pub nonce_authority: Pubkey,
}

/// Instruction builder for `InitializeNonceAccount`.
Expand All @@ -88,7 +88,7 @@ pub struct InitializeNonceAccountBuilder {
nonce_account: Option<solana_program::pubkey::Pubkey>,
recent_blockhashes_sysvar: Option<solana_program::pubkey::Pubkey>,
rent_sysvar: Option<solana_program::pubkey::Pubkey>,
nonce_account_arg: Option<Pubkey>,
nonce_authority: Option<Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}

Expand Down Expand Up @@ -117,8 +117,8 @@ impl InitializeNonceAccountBuilder {
self
}
#[inline(always)]
pub fn nonce_account_arg(&mut self, nonce_account_arg: Pubkey) -> &mut Self {
self.nonce_account_arg = Some(nonce_account_arg);
pub fn nonce_authority(&mut self, nonce_authority: Pubkey) -> &mut Self {
self.nonce_authority = Some(nonce_authority);
self
}
/// Add an aditional account to the instruction.
Expand Down Expand Up @@ -151,10 +151,10 @@ impl InitializeNonceAccountBuilder {
)),
};
let args = InitializeNonceAccountInstructionArgs {
nonce_account_arg: self
.nonce_account_arg
nonce_authority: self
.nonce_authority
.clone()
.expect("nonce_account_arg is not set"),
.expect("nonce_authority is not set"),
};

accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
Expand Down Expand Up @@ -297,7 +297,7 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> {
nonce_account: None,
recent_blockhashes_sysvar: None,
rent_sysvar: None,
nonce_account_arg: None,
nonce_authority: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
Expand Down Expand Up @@ -327,8 +327,8 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn nonce_account_arg(&mut self, nonce_account_arg: Pubkey) -> &mut Self {
self.instruction.nonce_account_arg = Some(nonce_account_arg);
pub fn nonce_authority(&mut self, nonce_authority: Pubkey) -> &mut Self {
self.instruction.nonce_authority = Some(nonce_authority);
self
}
/// Add an additional account to the instruction.
Expand Down Expand Up @@ -373,11 +373,11 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> {
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
let args = InitializeNonceAccountInstructionArgs {
nonce_account_arg: self
nonce_authority: self
.instruction
.nonce_account_arg
.nonce_authority
.clone()
.expect("nonce_account_arg is not set"),
.expect("nonce_authority is not set"),
};
let instruction = InitializeNonceAccountCpi {
__program: self.instruction.__program,
Expand Down Expand Up @@ -410,7 +410,7 @@ struct InitializeNonceAccountCpiBuilderInstruction<'a, 'b> {
nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
recent_blockhashes_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>,
rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>,
nonce_account_arg: Option<Pubkey>,
nonce_authority: Option<Pubkey>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
Expand Down
10 changes: 0 additions & 10 deletions configs/kinobi.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ kinobi.update(
// Update instructions.
kinobi.update(
new k.UpdateInstructionsVisitor({
authorizeNonceAccount: {
args: {
nonceAccountArg: { defaultsTo: k.accountDefault("nonceAccount") },
},
},
createAccount: {
bytesCreatedOnChain: k.bytesFromArg("space"),
},
Expand All @@ -61,11 +56,6 @@ kinobi.update(
k.dependsOnArg("addresses"),
]),
},
initializeNonceAccount: {
args: {
nonceAccountArg: { defaultsTo: k.accountDefault("nonceAccount") },
},
},
//
})
);
Expand Down
4 changes: 2 additions & 2 deletions idls/spl_system.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
],
"args": [
{
"name": "nonceAccountArg",
"name": "nonceAuthority",
"type": "publicKey"
}
],
Expand All @@ -238,7 +238,7 @@
],
"args": [
{
"name": "nonceAccountArg",
"name": "newNonceAuthority",
"type": "publicKey"
}
],
Expand Down

0 comments on commit 90dea2e

Please sign in to comment.