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

Refactor contract ownerships #1269

Merged

Conversation

Neylix
Copy link
Member

@Neylix Neylix commented Sep 12, 2023

Description

This PR improve the usability of the ownerships in the smart contracts. It also do some refactor about the contract constants.

  • Contract seed ownership is not accessible in the variable contract (removing it before creating the constant)
  • Contract ownerships are not anymore chained in the initial_tx (including the seed one)
  • When signing the new contract transaction, the seed ownership is automatically added in first place (creating a new ownership with new encrypted_key)
  • Owerships constant is now the same format as the Ownership module, used in contract.ownership variable. secrets, secret_keys and authorized_public_keys does not exist anymore
  • Contract.add_ownership has a new api with secret and authorized_keys as a map of public_key => encrypted_key
  • Contract.add_ownership keeps the order specified by the contract code
  • Refactor constant module for legacy code as well
  • Many tests has been updated to use TransactionFactory as the constants are now more strict (cannot have a nil address for example)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Units tests
Manual testing by creating contract and using ownerships

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Neylix Neylix added feature New feature request smart contracts Involve smart contracts quality Improve code quality labels Sep 12, 2023
@Neylix Neylix added this to the 1.3.1 milestone Sep 12, 2023
@Neylix Neylix added the breaking change Identify a change with a breaking API label Sep 12, 2023
@Neylix Neylix force-pushed the Refactor-contract-ownerships branch from 9f6113b to 0a3ff9e Compare September 12, 2023 11:24
@bchamagne
Copy link
Contributor

bchamagne commented Sep 13, 2023

  • Playground is not working. Adaptation to do (I'll do it)

@Neylix Neylix force-pushed the Refactor-contract-ownerships branch from 0a3ff9e to 2244392 Compare September 13, 2023 14:17
Copy link
Contributor

@bchamagne bchamagne left a comment

Choose a reason for hiding this comment

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

I tested it with playground

@Neylix Neylix merged commit 62e13f3 into archethic-foundation:develop Sep 14, 2023
@Neylix Neylix deleted the Refactor-contract-ownerships branch September 14, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Identify a change with a breaking API feature New feature request quality Improve code quality smart contracts Involve smart contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants