Skip to content

Call native contracts like a normal contract#2301

Merged
erikzhang merged 7 commits intomasterfrom
native-version
Feb 6, 2021
Merged

Call native contracts like a normal contract#2301
erikzhang merged 7 commits intomasterfrom
native-version

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?

@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.

Co-authored-by: Shargon <shargon@gmail.com>
@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