public static async Task <MethodDescriptor> GetContractMethodDescriptorAsync( this ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IChainContext chainContext, Address contractAddress, string methodName, bool throwException = true) { IEnumerable <FileDescriptor> fileDescriptors; try { fileDescriptors = await transactionReadOnlyExecutionService.GetFileDescriptorsAsync(chainContext, contractAddress); } catch { if (throwException) { throw new UserFriendlyException(Error.Message[Error.InvalidContractAddress], Error.InvalidContractAddress.ToString()); } return(null); } return(fileDescriptors .Select(fileDescriptor => fileDescriptor.Services.Select(s => s.FindMethodByName(methodName)).FirstOrDefault()) .FirstOrDefault(method => method != null)); }
public ConsensusReaderFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IConsensusReaderContextService contextService) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _contextService = contextService; }
internal static async Task <MethodDescriptor> GetContractMethodDescriptorAsync( IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, Address contractAddress, string methodName) { IEnumerable <FileDescriptor> fileDescriptors; _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; try { fileDescriptors = await GetFileDescriptorsAsync(contractAddress); } catch { throw new UserFriendlyException(Error.Message[Error.InvalidContractAddress], Error.InvalidContractAddress.ToString()); } foreach (var fileDescriptor in fileDescriptors) { var method = fileDescriptor.Services.Select(s => s.FindMethodByName(methodName)).FirstOrDefault(); if (method == null) { continue; } return(method); } return(null); }
public AEDPoSReaderFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IBlockTimeProvider blockTimeProvider) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _blockTimeProvider = blockTimeProvider; }
public TokenContractMethodStubFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IChainContext chainContext) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _chainContext = chainContext; }
public HostSmartContractBridgeContext(ISmartContractBridgeService smartContractBridgeService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IAccountService accountService, IOptionsSnapshot <HostSmartContractBridgeContextOptions> options, IOptionsSnapshot <ContractOptions> contractOptions) { _smartContractBridgeService = smartContractBridgeService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _accountService = accountService; _contractOptions = contractOptions.Value; Variables = new ContextVariableDictionary(options.Value.ContextVariables); var self = this; Address GetAddress() => self.Transaction.To; _lazyStateProvider = new Lazy <ICachedStateProvider>( () => new CachedStateProvider( new ScopedStateProvider() { ContractAddress = GetAddress(), HostSmartContractBridgeContext = this }), LazyThreadSafetyMode.PublicationOnly); }
public TransactionReadOnlyExecutionServiceTests() { _transactionReadOnlyExecutionService = GetRequiredService <ITransactionReadOnlyExecutionService>(); _smartContractHelper = GetRequiredService <SmartContractHelper>(); _kernelTestHelper = GetRequiredService <KernelTestHelper>(); _defaultContractZeroCodeProvider = GetRequiredService <IDefaultContractZeroCodeProvider>(); _smartContractExecutiveProvider = GetRequiredService <ISmartContractExecutiveProvider>(); }
public MethodStubFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IChainContext chainContext, Address sender) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _chainContext = chainContext; FromAddress = sender ?? Address.FromBytes(new byte[] { }.ComputeHash()); }
public MethodStubFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IChainContext chainContext, IBlockTimeProvider blockTimeProvider) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _chainContext = chainContext; _blockTimeProvider = blockTimeProvider; }
public TransactionAppService(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IBlockchainService blockchainService) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _blockchainService = blockchainService; LocalEventBus = NullLocalEventBus.Instance; }
public SmartContractAddressUpdateService( IEnumerable <ISmartContractAddressNameProvider> smartContractAddressNameProviders, ISmartContractAddressService smartContractAddressService, ITransactionReadOnlyExecutionService transactionExecutingService) { _smartContractAddressNameProviders = smartContractAddressNameProviders; _smartContractAddressService = smartContractAddressService; _transactionExecutingService = transactionExecutingService; }
public BlockTransactionLimitProvider(ISmartContractAddressService smartContractAddressService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IBlockchainService blockchainService) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _blockchainService = blockchainService; _smartContractAddressService = smartContractAddressService; Logger = NullLogger <BlockTransactionLimitProvider> .Instance; }
public static async Task <T> ExecuteAsync <T>( this ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IChainContext chainContext, Transaction transaction, DateTime currentBlockTime) where T : class, IMessage <T>, new() { return(await ExecuteAsync <T>(transactionReadOnlyExecutionService, chainContext, transaction, currentBlockTime, true)); }
public UnitTestSmartContractAddressService(IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressProvider smartContractAddressProvider, IEnumerable <ISmartContractAddressNameProvider> smartContractAddressNameProviders, IBlockchainService blockchainService) : base(defaultContractZeroCodeProvider, transactionReadOnlyExecutionService, smartContractAddressProvider, smartContractAddressNameProviders, blockchainService) { }
public MethodStubFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IChainContext chainContext, Timestamp currentBlockTime) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _chainContext = chainContext; CurrentBlockTime = currentBlockTime; }
public DPoSInformationGenerationServiceTests() { _minerKeyPair = CryptoHelpers.GenerateKeyPair(); _accountService = GetRequiredService <IAccountService>(); _consensusInformationGenerationService = GetRequiredService <IConsensusInformationGenerationService>(); _smartContractAddressService = GetRequiredService <ISmartContractAddressService>(); _transactionReadOnlyExecutionService = GetRequiredService <ITransactionReadOnlyExecutionService>(); }
public DeployedContractAddressService(ISmartContractAddressService smartContractAddressService, IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IDeployedContractAddressProvider deployedContractAddressProvider) { _smartContractAddressService = smartContractAddressService; _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _deployedContractAddressProvider = deployedContractAddressProvider; }
public async Task GlobalSetup() { _blockchainService = GetRequiredService <IBlockchainService>(); _transactionReadOnlyExecutionService = GetRequiredService <ITransactionReadOnlyExecutionService>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _contractAddress = await _osTestHelper.DeployContract <PerformanceTestContract.PerformanceTestContract>(); _chain = await _blockchainService.GetChainAsync(); }
public TransactionResultAppService(ITransactionResultProxyService transactionResultProxyService, ITransactionManager transactionManager, IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService) { _transactionResultProxyService = transactionResultProxyService; _transactionManager = transactionManager; _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; }
public MethodStubFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService, IChainContext chainContext, IConsensusReaderContextService contextService) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; _chainContext = chainContext; _contextService = contextService; FromAddress = AsyncHelper.RunSync(() => _contextService.GetAccountAsync()); }
public DPoSInformationGenerationService(IAccountService accountService, ConsensusControlInformation controlInformation, ISmartContractAddressService smartContractAddressService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService) { _accountService = accountService; _controlInformation = controlInformation; _smartContractAddressService = smartContractAddressService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; Logger = NullLogger <DPoSInformationGenerationService> .Instance; }
public SmartContractAddressService(IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressProvider smartContractAddressProvider, IEnumerable <ISmartContractAddressNameProvider> smartContractAddressNameProviders, IBlockchainService blockchainService) { _defaultContractZeroCodeProvider = defaultContractZeroCodeProvider; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressProvider = smartContractAddressProvider; _smartContractAddressNameProviders = smartContractAddressNameProviders; _blockchainService = blockchainService; }
public TransactionAppService(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IBlockchainService blockchainService, IObjectMapper <ChainApplicationWebAppAElfModule> objectMapper, ITransactionResultStatusCacheProvider transactionResultStatusCacheProvider) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _blockchainService = blockchainService; _objectMapper = objectMapper; _transactionResultStatusCacheProvider = transactionResultStatusCacheProvider; LocalEventBus = NullLocalEventBus.Instance; Logger = NullLogger <TransactionAppService> .Instance; }
public TransactionResultAppService(ITransactionResultProxyService transactionResultProxyService, ITransactionManager transactionManager, IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IObjectMapper <ChainApplicationWebAppAElfModule> objectMapper, ITransactionResultStatusCacheProvider transactionResultStatusCacheProvider, IOptionsMonitor <WebAppOptions> optionsSnapshot) { _transactionResultProxyService = transactionResultProxyService; _transactionManager = transactionManager; _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _objectMapper = objectMapper; _transactionResultStatusCacheProvider = transactionResultStatusCacheProvider; _webAppOptions = optionsSnapshot.CurrentValue; Logger = NullLogger <TransactionResultAppService> .Instance; }
public BlockChainAppService(IBlockchainService blockchainService, ISmartContractAddressService smartContractAddressService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ITransactionManager transactionManager, ITransactionResultQueryService transactionResultQueryService, ITxHub txHub, IBlockchainStateManager blockchainStateManager ) { _blockchainService = blockchainService; _smartContractAddressService = smartContractAddressService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _transactionManager = transactionManager; _transactionResultQueryService = transactionResultQueryService; _txHub = txHub; _blockchainStateManager = blockchainStateManager; Logger = NullLogger <BlockChainAppService> .Instance; LocalEventBus = NullLocalEventBus.Instance; }
public ParallelTestHelper(IOsBlockchainNodeContextService osBlockchainNodeContextService, IAccountService accountService, IMinerService minerService, IBlockchainService blockchainService, ITxHub txHub, ISmartContractAddressService smartContractAddressService, IBlockAttachService blockAttachService, IStaticChainInformationProvider staticChainInformationProvider, ITransactionResultService transactionResultService, IOptionsSnapshot <ChainOptions> chainOptions, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService ) : base(osBlockchainNodeContextService, accountService, minerService, blockchainService, txHub, smartContractAddressService, blockAttachService, staticChainInformationProvider, transactionResultService, chainOptions) { _accountService = accountService; _staticChainInformationProvider = staticChainInformationProvider; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; }
public static async Task <T> ExecuteAsync <T>( this ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, IChainContext chainContext, Transaction transaction, Timestamp currentBlockTime, bool failedThrowException) where T : class, IMessage <T>, new() { var trace = await transactionReadOnlyExecutionService.ExecuteAsync(chainContext, transaction, currentBlockTime); if (trace.IsSuccessful()) { var obj = new T(); obj.MergeFrom(trace.ReturnValue); return(obj); } if (failedThrowException) { throw new SmartContractExecutingException(trace.Error); } return(default(T)); }
public ReaderFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ISmartContractAddressService smartContractAddressService) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; }
public ContractFileDescriptorSetAppService(IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService) { _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; }
public ReadOnlyMethodStubFactory(ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService) { _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; }