فهرست منبع

poseidon hello-solana

Ayush 10 ماه پیش
والد
کامیت
66891257f1

+ 7 - 0
basics/hello-solana/poseidon/.gitignore

@@ -0,0 +1,7 @@
+.anchor
+.DS_Store
+target
+**/*.rs.bk
+node_modules
+test-ledger
+.yarn

+ 7 - 0
basics/hello-solana/poseidon/.prettierignore

@@ -0,0 +1,7 @@
+.anchor
+.DS_Store
+target
+node_modules
+dist
+build
+test-ledger

+ 18 - 0
basics/hello-solana/poseidon/Anchor.toml

@@ -0,0 +1,18 @@
+[toolchain]
+
+[features]
+resolution = true
+skip-lint = false
+
+[programs.localnet]
+poseidon = "8krac1be77qraaZQGzHypmngXH6MbftjBmcucLtQLahG"
+
+[registry]
+url = "https://api.apr.dev"
+
+[provider]
+cluster = "Localnet"
+wallet = "~/.config/solana/id.json"
+
+[scripts]
+test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

+ 14 - 0
basics/hello-solana/poseidon/Cargo.toml

@@ -0,0 +1,14 @@
+[workspace]
+members = [
+    "programs/*"
+]
+resolver = "2"
+
+[profile.release]
+overflow-checks = true
+lto = "fat"
+codegen-units = 1
+[profile.release.build-override]
+opt-level = 3
+incremental = false
+codegen-units = 1

+ 12 - 0
basics/hello-solana/poseidon/migrations/deploy.ts

@@ -0,0 +1,12 @@
+// Migrations are an early feature. Currently, they're nothing more than this
+// single deploy script that's invoked from the CLI, injecting a provider
+// configured from the workspace's Anchor.toml.
+
+const anchor = require('@coral-xyz/anchor');
+
+module.exports = async (provider) => {
+  // Configure client to use the provider.
+  anchor.setProvider(provider);
+
+  // Add your deploy script here.
+};

+ 20 - 0
basics/hello-solana/poseidon/package.json

@@ -0,0 +1,20 @@
+{
+  "license": "ISC",
+  "scripts": {
+    "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
+    "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+  },
+  "dependencies": {
+    "@coral-xyz/anchor": "^0.30.1"
+  },
+  "devDependencies": {
+    "chai": "^4.3.4",
+    "mocha": "^9.0.3",
+    "ts-mocha": "^10.0.0",
+    "@types/bn.js": "^5.1.0",
+    "@types/chai": "^4.3.0",
+    "@types/mocha": "^9.0.0",
+    "typescript": "^4.3.5",
+    "prettier": "^2.6.2"
+  }
+}

+ 20 - 0
basics/hello-solana/poseidon/programs/poseidon/Cargo.toml

@@ -0,0 +1,20 @@
+[package]
+name = "poseidon"
+version = "0.1.0"
+description = "Created with Anchor"
+edition = "2021"
+
+[lib]
+crate-type = ["cdylib", "lib"]
+name = "poseidon"
+
+[features]
+default = []
+cpi = ["no-entrypoint"]
+no-entrypoint = []
+no-idl = []
+no-log-ix-name = []
+idl-build = ["anchor-lang/idl-build"]
+
+[dependencies]
+anchor-lang = "0.30.1"

+ 2 - 0
basics/hello-solana/poseidon/programs/poseidon/Xargo.toml

@@ -0,0 +1,2 @@
+[target.bpfel-unknown-unknown.dependencies.std]
+features = []

+ 16 - 0
basics/hello-solana/poseidon/programs/poseidon/src/lib.rs

@@ -0,0 +1,16 @@
+use anchor_lang::prelude::*;
+
+declare_id!("8krac1be77qraaZQGzHypmngXH6MbftjBmcucLtQLahG");
+
+#[program]
+pub mod poseidon {
+    use super::*;
+
+    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
+        msg!("Greetings from: {:?}", ctx.program_id);
+        Ok(())
+    }
+}
+
+#[derive(Accounts)]
+pub struct Initialize {}

+ 16 - 0
basics/hello-solana/poseidon/tests/poseidon.ts

@@ -0,0 +1,16 @@
+import * as anchor from '@coral-xyz/anchor';
+import { Program } from '@coral-xyz/anchor';
+import { Poseidon } from '../target/types/poseidon';
+
+describe('poseidon', () => {
+  // Configure the client to use the local cluster.
+  anchor.setProvider(anchor.AnchorProvider.env());
+
+  const program = anchor.workspace.Poseidon as Program<Poseidon>;
+
+  it('Is initialized!', async () => {
+    // Add your test here.
+    const tx = await program.methods.initialize().rpc();
+    console.log('Your transaction signature', tx);
+  });
+});

+ 15 - 0
basics/hello-solana/poseidon/ts-programs/package.json

@@ -0,0 +1,15 @@
+{
+  "name": "ts-programs",
+  "version": "1.0.0",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "description": "",
+  "dependencies": {
+    "@solanaturbine/poseidon": "^0.0.10"
+  }
+}

+ 9 - 0
basics/hello-solana/poseidon/ts-programs/src/poseidon.ts

@@ -0,0 +1,9 @@
+import { Pubkey, type Result } from '@solanaturbine/poseidon';
+
+export default class Poseidon {
+  static PROGRAM_ID = new Pubkey('8krac1be77qraaZQGzHypmngXH6MbftjBmcucLtQLahG');
+
+  initialize(): Result {
+    // Write your program here
+  }
+}

+ 10 - 0
basics/hello-solana/poseidon/tsconfig.json

@@ -0,0 +1,10 @@
+{
+  "compilerOptions": {
+    "types": ["mocha", "chai"],
+    "typeRoots": ["./node_modules/@types"],
+    "lib": ["es2015"],
+    "module": "commonjs",
+    "target": "es6",
+    "esModuleInterop": true
+  }
+}