Skip to content

Commit

Permalink
feat: add get nonce to wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Aug 8, 2024
1 parent 8bb7430 commit 97989e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@ cdef extern from *:

FieldElement poseidon_hash(const FieldElement *felts, uintptr_t felts_len);

ResultFieldElement get_selector_from_name(const char *name);

FieldElement starknet_keccak(const uint8_t *bytes, uintptr_t bytes_len);

ResultFieldElement cairo_short_string_to_felt(const char *str);

Resultc_char parse_cairo_short_string(FieldElement felt);

ResultFieldElement typed_data_encode(const char *typed_data, FieldElement address);

FieldElement signing_key_new();
Expand Down Expand Up @@ -453,6 +461,8 @@ cdef extern from *:

void account_set_block_id(Account *account, BlockId block_id);

ResultFieldElement account_nonce(Account *account);

ResultFieldElement account_execute_raw(Account *account,
const Call *calldata,
uintptr_t calldata_len);
Expand Down
6 changes: 6 additions & 0 deletions src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ impl Account {

Result::Ok(Account(account))
}

#[wasm_bindgen(js_name = nonce)]
pub async unsafe fn nonce(&self) -> Result<String, JsValue> {
let nonce = self.0.get_nonce().await.map_err(|e| JsValue::from(e.to_string()))?;
Ok(format!("{:#x}", nonce))
}
}

#[wasm_bindgen(js_name = hashGetContractAddress)]
Expand Down

0 comments on commit 97989e4

Please sign in to comment.