Skip to content

add: basic/program-derived-addresses/seahorse #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions basics/program-derived-addresses/seahorse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.anchor
.DS_Store
target
**/*.rs.bk
node_modules
test-ledger
.yarn
7 changes: 7 additions & 0 deletions basics/program-derived-addresses/seahorse/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.anchor
.DS_Store
target
node_modules
dist
build
test-ledger
19 changes: 19 additions & 0 deletions basics/program-derived-addresses/seahorse/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[toolchain]

[features]
resolution = true
skip-lint = false
seeds = true

[programs.localnet]
program_derived_addresses_seahorse = "3AZUzzM9zVoeW1gmkjUYaWWGvHSvmmsajtzJLcgGcEQP"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
14 changes: 14 additions & 0 deletions basics/program-derived-addresses/seahorse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions basics/program-derived-addresses/seahorse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# program_derived_addresses_seahorse

This project was created by Seahorse 0.2.0.

To get started, just add your code to **programs_py/program_derived_addresses_seahorse.py** and run `seahorse build`.
12 changes: 12 additions & 0 deletions basics/program-derived-addresses/seahorse/migrations/deploy.ts
Original file line number Diff line number Diff line change
@@ -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 function (provider) {
// Configure client to use the provider.
anchor.setProvider(provider);

// Add your deploy script here.
};
20 changes: 20 additions & 0 deletions basics/program-derived-addresses/seahorse/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "program_derived_addresses_seahorse"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "program_derived_addresses_seahorse"

[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"
anchor-spl = "0.30.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod program;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(unused_mut)]
use crate::{id, seahorse_util::*};
use anchor_lang::{prelude::*, solana_program};
use anchor_spl::token::{self, Mint, Token, TokenAccount};
use std::{cell::RefCell, rc::Rc};

#[account]
#[derive(Debug)]
pub struct PageVisits {
pub visits: u32,
}

impl<'info, 'entrypoint> PageVisits {
pub fn load(
account: &'entrypoint mut Box<Account<'info, Self>>,
programs_map: &'entrypoint ProgramsMap<'info>,
) -> Mutable<LoadedPageVisits<'info, 'entrypoint>> {
let visits = account.visits;

Mutable::new(LoadedPageVisits {
__account__: account,
__programs__: programs_map,
visits,
})
}

pub fn store(loaded: Mutable<LoadedPageVisits>) {
let mut loaded = loaded.borrow_mut();
let visits = loaded.visits;

loaded.__account__.visits = visits;
}
}

#[derive(Debug)]
pub struct LoadedPageVisits<'info, 'entrypoint> {
pub __account__: &'entrypoint mut Box<Account<'info, PageVisits>>,
pub __programs__: &'entrypoint ProgramsMap<'info>,
pub visits: u32,
}

pub fn create_page_visits_handler<'info>(
mut owner: SeahorseSigner<'info, '_>,
mut page_visits: Empty<Mutable<LoadedPageVisits<'info, '_>>>,
) -> () {
page_visits.account.clone();
}

pub fn increment_page_visits_handler<'info>(
mut page_visits: Mutable<LoadedPageVisits<'info, '_>>,
) -> () {
assign!(
page_visits.borrow_mut().visits,
page_visits.borrow().visits + 1
);
}
Loading