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 OnPayment in OracleContract #2094

Closed
wants to merge 9 commits into from

Conversation

Tommo-L
Copy link
Contributor

@Tommo-L Tommo-L commented Nov 24, 2020

Close #2093

@Tommo-L Tommo-L changed the title add onpayment Add OnPayment in OracleContract Nov 24, 2020
@Tommo-L
Copy link
Contributor Author

Tommo-L commented Nov 24, 2020

#2095 is better

[ContractMethod(0_00100000, CallFlags.None)]
private void OnPayment(ApplicationEngine engine, UInt160 from, BigInteger amount)
{
if (engine.CallingScriptHash != Hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

So, it's like "Oracle" tokens? Maybe we need to fix GAS calls to go through CallFromNativeContract? Although it's Mint being called here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GAS.Mint cann't be called by contract, so we cann't call it through CallFromNativeContract.

[ContractMethod(0_00100000, CallFlags.None)]
private void OnPayment(ApplicationEngine engine, UInt160 from, BigInteger amount)
{
if (engine.CallingScriptHash != GAS.Hash)
Copy link
Member

Choose a reason for hiding this comment

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

The calling scripthash couldn't be GAS.Hash.

Copy link
Member

Choose a reason for hiding this comment

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

Change CallingScriptHash after call CallFromNativeContract?

Copy link
Member

Choose a reason for hiding this comment

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

engine.CurrentContext.GetState<ExecutionContextState>().CallingScriptHash = GAS.Hash;

Copy link
Member

Choose a reason for hiding this comment

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

Or load a GAS context before call it

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we add a MintWithoutCallingOnPayment() method in GAS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just remove PostTransfer in Mint and Burn method?

Copy link
Member

Choose a reason for hiding this comment

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

take a look to Tommo-L#21

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it breaks the context, a little....

Copy link
Member

Choose a reason for hiding this comment

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

Just remove PostTransfer in Mint and Burn method?

But you need to fire the Transfer event.

Copy link
Member

@shargon shargon Nov 24, 2020

Choose a reason for hiding this comment

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

Please take a look to #2098

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Oracle contract doesn't implement NEP-17 onPayment method
4 participants