Skip to content

Commit

Permalink
One time job to transfer ICP from NeuronController to OpenChat treasury
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Jan 3, 2024
1 parent c072fce commit 3a21e6c
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
use crate::ecdsa::make_canister_call_via_ecdsa;
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::Data;
use crate::{mutate_state, Data};
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use ic_cdk_macros::post_upgrade;
use icrc_ledger_types::icrc1::account::Account;
use icrc_ledger_types::icrc1::transfer::TransferArg;
use neuron_controller_canister::post_upgrade::Args;
use stable_memory::get_reader;
use std::time::Duration;
use tracing::info;
use utils::consts::SNS_GOVERNANCE_CANISTER_ID;
use utils::cycles::init_cycles_dispenser_client;

#[post_upgrade]
Expand All @@ -24,4 +29,25 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

info!(version = %args.wasm_version, "Post-upgrade complete");

ic_cdk_timers::set_timer(Duration::ZERO, || ic_cdk::spawn(transfer_to_treasury()));
}

async fn transfer_to_treasury() {
let request = mutate_state(|state| {
state.prepare_canister_call_via_ecdsa(
state.data.nns_ledger_canister_id,
"icrc1_transfer".to_string(),
&TransferArg {
from_subaccount: None,
to: Account::from(SNS_GOVERNANCE_CANISTER_ID),
fee: Some(10000u64.into()),
created_at_time: None,
memo: None,
amount: 258592708008u64.into(),
},
)
});

let _ = make_canister_call_via_ecdsa(request).await;
}

0 comments on commit 3a21e6c

Please sign in to comment.