Exemple #1
0
        //This function will only be used to create the initial ID object on login
        public async Task <ID> GetIDAsync(string address, string[] accessibleAttributes = null)
        {
            IDService idService  = new IDService(Web3, AccountService.PrivateKey, address);
            string    idcAddress = await idService.OwnerAsyncCall();

            IDControllerService idcService = new IDControllerService(Web3, AccountService.PrivateKey, idcAddress);

            ID newID = new ID
            {
                ControllerAddress = idcAddress,
                Address           = address,
                Owner             = await idcService.OwnerAsyncCall()
            };
            //Get attributes from the smart contract and add them to the ID object
            Dictionary <string, Attribute> attributes;

            if (accessibleAttributes != null)
            {
                attributes = await GetAttributesAsync(newID, accessibleAttributes);
            }
            else
            {
                attributes = await GetAttributesAsync(newID);
            }

            newID.Attributes = attributes;

            return(newID);
        }
Exemple #2
0
        public async Task <ID> DeployAsync(ID id)
        {
            FactoryService factory = new FactoryService(Web3, AccountService.PrivateKey, _factoryAddress);

            //Use the provided Factory address to create an ID + IDController
            Event         idCreationEvent   = factory.GetEventReturnIDController();
            HexBigInteger filterAddressFrom =
                await idCreationEvent.CreateFilterAsync(AccountService.GetAccountAddress());

            await factory.CreateIDAsync();

            List <EventLog <ReturnIDControllerEventDTO> > log =
                await idCreationEvent.GetFilterChanges <ReturnIDControllerEventDTO>(filterAddressFrom);

            string controllerAddress       = log[0].Event._controllerAddress;
            IDControllerService idcService =
                new IDControllerService(Web3, AccountService.PrivateKey, controllerAddress);

            id.ControllerAddress = controllerAddress;
            id.Address           = await idcService.GetIDAsyncCall();

            id.Owner = await idcService.OwnerAsyncCall();


            //Add each attribute from the ID model to the ID smart contract
            foreach (string key in id.Attributes.Keys)
            {
                Attribute attribute = id.GetAttribute(key);
                await AddAttributeAsync(id, attribute);
            }
            return(id);
        }