Skip to content

Commit 0111fdb

Browse files
committed
integrate progenitor fork
1 parent d2d8108 commit 0111fdb

File tree

11 files changed

+61
-61
lines changed

11 files changed

+61
-61
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,34 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
18-
19-
- name: Install Rust
20-
uses: dtolnay/rust-toolchain@1.87
21-
with:
22-
components: clippy
23-
24-
- name: Cache cargo registry
25-
uses: actions/cache@v3
26-
with:
27-
path: ~/.cargo/registry
28-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
29-
30-
- name: Cache cargo index
31-
uses: actions/cache@v3
32-
with:
33-
path: ~/.cargo/git
34-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
35-
36-
- name: Cache cargo build
37-
uses: actions/cache@v3
38-
with:
39-
path: target
40-
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
41-
42-
- name: Run tests
43-
run: cargo test --verbose
44-
45-
- name: Run clippy
46-
run: cargo clippy --all-targets --all-features -- -D warnings
17+
- uses: actions/checkout@v4
18+
19+
- name: Install toolchains
20+
uses: jdx/mise-action@v2
21+
22+
- name: Cache cargo registry
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/.cargo/registry
26+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
27+
28+
- name: Cache cargo index
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.cargo/git
32+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
33+
34+
- name: Cache cargo build
35+
uses: actions/cache@v3
36+
with:
37+
path: target
38+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
39+
40+
- name: Fetch openapi
41+
run: mise pull-openapi
42+
43+
- name: Run tests
44+
run: cargo test --verbose
45+
46+
- name: Run clippy
47+
run: cargo clippy --all-targets --all-features -- -D warnings

.mise.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ jq = "latest"
66
rust = "{{ exec(command='yq .toolchain.channel rust-toolchain.toml') }}"
77
cargo-binstall = "latest"
88
"cargo:bacon" = "latest"
9-
"cargo:cargo-progenitor" = "latest"
109

1110
[env]
1211
_.file = ['.env', '.env.local']
@@ -38,12 +37,6 @@ run = [
3837
"curl https://api.privy.io/v1/openapi.json | jq -s -f 'scripts/openapi.jq' openapi.overlay.json - | sed \"s/anyOf/oneOf/g\" > openapi.json",
3938
]
4039

41-
[tasks.generate-openapi]
42-
description = "Generate the Rust code from the OpenAPI spec"
43-
run = [
44-
"cargo progenitor --input openapi.json --output crates/privy-api --name privy-api --version 0.0.1 --interface builder --include-client=false"
45-
]
46-
4740
[tasks.gen-p256-key]
4841
description = "Generate P-256 key pair for Privy wallet owner"
4942
run = [

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ path = "examples/get_wallets.rs"
5252

5353
[build-dependencies]
5454
prettyplease = "0.2.37"
55-
progenitor = {path = "../progenitor/progenitor"}
55+
# the privy branch includes these PRs:
56+
# https://github.com/oxidecomputer/progenitor/pull/1194
57+
# https://github.com/oxidecomputer/typify/pull/894
58+
progenitor = { git = "https://github.com/arlyon/progenitor", branch = "privy" }
5659
quote = "1.0.40"
5760
serde_json = "1.0"
5861
syn = { version = "2.0.106", features = ["full", "extra-traits"] }

build.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
use std::{collections::HashMap, fs};
3434

3535
use heck::{ToPascalCase, ToSnakeCase};
36-
use progenitor::GenerationSettings;
36+
use progenitor::{GenerationSettings, OperationIdStrategy};
3737
use quote::quote;
3838
use serde_yaml::Value;
3939
use syn::{File, Item, ItemImpl, Signature};
@@ -70,7 +70,9 @@ fn main() {
7070

7171
// Step 1: Generate the base progenitor code
7272
let openapi_spec = load_openapi_spec();
73-
let mut generator = progenitor::Generator::new(&GenerationSettings::default());
73+
let mut generator = progenitor::Generator::new(
74+
&GenerationSettings::default().with_operation_id_strategy(OperationIdStrategy::OmitMissing),
75+
);
7476
let tokens = generator.generate_tokens(&openapi_spec).unwrap();
7577
let ast = syn::parse2(tokens).unwrap();
7678
let content = prettyplease::unparse(&ast);

examples/update_wallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async fn main() -> Result<()> {
6666
&wallet_id,
6767
&ctx,
6868
&UpdateWalletBody {
69-
owner: Some(OwnerInput::Variant0 {
69+
owner: Some(OwnerInput::PublicKeyOwner {
7070
public_key: public_key.to_string(),
7171
}),
7272
..Default::default()

examples/wallet_balance.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use anyhow::Result;
2020
use privy_rust::{
2121
PrivyClient,
2222
generated::types::{
23-
GetWalletBalanceAsset, GetWalletBalanceChain, GetWalletBalanceIncludeCurrency,
23+
GetWalletBalanceAsset, GetWalletBalanceAssetString, GetWalletBalanceChain,
24+
GetWalletBalanceChainString, GetWalletBalanceIncludeCurrency,
2425
},
2526
};
2627
use tracing_subscriber::EnvFilter;
@@ -55,12 +56,8 @@ async fn main() -> Result<()> {
5556
.balance()
5657
.get(
5758
&wallet_id,
58-
&GetWalletBalanceAsset::Variant0(
59-
privy_rust::generated::types::GetWalletBalanceAssetVariant0::Sol,
60-
),
61-
&GetWalletBalanceChain::Variant0(
62-
privy_rust::generated::types::GetWalletBalanceChainVariant0::Solana,
63-
),
59+
&GetWalletBalanceAsset::String(GetWalletBalanceAssetString::Sol),
60+
&GetWalletBalanceChain::String(GetWalletBalanceChainString::Solana),
6461
Some(GetWalletBalanceIncludeCurrency::Usd),
6562
)
6663
.await?;

examples/wallet_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use anyhow::Result;
2323
use hex::ToHex;
2424
use privy_rust::{
2525
AuthorizationContext, JwtUser, PrivateKeyFromFile, PrivyClient,
26-
generated::types::{HpkeEncryption, WalletExportRequest},
26+
generated::types::{HpkeEncryption, WalletExportRequestBody},
2727
};
2828
use tracing_subscriber::EnvFilter;
2929

@@ -67,7 +67,7 @@ async fn main() -> Result<()> {
6767
.export(
6868
&wallet_id,
6969
&ctx,
70-
&WalletExportRequest {
70+
&WalletExportRequestBody {
7171
encryption_type: HpkeEncryption::Hpke,
7272
recipient_public_key,
7373
},

examples/wallet_transactions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
use anyhow::Result;
2020
use privy_rust::{
2121
PrivyClient,
22-
generated::types::{WalletTransactionsAsset, WalletTransactionsChain},
22+
generated::types::{
23+
WalletTransactionsAsset, WalletTransactionsAssetString, WalletTransactionsChain,
24+
},
2325
};
2426
use tracing_subscriber::EnvFilter;
2527

@@ -53,9 +55,7 @@ async fn main() -> Result<()> {
5355
.transactions()
5456
.get(
5557
&wallet_id,
56-
&WalletTransactionsAsset::Variant0(
57-
privy_rust::generated::types::WalletTransactionsAssetVariant0::Sol,
58-
),
58+
&WalletTransactionsAsset::String(WalletTransactionsAssetString::Sol),
5959
WalletTransactionsChain::Base,
6060
None, // No cursor for first page
6161
Some(10.0), // Limit to 10 transactions

src/subclients.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl PoliciesClient {
5656
policy_id: &'a crate::generated::types::CreatePolicyRulePolicyId,
5757
ctx: &'a AuthorizationContext,
5858
body: &'a crate::generated::types::PolicyRule,
59-
) -> Result<ResponseValue<crate::generated::types::RuleResponse>, Error<()>> {
59+
) -> Result<ResponseValue<crate::generated::types::PolicyRuleResponse>, Error<()>> {
6060
let sig = generate_authorization_signatures(
6161
ctx,
6262
&self.app_id,
@@ -234,8 +234,8 @@ impl WalletsClient {
234234
&'a self,
235235
wallet_id: &'a str,
236236
ctx: &'a AuthorizationContext,
237-
body: &'a crate::generated::types::WalletExportRequest,
238-
) -> Result<ResponseValue<crate::generated::types::WalletExportResponse>, Error<()>> {
237+
body: &'a crate::generated::types::WalletExportRequestBody,
238+
) -> Result<ResponseValue<crate::generated::types::WalletExportResponseBody>, Error<()>> {
239239
let sig = generate_authorization_signatures(
240240
ctx,
241241
&self.app_id,

0 commit comments

Comments
 (0)