Skip to content

Commit

Permalink
feat: Adding remote proving + improving note models
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-demox committed Oct 30, 2024
1 parent b1c79f4 commit 491e8ef
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.6.0 (TBD)

* Added delegated proving for web client + improved note models (#566).
* Allow to set expiration delta for `TransactionRequest` (#553).
* Added WASM consumable notes API + improved note models (#561).
* [BREAKING] Refactored `OutputNoteRecord` to use states and transitions for updates (#551).
Expand Down
1 change: 1 addition & 0 deletions crates/web-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ getrandom = { version = "0.2", features = ["js"] }
miden-client = { path = "../rust-client", version = "0.5", default-features = false, features = ["idxdb", "web-tonic", "testing"] }
miden-lib = { workspace = true }
miden-objects = { workspace = true }
miden-tx-prover = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", features = ["async", "testing"], default-features = false }
rand = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/web-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@demox-labs/miden-sdk",
"version": "0.0.16",
"version": "0.0.17",
"description": "Polygon Miden Wasm SDK",
"collaborators": [
"Polygon Miden",
Expand Down
14 changes: 11 additions & 3 deletions crates/web-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ use alloc::sync::Arc;
use miden_client::{
rpc::WebTonicRpcClient,
store::{web_store::WebStore, StoreAuthenticator},
transactions::LocalTransactionProver,
transactions::{LocalTransactionProver, TransactionProver},
Client,
};
use miden_objects::{crypto::rand::RpoRandomCoin, Felt};
use miden_tx_prover::RemoteTransactionProver;
use rand::{rngs::StdRng, Rng, SeedableRng};
use wasm_bindgen::prelude::*;

Expand Down Expand Up @@ -45,7 +46,11 @@ impl WebClient {
self.inner.as_mut()
}

pub async fn create_client(&mut self, node_url: Option<String>) -> Result<JsValue, JsValue> {
pub async fn create_client(
&mut self,
node_url: Option<String>,
proving_url: Option<String>,
) -> Result<JsValue, JsValue> {
let mut rng = StdRng::from_entropy();
let coin_seed: [u64; 4] = rng.gen();

Expand All @@ -59,7 +64,10 @@ impl WebClient {
&node_url.unwrap_or_else(|| "http://18.203.155.106:57291".to_string()),
));

let tx_prover = Arc::new(LocalTransactionProver::default());
let tx_prover: Arc<dyn TransactionProver> = match proving_url {
Some(proving_url) => Arc::new(RemoteTransactionProver::new(&proving_url.to_string())),
None => Arc::new(LocalTransactionProver::new(Default::default())),
};

self.inner = Some(Client::new(
web_rpc_client,
Expand Down
12 changes: 11 additions & 1 deletion crates/web-client/src/models/input_note_record.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use miden_client::store::InputNoteRecord as NativeInputNoteRecord;
use wasm_bindgen::prelude::*;

use super::{input_note_state::InputNoteState, note_details::NoteDetails, note_id::NoteId};
use super::{
input_note_state::InputNoteState, note_details::NoteDetails, note_id::NoteId,
note_metadata::NoteMetadata,
};

#[derive(Clone)]
#[wasm_bindgen]
Expand All @@ -20,6 +23,13 @@ impl InputNoteRecord {
pub fn details(&self) -> NoteDetails {
self.0.details().into()
}

pub fn metadata(&self) -> Option<NoteMetadata> {
match self.0.metadata() {
Some(metadata) => Some(metadata.into()),
None => None,
}
}
}

// CONVERSIONS
Expand Down

0 comments on commit 491e8ef

Please sign in to comment.