Skip to content

feat: add support for codeOf T feature #1948

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

Merged
merged 22 commits into from
Feb 24, 2025
Merged

Conversation

i582
Copy link
Member

@i582 i582 commented Feb 21, 2025

Benchmark

codeOf Foo vs initOf Foo().code:

Screenshot 2025-02-24 at 11 36 18

Issue

Closes #1216.

Checklist

  • I have updated CHANGELOG.md
  • I have documented my contribution in docs/ and made the build locally
  • I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@i582 i582 added this to the v1.6.0 milestone Feb 21, 2025
@i582 i582 marked this pull request as ready for review February 21, 2025 10:59
@i582 i582 requested a review from a team as a code owner February 21, 2025 10:59
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

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

Let's also refactor the Jetton contracts to use codeOf:

...
// Owner may be any address, what matters here is the code, not data.
jettonWalletCode: initOf JettonWallet(myAddress(), myAddress()).code
...

@anton-trunov anton-trunov self-assigned this Feb 21, 2025
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

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

Awesome stuff! Can you take a stub at documenting codeOf in the Tact docs please? It would be nice to mention the "algebraic laws" there (the relationships between initOf, myCode and codeOf)

@i582 i582 requested a review from novusnota February 21, 2025 12:10
@i582
Copy link
Member Author

i582 commented Feb 21, 2025

(outdated)

Screenshot 2025-02-21 at 16 25 37

novusnota
novusnota previously approved these changes Feb 21, 2025
Copy link
Member

@novusnota novusnota left a comment

Choose a reason for hiding this comment

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

doc good rest ok

P.S.: The grammar was intentionally butchered for meme purposes. Thank you for your attention.

@Shvandre
Copy link
Contributor

I'd also try to reuse tests I've written for InitOf, so they would use codeOf.

(Or added more)
I mean the tests with diamond-shaped contract dependencies, and cyclic dependencies

@anton-trunov
Copy link
Member

Gas usage has just become higher for some reason

@anton-trunov anton-trunov merged commit 55ae769 into main Feb 24, 2025
25 checks passed
@anton-trunov anton-trunov deleted the pmakhnev/code_of_feature branch February 24, 2025 10:21
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.

Add ability to refer to the code cell of a child contract
4 participants