Contract stubs

This commit is contained in:
Ladd Hoffman 2024-02-20 14:47:41 -06:00
parent b893f13f6b
commit b1349fb091
15 changed files with 198 additions and 0 deletions

3
.gitignore vendored Normal file
View File

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

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[workspace]
members = [
"validation-pool",
"availability",
"work-1",
]
default-members = [
"validation-pool",
"availability",
"work-1",
]
resolver = "2"
[profile.release]
codegen-units = 1
lto = true

49
Makefile Normal file
View File

@ -0,0 +1,49 @@
PINNED_TOOLCHAIN := $(shell cat rust-toolchain)
prepare:
rustup target add wasm32-unknown-unknown
rustup component add clippy --toolchain ${PINNED_TOOLCHAIN}
rustup component add rustfmt --toolchain ${PINNED_TOOLCHAIN}
.PHONY: build-contract
build-contract:
cargo build --release --target wasm32-unknown-unknown -p validation-pool
cargo build --release --target wasm32-unknown-unknown -p availability
cargo build --release --target wasm32-unknown-unknown -p work-1
wasm-strip target/wasm32-unknown-unknown/release/validation_pool.wasm
wasm-strip target/wasm32-unknown-unknown/release/availability.wasm
wasm-strip target/wasm32-unknown-unknown/release/work_1.wasm
setup-test: build-contract
mkdir -p tests/wasm
cp ./target/wasm32-unknown-unknown/release/validation_pool.wasm tests/wasm
cp ./target/wasm32-unknown-unknown/release/availability.wasm tests/wasm
cp ./target/wasm32-unknown-unknown/release/work_1.wasm tests/wasm
test: setup-test
cd tests && cargo test
clippy:
cd validation-pool && cargo clippy --all-targets -- -D warnings
cd availability && cargo clippy --all-targets -- -D warnings
cd work-1 && cargo clippy --all-targets -- -D warnings
cd tests && cargo clippy --all-targets -- -D warnings
check-lint: clippy
cd validation_pool && cargo fmt -- --check
cd availability && cargo fmt -- --check
cd work-1 && cargo fmt -- --check
cd tests && cargo fmt -- --check
lint: clippy
cd validation-pool && cargo fmt
cd availability && cargo fmt
cd work-1 && cargo fmt
cd tests && cargo fmt
clean:
cd validation-pool && cargo clean
cd availability && cargo clean
cd work-1 && cargo clean
cd tests && cargo clean
rm -rf tests/wasm

15
availability/Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "availability"
version = "0.1.0"
edition = "2021"
[dependencies]
casper-contract = "4.0.0"
casper-types = "4.0.1"
[[bin]]
name = "availability"
path = "src/main.rs"
bench = false
doctest = false
test = false

View File

@ -0,0 +1,4 @@
// Entry points
// Entry point: Stake availability toward one or more work contracts
// Entry point: Assign work
// Entry point: Get assigned work

23
availability/src/main.rs Normal file
View File

@ -0,0 +1,23 @@
#![no_std]
#![no_main]
pub mod entry_points;
#[no_mangle]
pub extern "C" fn stake_availability() {
}
#[no_mangle]
pub extern "C" fn assign_work() {
}
#[no_mangle]
pub extern "C" fn get_assigned_work() {
}
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}

1
rust-toolchain Normal file
View File

@ -0,0 +1 @@
nightly-2023-01-09

View File

@ -0,0 +1,17 @@
[package]
name = "validation-pool"
version = "0.1.0"
edition = "2021"
[dependencies]
casper-contract = "4.0.0"
casper-types = "4.0.1"
[[bin]]
name = "validation_pool"
path = "src/main.rs"
bench = false
doctest = false
test = false

View File

@ -0,0 +1,4 @@
// Entry points
// Entry point: Initiate Validation Pool
// Entry point: Stake REP in Validation Pool
// Entry point: Evaluate outcome of Validation Pool

View File

@ -0,0 +1,23 @@
#![no_std]
#![no_main]
pub mod entry_points;
#[no_mangle]
pub extern "C" fn initiate_validation_pool() {
}
#[no_mangle]
pub extern "C" fn stake() {
}
#[no_mangle]
pub extern "C" fn evaluate_outcome() {
}
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}

15
work-1/Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "work-1"
version = "0.1.0"
edition = "2021"
[dependencies]
casper-contract = "4.0.0"
casper-types = "4.0.1"
[[bin]]
name = "work_1"
path = "src/main.rs"
bench = false
doctest = false
test = false

0
work-1/README.md Normal file
View File

1
work-1/rust-toolchain Normal file
View File

@ -0,0 +1 @@
stable

View File

@ -0,0 +1,4 @@
// Entry points
// Entry point: Customer sends CSPR to request work
// Entry point: Worker submits work evidence
// Entry point: Customer submits satisfied/unsatisfied

23
work-1/src/main.rs Normal file
View File

@ -0,0 +1,23 @@
#![no_std]
#![no_main]
pub mod entry_points;
#[no_mangle]
pub extern "C" fn request_work() {
}
#[no_mangle]
pub extern "C" fn submit_work_evidence() {
}
#[no_mangle]
pub extern "C" fn submit_customer_satisfaction() {
}
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}