protected void InvokeChainEvent(object sender, RawChainEventArgs e)
 {
     if (this.eventReceived != null)
     {
         this.eventReceived(this, TransformChainEvent(e));
     }
 }
Пример #2
0
 protected virtual void NotifyContractEventReceived(object sender, RawChainEventArgs e)
 {
     if (e.ContractAddress.Equals(this.Address))
     {
         InvokeChainEvent(sender, e);
     }
 }
Пример #3
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 the signature of event itself
            string eventName;

            if (!this.topicToEventName.TryGetValue(e.Topics[0], out eventName))
            {
                throw new EvmException($"Unknown topic {e.Topics[0]}, is the ABI out of sync with the contract?");
            }

            return(new EvmChainEventArgs(
                       e.ContractAddress,
                       e.CallerAddress,
                       e.BlockHeight,
                       e.Data,
                       eventName,
                       e.Topics
                       ));
        }
        private void ReadClientOnEventReceived(object sender, JsonRpcEventData e)
        {
            RawChainEventArgs rawChainEventArgs =
                new RawChainEventArgs(
                    e.ContractAddress,
                    e.CallerAddress,
                    UInt64.Parse(e.BlockHeight),
                    e.Data,
                    e.Topics
                    );

            this.ChainEventReceived?.Invoke(this, rawChainEventArgs);
        }
Пример #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
                       ));
        }
Пример #6
0
 protected abstract TChainEvent TransformChainEvent(RawChainEventArgs e);
Пример #7
0
 protected void InvokeChainEvent(object sender, RawChainEventArgs e)
 {
     this.ContractEventReceived?.Invoke(this, TransformChainEvent(e));
 }