Ejemplo n.º 1
0
        protected override EvmChainEventArgs TransformChainEvent(RawChainEventArgs e)
        {
            Event evt = new Event();

            evt.MergeFrom(e.Data);

            byte[][] topics = new byte[evt.Topics.Count][];
            for (int i = 0; i < evt.Topics.Count; i++)
            {
                topics[i] = evt.Topics[i].ToByteArray();
            }

            // First topic is a signature of event itself
            string eventName;

            this.topicToEventName.TryGetValue(topics[0], out eventName);

            return(new EvmChainEventArgs(
                       e.ContractAddress,
                       e.CallerAddress,
                       e.BlockHeight,
                       evt.Data.ToByteArray(),
                       topics,
                       eventName
                       ));
        }
Ejemplo n.º 2
0
        protected override EvmChainEventArgs TransformChainEvent(RawChainEventArgs e)
        {
            if (e.Topics == null)
            {
                throw new ArgumentNullException("topics");
            }

            for (int i = 0; i < e.Topics.Length; i++)
            {
                // Remove 0x
                e.Topics[i] = e.Topics[i].Substring(2);
            }

            // First topic is a signature of event itself
            string eventName;

            this.topicToEventName.TryGetValue(e.Topics[0], out eventName);

            return(new EvmChainEventArgs(
                       e.ContractAddress,
                       e.CallerAddress,
                       e.BlockHeight,
                       e.Data,
                       eventName,
                       e.Topics
                       ));
        }
Ejemplo n.º 3
0
 protected virtual void NotifyContractEventReceived(object sender, RawChainEventArgs e)
 {
     if (e.ContractAddress.Equals(this.Address))
     {
         InvokeChainEvent(sender, e);
     }
 }
Ejemplo n.º 4
0
 protected void InvokeChainEvent(object sender, RawChainEventArgs e)
 {
     if (this.eventReceived != null)
     {
         this.eventReceived(this, TransformChainEvent(e));
     }
 }
Ejemplo n.º 5
0
        protected override ChainEventArgs TransformChainEvent(RawChainEventArgs e)
        {
            string       jsonRpcEventString = Encoding.UTF8.GetString(e.Data);
            JsonRpcEvent jsonRpcEvent       = JsonConvert.DeserializeObject <JsonRpcEvent>(jsonRpcEventString);

            byte[] eventData = Encoding.UTF8.GetBytes(jsonRpcEvent.Data);

            return(new ChainEventArgs(
                       e.ContractAddress,
                       e.CallerAddress,
                       e.BlockHeight,
                       eventData,
                       jsonRpcEvent.Method
                       ));
        }
Ejemplo n.º 6
0
 protected abstract TChainEvent TransformChainEvent(RawChainEventArgs e);