public ApiLogDeserializer(IContractPrimitiveSerializer primitiveSerializer, Network network, IStateRepositoryRoot stateRepositoryRoot, IContractAssemblyCache contractAssemblyCache) { this.primitiveSerializer = primitiveSerializer; this.network = network; this.stateRepositoryRoot = stateRepositoryRoot; this.contractAssemblyCache = contractAssemblyCache; }
public Unity3dController(ILoggerFactory loggerFactory, IAddressIndexer addressIndexer, IBlockStore blockStore, IChainState chainState, Network network, ICoinView coinView, WalletController walletController, ChainIndexer chainIndexer, INFTTransferIndexer NFTTransferIndexer, IStakeChain stakeChain = null, IContractPrimitiveSerializer primitiveSerializer = null, IStateRepositoryRoot stateRoot = null, IContractAssemblyCache contractAssemblyCache = null, IReceiptRepository receiptRepository = null, ISmartContractTransactionService smartContractTransactionService = null, ILocalExecutor localExecutor = null) { Guard.NotNull(loggerFactory, nameof(loggerFactory)); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.addressIndexer = Guard.NotNull(addressIndexer, nameof(addressIndexer)); this.blockStore = Guard.NotNull(blockStore, nameof(blockStore)); this.chainState = Guard.NotNull(chainState, nameof(chainState)); this.network = Guard.NotNull(network, nameof(network)); this.coinView = Guard.NotNull(coinView, nameof(coinView)); this.walletController = Guard.NotNull(walletController, nameof(walletController)); this.chainIndexer = Guard.NotNull(chainIndexer, nameof(chainIndexer)); this.stakeChain = stakeChain; this.NFTTransferIndexer = NFTTransferIndexer; this.primitiveSerializer = primitiveSerializer; this.stateRoot = stateRoot; this.contractAssemblyCache = contractAssemblyCache; this.receiptRepository = receiptRepository; this.smartContractTransactionService = smartContractTransactionService; this.localExecutor = localExecutor; }
public SmartContractTransactionService( Network network, IWalletManager walletManager, IWalletTransactionHandler walletTransactionHandler, IMethodParameterStringSerializer methodParameterStringSerializer, ICallDataSerializer callDataSerializer, IAddressGenerator addressGenerator, IStateRepositoryRoot stateRoot, IReserveUtxoService reserveUtxoService, IBlockStore blockStore, ChainIndexer chainIndexer, IContractPrimitiveSerializer primitiveSerializer, IContractAssemblyCache contractAssemblyCache, IReceiptRepository receiptRepository ) { this.network = network; this.walletManager = walletManager; this.walletTransactionHandler = walletTransactionHandler; this.methodParameterStringSerializer = methodParameterStringSerializer; this.callDataSerializer = callDataSerializer; this.addressGenerator = addressGenerator; this.stateRoot = stateRoot; this.reserveUtxoService = reserveUtxoService; this.blockStore = blockStore; this.chainIndexer = chainIndexer; this.primitiveSerializer = primitiveSerializer; this.contractAssemblyCache = contractAssemblyCache; this.receiptRepository = receiptRepository; }
public SmartContractsController(IBroadcasterManager broadcasterManager, IBlockStoreCache blockStoreCache, ConcurrentChain chain, IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, Network network, IContractStateRoot stateRoot, IWalletManager walletManager, IWalletTransactionHandler walletTransactionHandler, IAddressGenerator addressGenerator, IContractPrimitiveSerializer contractPrimitiveSerializer, IReceiptRepository receiptRepository) { this.stateRoot = stateRoot; this.walletTransactionHandler = walletTransactionHandler; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.network = network; this.coinType = (CoinType)network.Consensus.CoinType; this.chain = chain; this.blockStoreCache = blockStoreCache; this.walletManager = walletManager; this.broadcasterManager = broadcasterManager; this.addressGenerator = addressGenerator; this.contractPrimitiveSerializer = contractPrimitiveSerializer; this.receiptRepository = receiptRepository; }
public SmartContractsController(IBroadcasterManager broadcasterManager, IBlockStore blockStore, ChainIndexer chainIndexer, CSharpContractDecompiler contractDecompiler, ILoggerFactory loggerFactory, Network network, IStateRepositoryRoot stateRoot, IWalletManager walletManager, ISerializer serializer, IContractPrimitiveSerializer primitiveSerializer, IReceiptRepository receiptRepository, ILocalExecutor localExecutor, ISmartContractTransactionService smartContractTransactionService, IConnectionManager connectionManager) { this.stateRoot = stateRoot; this.contractDecompiler = contractDecompiler; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.network = network; this.chainIndexer = chainIndexer; this.blockStore = blockStore; this.walletManager = walletManager; this.broadcasterManager = broadcasterManager; this.serializer = serializer; this.primitiveSerializer = primitiveSerializer; this.receiptRepository = receiptRepository; this.localExecutor = localExecutor; this.smartContractTransactionService = smartContractTransactionService; this.connectionManager = connectionManager; }
/// <summary> /// Serializes the log and topics to bytes. /// </summary> /// <returns></returns> private (List <byte[]>, List <byte[]>) Serialize(IContractPrimitiveSerializer serializer) { var logType = this.LogStruct.GetType(); // first topic is the log type name var logTypeName = serializer.Serialize(logType.Name); var topics = new List <byte[]> { logTypeName }; var fields = new List <byte[]>(); // rest of the topics are the indexed fields. foreach (FieldInfo field in logType.GetFields()) { object value = field.GetValue(this.LogStruct); byte[] serialized = value != null ? serializer.Serialize(value) : new byte[0]; if (field.CustomAttributes.Any(y => y.AttributeType == typeof(IndexAttribute))) { // It's an index, add to the topics topics.Add(serialized); } fields.Add(serialized); } return(topics, fields); }
public ContractParameterSerializationTests(PoWMockChainFixture fixture) { this.mockChain = fixture.Chain; this.node1 = this.mockChain.Nodes[0]; this.node2 = this.mockChain.Nodes[1]; this.serializer = new ContractPrimitiveSerializer(this.mockChain.Network); }
public State( IContractPrimitiveSerializer serializer, InternalTransactionExecutorFactory internalTransactionExecutorFactory, ISmartContractVirtualMachine vm, IContractStateRoot repository, IBlock block, Network network, ulong txAmount, uint256 transactionHash, IAddressGenerator addressGenerator, Gas gasLimit) { this.intermediateState = repository; this.LogHolder = new ContractLogHolder(network); this.internalTransfers = new List <TransferInfo>(); this.BalanceState = new BalanceState(this.intermediateState, txAmount, this.InternalTransfers); this.Network = network; this.Nonce = 0; this.Block = block; this.TransactionHash = transactionHash; this.AddressGenerator = addressGenerator; this.InternalTransactionExecutorFactory = internalTransactionExecutorFactory; this.Vm = vm; this.GasRemaining = gasLimit; this.Serializer = serializer; }
protected ContractParameterSerializationTests(T fixture) { this.mockChain = fixture.Chain; this.node1 = this.mockChain.Nodes[0]; this.node2 = this.mockChain.Nodes[1]; this.serializer = new ContractPrimitiveSerializer(this.node1.CoreNode.FullNode.Network); }
public MeteredContractLogger(IGasMeter gasMeter, IContractLogger logger, Network network, IContractPrimitiveSerializer serializer) { this.gasMeter = gasMeter; this.logger = logger; this.network = network; this.serializer = serializer; }
public SmartContractStateFactory(IContractPrimitiveSerializer serializer, Network network, IInternalExecutorFactory internalTransactionExecutorFactory) { this.Serializer = serializer; this.Network = network; this.InternalTransactionExecutorFactory = internalTransactionExecutorFactory; }
/// <summary> /// Transforms this log into the log type used by consensus. /// /// TODO: Cache this value. /// </summary> public Log ToLog(IContractPrimitiveSerializer serializer) { (List <byte[]> topics, List <byte[]> fields) = this.Serialize(serializer); byte[] encodedFields = RLP.EncodeList(fields.Select(RLP.EncodeElement).ToArray()); return(new Log(this.ContractAddress, topics, encodedFields)); }
public SmartContractStateFactory(IContractPrimitiveSerializer primitiveSerializer, IInternalExecutorFactory internalTransactionExecutorFactory, ISerializer serializer) { this.serializer = serializer; this.PrimitiveSerializer = primitiveSerializer; this.InternalTransactionExecutorFactory = internalTransactionExecutorFactory; }
/// <summary> /// Instantiate a new PersistentState instance. Each PersistentState object represents /// a slice of state for a particular contract address. /// </summary> public PersistentState( IPersistenceStrategy persistenceStrategy, IContractPrimitiveSerializer contractPrimitiveSerializer, uint160 contractAddress) { this.persistenceStrategy = persistenceStrategy; this.Serializer = contractPrimitiveSerializer; this.ContractAddress = contractAddress; }
public LocalExecutor(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IStateRepositoryRoot stateRoot, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.stateRoot = stateRoot; this.serializer = serializer; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
public ReflectionSmartContractExecutorFactory(ILoggerFactory loggerFactory, IContractPrimitiveSerializer contractPrimitiveSerializer, ICallDataSerializer serializer, ISmartContractResultRefundProcessor refundProcessor, ISmartContractResultTransferProcessor transferProcessor, ISmartContractVirtualMachine vm) { this.loggerFactory = loggerFactory; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.vm = vm; this.contractPrimitiveSerializer = contractPrimitiveSerializer; this.serializer = serializer; }
public StateFactory( Network network, IContractPrimitiveSerializer contractPrimitiveSerializer, ISmartContractVirtualMachine vm, IAddressGenerator addressGenerator, InternalTransactionExecutorFactory internalTransactionExecutorFactory ) { this.network = network; this.contractPrimitiveSerializer = contractPrimitiveSerializer; this.vm = vm; this.addressGenerator = addressGenerator; this.internalTransactionExecutorFactory = internalTransactionExecutorFactory; }
public Executor(ILoggerFactory loggerFactory, IContractPrimitiveSerializer contractPrimitiveSerializer, ICallDataSerializer serializer, IContractStateRepository stateSnapshot, ISmartContractResultRefundProcessor refundProcessor, ISmartContractResultTransferProcessor transferProcessor, ISmartContractVirtualMachine vm) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.contractPrimitiveSerializer = contractPrimitiveSerializer; this.stateSnapshot = stateSnapshot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.vm = vm; this.serializer = serializer; }
public ReflectionExecutorFactory(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IContractRefundProcessor refundProcessor, IContractTransferProcessor transferProcessor, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.loggerFactory = loggerFactory; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
/// <summary> /// Transforms this log into the log type used by consensus. /// </summary> public Log ToLog(IContractPrimitiveSerializer serializer) { var topics = new List <byte[]>(); // first topic is the log type name topics.Add(Encoding.UTF8.GetBytes(this.LogStruct.GetType().Name)); // rest of the topics are the indexed fields. TODO: This currently gets all fields. foreach (FieldInfo field in this.LogStruct.GetType().GetFields()) { object value = field.GetValue(this.LogStruct); byte[] serialized = serializer.Serialize(value); topics.Add(serialized); } return(new Log(this.ContractAddress, topics, serializer.Serialize(this.LogStruct))); }
public ContractExecutor( ICallDataSerializer serializer, IStateRepository stateRoot, IContractRefundProcessor refundProcessor, IContractTransferProcessor transferProcessor, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.stateRoot = stateRoot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
/// <summary> /// Transforms this log into the log type used by consensus. /// /// TODO: Cache this value. /// </summary> public Log ToLog(IContractPrimitiveSerializer serializer) { var topics = new List <byte[]>(); // first topic is the log type name topics.Add(Encoding.UTF8.GetBytes(this.LogStruct.GetType().Name)); // rest of the topics are the indexed fields. foreach (FieldInfo field in this.LogStruct.GetType().GetFields().Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(IndexAttribute)))) { object value = field.GetValue(this.LogStruct); byte[] serialized = serializer.Serialize(value); topics.Add(serialized); } return(new Log(this.ContractAddress, topics, serializer.Serialize(this.LogStruct))); }
public ReflectionVirtualMachine(ISmartContractValidator validator, InternalTransactionExecutorFactory internalTransactionExecutorFactory, ILoggerFactory loggerFactory, Network network, IAddressGenerator addressGenerator, ILoader assemblyLoader, IContractModuleDefinitionReader moduleDefinitionReader, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.validator = validator; this.internalTransactionExecutorFactory = internalTransactionExecutorFactory; this.logger = loggerFactory.CreateLogger(this.GetType()); this.network = network; this.addressGenerator = addressGenerator; this.assemblyLoader = assemblyLoader; this.moduleDefinitionReader = moduleDefinitionReader; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
public ContractExecutor(ILoggerFactory loggerFactory, ICallDataSerializer serializer, IStateRepository stateRoot, IContractRefundProcessor refundProcessor, IContractTransferProcessor transferProcessor, Network network, IStateFactory stateFactory, IStateProcessor stateProcessor, IContractPrimitiveSerializer contractPrimitiveSerializer) { this.logger = loggerFactory.CreateLogger(this.GetType()); this.stateRoot = stateRoot; this.refundProcessor = refundProcessor; this.transferProcessor = transferProcessor; this.serializer = serializer; this.network = network; this.stateFactory = stateFactory; this.stateProcessor = stateProcessor; this.contractPrimitiveSerializer = contractPrimitiveSerializer; }
public IndexerContractsController( Network network, ILoggerFactory loggerFactory, IStateRepositoryRoot stateRoot, CSharpContractDecompiler contractDecompiler, IReceiptRepository receiptRepository, IContractPrimitiveSerializer primitiveSerializer, IContractAssemblyCache contractAssemblyCache, ISmartContractEnrichmentFactory contractEnrichmentFactory, ISerializer serializer) { this.network = network; this.stateRoot = stateRoot; this.contractDecompiler = contractDecompiler; this.receiptRepository = receiptRepository; this.primitiveSerializer = primitiveSerializer; this.contractAssemblyCache = contractAssemblyCache; this.serializer = serializer; this.contractEnrichmentFactory = contractEnrichmentFactory; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); }
/// <summary> /// Returns contract logs in the log type used by consensus. /// </summary> public IList <Log> GetLogs(IContractPrimitiveSerializer serializer) { return(this.LogHolder.GetRawLogs().ToLogs(serializer)); }
public ContractPrimitiveSerializerV2Tests() { this.network = new SmartContractsRegTest(); this.serializer = new ContractPrimitiveSerializerV2(this.network); }
public Serializer(IContractPrimitiveSerializer primitiveSerializer) { this.primitiveSerializer = primitiveSerializer; }
/// <summary> /// Transforms all of the logs into the log type used by consensus. /// </summary> public static IList <Log> ToLogs(this IList <RawLog> rawLogs, IContractPrimitiveSerializer contractPrimitiveSerializer) { return(rawLogs.Select(x => x.ToLog(contractPrimitiveSerializer)).ToList()); }
public CallDataSerializer(IContractPrimitiveSerializer primitiveSerializer) { this.primitiveSerializer = primitiveSerializer; this.methodParamSerializer = new MethodParameterByteSerializer(primitiveSerializer); }