Skip to content

Commit 200780f

Browse files
feat(makefile): add WASM rules for iota-graphql-client and iota-transaction-builder (#302)
* feat(makefile): add WASM rules * wasm compatible graphql-client
1 parent 108ab5d commit 200780f

File tree

7 files changed

+65
-7
lines changed

7 files changed

+65
-7
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ test-with-localnet: package_test_example_v1.json package_test_example_v2.json ##
3333

3434
.PHONY: wasm
3535
wasm: ## Build WASM modules
36-
$(MAKE) -C crates/iota-sdk-types wasm
3736
$(MAKE) -C crates/iota-crypto wasm
37+
$(MAKE) -C crates/iota-graphql-client wasm
38+
$(MAKE) -C crates/iota-sdk-types wasm
39+
$(MAKE) -C crates/iota-transaction-builder wasm
3840

3941
.PHONY: doc
4042
doc: ## Generate documentation

crates/iota-graphql-client/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ iota-crypto = { path = "../iota-crypto", features = ["ed25519", "pem", "bech32"]
3030
iota-transaction-builder = { path = "../iota-transaction-builder" }
3131
iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde", "rand", "hash"] }
3232
rand = "0.8.5"
33-
tokio = { version = "1.40.0", features = ["full"] }
33+
34+
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
35+
tokio = { version = "1.0", features = ["macros", "rt"] }
36+
37+
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
38+
tokio = { version = "1.0", features = ["full"] }
3439

3540
[build-dependencies]
3641
iota-graphql-client-build = { path = "../iota-graphql-client-build" }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Set the default target of this Makefile
2+
.PHONY: all
3+
all:: check-features clippy test wasm
4+
5+
.PHONY: check-features
6+
check-features:
7+
cargo hack check --feature-powerset --no-dev-deps
8+
9+
.PHONY: clippy
10+
clippy:
11+
cargo clippy --all-features --all-targets
12+
13+
.PHONY: test
14+
test:
15+
cargo nextest run --all-features
16+
cargo test --all-features --doc
17+
18+
.PHONY: wasm
19+
wasm:
20+
CC=clang wasm-pack test -r --node --all-features
21+
22+
%:
23+
$(MAKE) -C ../.. $@

crates/iota-graphql-client/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ executing transactions and more.
2121

2222
Instantiate a client with [`Client::new(server: &str)`] or use one of the predefined functions for different networks [`Client`].
2323

24-
```rust, no_run
24+
```rust, ignore
2525
use iota_graphql_client::Client;
2626
use eyre::Result;
2727
@@ -43,7 +43,7 @@ The client provides an API to request gas from the faucet. The `request_and_wait
4343

4444
### Example for standard devnet/testnet/local networks.
4545

46-
```rust, no_run
46+
```rust, ignore
4747
use iota_graphql_client::faucet::FaucetClient;
4848
use iota_types::Address;
4949
@@ -73,7 +73,7 @@ async fn main() -> Result<()> {
7373

7474
Note that this `FaucetClient` is explicitly designed to work with two endpoints: `v1/gas`, and `v1/status`. When passing in the custom faucet URL, skip the final endpoint and only pass in the top-level url (e.g., `https://faucet.devnet.iota.cafe`).
7575

76-
```rust, no_run
76+
```rust, ignore
7777
use iota_graphql_client::faucet::FaucetClient;
7878
use iota_types::Address;
7979

crates/iota-sdk-types/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ test:
1515
cargo nextest run --all-features
1616
cargo test --all-features --doc
1717

18-
# --all-features
1918
.PHONY: wasm
2019
wasm:
2120
CC=clang wasm-pack test -r --node --all-features

crates/iota-transaction-builder/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ reqwest = "0.12"
1818
serde = "1.0"
1919
serde_json = "1.0"
2020
thiserror = "2.0"
21-
tokio = { version = "1.0", features = ["full"] }
2221
variadics_please = "1.1"
2322

23+
[target.'cfg(target_arch = "wasm32")'.dependencies]
24+
getrandom = { version = "0.2", features = ["js"] }
25+
tokio = { version = "1.0", features = ["macros", "rt"] }
26+
27+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
28+
tokio = { version = "1.0", features = ["full"] }
29+
2430
[dev-dependencies]
2531
eyre = "0.6"
2632
iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["rand"] }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Set the default target of this Makefile
2+
.PHONY: all
3+
all:: check-features clippy test wasm
4+
5+
.PHONY: check-features
6+
check-features:
7+
cargo hack check --feature-powerset --no-dev-deps
8+
9+
.PHONY: clippy
10+
clippy:
11+
cargo clippy --all-features --all-targets
12+
13+
.PHONY: test
14+
test:
15+
cargo nextest run --all-features
16+
cargo test --all-features --doc
17+
18+
.PHONY: wasm
19+
wasm:
20+
CC=clang wasm-pack test -r --node --all-features
21+
22+
%:
23+
$(MAKE) -C ../.. $@

0 commit comments

Comments
 (0)