Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
runtian-zhou committed Aug 1, 2024
1 parent 8b7486b commit 6d820a3
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 258 deletions.
123 changes: 108 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aptos-move/aptos-intent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ reqwest = { version = "*", features = ["blocking"] }

[dev-dependencies]
e2e-move-tests = { path = "../e2e-move-tests" }
aptos-types = { workspace = true }
aptos-types = { workspace = true }
25 changes: 14 additions & 11 deletions aptos-move/aptos-intent/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum BatchArgumentType {
PreviousResult,
}

#[wasm_bindgen]
#[wasm_bindgen(js_name = BatchArgument)]
/// Arguments for each function. Wasm bindgen only support C-style enum so use option to work around.
#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub struct BatchArgumentWASM {
Expand Down Expand Up @@ -93,6 +93,16 @@ impl BatchedFunctionCallBuilder {
)
.map_err(|err| format!("{:?}", err))
}

pub async fn load_module(
&mut self,
api_url: String,
module_name: String,
) -> Result<(), JsValue> {
self.load_module_impl(api_url, module_name)
.await
.map_err(|err| JsValue::from(format!("{:?}", err)))
}
}

fn find_function<'a>(
Expand All @@ -118,6 +128,9 @@ impl BatchedFunctionCallBuilder {
func_name: &IdentStr,
ty_args: &[TypeTag],
) -> anyhow::Result<Vec<BatchArgument>> {
if self.calls.is_empty() {
bail!("No calls exists in the builder yet");
}
let (module, handle) = find_function(&self.modules, module_id, func_name)?;
let mut returns = vec![];
for (idx, sig) in module.signature_at(handle.return_).0.iter().enumerate() {
Expand Down Expand Up @@ -357,16 +370,6 @@ impl BatchedFunctionCallBuilder {
}
}

pub async fn load_module(
&mut self,
api_url: String,
module_name: String,
) -> Result<(), JsValue> {
self.load_module_impl(api_url, module_name)
.await
.map_err(|err| JsValue::from(format!("{:?}", err)))
}

#[cfg(test)]
pub(crate) fn calls(&self) -> &[BatchedFunctionCall] {
&self.calls
Expand Down
Loading

0 comments on commit 6d820a3

Please sign in to comment.