Skip to content

Commit

Permalink
chore: dep updates (#19)
Browse files Browse the repository at this point in the history
* chore: dep updates

* ci: speed up arm64-glibc test

* Revert "ci: speed up arm64-glibc test"

This reverts commit 644e817.
zone117x authored Jul 2, 2024
1 parent 60bf018 commit 84badb5
Showing 9 changed files with 140 additions and 84 deletions.
186 changes: 121 additions & 65 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ sha2 = { version = "0.10", features = ["asm"] }
sha2 = { version = "0.10" }

[dependencies.neon]
version = "0.10.0"
version = "1.0.0"
# git = "https://github.com/zone117x/neon"
# rev = "bdb936a7fba8fb932fc61cbe529e06f65f75f9d9"
default-features = false
14 changes: 7 additions & 7 deletions package-lock.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
},
"devDependencies": {
"@types/jest": "^27.4.1",
"cargo-cp-artifact": "^0.1",
"cargo-cp-artifact": "^0.1.9",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
2 changes: 1 addition & 1 deletion src/clarity_value/mod.rs
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ pub fn decode_clarity_value_array(mut cx: FunctionContext) -> JsResult<JsArray>
0
};

let array_result = JsArray::new(&mut cx, result_length);
let array_result = JsArray::new(&mut cx, result_length as usize);

let deep: bool = match cx.argument_opt(1) {
Some(arg) => arg
2 changes: 1 addition & 1 deletion src/clarity_value/neon_encoder.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ pub fn decode_clarity_val<T: AsRef<[u8]>>(
cur_obj.set(cx, "buffer", obj_buffer)?;
}
List(data) => {
let list_obj = JsArray::new(cx, data.len() as u32);
let list_obj = JsArray::new(cx, data.len());
for (i, x) in data.iter().enumerate() {
let item_obj = cx.empty_object();
decode_clarity_val(
10 changes: 5 additions & 5 deletions src/neon_util.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ pub fn eval<'a, 'b, C: Context<'a>>(

#[allow(dead_code)]
pub fn console_log<'a, C: Context<'a>, S: AsRef<str>>(cx: &mut C, msg: S) -> NeonResult<()> {
let console_global: Handle<JsObject> = cx.global().get(cx, "console")?;
let console_global: Handle<JsObject> = cx.global::<JsObject>("console")?;
let log_fn: Handle<JsFunction> = console_global.get(cx, "log")?;
log_fn
.call_with(cx)
@@ -36,7 +36,7 @@ pub fn console_log<'a, C: Context<'a>, S: AsRef<str>>(cx: &mut C, msg: S) -> Neo

#[allow(dead_code)]
pub fn console_log_val(cx: &mut FunctionContext, msg: Handle<JsValue>) -> NeonResult<()> {
let console_global: Handle<JsObject> = cx.global().get(cx, "console")?;
let console_global: Handle<JsObject> = cx.global::<JsObject>("console")?;
let log_fn: Handle<JsFunction> = console_global.get(cx, "log")?;
log_fn.call_with(cx).arg(msg).apply::<JsValue, _>(cx)?;
Ok(())
@@ -47,14 +47,14 @@ pub fn json_parse<'a, C: Context<'a>, S: AsRef<str>>(
cx: &mut C,
input: S,
) -> NeonResult<Handle<'a, JsValue>> {
let json_global: Handle<JsObject> = cx.global().get(cx, "JSON")?;
let json_global: Handle<JsObject> = cx.global::<JsObject>("JSON")?;
let json_parse: Handle<JsFunction> = json_global.get(cx, "parse")?;
let result: Handle<JsValue> = json_parse.call_with(cx).arg(cx.string(input)).apply(cx)?;
Ok(result)
}

pub fn arg_as_bytes_copied(cx: &mut FunctionContext, arg_index: i32) -> NeonResult<Box<[u8]>> {
let input_arg: Handle<JsValue> = cx.argument(arg_index)?;
let input_arg: Handle<JsValue> = cx.argument(arg_index as usize)?;
if let Ok(handle) = input_arg.downcast::<JsString, _>(cx) {
let val_bytes = decode_hex(handle.value(cx))
.or_else(|e| cx.throw_error(format!("Hex parsing error: {}", e)))?;
@@ -73,7 +73,7 @@ where
F: Fn(&[u8]) -> Result<T, String>,
{
let input_arg: Handle<JsValue> = cx
.argument(arg_index)
.argument(arg_index as usize)
.or_else(|e| Err(format!("Error getting function arg {}: {}", arg_index, e)))?;
if let Ok(handle) = input_arg.downcast::<JsString, _>(cx) {
let val_bytes =
2 changes: 1 addition & 1 deletion src/post_condition/mod.rs
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ pub fn decode_tx_post_conditions(mut cx: FunctionContext) -> JsResult<JsObject>
e
))
})?);
let array_result = JsArray::new(&mut cx, result_length);
let array_result = JsArray::new(&mut cx, result_length as usize);
// next bytes are serialized post condition items
let post_condition_bytes = &input_bytes[5..];
let post_condition_bytes_len = post_condition_bytes.len() as u64;
4 changes: 2 additions & 2 deletions src/stacks_tx/neon_encoder.rs
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ impl NeonJsSerialize for StacksTransaction {
let post_condition_mode = cx.number(self.post_condition_mode as u8);
obj.set(cx, "post_condition_mode", post_condition_mode)?;

let post_conditions = JsArray::new(cx, self.post_conditions.len() as u32);
let post_conditions = JsArray::new(cx, self.post_conditions.len());
for (i, x) in self.post_conditions.iter().enumerate() {
let post_condition_obj = cx.empty_object();
x.neon_js_serialize(cx, &post_condition_obj)?;
@@ -616,7 +616,7 @@ impl NeonJsSerialize for TransactionContractCall {
obj.set(cx, "function_name", function_name)?;

let mut function_args_raw = u32::to_be_bytes(self.function_args.len() as u32).to_vec();
let function_args = JsArray::new(cx, self.function_args.len() as u32);
let function_args = JsArray::new(cx, self.function_args.len());
for (i, clarity_val) in self.function_args.iter().enumerate() {
let val_obj = cx.empty_object();
function_args_raw.extend_from_slice(&clarity_val.serialized_bytes.as_ref().unwrap());

0 comments on commit 84badb5

Please sign in to comment.