Add assert-owner program
This commit is contained in:
parent
5adf8799ae
commit
6138ca9828
|
@ -3030,6 +3030,13 @@ dependencies = [
|
|||
"tokio 0.2.22",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serum_assert_owner"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"solana-program",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serum_dex"
|
||||
version = "0.2.0"
|
||||
|
@ -3393,10 +3400,43 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.3.15"
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2a5735685cdfabd2f9e78590d078ffdd8db89e90f2f22136ad37cb3d4c89dfc"
|
||||
checksum = "63bbbf3bf442bc7e4e76b57af858030fdcb8953cdbcbc6bf3ddd4819aa38e982"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"bv",
|
||||
"generic-array 0.14.4",
|
||||
"log",
|
||||
"memmap",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdb4a177d5f46025b619c83d0562e6ea302a871f98148bd7edbc82416ac76949"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.7",
|
||||
"rustc_version",
|
||||
"syn 1.0.42",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8f251c26d46a55bf5c3f6ef5e999e8949909eab952e19a9261e6434ebd31041"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -3453,6 +3493,36 @@ dependencies = [
|
|||
"url 2.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-program"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d4621f2d8ca6d7ac09c0138a02d21def0a736b70feab1f2516f5a74f1ee642f"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bs58",
|
||||
"bv",
|
||||
"curve25519-dalek",
|
||||
"hex",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"rand 0.7.3",
|
||||
"rustc_version",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"sha2",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-logger",
|
||||
"solana-sdk-macro",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.3.15"
|
||||
|
@ -3575,9 +3645,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.3.15"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57463935ec0091ef806eb58272f8a6abd1bb23df6c13419bfd8e3f03d27ef079"
|
||||
checksum = "a02d89c5d8c3c098552e39ad716f8e25b1b9ce95905ad0c770c78d36e1ebcc39"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2 1.0.24",
|
||||
|
|
|
@ -17,6 +17,7 @@ members = [
|
|||
"node/context",
|
||||
"node/dev",
|
||||
"lockup/tests/stake",
|
||||
"assert-owner",
|
||||
]
|
||||
exclude = [
|
||||
"dex",
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "serum_assert_owner"
|
||||
version = "0.1.0"
|
||||
repository = "https://github.com/project-serum/serum-dex"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-program = "1.4.3"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
name = "serum_assert_owner"
|
||||
|
||||
[dev-dependencies]
|
|
@ -0,0 +1 @@
|
|||
Build with `cargo build-bpf`, after installing v1.4.3 of the solana cli
|
|
@ -0,0 +1,2 @@
|
|||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
|
@ -0,0 +1 @@
|
|||
4MNPdKu9wFMvEeZBMt3Eipfs5ovVWTJb31pEXDJAAxX5
|
|
@ -0,0 +1,26 @@
|
|||
use solana_program::{
|
||||
pubkey::Pubkey,
|
||||
account_info::AccountInfo,
|
||||
program_error::ProgramError,
|
||||
entrypoint::ProgramResult,
|
||||
info,
|
||||
entrypoint,
|
||||
};
|
||||
|
||||
entrypoint!(entry);
|
||||
fn entry(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
instruction_data: &[u8],
|
||||
) -> ProgramResult {
|
||||
let account = accounts.get(0).ok_or(ProgramError::NotEnoughAccountKeys)?;
|
||||
if instruction_data.len() != 32 {
|
||||
return Err(ProgramError::InvalidInstructionData);
|
||||
}
|
||||
let expected_owner = Pubkey::new(instruction_data);
|
||||
if expected_owner != *account.owner {
|
||||
info!("Account owner mismatch");
|
||||
return Err(ProgramError::Custom(0x100));
|
||||
}
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in New Issue