You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: minor enhancements in immutability control behaviour in deploy (#144)
* docs: further clarifications on v3 deploy behaviour
* docs: extra notes on deploy time immutability control
* docs: apply suggestions from code review
Co-authored-by: Neil Campbell <neil.campbell@makerx.com.au>
---------
Co-authored-by: Neil Campbell <neil.campbell@makerx.com.au>
> NOTE: Starting from v3.0.0, AlgoKit Utils no longer automatically increments the contract version by default. It is the user's responsibility to explicitly manage versioning of their smart contracts (if desired).
72
+
71
73
## Lookup deployed apps by name
72
74
73
75
In order to resolve what apps have been previously deployed and their metadata, AlgoKit provides a method that does a series of indexer lookups and returns a map of name to app metadata via `get_creator_apps_by_name(creator_address)`.
@@ -179,8 +181,6 @@ In order for a smart contract to opt-in to use this functionality, it must have
179
181
- `TMPL_UPDATABLE` - Which will be replaced with a `1` if an app should be updatable and `0` if it shouldn't (immutable)
180
182
- `TMPL_DELETABLE` - Which will be replaced with a `1` if an app should be deletable and `0` if it shouldn't (permanent)
181
183
182
-
If you are building a smart contract using the production [AlgoKit init templates](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/init.md) provide a reference implementation out of the box for the deploy-time immutability and permanence control.
183
-
184
184
If you passed in a TEAL template for the `approval_program` or `clear_state_program` (i.e. a `str` rather than a `bytes`) then `deploy` will return the {py:obj}`CompiledTeal <algokit_utils.models.app_deployer.CompiledTeal>` of substituting then compiling the TEAL template(s) in the following properties of the return value:
185
185
186
186
- `compiled_approval: CompiledTeal | None`
@@ -193,6 +193,50 @@ Template substitution is done by executing `algorand.app.compile_teal_template(t
193
193
- `AppManager.replace_teal_template_deploy_time_control_params(teal_template_code, params)` - If `params` is provided, it allows for deploy-time immutability and permanence control by replacing `TMPL_UPDATABLE` with `params.get("updatable")` if not `None` and replacing `TMPL_DELETABLE` with `params.get("deletable")` if not `None`
194
194
- `algorand.app.compile_teal(teal_code)` - Sends the final TEAL to algod for compilation and returns the result including the source map and caches the compilation result within the `AppManager` instance
195
195
196
+
#### Making updatable/deletable apps
197
+
198
+
Below is a sample in [Algorand Python SDK](https://github.com/algorandfoundation/puya) that demonstrates how to make an app updatable/deletable smart contract with the use of `TMPL_UPDATABLE` and `TMPL_DELETABLE` template parameters.
With the above code, when deploying your application, you can pass in the following deploy-time parameters:
229
+
230
+
```python
231
+
my_factory.deploy(
232
+
... # other deployment parameters ...
233
+
compilation_params={
234
+
"updatable": True, # resulting app will be updatable, and this metadata will be set in the ARC-2 transaction note
235
+
"deletable": False, # resulting app will not be deletable, and this metadata will be set in the ARC-2 transaction note
236
+
}
237
+
)
238
+
```
239
+
196
240
### Return value
197
241
198
242
When `deploy` executes it will return a {py:obj}`AppDeployResult <algokit_utils.models.app_deployer.AppDeployResult>` object that describes exactly what it did and has comprehensive metadata to describe the end result of the deployed app.
Copy file name to clipboardExpand all lines: docs/html/_sources/v3-migration-guide.md.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -249,6 +249,7 @@ result = algorand.send.asset_opt_in(
249
249
4. **Application Client**
250
250
251
251
- Split into `AppClient`, `AppDeployer` and `AppFactory`
252
+
- `deploy` method in `AppFactory`/`AppDeployer` no longer auto increments the contract version by default. It is the user's responsibility to explicitly manage versioning of their smart contracts (if desired).
252
253
- New intuitive structured interface for creating or sending `AppCall`|`AppMethodCall` transactions
253
254
- ARC-56 support along with automatic conversion of specs from ARC-32 to ARC-56
<div><p>NOTE: Starting from v3.0.0, AlgoKit Utils no longer automatically increments the contract version by default. It is the user’s responsibility to explicitly manage versioning of their smart contracts (if desired).</p>
390
+
</div></blockquote>
388
391
</section>
389
392
<sectionid="lookup-deployed-apps-by-name">
390
393
<h2>Lookup deployed apps by name<aclass="headerlink" href="#lookup-deployed-apps-by-name" title="Link to this heading">¶</a></h2>
@@ -491,7 +494,6 @@ <h3>Compilation and template substitution<a class="headerlink" href="#compilatio
491
494
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">TMPL_UPDATABLE</span></code> - Which will be replaced with a <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code> if an app should be updatable and <codeclass="docutils literal notranslate"><spanclass="pre">0</span></code> if it shouldn’t (immutable)</p></li>
492
495
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">TMPL_DELETABLE</span></code> - Which will be replaced with a <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code> if an app should be deletable and <codeclass="docutils literal notranslate"><spanclass="pre">0</span></code> if it shouldn’t (permanent)</p></li>
493
496
</ul>
494
-
<p>If you are building a smart contract using the production <aclass="reference external" href="https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/init.md">AlgoKit init templates</a> provide a reference implementation out of the box for the deploy-time immutability and permanence control.</p>
495
497
<p>If you passed in a TEAL template for the <codeclass="docutils literal notranslate"><spanclass="pre">approval_program</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">clear_state_program</span></code> (i.e. a <codeclass="docutils literal notranslate"><spanclass="pre">str</span></code> rather than a <codeclass="docutils literal notranslate"><spanclass="pre">bytes</span></code>) then <codeclass="docutils literal notranslate"><spanclass="pre">deploy</span></code> will return the <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">CompiledTeal</span></code> of substituting then compiling the TEAL template(s) in the following properties of the return value:</p>
@@ -504,6 +506,45 @@ <h3>Compilation and template substitution<a class="headerlink" href="#compilatio
504
506
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">AppManager.replace_teal_template_deploy_time_control_params(teal_template_code,</span><spanclass="pre">params)</span></code> - If <codeclass="docutils literal notranslate"><spanclass="pre">params</span></code> is provided, it allows for deploy-time immutability and permanence control by replacing <codeclass="docutils literal notranslate"><spanclass="pre">TMPL_UPDATABLE</span></code> with <codeclass="docutils literal notranslate"><spanclass="pre">params.get("updatable")</span></code> if not <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code> and replacing <codeclass="docutils literal notranslate"><spanclass="pre">TMPL_DELETABLE</span></code> with <codeclass="docutils literal notranslate"><spanclass="pre">params.get("deletable")</span></code> if not <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code></p></li>
505
507
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">algorand.app.compile_teal(teal_code)</span></code> - Sends the final TEAL to algod for compilation and returns the result including the source map and caches the compilation result within the <codeclass="docutils literal notranslate"><spanclass="pre">AppManager</span></code> instance</p></li>
506
508
</ul>
509
+
<sectionid="making-updatable-deletable-apps">
510
+
<h4>Making updatable/deletable apps<aclass="headerlink" href="#making-updatable-deletable-apps" title="Link to this heading">¶</a></h4>
511
+
<p>Below is a sample in <aclass="reference external" href="https://github.com/algorandfoundation/puya">Algorand Python SDK</a> that demonstrates how to make an app updatable/deletable smart contract with the use of <codeclass="docutils literal notranslate"><spanclass="pre">TMPL_UPDATABLE</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">TMPL_DELETABLE</span></code> template parameters.</p>
512
+
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># ... your contract code ...</span>
<spanclass="s2">"updatable"</span><spanclass="p">:</span><spanclass="kc">True</span><spanclass="p">,</span><spanclass="c1"># resulting app will be updatable, and this metadata will be set in the ARC-2 transaction note</span>
542
+
<spanclass="s2">"deletable"</span><spanclass="p">:</span><spanclass="kc">False</span><spanclass="p">,</span><spanclass="c1"># resulting app will not be deletable, and this metadata will be set in the ARC-2 transaction note</span>
543
+
<spanclass="p">}</span>
544
+
<spanclass="p">)</span>
545
+
</pre></div>
546
+
</div>
547
+
</section>
507
548
</section>
508
549
<sectionid="return-value">
509
550
<h3>Return value<aclass="headerlink" href="#return-value" title="Link to this heading">¶</a></h3>
@@ -593,7 +634,10 @@ <h3>Return value<a class="headerlink" href="#return-value" title="Link to this h
593
634
<li><aclass="reference internal" href="#performing-a-deployment">Performing a deployment</a><ul>
Copy file name to clipboardExpand all lines: docs/html/v3-migration-guide.html
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -577,6 +577,7 @@ <h2>Breaking Changes<a class="headerlink" href="#breaking-changes" title="Link t
577
577
<li><p><strong>Application Client</strong></p>
578
578
<ulclass="simple">
579
579
<li><p>Split into <codeclass="docutils literal notranslate"><spanclass="pre">AppClient</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">AppDeployer</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">AppFactory</span></code></p></li>
580
+
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">deploy</span></code> method in <codeclass="docutils literal notranslate"><spanclass="pre">AppFactory</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">AppDeployer</span></code> no longer auto increments the contract version by default. It is the user’s responsibility to explicitly manage versioning of their smart contracts (if desired).</p></li>
580
581
<li><p>New intuitive structured interface for creating or sending <codeclass="docutils literal notranslate"><spanclass="pre">AppCall</span></code>|<codeclass="docutils literal notranslate"><spanclass="pre">AppMethodCall</span></code> transactions</p></li>
581
582
<li><p>ARC-56 support along with automatic conversion of specs from ARC-32 to ARC-56</p></li>
0 commit comments