Beispiel #1
0
 /// <summary>
 /// Check the correctness of the script and ABI.
 /// </summary>
 /// <param name="script">The script of the contract.</param>
 /// <param name="abi">The ABI of the contract.</param>
 /// <remarks>Note: The <see cref="Script"/> passed to this method should be constructed with strict mode.</remarks>
 public static void Check(this Script script, ContractAbi abi)
 {
     foreach (ContractMethodDescriptor method in abi.Methods)
     {
         script.GetInstruction(method.Offset);
     }
     abi.GetMethod(string.Empty, 0);           // Trigger the construction of ContractAbi.methodDictionary to check the uniqueness of the method names.
     _ = abi.Events.ToDictionary(p => p.Name); // Check the uniqueness of the event names.
 }
 public ContractAbiModel(ContractAbi abi)
 {
     if (abi != null)
     {
         ContractHash = abi.Hash;
         EntryPoint   = new ContractMethodModel(abi.EntryPoint);
         Methods      = abi.Methods.Select(m => new ContractMethodModel(m)).ToArray();
         Events       = abi.Events.Select(m => new ContractEventModel(m)).ToArray();
     }
 }
Beispiel #3
0
        private static void Check(byte[] script, ContractAbi abi)
        {
            Script s = new Script(script, true);

            foreach (ContractMethodDescriptor method in abi.Methods)
            {
                s.GetInstruction(method.Offset);
            }
            abi.GetMethod(string.Empty, 0);           // Trigger the construction of ContractAbi.methodDictionary to check the uniqueness of the method names.
            _ = abi.Events.ToDictionary(p => p.Name); // Check the uniqueness of the event names.
        }
Beispiel #4
0
 /// <summary>
 /// Check the correctness of the script and ABI.
 /// </summary>
 /// <param name="script">The script of the contract.</param>
 /// <param name="abi">The ABI of the contract.</param>
 public static void Check(byte[] script, ContractAbi abi)
 {
     Check(new Script(script, true), abi);
 }