Skip to content

Commit c6279da

Browse files
authored
Merge pull request #54 from Zoints/documentation
Adding additional comments for open sourcing
2 parents 38aae4e + 0885bcb commit c6279da

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021 Zoints
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+5-26
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1+
# Zoints Staking
12

2-
## Running Tests
3+
Layout of this repository:
34

4-
Install JavaScript dependencies:
5-
6-
```bash
7-
cd js
8-
npm i
9-
npm run build
10-
cd ../test_server
11-
npm i
12-
```
13-
14-
Build Solana program:
15-
16-
```bash
17-
cd ../program
18-
cargo build-bpf
19-
```
20-
21-
Start Solana node and interactive web server:
22-
23-
```bash
24-
cd ../test_server
25-
docker-compose up -d
26-
27-
npm run start
28-
```
5+
* [/program](/program) The code for the Solana staking program used by Zoints
6+
* [/js](/js) The code for the [@zoints/staking](https://www.npmjs.com/package/@zoints/staking) library published on npmjs
7+
* [/test_server](/test_server) A developer test environment to allow quick simulations of the code and test features

program/src/account.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Settings {
168168
}
169169
}
170170

171-
/// The PDA that owns the pool associated accounts
171+
/// The PDA that owns the reward pool associated account
172172
#[derive(Debug, PartialEq, Clone, Copy, Eq)]
173173
pub struct PoolAuthority {}
174174
impl PoolAuthority {
@@ -204,7 +204,10 @@ impl RewardPool {
204204
}
205205
}
206206

207-
/// The way that the "Authority" address should be interpreted.
207+
/// The way that the "Authority" address of a Stake should be interpreted.
208+
/// A "Basic" authority is a direct ownership of the stake by a wallet address.
209+
/// An "NFT" authority is a delegated ownership, where the current holder of the
210+
/// NFT is considered the owner.
208211
#[derive(Debug, PartialEq, Eq, Clone, Copy, BorshDeserialize, BorshSerialize)]
209212
pub enum Authority {
210213
/// A regular Solana address that can sign instructions
@@ -214,6 +217,7 @@ pub enum Authority {
214217
}
215218

216219
impl Authority {
220+
/// Verifies that an account matches the authority's type
217221
pub fn verify(&self, account: &AccountInfo) -> Result<(), ProgramError> {
218222
match self {
219223
Authority::Basic(pubkey) => {
@@ -242,6 +246,9 @@ impl Authority {
242246
}
243247
}
244248

249+
/// Verifies that the owner and signer accounts provided a valid signature for the authority type.
250+
/// For a basic authority, the owner and signer are the same account.
251+
/// For an NFT authority, the owner is the associated SPL token accont, the signer is the associated account's owner
245252
pub fn has_signed(&self, owner: &AccountInfo, signer: &AccountInfo) -> bool {
246253
match self {
247254
Authority::Basic(key) => {
@@ -358,7 +365,7 @@ impl Beneficiary {
358365
}
359366
}
360367

361-
/// The account that initiated a stake
368+
/// The account that holds the data for a staker staking with a specific Endpoint.
362369
#[derive(Debug, PartialEq, BorshDeserialize, BorshSerialize, Clone, Copy, Eq)]
363370
pub struct Stake {
364371
/// Time the account was initiated

0 commit comments

Comments
 (0)