From 3a21e6cc2465a56f7ba4c58a7deb5ccb6c64f15f Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 3 Jan 2024 16:44:04 +0000 Subject: [PATCH 1/2] One time job to transfer ICP from NeuronController to OpenChat treasury --- .../impl/src/lifecycle/post_upgrade.rs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/backend/canisters/neuron_controller/impl/src/lifecycle/post_upgrade.rs b/backend/canisters/neuron_controller/impl/src/lifecycle/post_upgrade.rs index f16bde16ad..1016df81a4 100644 --- a/backend/canisters/neuron_controller/impl/src/lifecycle/post_upgrade.rs +++ b/backend/canisters/neuron_controller/impl/src/lifecycle/post_upgrade.rs @@ -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] @@ -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; } From 238437b3cb673b11a344c12ad201ed5eef0c9711 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 3 Jan 2024 16:47:59 +0000 Subject: [PATCH 2/2] Update CHANGELOG --- backend/canisters/neuron_controller/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/canisters/neuron_controller/CHANGELOG.md b/backend/canisters/neuron_controller/CHANGELOG.md index c2cde791ac..1119db7a35 100644 --- a/backend/canisters/neuron_controller/CHANGELOG.md +++ b/backend/canisters/neuron_controller/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Added + +- One time job to transfer ICP from NeuronController to OpenChat treasury ([#5106](https://github.com/open-chat-labs/open-chat/pull/5106)) + ### Changed - Only disburse 1 ICP rather than full amount until we've seen it working ([#5103](https://github.com/open-chat-labs/open-chat/pull/5103))