Skip to content

Commit 30de79d

Browse files
Merge main into release
2 parents aaea50c + 31df3ce commit 30de79d

File tree

4 files changed

+64
-14
lines changed

4 files changed

+64
-14
lines changed

docs/capabilities/app-deploy.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ In order for a smart contract to opt-in to use this functionality, it must have
245245
- `TMPL_UPDATABLE` - Which will be replaced with a `1` if an app should be updatable and `0` if it shouldn't (immutable)
246246
- `TMPL_DELETABLE` - Which will be replaced with a `1` if an app should be deletable and `0` if it shouldn't (permanent)
247247

248-
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.
249-
250248
If you passed in a TEAL template for the approvalProgram or clearStateProgram (i.e. a `string` rather than a `Uint8Array`) then `deploy` will return the [compilation result](../code/interfaces/types_app.CompiledTeal.md) of substituting then compiling the TEAL template(s) in the following properties of the return value:
251249

252250
- `compiledApproval?: CompiledTeal`
@@ -259,6 +257,48 @@ Template substitution is done by executing `algorand.app.compileTealTemplate(tea
259257
- `AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplateCode, deploymentMetadata)` - If `deploymentMetadata` is provided, it allows for deploy-time immutability and permanence control by replacing `TMPL_UPDATABLE` with `deploymentMetadata.updatable` if it's not `undefined` and replacing `TMPL_DELETABLE` with `deploymentMetadata.deletable` if it's not `undefined`
260258
- `algorand.app.compileTeal(tealCode)` - 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
261259

260+
#### Making updatable/deletable apps
261+
262+
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.
263+
264+
```python
265+
# ... your contract code ...
266+
@arc4.baremethod(allow_actions=["UpdateApplication"])
267+
def update(self) -> None:
268+
assert TemplateVar[bool]("UPDATABLE")
269+
270+
@arc4.baremethod(allow_actions=["DeleteApplication"])
271+
def delete(self) -> None:
272+
assert TemplateVar[bool]("DELETABLE")
273+
# ... your contract code ...
274+
```
275+
276+
Alternative example in [Algorand TypeScript SDK](https://github.com/algorandfoundation/puya-ts):
277+
278+
```typescript
279+
// ... your contract code ...
280+
@baremethod({ allowActions: 'UpdateApplication' })
281+
public onUpdate() {
282+
assert(TemplateVar<boolean>('UPDATABLE'))
283+
}
284+
285+
@baremethod({ allowActions: 'DeleteApplication' })
286+
public onDelete() {
287+
assert(TemplateVar<boolean>('DELETABLE'))
288+
}
289+
// ... your contract code ...
290+
```
291+
292+
With the above code, when deploying your application, you can pass in the following deploy-time parameters:
293+
294+
```typescript
295+
myFactory.deploy({
296+
... // other deployment parameters
297+
updatable: true, // resulting app will be updatable, and this metadata will be set in the ARC-2 transaction note
298+
deletable: false, // resulting app will not be deletable, and this metadata will be set in the ARC-2 transaction note
299+
})
300+
```
301+
262302
### Return value
263303

264304
When `deploy` executes it will return a [comprehensive result](../code/modules/types_app_deployer.md#appdeployresult) object that describes exactly what it did and has comprehensive metadata to describe the end result of the deployed app.

docs/code/modules/index.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ the estimated rate.
575575

576576
#### Defined in
577577

578-
[src/transaction/transaction.ts:1056](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1056)
578+
[src/transaction/transaction.ts:1058](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1058)
579579

580580
___
581581

@@ -639,7 +639,7 @@ Allows for control of fees on a `Transaction` or `SuggestedParams` object
639639

640640
#### Defined in
641641

642-
[src/transaction/transaction.ts:1083](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1083)
642+
[src/transaction/transaction.ts:1085](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1085)
643643

644644
___
645645

@@ -966,7 +966,7 @@ Converts `bigint`'s for Uint's < 64 to `number` for easier use.
966966

967967
#### Defined in
968968

969-
[src/transaction/transaction.ts:926](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L926)
969+
[src/transaction/transaction.ts:928](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L928)
970970

971971
___
972972

@@ -1942,7 +1942,7 @@ Returns the array of transactions currently present in the given `AtomicTransact
19421942

19431943
#### Defined in
19441944

1945-
[src/transaction/transaction.ts:1132](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1132)
1945+
[src/transaction/transaction.ts:1134](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1134)
19461946

19471947
___
19481948

@@ -2329,7 +2329,7 @@ Returns suggested transaction parameters from algod unless some are already prov
23292329

23302330
#### Defined in
23312331

2332-
[src/transaction/transaction.ts:1110](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1110)
2332+
[src/transaction/transaction.ts:1112](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1112)
23332333

23342334
___
23352335

@@ -2770,7 +2770,8 @@ ___
27702770
**prepareGroupForSending**(`atc`, `algod`, `sendParams`, `additionalAtcContext?`): `Promise`\<`AtomicTransactionComposer`\>
27712771

27722772
Take an existing Atomic Transaction Composer and return a new one with changes applied to the transactions
2773-
based on the supplied sendParams to ensure the transaction group is ready for sending.
2773+
based on the supplied sendParams to prepare it for sending.
2774+
Please note, that before calling `.execute()` on the returned ATC, you must call `.buildGroup()`.
27742775

27752776
#### Parameters
27762777

@@ -2789,7 +2790,7 @@ A new ATC with the changes applied
27892790

27902791
#### Defined in
27912792

2792-
[src/transaction/transaction.ts:401](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L401)
2793+
[src/transaction/transaction.ts:402](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L402)
27932794

27942795
___
27952796

@@ -2939,7 +2940,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa
29392940

29402941
#### Defined in
29412942

2942-
[src/transaction/transaction.ts:776](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L776)
2943+
[src/transaction/transaction.ts:777](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L777)
29432944

29442945
___
29452946

@@ -2968,7 +2969,7 @@ Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-de
29682969

29692970
#### Defined in
29702971

2971-
[src/transaction/transaction.ts:955](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L955)
2972+
[src/transaction/transaction.ts:957](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L957)
29722973

29732974
___
29742975

@@ -3241,4 +3242,4 @@ Throws an error if the transaction is not confirmed or rejected in the next `tim
32413242

32423243
#### Defined in
32433244

3244-
[src/transaction/transaction.ts:999](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L999)
3245+
[src/transaction/transaction.ts:1001](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L1001)

src/transaction/transaction.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ describe('transaction', () => {
460460
expect(result.transactions[0].fee).toBe(1500n)
461461
expect(result.transactions[1].fee).toBe(7500n)
462462
expect(result.transactions[2].fee).toBe(0n)
463+
expect(result.groupId).not.toBe('')
464+
await Promise.all(
465+
result.transactions.map(async (txn) => {
466+
expect(Buffer.from(txn.group!).toString('base64')).toBe(result.groupId)
467+
await localnet.context.waitForIndexerTransaction(txn.txID())
468+
}),
469+
)
463470
})
464471

465472
test('alters fee, handling nested abi method calls', async () => {

src/transaction/transaction.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
386386

387387
/**
388388
* Take an existing Atomic Transaction Composer and return a new one with changes applied to the transactions
389-
* based on the supplied sendParams to ensure the transaction group is ready for sending.
389+
* based on the supplied sendParams to prepare it for sending.
390+
* Please note, that before calling `.execute()` on the returned ATC, you must call `.buildGroup()`.
390391
*
391392
* @param algod The algod client to use for the simulation
392393
* @param atc The ATC containing the txn group
@@ -799,7 +800,8 @@ export const sendAtomicTransactionComposer = async function (atcSend: AtomicTran
799800
)
800801
}
801802

802-
const transactionsToSend = transactionsWithSigner.map((t) => {
803+
// atc.buildGroup() is needed to ensure that any changes made by prepareGroupForSending are reflected and the group id is set
804+
const transactionsToSend = atc.buildGroup().map((t) => {
803805
return t.txn
804806
})
805807
let groupId: string | undefined = undefined

0 commit comments

Comments
 (0)