Skip to content

Commit 8a67c81

Browse files
authored
Merge pull request #2 from AElfProject/codex/wasm32-wasip2-alpha1
feat(sdk): ✨ ship wasm alpha and runtime hardening
2 parents ed81699 + 1c3eb22 commit 8a67c81

34 files changed

+793
-580
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,27 @@ jobs:
1616
- name: msrv
1717
run: cargo check --workspace --all-targets --all-features --locked
1818

19-
test:
19+
wasm:
2020
runs-on: ubuntu-latest
2121
needs: msrv
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: dtolnay/rust-toolchain@stable
25+
with:
26+
targets: wasm32-wasip2
27+
- uses: Swatinem/rust-cache@v2
28+
- name: wasm aelf-client
29+
run: cargo check -p aelf-client --target wasm32-wasip2 --no-default-features
30+
- name: wasm aelf-contract
31+
run: cargo check -p aelf-contract --target wasm32-wasip2 --no-default-features
32+
- name: wasm aelf-sdk
33+
run: cargo check -p aelf-sdk --target wasm32-wasip2 --no-default-features
34+
35+
test:
36+
runs-on: ubuntu-latest
37+
needs:
38+
- msrv
39+
- wasm
2240
steps:
2341
- uses: actions/checkout@v4
2442
- uses: dtolnay/rust-toolchain@stable
@@ -35,3 +53,28 @@ jobs:
3553
run: cargo check --workspace --examples
3654
- name: test
3755
run: cargo test --workspace --all-targets
56+
57+
public-smoke:
58+
runs-on: ubuntu-latest
59+
needs: test
60+
steps:
61+
- uses: actions/checkout@v4
62+
- uses: dtolnay/rust-toolchain@stable
63+
- uses: Swatinem/rust-cache@v2
64+
- name: public readonly smoke
65+
run: |
66+
retry() {
67+
local attempts=3
68+
local delay=5
69+
for attempt in $(seq 1 "$attempts"); do
70+
if "$@"; then
71+
return 0
72+
fi
73+
if [[ "$attempt" -lt "$attempts" ]]; then
74+
sleep "$delay"
75+
fi
76+
done
77+
return 1
78+
}
79+
80+
retry cargo test -p aelf-sdk --test public_readonly_smoke -- --ignored --test-threads=1 --nocapture

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,17 @@ jobs:
147147
return 1
148148
}
149149
150+
if [[ "$DRY_RUN" != "true" && -z "${CARGO_REGISTRY_TOKEN:-}" ]]; then
151+
echo "::error::CARGO_REGISTRY_TOKEN is required when dry_run=false."
152+
exit 1
153+
fi
154+
150155
if [[ "$DRY_RUN" == "true" && "${#requested_packages[@]}" -eq 0 ]]; then
151156
echo "Running workspace dry-run for the full publish set."
152157
cargo publish --workspace --dry-run --locked
153158
exit 0
154159
fi
155160
156-
if [[ "$DRY_RUN" != "true" && -z "${CARGO_REGISTRY_TOKEN:-}" ]]; then
157-
echo "::error::CARGO_REGISTRY_TOKEN is required when dry_run=false."
158-
exit 1
159-
fi
160-
161161
for pkg in "${ordered_packages[@]}"; do
162162
if ! package_selected "$pkg"; then
163163
continue
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: transaction-smoke
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
funded-transaction-smoke:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: dtolnay/rust-toolchain@stable
15+
- uses: Swatinem/rust-cache@v2
16+
- name: funded transaction smoke
17+
env:
18+
AELF_ENDPOINT: ${{ secrets.AELF_TRANSACTION_SMOKE_ENDPOINT }}
19+
AELF_PRIVATE_KEY: ${{ secrets.AELF_TRANSACTION_SMOKE_PRIVATE_KEY }}
20+
AELF_TO_ADDRESS: ${{ secrets.AELF_TRANSACTION_SMOKE_TO_ADDRESS }}
21+
AELF_TOKEN_CONTRACT: ${{ secrets.AELF_TRANSACTION_SMOKE_TOKEN_CONTRACT }}
22+
AELF_AMOUNT: ${{ secrets.AELF_TRANSACTION_SMOKE_AMOUNT }}
23+
run: cargo test -p aelf-sdk --test funded_transaction_smoke funded_send_transaction_smoke -- --ignored --exact --nocapture

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ All notable changes to `aelf-sdk.rust` will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.0-alpha.1] - 2026-03-11
9+
10+
### Added
11+
12+
- `native-http` Cargo feature on `aelf-client`, `aelf-contract`, and `aelf-sdk`, enabled by default for native consumers
13+
- `AElfClient::with_provider(...)` and `Provider` re-exports on the facade crate for custom transports
14+
- `wasm32-wasip2` CI compile gates for `aelf-client`, `aelf-contract`, and `aelf-sdk` with `--no-default-features`
15+
- public readonly smoke coverage in a dedicated CI job plus a manual funded transaction smoke workflow
16+
17+
### Changed
18+
19+
- The workspace version moved to `0.1.0-alpha.1`
20+
- Tokio now uses the wasm-compatible `rt` feature instead of `rt-multi-thread`
21+
- `HttpProvider` and `AElfClient::new(...)` are now gated behind `native-http`, while the core SDK remains provider-first
22+
- root `/examples` now forward to `crates/aelf-sdk/examples` so the SDK only maintains one example source of truth
23+
- wallet keystore examples now redact private key and mnemonic output
24+
25+
### Fixed
26+
27+
- `aelf-client`, `aelf-contract`, and `aelf-sdk` now compile for `wasm32-wasip2` when consumed with `default-features = false`
28+
- The facade crate now exposes the transport abstraction needed by native-wasm skill runtimes
29+
- `send_transaction` no longer treats arbitrary non-empty text payloads as success
30+
- typed contract wrappers now lazily reuse the first descriptor per handle, while direct `contract_at(...)` calls still fetch a fresh descriptor for each new handle
31+
832
## [0.1.0-alpha.0] - 2026-03-10
933

1034
### Added

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ cargo +1.85.0 check --workspace --all-targets --all-features --locked
2020
cargo clippy --workspace --all-targets --all-features -- -D warnings
2121
cargo audit
2222
cargo check --workspace --examples
23+
cargo check -p aelf-client --target wasm32-wasip2 --no-default-features
24+
cargo check -p aelf-contract --target wasm32-wasip2 --no-default-features
25+
cargo check -p aelf-sdk --target wasm32-wasip2 --no-default-features
2326
cargo test --workspace
2427
```
2528

26-
Optional local-node validation:
29+
Optional live-node validation:
2730

2831
```bash
2932
cargo test -p aelf-sdk --test local_node -- --ignored
33+
cargo test -p aelf-sdk --test public_readonly_smoke -- --ignored --test-threads=1
3034
```
3135

36+
`cargo test --workspace` intentionally excludes the ignored live smoke suites so the default test pass remains deterministic and offline-friendly.
37+
3238
## Repository Layout
3339

3440
- `crates/aelf-sdk`: public facade crate
@@ -37,7 +43,8 @@ cargo test -p aelf-sdk --test local_node -- --ignored
3743
- `crates/aelf-crypto`: wallet, signing, address utilities
3844
- `crates/aelf-keystore`: JS-compatible keystore support
3945
- `crates/aelf-proto`: generated protobuf bindings
40-
- `examples/`: runnable examples wired into `aelf-sdk`
46+
- `crates/aelf-sdk/examples`: canonical example sources
47+
- `examples/`: thin forwarding wrappers for local convenience
4148

4249
## Pull Requests
4350

@@ -46,6 +53,7 @@ cargo test -p aelf-sdk --test local_node -- --ignored
4653
- Document public API additions with rustdoc.
4754
- Update `README.md`, `README.zh.md`, or `CHANGELOG.md` when user-facing behavior changes.
4855
- Keep the documented MSRV at Rust `1.85` and preserve the hard `cargo +1.85.0 check --workspace --all-targets --all-features --locked` CI gate.
56+
- Preserve the `wasm32-wasip2` compile gates for `aelf-client`, `aelf-contract`, and `aelf-sdk` when changing transport or feature-flag behavior.
4957

5058
## Commit Style
5159

Cargo.lock

Lines changed: 10 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2021"
1515
license = "MIT"
1616
repository = "https://github.com/AElfProject/aelf-web3.rust"
1717
rust-version = "1.85"
18-
version = "0.1.0-alpha.0"
18+
version = "0.1.0-alpha.1"
1919

2020
[workspace.dependencies]
2121
async-trait = "0.1.89"
@@ -30,7 +30,6 @@ coins-bip39 = "0.13.0"
3030
ctr = "0.9.2"
3131
hex = "0.4.3"
3232
http = "1.3.1"
33-
lru = "0.16.3"
3433
pbjson = "0.9.0"
3534
pbjson-build = "0.9.0"
3635
pbjson-types = "0.9.0"
@@ -49,7 +48,7 @@ serde_json = "1.0.140"
4948
sha2 = "0.10.9"
5049
sha3 = "0.10.8"
5150
thiserror = "2.0.18"
52-
tokio = { version = "1.47.1", features = ["macros", "rt-multi-thread", "sync", "time"] }
51+
tokio = { version = "1.47.1", features = ["macros", "rt", "sync", "time"] }
5352
zeroize = "1.8.1"
5453

5554
[workspace.lints.rust]

0 commit comments

Comments
 (0)