id shortcut

This commit is contained in:
Hardhat Chad
2024-10-07 18:55:44 +00:00
parent 7c9532aeac
commit f356139484

View File

@@ -20,14 +20,14 @@ pub fn auth(proof: Pubkey) -> Instruction {
pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
let proof = proof_pda(signer).0;
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(beneficiary, false),
AccountMeta::new(proof, false),
AccountMeta::new_readonly(TREASURY_ADDRESS, false),
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
],
data: Claim {
amount: amount.to_le_bytes(),
@@ -40,11 +40,11 @@ pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
pub fn close(signer: Pubkey) -> Instruction {
let proof = proof_pda(signer).0;
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(proof, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
],
data: Close {}.to_bytes(),
}
@@ -64,15 +64,15 @@ pub fn mine(
AccountMeta::new(bus, false),
AccountMeta::new_readonly(CONFIG_ADDRESS, false),
AccountMeta::new(proof, false),
AccountMeta::new_readonly(sysvar::instructions::id(), false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
AccountMeta::new_readonly(sysvar::instructions::ID, false),
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
];
let optional_accounts = boost_accounts
.into_iter()
.map(|pk| AccountMeta::new_readonly(pk, false))
.collect();
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: [required_accounts, optional_accounts].concat(),
data: Mine {
digest: solution.d,
@@ -86,14 +86,14 @@ pub fn mine(
pub fn open(signer: Pubkey, miner: Pubkey, payer: Pubkey) -> Instruction {
let proof_pda = proof_pda(signer);
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new_readonly(miner, false),
AccountMeta::new(payer, true),
AccountMeta::new(proof_pda.0, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
],
data: Open { bump: proof_pda.1 }.to_bytes(),
}
@@ -102,7 +102,7 @@ pub fn open(signer: Pubkey, miner: Pubkey, payer: Pubkey) -> Instruction {
/// Builds a reset instruction.
pub fn reset(signer: Pubkey) -> Instruction {
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(BUS_ADDRESSES[0], false),
@@ -117,7 +117,7 @@ pub fn reset(signer: Pubkey) -> Instruction {
AccountMeta::new(MINT_ADDRESS, false),
AccountMeta::new(TREASURY_ADDRESS, false),
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
],
data: Reset {}.to_bytes(),
}
@@ -127,13 +127,13 @@ pub fn reset(signer: Pubkey) -> Instruction {
pub fn stake(signer: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
let proof = proof_pda(signer).0;
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(proof, false),
AccountMeta::new(sender, false),
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
],
data: Stake {
amount: amount.to_le_bytes(),
@@ -146,7 +146,7 @@ pub fn stake(signer: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
pub fn update(signer: Pubkey, miner: Pubkey) -> Instruction {
let proof = proof_pda(signer).0;
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new_readonly(miner, false),
@@ -159,7 +159,7 @@ pub fn update(signer: Pubkey, miner: Pubkey) -> Instruction {
// Build an upgrade instruction.
pub fn upgrade(signer: Pubkey, beneficiary: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(beneficiary, false),
@@ -167,7 +167,7 @@ pub fn upgrade(signer: Pubkey, beneficiary: Pubkey, sender: Pubkey, amount: u64)
AccountMeta::new(MINT_V1_ADDRESS, false),
AccountMeta::new(sender, false),
AccountMeta::new(TREASURY_ADDRESS, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
],
data: Upgrade {
amount: amount.to_le_bytes(),
@@ -189,7 +189,7 @@ pub fn initialize(signer: Pubkey) -> Instruction {
bus_pda(7),
];
let config_pda = config_pda();
let mint_pda = Pubkey::find_program_address(&[MINT, MINT_NOISE.as_slice()], &crate::id());
let mint_pda = Pubkey::find_program_address(&[MINT, MINT_NOISE.as_slice()], &crate::ID);
let treasury_pda = treasury_pda();
let metadata_pda = Pubkey::find_program_address(
&[
@@ -200,7 +200,7 @@ pub fn initialize(signer: Pubkey) -> Instruction {
&mpl_token_metadata::ID,
);
Instruction {
program_id: crate::id(),
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(bus_pdas[0].0, false),
@@ -216,11 +216,11 @@ pub fn initialize(signer: Pubkey) -> Instruction {
AccountMeta::new(mint_pda.0, false),
AccountMeta::new(treasury_pda.0, false),
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
AccountMeta::new_readonly(system_program::id(), false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_associated_token_account::id(), false),
AccountMeta::new_readonly(system_program::ID, false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
AccountMeta::new_readonly(mpl_token_metadata::ID, false),
AccountMeta::new_readonly(sysvar::rent::id(), false),
AccountMeta::new_readonly(sysvar::rent::ID, false),
],
data: Initialize {
bus_0_bump: bus_pdas[0].1,