Exemple #1
0
        public static Meadow.Contract.EventLog Parse(string eventSignatureHash, Meadow.JsonRpc.Types.FilterLogObject log)
        {
            var eventLog = Meadow.Contract.EventLogUtil.Parse(eventSignatureHash, log);

            if (eventLog != null)
            {
                return(eventLog);
            }

            // Switch on the event signature hash and the number of indexed event arguments.
            switch (eventSignatureHash + "_" + (log.Topics.Length - 1).ToString("00", CultureInfo.InvariantCulture))
            {
            case "8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925_02":
                return(new TokenContract.ERC20Basic.Approval(log));

            case "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef_02":
                return(new TokenContract.ERC20Basic.Transfer(log));

            case "28843b844d4060d225bc7fb6279bd091f7ddb51b0f3d7e97947f52d3b609a2be_00":
                return(new TokenContract.HelloWorld.HelloEvent(log));

            default:
                return(null);
            }
        }
            public HelloEvent(Meadow.JsonRpc.Types.FilterLogObject log) : base(log)
            {
                // Decode the log topic args.
                Span <byte> topicBytes = MemoryMarshal.AsBytes(new Span <Meadow.Core.EthTypes.Data>(log.Topics).Slice(1));

                AbiTypeInfo[] topicTypes = Array.Empty <AbiTypeInfo>();
                var           topicBuff  = new AbiDecodeBuffer(topicBytes, topicTypes);
                // Decode the log data args.
                Span <byte> dataBytes = log.Data;

                AbiTypeInfo[] dataTypes = new AbiTypeInfo[] { "string", "address" };
                var           dataBuff  = new AbiDecodeBuffer(dataBytes, dataTypes);

                DecoderFactory.Decode(dataTypes[0], ref dataBuff, out _message);
                DecoderFactory.Decode(dataTypes[1], ref dataBuff, out _sender);
                // Add all the log args and their metadata to a collection that can be checked at runtime.
                LogArgs = new(string Name, string Type, bool Indexed, object Value)[] { ("_message", "string", false, _message), ("_sender", "address", false, _sender) };
            public Transfer(Meadow.JsonRpc.Types.FilterLogObject log) : base(log)
            {
                // Decode the log topic args.
                Span <byte> topicBytes = MemoryMarshal.AsBytes(new Span <Meadow.Core.EthTypes.Data>(log.Topics).Slice(1));

                AbiTypeInfo[] topicTypes = new AbiTypeInfo[] { "address", "address" };
                var           topicBuff  = new AbiDecodeBuffer(topicBytes, topicTypes);

                DecoderFactory.Decode(topicTypes[0], ref topicBuff, out from);
                DecoderFactory.Decode(topicTypes[1], ref topicBuff, out to);
                // Decode the log data args.
                Span <byte> dataBytes = log.Data;

                AbiTypeInfo[] dataTypes = new AbiTypeInfo[] { "uint256" };
                var           dataBuff  = new AbiDecodeBuffer(dataBytes, dataTypes);

                DecoderFactory.Decode(dataTypes[0], ref dataBuff, out tokens);
                // Add all the log args and their metadata to a collection that can be checked at runtime.
                LogArgs = new(string Name, string Type, bool Indexed, object Value)[] { ("from", "address", true, from), ("to", "address", true, to), ("tokens", "uint256", false, tokens) };
            public LogAccess(Meadow.JsonRpc.Types.FilterLogObject log) : base(log)
            {
                // Decode the log topic args.
                Span <byte> topicBytes = MemoryMarshal.AsBytes(new Span <Meadow.Core.EthTypes.Data>(log.Topics).Slice(1));

                AbiTypeInfo[] topicTypes = new AbiTypeInfo[] { "address", "uint256" };
                var           topicBuff  = new AbiDecodeBuffer(topicBytes, topicTypes);

                DecoderFactory.Decode(topicTypes[0], ref topicBuff, out by);
                DecoderFactory.Decode(topicTypes[1], ref topicBuff, out accessTime);
                // Decode the log data args.
                Span <byte> dataBytes = log.Data;

                AbiTypeInfo[] dataTypes = new AbiTypeInfo[] { "string", "string" };
                var           dataBuff  = new AbiDecodeBuffer(dataBytes, dataTypes);

                DecoderFactory.Decode(dataTypes[0], ref dataBuff, out method);
                DecoderFactory.Decode(dataTypes[1], ref dataBuff, out desc);
                // Add all the log args and their metadata to a collection that can be checked at runtime.
                LogArgs = new(string Name, string Type, bool Indexed, object Value)[] { ("by", "address", true, by), ("accessTime", "uint256", true, accessTime), ("method", "string", false, method), ("desc", "string", false, desc) };
        public static Meadow.Contract.EventLog Parse(string eventSignatureHash, Meadow.JsonRpc.Types.FilterLogObject log)
        {
            var eventLog = Meadow.Contract.EventLogUtil.Parse(eventSignatureHash, log);

            if (eventLog != null)
            {
                return(eventLog);
            }

            // Switch on the event signature hash and the number of indexed event arguments.
            switch (eventSignatureHash + "_" + (log.Topics.Length - 1).ToString("00", CultureInfo.InvariantCulture))
            {
            case "d114fdd66c4524801ee92e5d6d9db879e73730efc8ba069ae8d56046bd4e2d4d_02":
                return(new solidity_vscode_unit_test.aclContract.LogAccess(log));

            // Event with duplicate signature: solidity_vscode_unit_test.patientContract.LogAccess
            default:
                return(null);
            }
        }