1#[cfg(feature = "host")]
2use crate::hex::hex_bytes;
3#[cfg(feature = "host")]
4use lookup::enforce_mainnet_network;
5#[cfg(feature = "host")]
6pub(in crate::sns::report) use model::{
7 SNS_PROPOSAL_DECISION_DECIDED, SNS_PROPOSAL_DECISION_EXECUTED, SNS_PROPOSAL_DECISION_FAILED,
8 SNS_PROPOSAL_DECISION_OPEN, SNS_PROPOSAL_STATUS_ADOPTED_CODE,
9 SNS_PROPOSAL_STATUS_REJECTED_CODE,
10};
11#[cfg(all(test, feature = "host"))]
12pub(in crate::sns::report) use model::{
13 SNS_PROPOSAL_STATUS_EXECUTED_CODE, SNS_PROPOSAL_STATUS_OPEN_CODE,
14};
15pub use model::{
16 SnsCustomProposalCriticality, SnsGovernanceParameters, SnsInfoReport, SnsInfoRequest,
17 SnsListReport, SnsListRequest, SnsListRow, SnsListSort, SnsLookupRequest,
18 SnsNeuronPermissionList, SnsParamsReport, SnsParamsRequest, SnsProposalBallotRow,
19 SnsProposalEligibilityFilter, SnsProposalFailureReason, SnsProposalReport, SnsProposalRequest,
20 SnsProposalRow, SnsProposalSortDirection, SnsProposalStatusFilter, SnsProposalTally,
21 SnsProposalTopicFilter, SnsProposalsReport, SnsProposalsRequest, SnsProposalsSort,
22 SnsTokenMetadataRow, SnsTokenReport, SnsTokenRequest, SnsTokenStandardRow,
23 SnsVotingRewardsParameters,
24};
25#[cfg(feature = "host")]
26pub use model::{
27 SnsHostError, SnsNeuronRow, SnsNeuronsCacheListReport, SnsNeuronsCacheListRequest,
28 SnsNeuronsCacheStatusReport, SnsNeuronsCacheStatusRequest, SnsNeuronsCacheSummary,
29 SnsNeuronsRefreshAttemptStatus, SnsNeuronsRefreshReport, SnsNeuronsRefreshRequest,
30 SnsNeuronsReport, SnsNeuronsRequest, SnsNeuronsSort, SnsProposalsCacheListReport,
31 SnsProposalsCacheListRequest, SnsProposalsCacheStatusReport, SnsProposalsCacheStatusRequest,
32 SnsProposalsCacheSummary, SnsProposalsRefreshAttemptStatus, SnsProposalsRefreshReport,
33 SnsProposalsRefreshRequest,
34};
35#[cfg(feature = "host")]
36use source::{
37 MainnetSns, MainnetSnsCanisters, MainnetSnsList, MainnetSnsNeuronPage, MainnetSnsNeurons,
38 MainnetSnsProposal, MainnetSnsProposalPage, MainnetSnsProposals, MainnetSnsToken,
39 SnsFetchRequest, SnsListSource, SnsNeuronId, SnsNeuronsSource, SnsParamsSource,
40 SnsProposalSource, SnsProposalsSource, SnsTokenSource,
41};
42
43#[cfg(feature = "host")]
44mod assemble;
45#[cfg(feature = "host")]
46mod build;
47#[cfg(feature = "host")]
48mod cache_attempt;
49#[cfg(feature = "host")]
50mod cache_paths;
51#[cfg(feature = "host")]
52mod cache_status;
53#[cfg(feature = "host")]
54mod cache_storage;
55#[cfg(feature = "host")]
56mod cache_summary;
57#[cfg(feature = "host")]
58mod live;
59#[cfg(feature = "host")]
60mod lookup;
61mod model;
62#[cfg(feature = "host")]
63mod neurons_cache;
64#[cfg(feature = "host")]
65mod proposals_cache;
66#[cfg(feature = "host")]
67mod source;
68mod text;
69#[cfg(feature = "host")]
70mod view;
71
72#[cfg(feature = "host")]
73pub use build::{
74 build_sns_info_report, build_sns_list_report, build_sns_neurons_report,
75 build_sns_params_report, build_sns_proposal_report, build_sns_proposals_report,
76 build_sns_token_report,
77};
78#[cfg(feature = "host")]
79pub(in crate::sns::report) use cache_summary::{
80 SnsCacheListFamily, SnsCacheSummarySortKey, build_sns_cache_list_lookup,
81 find_valid_sns_cache_summary_by_id, invalid_sns_cache_summary_fields,
82 parse_sns_root_canister_input,
83};
84#[cfg(feature = "host")]
85pub use neurons_cache::{
86 DEFAULT_SNS_NEURONS_REFRESH_LOCK_STALE_SECONDS, build_sns_neurons_cache_list_report,
87 build_sns_neurons_cache_status_report, refresh_sns_neurons_cache, sns_neurons_cache_path,
88 sns_neurons_refresh_attempt_path, sns_neurons_refresh_lock_path,
89};
90#[cfg(all(test, feature = "host"))]
91use neurons_cache::{
92 SNS_NEURONS_CACHE_LIST_REPORT_SCHEMA_VERSION, SNS_NEURONS_CACHE_SCHEMA_VERSION,
93 SNS_NEURONS_CACHE_STATUS_REPORT_SCHEMA_VERSION, refresh_sns_neurons_cache_with_source,
94};
95#[cfg(all(test, feature = "host"))]
96use proposals_cache::refresh_sns_proposals_cache_with_source;
97#[cfg(feature = "host")]
98pub use proposals_cache::{
99 DEFAULT_SNS_PROPOSALS_REFRESH_LOCK_STALE_SECONDS, build_sns_proposals_cache_list_report,
100 build_sns_proposals_cache_status_report, refresh_sns_proposals_cache, sns_proposals_cache_path,
101 sns_proposals_refresh_attempt_path, sns_proposals_refresh_lock_path,
102};
103pub use text::{
104 sns_info_report_text, sns_list_report_text, sns_params_report_text, sns_proposal_report_text,
105 sns_proposals_report_text, sns_token_report_text,
106};
107#[cfg(feature = "host")]
108pub use text::{
109 sns_neurons_cache_list_report_text, sns_neurons_cache_status_report_text,
110 sns_neurons_refresh_report_text, sns_neurons_report_text, sns_proposals_cache_list_report_text,
111 sns_proposals_cache_status_report_text, sns_proposals_refresh_report_text,
112};
113
114#[cfg(all(test, feature = "host"))]
115use crate::icrc::ledger::{IcrcMetadataValue, metadata_row};
116
117#[cfg(all(test, feature = "host"))]
118use crate::subnet_catalog::{MAINNET_NETWORK, format_utc_timestamp_secs};
119
120pub const DEFAULT_SNS_SOURCE_ENDPOINT: &str = "https://icp-api.io";
121pub const MAINNET_SNS_WASM_CANISTER_ID: &str = "qaa6y-5yaaa-aaaaa-aaafa-cai";
122
123#[cfg(feature = "host")]
124const SNS_LIST_REPORT_SCHEMA_VERSION: u32 = 3;
125#[cfg(feature = "host")]
126const SNS_INFO_REPORT_SCHEMA_VERSION: u32 = 2;
127#[cfg(feature = "host")]
128const SNS_TOKEN_REPORT_SCHEMA_VERSION: u32 = 1;
129#[cfg(feature = "host")]
130const SNS_PARAMS_REPORT_SCHEMA_VERSION: u32 = 1;
131#[cfg(feature = "host")]
132const SNS_PROPOSAL_REPORT_SCHEMA_VERSION: u32 = 5;
133#[cfg(feature = "host")]
134const SNS_PROPOSALS_REPORT_SCHEMA_VERSION: u32 = 10;
135#[cfg(feature = "host")]
136const SNS_NEURONS_REPORT_SCHEMA_VERSION: u32 = 1;
137const COMPACT_PRINCIPAL_CHARS: usize = 5;
138#[cfg(all(test, feature = "host"))]
139const SNS_TOKEN_LOGO_METADATA_KEY: &str = "icrc1:logo";
140#[cfg(feature = "host")]
141const SNS_METADATA_CONCURRENCY: usize = 16;
142
143pub(super) fn short_principal(value: &str) -> String {
144 value.chars().take(COMPACT_PRINCIPAL_CHARS).collect()
145}
146
147#[cfg(all(test, feature = "host"))]
148use build::{
149 build_sns_info_report_with_source, build_sns_list_report_with_source,
150 build_sns_neurons_report_with_source, build_sns_params_report_with_source,
151 build_sns_proposal_report_with_source, build_sns_proposals_report_with_source,
152 build_sns_token_report_with_source,
153};
154
155#[cfg(all(test, feature = "host"))]
156mod tests;