Skip to content

Commit aea393c

Browse files
committed
Merge pull-request #77
2 parents fb031e7 + e07a18b commit aea393c

File tree

23 files changed

+522
-163
lines changed

23 files changed

+522
-163
lines changed

Cargo.lock

Lines changed: 1 addition & 0 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ serde = { version = "1.0.219", default-features = false, features = ["std", "der
2929
serde_json = { version = "1.0.140", default-features = false, features = ["std"] }
3030
serde_bytes = { version = "0.11", default-features = false }
3131
serde_cbor = { version = "0.11", default-features = false }
32-
serde_with = { version = "3.14.0", default-features = false, features = ["macros"] }
32+
serde_with = { version = "3.14.0", default-features = false, features = ["macros", "base64"] }
3333

3434
# Cryptography
3535
hpke = { version = "0.10", features = ["alloc", "p256", "serde_impls"], default-features = false }
@@ -74,6 +74,7 @@ borsh = { version = "1.0", features = ["std", "derive"], default-features = fals
7474
toml = { version = "0.8", default-features = false, features = ["parse", "display"] }
7575

7676
# Code generation and parsing
77+
chrono = { version = "0.4", default-features = false, features = ["clock"] }
7778
heck = { version = "0.5.0", default-features = false }
7879
prettyplease = { version = "0.2", default-features = false }
7980
proc-macro2 = { version = "1.0.95", default-features = false }

client/src/generated/external.data.v1.rs

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,10 @@ pub struct TvcApp {
518518
pub organization_id: ::prost::alloc::string::String,
519519
pub name: ::prost::alloc::string::String,
520520
pub quorum_public_key: ::prost::alloc::string::String,
521-
pub manifest_set_id: ::prost::alloc::string::String,
522-
pub share_set_id: ::prost::alloc::string::String,
521+
#[serde(default)]
522+
pub manifest_set: ::core::option::Option<TvcOperatorSet>,
523+
#[serde(default)]
524+
pub share_set: ::core::option::Option<TvcOperatorSet>,
523525
#[serde(default)]
524526
pub external_connectivity: bool,
525527
#[serde(default)]
@@ -535,9 +537,14 @@ pub struct TvcDeployment {
535537
pub id: ::prost::alloc::string::String,
536538
pub organization_id: ::prost::alloc::string::String,
537539
pub app_id: ::prost::alloc::string::String,
538-
pub manifest_id: ::prost::alloc::string::String,
539540
#[serde(default)]
540-
pub manifest: ::prost::alloc::vec::Vec<u8>,
541+
pub manifest_set: ::core::option::Option<TvcOperatorSet>,
542+
#[serde(default)]
543+
pub share_set: ::core::option::Option<TvcOperatorSet>,
544+
#[serde(default)]
545+
pub manifest: ::core::option::Option<TvcManifest>,
546+
#[serde(default)]
547+
pub manifest_approvals: ::prost::alloc::vec::Vec<TvcOperatorApproval>,
541548
pub qos_version: ::prost::alloc::string::String,
542549
#[serde(default)]
543550
pub pivot_container: ::core::option::Option<TvcContainerSpec>,
@@ -562,6 +569,67 @@ pub struct TvcContainerSpec {
562569
pub has_pull_secret: bool,
563570
}
564571
#[derive(Debug)]
572+
#[derive(::serde::Serialize, ::serde::Deserialize)]
573+
#[serde(rename_all = "camelCase")]
574+
#[derive(Clone, PartialEq)]
575+
pub struct TvcOperatorApproval {
576+
pub id: ::prost::alloc::string::String,
577+
pub manifest_id: ::prost::alloc::string::String,
578+
#[serde(default)]
579+
pub operator: ::core::option::Option<TvcOperator>,
580+
#[serde(default)]
581+
pub approval: ::prost::alloc::vec::Vec<u8>,
582+
#[serde(default)]
583+
pub created_at: ::core::option::Option<Timestamp>,
584+
#[serde(default)]
585+
pub updated_at: ::core::option::Option<Timestamp>,
586+
}
587+
#[derive(Debug)]
588+
#[derive(::serde::Serialize, ::serde::Deserialize)]
589+
#[serde(rename_all = "camelCase")]
590+
#[derive(Clone, PartialEq)]
591+
pub struct TvcOperatorSet {
592+
pub id: ::prost::alloc::string::String,
593+
pub name: ::prost::alloc::string::String,
594+
pub organization_id: ::prost::alloc::string::String,
595+
#[serde(default)]
596+
pub operators: ::prost::alloc::vec::Vec<TvcOperator>,
597+
#[serde(default)]
598+
pub threshold: u32,
599+
#[serde(default)]
600+
pub created_at: ::core::option::Option<Timestamp>,
601+
#[serde(default)]
602+
pub updated_at: ::core::option::Option<Timestamp>,
603+
}
604+
#[derive(Debug)]
605+
#[derive(::serde::Serialize, ::serde::Deserialize)]
606+
#[serde(rename_all = "camelCase")]
607+
#[derive(Clone, PartialEq)]
608+
pub struct TvcOperator {
609+
pub id: ::prost::alloc::string::String,
610+
pub name: ::prost::alloc::string::String,
611+
pub public_key: ::prost::alloc::string::String,
612+
#[serde(default)]
613+
pub created_at: ::core::option::Option<Timestamp>,
614+
#[serde(default)]
615+
pub updated_at: ::core::option::Option<Timestamp>,
616+
}
617+
#[derive(Debug)]
618+
#[serde_with::serde_as]
619+
#[derive(::serde::Serialize, ::serde::Deserialize)]
620+
#[serde(rename_all = "camelCase")]
621+
#[derive(Clone, PartialEq)]
622+
pub struct TvcManifest {
623+
pub id: ::prost::alloc::string::String,
624+
#[serde(default)]
625+
#[serde_as(as = "serde_with::base64::Base64")]
626+
pub manifest: ::prost::alloc::vec::Vec<u8>,
627+
#[serde(default)]
628+
pub created_at: ::core::option::Option<Timestamp>,
629+
#[serde(default)]
630+
pub updated_at: ::core::option::Option<Timestamp>,
631+
}
632+
#[derive(Debug)]
565633
/// An account derived from a Wallet
566634
#[derive(::serde::Serialize, ::serde::Deserialize)]
567635
#[serde(rename_all = "camelCase")]

client/src/generated/immutable.activity.v1.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,8 @@ pub struct UpsertGasUsageConfigIntent {
15751575
pub sub_org_window_limit_usd: ::prost::alloc::string::String,
15761576
/// @inject_tag: validate:"required,numeric"
15771577
pub window_duration_minutes: ::prost::alloc::string::String,
1578+
#[serde(default)]
1579+
pub enabled: ::core::option::Option<bool>,
15781580
}
15791581
#[derive(Debug)]
15801582
#[derive(::serde::Serialize, ::serde::Deserialize)]

client/src/generated/immutable.common.v1.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ impl ClientSignatureScheme {
105105
pub enum Curve {
106106
#[serde(rename = "CURVE_UNSPECIFIED")]
107107
Unspecified = 0,
108+
/// Curve SECP256K1 as defined in <https://www.secg.org/sec2-v2.pdf>
108109
#[serde(rename = "CURVE_SECP256K1")]
109110
Secp256k1 = 1,
111+
/// Curve ED25519 as defined in <https://www.rfc-editor.org/rfc/rfc8032>
110112
#[serde(rename = "CURVE_ED25519")]
111113
Ed25519 = 2,
114+
/// Curve NIST P-256 (secp256r1) as defined in <https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/papers/session6-adalier-mehmet.pdf>
115+
#[serde(rename = "CURVE_P256")]
116+
P256 = 3,
112117
}
113118
impl Curve {
114119
/// String value of the enum field names used in the ProtoBuf definition.
@@ -120,6 +125,7 @@ impl Curve {
120125
Self::Unspecified => "CURVE_UNSPECIFIED",
121126
Self::Secp256k1 => "CURVE_SECP256K1",
122127
Self::Ed25519 => "CURVE_ED25519",
128+
Self::P256 => "CURVE_P256",
123129
}
124130
}
125131
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -128,6 +134,7 @@ impl Curve {
128134
"CURVE_UNSPECIFIED" => Some(Self::Unspecified),
129135
"CURVE_SECP256K1" => Some(Self::Secp256k1),
130136
"CURVE_ED25519" => Some(Self::Ed25519),
137+
"CURVE_P256" => Some(Self::P256),
131138
_ => None,
132139
}
133140
}
@@ -1096,6 +1103,9 @@ pub enum TransactionType {
10961103
/// Unsigned Bitcoin transaction, hex encoded
10971104
#[serde(rename = "TRANSACTION_TYPE_BITCOIN")]
10981105
Bitcoin = 4,
1106+
/// Unsigned Tempo transaction. Similar to EVM transactions but includes extra fields for Tempo
1107+
#[serde(rename = "TRANSACTION_TYPE_TEMPO")]
1108+
Tempo = 5,
10991109
}
11001110
impl TransactionType {
11011111
/// String value of the enum field names used in the ProtoBuf definition.
@@ -1109,6 +1119,7 @@ impl TransactionType {
11091119
Self::Solana => "TRANSACTION_TYPE_SOLANA",
11101120
Self::Tron => "TRANSACTION_TYPE_TRON",
11111121
Self::Bitcoin => "TRANSACTION_TYPE_BITCOIN",
1122+
Self::Tempo => "TRANSACTION_TYPE_TEMPO",
11121123
}
11131124
}
11141125
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -1119,6 +1130,7 @@ impl TransactionType {
11191130
"TRANSACTION_TYPE_SOLANA" => Some(Self::Solana),
11201131
"TRANSACTION_TYPE_TRON" => Some(Self::Tron),
11211132
"TRANSACTION_TYPE_BITCOIN" => Some(Self::Bitcoin),
1133+
"TRANSACTION_TYPE_TEMPO" => Some(Self::Tempo),
11221134
_ => None,
11231135
}
11241136
}
@@ -1305,21 +1317,20 @@ impl Oauth2Provider {
13051317
}
13061318
}
13071319
/// The current stage of a TVC deployment
1320+
/// (note: leaving some space in the numbering to account for potential future stages)
13081321
#[derive(::serde::Serialize, ::serde::Deserialize)]
13091322
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13101323
pub enum TvcDeploymentStage {
13111324
#[serde(rename = "TVC_DEPLOYMENT_STAGE_UNSPECIFIED")]
13121325
Unspecified = 0,
1313-
#[serde(rename = "TVC_DEPLOYMENT_STAGE_CREATE")]
1314-
Create = 1,
13151326
#[serde(rename = "TVC_DEPLOYMENT_STAGE_APPROVE")]
1316-
Approve = 2,
1327+
Approve = 10,
13171328
#[serde(rename = "TVC_DEPLOYMENT_STAGE_PROVISION")]
1318-
Provision = 3,
1329+
Provision = 20,
13191330
#[serde(rename = "TVC_DEPLOYMENT_STAGE_LIVE")]
1320-
Live = 4,
1331+
Live = 30,
13211332
#[serde(rename = "TVC_DEPLOYMENT_STAGE_DELETE")]
1322-
Delete = 5,
1333+
Delete = 40,
13231334
}
13241335
impl TvcDeploymentStage {
13251336
/// String value of the enum field names used in the ProtoBuf definition.
@@ -1329,7 +1340,6 @@ impl TvcDeploymentStage {
13291340
pub fn as_str_name(&self) -> &'static str {
13301341
match self {
13311342
Self::Unspecified => "TVC_DEPLOYMENT_STAGE_UNSPECIFIED",
1332-
Self::Create => "TVC_DEPLOYMENT_STAGE_CREATE",
13331343
Self::Approve => "TVC_DEPLOYMENT_STAGE_APPROVE",
13341344
Self::Provision => "TVC_DEPLOYMENT_STAGE_PROVISION",
13351345
Self::Live => "TVC_DEPLOYMENT_STAGE_LIVE",
@@ -1340,7 +1350,6 @@ impl TvcDeploymentStage {
13401350
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
13411351
match value {
13421352
"TVC_DEPLOYMENT_STAGE_UNSPECIFIED" => Some(Self::Unspecified),
1343-
"TVC_DEPLOYMENT_STAGE_CREATE" => Some(Self::Create),
13441353
"TVC_DEPLOYMENT_STAGE_APPROVE" => Some(Self::Approve),
13451354
"TVC_DEPLOYMENT_STAGE_PROVISION" => Some(Self::Provision),
13461355
"TVC_DEPLOYMENT_STAGE_LIVE" => Some(Self::Live),

client/src/generated/services.coordinator.public.v1.rs

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ pub struct GetWhoamiResponse {
5454
#[derive(::serde::Serialize, ::serde::Deserialize)]
5555
#[serde(rename_all = "camelCase")]
5656
#[derive(Clone, PartialEq)]
57-
pub struct GetAttestationDocumentRequest {
58-
pub organization_id: ::prost::alloc::string::String,
59-
pub enclave_type: ::prost::alloc::string::String,
60-
}
61-
#[derive(Debug)]
62-
#[derive(::serde::Serialize, ::serde::Deserialize)]
63-
#[serde(rename_all = "camelCase")]
64-
#[derive(Clone, PartialEq)]
65-
pub struct GetAttestationDocumentResponse {
66-
#[serde(default)]
67-
pub attestation_document: ::prost::alloc::vec::Vec<u8>,
68-
}
69-
#[derive(Debug)]
70-
#[derive(::serde::Serialize, ::serde::Deserialize)]
71-
#[serde(rename_all = "camelCase")]
72-
#[derive(Clone, PartialEq)]
7357
pub struct GetSubOrgIdsRequest {
7458
pub organization_id: ::prost::alloc::string::String,
7559
pub filter_type: ::prost::alloc::string::String,
@@ -901,3 +885,41 @@ pub struct RefreshFeatureFlagsRequest {}
901885
#[serde(rename_all = "camelCase")]
902886
#[derive(Clone, Copy, PartialEq)]
903887
pub struct RefreshFeatureFlagsResponse {}
888+
#[derive(Debug)]
889+
#[derive(::serde::Serialize, ::serde::Deserialize)]
890+
#[serde(rename_all = "camelCase")]
891+
#[derive(Clone, PartialEq)]
892+
pub struct GetWalletAddressBalancesRequest {
893+
pub organization_id: ::prost::alloc::string::String,
894+
pub address: ::prost::alloc::string::String,
895+
pub caip2: ::prost::alloc::string::String,
896+
}
897+
#[derive(Debug)]
898+
#[derive(::serde::Serialize, ::serde::Deserialize)]
899+
#[serde(rename_all = "camelCase")]
900+
#[derive(Clone, PartialEq)]
901+
pub struct GetWalletAddressBalancesResponse {
902+
#[serde(default)]
903+
pub balances: ::prost::alloc::vec::Vec<AssetBalance>,
904+
}
905+
#[derive(Debug)]
906+
#[derive(::serde::Serialize, ::serde::Deserialize)]
907+
#[serde(rename_all = "camelCase")]
908+
#[derive(Clone, PartialEq)]
909+
pub struct AssetBalance {
910+
pub caip19: ::prost::alloc::string::String,
911+
pub symbol: ::prost::alloc::string::String,
912+
pub balance: ::prost::alloc::string::String,
913+
#[serde(default)]
914+
pub decimals: i32,
915+
#[serde(default)]
916+
pub display: ::core::option::Option<AssetBalanceDisplay>,
917+
}
918+
#[derive(Debug)]
919+
#[derive(::serde::Serialize, ::serde::Deserialize)]
920+
#[serde(rename_all = "camelCase")]
921+
#[derive(Clone, PartialEq)]
922+
pub struct AssetBalanceDisplay {
923+
pub usd: ::prost::alloc::string::String,
924+
pub crypto: ::prost::alloc::string::String,
925+
}

codegen/src/transform.rs

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ use syn::{
66
TypePath,
77
};
88

9+
/// List of (struct_name, field_name) pairs where Vec<u8> fields should be
10+
/// serialized/deserialized as base64.
11+
const BASE64_FIELDS: &[(&str, &str)] = &[
12+
("TvcManifest", "manifest"),
13+
// Add more fields here as needed
14+
];
15+
916
/// Top-level function to apply transformations to generated code.
1017
/// This function simply parses the content of a single file, applies transformations to each parsed item,
1118
/// and returns the result. File mutation operations happen in `main.rs`. We only deal with strings here.
@@ -188,9 +195,14 @@ fn mutate_struct(struct_value: &syn::ItemStruct) -> TokenStream {
188195
}
189196

190197
// Add `serde_with::serde_as` attribute if needed
191-
let serde_as_added = add_serde_as_for_large_int(&mut field);
198+
let serde_as_added_int = add_serde_as_for_large_int(&mut field);
199+
let serde_as_added_base64 =
200+
add_serde_as_for_base64(&mut field, &struct_ident.to_string());
192201

193-
(quote! { #field }, serde_as_added)
202+
(
203+
quote! { #field },
204+
serde_as_added_int || serde_as_added_base64,
205+
)
194206
})
195207
.collect();
196208

@@ -246,6 +258,58 @@ fn strip_prost_derive_from_attr(attr: &syn::Attribute) -> Option<proc_macro2::To
246258
})
247259
}
248260

261+
/// Adds base64 serialization for Vec<u8> fields listed in BASE64_FIELDS.
262+
/// Returns true if the field was mutated.
263+
pub fn add_serde_as_for_base64(field: &mut Field, struct_name: &str) -> bool {
264+
let field_name = match &field.ident {
265+
Some(ident) => ident.to_string(),
266+
None => return false,
267+
};
268+
269+
// Check if this (struct, field) pair is in our base64 list
270+
if !BASE64_FIELDS
271+
.iter()
272+
.any(|(s, f)| *s == struct_name && *f == field_name)
273+
{
274+
return false;
275+
}
276+
277+
// Verify the field type is Vec<u8>
278+
if !is_vec_u8(&field.ty) {
279+
return false;
280+
}
281+
282+
field
283+
.attrs
284+
.push(syn::parse_quote!(#[serde_as(as = "serde_with::base64::Base64")]));
285+
true
286+
}
287+
288+
fn is_vec_u8(ty: &Type) -> bool {
289+
match ty {
290+
Type::Path(TypePath { qself: None, path }) => {
291+
let seg = match path.segments.last() {
292+
Some(s) => s,
293+
None => return false,
294+
};
295+
296+
if seg.ident == "Vec" {
297+
if let PathArguments::AngleBracketed(ab) = &seg.arguments {
298+
if let Some(GenericArgument::Type(Type::Path(TypePath {
299+
qself: None,
300+
path: inner,
301+
}))) = ab.args.first()
302+
{
303+
return inner.segments.len() == 1 && inner.segments[0].ident == "u8";
304+
}
305+
}
306+
}
307+
false
308+
}
309+
_ => false,
310+
}
311+
}
312+
249313
// This modifies fields which are u64, i64, u128, i128 (or their option variants: Option<u64>, etc)
250314
// and uses `serde_with::serde_as` so these big ints can be parsed from JSON strings.
251315
// Returns a boolean to indicate whether the field was mutated or not.

proto/external/crypto/v1/crypto.proto

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,3 @@ enum PayloadEncoding {
5656
// Will be converted to bytes for signing using serde_json::from_str
5757
PAYLOAD_ENCODING_EIP7702_AUTHORIZATION = 4;
5858
}
59-
60-
enum Curve {
61-
CURVE_UNSPECIFIED = 0;
62-
// Curve SECP256K1 as defined in https://www.secg.org/sec2-v2.pdf
63-
CURVE_SECP256K1 = 1;
64-
// Curve ED25519 as defined in https://www.rfc-editor.org/rfc/rfc8032
65-
CURVE_ED25519 = 2;
66-
}

0 commit comments

Comments
 (0)