public static object HandleHelperOperation(string operation, params object[] args) { switch (operation) { case "BalanceOfVestedAddress": // retrieve the real balance of an address that has been subjected to whitepaper defined vesting period if (!Helpers.RequireArgumentLength(args, 1)) { return(false); } return(Helpers.BalanceOfVestedAddress((byte[])args[0])); case "IsPrivateSaleAllocationLocked": // if the admin method `Administration.AllocatePresalePurchase` is permanently disabled, this method will return // the timestamp the lock was put in place. return(Storage.Get(Storage.CurrentContext, StorageKeys.PrivateSaleAllocationLocked())); case "supportedStandards": // support NEP-10 by responding to supportedStandards // https://github.com/neo-project/proposals/blob/master/nep-10.mediawiki return(ICOTemplate.SupportedStandards()); case "BalanceOfSaleContribution": if (!Helpers.RequireArgumentLength(args, 1)) { return(false); } return(Helpers.BalanceOfSaleContribution((byte[])args[0])); } return(false); }
/// <summary> /// allow allocation of presale purchases by contract administrator. this allows the nOS team to allocate the nOS tokens from the private sale, company reserve, and locked incentive reserve. /// This method will not allow the private allocations to exceed the defined amount /// the state of the `LockPrivateSaleAllocation` can be determined by the public using the method `IsPrivateSaleAllocationLocked` (returns timestamp that lock was put in place) /// </summary> /// <param name="address"></param> /// <param name="amountPurchased"></param> /// <returns></returns> public static bool AllocatePrivateSalePurchase(byte[] address, string allocationType, BigInteger amountPurchased) { amountPurchased = amountPurchased * NEP5.factor; bool privateSaleLocked = Storage.Get(Storage.CurrentContext, StorageKeys.PrivateSaleAllocationLocked()).AsBigInteger() > 0; if (privateSaleLocked) { Runtime.Notify("AllocatePrivateSalePurchase() privateSaleLocked, can't allocate"); return(false); } if (allocationType != "incentive" && allocationType != "privateSale" && allocationType != "company") { return(false); } BigInteger presaleAllocationMaxValue = ICOTemplate.LockedTokenAllocationAmount() * NEP5.factor; BigInteger presaleAllocatedValue = Storage.Get(Storage.CurrentContext, StorageKeys.PresaleAllocatedValue()).AsBigInteger(); if ((presaleAllocatedValue + amountPurchased) > presaleAllocationMaxValue) { // this purchase will exceed the presale cap.. dont allow Runtime.Notify("AllocatePrivateSalePurchase() purchase will exceed max allocation"); return(false); } if (!TokenSale.SetVestingPeriodForAddress(address, allocationType, amountPurchased)) { Runtime.Notify("SetVestingPeriodForAddress() failed."); return(false); } Storage.Put(Storage.CurrentContext, StorageKeys.PresaleAllocatedValue(), presaleAllocatedValue + amountPurchased); transfer(null, address, amountPurchased); Runtime.Notify("AllocatePrivateSalePurchase() tokens allocated", address, amountPurchased, allocationType); return(true); }
/// <summary> /// once initial presale allocation completed perform lock that prevents allocation being used /// </summary> /// <returns></returns> public static bool LockPrivateSaleAllocation() { Runtime.Log("LockPrivateSaleAllocation() further presale allocations locked"); Storage.Put(Storage.CurrentContext, StorageKeys.PrivateSaleAllocationLocked(), Helpers.GetBlockTimestamp()); return(true); }