@realms-today/sowell-governance 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +336 -0
- package/dist/accounts/bet.d.ts +30 -0
- package/dist/accounts/bet.d.ts.map +1 -0
- package/dist/accounts/bet.js +36 -0
- package/dist/accounts/bet.js.map +1 -0
- package/dist/accounts/governance.d.ts +18 -0
- package/dist/accounts/governance.d.ts.map +1 -0
- package/dist/accounts/governance.js +21 -0
- package/dist/accounts/governance.js.map +1 -0
- package/dist/accounts/governanceLimits.d.ts +10 -0
- package/dist/accounts/governanceLimits.d.ts.map +1 -0
- package/dist/accounts/governanceLimits.js +14 -0
- package/dist/accounts/governanceLimits.js.map +1 -0
- package/dist/accounts/index.d.ts +14 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +30 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/proposal.d.ts +40 -0
- package/dist/accounts/proposal.d.ts.map +1 -0
- package/dist/accounts/proposal.js +46 -0
- package/dist/accounts/proposal.js.map +1 -0
- package/dist/accounts/proposalDeposit.d.ts +9 -0
- package/dist/accounts/proposalDeposit.d.ts.map +1 -0
- package/dist/accounts/proposalDeposit.js +13 -0
- package/dist/accounts/proposalDeposit.js.map +1 -0
- package/dist/accounts/proposalTransaction.d.ts +15 -0
- package/dist/accounts/proposalTransaction.d.ts.map +1 -0
- package/dist/accounts/proposalTransaction.js +19 -0
- package/dist/accounts/proposalTransaction.js.map +1 -0
- package/dist/accounts/realm.d.ts +17 -0
- package/dist/accounts/realm.d.ts.map +1 -0
- package/dist/accounts/realm.js +19 -0
- package/dist/accounts/realm.js.map +1 -0
- package/dist/accounts/realmConfig.d.ts +16 -0
- package/dist/accounts/realmConfig.d.ts.map +1 -0
- package/dist/accounts/realmConfig.js +22 -0
- package/dist/accounts/realmConfig.js.map +1 -0
- package/dist/accounts/receipt.d.ts +21 -0
- package/dist/accounts/receipt.d.ts.map +1 -0
- package/dist/accounts/receipt.js +24 -0
- package/dist/accounts/receipt.js.map +1 -0
- package/dist/accounts/secondaryMarket.d.ts +21 -0
- package/dist/accounts/secondaryMarket.d.ts.map +1 -0
- package/dist/accounts/secondaryMarket.js +27 -0
- package/dist/accounts/secondaryMarket.js.map +1 -0
- package/dist/accounts/sowellianConfig.d.ts +20 -0
- package/dist/accounts/sowellianConfig.d.ts.map +1 -0
- package/dist/accounts/sowellianConfig.js +37 -0
- package/dist/accounts/sowellianConfig.js.map +1 -0
- package/dist/accounts/tokenOwnerRecord.d.ts +15 -0
- package/dist/accounts/tokenOwnerRecord.d.ts.map +1 -0
- package/dist/accounts/tokenOwnerRecord.js +19 -0
- package/dist/accounts/tokenOwnerRecord.js.map +1 -0
- package/dist/accounts/voteRecord.d.ts +13 -0
- package/dist/accounts/voteRecord.d.ts.map +1 -0
- package/dist/accounts/voteRecord.js +17 -0
- package/dist/accounts/voteRecord.js.map +1 -0
- package/dist/borsh.d.ts +46 -0
- package/dist/borsh.d.ts.map +1 -0
- package/dist/borsh.js +192 -0
- package/dist/borsh.js.map +1 -0
- package/dist/decode.d.ts +96 -0
- package/dist/decode.d.ts.map +1 -0
- package/dist/decode.js +128 -0
- package/dist/decode.js.map +1 -0
- package/dist/enums.d.ts +124 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +143 -0
- package/dist/enums.js.map +1 -0
- package/dist/errors.d.ts +171 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +342 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +33 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +68 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/castSecondaryVote.d.ts +16 -0
- package/dist/instructions/castSecondaryVote.d.ts.map +1 -0
- package/dist/instructions/castSecondaryVote.js +36 -0
- package/dist/instructions/castSecondaryVote.js.map +1 -0
- package/dist/instructions/castSowellianVote.d.ts +22 -0
- package/dist/instructions/castSowellianVote.d.ts.map +1 -0
- package/dist/instructions/castSowellianVote.js +38 -0
- package/dist/instructions/castSowellianVote.js.map +1 -0
- package/dist/instructions/castVote.d.ts +18 -0
- package/dist/instructions/castVote.d.ts.map +1 -0
- package/dist/instructions/castVote.js +37 -0
- package/dist/instructions/castVote.js.map +1 -0
- package/dist/instructions/closeBet.d.ts +13 -0
- package/dist/instructions/closeBet.d.ts.map +1 -0
- package/dist/instructions/closeBet.js +33 -0
- package/dist/instructions/closeBet.js.map +1 -0
- package/dist/instructions/closeProposal.d.ts +16 -0
- package/dist/instructions/closeProposal.d.ts.map +1 -0
- package/dist/instructions/closeProposal.js +31 -0
- package/dist/instructions/closeProposal.js.map +1 -0
- package/dist/instructions/closeReceipt.d.ts +11 -0
- package/dist/instructions/closeReceipt.d.ts.map +1 -0
- package/dist/instructions/closeReceipt.js +19 -0
- package/dist/instructions/closeReceipt.js.map +1 -0
- package/dist/instructions/closeSecondary.d.ts +13 -0
- package/dist/instructions/closeSecondary.d.ts.map +1 -0
- package/dist/instructions/closeSecondary.js +29 -0
- package/dist/instructions/closeSecondary.js.map +1 -0
- package/dist/instructions/createGovernance.d.ts +14 -0
- package/dist/instructions/createGovernance.d.ts.map +1 -0
- package/dist/instructions/createGovernance.js +31 -0
- package/dist/instructions/createGovernance.js.map +1 -0
- package/dist/instructions/createNativeTreasury.d.ts +3 -0
- package/dist/instructions/createNativeTreasury.d.ts.map +1 -0
- package/dist/instructions/createNativeTreasury.js +20 -0
- package/dist/instructions/createNativeTreasury.js.map +1 -0
- package/dist/instructions/createProposal.d.ts +37 -0
- package/dist/instructions/createProposal.d.ts.map +1 -0
- package/dist/instructions/createProposal.js +72 -0
- package/dist/instructions/createProposal.js.map +1 -0
- package/dist/instructions/createProposalWithTransactions.d.ts +27 -0
- package/dist/instructions/createProposalWithTransactions.d.ts.map +1 -0
- package/dist/instructions/createProposalWithTransactions.js +85 -0
- package/dist/instructions/createProposalWithTransactions.js.map +1 -0
- package/dist/instructions/createRealm.d.ts +18 -0
- package/dist/instructions/createRealm.d.ts.map +1 -0
- package/dist/instructions/createRealm.js +61 -0
- package/dist/instructions/createRealm.js.map +1 -0
- package/dist/instructions/createTokenOwnerRecord.d.ts +3 -0
- package/dist/instructions/createTokenOwnerRecord.d.ts.map +1 -0
- package/dist/instructions/createTokenOwnerRecord.js +22 -0
- package/dist/instructions/createTokenOwnerRecord.js.map +1 -0
- package/dist/instructions/depositGoverningTokens.d.ts +14 -0
- package/dist/instructions/depositGoverningTokens.d.ts.map +1 -0
- package/dist/instructions/depositGoverningTokens.js +31 -0
- package/dist/instructions/depositGoverningTokens.js.map +1 -0
- package/dist/instructions/executeTransaction.d.ts +18 -0
- package/dist/instructions/executeTransaction.d.ts.map +1 -0
- package/dist/instructions/executeTransaction.js +25 -0
- package/dist/instructions/executeTransaction.js.map +1 -0
- package/dist/instructions/index.d.ts +29 -0
- package/dist/instructions/index.d.ts.map +1 -0
- package/dist/instructions/index.js +45 -0
- package/dist/instructions/index.js.map +1 -0
- package/dist/instructions/insertTransaction.d.ts +17 -0
- package/dist/instructions/insertTransaction.d.ts.map +1 -0
- package/dist/instructions/insertTransaction.js +31 -0
- package/dist/instructions/insertTransaction.js.map +1 -0
- package/dist/instructions/refundProposalDeposit.d.ts +3 -0
- package/dist/instructions/refundProposalDeposit.d.ts.map +1 -0
- package/dist/instructions/refundProposalDeposit.js +19 -0
- package/dist/instructions/refundProposalDeposit.js.map +1 -0
- package/dist/instructions/relinquishVote.d.ts +13 -0
- package/dist/instructions/relinquishVote.d.ts.map +1 -0
- package/dist/instructions/relinquishVote.js +27 -0
- package/dist/instructions/relinquishVote.js.map +1 -0
- package/dist/instructions/resolveBet.d.ts +21 -0
- package/dist/instructions/resolveBet.d.ts.map +1 -0
- package/dist/instructions/resolveBet.js +36 -0
- package/dist/instructions/resolveBet.js.map +1 -0
- package/dist/instructions/setGovernanceConfig.d.ts +4 -0
- package/dist/instructions/setGovernanceConfig.d.ts.map +1 -0
- package/dist/instructions/setGovernanceConfig.js +15 -0
- package/dist/instructions/setGovernanceConfig.js.map +1 -0
- package/dist/instructions/setGovernanceLimits.d.ts +4 -0
- package/dist/instructions/setGovernanceLimits.d.ts.map +1 -0
- package/dist/instructions/setGovernanceLimits.js +24 -0
- package/dist/instructions/setGovernanceLimits.js.map +1 -0
- package/dist/instructions/setOrUpdateSowellianConfig.d.ts +15 -0
- package/dist/instructions/setOrUpdateSowellianConfig.d.ts.map +1 -0
- package/dist/instructions/setOrUpdateSowellianConfig.js +30 -0
- package/dist/instructions/setOrUpdateSowellianConfig.js.map +1 -0
- package/dist/instructions/setRealmAuthority.d.ts +4 -0
- package/dist/instructions/setRealmAuthority.d.ts.map +1 -0
- package/dist/instructions/setRealmAuthority.js +21 -0
- package/dist/instructions/setRealmAuthority.js.map +1 -0
- package/dist/instructions/setRealmConfig.d.ts +15 -0
- package/dist/instructions/setRealmConfig.d.ts.map +1 -0
- package/dist/instructions/setRealmConfig.js +42 -0
- package/dist/instructions/setRealmConfig.js.map +1 -0
- package/dist/instructions/setSowellianGovernanceConfig.d.ts +12 -0
- package/dist/instructions/setSowellianGovernanceConfig.d.ts.map +1 -0
- package/dist/instructions/setSowellianGovernanceConfig.js +27 -0
- package/dist/instructions/setSowellianGovernanceConfig.js.map +1 -0
- package/dist/instructions/settleBet.d.ts +29 -0
- package/dist/instructions/settleBet.d.ts.map +1 -0
- package/dist/instructions/settleBet.js +44 -0
- package/dist/instructions/settleBet.js.map +1 -0
- package/dist/instructions/withdrawGoverningTokens.d.ts +11 -0
- package/dist/instructions/withdrawGoverningTokens.d.ts.map +1 -0
- package/dist/instructions/withdrawGoverningTokens.js +27 -0
- package/dist/instructions/withdrawGoverningTokens.js.map +1 -0
- package/dist/instructions/withdrawPayoff.d.ts +16 -0
- package/dist/instructions/withdrawPayoff.d.ts.map +1 -0
- package/dist/instructions/withdrawPayoff.js +28 -0
- package/dist/instructions/withdrawPayoff.js.map +1 -0
- package/dist/pda.d.ts +20 -0
- package/dist/pda.d.ts.map +1 -0
- package/dist/pda.js +144 -0
- package/dist/pda.js.map +1 -0
- package/dist/programId.d.ts +4 -0
- package/dist/programId.d.ts.map +1 -0
- package/dist/programId.js +17 -0
- package/dist/programId.js.map +1 -0
- package/dist/tradeExecutor/accounts.d.ts +3 -0
- package/dist/tradeExecutor/accounts.d.ts.map +1 -0
- package/dist/tradeExecutor/accounts.js +36 -0
- package/dist/tradeExecutor/accounts.js.map +1 -0
- package/dist/tradeExecutor/discriminators.d.ts +10 -0
- package/dist/tradeExecutor/discriminators.d.ts.map +1 -0
- package/dist/tradeExecutor/discriminators.js +13 -0
- package/dist/tradeExecutor/discriminators.js.map +1 -0
- package/dist/tradeExecutor/index.d.ts +7 -0
- package/dist/tradeExecutor/index.d.ts.map +1 -0
- package/dist/tradeExecutor/index.js +23 -0
- package/dist/tradeExecutor/index.js.map +1 -0
- package/dist/tradeExecutor/instructions.d.ts +44 -0
- package/dist/tradeExecutor/instructions.d.ts.map +1 -0
- package/dist/tradeExecutor/instructions.js +132 -0
- package/dist/tradeExecutor/instructions.js.map +1 -0
- package/dist/tradeExecutor/pda.d.ts +4 -0
- package/dist/tradeExecutor/pda.d.ts.map +1 -0
- package/dist/tradeExecutor/pda.js +15 -0
- package/dist/tradeExecutor/pda.js.map +1 -0
- package/dist/tradeExecutor/programId.d.ts +11 -0
- package/dist/tradeExecutor/programId.d.ts.map +1 -0
- package/dist/tradeExecutor/programId.js +14 -0
- package/dist/tradeExecutor/programId.js.map +1 -0
- package/dist/tradeExecutor/types.d.ts +57 -0
- package/dist/tradeExecutor/types.d.ts.map +1 -0
- package/dist/tradeExecutor/types.js +17 -0
- package/dist/tradeExecutor/types.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +227 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# @sowell/governance-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the sowell-gov on-chain governance program.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @sowell/governance-sdk @solana/web3.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
createProposalWithTransactionsInstruction,
|
|
16
|
+
getGovernanceAddress,
|
|
17
|
+
getProposalAddress,
|
|
18
|
+
setProgramId,
|
|
19
|
+
} from "@sowell/governance-sdk";
|
|
20
|
+
import { PublicKey } from "@solana/web3.js";
|
|
21
|
+
|
|
22
|
+
setProgramId(new PublicKey("YourProgramId..."));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Instructions
|
|
26
|
+
|
|
27
|
+
All 18 instruction builders return a `TransactionInstruction` ready to send.
|
|
28
|
+
|
|
29
|
+
| # | Function | Description |
|
|
30
|
+
|---|----------|-------------|
|
|
31
|
+
| 0 | `createRealmInstruction` | Create a new realm (DAO) |
|
|
32
|
+
| 1 | `depositGoverningTokensInstruction` | Deposit tokens to get voting power |
|
|
33
|
+
| 2 | `withdrawGoverningTokensInstruction` | Withdraw deposited tokens |
|
|
34
|
+
| 3 | `createGovernanceInstruction` | Create a governance over an account |
|
|
35
|
+
| 4 | `createProposalInstruction` | Create a bare proposal (legacy) |
|
|
36
|
+
| 5 | `insertTransactionInstruction` | Attach a transaction to a proposal |
|
|
37
|
+
| 6 | `castVoteInstruction` | Cast a vote on a proposal |
|
|
38
|
+
| 7 | `relinquishVoteInstruction` | Withdraw a vote |
|
|
39
|
+
| 8 | `executeTransactionInstruction` | Execute an approved proposal's transaction |
|
|
40
|
+
| 9 | `setGovernanceConfigInstruction` | Update governance config (via proposal) |
|
|
41
|
+
| 10 | `setRealmAuthorityInstruction` | Transfer/remove realm authority |
|
|
42
|
+
| 11 | `setRealmConfigInstruction` | Update realm settings |
|
|
43
|
+
| 12 | `createTokenOwnerRecordInstruction` | Create a TOR without depositing |
|
|
44
|
+
| 13 | `createNativeTreasuryInstruction` | Create the native SOL treasury PDA |
|
|
45
|
+
| 14 | `refundProposalDepositInstruction` | Reclaim proposal deposit after completion |
|
|
46
|
+
| 15 | `createProposalWithTransactionsInstruction` | Atomic proposal + transactions + vote |
|
|
47
|
+
| 16 | `setGovernanceLimitsInstruction` | Set per-mint spending limits |
|
|
48
|
+
| 17 | `closeProposalInstruction` | Cancel/finalize/dispose a proposal |
|
|
49
|
+
|
|
50
|
+
## Key workflows
|
|
51
|
+
|
|
52
|
+
### One-shot proposal (create + vote in a single tx)
|
|
53
|
+
|
|
54
|
+
`createProposalWithTransactionsInstruction` is the primary instruction for fast treasury operations. It batches up to four steps in one instruction:
|
|
55
|
+
|
|
56
|
+
1. Create proposal (always SingleChoice with deny option)
|
|
57
|
+
2. Attach N transactions (each with `holdUpTime` + instructions)
|
|
58
|
+
3. Enter voting (`finalize: true`)
|
|
59
|
+
4. Cast an approve vote (`vote: true`, implies `finalize`)
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import {
|
|
63
|
+
createProposalWithTransactionsInstruction,
|
|
64
|
+
ProposalTransactionInput,
|
|
65
|
+
InstructionData,
|
|
66
|
+
} from "@sowell/governance-sdk";
|
|
67
|
+
|
|
68
|
+
const tx: InstructionData = {
|
|
69
|
+
programId: SystemProgram.programId,
|
|
70
|
+
accounts: [
|
|
71
|
+
{ pubkey: treasuryPda, isSigner: true, isWritable: true },
|
|
72
|
+
{ pubkey: destination, isSigner: false, isWritable: true },
|
|
73
|
+
],
|
|
74
|
+
data: transferInstructionData,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const ix = createProposalWithTransactionsInstruction({
|
|
78
|
+
programId,
|
|
79
|
+
realm,
|
|
80
|
+
governance,
|
|
81
|
+
proposalOwnerRecord: tokenOwnerRecord,
|
|
82
|
+
governingTokenMint: communityMint,
|
|
83
|
+
governanceAuthority: wallet.publicKey,
|
|
84
|
+
payer: wallet.publicKey,
|
|
85
|
+
name: "Transfer 5 SOL",
|
|
86
|
+
descriptionLink: "https://...",
|
|
87
|
+
proposalSeed: Keypair.generate().publicKey,
|
|
88
|
+
transactions: [{ holdUpTime: 0, instructions: [tx] }],
|
|
89
|
+
finalize: true, // Draft -> Voting
|
|
90
|
+
vote: true, // also cast an Approve vote (implies finalize)
|
|
91
|
+
// maxVotingTime: 3600, // optional: override governance default (can only extend)
|
|
92
|
+
// voterWeightRecord, // optional: voter weight addin
|
|
93
|
+
// maxVoterWeightRecord, // optional: max voter weight addin
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Tips:**
|
|
98
|
+
- `vote: true` implies `finalize: true` -- you don't need to set both
|
|
99
|
+
- If the voter has enough weight to tip the vote (e.g. >60% under Early tipping), the proposal immediately transitions to Succeeded within the same instruction
|
|
100
|
+
- `holdUpTime: 0` means the transaction is executable immediately after the vote passes (after 1 slot)
|
|
101
|
+
- `proposalSeed` must be unique per proposal -- use `Keypair.generate().publicKey`
|
|
102
|
+
- Max ~4 SOL-transfer-sized transactions fit in a single instruction due to Solana's 1232-byte tx limit
|
|
103
|
+
|
|
104
|
+
### Execute a succeeded proposal
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import {
|
|
108
|
+
executeTransactionInstruction,
|
|
109
|
+
getProposalTransactionAddress,
|
|
110
|
+
getGovernanceLimitsAddress,
|
|
111
|
+
} from "@sowell/governance-sdk";
|
|
112
|
+
|
|
113
|
+
const txPda = getProposalTransactionAddress(programId, proposal, 0, 0);
|
|
114
|
+
|
|
115
|
+
const ix = executeTransactionInstruction({
|
|
116
|
+
programId,
|
|
117
|
+
governance,
|
|
118
|
+
proposal,
|
|
119
|
+
proposalTransaction: txPda,
|
|
120
|
+
instructionAccounts: [
|
|
121
|
+
// accounts required by the inner CPI, in order
|
|
122
|
+
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
123
|
+
{ pubkey: treasuryPda, isSigner: false, isWritable: true },
|
|
124
|
+
{ pubkey: destination, isSigner: false, isWritable: true },
|
|
125
|
+
],
|
|
126
|
+
// Pass this to enforce spending limits (required when governance has limits set)
|
|
127
|
+
governanceLimits: getGovernanceLimitsAddress(programId, governance),
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Close / cancel a proposal
|
|
132
|
+
|
|
133
|
+
`closeProposalInstruction` is a unified instruction that handles cancellation, finalization, and account disposal (reclaims rent).
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
const ix = closeProposalInstruction({
|
|
137
|
+
programId,
|
|
138
|
+
realm,
|
|
139
|
+
governance,
|
|
140
|
+
proposal,
|
|
141
|
+
proposalOwnerRecord: tokenOwnerRecord,
|
|
142
|
+
governingTokenMint: communityMint,
|
|
143
|
+
authority: wallet.publicKey,
|
|
144
|
+
beneficiary: wallet.publicKey, // receives reclaimed rent
|
|
145
|
+
proposalTransactions: [txPda1, txPda2], // must pass ALL transaction PDAs
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Who can close:**
|
|
150
|
+
|
|
151
|
+
| Proposal state | Who | Outcome |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| Completed, Cancelled, Defeated, Vetoed | Anyone | Dispose (reclaim rent) |
|
|
154
|
+
| Draft, SigningOff | Owner/delegate | Cancel + dispose |
|
|
155
|
+
| Voting (active) | Owner/delegate | Cancel + dispose |
|
|
156
|
+
| Voting (expired) | Anyone | Finalize vote; dispose if Defeated/Vetoed |
|
|
157
|
+
| Succeeded, Executing, ExecutingWithErrors | No one | Must execute txns or expire |
|
|
158
|
+
|
|
159
|
+
### Spending limits
|
|
160
|
+
|
|
161
|
+
Set per-mint caps on how much a governance can spend per `ExecuteTransaction`:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import {
|
|
165
|
+
setGovernanceLimitsInstruction,
|
|
166
|
+
MintSpendingLimit,
|
|
167
|
+
NATIVE_SOL_MINT,
|
|
168
|
+
SpendingLimitTypeKind,
|
|
169
|
+
} from "@sowell/governance-sdk";
|
|
170
|
+
|
|
171
|
+
const limits: MintSpendingLimit[] = [
|
|
172
|
+
{ mint: usdcMint, limit: { kind: SpendingLimitTypeKind.Absolute, amount: 1_000_000_000n } },
|
|
173
|
+
{ mint: NATIVE_SOL_MINT, limit: { kind: SpendingLimitTypeKind.Bps, bps: 500 } }, // 5% of balance
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
const ix = setGovernanceLimitsInstruction(
|
|
177
|
+
programId,
|
|
178
|
+
governance,
|
|
179
|
+
realm,
|
|
180
|
+
realmAuthority, // or governance PDA (via proposal)
|
|
181
|
+
payer,
|
|
182
|
+
limits,
|
|
183
|
+
);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Tips:**
|
|
187
|
+
- `NATIVE_SOL_MINT` (`PublicKey.default`) is the sentinel for native SOL limits
|
|
188
|
+
- BPS values are basis points: `10000` = 100%, `500` = 5%
|
|
189
|
+
- BPS limits are per-execution against the current balance (not the original)
|
|
190
|
+
- Pass an empty `limits` array to clear all limits and unset the `has_spending_limits` flag
|
|
191
|
+
- Once limits are set, `executeTransactionInstruction` must include the `governanceLimits` PDA
|
|
192
|
+
|
|
193
|
+
## Account decoders
|
|
194
|
+
|
|
195
|
+
Deserialize on-chain account data into typed objects. Pass the raw `Buffer` from `connection.getAccountInfo()`.
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import {
|
|
199
|
+
decodeRealm,
|
|
200
|
+
decodeGovernance,
|
|
201
|
+
decodeProposal,
|
|
202
|
+
decodeTokenOwnerRecord,
|
|
203
|
+
decodeVoteRecord,
|
|
204
|
+
decodeProposalTransaction,
|
|
205
|
+
decodeRealmConfig,
|
|
206
|
+
decodeProposalDeposit,
|
|
207
|
+
decodeGovernanceLimits,
|
|
208
|
+
} from "@sowell/governance-sdk";
|
|
209
|
+
|
|
210
|
+
const info = await connection.getAccountInfo(proposalAddress);
|
|
211
|
+
const proposal = decodeProposal(info.data);
|
|
212
|
+
console.log(proposal.state); // ProposalState enum
|
|
213
|
+
console.log(proposal.name);
|
|
214
|
+
console.log(proposal.options); // ProposalOption[]
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## PDA derivation
|
|
218
|
+
|
|
219
|
+
All 14 PDA helpers follow the pattern `get*Address(programId, ...seeds): PublicKey`.
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
import {
|
|
223
|
+
getRealmAddress,
|
|
224
|
+
getGovernanceAddress,
|
|
225
|
+
getTokenOwnerRecordAddress,
|
|
226
|
+
getProposalAddress,
|
|
227
|
+
getProposalTransactionAddress,
|
|
228
|
+
getVoteRecordAddress,
|
|
229
|
+
getNativeTreasuryAddress,
|
|
230
|
+
getGovernanceLimitsAddress,
|
|
231
|
+
getGoverningTokenHoldingAddress,
|
|
232
|
+
getRealmConfigAddress,
|
|
233
|
+
getProposalDepositAddress,
|
|
234
|
+
getProgramGovernanceAddress,
|
|
235
|
+
getMintGovernanceAddress,
|
|
236
|
+
getTokenGovernanceAddress,
|
|
237
|
+
} from "@sowell/governance-sdk";
|
|
238
|
+
|
|
239
|
+
const realm = getRealmAddress(programId, "My DAO");
|
|
240
|
+
const governance = getGovernanceAddress(programId, realm, governedAccount);
|
|
241
|
+
const treasury = getNativeTreasuryAddress(programId, governance);
|
|
242
|
+
const limits = getGovernanceLimitsAddress(programId, governance);
|
|
243
|
+
const proposal = getProposalAddress(programId, governance, mint, seed);
|
|
244
|
+
const txPda = getProposalTransactionAddress(programId, proposal, 0, 0);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Instruction decoder (for indexers)
|
|
248
|
+
|
|
249
|
+
Parse raw instruction data into typed discriminated unions:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
import { decodeGovernanceInstruction, getInstructionName } from "@sowell/governance-sdk";
|
|
253
|
+
|
|
254
|
+
const decoded = decodeGovernanceInstruction(instructionData);
|
|
255
|
+
if (decoded && decoded.instruction === 15) {
|
|
256
|
+
// CreateProposalWithTransactions
|
|
257
|
+
console.log(decoded.name, decoded.finalize, decoded.vote);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
getInstructionName(6); // "CastVote"
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Error handling
|
|
264
|
+
|
|
265
|
+
Parse custom program errors from transaction failures:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
import {
|
|
269
|
+
parseGovernanceError,
|
|
270
|
+
isGovernanceError,
|
|
271
|
+
getGovernanceErrorName,
|
|
272
|
+
getGovernanceErrorMessage,
|
|
273
|
+
} from "@sowell/governance-sdk";
|
|
274
|
+
|
|
275
|
+
// From a failed transaction's error code:
|
|
276
|
+
const err = parseGovernanceError(604);
|
|
277
|
+
// { code: 604, name: "SpendingLimitExceeded", message: "Treasury spending limit breached" }
|
|
278
|
+
|
|
279
|
+
isGovernanceError(604); // true
|
|
280
|
+
getGovernanceErrorName(604); // "SpendingLimitExceeded"
|
|
281
|
+
getGovernanceErrorMessage(604); // "Treasury spending limit breached"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Error codes range from 500-606. Key ones:
|
|
285
|
+
|
|
286
|
+
| Code | Name | When |
|
|
287
|
+
|---|---|---|
|
|
288
|
+
| 500 | `InvalidInstruction` | Unrecognized instruction discriminant |
|
|
289
|
+
| 503 | `InvalidGoverningTokenMint` | Wrong mint for the governance |
|
|
290
|
+
| 509 | `InvalidProposalState` | Operation not valid for current proposal state |
|
|
291
|
+
| 548 | `VoteWeightSourceNotAllowed` | Voter weight addin check failed |
|
|
292
|
+
| 602 | `MathematicalOverflow` | Arithmetic overflow |
|
|
293
|
+
| 603 | `InvalidMaxVotingTime` | `maxVotingTime` below `votingBaseTime` |
|
|
294
|
+
| 604 | `SpendingLimitExceeded` | Transaction exceeds treasury spending limit |
|
|
295
|
+
| 605 | `InvalidGovernanceLimitsAccount` | Wrong or invalid GovernanceLimits PDA |
|
|
296
|
+
| 606 | `InvalidCloseProposalState` | Invalid state for CloseProposal |
|
|
297
|
+
|
|
298
|
+
## Enums
|
|
299
|
+
|
|
300
|
+
All state enums are exported for matching against decoded account data:
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
import {
|
|
304
|
+
ProposalState,
|
|
305
|
+
VoteTipping,
|
|
306
|
+
VoteThresholdType,
|
|
307
|
+
VoteKind,
|
|
308
|
+
SpendingLimitTypeKind,
|
|
309
|
+
GovernanceAccountType,
|
|
310
|
+
TransactionExecutionStatus,
|
|
311
|
+
GovernanceInstruction,
|
|
312
|
+
} from "@sowell/governance-sdk";
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
| Enum | Values |
|
|
316
|
+
|---|---|
|
|
317
|
+
| `ProposalState` | Draft, SigningOff, Voting, Succeeded, Executing, Completed, Cancelled, Defeated, ExecutingWithErrors, Vetoed |
|
|
318
|
+
| `VoteTipping` | Strict, Early, Disabled |
|
|
319
|
+
| `VoteThresholdType` | YesVotePercentage, Disabled |
|
|
320
|
+
| `VoteKind` | Approve, Deny, Veto |
|
|
321
|
+
| `SpendingLimitTypeKind` | Absolute, Bps |
|
|
322
|
+
| `GovernanceInstruction` | 0-17, maps to all 18 instructions |
|
|
323
|
+
|
|
324
|
+
## Testing
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
yarn test # run all tests
|
|
328
|
+
yarn test:watch # watch mode
|
|
329
|
+
yarn build # compile TypeScript
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Tests use [LiteSVM](https://github.com/LiteSVM/litesvm) for fast in-process Solana program testing.
|
|
333
|
+
|
|
334
|
+
## License
|
|
335
|
+
|
|
336
|
+
Apache-2.0
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { BetOutcome, GovernanceAccountType } from "../enums";
|
|
3
|
+
/** Per-proposal Sowellian prediction market. PDA seeds: `["bet", proposal]`. */
|
|
4
|
+
export interface BetAccount {
|
|
5
|
+
accountType: GovernanceAccountType;
|
|
6
|
+
proposal: PublicKey;
|
|
7
|
+
governance: PublicKey;
|
|
8
|
+
creator: PublicKey;
|
|
9
|
+
betAmount: bigint;
|
|
10
|
+
yesAmount: bigint;
|
|
11
|
+
noAmount: bigint;
|
|
12
|
+
yesWeight: bigint;
|
|
13
|
+
noWeight: bigint;
|
|
14
|
+
evaluationPeriod: number;
|
|
15
|
+
treasuryCutBps: number;
|
|
16
|
+
executed: boolean;
|
|
17
|
+
executedAt: bigint | null;
|
|
18
|
+
cancelled: boolean;
|
|
19
|
+
outcome: BetOutcome;
|
|
20
|
+
impactBps: number;
|
|
21
|
+
impactEnabled: boolean;
|
|
22
|
+
resolvedAt: bigint | null;
|
|
23
|
+
outstandingReceipts: number;
|
|
24
|
+
bump: number;
|
|
25
|
+
reserved: Buffer;
|
|
26
|
+
}
|
|
27
|
+
export declare function decodeBet(data: Buffer): BetAccount;
|
|
28
|
+
/** True iff the bet is in a final (cancelled or resolved) state. */
|
|
29
|
+
export declare function isBetTerminal(bet: BetAccount): boolean;
|
|
30
|
+
//# sourceMappingURL=bet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bet.d.ts","sourceRoot":"","sources":["../../src/accounts/bet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE7D,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,qBAAqB,CAAC;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,SAAS,CAAC;IACtB,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAyBlD;AAED,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAEtD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeBet = decodeBet;
|
|
4
|
+
exports.isBetTerminal = isBetTerminal;
|
|
5
|
+
const borsh_1 = require("../borsh");
|
|
6
|
+
function decodeBet(data) {
|
|
7
|
+
const r = new borsh_1.BorshReader(data);
|
|
8
|
+
return {
|
|
9
|
+
accountType: r.readU8(),
|
|
10
|
+
proposal: r.readPubkey(),
|
|
11
|
+
governance: r.readPubkey(),
|
|
12
|
+
creator: r.readPubkey(),
|
|
13
|
+
betAmount: r.readU64(),
|
|
14
|
+
yesAmount: r.readU64(),
|
|
15
|
+
noAmount: r.readU64(),
|
|
16
|
+
yesWeight: r.readU128(),
|
|
17
|
+
noWeight: r.readU128(),
|
|
18
|
+
evaluationPeriod: r.readU32(),
|
|
19
|
+
treasuryCutBps: r.readU16(),
|
|
20
|
+
executed: r.readBool(),
|
|
21
|
+
executedAt: r.readOption((r) => r.readI64()),
|
|
22
|
+
cancelled: r.readBool(),
|
|
23
|
+
outcome: r.readU8(),
|
|
24
|
+
impactBps: r.readU16(),
|
|
25
|
+
impactEnabled: r.readBool(),
|
|
26
|
+
resolvedAt: r.readOption((r) => r.readI64()),
|
|
27
|
+
outstandingReceipts: r.readU32(),
|
|
28
|
+
bump: r.readU8(),
|
|
29
|
+
reserved: r.readFixedBytes(64),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** True iff the bet is in a final (cancelled or resolved) state. */
|
|
33
|
+
function isBetTerminal(bet) {
|
|
34
|
+
return bet.cancelled || bet.resolvedAt !== null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=bet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bet.js","sourceRoot":"","sources":["../../src/accounts/bet.ts"],"names":[],"mappings":";;AA6BA,8BAyBC;AAGD,sCAEC;AA1DD,oCAAuC;AA4BvC,SAAgB,SAAS,CAAC,IAAY;IACpC,MAAM,CAAC,GAAG,IAAI,mBAAW,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,MAAM,EAA2B;QAChD,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE;QACxB,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE;QAC1B,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE;QACvB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;QACtB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;QACrB,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE;QACvB,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;QACtB,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE;QAC7B,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;QAC3B,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;QACtB,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC5C,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE;QACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAgB;QACjC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;QACtB,aAAa,EAAE,CAAC,CAAC,QAAQ,EAAE;QAC3B,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC5C,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE;QAChC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,QAAQ,EAAE,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,SAAgB,aAAa,CAAC,GAAe;IAC3C,OAAO,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,UAAU,KAAK,IAAI,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { GovernanceAccountType } from "../enums";
|
|
3
|
+
import { GovernanceConfig } from "../types";
|
|
4
|
+
export interface SowellianGovernanceConfig {
|
|
5
|
+
betEnabled: boolean;
|
|
6
|
+
secondaryEnabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface GovernanceAccount {
|
|
9
|
+
accountType: GovernanceAccountType;
|
|
10
|
+
realm: PublicKey;
|
|
11
|
+
governedAccount: PublicKey;
|
|
12
|
+
config: GovernanceConfig;
|
|
13
|
+
activeProposalCount: bigint;
|
|
14
|
+
hasSpendingLimits: boolean;
|
|
15
|
+
sowellian: SowellianGovernanceConfig;
|
|
16
|
+
}
|
|
17
|
+
export declare function decodeGovernance(data: Buffer): GovernanceAccount;
|
|
18
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/accounts/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAwB,MAAM,UAAU,CAAC;AAElE,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,qBAAqB,CAAC;IACnC,KAAK,EAAE,SAAS,CAAC;IACjB,eAAe,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,yBAAyB,CAAC;CACtC;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAchE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeGovernance = decodeGovernance;
|
|
4
|
+
const borsh_1 = require("../borsh");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
function decodeGovernance(data) {
|
|
7
|
+
const r = new borsh_1.BorshReader(data);
|
|
8
|
+
return {
|
|
9
|
+
accountType: r.readU8(),
|
|
10
|
+
realm: r.readPubkey(),
|
|
11
|
+
governedAccount: r.readPubkey(),
|
|
12
|
+
config: (0, types_1.readGovernanceConfig)(r),
|
|
13
|
+
activeProposalCount: r.readU64(),
|
|
14
|
+
hasSpendingLimits: r.readBool(),
|
|
15
|
+
sowellian: {
|
|
16
|
+
betEnabled: r.readBool(),
|
|
17
|
+
secondaryEnabled: r.readBool(),
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/accounts/governance.ts"],"names":[],"mappings":";;AAoBA,4CAcC;AAjCD,oCAAuC;AAEvC,oCAAkE;AAiBlE,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,MAAM,CAAC,GAAG,IAAI,mBAAW,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,MAAM,EAA2B;QAChD,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE;QACrB,eAAe,EAAE,CAAC,CAAC,UAAU,EAAE;QAC/B,MAAM,EAAE,IAAA,4BAAoB,EAAC,CAAC,CAAC;QAC/B,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE;QAChC,iBAAiB,EAAE,CAAC,CAAC,QAAQ,EAAE;QAC/B,SAAS,EAAE;YACT,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE;YACxB,gBAAgB,EAAE,CAAC,CAAC,QAAQ,EAAE;SAC/B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { GovernanceAccountType } from "../enums";
|
|
3
|
+
import { MintSpendingLimit } from "../types";
|
|
4
|
+
export interface GovernanceLimitsAccount {
|
|
5
|
+
accountType: GovernanceAccountType;
|
|
6
|
+
governance: PublicKey;
|
|
7
|
+
limits: MintSpendingLimit[];
|
|
8
|
+
}
|
|
9
|
+
export declare function decodeGovernanceLimits(data: Buffer): GovernanceLimitsAccount;
|
|
10
|
+
//# sourceMappingURL=governanceLimits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governanceLimits.d.ts","sourceRoot":"","sources":["../../src/accounts/governanceLimits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,UAAU,CAAC;AAEpE,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,qBAAqB,CAAC;IACnC,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAO5E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeGovernanceLimits = decodeGovernanceLimits;
|
|
4
|
+
const borsh_1 = require("../borsh");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
function decodeGovernanceLimits(data) {
|
|
7
|
+
const r = new borsh_1.BorshReader(data);
|
|
8
|
+
return {
|
|
9
|
+
accountType: r.readU8(),
|
|
10
|
+
governance: r.readPubkey(),
|
|
11
|
+
limits: r.readVec(types_1.readMintSpendingLimit),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=governanceLimits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governanceLimits.js","sourceRoot":"","sources":["../../src/accounts/governanceLimits.ts"],"names":[],"mappings":";;AAWA,wDAOC;AAjBD,oCAAuC;AAEvC,oCAAoE;AAQpE,SAAgB,sBAAsB,CAAC,IAAY;IACjD,MAAM,CAAC,GAAG,IAAI,mBAAW,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,MAAM,EAA2B;QAChD,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE;QAC1B,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,6BAAqB,CAAC;KACzC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./realm";
|
|
2
|
+
export * from "./governance";
|
|
3
|
+
export * from "./proposal";
|
|
4
|
+
export * from "./proposalTransaction";
|
|
5
|
+
export * from "./tokenOwnerRecord";
|
|
6
|
+
export * from "./voteRecord";
|
|
7
|
+
export * from "./realmConfig";
|
|
8
|
+
export * from "./proposalDeposit";
|
|
9
|
+
export * from "./governanceLimits";
|
|
10
|
+
export * from "./sowellianConfig";
|
|
11
|
+
export * from "./bet";
|
|
12
|
+
export * from "./secondaryMarket";
|
|
13
|
+
export * from "./receipt";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/accounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,OAAO,CAAC;AACtB,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./realm"), exports);
|
|
18
|
+
__exportStar(require("./governance"), exports);
|
|
19
|
+
__exportStar(require("./proposal"), exports);
|
|
20
|
+
__exportStar(require("./proposalTransaction"), exports);
|
|
21
|
+
__exportStar(require("./tokenOwnerRecord"), exports);
|
|
22
|
+
__exportStar(require("./voteRecord"), exports);
|
|
23
|
+
__exportStar(require("./realmConfig"), exports);
|
|
24
|
+
__exportStar(require("./proposalDeposit"), exports);
|
|
25
|
+
__exportStar(require("./governanceLimits"), exports);
|
|
26
|
+
__exportStar(require("./sowellianConfig"), exports);
|
|
27
|
+
__exportStar(require("./bet"), exports);
|
|
28
|
+
__exportStar(require("./secondaryMarket"), exports);
|
|
29
|
+
__exportStar(require("./receipt"), exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accounts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+CAA6B;AAC7B,6CAA2B;AAC3B,wDAAsC;AACtC,qDAAmC;AACnC,+CAA6B;AAC7B,gDAA8B;AAC9B,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,wCAAsB;AACtB,oDAAkC;AAClC,4CAA0B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { GovernanceAccountType, OptionVoteResult, ProposalState } from "../enums";
|
|
3
|
+
import { VoteThreshold, VoteType } from "../types";
|
|
4
|
+
export interface ProposalOption {
|
|
5
|
+
label: string;
|
|
6
|
+
voteWeight: bigint;
|
|
7
|
+
voteResult: OptionVoteResult;
|
|
8
|
+
transactionsExecutedCount: number;
|
|
9
|
+
transactionsCount: number;
|
|
10
|
+
transactionsNextIndex: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ProposalAccount {
|
|
13
|
+
accountType: GovernanceAccountType;
|
|
14
|
+
governance: PublicKey;
|
|
15
|
+
governingTokenMint: PublicKey;
|
|
16
|
+
state: ProposalState;
|
|
17
|
+
tokenOwnerRecord: PublicKey;
|
|
18
|
+
signatoriesCount: number;
|
|
19
|
+
signatoriesSignedOffCount: number;
|
|
20
|
+
voteType: VoteType;
|
|
21
|
+
options: ProposalOption[];
|
|
22
|
+
denyVoteWeight: bigint | null;
|
|
23
|
+
draftAt: bigint;
|
|
24
|
+
signingOffAt: bigint | null;
|
|
25
|
+
votingAt: bigint | null;
|
|
26
|
+
votingAtSlot: bigint | null;
|
|
27
|
+
votingCompletedAt: bigint | null;
|
|
28
|
+
executingAt: bigint | null;
|
|
29
|
+
closedAt: bigint | null;
|
|
30
|
+
maxVoteWeight: bigint | null;
|
|
31
|
+
maxVotingTime: number | null;
|
|
32
|
+
voteThreshold: VoteThreshold | null;
|
|
33
|
+
name: string;
|
|
34
|
+
descriptionLink: string;
|
|
35
|
+
vetoVoteWeight: bigint;
|
|
36
|
+
hasBet: boolean;
|
|
37
|
+
hasSecondary: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function decodeProposal(data: Buffer): ProposalAccount;
|
|
40
|
+
//# sourceMappingURL=proposal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposal.d.ts","sourceRoot":"","sources":["../../src/accounts/proposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAGL,aAAa,EACb,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,qBAAqB,CAAC;IACnC,UAAU,EAAE,SAAS,CAAC;IACtB,kBAAkB,EAAE,SAAS,CAAC;IAC9B,KAAK,EAAE,aAAa,CAAC;IACrB,gBAAgB,EAAE,SAAS,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACvB;AAaD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA6B5D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeProposal = decodeProposal;
|
|
4
|
+
const borsh_1 = require("../borsh");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
function readProposalOption(r) {
|
|
7
|
+
return {
|
|
8
|
+
label: r.readString(),
|
|
9
|
+
voteWeight: r.readU64(),
|
|
10
|
+
voteResult: r.readU8(),
|
|
11
|
+
transactionsExecutedCount: r.readU16(),
|
|
12
|
+
transactionsCount: r.readU16(),
|
|
13
|
+
transactionsNextIndex: r.readU16(),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function decodeProposal(data) {
|
|
17
|
+
const r = new borsh_1.BorshReader(data);
|
|
18
|
+
return {
|
|
19
|
+
accountType: r.readU8(),
|
|
20
|
+
governance: r.readPubkey(),
|
|
21
|
+
governingTokenMint: r.readPubkey(),
|
|
22
|
+
state: r.readU8(),
|
|
23
|
+
tokenOwnerRecord: r.readPubkey(),
|
|
24
|
+
signatoriesCount: r.readU8(),
|
|
25
|
+
signatoriesSignedOffCount: r.readU8(),
|
|
26
|
+
voteType: (0, types_1.readVoteType)(r),
|
|
27
|
+
options: r.readVec(readProposalOption),
|
|
28
|
+
denyVoteWeight: r.readOption((r) => r.readU64()),
|
|
29
|
+
draftAt: r.readI64(),
|
|
30
|
+
signingOffAt: r.readOption((r) => r.readI64()),
|
|
31
|
+
votingAt: r.readOption((r) => r.readI64()),
|
|
32
|
+
votingAtSlot: r.readOption((r) => r.readU64()),
|
|
33
|
+
votingCompletedAt: r.readOption((r) => r.readI64()),
|
|
34
|
+
executingAt: r.readOption((r) => r.readI64()),
|
|
35
|
+
closedAt: r.readOption((r) => r.readI64()),
|
|
36
|
+
maxVoteWeight: r.readOption((r) => r.readU64()),
|
|
37
|
+
maxVotingTime: r.readOption((r) => r.readU32()),
|
|
38
|
+
voteThreshold: r.readOption(types_1.readVoteThreshold),
|
|
39
|
+
name: r.readString(),
|
|
40
|
+
descriptionLink: r.readString(),
|
|
41
|
+
vetoVoteWeight: r.readU64(),
|
|
42
|
+
hasBet: r.readBool(),
|
|
43
|
+
hasSecondary: r.readBool(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=proposal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposal.js","sourceRoot":"","sources":["../../src/accounts/proposal.ts"],"names":[],"mappings":";;AA0DA,wCA6BC;AAtFD,oCAAuC;AAEvC,oCAKkB;AAuClB,SAAS,kBAAkB,CAAC,CAAc;IACxC,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE;QACrB,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;QACvB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAsB;QAC1C,yBAAyB,EAAE,CAAC,CAAC,OAAO,EAAE;QACtC,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE;QAC9B,qBAAqB,EAAE,CAAC,CAAC,OAAO,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,CAAC,GAAG,IAAI,mBAAW,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,MAAM,EAA2B;QAChD,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE;QAC1B,kBAAkB,EAAE,CAAC,CAAC,UAAU,EAAE;QAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAmB;QAClC,gBAAgB,EAAE,CAAC,CAAC,UAAU,EAAE;QAChC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC5B,yBAAyB,EAAE,CAAC,CAAC,MAAM,EAAE;QACrC,QAAQ,EAAE,IAAA,oBAAY,EAAC,CAAC,CAAC;QACzB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACtC,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAChD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;QACpB,YAAY,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9C,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1C,YAAY,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9C,iBAAiB,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACnD,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7C,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1C,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/C,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/C,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,yBAAiB,CAAC;QAC9C,IAAI,EAAE,CAAC,CAAC,UAAU,EAAE;QACpB,eAAe,EAAE,CAAC,CAAC,UAAU,EAAE;QAC/B,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;QAC3B,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;QACpB,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { GovernanceAccountType } from "../enums";
|
|
3
|
+
export interface ProposalDepositAccount {
|
|
4
|
+
accountType: GovernanceAccountType;
|
|
5
|
+
proposal: PublicKey;
|
|
6
|
+
depositPayer: PublicKey;
|
|
7
|
+
}
|
|
8
|
+
export declare function decodeProposalDeposit(data: Buffer): ProposalDepositAccount;
|
|
9
|
+
//# sourceMappingURL=proposalDeposit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposalDeposit.d.ts","sourceRoot":"","sources":["../../src/accounts/proposalDeposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,qBAAqB,CAAC;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,SAAS,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,CAO1E"}
|