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

Extending contract #319

Closed
wants to merge 4 commits into from
Closed

Extending contract #319

wants to merge 4 commits into from

Conversation

volovyks
Copy link
Collaborator

@volovyks volovyks commented Dec 4, 2022

Let's define if we want our contract to be extendable. Looks good, but it can lead to some issues with code generation (@waynenilsen ) and ABI (cc @itegulov).
@MaximusHaximus what is your opinion on this? Previously your advice was to avoid class extensions. But contract composability is a cool feature to have.

Note 1: now it does not work, functions from the parent class are not generated or exported.

Note 2: In Rust composability is achieved with macros: https://github.com/near/near-sdk-rs/blob/master/examples/non-fungible-token/nft/src/lib.rs#L103
Not something users want I think, especially in JS projects.

cc @ailisp

? "./build/counter-ts.wasm"
: "./build/counter.wasm"
);
const counter = await root.devDeploy(counterContract);
Copy link
Member

Choose a reason for hiding this comment

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

Adding a test for reset?

Copy link
Member

Choose a reason for hiding this comment

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

oh I didn't see this:

Note 1: now it does not work, functions from the parent class are not generated or exported.

NearBindgen doesn't walk through parent class, it may be possible to identify extends pattern in our babel pass then recursively NearBindgen on parent class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it should be possible (not tested), the question is - is it the best approach? I will experiment with this.

@volovyks
Copy link
Collaborator Author

volovyks commented Dec 7, 2022

Closing in favor of #325

@volovyks volovyks closed this Dec 7, 2022
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.

Helper class inheritance or code generation to quickly build standard contract
2 participants