Rename to voter-stake-registry
This commit is contained in:
parent
0efd7c0518
commit
0543f5fe20
|
@ -1,5 +1,5 @@
|
|||
[programs.localnet]
|
||||
governance_registry = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
|
||||
voter_stake_registry = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
|
||||
|
||||
[provider]
|
||||
cluster = "localnet"
|
||||
|
|
|
@ -1065,24 +1065,6 @@ dependencies = [
|
|||
"scroll",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "governance-registry"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
"serde",
|
||||
"solana-logger",
|
||||
"solana-program",
|
||||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
"spl-associated-token-account",
|
||||
"spl-governance",
|
||||
"spl-token 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.7"
|
||||
|
@ -3207,6 +3189,24 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
[[package]]
|
||||
name = "voter-stake-registry"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
"serde",
|
||||
"solana-logger",
|
||||
"solana-program",
|
||||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
"spl-associated-token-account",
|
||||
"spl-governance",
|
||||
"spl-token 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.3.2"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
[package]
|
||||
name = "governance-registry"
|
||||
name = "voter-stake-registry"
|
||||
version = "0.1.0"
|
||||
description = "Created with Anchor"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
name = "governance_registry"
|
||||
name = "voter_stake_registry"
|
||||
doctest = false
|
||||
|
||||
[features]
|
|
@ -61,7 +61,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|||
/// Note that the above also implies that the `max_vote_weight` must fit into
|
||||
/// a u64.
|
||||
#[program]
|
||||
pub mod governance_registry {
|
||||
pub mod voter_stake_registry {
|
||||
use super::*;
|
||||
|
||||
/// Creates a new voting registrar. There can only be a single registrar
|
|
@ -53,14 +53,14 @@ impl AddinCookie {
|
|||
|
||||
let vote_weight_decimals = 6;
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
&governance_registry::instruction::CreateRegistrar {
|
||||
&voter_stake_registry::instruction::CreateRegistrar {
|
||||
vote_weight_decimals,
|
||||
registrar_bump,
|
||||
},
|
||||
);
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::CreateRegistrar {
|
||||
&voter_stake_registry::accounts::CreateRegistrar {
|
||||
registrar,
|
||||
governance_program_id: realm.governance.program_id,
|
||||
realm: realm.realm,
|
||||
|
@ -113,7 +113,7 @@ impl AddinCookie {
|
|||
);
|
||||
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
&governance_registry::instruction::CreateExchangeRate {
|
||||
&voter_stake_registry::instruction::CreateExchangeRate {
|
||||
idx: index,
|
||||
mint: deposit_mint,
|
||||
rate,
|
||||
|
@ -122,7 +122,7 @@ impl AddinCookie {
|
|||
);
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::CreateExchangeRate {
|
||||
&voter_stake_registry::accounts::CreateExchangeRate {
|
||||
exchange_vault,
|
||||
deposit_mint,
|
||||
registrar: registrar.address,
|
||||
|
@ -181,13 +181,13 @@ impl AddinCookie {
|
|||
);
|
||||
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::CreateVoter {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::CreateVoter {
|
||||
voter_bump,
|
||||
voter_weight_record_bump,
|
||||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::CreateVoter {
|
||||
&voter_stake_registry::accounts::CreateVoter {
|
||||
voter,
|
||||
voter_weight_record,
|
||||
registrar: registrar.address,
|
||||
|
@ -232,13 +232,13 @@ impl AddinCookie {
|
|||
exchange_rate: &ExchangeRateCookie,
|
||||
deposit_authority: &Keypair,
|
||||
token_address: Pubkey,
|
||||
lockup_kind: governance_registry::account::LockupKind,
|
||||
lockup_kind: voter_stake_registry::account::LockupKind,
|
||||
amount: u64,
|
||||
periods: i32,
|
||||
allow_clawback: bool,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::CreateDeposit {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::CreateDeposit {
|
||||
kind: lockup_kind,
|
||||
amount,
|
||||
periods,
|
||||
|
@ -246,8 +246,8 @@ impl AddinCookie {
|
|||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::CreateDeposit {
|
||||
deposit: governance_registry::accounts::UpdateDeposit {
|
||||
&voter_stake_registry::accounts::CreateDeposit {
|
||||
deposit: voter_stake_registry::accounts::UpdateDeposit {
|
||||
registrar: registrar.address,
|
||||
voter: voter.address,
|
||||
exchange_vault: exchange_rate.exchange_vault,
|
||||
|
@ -290,13 +290,13 @@ impl AddinCookie {
|
|||
amount: u64,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::UpdateDeposit {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::UpdateDeposit {
|
||||
id,
|
||||
amount,
|
||||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::UpdateDeposit {
|
||||
&voter_stake_registry::accounts::UpdateDeposit {
|
||||
registrar: registrar.address,
|
||||
voter: voter.address,
|
||||
exchange_vault: exchange_rate.exchange_vault,
|
||||
|
@ -336,12 +336,12 @@ impl AddinCookie {
|
|||
deposit_id: u8,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::Clawback {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::Clawback {
|
||||
deposit_id,
|
||||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::WithdrawOrClawback {
|
||||
&voter_stake_registry::accounts::WithdrawOrClawback {
|
||||
registrar: registrar.address,
|
||||
voter: voter.address,
|
||||
token_owner_record: token_owner_record.address,
|
||||
|
@ -380,13 +380,13 @@ impl AddinCookie {
|
|||
amount: u64,
|
||||
) -> std::result::Result<(), TransportError> {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::Withdraw {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::Withdraw {
|
||||
deposit_id,
|
||||
amount,
|
||||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::WithdrawOrClawback {
|
||||
&voter_stake_registry::accounts::WithdrawOrClawback {
|
||||
registrar: registrar.address,
|
||||
voter: voter.address,
|
||||
token_owner_record: token_owner_record.address,
|
||||
|
@ -417,13 +417,13 @@ impl AddinCookie {
|
|||
&self,
|
||||
registrar: &RegistrarCookie,
|
||||
voter: &VoterCookie,
|
||||
) -> std::result::Result<governance_registry::account::VoterWeightRecord, TransportError> {
|
||||
) -> std::result::Result<voter_stake_registry::account::VoterWeightRecord, TransportError> {
|
||||
let data = anchor_lang::InstructionData::data(
|
||||
&governance_registry::instruction::UpdateVoterWeightRecord {},
|
||||
&voter_stake_registry::instruction::UpdateVoterWeightRecord {},
|
||||
);
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::UpdateVoterWeightRecord {
|
||||
&voter_stake_registry::accounts::UpdateVoterWeightRecord {
|
||||
registrar: registrar.address,
|
||||
voter: voter.address,
|
||||
voter_weight_record: voter.voter_weight_record,
|
||||
|
@ -442,7 +442,7 @@ impl AddinCookie {
|
|||
|
||||
Ok(self
|
||||
.solana
|
||||
.get_account::<governance_registry::account::VoterWeightRecord>(
|
||||
.get_account::<voter_stake_registry::account::VoterWeightRecord>(
|
||||
voter.voter_weight_record,
|
||||
)
|
||||
.await)
|
||||
|
@ -455,12 +455,12 @@ impl AddinCookie {
|
|||
deposit_id: u8,
|
||||
) -> Result<(), TransportError> {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::CloseDeposit {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::CloseDeposit {
|
||||
deposit_id,
|
||||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::CloseDeposit {
|
||||
&voter_stake_registry::accounts::CloseDeposit {
|
||||
voter: voter.address,
|
||||
voter_authority: authority.pubkey(),
|
||||
},
|
||||
|
@ -488,12 +488,12 @@ impl AddinCookie {
|
|||
time_offset: i64,
|
||||
) {
|
||||
let data =
|
||||
anchor_lang::InstructionData::data(&governance_registry::instruction::SetTimeOffset {
|
||||
anchor_lang::InstructionData::data(&voter_stake_registry::instruction::SetTimeOffset {
|
||||
time_offset,
|
||||
});
|
||||
|
||||
let accounts = anchor_lang::ToAccountMetas::to_account_metas(
|
||||
&governance_registry::accounts::SetTimeOffset {
|
||||
&voter_stake_registry::accounts::SetTimeOffset {
|
||||
registrar: registrar.address,
|
||||
realm_authority: authority.pubkey(),
|
||||
},
|
||||
|
@ -528,7 +528,7 @@ impl ExchangeRateCookie {
|
|||
impl VoterCookie {
|
||||
pub async fn deposit_amount(&self, solana: &SolanaCookie, deposit_id: u8) -> u64 {
|
||||
solana
|
||||
.get_account::<governance_registry::account::Voter>(self.address)
|
||||
.get_account::<voter_stake_registry::account::Voter>(self.address)
|
||||
.await
|
||||
.deposits[deposit_id as usize]
|
||||
.amount_deposited_native
|
|
@ -56,12 +56,12 @@ pub struct TestContext {
|
|||
|
||||
impl TestContext {
|
||||
pub async fn new() -> Self {
|
||||
let addin_program_id = governance_registry::id();
|
||||
let addin_program_id = voter_stake_registry::id();
|
||||
|
||||
let mut test = ProgramTest::new(
|
||||
"governance_registry",
|
||||
"voter_stake_registry",
|
||||
addin_program_id,
|
||||
processor!(governance_registry::entry),
|
||||
processor!(voter_stake_registry::entry),
|
||||
);
|
||||
test.set_bpf_compute_max_units(200000);
|
||||
|
|
@ -61,7 +61,7 @@ async fn test_basic() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::Cliff,
|
||||
voter_stake_registry::account::LockupKind::Cliff,
|
||||
10000,
|
||||
0,
|
||||
false,
|
|
@ -83,7 +83,7 @@ async fn test_clawback() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
realm_authority,
|
||||
realm_authority_ata,
|
||||
governance_registry::account::LockupKind::Daily,
|
||||
voter_stake_registry::account::LockupKind::Daily,
|
||||
10000,
|
||||
10,
|
||||
true,
|
|
@ -123,7 +123,7 @@ async fn test_deposit_cliff() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::Cliff,
|
||||
voter_stake_registry::account::LockupKind::Cliff,
|
||||
9000,
|
||||
3, // days
|
||||
false,
|
|
@ -123,7 +123,7 @@ async fn test_deposit_daily_vesting() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::Daily,
|
||||
voter_stake_registry::account::LockupKind::Daily,
|
||||
9000,
|
||||
3,
|
||||
false,
|
|
@ -123,7 +123,7 @@ async fn test_deposit_monthly_vesting() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::Monthly,
|
||||
voter_stake_registry::account::LockupKind::Monthly,
|
||||
9000,
|
||||
3,
|
||||
false,
|
|
@ -127,7 +127,7 @@ async fn test_deposit_no_locking() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::None,
|
||||
voter_stake_registry::account::LockupKind::None,
|
||||
10000,
|
||||
0,
|
||||
false,
|
||||
|
@ -159,7 +159,7 @@ async fn test_deposit_no_locking() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::None,
|
||||
voter_stake_registry::account::LockupKind::None,
|
||||
7000,
|
||||
0,
|
||||
false,
|
||||
|
@ -238,7 +238,7 @@ async fn test_deposit_no_locking() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter2_authority,
|
||||
context.users[2].token_accounts[0],
|
||||
governance_registry::account::LockupKind::None,
|
||||
voter_stake_registry::account::LockupKind::None,
|
||||
1000,
|
||||
5,
|
||||
false,
|
||||
|
@ -267,7 +267,7 @@ async fn test_deposit_no_locking() -> Result<(), TransportError> {
|
|||
&mngo_rate,
|
||||
&voter_authority,
|
||||
reference_account,
|
||||
governance_registry::account::LockupKind::Monthly,
|
||||
voter_stake_registry::account::LockupKind::Monthly,
|
||||
3000,
|
||||
1,
|
||||
false,
|
|
@ -14,7 +14,7 @@ import {
|
|||
TOKEN_PROGRAM_ID,
|
||||
ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||
} from "@solana/spl-token";
|
||||
import { GovernanceRegistry } from "../target/types/governance_registry";
|
||||
import { VoterStakeRegistry } from "../target/types/voter_stake_registry";
|
||||
|
||||
const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey(
|
||||
"Sysvar1nstructions1111111111111111111111111"
|
||||
|
@ -24,7 +24,7 @@ describe("voting-rights", () => {
|
|||
anchor.setProvider(anchor.Provider.env());
|
||||
|
||||
const program = anchor.workspace
|
||||
.GovernanceRegistry as Program<GovernanceRegistry>;
|
||||
.VoterStakeRegistry as Program<VoterStakeRegistry>;
|
||||
|
||||
// Initialized variables shared across tests.
|
||||
const governanceProgramId = new PublicKey(
|
Loading…
Reference in New Issue