Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3. using Neo.SmartContract.Framework;
  4. using Neo.SmartContract.Framework.Services.Neo;
  5.  
  6.  
  7. namespace CheckFuncContract
  8. {
  9.     /// <summary>
  10.     /// Multiownable logic.
  11.     /// </summary>
  12.     public static class Multiownable
  13.     {
  14.         /// <summary>
  15.         /// Sha256 by OpCode.
  16.         /// </summary>
  17.         /// <param name="byteArray"></param>
  18.         /// <returns></returns>
  19.         [OpCode(Neo.VM.OpCode.SHA256)]
  20.         public extern static byte[] Sha256(byte[] byteArray);
  21.  
  22.         /// <summary>
  23.         /// Check accepted by some owners.
  24.         /// </summary>
  25.         /// <param name="originator"></param>
  26.         /// <param name="functionName"></param>
  27.         /// <param name="ownersCount"></param>
  28.         /// <param name="args"></param>
  29.         /// <returns></returns>
  30.         public static Boolean IsAcceptedBySomeOwners(Byte[] originator,
  31.             String functionName, BigInteger ownersCount, params Object[] args)
  32.         {
  33.             // Convert and concat.
  34.             byte[] mainArray = functionName.AsByteArray().Concat(ownersCount.AsByteArray());
  35.             for (int i = 0; i < args.Length; i++)
  36.                 mainArray.Concat((byte[])args[0]);
  37.  
  38.             // Get Sha256.
  39.             byte[] shaMainArray = Sha256(mainArray);
  40.  
  41.             // Check timeout.
  42.             var timeout = Storage.Get(Storage.CurrentContext, mainArray.Concat("timeout".AsByteArray()));
  43.             uint curDate = Runtime.Time;
  44.  
  45.             if (curDate > (uint)timeout.AsBigInteger())
  46.             {
  47.                 Runtime.Log("Overdue.");
  48.                 return false;
  49.             }
  50.  
  51.             // TODO : Check all votes and return true or false.
  52.             for (int i = 0; i < ownersCount; i++)
  53.             {
  54.                
  55.             }
  56.  
  57.             return false;
  58.         }
  59.  
  60.         /// <summary>
  61.         /// Return owner count.
  62.         /// </summary>
  63.         /// <returns></returns>
  64.         public static BigInteger GetOwnerCount()
  65.         {
  66.             // TODO : Get owner count.
  67.             return 0;
  68.         }
  69.  
  70.         /// <summary>
  71.         /// Return index by owner.
  72.         /// </summary>
  73.         /// <param name="owner"></param>
  74.         /// <returns></returns>
  75.         public static Byte GetIndexByOwner(Byte[] owner)
  76.         {
  77.             // TODO : Get index by owner.
  78.             return 0;
  79.         }
  80.        
  81.         /// <summary>
  82.         /// Return owner by index.
  83.         /// </summary>
  84.         /// <param name="index"></param>
  85.         /// <returns></returns>
  86.         public static Byte[] GetOwnerByIndex(Byte index)
  87.         {
  88.             // TODO : Get owner by index.
  89.             return new byte[] { };
  90.         }
  91.  
  92.         /// <summary>
  93.         /// Set new owners.
  94.         /// </summary>
  95.         /// <param name="newOwners"></param>
  96.         /// <returns></returns>
  97.         public static Boolean TransferOwnership(params Object[] newOwners)
  98.         {
  99.             // TODO : TransferOwnership.
  100.             return false;
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement