Skip to content

Commit 66242ab

Browse files
authored
feat(rust): implement sdk (#409)
1 parent 52c7063 commit 66242ab

38 files changed

+67718
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: E2E Rust Tests
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
permissions:
8+
contents: read
9+
10+
defaults:
11+
run:
12+
working-directory: ./rust
13+
14+
jobs:
15+
e2e:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
rust: ["stable", "beta"]
21+
22+
steps:
23+
- name: Harden the runner (Audit all outbound calls)
24+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
25+
with:
26+
egress-policy: audit
27+
28+
- name: Checkout
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
31+
- name: Setup Rust ${{ matrix.rust }}
32+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
33+
with:
34+
toolchain: ${{ matrix.rust }}
35+
36+
- name: Cache Cargo dependencies
37+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
38+
with:
39+
path: |
40+
~/.cargo/bin/
41+
~/.cargo/registry/index/
42+
~/.cargo/registry/cache/
43+
~/.cargo/git/db/
44+
rust/target/
45+
key: ${{ runner.os }}-cargo-e2e-${{ matrix.rust }}-${{ hashFiles('rust/Cargo.lock') }}
46+
47+
- name: Build project
48+
run: cargo build --verbose
49+
50+
- name: Run E2E Tests
51+
if: failure()
52+
env:
53+
CDP_API_KEY_ID: ${{ secrets.CDP_API_KEY_ID }}
54+
CDP_API_KEY_SECRET: ${{ secrets.CDP_API_KEY_SECRET }}
55+
CDP_WALLET_SECRET: ${{ secrets.CDP_WALLET_SECRET }}
56+
CDP_E2E_SMART_ACCOUNT_ADDRESS: ${{ vars.CDP_E2E_SMART_ACCOUNT_ADDRESS }}
57+
CDP_E2E_SOLANA_RPC_URL: ${{ secrets.CDP_E2E_SOLANA_RPC_URL }}
58+
CDP_E2E_SKIP_EVM_TOKEN_BALANCES: ${{ vars.CDP_E2E_SKIP_EVM_TOKEN_BALANCES }}
59+
E2E_LOGGING: true
60+
DISABLE_CDP_ERROR_REPORTING: true
61+
DISABLE_CDP_USAGE_TRACKING: true
62+
run: cargo test --test e2e --verbose -- --nocapture

.github/workflows/rust_lint.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Rust Checks
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
permissions:
8+
contents: read
9+
10+
defaults:
11+
run:
12+
working-directory: ./rust
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Harden the runner (Audit all outbound calls)
19+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
20+
with:
21+
egress-policy: audit
22+
23+
- name: Checkout
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
26+
- name: Setup Rust
27+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
28+
with:
29+
toolchain: stable
30+
components: clippy, rustfmt
31+
32+
- name: Cache Cargo dependencies
33+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
34+
with:
35+
path: |
36+
~/.cargo/bin/
37+
~/.cargo/registry/index/
38+
~/.cargo/registry/cache/
39+
~/.cargo/git/db/
40+
rust/target/
41+
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
42+
43+
- name: Build
44+
run: cargo build --verbose
45+
46+
lint:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Harden the runner (Audit all outbound calls)
50+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
51+
with:
52+
egress-policy: audit
53+
54+
- name: Checkout
55+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56+
57+
- name: Setup Rust
58+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
59+
with:
60+
toolchain: stable
61+
components: clippy, rustfmt
62+
63+
- name: Cache Cargo dependencies
64+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
65+
with:
66+
path: |
67+
~/.cargo/bin/
68+
~/.cargo/registry/index/
69+
~/.cargo/registry/cache/
70+
~/.cargo/git/db/
71+
rust/target/
72+
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
73+
74+
- name: Lint
75+
run: cargo clippy --all-targets --all-features -- -D warnings
76+
77+
format:
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Harden the runner (Audit all outbound calls)
81+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
82+
with:
83+
egress-policy: audit
84+
85+
- name: Checkout
86+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
87+
88+
- name: Setup Rust
89+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
90+
with:
91+
toolchain: stable
92+
components: clippy, rustfmt
93+
94+
- name: Check formatting
95+
run: cargo fmt --all -- --check
96+
97+
lint-examples:
98+
runs-on: ubuntu-latest
99+
defaults:
100+
run:
101+
working-directory: ./examples/rust
102+
steps:
103+
- name: Harden the runner (Audit all outbound calls)
104+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
105+
with:
106+
egress-policy: audit
107+
108+
- name: Checkout
109+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
111+
- name: Setup Rust
112+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
113+
with:
114+
toolchain: stable
115+
components: clippy, rustfmt
116+
117+
- name: Cache Cargo dependencies
118+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
119+
with:
120+
path: |
121+
~/.cargo/bin/
122+
~/.cargo/registry/index/
123+
~/.cargo/registry/cache/
124+
~/.cargo/git/db/
125+
rust/target/
126+
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
127+
128+
- name: Lint
129+
run: cargo clippy --all-targets --all-features -- -D warnings
130+
131+
format-examples:
132+
runs-on: ubuntu-latest
133+
defaults:
134+
run:
135+
working-directory: ./examples/rust
136+
steps:
137+
- name: Harden the runner (Audit all outbound calls)
138+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
139+
with:
140+
egress-policy: audit
141+
142+
- name: Checkout
143+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
144+
145+
- name: Setup Rust
146+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
147+
with:
148+
toolchain: stable
149+
components: clippy, rustfmt
150+
151+
- name: Check formatting
152+
run: cargo fmt --all -- --check
153+
154+
lockfile:
155+
runs-on: ubuntu-latest
156+
steps:
157+
- name: Harden the runner (Audit all outbound calls)
158+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
159+
with:
160+
egress-policy: audit
161+
162+
- name: Checkout
163+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
164+
165+
- name: Setup Rust
166+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
167+
with:
168+
toolchain: stable
169+
170+
- name: Check Cargo.lock
171+
run: |
172+
cargo check
173+
if [ -n "$(git diff Cargo.lock)" ]; then
174+
echo "Error: Cargo.lock was modified after running cargo check. Please commit the updated Cargo.lock file."
175+
exit 1
176+
fi

.github/workflows/rust_publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish cdp-sdk (Rust)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
id-token: write
9+
10+
defaults:
11+
run:
12+
working-directory: ./rust
13+
14+
jobs:
15+
publish:
16+
name: Publish
17+
runs-on: ubuntu-latest
18+
environment:
19+
name: crates.io
20+
url: https://crates.io/crates/cdp-sdk
21+
steps:
22+
- name: Harden the runner (Audit all outbound calls)
23+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
24+
with:
25+
egress-policy: audit
26+
27+
- name: Checkout
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
30+
- name: Setup Rust
31+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable
32+
with:
33+
toolchain: stable
34+
35+
- name: Cache Cargo dependencies
36+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
37+
with:
38+
path: |
39+
~/.cargo/bin/
40+
~/.cargo/registry/index/
41+
~/.cargo/registry/cache/
42+
~/.cargo/git/db/
43+
rust/target/
44+
key: ${{ runner.os }}-cargo-publish-${{ hashFiles('rust/Cargo.lock') }}
45+
46+
- name: Run tests
47+
run: cargo test --verbose --all-features
48+
49+
- name: Build
50+
run: cargo build --release --verbose
51+
52+
- name: Publish
53+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/rust_test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Rust Tests
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
permissions:
8+
contents: read
9+
10+
defaults:
11+
run:
12+
working-directory: ./rust
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
rust: ["stable", "beta"]
21+
22+
steps:
23+
- name: Harden the runner (Audit all outbound calls)
24+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
25+
with:
26+
egress-policy: audit
27+
28+
- name: Checkout
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
31+
- name: Setup Rust ${{ matrix.rust }}
32+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
33+
with:
34+
toolchain: ${{ matrix.rust }}
35+
36+
- name: Cache Cargo dependencies
37+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
38+
with:
39+
path: |
40+
~/.cargo/bin/
41+
~/.cargo/registry/index/
42+
~/.cargo/registry/cache/
43+
~/.cargo/git/db/
44+
rust/target/
45+
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('rust/Cargo.lock') }}
46+
47+
- name: Run unit tests
48+
run: cargo test --lib --verbose --all-features
49+
50+
- name: Run unit tests (no default features)
51+
run: cargo test --lib --verbose --no-default-features
52+
53+
- name: Run doc tests
54+
run: cargo test --verbose --doc

0 commit comments

Comments
 (0)