Skip to content

Commit a2a5dd4

Browse files
committed
[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.
1 parent 2d8bf5d commit a2a5dd4

File tree

110 files changed

+34128
-440
lines changed

Some content is hidden

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

110 files changed

+34128
-440
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: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: CI
22

33
on:
44
push:
5+
<<<<<<< HEAD
56
branches: [ main ]
67
pull_request:
78
branches: [ main ]
@@ -91,3 +92,207 @@ jobs:
9192
9293
- name: Build (excluding examples)
9394
run: cargo build --workspace --exclude examples --release
95+
||||||| parent of f0948e7 ([SDK] Introduce a replacement Rust SDK for the entirety of the existing one)
96+
=======
97+
branches: [main, develop]
98+
pull_request:
99+
branches: [main, develop]
100+
101+
env:
102+
CARGO_TERM_COLOR: always
103+
RUST_BACKTRACE: 1
104+
105+
jobs:
106+
format:
107+
name: Format
108+
runs-on: ubuntu-latest
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- name: Install Rust nightly
113+
uses: dtolnay/rust-toolchain@nightly
114+
with:
115+
components: rustfmt
116+
117+
- name: Check formatting
118+
run: cargo +nightly fmt --all -- --check
119+
120+
lint:
121+
name: Lint
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v4
125+
126+
- name: Install Rust
127+
uses: dtolnay/rust-toolchain@stable
128+
with:
129+
components: clippy
130+
131+
- name: Cache cargo
132+
uses: Swatinem/rust-cache@v2
133+
134+
- name: Run Clippy (default features)
135+
run: cargo clippy --all-targets -- -D warnings
136+
137+
- name: Run Clippy (all features)
138+
run: cargo clippy --all-targets --all-features -- -D warnings
139+
140+
- name: Run Clippy (no default features)
141+
run: cargo clippy -p aptos-rust-sdk-v2 --no-default-features -- -D warnings
142+
143+
test:
144+
name: Test
145+
runs-on: ${{ matrix.os }}
146+
strategy:
147+
fail-fast: false
148+
matrix:
149+
os: [ubuntu-latest, macos-latest, windows-latest]
150+
rust: [stable, beta]
151+
steps:
152+
- uses: actions/checkout@v4
153+
154+
- name: Install Rust ${{ matrix.rust }}
155+
uses: dtolnay/rust-toolchain@master
156+
with:
157+
toolchain: ${{ matrix.rust }}
158+
159+
- name: Cache cargo
160+
uses: Swatinem/rust-cache@v2
161+
162+
- name: Build
163+
run: cargo build --all-targets
164+
165+
- name: Run tests
166+
run: cargo test --all-targets
167+
168+
- name: Run tests (all features)
169+
run: cargo test --all-targets --all-features
170+
171+
test-features:
172+
name: Test Feature Combinations
173+
runs-on: ubuntu-latest
174+
steps:
175+
- uses: actions/checkout@v4
176+
177+
- name: Install Rust
178+
uses: dtolnay/rust-toolchain@stable
179+
180+
- name: Cache cargo
181+
uses: Swatinem/rust-cache@v2
182+
183+
- name: Test with only ed25519
184+
run: cargo test -p aptos-rust-sdk-v2 --no-default-features --features ed25519
185+
186+
- name: Test with only secp256k1
187+
run: cargo test -p aptos-rust-sdk-v2 --no-default-features --features secp256k1
188+
189+
- name: Test with secp256r1
190+
run: cargo test -p aptos-rust-sdk-v2 --features secp256r1
191+
192+
- name: Test with bls
193+
run: cargo test -p aptos-rust-sdk-v2 --features bls
194+
195+
- name: Test with faucet
196+
run: cargo test -p aptos-rust-sdk-v2 --features faucet
197+
198+
- name: Test with indexer
199+
run: cargo test -p aptos-rust-sdk-v2 --features indexer
200+
201+
- name: Test with full features
202+
run: cargo test -p aptos-rust-sdk-v2 --features full
203+
204+
docs:
205+
name: Documentation
206+
runs-on: ubuntu-latest
207+
steps:
208+
- uses: actions/checkout@v4
209+
210+
- name: Install Rust
211+
uses: dtolnay/rust-toolchain@stable
212+
213+
- name: Cache cargo
214+
uses: Swatinem/rust-cache@v2
215+
216+
- name: Check documentation
217+
env:
218+
RUSTDOCFLAGS: -D warnings
219+
run: cargo doc --no-deps --all-features
220+
221+
- name: Check examples documentation
222+
env:
223+
RUSTDOCFLAGS: -D warnings
224+
run: cargo doc -p aptos-rust-sdk-v2 --all-features --document-private-items
225+
226+
# Deploy docs to GitHub Pages on main branch
227+
deploy-docs:
228+
name: Deploy Documentation
229+
runs-on: ubuntu-latest
230+
needs: [docs, test, lint]
231+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
232+
permissions:
233+
contents: read
234+
pages: write
235+
id-token: write
236+
environment:
237+
name: github-pages
238+
url: ${{ steps.deployment.outputs.page_url }}
239+
steps:
240+
- uses: actions/checkout@v4
241+
242+
- name: Install Rust
243+
uses: dtolnay/rust-toolchain@stable
244+
245+
- name: Cache cargo
246+
uses: Swatinem/rust-cache@v2
247+
248+
- name: Build documentation
249+
env:
250+
RUSTDOCFLAGS: --cfg docsrs
251+
run: cargo doc --no-deps --all-features
252+
253+
- name: Add redirect to main crate
254+
run: |
255+
echo '<meta http-equiv="refresh" content="0; url=aptos_rust_sdk_v2/index.html">' > target/doc/index.html
256+
257+
- name: Setup Pages
258+
uses: actions/configure-pages@v4
259+
260+
- name: Upload artifact
261+
uses: actions/upload-pages-artifact@v3
262+
with:
263+
path: target/doc
264+
265+
- name: Deploy to GitHub Pages
266+
id: deployment
267+
uses: actions/deploy-pages@v4
268+
269+
msrv:
270+
name: Minimum Supported Rust Version
271+
runs-on: ubuntu-latest
272+
steps:
273+
- uses: actions/checkout@v4
274+
275+
- name: Install Rust 1.90
276+
uses: dtolnay/rust-toolchain@master
277+
with:
278+
toolchain: "1.90"
279+
280+
- name: Cache cargo
281+
uses: Swatinem/rust-cache@v2
282+
283+
- name: Check MSRV
284+
run: cargo check -p aptos-rust-sdk-v2
285+
286+
security-audit:
287+
name: Security Audit
288+
runs-on: ubuntu-latest
289+
steps:
290+
- uses: actions/checkout@v4
291+
292+
- name: Install cargo-audit
293+
run: cargo install cargo-audit
294+
295+
- name: Run security audit
296+
run: cargo audit
297+
298+
>>>>>>> f0948e7 ([SDK] Introduce a replacement Rust SDK for the entirety of the existing one)

.github/workflows/e2e.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
# Run daily at midnight UTC
10+
- cron: '0 0 * * *'
11+
workflow_dispatch:
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
RUST_BACKTRACE: 1
16+
17+
jobs:
18+
e2e-localnet:
19+
name: E2E Tests (Localnet)
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Cache cargo
29+
uses: Swatinem/rust-cache@v2
30+
31+
- name: Install Aptos CLI
32+
run: |
33+
curl -fsSL "https://aptos.dev/scripts/install_cli.py" | python3
34+
echo "$HOME/.local/bin" >> $GITHUB_PATH
35+
36+
- name: Verify Aptos CLI installation
37+
run: aptos --version
38+
39+
- name: Start localnet
40+
run: |
41+
aptos node run-localnet --with-faucet --force-restart &
42+
sleep 30
43+
# Wait for localnet to be ready
44+
for i in {1..30}; do
45+
if curl -s http://127.0.0.1:8080/v1 > /dev/null; then
46+
echo "Localnet is ready"
47+
break
48+
fi
49+
echo "Waiting for localnet... ($i)"
50+
sleep 2
51+
done
52+
53+
- name: Run E2E tests
54+
run: cargo test -p aptos-rust-sdk-v2 --features "full,faucet" -- --ignored e2e
55+
env:
56+
APTOS_LOCAL_FAUCET_URL: http://127.0.0.1:8081
57+
APTOS_LOCAL_NODE_URL: http://127.0.0.1:8080/v1
58+
59+
- name: Stop localnet
60+
if: always()
61+
run: pkill -f "aptos node" || true
62+
63+
e2e-testnet:
64+
name: E2E Tests (Testnet)
65+
runs-on: ubuntu-latest
66+
timeout-minutes: 30
67+
# Only run on main branch to avoid rate limiting
68+
if: github.ref == 'refs/heads/main'
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Install Rust
73+
uses: dtolnay/rust-toolchain@stable
74+
75+
- name: Cache cargo
76+
uses: Swatinem/rust-cache@v2
77+
78+
- name: Run testnet E2E tests
79+
run: cargo test -p aptos-rust-sdk-v2 --features "full,faucet" -- --ignored e2e_testnet
80+
env:
81+
APTOS_NETWORK: testnet
82+

0 commit comments

Comments
 (0)