Skip to content

Commit cd8f28d

Browse files
authored
[SDK] Introduce a replacement Rust SDK for the entirety of the existi… (#20)
* [SDK] Introduce a replacement Rust SDK for the entirety of the existing one This is based off of the TypeScript SDK, and we'll see how well it goes with more extensive testing. * more additions to rust SDK v2 * [sdkv2] Add feature flags to gate features and reduce overhead * format files * address comments * address comments * fix formatting * update some fixes for CI and PR comments * more cleanup * more fixes * Address PR review comments and fix CI - Add rustfmt component to release.yml workflow - Fix deploy_module.rs BCS encoding comment (clarify bytes are passed directly) - Fix multi_key_account.rs to use chain_id().id() and propagate errors - Fix call_contract.rs to check specifically for "not found" errors - Add clearer comment in multi_agent.rs about example limitations These changes address the copilot-pull-request-reviewer comments from PR #20. * Fix clippy lint: remove unnecessary to_string() in println * add more examples * remove ANS for now * add migration guide * cleanup security issues * fix some lints * enable some pedantic lints * re-enable a bunch of pedantic lints * add pedantic lint * add pedantic lint, must use for self * add another pedantic lint * add more pedantic lints * more pedantic lints * lint more pedantic * add error messaging, and single key support * Fix single key handling, AIP80 formatting, signed integer type, and orderless transactions upport * add significantly more testing * add security fixes * fix some PR comments * fix clippy warnings, and CI issues * fix lints * Address PR comments * update GitHub Actions to latest versions - actions/checkout v4 -> v6 - actions/configure-pages v4 -> v5 - actions/upload-pages-artifact v3 -> v4 - softprops/action-gh-release v1 -> v2 * fix invalid Rust syntax in deploy_module example Use single braces for import statement in the printed code example. The code is inside a raw string (not a format string), so double braces render literally instead of being escaped. * fix format string lint * address PR comments * rename crates to more publishable crate names * fix remaining renames * finalize renames * Fix invalid string * Add security audit CI and fix bytes vulnerability - Add security.yml workflow with cargo-audit and cargo-deny checks - Runs on push, PR, and daily schedule to catch new advisories - Update bytes crate 1.11.0 -> 1.11.1 to fix RUSTSEC-2026-0007 (integer overflow in BytesMut::reserve)
1 parent 2d8bf5d commit cd8f28d

File tree

243 files changed

+48309
-33867
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+48309
-33867
lines changed

.clippy.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Clippy configuration
2+
3+
# Cognitive complexity threshold
4+
cognitive-complexity-threshold = 30
5+
6+
# Maximum number of lines for a function
7+
too-many-lines-threshold = 200
8+
9+
# Maximum number of arguments for a function
10+
too-many-arguments-threshold = 8
11+
12+
# Maximum number of struct fields
13+
max-struct-bools = 3
14+
15+
# Allowed names for variables (won't trigger `disallowed_names`)
16+
allowed-idents-below-min-chars = ["i", "j", "k", "n", "x", "y", "z", "id", "to", "db"]
17+
18+
# Type complexity threshold
19+
type-complexity-threshold = 350
20+
21+
# Maximum enum variant size ratio for large_enum_variant
22+
enum-variant-size-threshold = 200
23+
24+
# Allow these macros to have more than 7 lines
25+
excessive-nesting-threshold = 10
26+

.github/workflows/ci.yml

Lines changed: 204 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,229 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
env:
1010
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
1112

1213
jobs:
13-
fmt:
14-
name: Format check
14+
format:
15+
name: Format
1516
runs-on: ubuntu-latest
1617
steps:
17-
- uses: actions/checkout@v4
18-
19-
- name: Install Rust
20-
uses: dtolnay/rust-toolchain@stable
18+
- uses: actions/checkout@v6
19+
20+
- name: Install Rust
21+
uses: dtolnay/rust-toolchain@master
22+
with:
23+
toolchain: "1.90"
24+
components: rustfmt
25+
26+
- name: Check formatting
27+
run: cargo fmt --all -- --check
2128

22-
- name: Add rustfmt component
23-
run: rustup component add rustfmt
24-
25-
- name: Check formatting
26-
run: cargo fmt --all -- --check
29+
lint:
30+
name: Lint
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v6
34+
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@master
37+
with:
38+
toolchain: "1.90"
39+
components: clippy
40+
41+
- name: Cache cargo
42+
uses: Swatinem/rust-cache@v2
43+
44+
- name: Run Clippy (default features)
45+
run: cargo clippy -p aptos-sdk --all-targets -- -D warnings
46+
47+
- name: Run Clippy (all features)
48+
run: cargo clippy -p aptos-sdk --all-targets --all-features -- -D warnings
49+
50+
- name: Run Clippy (no default features)
51+
run: cargo clippy -p aptos-sdk --no-default-features -- -D warnings
2752

2853
test:
2954
name: Test
30-
runs-on: ubuntu-latest
55+
runs-on: ${{ matrix.os }}
3156
strategy:
57+
fail-fast: false
3258
matrix:
59+
os: [ubuntu-latest, macos-latest]
3360
rust: [stable]
3461
steps:
35-
- uses: actions/checkout@v4
36-
37-
- name: Install Rust
38-
uses: dtolnay/rust-toolchain@master
39-
with:
40-
toolchain: ${{ matrix.rust }}
41-
components: clippy
62+
- uses: actions/checkout@v6
63+
64+
- name: Install Rust ${{ matrix.rust }}
65+
uses: dtolnay/rust-toolchain@master
66+
with:
67+
toolchain: ${{ matrix.rust }}
68+
69+
- name: Cache cargo
70+
uses: Swatinem/rust-cache@v2
71+
72+
- name: Build
73+
run: cargo build -p aptos-sdk --all-targets
74+
75+
- name: Run tests
76+
run: cargo test -p aptos-sdk --all-targets
77+
78+
- name: Run tests (all features)
79+
run: cargo test -p aptos-sdk --all-targets --all-features
4280

43-
- name: Install LLVM linker
44-
run: sudo apt-get update && sudo apt-get install -y lld
45-
46-
- name: Cache cargo registry
47-
uses: actions/cache@v4
48-
with:
49-
path: |
50-
~/.cargo/registry
51-
~/.cargo/git
52-
target
53-
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
54-
restore-keys: |
55-
${{ runner.os }}-cargo-${{ matrix.rust }}-
56-
${{ runner.os }}-cargo-
57-
58-
- name: Run tests (excluding examples)
59-
run: |
60-
# Test only the main crates, excluding examples
61-
# Skip network-dependent tests by setting environment variable
62-
# Skip doctests due to dependency version conflicts
63-
SKIP_NETWORK_TESTS=1 cargo test --workspace --exclude examples --lib --bins
64-
65-
- name: Run clippy
66-
run: cargo clippy --workspace --exclude examples -- -W warnings
81+
test-features:
82+
name: Test Feature Combinations
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v6
86+
87+
- name: Install Rust
88+
uses: dtolnay/rust-toolchain@master
89+
with:
90+
toolchain: "1.90"
91+
92+
- name: Cache cargo
93+
uses: Swatinem/rust-cache@v2
94+
95+
- name: Test with only ed25519
96+
run: cargo test -p aptos-sdk --no-default-features --features ed25519
97+
98+
- name: Test with only secp256k1
99+
run: cargo test -p aptos-sdk --no-default-features --features secp256k1
100+
101+
- name: Test with secp256r1
102+
run: cargo test -p aptos-sdk --features secp256r1
103+
104+
- name: Test with bls
105+
run: cargo test -p aptos-sdk --features bls
106+
107+
- name: Test with faucet
108+
run: cargo test -p aptos-sdk --features faucet
109+
110+
- name: Test with indexer
111+
run: cargo test -p aptos-sdk --features indexer
112+
113+
- name: Test with full features
114+
run: cargo test -p aptos-sdk --features full
115+
116+
# Spec tests (behavioral tests from specifications)
117+
# TODO: Re-enable once specification tests are stabilized
118+
# spec-tests:
119+
# name: Spec Tests
120+
# runs-on: ubuntu-latest
121+
# steps:
122+
# - uses: actions/checkout@v6
123+
#
124+
# - name: Install Rust
125+
# uses: dtolnay/rust-toolchain@stable
126+
#
127+
# - name: Cache cargo
128+
# uses: Swatinem/rust-cache@v2
129+
#
130+
# - name: Run spec tests
131+
# run: cargo test --test specs
132+
# working-directory: specifications/tests/rust
67133

68-
build:
69-
name: Build
134+
docs:
135+
name: Documentation
70136
runs-on: ubuntu-latest
71137
steps:
72-
- uses: actions/checkout@v4
73-
74-
- name: Install Rust
75-
uses: dtolnay/rust-toolchain@stable
138+
- uses: actions/checkout@v6
139+
140+
- name: Install Rust
141+
uses: dtolnay/rust-toolchain@master
142+
with:
143+
toolchain: "1.90"
144+
145+
- name: Cache cargo
146+
uses: Swatinem/rust-cache@v2
147+
148+
- name: Check documentation
149+
env:
150+
RUSTDOCFLAGS: -D warnings
151+
run: cargo doc -p aptos-sdk --no-deps --all-features
152+
153+
- name: Check examples documentation
154+
env:
155+
RUSTDOCFLAGS: -D warnings
156+
run: cargo doc -p aptos-sdk --all-features --document-private-items
76157

77-
- name: Install LLVM linker
78-
run: sudo apt-get update && sudo apt-get install -y lld
158+
# Deploy docs to GitHub Pages on main branch
159+
deploy-docs:
160+
name: Deploy Documentation
161+
runs-on: ubuntu-latest
162+
needs: [docs, test, lint]
163+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
164+
permissions:
165+
contents: read
166+
pages: write
167+
id-token: write
168+
environment:
169+
name: github-pages
170+
url: ${{ steps.deployment.outputs.page_url }}
171+
steps:
172+
- uses: actions/checkout@v6
173+
174+
- name: Install Rust
175+
uses: dtolnay/rust-toolchain@master
176+
with:
177+
toolchain: "1.90"
178+
179+
- name: Cache cargo
180+
uses: Swatinem/rust-cache@v2
181+
182+
- name: Build documentation
183+
env:
184+
RUSTDOCFLAGS: --cfg docsrs
185+
run: cargo doc -p aptos-sdk --no-deps --all-features
186+
187+
- name: Add redirect to main crate
188+
run: |
189+
echo '<meta http-equiv="refresh" content="0; url=aptos_sdk/index.html">' > target/doc/index.html
190+
191+
- name: Setup Pages
192+
uses: actions/configure-pages@v5
193+
194+
- name: Upload artifact
195+
uses: actions/upload-pages-artifact@v4
196+
with:
197+
path: target/doc
198+
199+
- name: Deploy to GitHub Pages
200+
id: deployment
201+
uses: actions/deploy-pages@v4
202+
203+
msrv:
204+
name: Minimum Supported Rust Version
205+
runs-on: ubuntu-latest
206+
steps:
207+
- uses: actions/checkout@v6
208+
209+
- name: Install Rust 1.85
210+
uses: dtolnay/rust-toolchain@master
211+
with:
212+
toolchain: "1.85"
213+
214+
- name: Cache cargo
215+
uses: Swatinem/rust-cache@v2
216+
217+
- name: Check MSRV
218+
run: cargo check -p aptos-sdk
79219

80-
- name: Cache cargo registry
81-
uses: actions/cache@v4
82-
with:
83-
path: |
84-
~/.cargo/registry
85-
~/.cargo/git
86-
target
87-
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
88-
restore-keys: |
89-
${{ runner.os }}-cargo-build-
90-
${{ runner.os }}-cargo-
91-
92-
- name: Build (excluding examples)
93-
run: cargo build --workspace --exclude examples --release
220+
security-audit:
221+
name: Security Audit
222+
runs-on: ubuntu-latest
223+
steps:
224+
- uses: actions/checkout@v6
225+
226+
- name: Install cargo-audit
227+
run: cargo install cargo-audit
228+
229+
- name: Run security audit
230+
run: cargo audit

0 commit comments

Comments
 (0)