Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wasm): trim start 0x for u256 hex #99

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,10 @@ impl ToriiClient {
.collect::<Result<Vec<_>, _>>()
.map_err(|e| JsValue::from(format!("failed to parse contract addresses: {e}")))?;

let token_ids = token_ids.into_iter().map(|t| U256::from_be_hex(&t)).collect::<Vec<_>>();
let token_ids = token_ids
.into_iter()
.map(|t| U256::from_be_hex(t.trim_start_matches("0x")))
.collect::<Vec<_>>();

let tokens = self
.inner
Expand Down Expand Up @@ -673,7 +676,10 @@ impl ToriiClient {
})
.collect::<Result<Vec<_>, _>>()?;

let token_ids = token_ids.into_iter().map(|t| U256::from_be_hex(&t)).collect::<Vec<_>>();
let token_ids = token_ids
.into_iter()
.map(|t| U256::from_be_hex(t.trim_start_matches("0x")))
.collect::<Vec<_>>();

let subscription_id = Arc::new(AtomicU64::new(0));
let (trigger, tripwire) = Tripwire::new();
Expand Down Expand Up @@ -746,7 +752,10 @@ impl ToriiClient {
.collect::<Result<Vec<_>, _>>()
.map_err(|e| JsValue::from(format!("failed to parse contract addresses: {e}")))?;

let token_ids = token_ids.into_iter().map(|t| U256::from_be_hex(&t)).collect::<Vec<_>>();
let token_ids = token_ids
.into_iter()
.map(|t| U256::from_be_hex(t.trim_start_matches("0x")))
.collect::<Vec<_>>();

let token_balances = self
.inner
Expand Down Expand Up @@ -1166,7 +1175,10 @@ impl ToriiClient {
})
.collect::<Result<Vec<_>, _>>()?;

let token_ids = token_ids.into_iter().map(|t| U256::from_be_hex(&t)).collect::<Vec<_>>();
let token_ids = token_ids
.into_iter()
.map(|t| U256::from_be_hex(t.trim_start_matches("0x")))
.collect::<Vec<_>>();

let subscription_id = Arc::new(AtomicU64::new(0));
let (trigger, tripwire) = Tripwire::new();
Expand Down Expand Up @@ -1251,7 +1263,10 @@ impl ToriiClient {
})
.collect::<Result<Vec<_>, _>>()?;

let token_ids = token_ids.into_iter().map(|t| U256::from_be_hex(&t)).collect::<Vec<_>>();
let token_ids = token_ids
.into_iter()
.map(|t| U256::from_be_hex(t.trim_start_matches("0x")))
.collect::<Vec<_>>();

self.inner
.update_token_balance_subscription(
Expand Down