From 70cab24c9856736270ed1515935899f106eacab2 Mon Sep 17 00:00:00 2001 From: tomkoom Date: Thu, 16 May 2024 17:40:59 +0300 Subject: [PATCH] add canisters --- src/fund.mo | 33 +++++++++++++++++++++++++++++++++ src/fund_promo.mo | 33 +++++++++++++++++++++++++++++++++ src/treasury.mo | 1 + 3 files changed, 67 insertions(+) diff --git a/src/fund.mo b/src/fund.mo index e69de29..1fc9baa 100644 --- a/src/fund.mo +++ b/src/fund.mo @@ -0,0 +1,33 @@ +import Principal "mo:base/Principal"; +import Ledger "./ledger_service"; +import C "./_constants" + +actor { + let ledger = actor (C.ledgerId) : Ledger.Self; + + public shared ({ caller }) func send(owner : Principal, amount : Nat) : async Ledger.Result { + assert (caller == Principal.fromText(C.admin1)); + + let to : Ledger.Account = { + owner; + subaccount = null; + }; + + let transferArg : Ledger.TransferArg = { + to; + fee = null; + memo = null; + from_subaccount = null; + created_at_time = null; + amount; + }; + + await ledger.icrc1_transfer(transferArg); + }; + + // test + + public shared query ({ caller }) func whoami() : async Text { + return Principal.toText(caller); + }; +}; diff --git a/src/fund_promo.mo b/src/fund_promo.mo index e69de29..1fc9baa 100644 --- a/src/fund_promo.mo +++ b/src/fund_promo.mo @@ -0,0 +1,33 @@ +import Principal "mo:base/Principal"; +import Ledger "./ledger_service"; +import C "./_constants" + +actor { + let ledger = actor (C.ledgerId) : Ledger.Self; + + public shared ({ caller }) func send(owner : Principal, amount : Nat) : async Ledger.Result { + assert (caller == Principal.fromText(C.admin1)); + + let to : Ledger.Account = { + owner; + subaccount = null; + }; + + let transferArg : Ledger.TransferArg = { + to; + fee = null; + memo = null; + from_subaccount = null; + created_at_time = null; + amount; + }; + + await ledger.icrc1_transfer(transferArg); + }; + + // test + + public shared query ({ caller }) func whoami() : async Text { + return Principal.toText(caller); + }; +}; diff --git a/src/treasury.mo b/src/treasury.mo index e69de29..ae6acba 100644 --- a/src/treasury.mo +++ b/src/treasury.mo @@ -0,0 +1 @@ +actor {}