Exemple #1
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);
        }
Exemple #2
0
        public async Task TestCreateIDAsync()
        {
            Event idCreationEvent = _factory.GetEventReturnIDController();

            HexBigInteger filterAddressFrom = await idCreationEvent.CreateFilterAsync(AddressFrom);

            string transactionHash = await _factory.CreateIDAsync(AddressFrom, new HexBigInteger(3905820));

            string transactionHash2 = await _factory.CreateIDAsync(AddressFrom, new HexBigInteger(3905820));

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

            Assert.True(log.Count > 0);
            string controllerAddress = log[0].Event._controllerAddress;

            Assert.NotNull(controllerAddress);
        }