Beispiel #1
0
        private async Task StartNodeAsync()
        {
            var dto = new OsBlockchainNodeContextStartDto
            {
                ZeroSmartContract = typeof(BasicContractZero),
                ChainId           = _chainOptions.ChainId
            };

            dto.SmartContractRunnerCategory = KernelConstants.CodeCoverageRunnerCategory;
            dto.InitializationSmartContracts.AddGenesisSmartContract(
                ConsensusContractCode,
                ConsensusSmartContractAddressNameProvider.Name);

            var ownAddress = await _accountService.GetAccountAsync();

            var callList = new SystemContractDeploymentInput.Types.SystemTransactionMethodCallList();

            callList.Add(nameof(TokenContractContainer.TokenContractStub.Create), new CreateInput
            {
                Symbol      = "ELF",
                TokenName   = "ELF_Token",
                TotalSupply = TokenTotalSupply,
                Decimals    = 2,
                Issuer      = ownAddress,
                IsBurnable  = true
            });
            callList.Add(nameof(TokenContractContainer.TokenContractStub.SetPrimaryTokenSymbol),
                         new SetPrimaryTokenSymbolInput {
                Symbol = "ELF"
            });
            callList.Add(nameof(TokenContractContainer.TokenContractStub.Issue), new IssueInput
            {
                Symbol = "ELF",
                Amount = TokenTotalSupply,
                To     = ownAddress,
                Memo   = "Issue"
            });
            callList.Add(nameof(TokenContractContainer.TokenContractStub.InitialCoefficients), new Empty());

            dto.InitializationSmartContracts.AddGenesisSmartContract(
                ElectionContractCode,
                ElectionSmartContractAddressNameProvider.Name);
            dto.InitializationSmartContracts.AddGenesisSmartContract(
                TokenContractCode,
                TokenSmartContractAddressNameProvider.Name, callList);

            _blockchainNodeCtxt = await _osBlockchainNodeContextService.StartAsync(dto);
        }
        private async Task StartNodeAsync()
        {
            var ownAddress = await _accountService.GetAccountAsync();

            var callList = new List <ContractInitializationMethodCall>();

            callList.Add(nameof(TokenContractContainer.TokenContractStub.Create), new CreateInput
            {
                Symbol      = _nativeSymbol,
                TokenName   = "ELF_Token",
                TotalSupply = TokenTotalSupply,
                Decimals    = 8,
                Issuer      = ownAddress,
                IsBurnable  = true
            });
            callList.Add(nameof(TokenContractContainer.TokenContractStub.SetPrimaryTokenSymbol),
                         new SetPrimaryTokenSymbolInput {
                Symbol = _nativeSymbol
            });
            callList.Add(nameof(TokenContractContainer.TokenContractStub.Issue), new IssueInput
            {
                Symbol = _nativeSymbol,
                Amount = TokenTotalSupply,
                To     = ownAddress,
                Memo   = "Issue"
            });

            var tokenContractCode = Codes.Single(kv => kv.Key.Split(",").First().Trim().EndsWith("MultiToken")).Value;
            var dto = new OsBlockchainNodeContextStartDto
            {
                ZeroSmartContract           = typeof(BasicContractZero),
                ChainId                     = ChainHelper.ConvertBase58ToChainId("AELF"),
                SmartContractRunnerCategory = KernelConstants.CodeCoverageRunnerCategory,
            };
            var genesisSmartContractDto = new GenesisSmartContractDto
            {
                Code = tokenContractCode,
                SystemSmartContractName = TokenSmartContractAddressNameProvider.Name,
            };

            genesisSmartContractDto.AddGenesisTransactionMethodCall(callList.ToArray());
            dto.InitializationSmartContracts.Add(genesisSmartContractDto);

            await _osBlockchainNodeContextService.StartAsync(dto);
        }
        private async Task StartNodeAsync()
        {
            var dto = new OsBlockchainNodeContextStartDto
            {
                ZeroSmartContract = typeof(BasicContractZero),
                ChainId           = _chainOptions.ChainId
            };

            dto.SmartContractRunnerCategory = KernelConstants.CodeCoverageRunnerCategory;
            var consensusContractDto = new GenesisSmartContractDto
            {
                Code = ConsensusContractCode,
                SystemSmartContractName = ConsensusSmartContractAddressNameProvider.Name,
                ContractInitializationMethodCallList = new List <ContractInitializationMethodCall>()
            };

            dto.InitializationSmartContracts.Add(consensusContractDto);

            var tokenContractDto = new GenesisSmartContractDto
            {
                Code = TokenContractCode,
                SystemSmartContractName = TokenSmartContractAddressNameProvider.Name,
                ContractInitializationMethodCallList = new List <ContractInitializationMethodCall>()
            };
            var ownAddress = await _accountService.GetAccountAsync();

            tokenContractDto
            .AddGenesisTransactionMethodCall(new ContractInitializationMethodCall
            {
                MethodName = nameof(TokenContractContainer.TokenContractStub.Create), Params = new CreateInput
                {
                    Symbol      = "ELF",
                    TokenName   = "ELF_Token",
                    TotalSupply = TokenTotalSupply,
                    Decimals    = 2,
                    Issuer      = ownAddress,
                    IsBurnable  = true
                }.ToByteString()
            });

            tokenContractDto.AddGenesisTransactionMethodCall(new ContractInitializationMethodCall
            {
                MethodName = nameof(TokenContractContainer.TokenContractStub.SetPrimaryTokenSymbol),
                Params     =
                    new SetPrimaryTokenSymbolInput {
                    Symbol = "ELF"
                }.ToByteString()
            });
            tokenContractDto.AddGenesisTransactionMethodCall(new ContractInitializationMethodCall
            {
                MethodName = nameof(TokenContractContainer.TokenContractStub.Issue), Params = new IssueInput
                {
                    Symbol = "ELF",
                    Amount = TokenTotalSupply,
                    To     = ownAddress,
                    Memo   = "Issue"
                }.ToByteString()
            });

            tokenContractDto.AddGenesisTransactionMethodCall(new ContractInitializationMethodCall
            {
                MethodName = nameof(TokenContractContainer.TokenContractStub.InitialCoefficients),
                Params     = new Empty().ToByteString()
            });
            dto.InitializationSmartContracts.Add(tokenContractDto);


            var electionContractDto = new GenesisSmartContractDto
            {
                Code = ElectionContractCode,
                SystemSmartContractName = ElectionSmartContractAddressNameProvider.Name,
                ContractInitializationMethodCallList = new List <ContractInitializationMethodCall>()
            };

            dto.InitializationSmartContracts.Add(electionContractDto);

            _blockchainNodeCtxt = await _osBlockchainNodeContextService.StartAsync(dto);
        }