Skip to content

Commit 5ff8573

Browse files
committed
feat: vesting project
1 parent 3188cbd commit 5ff8573

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2937
-0
lines changed

project-8-token-vesting/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 brimigs
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# token-vesting
2+
3+
This project is generated with the [create-solana-dapp](https://github.com/solana-developers/create-solana-dapp) generator.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
- Node v18.18.0 or higher
10+
11+
- Rust v1.77.2 or higher
12+
- Anchor CLI 0.30.0 or higher
13+
- Solana CLI 1.18.9 or higher
14+
15+
### Installation
16+
17+
#### Clone the repo
18+
19+
```shell
20+
git clone <repo-url>
21+
cd <repo-name>
22+
```
23+
24+
#### Install Dependencies
25+
26+
```shell
27+
npm install
28+
```
29+
30+
#### Start the web app
31+
32+
```
33+
npm run dev
34+
```
35+
36+
## Apps
37+
38+
### anchor
39+
40+
This is a Solana program written in Rust using the Anchor framework.
41+
42+
#### Commands
43+
44+
You can use any normal anchor commands. Either move to the `anchor` directory and run the `anchor` command or prefix the command with `npm run`, eg: `npm run anchor`.
45+
46+
#### Sync the program id:
47+
48+
Running this command will create a new keypair in the `anchor/target/deploy` directory and save the address to the Anchor config file and update the `declare_id!` macro in the `./src/lib.rs` file of the program.
49+
50+
You will manually need to update the constant in `anchor/lib/vesting-exports.ts` to match the new program id.
51+
52+
```shell
53+
npm run anchor keys sync
54+
```
55+
56+
#### Build the program:
57+
58+
```shell
59+
npm run anchor-build
60+
```
61+
62+
#### Start the test validator with the program deployed:
63+
64+
```shell
65+
npm run anchor-localnet
66+
```
67+
68+
#### Run the tests
69+
70+
```shell
71+
npm run anchor-test
72+
```
73+
74+
#### Deploy to Devnet
75+
76+
```shell
77+
npm run anchor deploy --provider.cluster devnet
78+
```
79+
80+
### web
81+
82+
This is a React app that uses the Anchor generated client to interact with the Solana program.
83+
84+
#### Commands
85+
86+
Start the web app
87+
88+
```shell
89+
npm run dev
90+
```
91+
92+
Build the web app
93+
94+
```shell
95+
npm run build
96+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": ["../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["*.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/dependency-checks": [
22+
"error",
23+
{
24+
"ignoredFiles": ["{projectRoot}/rollup.config.{js,ts,mjs,mts}"]
25+
}
26+
]
27+
}
28+
}
29+
]
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"jsc": {
3+
"target": "es2017",
4+
"parser": {
5+
"syntax": "typescript",
6+
"decorators": true,
7+
"dynamicImport": true
8+
},
9+
"transform": {
10+
"decoratorMetadata": true,
11+
"legacyDecorator": true
12+
},
13+
"keepClassNames": true,
14+
"externalHelpers": true,
15+
"loose": true
16+
},
17+
"module": {
18+
"type": "es6"
19+
},
20+
"sourceMaps": true,
21+
"exclude": [
22+
"jest.config.ts",
23+
".*\\.spec.tsx?$",
24+
".*\\.test.tsx?$",
25+
"./src/jest-setup.ts$",
26+
"./**/jest-setup.ts$",
27+
".*.js$"
28+
]
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[toolchain]
2+
3+
[features]
4+
resolution = true
5+
skip-lint = false
6+
7+
[programs.localnet]
8+
vesting = "GFdLg11UBR8ZeePW43ZyD1gY4z4UQ96LPa22YBgnn4z8"
9+
10+
[registry]
11+
url = "https://api.apr.dev"
12+
13+
[provider]
14+
cluster = "Localnet"
15+
wallet = "~/.config/solana/id.json"
16+
17+
[scripts]
18+
test = "../node_modules/.bin/nx run anchor:jest"
19+
20+
[test]
21+
startup_wait = 5000
22+
shutdown_wait = 2000
23+
upgradeable = false
24+
25+
[test.validator]
26+
bind_address = "127.0.0.1"
27+
ledger = ".anchor/test-ledger"
28+
rpc_port = 8899
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[workspace]
2+
members = [
3+
"programs/*"
4+
]
5+
resolver = "2"
6+
7+
[profile.release]
8+
overflow-checks = true
9+
lto = "fat"
10+
codegen-units = 1
11+
[profile.release.build-override]
12+
opt-level = 3
13+
incremental = false
14+
codegen-units = 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# anchor
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build anchor` to build the library.
8+
9+
## Running unit tests
10+
11+
Run `nx test anchor` to execute the unit tests via [Jest](https://jestjs.io).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-disable */
2+
import { readFileSync } from 'fs';
3+
4+
// Reading the SWC compilation config and remove the "exclude"
5+
// for the test files to be compiled by SWC
6+
const { exclude: _, ...swcJestConfig } = JSON.parse(
7+
readFileSync(`${__dirname}/.swcrc`, 'utf-8')
8+
);
9+
10+
// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
11+
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
12+
if (swcJestConfig.swcrc === undefined) {
13+
swcJestConfig.swcrc = false;
14+
}
15+
16+
// Uncomment if using global setup/teardown files being transformed via swc
17+
// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries
18+
// jest needs EsModule Interop to find the default exported setup/teardown functions
19+
// swcJestConfig.module.noInterop = false;
20+
21+
export default {
22+
displayName: 'anchor',
23+
preset: '../jest.preset.js',
24+
transform: {
25+
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
26+
},
27+
moduleFileExtensions: ['ts', 'js', 'html'],
28+
testEnvironment: '',
29+
coverageDirectory: '../coverage/anchor',
30+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Migrations are an early feature. Currently, they're nothing more than this
2+
// single deploy script that's invoked from the CLI, injecting a provider
3+
// configured from the workspace's Anchor.toml.
4+
5+
import * as anchor from '@coral-xyz/anchor';
6+
7+
module.exports = async function (provider) {
8+
// Configure client to use the provider.
9+
anchor.setProvider(provider);
10+
11+
// Add your deploy script here.
12+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@token-vesting/anchor",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"@coral-xyz/anchor": "^0.30.1",
6+
"@solana/spl-token": "^0.4.8",
7+
"@solana/web3.js": "1.94.0",
8+
"anchor-bankrun": "^0.4.0",
9+
"solana-bankrun": "^0.2.0",
10+
"spl-token-bankrun": "0.2.5"
11+
},
12+
"main": "./index.cjs",
13+
"module": "./index.js",
14+
"private": true
15+
}

0 commit comments

Comments
 (0)