remove contracts
This commit is contained in:
parent
52addd2eb3
commit
21e8ea6f07
6
contracts/.gitignore
vendored
6
contracts/.gitignore
vendored
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
.anchor
|
|
||||||
.DS_Store
|
|
||||||
target
|
|
||||||
**/*.rs.bk
|
|
||||||
node_modules
|
|
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": false,
|
|
||||||
"trailingComma": "es5",
|
|
||||||
"singleQuote": true
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
[programs.localnet]
|
|
||||||
dpm = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
|
|
||||||
|
|
||||||
[registry]
|
|
||||||
url = "https://anchor.projectserum.com"
|
|
||||||
|
|
||||||
[provider]
|
|
||||||
cluster = "localnet"
|
|
||||||
wallet = "/Users/jahooma/.config/solana/id.json"
|
|
||||||
|
|
||||||
[scripts]
|
|
||||||
test = "yarn run mocha -t 1000000 tests/"
|
|
1105
contracts/Cargo.lock
generated
1105
contracts/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +0,0 @@
|
||||||
[workspace]
|
|
||||||
members = [
|
|
||||||
"programs/*"
|
|
||||||
]
|
|
|
@ -1,12 +0,0 @@
|
||||||
// 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.
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"@project-serum/anchor": "^0.18.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"chai": "^4.3.4",
|
|
||||||
"mocha": "^9.0.3"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "dpm"
|
|
||||||
version = "0.1.0"
|
|
||||||
description = "Created with Anchor"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib", "lib"]
|
|
||||||
name = "dpm"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
no-entrypoint = []
|
|
||||||
no-idl = []
|
|
||||||
no-log-ix-name = []
|
|
||||||
cpi = ["no-entrypoint"]
|
|
||||||
default = []
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anchor-lang = "0.18.2"
|
|
|
@ -1,2 +0,0 @@
|
||||||
[target.bpfel-unknown-unknown.dependencies.std]
|
|
||||||
features = []
|
|
|
@ -1,92 +0,0 @@
|
||||||
use anchor_lang::prelude::*;
|
|
||||||
|
|
||||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|
||||||
|
|
||||||
#[program]
|
|
||||||
pub mod dpm {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
pub fn create_contract(ctx: Context<CreateContract>, props: NewContractProps) -> ProgramResult {
|
|
||||||
let contract = &mut ctx.accounts.contract;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn place_bet(ctx: Context<PlaceBet>, props: BetProps) -> ProgramResult {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
|
||||||
pub struct NewContractProps {
|
|
||||||
pub id: String,
|
|
||||||
pub creator_id: String,
|
|
||||||
pub question: String,
|
|
||||||
pub description: String,
|
|
||||||
pub seed_amounts: SeedAmounts,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Accounts)]
|
|
||||||
pub struct CreateContract<'info> {
|
|
||||||
#[account(init, payer = creator, space = 9000)]
|
|
||||||
pub contract: Account<'info, Contract>,
|
|
||||||
|
|
||||||
#[account(mut)]
|
|
||||||
pub creator: Signer<'info>,
|
|
||||||
|
|
||||||
pub system_program: Program<'info, System>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
|
||||||
pub struct BetProps {
|
|
||||||
pub amount: u64,
|
|
||||||
pub user_id: String,
|
|
||||||
pub outcome: BetOutcome,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Accounts)]
|
|
||||||
pub struct PlaceBet<'info> {
|
|
||||||
#[account(mut)]
|
|
||||||
pub contract: Account<'info, Contract>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
|
||||||
pub enum BetOutcome {
|
|
||||||
Yes,
|
|
||||||
No,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
|
||||||
pub enum ResolutionOutcome {
|
|
||||||
Yes,
|
|
||||||
No,
|
|
||||||
Cancel,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
|
||||||
pub struct SeedAmounts {
|
|
||||||
yes: u64,
|
|
||||||
no: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
|
||||||
pub struct Resolution {
|
|
||||||
time: u64,
|
|
||||||
outcome: ResolutionOutcome,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[account]
|
|
||||||
pub struct Contract {
|
|
||||||
pub id: String,
|
|
||||||
pub creator_id: String,
|
|
||||||
pub question: String,
|
|
||||||
pub description: String,
|
|
||||||
pub seed_amounts: SeedAmounts,
|
|
||||||
|
|
||||||
pub created_time: u64,
|
|
||||||
pub last_updated_time: u64,
|
|
||||||
|
|
||||||
pub resolution: Option<Resolution>
|
|
||||||
|
|
||||||
// pub bets: Vec<Bet>
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
const anchor = require('@project-serum/anchor')
|
|
||||||
|
|
||||||
const { SystemProgram } = anchor.web3
|
|
||||||
|
|
||||||
const main = async () => {
|
|
||||||
console.log('🚀 Starting test...')
|
|
||||||
|
|
||||||
const provider = anchor.Provider.env()
|
|
||||||
anchor.setProvider(provider)
|
|
||||||
|
|
||||||
const program = anchor.workspace.Dpm
|
|
||||||
|
|
||||||
// Create an account keypair for our program to use.
|
|
||||||
const baseAccount = anchor.web3.Keypair.generate()
|
|
||||||
|
|
||||||
const tx = await program.rpc.initialize({
|
|
||||||
accounts: {
|
|
||||||
contract: baseAccount.publicKey,
|
|
||||||
user: provider.wallet.publicKey,
|
|
||||||
systemProgram: SystemProgram.programId,
|
|
||||||
},
|
|
||||||
signers: [baseAccount],
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log('📝 Your transaction signature', tx)
|
|
||||||
|
|
||||||
let account = await program.account.contract.fetch(baseAccount.publicKey)
|
|
||||||
console.log('👀 Bets Count', account.bets.toString())
|
|
||||||
|
|
||||||
await program.rpc.addBet({
|
|
||||||
accounts: {
|
|
||||||
contract: baseAccount.publicKey,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
account = await program.account.contract.fetch(baseAccount.publicKey)
|
|
||||||
console.log('👀 Bets Count', account.bets.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
const runMain = async () => {
|
|
||||||
try {
|
|
||||||
await main()
|
|
||||||
process.exit(0)
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
runMain()
|
|
1092
contracts/yarn.lock
1092
contracts/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user