Skip to content

Commit

Permalink
fix: clarinet-deployments wasm build (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard authored Sep 7, 2023
1 parent b8cedf6 commit 1ab5702
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/clarinet-deployments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bitcoin = { version = "0.29.2", optional = true }
bitcoincore-rpc = { version = "0.16.0", optional = true }
bitcoincore-rpc-json = { version = "0.16.0", optional = true }
base58 = { version = "0.2.0", optional = true }
base64 = "0.21.3"
tiny-hderive = { version = "0.3.0", optional = true }
libsecp256k1 = { version = "0.7.0", optional = true }
clarinet_utils = { package = "clarinet-utils", path = "../clarinet-utils", optional = true }
Expand Down
11 changes: 6 additions & 5 deletions components/clarinet-deployments/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,15 @@ pub struct RequirementPublishSpecification {
}

pub mod source_serde {
use bitcoincore_rpc::jsonrpc::base64::{decode, encode};
use base64::{engine::general_purpose::STANDARD as b64, Engine as _};
use serde::{Deserialize, Deserializer, Serializer};
use std::str::from_utf8;

pub fn serialize<S>(x: &str, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let enc = encode(&x);
let enc = b64.encode(&x);
s.serialize_str(&enc)
}

Expand All @@ -543,7 +543,8 @@ pub mod source_serde {
}

pub fn base64_decode(encoded: &str) -> Result<String, String> {
let bytes = decode(&encoded)
let bytes = b64
.decode(&encoded)
.map_err(|e| format!("unable to decode contract source: {}", e.to_string()))?;
let decoded = from_utf8(&bytes).map_err(|e| {
format!(
Expand Down Expand Up @@ -893,7 +894,7 @@ pub struct DeploymentSpecification {
}

pub mod contracts_serde {
use bitcoincore_rpc::jsonrpc::base64::encode;
use base64::{engine::general_purpose::STANDARD as b64, Engine as _};
use clarinet_files::FileLocation;
use clarity_repl::clarity::vm::types::QualifiedContractIdentifier;
use serde::{ser::SerializeSeq, Deserializer, Serializer};
Expand All @@ -910,7 +911,7 @@ pub mod contracts_serde {
{
let mut out = serializer.serialize_seq(Some(target.len()))?;
for (contract_id, (source, file_location)) in target {
let encoded = encode(&source);
let encoded = b64.encode(&source);
let mut map = BTreeMap::new();
map.insert("contract_id", contract_id.to_string());
map.insert("source", encoded);
Expand Down

0 comments on commit 1ab5702

Please sign in to comment.