Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TransactionInvocation.GetScript to StateReader #170

Merged
merged 3 commits into from
Feb 8, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions neo/SmartContract/StateReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public StateReader()
Register("Neo.Transaction.GetOutputs", Transaction_GetOutputs);
Register("Neo.Transaction.GetReferences", Transaction_GetReferences);
Register("Neo.Transaction.GetUnspentCoins", Transaction_GetUnspentCoins);
Register("Neo.Transaction.GetUnspentCoins", Transaction_GetUnspentCoins);
Register("Neo.InvocationTransaction.GetScript", InvocationTransaction_GetScript);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be Register("Neo.Transaction.GetScript", Transaction_GetScript)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, only the subclass InvocationTransaction has the Script property. can we still just use Transaction?

Register("Neo.Attribute.GetUsage", Attribute_GetUsage);
Register("Neo.Attribute.GetData", Attribute_GetData);
Register("Neo.Input.GetHash", Input_GetHash);
Expand Down Expand Up @@ -671,6 +673,18 @@ protected virtual bool Transaction_GetUnspentCoins(ExecutionEngine engine)
return false;
}

protected virtual bool InvocationTransaction_GetScript(ExecutionEngine engine)
{
if (engine.EvaluationStack.Pop() is InteropInterface _interface)
{
InvocationTransaction tx = _interface.GetInterface<InvocationTransaction>();
if (tx == null) return false;
engine.EvaluationStack.Push(tx.Script);
return true;
}
return false;
}

protected virtual bool Attribute_GetUsage(ExecutionEngine engine)
{
if (engine.EvaluationStack.Pop() is InteropInterface _interface)
Expand Down