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 )); }
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 )); }
protected virtual void NotifyContractEventReceived(object sender, RawChainEventArgs e) { if (e.ContractAddress.Equals(this.Address)) { InvokeChainEvent(sender, e); } }
protected void InvokeChainEvent(object sender, RawChainEventArgs e) { if (this.eventReceived != null) { this.eventReceived(this, TransformChainEvent(e)); } }
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 )); }
protected abstract TChainEvent TransformChainEvent(RawChainEventArgs e);