Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit addc6bf

Browse files
SebastianBorjoncinquemvines
authored
Governance: Implement Realms
Implemented instructions: - CreateRealm - DepositGoverningTokens - WithdrawGoverningTokens -SetVoteAuthority Co-authored-by: Jon Cinque <jon.cinque@gmail.com> Co-authored-by: Michael Vines <mvines@gmail.com>
1 parent 79f31e3 commit addc6bf

29 files changed

+2407
-50
lines changed

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

governance/program/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@ repository = "https://github.com/solana-labs/solana-program-library"
77
license = "Apache-2.0"
88
edition = "2018"
99

10-
1110
[features]
1211
no-entrypoint = []
1312
test-bpf = []
1413

15-
1614
[dependencies]
17-
solana-program = "1.6.7"
18-
thiserror = "1.0"
15+
arrayref = "0.3.6"
16+
bincode = "1.3.2"
17+
borsh = "0.8.1"
1918
num-derive = "0.3"
2019
num-traits = "0.2"
20+
serde = "1.0.121"
21+
serde_derive = "1.0.103"
22+
solana-program = "1.6.7"
23+
spl-token = { path = "../../token/program", features = [ "no-entrypoint" ] }
24+
thiserror = "1.0"
2125

2226
[dev-dependencies]
2327
assert_matches = "1.5.0"
2428
solana-program-test = "1.6.7"
2529
solana-sdk = "1.6.7"
2630

27-
2831
[lib]
2932
crate-type = ["cdylib", "lib"]

governance/program/src/error.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,53 @@ use solana_program::{
88
};
99
use thiserror::Error;
1010

11-
/// Errors that may be returned by the Governance program.
11+
/// Errors that may be returned by the Governance program
1212
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
1313
pub enum GovernanceError {
14-
/// Invalid instruction passed to program.
14+
/// Invalid instruction passed to program
1515
#[error("Invalid instruction passed to program")]
1616
InvalidInstruction,
17+
18+
/// Realm with the given name and governing mints already exists
19+
#[error("Realm with the given name and governing mints already exists")]
20+
RealmAlreadyExists,
21+
22+
/// Invalid Governing Token Mint
23+
#[error("Invalid Governing Token Mint")]
24+
InvalidGoverningTokenMint,
25+
26+
/// Governing Token Owner must sign transaction
27+
#[error("Governing Token Owner must sign transaction")]
28+
GoverningTokenOwnerMustSign,
29+
30+
/// Governing Token Owner or Vote Authority must sign transaction
31+
#[error("Governing Token Owner or Vote Authority must sign transaction")]
32+
GoverningTokenOwnerOrVoteAuthrotiyMustSign,
33+
34+
/// All active votes must be relinquished to withdraw governing tokens
35+
#[error("All active votes must be relinquished to withdraw governing tokens")]
36+
CannotWithdrawGoverningTokensWhenActiveVotesExist,
37+
38+
/// Invalid Voter account address
39+
#[error("Invalid Voter account address")]
40+
InvalidVoterAccountAddress,
41+
42+
/// ---- Account Tools Errors -----
43+
44+
/// Invalid account owner
45+
#[error("Invalid account owner")]
46+
InvalidAccountOwner,
47+
48+
/// ---- Token Tools Errors -----
49+
50+
/// Invalid Token account owner
51+
#[error("Invalid Token account owner")]
52+
InvalidTokenAccountOwner,
1753
}
1854

1955
impl PrintProgramError for GovernanceError {
2056
fn print<E>(&self) {
21-
msg!(&self.to_string());
57+
msg!("GOVERNANCE-ERROR: {}", &self.to_string());
2258
}
2359
}
2460

0 commit comments

Comments
 (0)