/// Extracts a proposal payload from the provided command and uses it to submit
/// a proposal to the governance canister.
Extracts a proposal payload from the provided command and uses it to submit
a proposal to the governance canister.
Extracts a proposal payload from the provided command and uses it to submit a proposal to the governance canister .
async fn propose_external_proposal_from_command<
    C: CandidType + Serialize + Debug,
    Command: ProposalMetadata + ProposalTitleAndPayload<C>,
>(
    cmd: Command,
    nns_function: NnsFunction,
    nns_url: Url,
    sender: Sender,
) {
    let (proposer, sender) = cmd.proposer_and_sender(sender);
    let canister_client = GovernanceCanisterClient(make_canister_client(
        nns_url.clone(),
        GOVERNANCE_CANISTER_ID,
        sender,
        Some(proposer),
    ));
    let payload = cmd.payload(nns_url).await;
    print_payload(&payload, &cmd);
    if cmd.is_dry_run() {
        return;
    }
    let response = canister_client
        .submit_external_proposal_candid(
            payload,
            nns_function,
            cmd.url(),
            &cmd.title(),
            &cmd.summary(),
        )
        .await;
    eprintln!(
        "submit_proposal for {} response: {:?}",
        cmd.title(),
        response,
    );
    match response {
        Ok(proposal_id) => {
            println!("{}", proposal_id);
        }
        Err(e) => {
            eprintln!("submit_proposal for {} error: {:?}", cmd.title(), e);
            std::process::exit(1);
        }
    };
}
async fn propose_external_proposal_from_command < C : CandidType + Serialize + Debug , Command : ProposalMetadata + ProposalTitleAndPayload < C > , > ( cmd : Command , nns_function : NnsFunction , nns_url : Url , sender : Sender , ) { let ( proposer , sender ) = cmd . proposer_and_sender ( sender ) ; let canister_client = GovernanceCanisterClient ( make_canister_client ( nns_url . clone ( ) , GOVERNANCE_CANISTER_ID , sender , Some ( proposer ) , ) ) ; let payload = cmd . payload ( nns_url ) . await ; print_payload ( & payload , & cmd ) ; if cmd . is_dry_run ( ) { return ; } let response = canister_client . submit_external_proposal_candid ( payload , nns_function , cmd . url ( ) , & cmd . title ( ) , & cmd . summary ( ) , ) . await ; eprintln ! ( " " cmd title ( ) response ) ; match response { Ok ( proposal_id ) => { println ! ( " " proposal_id ) ; } Err ( e ) => { eprintln ! ( " " cmd title ( ) e ) ; std :: process :: exit ( 1 ) ; } } ; }
Extracts a proposal payload from the provided command and uses it to submit
a proposal to the governance canister.
Extracts a proposal payload from the provided command and uses it to submit a proposal to the governance canister .
cmd
Command
nns_function
NnsFunction
nns_url
Url
sender
Sender