This commit is contained in:
Armani Ferrante 2022-01-10 18:19:48 -05:00
commit 5069145267
No known key found for this signature in database
GPG Key ID: D597A80BCF8E12B7
12 changed files with 2687 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.anchor
.DS_Store
target
**/*.rs.bk
node_modules

12
Anchor.toml Normal file
View File

@ -0,0 +1,12 @@
[programs.localnet]
raw = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
[registry]
url = "https://anchor.projectserum.com"
[provider]
cluster = "localnet"
wallet = "/home/armaniferrante/.config/solana/id.json"
[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

1354
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

4
Cargo.toml Normal file
View File

@ -0,0 +1,4 @@
[workspace]
members = [
"programs/*"
]

12
migrations/deploy.ts Normal file
View File

@ -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("@project-serum/anchor");
module.exports = async function (provider) {
// Configure client to use the provider.
anchor.setProvider(provider);
// Add your deploy script here.
}

12
package.json Normal file
View File

@ -0,0 +1,12 @@
{
"dependencies": {
"@project-serum/anchor": "^0.20.0"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^8.0.0",
"@types/mocha": "^9.0.0",
"typescript": "^4.3.5"
}
}

View File

@ -0,0 +1,20 @@
[package]
name = "owner-checks-1"
version = "0.1.0"
description = "Created with Anchor"
edition = "2018"
[lib]
crate-type = ["cdylib", "lib"]
name = "owner_checks_1"
[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []
[dependencies]
anchor-lang = "0.20.1"
anchor-spl = "0.20.1"

View File

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

View File

@ -0,0 +1,42 @@
use anchor_lang::prelude::*;
use anchor_spl::token::{Token, TokenAccount};
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod owner_checks_1 {
use super::*;
pub fn create_user(ctx: Context<CreateUser>) -> ProgramResult {
let user = &mut ctx.accounts.user;
user.authority = ctx.accounts.authority.key();
Ok(())
}
pub fn log_message(ctx: Context<LogMessage>) -> ProgramResult {
let token = &ctx.accounts.token;
Ok(())
}
}
#[derive(Accounts)]
pub struct CreateUser<'info> {
#[account(init, payer = authority, space = 8+32)]
user: Account<'info, User>,
#[account(init, payer = authority, space = TokenAccount::LEN)]
token: Account<'info, TokenAccount>,
#[account(mut)]
authority: Signer<'info>,
token_program: Program<'info, Token>,
system_program: Program<'info, System>,
}
#[derive(Accounts)]
pub struct LogMessage<'info> {
token: AccountInfo<'info>,
}
#[account]
pub struct User {
authority: Pubkey,
}

16
tests/raw.ts Normal file
View File

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

10
tsconfig.json Normal file
View File

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

1197
yarn.lock Normal file

File diff suppressed because it is too large Load Diff