example/dummy-contract: Fix paths

This commit is contained in:
parazyd
2024-01-08 12:47:22 +01:00
parent b9f8ffa16d
commit 64377fe908
4 changed files with 26 additions and 5 deletions

2
example/dummy-contract/.gitignore vendored Normal file
View File

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

View File

@@ -30,3 +30,7 @@ path = "src/runtime.rs"
[features]
default = []
no-entrypoint = []
[patch.crates-io]
halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"}
halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"}

View File

@@ -16,7 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use darkfi_sdk::{crypto::ContractId, error::ContractResult};
use darkfi_sdk::{
crypto::ContractId,
db::{db_init, db_lookup},
error::ContractResult,
};
darkfi_sdk::define_contract!(
init: init_contract,
@@ -25,8 +29,12 @@ darkfi_sdk::define_contract!(
metadata: get_metadata
);
fn init_contract(_cid: ContractId, _ix: &[u8]) -> ContractResult {
//panic!("ohai");
fn init_contract(cid: ContractId, _ix: &[u8]) -> ContractResult {
let db = match db_lookup(cid, "dummy_db") {
Ok(v) => v,
Err(_) => db_init(cid, "dummy_db")?,
};
Ok(())
}
@@ -34,7 +42,9 @@ fn get_metadata(_cid: ContractId, _ix: &[u8]) -> ContractResult {
Ok(())
}
fn process_instruction(_cid: ContractId, _ix: &[u8]) -> ContractResult {
fn process_instruction(cid: ContractId, _ix: &[u8]) -> ContractResult {
let db = db_lookup(cid, "dummy_db")?;
Ok(())
}

View File

@@ -46,7 +46,7 @@ fn main() {
let timekeeper = TimeKeeper::new(Timestamp::current_time(), 10, 90, 0);
let wasm_bytes =
include_bytes!("../../../target/wasm32-unknown-unknown/release/darkfi_dummy_contract.wasm");
include_bytes!("../target/wasm32-unknown-unknown/release/darkfi_dummy_contract.wasm");
let contract_id = ContractId::from(pallas::Base::from(69));
@@ -55,4 +55,9 @@ fn main() {
Ok(()) => {}
Err(e) => println!("Error running deploy: {:#?}", e),
}
match runtime.exec(&[]) {
Ok(_) => {}
Err(e) => println!("Error running exec: {:#?}", e),
}
}