public async Task SmartContractAddress_Set_And_Get_Test() { var chain = await _smartContractHelper.CreateChainWithGenesisContractAsync(); var chainContext = new ChainContext { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }; var address = await _smartContractAddressService.GetAddressByContractNameAsync(chainContext, TestSmartContractAddressNameProvider.StringName); address.ShouldBeNull(); var dto = await _smartContractAddressService.GetSmartContractAddressAsync(chainContext, TestSmartContractAddressNameProvider.StringName); dto.ShouldBeNull(); dto = await _smartContractAddressService.GetSmartContractAddressAsync(chainContext, ZeroSmartContractAddressNameProvider.StringName); dto.SmartContractAddress.Address.ShouldBe(_smartContractAddressService.GetZeroSmartContractAddress()); dto.Irreversible.ShouldBeFalse(); address = await _smartContractAddressService.GetAddressByContractNameAsync(chainContext, ZeroSmartContractAddressNameProvider.StringName); address.ShouldBe(_smartContractAddressService.GetZeroSmartContractAddress()); await _smartContractAddressService.SetSmartContractAddressAsync(chainContext, TestSmartContractAddressNameProvider.StringName, SampleAddress.AddressList[0]); address = await _smartContractAddressService.GetAddressByContractNameAsync(chainContext, TestSmartContractAddressNameProvider.StringName); address.ShouldBe(SampleAddress.AddressList[0]); var smartContractAddressDto = await _smartContractAddressService.GetSmartContractAddressAsync(chainContext, TestSmartContractAddressNameProvider.StringName); smartContractAddressDto.SmartContractAddress.ShouldBe(new SmartContractAddress { Address = SampleAddress.AddressList[0], BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }); smartContractAddressDto.Irreversible.ShouldBeTrue(); var map = await _smartContractAddressService.GetSystemContractNameToAddressMappingAsync(chainContext); map.Count.ShouldBe(2); map[ZeroSmartContractAddressNameProvider.Name].ShouldBe(_smartContractAddressService.GetZeroSmartContractAddress()); map[TestSmartContractAddressNameProvider.Name].ShouldBe(SampleAddress.AddressList[0]); }
public override async Task <InterestedEvent> GetInterestedEventAsync(IChainContext chainContext) { if (InterestedEvent != null) { return(InterestedEvent); } var smartContractAddressDto = await _smartContractAddressService.GetSmartContractAddressAsync( chainContext, TokenSmartContractAddressNameProvider.StringName); if (smartContractAddressDto == null) { return(null); } var interestedEvent = GetInterestedEvent <CalculateFeeAlgorithmUpdated>(smartContractAddressDto.SmartContractAddress.Address); if (!smartContractAddressDto.Irreversible) { return(interestedEvent); } InterestedEvent = interestedEvent; return(InterestedEvent); }
public override async Task <InterestedEvent> GetInterestedEventAsync(IChainContext chainContext) { if (InterestedEvent != null) { return(InterestedEvent); } var smartContractAddressDto = await _smartContractAddressService.GetSmartContractAddressAsync( chainContext, ConsensusSmartContractAddressNameProvider.StringName); if (smartContractAddressDto == null) { return(null); } var interestedEvent = GetInterestedEvent <SecretSharingInformation>(smartContractAddressDto.SmartContractAddress.Address); if (!smartContractAddressDto.Irreversible) { return(interestedEvent); } InterestedEvent = interestedEvent; return(InterestedEvent); }
public override async Task <InterestedEvent> GetInterestedEventAsync(IChainContext chainContext) { if (InterestedEvent != null) { return(InterestedEvent); } var smartContractAddressDto = await _smartContractAddressService.GetSmartContractAddressAsync( chainContext, CrossChainSmartContractAddressNameProvider.StringName); if (smartContractAddressDto == null) { return(null); } var interestedEvent = GetInterestedEvent <CrossChainIndexingDataProposedEvent>(smartContractAddressDto .SmartContractAddress.Address); if (!smartContractAddressDto.Irreversible) { return(interestedEvent); } InterestedEvent = interestedEvent; return(InterestedEvent); }