Skip to content

Commit

Permalink
serialize u64 as bigint [js] (#3177)
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 committed Oct 11, 2023
1 parent 0246263 commit 027faa0
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions crates/wasm/src/view_server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use crate::error::WasmResult;
use crate::note_record::SpendableNoteRecord;
use crate::storage::IndexedDBStorage;
use crate::swap_record::SwapRecord;
use std::convert::TryInto;
use std::{collections::BTreeMap, str::FromStr};

use serde::{Deserialize, Serialize};
use serde_wasm_bindgen::Error;
use serde_wasm_bindgen::Serializer;
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsValue;

use penumbra_asset::asset::{DenomMetadata, Id};
use penumbra_compact_block::{CompactBlock, StatePayload};
use penumbra_dex::lp::position::Position;
Expand All @@ -11,14 +16,13 @@ use penumbra_sct::Nullifier;
use penumbra_shielded_pool::note;
use penumbra_tct as tct;
use penumbra_tct::Witness::*;
use serde::{Deserialize, Serialize};
use serde_wasm_bindgen::Error;
use std::convert::TryInto;
use std::{collections::BTreeMap, str::FromStr};
use tct::storage::{StoreCommitment, StoreHash, StoredPosition, Updates};
use tct::{Forgotten, Tree};
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsValue;

use crate::error::WasmResult;
use crate::note_record::SpendableNoteRecord;
use crate::storage::IndexedDBStorage;
use crate::swap_record::SwapRecord;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct StoredTree {
Expand Down Expand Up @@ -276,7 +280,8 @@ impl ViewServer {
self.last_position = nct_updates.set_position;
self.last_forgotten = nct_updates.set_forgotten;

let result = serde_wasm_bindgen::to_value(&updates)?;
let serializer = Serializer::new().serialize_large_number_types_as_bigints(true);
let result = updates.serialize(&serializer)?;
Ok(result)
}

Expand Down

0 comments on commit 027faa0

Please sign in to comment.