Initial commit from template

This commit is contained in:
StackClass
2025-09-06 03:11:19 +00:00
commit 52f39bd23e
10 changed files with 184 additions and 0 deletions

16
.eslintrc.js Normal file
View File

@@ -0,0 +1,16 @@
module.exports = {
env: {
es2021: true,
node: true,
},
extends: ["eslint:recommended", "@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
// Add custom rules here
},
};

28
.gitignore vendored Normal file
View File

@@ -0,0 +1,28 @@
# Dependencies
node_modules/
target/
dist/
# Environment variables
.env
.env.local
# IDE files
.vscode/
.idea/
# OS files
.DS_Store
Thumbs.db
# Logs
logs
*.log
# Coverage
coverage/
.nyc_output/
# Anchor
.anchor/
test-ledger/

9
Anchor.toml Normal file
View File

@@ -0,0 +1,9 @@
[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"
[programs.devnet]
voting_program = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

9
Cargo.toml Normal file
View File

@@ -0,0 +1,9 @@
[workspace]
members = [
"programs/*",
"tests",
]
[profile.release]
lto = true
opt-level = 3

14
migrations/deploy.ts Normal file
View File

@@ -0,0 +1,14 @@
// Migrations are managed by Anchor
// This file can be used for custom deployment scripts
import * as anchor from "@coral-xyz/anchor";
async function main() {
console.log("Running deployment script...");
// Custom deployment logic can be added here
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

24
package.json Normal file
View File

@@ -0,0 +1,24 @@
{
"name": "solana-voting",
"version": "0.1.0",
"description": "Solana voting program built with Anchor",
"main": "index.js",
"scripts": {
"test": "anchor test",
"lint": "eslint --ext .ts tests/",
"build": "anchor build",
"deploy": "anchor deploy"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0",
"@solana/web3.js": "^1.87.0"
},
"devDependencies": {
"@types/mocha": "^10.0.0",
"@types/node": "^20.0.0",
"eslint": "^8.0.0",
"mocha": "^10.0.0",
"ts-mocha": "^10.0.0",
"typescript": "^5.0.0"
}
}

View File

@@ -0,0 +1,12 @@
[package]
name = "voting-program"
version = "0.1.0"
description = "Solana voting program"
edition = "2021"
[lib]
crate-type = ["cdylib", "lib"]
[dependencies]
anchor-lang = { version = "0.29.0", features = ["init", "derive"] }
anchor-spl = "0.29.0"

View File

@@ -0,0 +1,42 @@
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod voting_program {
use super::*;
pub fn initialize_proposal(
ctx: Context<InitializeProposal>,
title: String,
options: Vec<String>,
) -> Result<()> {
// Students will implement this function
Ok(())
}
pub fn vote(ctx: Context<Vote>, option_index: u32) -> Result<()> {
// Students will implement this function
Ok(())
}
}
#[account]
pub struct Proposal {
// Students will complete this struct
}
#[derive(Accounts)]
pub struct InitializeProposal<'info> {
// Students will complete this struct
}
#[derive(Accounts)]
pub struct Vote<'info> {
// Students will complete this struct
}
#[error_code]
pub enum VotingError {
// Students will define error codes
}

15
tests/voting-program.ts Normal file
View File

@@ -0,0 +1,15 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { VotingProgram } from "../target/types/voting_program";
describe("voting-program", () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const program = anchor.workspace.VotingProgram as Program<VotingProgram>;
it("Is initialized!", async () => {
// Students will write test cases here
});
});

15
tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"types": ["mocha", "chai"],
"typeRoots": ["./node_modules/@types"],
"lib": ["es2020"],
"module": "commonjs",
"target": "es2020",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
}
}