Skip to content

Commit

Permalink
Merge pull request #747 from rainlanguage/2024-08-01-support-wasm-build
Browse files Browse the repository at this point in the history
support wasm build
  • Loading branch information
thedavidmeister authored Aug 5, 2024
2 parents dbfe232 + 265d0cf commit 0849124
Show file tree
Hide file tree
Showing 81 changed files with 432 additions and 279 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/rainix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
# We don't need to do rust static analysis on multiple platforms
- os: ubuntu-latest
task: rainix-rs-static
# Wasm target doesnt need to run on multiple platforms
- os: ubuntu-latest
task: rainix-wasm-artifacts
fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -45,7 +48,9 @@ jobs:
- run: nix develop -c rainix-rs-prelude
working-directory: lib/rain.interpreter
- run: nix develop -c rainix-sol-prelude
working-directory: lib/rain.metadata
working-directory: lib/rain.interpreter/lib/rain.metadata
- run: nix develop -c rainix-rs-prelude
working-directory: lib/rain.interpreter/lib/rain.metadata

- run: nix develop -c rainix-sol-prelude
- run: nix develop -c rainix-rs-prelude
Expand All @@ -58,3 +63,4 @@ jobs:
DEPLOY_VERIFIER: ""

run: nix develop -c ${{ matrix.task }}

12 changes: 0 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
[submodule "lib/rain.erc1820"]
path = lib/rain.erc1820
url = https://github.com/rainprotocol/rain.erc1820
[submodule "lib/rain.lib.memkv"]
path = lib/rain.lib.memkv
url = https://github.com/rainprotocol/rain.lib.memkv
[submodule "lib/sushixswap-v2"]
path = lib/sushixswap-v2
url = https://github.com/rainprotocol/sushixswap-v2
[submodule "lib/rain.solmem"]
path = lib/rain.solmem
url = https://github.com/rainprotocol/rain.solmem
[submodule "lib/rain.orderbook.interface"]
path = lib/rain.orderbook.interface
url = https://github.com/rainlanguage/rain.orderbook.interface
[submodule "lib/rain.metadata"]
path = lib/rain.metadata
url = https://github.com/rainlanguage/rain.metadata
[submodule "lib/rain.interpreter"]
path = lib/rain.interpreter
url = https://github.com/rainlanguage/rain.interpreter
77 changes: 70 additions & 7 deletions Cargo.lock

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

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://github.com/rainprotocol/rain.orderbook"

[workspace.dependencies]
foundry-block-explorers = "0.2.6"
alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "cbdedb77fb1994a18ceb47e72786f8b32b670669" }
alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "d9bd0fe8360d803ed3e58b34063890c8775999f2" }
alloy-sol-types = "0.6.3"
alloy-primitives = "0.6.3"
alloy-json-abi = "0.6.3"
Expand All @@ -21,12 +21,12 @@ clap = { version = "4.2.5", features = ["cargo", "derive"] }
once_cell = "1.17.1"
reqwest = { version = "0.11.17", features = ["json"] }
rust-bigint = "1.2.0"
serde = "1.0.160"
serde = "1.0.200"
futures = "0.3.17"
serde_bytes = "0.11.9"
serde_json = "1.0.112"
serde_yaml = "0.9.32"
tokio = { version = "1.28.0", features = ["full"] }
tokio = { version = "1.28.0" }
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
url = "2.5.0"
Expand All @@ -39,9 +39,9 @@ thiserror = "1.0.56"
strict-yaml-rust = "0.1.2"
dotrain = "6.0.1-alpha.18"
dotrain-lsp = "6.0.1-alpha.18"
rain-metadata = { path = "lib/rain.metadata/crates/cli" }
rain-metadata-bindings = { path = "lib/rain.metadata/crates/bindings" }
rain-metaboard-subgraph = { path = "lib/rain.metadata/crates/metaboard" }
rain-metadata = { path = "lib/rain.interpreter/lib/rain.metadata/crates/cli" }
rain-metadata-bindings = { path = "lib/rain.interpreter/lib/rain.metadata/crates/bindings" }
rain-metaboard-subgraph = { path = "lib/rain.interpreter/lib/rain.metadata/crates/metaboard" }
rain_interpreter_bindings = { path = "lib/rain.interpreter/crates/bindings" }
rain_interpreter_dispair = { path = "lib/rain.interpreter/crates/dispair" }
rain_interpreter_parser = { path = "lib/rain.interpreter/crates/parser" }
Expand All @@ -54,8 +54,8 @@ thirtyfour = "0.31.0"
test-context = "0.3.0"
portpicker = "0.1.1"
rain-orderbook-env = { path = "crates/env" }
rain-erc = { git = "https://github.com/rainlanguage/rain.erc", rev = "cc9d7c3c74cf8e9676d72ee054af7f1b67a84974" }
rain-error-decoding = { git = "https://github.com/rainlanguage/rain.error", rev = "700142c3c73d5cbaea82f1d51af5ce04de5bac6a" }
rain-erc = { git = "https://github.com/rainlanguage/rain.erc", rev = "7f50b2c05eb41a77ee925ebe80fe49420a2b5b80" }
rain-error-decoding = { git = "https://github.com/rainlanguage/rain.error", rev = "72d9577fdaf7135113847027ba951f9a43b41827" }

[workspace.dependencies.rain_orderbook_bindings]
path = "crates/bindings"
Expand Down
8 changes: 7 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ reqwest = { workspace = true }
rust-bigint = { workspace = true }
serde = { workspace = true }
serde_bytes = { workspace = true }
tokio = { workspace = true }
# tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ['env-filter'] }
alloy-primitives = { workspace = true }
alloy-sol-types = { workspace = true }
comfy-table = { workspace = true }
chrono = { workspace = true }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { workspace = true, features = ["full"] }

[target.'cfg(target_family = "wasm")'.dependencies]
tokio = { workspace = true, features = ["sync", "macros", "io-util", "rt", "time"] }
25 changes: 18 additions & 7 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ homepage = "https://github.com/rainprotocol/rain.orderbook"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["rlib", "cdylib"]

[dependencies]
rain_orderbook_bindings = { workspace = true }
rain_orderbook_subgraph_client = { workspace = true }
rain_orderbook_app_settings = { workspace = true }
alloy-primitives = { workspace = true }
alloy-primitives = { workspace = true, features = ["rand"] }
alloy-ethers-typecast = { workspace = true }
alloy-sol-types = { workspace = true }
url = { workspace = true }
Expand All @@ -34,17 +37,25 @@ rain-metadata-bindings = { workspace = true }
rain_interpreter_bindings = { workspace = true }
rain_interpreter_dispair = { workspace = true }
rain_interpreter_parser = { workspace = true }
rain-interpreter-eval = { workspace = true }
rain-orderbook-env = { workspace = true }
serde_bytes = { workspace = true }
tokio = { workspace = true }
proptest = { workspace = true }
typeshare = { workspace = true }
csv = { workspace = true }
chrono = { workspace = true }
futures = { workspace = true }
rain-error-decoding = { workspace = true }
rand = "0.8.5"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { workspace = true, features = ["full"] }
rain-interpreter-eval = { workspace = true }
proptest = { workspace = true }

[target.'cfg(target_family = "wasm")'.dependencies]
js-sys = { version = "0.3.69" }
wasm-bindgen = { version = "0.2.92" }
serde-wasm-bindgen = { version = "0.6.5" }
wasm-bindgen-futures = { version = "0.4.42" }
tsify = { version = "0.4.5", default-features = false, features = ["js", "wasm-bindgen"] }
tokio = { workspace = true, features = ["sync", "macros", "io-util", "rt", "time"] }

[dev-dependencies]
tokio = { workspace = true }
rain-orderbook-env = { workspace = true }
6 changes: 4 additions & 2 deletions crates/common/src/add_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use crate::{
};
use alloy_ethers_typecast::transaction::{
ReadContractParameters, ReadableClientError, ReadableClientHttp, WritableClientError,
WriteTransaction, WriteTransactionStatus,
};
use alloy_primitives::{hex::FromHexError, Address, U256};
#[cfg(not(target_family = "wasm"))]
use alloy_ethers_typecast::transaction::{WriteTransaction, WriteTransactionStatus};
use alloy_primitives::{hex::FromHexError, private::rand, Address, U256};
use alloy_sol_types::SolCall;
use dotrain::{error::ComposeError, RainDocument, Rebind};
use rain_interpreter_dispair::{DISPair, DISPairError};
Expand Down Expand Up @@ -212,6 +213,7 @@ impl AddOrderArgs {
})
}

#[cfg(not(target_family = "wasm"))]
pub async fn execute<S: Fn(WriteTransactionStatus<addOrder2Call>)>(
&self,
transaction_args: TransactionArgs,
Expand Down
12 changes: 8 additions & 4 deletions crates/common/src/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::transaction::{TransactionArgs, TransactionArgsError, WritableTransactionExecuteError};
use alloy_ethers_typecast::transaction::{
ReadContractParametersBuilder, ReadContractParametersBuilderError, ReadableClient,
ReadableClientError, WritableClientError,
};
#[cfg(not(target_family = "wasm"))]
use alloy_ethers_typecast::{
ethers_address_to_alloy,
transaction::{
ReadContractParametersBuilder, ReadContractParametersBuilderError, ReadableClient,
ReadableClientError, WritableClientError, WriteTransaction, WriteTransactionStatus,
},
transaction::{WriteTransaction, WriteTransactionStatus},
};
use alloy_primitives::{Address, U256};
use alloy_sol_types::SolCall;
Expand Down Expand Up @@ -72,6 +74,7 @@ impl DepositArgs {
}

/// Execute IERC20 approve call
#[cfg(not(target_family = "wasm"))]
pub async fn execute_approve<S: Fn(WriteTransactionStatus<approveCall>)>(
&self,
transaction_args: TransactionArgs,
Expand Down Expand Up @@ -118,6 +121,7 @@ impl DepositArgs {
}

/// Execute OrderbookV3 deposit call
#[cfg(not(target_family = "wasm"))]
pub async fn execute_deposit<S: Fn(WriteTransactionStatus<deposit2Call>)>(
&self,
transaction_args: TransactionArgs,
Expand Down
Loading

0 comments on commit 0849124

Please sign in to comment.