コード例 #1
0
 public ApiLogDeserializer(IContractPrimitiveSerializer primitiveSerializer, Network network, IStateRepositoryRoot stateRepositoryRoot, IContractAssemblyCache contractAssemblyCache)
 {
     this.primitiveSerializer   = primitiveSerializer;
     this.network               = network;
     this.stateRepositoryRoot   = stateRepositoryRoot;
     this.contractAssemblyCache = contractAssemblyCache;
 }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
        /// <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);
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 public MeteredContractLogger(IGasMeter gasMeter, IContractLogger logger, Network network, IContractPrimitiveSerializer serializer)
 {
     this.gasMeter   = gasMeter;
     this.logger     = logger;
     this.network    = network;
     this.serializer = serializer;
 }
コード例 #11
0
 public SmartContractStateFactory(IContractPrimitiveSerializer serializer,
                                  Network network,
                                  IInternalExecutorFactory internalTransactionExecutorFactory)
 {
     this.Serializer = serializer;
     this.Network    = network;
     this.InternalTransactionExecutorFactory = internalTransactionExecutorFactory;
 }
コード例 #12
0
        /// <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));
        }
コード例 #13
0
 public SmartContractStateFactory(IContractPrimitiveSerializer primitiveSerializer,
                                  IInternalExecutorFactory internalTransactionExecutorFactory,
                                  ISerializer serializer)
 {
     this.serializer          = serializer;
     this.PrimitiveSerializer = primitiveSerializer;
     this.InternalTransactionExecutorFactory = internalTransactionExecutorFactory;
 }
コード例 #14
0
 /// <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;
 }
コード例 #15
0
ファイル: LocalExecutor.cs プロジェクト: georgepinca/src
 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;
 }
コード例 #17
0
ファイル: StateFactory.cs プロジェクト: MM2010/X42-FullNode
 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;
 }
コード例 #18
0
 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;
 }
コード例 #19
0
 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;
 }
コード例 #20
0
        /// <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)));
        }
コード例 #21
0
 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;
 }
コード例 #22
0
        /// <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)));
        }
コード例 #23
0
 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;
 }
コード例 #24
0
 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;
 }
コード例 #25
0
 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);
 }
コード例 #26
0
 /// <summary>
 /// Returns contract logs in the log type used by consensus.
 /// </summary>
 public IList <Log> GetLogs(IContractPrimitiveSerializer serializer)
 {
     return(this.LogHolder.GetRawLogs().ToLogs(serializer));
 }
コード例 #27
0
 public ContractPrimitiveSerializerV2Tests()
 {
     this.network    = new SmartContractsRegTest();
     this.serializer = new ContractPrimitiveSerializerV2(this.network);
 }
コード例 #28
0
 public Serializer(IContractPrimitiveSerializer primitiveSerializer)
 {
     this.primitiveSerializer = primitiveSerializer;
 }
コード例 #29
0
 /// <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());
 }
コード例 #30
0
 public CallDataSerializer(IContractPrimitiveSerializer primitiveSerializer)
 {
     this.primitiveSerializer   = primitiveSerializer;
     this.methodParamSerializer = new MethodParameterByteSerializer(primitiveSerializer);
 }