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

docs: evolve spec #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

docs: evolve spec #3

wants to merge 5 commits into from

Conversation

asiaziola
Copy link

No description provided.

README.md Outdated
5. `evolve` interaction MUST be called with the evolved contract source id indicated as the input `value`, an example of correct interaction:

```js
await contract.writeInteraction({ function: 'evolve', value: 'OFh9ImnAauPjW49IHzaVq7hI-S0yswV0Nh7bTUQxdtc });
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the await contract.writeInteraction( - as this is our SDK - specific. JSON itself should be enough.
Also - maybe it would be worth noting, that value is the tx.id from the point 4.

Copy link
Author

Choose a reason for hiding this comment

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

oops, got too used to our api

README.md Outdated
await contract.writeInteraction({ function: 'evolve', value: 'OFh9ImnAauPjW49IHzaVq7hI-S0yswV0Nh7bTUQxdtc });
```

Evolved contract source is then referred instead of the original contract source when performing any interactions. The state is evaluated based on all contract sources linked to the contract. There is no limitation for number of evolved contract sources associated to one contract.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we need to be more specific here, e.g. when performing any interactions after the "evolve" interaction

Copy link
Author

Choose a reason for hiding this comment

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

done

README.md Outdated

1. `canEvolve` property set to `true` MUST be added to the initial state.
2. `evolve` interaction MUST be added to the original contract source, it MUST set the `evolve` property in the state to `action.input.value` - new contract source transaction id.
3. `evolve` interaction MUST be conditioned to the owner of the contract.

Choose a reason for hiding this comment

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

I think we should leave this up to the developer, which is why we would use canEvolve so that the developer can handle when it's allowed to evolve.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, so - if I understand correctly - you would like to add a function, that will switch on/off the canEvolve flag?
Who should be allowed to switch value of this flag? only contract owner?

Choose a reason for hiding this comment

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

@ppedziwiatr So the state already has a property called canEvolve. If canEvolve is false and there's evolve present, then it doesn't evolve. The developer should programatically set canEvolve to true or false during the evaluation of the interaction so that the executor can know whether the evolve requested was allowed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, since canEvolve is a part of the contract's state, it should be IMHO only modified by interacting with the contract - i.e. by creating an interaction transaction with a contract - so that anyone, who's willing to evaluate the state, will get the exactly same result.

"The developer should programatically set canEvolve to true or false during the evaluation of the interaction" - how exactly this "programatically setting" would work in this case..? You would like to change the value of this flag without interacting with the contract?

Sorry for all the questions, I just want to fully understand your idea.


Evolving contract is a way of updating contract source. In order to properly evolve the contract following steps need to be reproduced:

1. `canEvolve` property set to `true` MUST be added to the initial state (defaults to `false`, cannot evolve without setting it explicitly).
Copy link
Author

Choose a reason for hiding this comment

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

i've changed this sentence, so one needs to set canEvolve to true explicitly.

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