#[cfg(feature = "host")]
mod assemble;
#[cfg(feature = "host")]
mod build;
#[cfg(feature = "host")]
mod cache_attempt;
#[cfg(feature = "host")]
mod cache_paths;
#[cfg(feature = "host")]
mod cache_refresh;
#[cfg(feature = "host")]
mod cache_status;
#[cfg(feature = "host")]
mod cache_storage;
#[cfg(feature = "host")]
mod cache_summary;
#[cfg(feature = "host")]
mod live;
#[cfg(feature = "host")]
mod lookup;
mod model;
#[cfg(feature = "host")]
mod neurons_cache;
#[cfg(feature = "host")]
mod proposals_cache;
#[cfg(feature = "host")]
mod source;
mod text;
#[cfg(feature = "host")]
mod view;
#[cfg(all(test, feature = "host"))]
mod tests;
#[cfg(feature = "host")]
use crate::hex::hex_bytes;
#[cfg(all(test, feature = "host"))]
use crate::icrc::ledger::{IcrcMetadataValue, metadata_row};
#[cfg(all(test, feature = "host"))]
use crate::subnet_catalog::{MAINNET_NETWORK, format_utc_timestamp_secs};
#[cfg(all(test, feature = "host"))]
use neurons_cache::{
SNS_NEURONS_CACHE_LIST_REPORT_SCHEMA_VERSION, SNS_NEURONS_CACHE_SCHEMA_VERSION,
SNS_NEURONS_CACHE_STATUS_REPORT_SCHEMA_VERSION,
};
#[cfg(feature = "host")]
use source::MainnetSnsCanisters;
#[cfg(feature = "host")]
pub use build::{
build_sns_canister_report, build_sns_canister_report_with_source, build_sns_info_report,
build_sns_info_report_with_source, build_sns_list_report, build_sns_list_report_with_source,
build_sns_neurons_report, build_sns_neurons_report_with_source, build_sns_params_report,
build_sns_params_report_with_source, build_sns_proposal_report,
build_sns_proposal_report_with_source, build_sns_proposals_report,
build_sns_proposals_report_with_progress, build_sns_proposals_report_with_source,
build_sns_token_report, build_sns_token_report_with_source,
};
#[cfg(feature = "host")]
pub(in crate::sns::report) use cache_summary::{
SnsCacheListFamily, SnsCacheSummarySortKey, build_sns_cache_list_lookup,
find_sns_cache_summary_by_id, parse_sns_root_canister_input, project_sns_cache_summary,
};
#[cfg(feature = "host")]
pub use live::LiveSnsSource;
#[cfg(feature = "host")]
pub(in crate::sns::report) use model::{
SNS_PROPOSAL_DECISION_DECIDED, SNS_PROPOSAL_DECISION_EXECUTED, SNS_PROPOSAL_DECISION_FAILED,
SNS_PROPOSAL_DECISION_OPEN, SNS_PROPOSAL_STATUS_ADOPTED_CODE,
SNS_PROPOSAL_STATUS_REJECTED_CODE,
};
#[cfg(all(test, feature = "host"))]
pub(in crate::sns::report) use model::{
SNS_PROPOSAL_STATUS_EXECUTED_CODE, SNS_PROPOSAL_STATUS_OPEN_CODE,
};
#[cfg(feature = "host")]
pub use model::{
SnsCacheListReport, SnsCacheListRequest, SnsCacheStatusReport, SnsCacheStatusRequest,
SnsCacheSummary, SnsHostError, SnsNeuronRow, SnsNeuronsRefreshReport, SnsNeuronsRefreshRequest,
SnsNeuronsReport, SnsNeuronsRequest, SnsNeuronsSort, SnsProposalsRefreshReport,
SnsProposalsRefreshRequest, SnsRefreshAttemptStatus,
};
pub use model::{
SnsCanisterGap, SnsCanisterGapKind, SnsCanisterReport, SnsCanisterRole, SnsCanisterRow,
SnsCanisterStatus, SnsCustomProposalCriticality, SnsGovernanceParameters, SnsInfoReport,
SnsListReport, SnsListRequest, SnsListRow, SnsListSort, SnsLookupRequest,
SnsNeuronPermissionList, SnsParamsReport, SnsProposalBallotRow, SnsProposalEligibilityFilter,
SnsProposalFailureReason, SnsProposalReport, SnsProposalRequest, SnsProposalRow,
SnsProposalSortDirection, SnsProposalStatusFilter, SnsProposalTally, SnsProposalTopicFilter,
SnsProposalsReport, SnsProposalsRequest, SnsProposalsSort, SnsTokenMetadataRow, SnsTokenReport,
SnsTokenStandardRow, SnsVotingRewardsParameters,
};
#[cfg(feature = "host")]
pub use neurons_cache::{
DEFAULT_SNS_NEURONS_REFRESH_LOCK_STALE_SECONDS, build_sns_neurons_cache_list_report,
build_sns_neurons_cache_status_report, refresh_sns_neurons_cache,
refresh_sns_neurons_cache_with_progress, refresh_sns_neurons_cache_with_source,
sns_neurons_cache_path, sns_neurons_refresh_attempt_path, sns_neurons_refresh_lock_path,
};
#[cfg(feature = "host")]
pub use proposals_cache::{
DEFAULT_SNS_PROPOSALS_REFRESH_LOCK_STALE_SECONDS, build_sns_proposals_cache_list_report,
build_sns_proposals_cache_status_report, refresh_sns_proposals_cache,
refresh_sns_proposals_cache_with_progress, refresh_sns_proposals_cache_with_source,
sns_proposals_cache_path, sns_proposals_refresh_attempt_path, sns_proposals_refresh_lock_path,
};
#[cfg(feature = "host")]
pub use source::{
MainnetSns, MainnetSnsCanisterInventory, MainnetSnsList, MainnetSnsNeuronPage,
MainnetSnsNeurons, MainnetSnsProposal, MainnetSnsProposalPage, MainnetSnsProposals,
MainnetSnsToken, SnsCanisterSource, SnsListSource, SnsNeuronId, SnsNeuronsSource,
SnsParamsSource, SnsProposalSource, SnsProposalsSource, SnsSourceRequest, SnsTokenSource,
};
pub use text::{
sns_canister_report_text, sns_info_report_text, sns_list_report_text, sns_params_report_text,
sns_proposal_report_text, sns_proposals_report_text, sns_token_report_text,
};
#[cfg(feature = "host")]
pub use text::{
sns_neurons_cache_list_report_text, sns_neurons_cache_status_report_text,
sns_neurons_refresh_report_text, sns_neurons_report_text, sns_proposals_cache_list_report_text,
sns_proposals_cache_status_report_text, sns_proposals_refresh_report_text,
};
pub const DEFAULT_SNS_SOURCE_ENDPOINT: &str = "https://icp-api.io";
pub const MAINNET_SNS_WASM_CANISTER_ID: &str = "qaa6y-5yaaa-aaaaa-aaafa-cai";
#[cfg(feature = "host")]
pub const SNS_REFRESH_MAX_PAGE_SIZE: u32 = 100;
#[cfg(feature = "host")]
const SNS_LIST_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_CANISTER_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_INFO_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_TOKEN_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_PARAMS_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_PROPOSAL_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_PROPOSALS_REPORT_SCHEMA_VERSION: u32 = 1;
#[cfg(feature = "host")]
const SNS_NEURONS_REPORT_SCHEMA_VERSION: u32 = 1;
const COMPACT_PRINCIPAL_CHARS: usize = 5;
#[cfg(feature = "host")]
const SNS_METADATA_CONCURRENCY: usize = 16;
#[cfg(feature = "host")]
pub(in crate::sns::report) fn enforce_mainnet_network(network: &str) -> Result<(), SnsHostError> {
crate::network::enforce_mainnet_network_with(network, |network| {
SnsHostError::UnsupportedNetwork { network }
})
}
pub(super) fn short_principal(value: &str) -> String {
value.chars().take(COMPACT_PRINCIPAL_CHARS).collect()
}