Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenized vaults example #1182

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
21 changes: 21 additions & 0 deletions x/programs/rust/examples/vault/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "vault"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[features]
bindings = []

[dependencies]
wasmlanche-sdk = { workspace = true, features = ["debug"] }
borsh = { workspace = true }
token = { path = "../token", features = ["bindings"] }

[dev-dependencies]
simulator = { workspace = true }

[build-dependencies]
wasmlanche-sdk = { workspace = true, features = ["build"] }
31 changes: 31 additions & 0 deletions x/programs/rust/examples/vault/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

use std::path::Path;

fn main() {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let package_name = std::env::var("CARGO_PKG_NAME").unwrap();
let path = Path::new(&manifest_dir)
.canonicalize()
.expect("failed to canonicalize path");
let token_package_name = "token";
let token_manifest_dir = path
.parent()
.map(|p| p.join(token_package_name))
.expect("failed to find token manifest path");

// # Safety
// This is safe to call in a single-threaded program
unsafe {
std::env::set_var("CARGO_MANIFEST_DIR", token_manifest_dir);
std::env::set_var("CARGO_PKG_NAME", token_package_name);
}
wasmlanche_sdk::build::build_wasm_on_test();

unsafe {
std::env::set_var("CARGO_MANIFEST_DIR", manifest_dir);
std::env::set_var("CARGO_PKG_NAME", package_name);
}
wasmlanche_sdk::build::build_wasm_on_test();
}
Loading
Loading