Skip to content

Commit

Permalink
use oracle component lib later!
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-ps-2003 committed Nov 22, 2024
1 parent 0c25352 commit ee7e0bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ miden-objects = { version = "0.6.1", default-features = false }
miden-tx = { version = "0.6", features = ["testing"] }
miden-air = { version = "0.11", default-features = false }
miden-cli = { version = "0.6" }
miden-assembly = { version = "0.11.0", default-features = false }

rusqlite = { version = "0.32", features = ["vtab", "array", "bundled"]}
rand = "0.8"
Expand Down
25 changes: 22 additions & 3 deletions src/accounts/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ use miden_objects::{
Account, AccountBuilder, AccountCode, AccountComponent, AccountId, AccountStorage,
AccountStorageMode, AccountType, AuthSecretKey, StorageSlot,
},
assembly::{Assembler, Library, LibraryNamespace, LibraryPath},
assembly::{Assembler, Library, LibraryNamespace, LibraryPath, DefaultSourceManager},
transaction::{TransactionArgs, TransactionScript},
AccountError, Word,
};
use miden_assembly::ast::{Module, ModuleKind};
use miden_tx::{
auth::{BasicAuthenticator, TransactionAuthenticator},
TransactionExecutor,
Expand All @@ -24,15 +25,33 @@ use std::collections::BTreeMap;
use std::error::Error as StdError;
use std::fmt;
use std::str::FromStr;
use std::sync::Arc;
use std::sync::{Arc, LazyLock};
use std::{
env, io,
path::{Path, PathBuf},
};

// Include the oracle module source code
// pub const PUSH_ORACLE_PATH: &str = "src/accounts/oracle/push_oracle.masm";
// pub const READ_ORACLE_PATH: &str = "src/accounts/oracle/read_oracle.masm";
// pub const READ_ORACLE_PATH: &str = "src/accounts/oracle/read_oracle.masm"

// TODO: use component library instead of directly calling procedures
pub static ORACLE_COMPONENT_LIBRARY: LazyLock<Library> = LazyLock::new(|| {
let assembler = TransactionKernel::assembler().with_debug_mode(true);

let source_manager = Arc::new(DefaultSourceManager::default());
let oracle_component_module = Module::parser(ModuleKind::Library)
.parse_str(
LibraryPath::new("oracle_component::oracle_module").unwrap(),
SOURCE_CODE,
&source_manager,
)
.unwrap();

assembler
.assemble_library([oracle_component_module])
.expect("assembly should succeed")
});

/// Transaction script template for pushing data to oracle
pub const PUSH_DATA_TX_SCRIPT: &str = r#"
Expand Down

0 comments on commit ee7e0bd

Please sign in to comment.