Exemple #1
0
        /// <summary>
        /// Parse ContractPermission from json
        /// </summary>
        /// <param name="json">Json</param>
        /// <returns>Return ContractPermission</returns>
        public static ContractPermission FromJson(JObject json)
        {
            ContractPermission permission = new ContractPermission
            {
                Contract = ContractPermissionDescriptor.FromJson(json["contract"]),
                Methods  = WildcardContainer <string> .FromJson(json["methods"], u => u.GetString()),
            };

            if (permission.Methods.Any(p => string.IsNullOrEmpty(p)))
            {
                throw new FormatException();
            }
            _ = permission.Methods.ToDictionary(p => p);
            return(permission);
        }
Exemple #2
0
        private void DeserializeFromJson(JObject json)
        {
            Abi         = ContractAbi.FromJson(json["abi"]);
            Groups      = ((JArray)json["groups"]).Select(u => ContractGroup.FromJson(u)).ToArray();
            Features    = ContractFeatures.NoProperty;
            Permissions = ((JArray)json["permissions"]).Select(u => ContractPermission.FromJson(u)).ToArray();
            Trusts      = WildCardContainer <UInt160> .FromJson(json["trusts"], u => UInt160.Parse(u.AsString()));

            SafeMethods = WildCardContainer <string> .FromJson(json["safeMethods"], u => u.AsString());

            if (json["features"]["storage"].AsBoolean())
            {
                Features |= ContractFeatures.HasStorage;
            }
            if (json["features"]["payable"].AsBoolean())
            {
                Features |= ContractFeatures.Payable;
            }
        }