fix: remove deprecated bpf-sdk, localnet, and examples

BREAKING CHANGE: Removed binaries solana-localnet and solana-bpf-sdk-install.
Please install the Solana CLI tools to download the BPF SDK and to
install the solana-test-validator binary intead.
This commit is contained in:
Justin Starry
2021-03-15 15:35:41 +08:00
committed by Justin Starry
parent f46f346710
commit e9b08b5e7f
26 changed files with 33 additions and 472 deletions

View File

@ -0,0 +1,3 @@
/target/
Cargo.lock

View File

@ -0,0 +1,23 @@
[package]
name = "solana-bpf-rust-noop"
version = "0.1.0"
description = "Solana BPF noop program written in Rust"
authors = ["Solana Maintainers <maintainers@solana.com>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-bpf-rust-noop"
edition = "2018"
[dependencies]
num-derive = "0.2"
num-traits = "0.2"
solana-program = "1.4.16"
thiserror = "1.0"
[workspace]
members = []
[lib]
name = "solana_bpf_rust_noop"
crate-type = ["cdylib"]

View File

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

7
web3.js/test/fixtures/noop-program/build.sh vendored Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -ex
cd "$(dirname "$0")"
cargo build-bpf
cp ./target/deploy/solana_bpf_rust_noop.so .

Binary file not shown.

View File

@ -0,0 +1,70 @@
//! @brief Example Rust-based BPF program that prints out the parameters passed to it
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, log::*, pubkey::Pubkey,
};
#[derive(Debug, PartialEq)]
struct SStruct {
x: u64,
y: u64,
z: u64,
}
#[inline(never)]
fn return_sstruct() -> SStruct {
SStruct { x: 1, y: 2, z: 3 }
}
entrypoint!(process_instruction);
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
msg!("Program identifier:");
program_id.log();
// Log the provided account keys and instruction input data. In the case of
// the no-op program, no account keys or input data are expected but real
// programs will have specific requirements so they can do their work.
msg!("Account keys and instruction input data:");
sol_log_params(accounts, instruction_data);
{
// Test - use std methods, unwrap
// valid bytes, in a stack-allocated array
let sparkle_heart = [240, 159, 146, 150];
let result_str = std::str::from_utf8(&sparkle_heart).unwrap();
assert_eq!(4, result_str.len());
assert_eq!("💖", result_str);
msg!(result_str);
}
{
// Test - struct return
let s = return_sstruct();
assert_eq!(s.x + s.y + s.z, 6);
}
{
// Test - arch config
#[cfg(not(target_arch = "bpf"))]
panic!();
}
Ok(())
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_return_sstruct() {
assert_eq!(SStruct { x: 1, y: 2, z: 3 }, return_sstruct());
}
}