Verb-noun-ify Nonce API (#7925)

* Verb-noun-ify Nonce API

* Unify instruction naming with API naming

The more verbose nonce_account/NonceAccount was chosen for clarity
that these instructions work on a unique species of system account
This commit is contained in:
Trent Nelson
2020-01-22 16:31:39 -07:00
committed by GitHub
parent 934c32cbc6
commit 964ff522be
7 changed files with 103 additions and 91 deletions

View File

@ -237,7 +237,7 @@ pub fn process_instruction(
}
SystemInstruction::AdvanceNonceAccount => {
let me = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_advance(
me.advance_nonce_account(
&RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
&signers,
)
@ -245,7 +245,7 @@ pub fn process_instruction(
SystemInstruction::WithdrawNonceAccount(lamports) => {
let me = &mut next_keyed_account(keyed_accounts_iter)?;
let to = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_withdraw(
me.withdraw_nonce_account(
lamports,
to,
&RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
@ -255,7 +255,7 @@ pub fn process_instruction(
}
SystemInstruction::InitializeNonceAccount(authorized) => {
let me = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_initialize(
me.initialize_nonce_account(
&authorized,
&RecentBlockhashes::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
&Rent::from_keyed_account(next_keyed_account(keyed_accounts_iter)?)?,
@ -263,7 +263,7 @@ pub fn process_instruction(
}
SystemInstruction::AuthorizeNonceAccount(nonce_authority) => {
let me = &mut next_keyed_account(keyed_accounts_iter)?;
me.nonce_authorize(&nonce_authority, &signers)
me.authorize_nonce_account(&nonce_authority, &signers)
}
SystemInstruction::Allocate { space } => {
let keyed_account = next_keyed_account(keyed_accounts_iter)?;
@ -1045,7 +1045,7 @@ mod tests {
#[test]
fn test_process_nonce_ix_no_acc_data_fail() {
assert_eq!(
process_nonce_instruction(&system_instruction::nonce_advance(
process_nonce_instruction(&system_instruction::advance_nonce_account(
&Pubkey::default(),
&Pubkey::default()
)),
@ -1142,7 +1142,7 @@ mod tests {
#[test]
fn test_process_withdraw_ix_no_acc_data_fail() {
assert_eq!(
process_nonce_instruction(&system_instruction::nonce_withdraw(
process_nonce_instruction(&system_instruction::withdraw_nonce_account(
&Pubkey::default(),
&Pubkey::default(),
&Pubkey::default(),
@ -1379,7 +1379,7 @@ mod tests {
#[test]
fn test_process_authorize_bad_account_data_fail() {
assert_eq!(
process_nonce_instruction(&system_instruction::nonce_authorize(
process_nonce_instruction(&system_instruction::authorize_nonce_account(
&Pubkey::default(),
&Pubkey::default(),
&Pubkey::default(),