Skip to content

Commit

Permalink
[wasm crate] Remove async constructor (#3104)
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 authored Sep 26, 2023
1 parent 5d72efb commit f776848
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion crates/wasm/publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "ISC",
"scripts": {
"format": "prettier --write .",
"publish-wasm": "tsc && node build/publish-wasm.js"
"compile-wasm": "tsc && node build/run.js",
"publish-wasm": "npm run compile-wasm -- --publish"
},
"dependencies": {
"wasm-pack": "^0.12.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import path from 'path';
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';

const targets = ['web', 'nodejs', 'bundler'];
const TARGETS = ['web', 'nodejs', 'bundler'];

targets.forEach(target => {
TARGETS.forEach(target => {
// Run wasm-pack for each target
execSync(
`wasm-pack build ../ --release --target ${target} --out-name index --out-dir publish/${target}`,
Expand All @@ -23,8 +23,10 @@ targets.forEach(target => {
process.chdir(target);
execSync('npm pack', { stdio: 'inherit' });

// Publish to npm
execSync('npm publish --access public', { stdio: 'inherit' });
// Publish to npm if flag provided
if (process.argv.includes('--publish')) {
execSync('npm publish --access public', { stdio: 'inherit' });
}

// Change working directory back to parent
process.chdir('..');
Expand Down
2 changes: 0 additions & 2 deletions crates/wasm/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl<R: RngCore + CryptoRng> Planner<R> {
address_index: None,
amount_to_spend: Some(amount.into()),
include_spent: false,
..Default::default()
})
.collect(),
self.vote_intents
Expand All @@ -107,7 +106,6 @@ impl<R: RngCore + CryptoRng> Planner<R> {
account_group_id: None,
votable_at_height: *start_block_height,
address_index: None,
..Default::default()
},
)
.collect(),
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn build_tx(
) -> Result<JsValue, Error> {
let plan: TransactionPlan = serde_wasm_bindgen::from_value(transaction_plan)?;

let fvk = FullViewingKey::from_str(full_viewing_key.as_ref())
let fvk = FullViewingKey::from_str(full_viewing_key)
.expect("The provided string is not a valid FullViewingKey");

let auth_data = sign_plan(spend_key_str, plan.clone())?;
Expand Down Expand Up @@ -248,7 +248,7 @@ fn witness(nct: Tree, plan: TransactionPlan) -> WasmResult<WitnessData> {
let note_commitments: Vec<StateCommitment> = plan
.spend_plans()
.filter(|plan| plan.note.amount() != 0u64.into())
.map(|spend| spend.note.commit().into())
.map(|spend| spend.note.commit())
.chain(
plan.swap_claim_plans()
.map(|swap_claim| swap_claim.swap_plaintext.swap_commitment()),
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm/src/view_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct ViewServer {

#[wasm_bindgen]
impl ViewServer {
#[wasm_bindgen(constructor)]
#[wasm_bindgen]
pub async fn new(
full_viewing_key: &str,
epoch_duration: u64,
Expand Down

0 comments on commit f776848

Please sign in to comment.