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

Call native contracts like a normal contract #2301

Merged
merged 7 commits into from
Feb 6, 2021
Merged

Conversation

erikzhang
Copy link
Member

No description provided.

@shargon
Copy link
Member

shargon commented Feb 5, 2021

It's not better to use the height for change the logic?

@vncoelho
Copy link
Member

vncoelho commented Feb 5, 2021

I think so @shargon

@erikzhang erikzhang changed the title Add version to native contracts Call native contracts like a normal contract Feb 6, 2021
@erikzhang
Copy link
Member Author

Now we can call native contracts like a normal contract, without inserting the method name for the native contract during execution. And now native contracts can be upgraded like a normal contract, and it supports upgrades based on methods.

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

If we only have access to version during Invoke how it will be used in a future?

src/neo/SmartContract/Native/ContractMethodMetadata.cs Outdated Show resolved Hide resolved
@erikzhang
Copy link
Member Author

If we only have access to version during Invoke how it will be used in a future?

In the future, we can update the native contract like other normal contracts. And the version will be updated too.

@shargon
Copy link
Member

shargon commented Feb 6, 2021

But your goal it's to be able to call older version? otherwise we can use the ContractState.UpdateCounter

@erikzhang
Copy link
Member Author

But your goal it's to be able to call older version?

if (version != 0)
throw new InvalidOperationException($"The native contract of version {version} is not active.");

Here you can distinguish whether the new version or the old version is called, and then execute the corresponding logic.

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.

3 participants