Skip to content

Commit

Permalink
feat: Adding remote proving + improving note models (0xPolygonMiden#566)
Browse files Browse the repository at this point in the history
* feat: Adding remote proving + improving note models

* exposing further get apis on input note + cleanup
  • Loading branch information
julian-demox authored Nov 1, 2024
1 parent c1c69eb commit 0924d28
Show file tree
Hide file tree
Showing 5 changed files with 46 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
33 changes: 32 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_inclusion_proof::NoteInclusionProof, note_metadata::NoteMetadata,
};

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

pub fn metadata(&self) -> Option<NoteMetadata> {
self.0.metadata().map(|metadata| metadata.into())
}

pub fn inclusion_proof(&self) -> Option<NoteInclusionProof> {
self.0.inclusion_proof().map(|proof| proof.into())
}

pub fn consumer_transaction_id(&self) -> Option<String> {
self.0.consumer_transaction_id().map(|id| id.to_string())
}

pub fn nullifier(&self) -> String {
self.0.nullifier().to_hex()
}

pub fn is_authenticated(&self) -> bool {
self.0.is_authenticated()
}

pub fn is_consumed(&self) -> bool {
self.0.is_consumed()
}

pub fn is_processing(&self) -> bool {
self.0.is_processing()
}
}

// CONVERSIONS
Expand Down

0 comments on commit 0924d28

Please sign in to comment.