Skip to content

Commit

Permalink
fix action ser json
Browse files Browse the repository at this point in the history
  • Loading branch information
OlofBlomqvist committed May 21, 2024
1 parent f7fd2a2 commit 99979c9
Show file tree
Hide file tree
Showing 13 changed files with 301 additions and 17 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "RustyContainer1",
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
"features": {
"ghcr.io/lee-orr/rusty-dev-containers/cargo-watch:0": {}
},
"mounts": [
{
"source": "devcontainer-cargo-cache-${devcontainerId}",
"target": "/usr/local/cargo",
"type": "volume"
}
],
"remoteUser": "root",
"customizations": {
"vscode": {
"extensions": [
"rust-lang.rust-analyzer"
]
}
},
"postCreateCommand": "rustup install nightly && rustup default nightly"
}

2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "marlowe_lang"
description = "experimental parser lib for Cardano Marlowe DSL"
version = "0.3.1"
version = "0.3.2"
edition = "2021"
authors = ["Olof Blomqvist <olof@twnet.se>"]
repository = "https://github.com/OlofBlomqvist/marlowe_rust"
Expand Down
18 changes: 9 additions & 9 deletions build_npm_packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if($skipBuild -ne $true) {
Remove-Item $latest_dir/ -Recurse -Force -ErrorAction Stop
}
# Build for NodeJS
wasm-pack build --all-features --release --target nodejs --out-dir $nodejs_dir/pkg
/home/olof/.cargo/bin/wasm-pack build --all-features --release --target nodejs --out-dir $nodejs_dir/pkg
$j = Get-Content $nodejs_dir/pkg/package.json |convertfrom-json
if($null -ne $version -and $version.Length -gt 1) {
$j.version = $version + "-nodejs"
Expand All @@ -42,7 +42,7 @@ if($skipBuild -ne $true) {


# Build for Web
wasm-pack build --all-features --release --target web --out-dir $web_dir/pkg
/home/olof/.cargo/bin/wasm-pack build --all-features --release --target web --out-dir $web_dir/pkg
$j = Get-Content $web_dir/pkg/package.json |convertfrom-json
if($null -ne $version -and $version.Length -gt 0) {
$j.version = $version + "-web"
Expand All @@ -62,7 +62,7 @@ if($skipBuild -ne $true) {
#wasm-pack pack $web_dir

# Build bundle
wasm-pack build --all-features --release --target bundler --out-dir $bundle_dir/pkg
/home/olof/.cargo/bin/wasm-pack build --all-features --release --target bundler --out-dir $bundle_dir/pkg
$j = Get-Content $bundle_dir/pkg/package.json |convertfrom-json
if($null -ne $version -and $version.Length -gt 0) {
$j.version = $version + "-bundle"
Expand All @@ -75,7 +75,7 @@ if($skipBuild -ne $true) {
#wasm-pack pack $bundle_dir

# Build latest
wasm-pack build --all-features --release --target nodejs --out-dir $latest_dir/pkg
/home/olof/.cargo/bin/wasm-pack build --all-features --release --target nodejs --out-dir $latest_dir/pkg
$j = Get-Content $latest_dir/pkg/package.json |convertfrom-json
if($null -ne $version -and $version.Length -gt 0) {
$j.version = $version
Expand All @@ -98,14 +98,14 @@ if($skipBuild -ne $true) {

if($publish) {
write-host -ForegroundColor Green "Publishing web... $web_dir $webv"
wasm-pack publish -t web --tag web $web_dir
/home/olof/.cargo/bin/wasm-pack publish -t web --tag web $web_dir
write-host -ForegroundColor Green "Publishing nodejs... $nodejs_dir $njsv"
wasm-pack publish -t nodejs --tag nodejs $nodejs_dir
/home/olof/.cargo/bin/wasm-pack publish -t nodejs --tag nodejs $nodejs_dir
write-host -ForegroundColor Green "Publishing bundle... $bundle_dir $bundlev"
wasm-pack publish -t bundler --tag bundle $bundle_dir
/home/olof/.cargo/bin/wasm-pack publish -t bundler --tag bundle $bundle_dir
if($publishLatestTag) {
write-host -ForegroundColor Green "Publishing latest... $latest_dir $latestlev"
wasm-pack publish -t nodejs --tag latest $latest_dir
/home/olof/.cargo/bin/wasm-pack publish -t nodejs --tag latest $latest_dir

}
}
}
130 changes: 130 additions & 0 deletions flake.lock

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

75 changes: 75 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
description = "A Rust application using the nightly compiler";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs {
inherit system overlays;
};

rustNightly = pkgs.rustChannelOf {
channel = "nightly";
date = "2024-03-04";
};

in {

packages.default = pkgs.rustPlatform.buildRustPackage rec {

pname = "odd-box";
version = "0.0.10";
src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};

#buildNoDefaultFeatures = true;
#buildFeatures = [ "color" "net" ];
#checkFeatures = [ "color" ];

meta = with pkgs.lib; {
description = "dead simple reverse-proxy";
homepage = "https://github.com/OlofBlomqvist/odd-box";
license = licenses.mit;
maintainers = ["olof@twnet.se"];
};

buildType = "release";
buildInputs = [ pkgs.openssl pkgs.pkg-config ];

RUSTC = "${rustNightly.default}/bin/rustc";
CARGO = "${rustNightly.default}/bin/cargo";

nativeBuildInputs = [ rustNightly.default ];

OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";

installPhase = ''
mkdir -p $out/bin
cp target/*/release/odd-box $out/bin/
'';

};

# DEV THE THING
devShell = pkgs.mkShell {
nativeBuildInputs = [
rustNightly.default
pkgs.openssl
pkgs.pkg-config
];
};
}

);
}
Binary file added pkg_wasi/libmarlowe_lang.rlib
Binary file not shown.
Binary file modified pkg_wasi/marlowe_lang.wasm
100644 → 100755
Binary file not shown.
Binary file modified pkg_wasi/marlowe_lang_cli.wasm
100644 → 100755
Binary file not shown.
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly"
cargo-features = ["edition2021"]
8 changes: 4 additions & 4 deletions src/lib/deserialization/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ impl<'de> serde::de::Visitor<'de> for InputActionVisitor {
})
}

if let Some(a) = input_that_chooses_num &&
let Some(b) = for_choice_id
if let Some(chosen_number) = input_that_chooses_num &&
let Some(choice_id) = for_choice_id
{
return Ok(InputAction::Choice {
for_choice_id: Some(a),
input_that_chooses_num: b
for_choice_id: Some(choice_id),
input_that_chooses_num: chosen_number
})
}

Expand Down
10 changes: 9 additions & 1 deletion src/lib/extras/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,4 +1198,12 @@ fn payee_to_wasm(x:&Payee) -> WasmPayee {
_ => panic!("cannot convert payee to wasm because it is null.")
};
account_id_to_wasm_payee(accid)
}
}


#[wasm_bindgen()]
pub fn redeemer_json_to_cbor(list_of_inputs_json:&str) {
let deserialized : Vec<crate::types::marlowe::InputAction> = crate::deserialization::json::deserialize(list_of_inputs_json.into()).unwrap();
let action = deserialized.into_iter().map(PossiblyMerkleizedInput::Action).collect::<Vec<PossiblyMerkleizedInput>>();
crate::serialization::cborhex::serialize(action).unwrap();
}
Loading

0 comments on commit 99979c9

Please sign in to comment.