0.7.47-1FE5

This commit is contained in:
2026-05-31 16:43:19 +02:00
parent 7bd6593015
commit 8b09e82b3b
39 changed files with 24260 additions and 332 deletions

View File

@@ -285,6 +285,239 @@ pub(crate) async fn demo3_search_local_dex_corpus(
})
}
/// Search request for the static upstream registry exposed through Demo3.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/Demo3UpstreamRegistrySearchRequest.ts")]
#[serde(rename_all = "camelCase")]
pub(crate) struct Demo3UpstreamRegistrySearchRequest {
/// Optional decoder-code filter.
pub decoder_code: std::option::Option<std::string::String>,
/// Optional program-id filter.
pub program_id: std::option::Option<std::string::String>,
/// Optional program-family filter.
pub program_family: std::option::Option<std::string::String>,
/// Optional surface-kind filter.
pub surface_kind: std::option::Option<std::string::String>,
/// Optional entry-kind filter.
pub entry_kind: std::option::Option<std::string::String>,
/// Optional proof-status filter.
pub proof_status: std::option::Option<std::string::String>,
/// Optional maximum number of entries to return.
pub limit: std::option::Option<u32>,
}
/// Payload returned by the Demo3 upstream registry command.
#[derive(Clone, Debug, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/Demo3UpstreamRegistryPayload.ts")]
#[serde(rename_all = "camelCase")]
pub(crate) struct Demo3UpstreamRegistryPayload {
/// Pretty JSON representation of the registry result.
pub result_json: std::string::String,
/// Structured registry result.
pub result: Demo3UpstreamRegistryResult,
}
/// Structured upstream registry result exposed through Demo3.
#[derive(Clone, Debug, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/Demo3UpstreamRegistryResult.ts")]
#[serde(rename_all = "camelCase")]
pub(crate) struct Demo3UpstreamRegistryResult {
/// Normalized request used by kb_lib.
pub request: Demo3UpstreamRegistrySearchRequest,
/// Registry summary.
pub summary: Demo3UpstreamRegistrySummary,
/// Matching entries.
pub entries: std::vec::Vec<Demo3UpstreamRegistryEntry>,
}
/// Summary of the upstream registry snapshot exposed through Demo3.
#[derive(Clone, Debug, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/Demo3UpstreamRegistrySummary.ts")]
#[serde(rename_all = "camelCase")]
pub(crate) struct Demo3UpstreamRegistrySummary {
/// Total static registry entry count before filtering.
#[ts(type = "number")]
pub total_entry_count: usize,
/// Returned entry count after filtering.
#[ts(type = "number")]
pub returned_entry_count: usize,
/// Number of entries that have a program id.
#[ts(type = "number")]
pub entries_with_program_id_count: usize,
/// Number of entries that have a discriminator.
#[ts(type = "number")]
pub entries_with_discriminator_count: usize,
/// Number of program-level seed entries.
#[ts(type = "number")]
pub program_entry_count: usize,
/// Number of instruction entries.
#[ts(type = "number")]
pub instruction_entry_count: usize,
/// Number of event entries.
#[ts(type = "number")]
pub event_entry_count: usize,
/// Number of account entries.
#[ts(type = "number")]
pub account_entry_count: usize,
/// Number of entries still unverified from upstream Git or seed data.
#[ts(type = "number")]
pub upstream_git_unverified_count: usize,
/// Number of entries mapped into decoders but not locally observed.
#[ts(type = "number")]
pub upstream_git_mapped_unverified_count: usize,
/// Number of entries observed in the local corpus.
#[ts(type = "number")]
pub upstream_git_local_corpus_observed_count: usize,
/// Number of entries materialized in local business tables.
#[ts(type = "number")]
pub upstream_git_local_corpus_materialized_count: usize,
/// Number of layout entries still unverified locally.
#[ts(type = "number")]
pub upstream_git_layout_unverified_count: usize,
}
/// One upstream registry entry exposed through Demo3.
#[derive(Clone, Debug, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/Demo3UpstreamRegistryEntry.ts")]
#[serde(rename_all = "camelCase")]
pub(crate) struct Demo3UpstreamRegistryEntry {
/// Repository name or bootstrap locator that produced the entry.
pub source_repo: std::option::Option<std::string::String>,
/// Repository-relative path or bootstrap path that produced the entry.
pub source_path: std::option::Option<std::string::String>,
/// Stable decoder code used by the registry.
pub decoder_code: std::string::String,
/// Optional Solana program id when already known by the source entry.
pub program_id: std::option::Option<std::string::String>,
/// Program family used to group related programs.
pub program_family: std::string::String,
/// Surface kind such as AMM, CLMM, launch, aggregator or core Solana.
pub surface_kind: std::string::String,
/// Entry kind: instruction, event, account or program.
pub entry_kind: std::string::String,
/// Source-level entry name.
pub entry_name: std::string::String,
/// Optional discriminator bytes encoded as lowercase hexadecimal.
pub discriminator_hex: std::option::Option<std::string::String>,
/// Optional discriminator byte length.
pub discriminator_len: std::option::Option<u16>,
/// Current proof status.
pub proof_status: std::string::String,
/// Notes that preserve uncertainty and validation requirements.
pub notes: std::string::String,
}
/// Searches the static upstream registry from Demo3.
#[tauri::command]
pub(crate) fn demo3_search_upstream_registry(
request: Demo3UpstreamRegistrySearchRequest,
) -> Result<Demo3UpstreamRegistryPayload, std::string::String> {
let service = kb_lib::UpstreamRegistryService::new();
let lib_request = to_lib_upstream_registry_request(&request);
let lib_result = service.search(&lib_request);
let ui_result = from_lib_upstream_registry_result(lib_result);
let result_json_result = serde_json::to_string_pretty(&ui_result);
let result_json = match result_json_result {
Ok(result_json) => result_json,
Err(error) => {
return Err(format!("cannot serialize upstream registry result: {}", error));
},
};
return Ok(Demo3UpstreamRegistryPayload {
result_json,
result: ui_result,
});
}
fn to_lib_upstream_registry_request(
request: &Demo3UpstreamRegistrySearchRequest,
) -> kb_lib::UpstreamRegistrySearchRequestDto {
return kb_lib::UpstreamRegistrySearchRequestDto {
decoder_code: normalize_optional_text(request.decoder_code.clone()),
program_id: normalize_optional_text(request.program_id.clone()),
program_family: normalize_optional_text(request.program_family.clone()),
surface_kind: normalize_optional_text(request.surface_kind.clone()),
entry_kind: normalize_optional_text(request.entry_kind.clone()),
proof_status: normalize_optional_text(request.proof_status.clone()),
limit: match request.limit {
Some(limit) => Some(limit as usize),
None => None,
},
};
}
fn from_lib_upstream_registry_result(
result: kb_lib::UpstreamRegistrySearchResultDto,
) -> Demo3UpstreamRegistryResult {
let mut entries = std::vec::Vec::new();
for entry in result.entries {
entries.push(from_lib_upstream_registry_entry(entry));
}
return Demo3UpstreamRegistryResult {
request: from_lib_upstream_registry_request(result.request),
summary: from_lib_upstream_registry_summary(result.summary),
entries,
};
}
fn from_lib_upstream_registry_request(
request: kb_lib::UpstreamRegistrySearchRequestDto,
) -> Demo3UpstreamRegistrySearchRequest {
return Demo3UpstreamRegistrySearchRequest {
decoder_code: request.decoder_code,
program_id: request.program_id,
program_family: request.program_family,
surface_kind: request.surface_kind,
entry_kind: request.entry_kind,
proof_status: request.proof_status,
limit: match request.limit {
Some(limit) => Some(limit as u32),
None => None,
},
};
}
fn from_lib_upstream_registry_summary(
summary: kb_lib::UpstreamRegistrySummaryDto,
) -> Demo3UpstreamRegistrySummary {
return Demo3UpstreamRegistrySummary {
total_entry_count: summary.total_entry_count,
returned_entry_count: summary.returned_entry_count,
entries_with_program_id_count: summary.entries_with_program_id_count,
entries_with_discriminator_count: summary.entries_with_discriminator_count,
program_entry_count: summary.program_entry_count,
instruction_entry_count: summary.instruction_entry_count,
event_entry_count: summary.event_entry_count,
account_entry_count: summary.account_entry_count,
upstream_git_unverified_count: summary.upstream_git_unverified_count,
upstream_git_mapped_unverified_count: summary.upstream_git_mapped_unverified_count,
upstream_git_local_corpus_observed_count: summary
.upstream_git_local_corpus_observed_count,
upstream_git_local_corpus_materialized_count: summary
.upstream_git_local_corpus_materialized_count,
upstream_git_layout_unverified_count: summary.upstream_git_layout_unverified_count,
};
}
fn from_lib_upstream_registry_entry(
entry: kb_lib::UpstreamRegistryEntryDto,
) -> Demo3UpstreamRegistryEntry {
return Demo3UpstreamRegistryEntry {
source_repo: entry.source_repo,
source_path: entry.source_path,
decoder_code: entry.decoder_code,
program_id: entry.program_id,
program_family: entry.program_family,
surface_kind: entry.surface_kind,
entry_kind: entry.entry_kind,
entry_name: entry.entry_name,
discriminator_hex: entry.discriminator_hex,
discriminator_len: entry.discriminator_len,
proof_status: entry.proof_status,
notes: entry.notes,
};
}
fn to_lib_search_request(
request: &Demo3LocalDexCorpusSearchRequest,
) -> kb_lib::LocalDexCorpusSearchRequestDto {

View File

@@ -125,6 +125,7 @@ pub async fn run() -> Result<(), kb_lib::Error> {
stop_ws_clients,
crate::demo3::open_demo3_window,
crate::demo3::demo3_search_local_dex_corpus,
crate::demo3::demo3_search_upstream_registry,
crate::demo3::demo3_discover_onchain_dex_pairs,
crate::demo3old::open_demo3old_window,
crate::demo3old::demo3old_search_local_dex_corpus,