Beispiel #1
0
        private async Task <Certificate[]> IssueCertificates(string[] attributeKeys)
        {
            Certificate[] certificates = new Certificate[attributeKeys.Length];

            int i = 0;

            foreach (string key in attributeKeys)
            {
                Attribute   attr = SynAck.Id.Attributes[key];
                Certificate cert = new Certificate()
                {
                    OwningAttribute = attr,
                    Revoked         = false,
                    Location        = "CertFor" + attr.Description,
                    Hash            = "HashFor" + attr.Description
                };

                await _certificateFacade.DeployAsync(cert);

                certificates[i] = cert;
                i++;
            }

            return(certificates);
        }
Beispiel #2
0
        public async Task <Attribute> DeployAsync(Attribute attribute, string owner)
        {
            Bytes32TypeEncoder encoder         = new Bytes32TypeEncoder();
            string             transactionHash = await AttributeService.DeployContractAsync(Web3, AccountService.PrivateKey, attribute.Location, encoder.Encode(attribute.Description), attribute.Hash, owner);

            TransactionReceipt receipt = await Web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash);

            //Populating the attribute model with the new address
            attribute.Address = receipt.ContractAddress;
            attribute.Owner   = owner;

            //Iterating over certificates and deploying each one
            foreach (string key in attribute.Certificates.Keys)
            {
                Certificate cert = await _certificateFacade.DeployAsync(attribute.Certificates[key]);
                await AddCertificateAsync(attribute, cert);
            }

            return(attribute);
        }
        private async Task <Certificate> DeployCertificateAsync()
        {
            Attribute dummyAttribute = new Attribute()
            {
                Address = _accountService.GetAccountAddress()
            };

            Certificate cert = new Certificate()
            {
                Hash            = "I am a hash",
                Location        = "I am a location",
                OwningAttribute = dummyAttribute
            };

            Certificate deployed = await _facade.DeployAsync(cert);

            return(deployed);
        }