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 {}