Exemplo n.º 1
0
        private UInt256 GetOriginalTxid(ApplicationEngine engine)
        {
            Transaction    tx       = (Transaction)engine.ScriptContainer;
            OracleResponse response = tx.GetAttribute <OracleResponse>();

            if (response is null)
            {
                return(tx.Hash);
            }
            OracleRequest request = GetRequest(engine.Snapshot, response.Id);

            return(request.OriginalTxid);
        }
Exemplo n.º 2
0
        private void Finish(ApplicationEngine engine)
        {
            Transaction    tx       = (Transaction)engine.ScriptContainer;
            OracleResponse response = tx.GetAttribute <OracleResponse>();

            if (response == null)
            {
                throw new ArgumentException("Oracle response was not found");
            }
            OracleRequest request = GetRequest(engine.Snapshot, response.Id);

            if (request == null)
            {
                throw new ArgumentException("Oracle request was not found");
            }
            StackItem userData = BinarySerializer.Deserialize(request.UserData, engine.MaxStackSize, engine.MaxItemSize, engine.ReferenceCounter);

            engine.CallFromNativeContract(null, request.CallbackContract, request.CallbackMethod, request.Url, userData, (int)response.Code, response.Result);
        }
Exemplo n.º 3
0
        private void Finish(ApplicationEngine engine)
        {
            Transaction    tx       = (Transaction)engine.ScriptContainer;
            OracleResponse response = tx.GetAttribute <OracleResponse>();

            if (response == null)
            {
                throw new ArgumentException("Oracle response was not found");
            }
            OracleRequest request = GetRequest(engine.Snapshot, response.Id);

            if (request == null)
            {
                throw new ArgumentException("Oracle request was not found");
            }
            engine.SendNotification(Hash, "OracleResponse", new VM.Types.Array {
                response.Id, request.OriginalTxid.ToArray()
            });
            StackItem userData = BinarySerializer.Deserialize(request.UserData, engine.Limits.MaxStackSize, engine.Limits.MaxItemSize, engine.ReferenceCounter);

            engine.CallFromNativeContract(() => { }, request.CallbackContract, request.CallbackMethod, request.Url, userData, (int)response.Code, response.Result);
        }