ic-query 0.55.0

Internet Computer query library for CloudEngine, NNS, SNS, ICRC, system canisters, and public network metadata
Documentation
use super::{FixtureSnsDiscoverySource, GOVERNANCE_A, INDEX_A, LEDGER_A};
use crate::sns::report::tests::*;

///
/// FixtureSnsTokenSource
///
/// Successful SNS ledger token source used by report tests.
///

pub(in crate::sns::report::tests) struct FixtureSnsTokenSource;

delegate_sns_discovery!(FixtureSnsTokenSource);

impl SnsTokenSource for FixtureSnsTokenSource {
    fn fetch_sns_token<'a>(
        &'a self,
        _request: &'a SnsSourceRequest,
        sns: &'a MainnetSns,
    ) -> crate::report::SourceFuture<'a, Result<MainnetSnsToken, SnsHostError>> {
        Box::pin(async move {
            assert_eq!(sns.ledger_canister_id, LEDGER_A);
            Ok(MainnetSnsToken {
                token_name: "Fixture Token".to_string(),
                token_symbol: "FIX".to_string(),
                decimals: 8,
                transfer_fee: "10_000".to_string(),
                total_supply: "1_000_000_000".to_string(),
                minting_account_owner: Some(GOVERNANCE_A.to_string()),
                minting_account_subaccount_hex: Some("000102".to_string()),
                ledger_index_canister_id: Some(INDEX_A.to_string()),
                ledger_index_error: None,
                supported_standards: vec![
                    SnsTokenStandardRow {
                        name: "ICRC-1".to_string(),
                        url: "https://github.com/dfinity/ICRC-1".to_string(),
                    },
                    SnsTokenStandardRow {
                        name: "ICRC-2".to_string(),
                        url: "https://github.com/dfinity/ICRC-2".to_string(),
                    },
                ],
                metadata: vec![
                    SnsTokenMetadataRow {
                        key: "icrc1:name".to_string(),
                        value_type: IcrcMetadataValueKind::Text,
                        value: serde_json::json!("Fixture Token"),
                    },
                    SnsTokenMetadataRow {
                        key: "icrc1:decimals".to_string(),
                        value_type: IcrcMetadataValueKind::Nat,
                        value: serde_json::json!("8"),
                    },
                    SnsTokenMetadataRow {
                        key: "icrc1:fee".to_string(),
                        value_type: IcrcMetadataValueKind::Nat,
                        value: serde_json::json!("10_000"),
                    },
                    SnsTokenMetadataRow {
                        key: "icrc1:logo".to_string(),
                        value_type: IcrcMetadataValueKind::Text,
                        value: serde_json::json!("data:image/png;base64,fixture"),
                    },
                ],
            })
        })
    }
}