From 7a1e2594db48219bc721ec3a08db306c509a660b Mon Sep 17 00:00:00 2001 From: Gabriel Kuettel Date: Thu, 20 Mar 2025 18:35:23 -0600 Subject: [PATCH 1/5] fix: update group txn example to exclude setup code --- .../transactions/atomic_transaction_groups.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/projects/python-examples/algokit_utils_py_examples/transactions/atomic_transaction_groups.py b/projects/python-examples/algokit_utils_py_examples/transactions/atomic_transaction_groups.py index ffa4da7..1e260bd 100644 --- a/projects/python-examples/algokit_utils_py_examples/transactions/atomic_transaction_groups.py +++ b/projects/python-examples/algokit_utils_py_examples/transactions/atomic_transaction_groups.py @@ -4,12 +4,11 @@ def atomic_transaction_groups() -> None: - # example: ATOMIC_TRANSACTION_GROUP - algorand_client, dispenser, account_a, account_b, account_c = ( setup_localnet_environment() ) + # example: ATOMIC_TRANSACTION_GROUP """ Create a transaction group that will execute atomically Either all transactions succeed, or they all fail @@ -31,7 +30,6 @@ def atomic_transaction_groups() -> None: note=b"Second payment in atomic group", ) ).send() # Send the atomic group of transactions - # example: ATOMIC_TRANSACTION_GROUP # example: ATOMIC_GROUP_SIMULATE From 952a77211f7f29f63ab3ce57e459a7527709c399 Mon Sep 17 00:00:00 2001 From: Gabriel Kuettel Date: Thu, 20 Mar 2025 20:20:42 -0600 Subject: [PATCH 2/5] chore: update comments --- .../InnerTransactions/contract.algo.ts | 83 +++++++------------ 1 file changed, 32 insertions(+), 51 deletions(-) diff --git a/projects/typescript-examples/contracts/InnerTransactions/contract.algo.ts b/projects/typescript-examples/contracts/InnerTransactions/contract.algo.ts index 391cd9a..63b88e3 100644 --- a/projects/typescript-examples/contracts/InnerTransactions/contract.algo.ts +++ b/projects/typescript-examples/contracts/InnerTransactions/contract.algo.ts @@ -19,7 +19,11 @@ import type { uint64 } from '@algorandfoundation/algorand-typescript' export default class InnerTransactions extends Contract { // example: PAYMENT /** - * Demonstrates a simple payment inner transaction + * Demonstrates a simple payment inner transaction. + * The fee is set to 0 by default. Manually set here for demonstration purposes. + * The `Sender` for the payment is implied to be Global.currentApplicationAddress. + * If a different sender is needed, it'd have to be an account that has been + * rekeyed to the application address. * @returns The amount of the payment */ @abimethod() @@ -34,14 +38,6 @@ export default class InnerTransactions extends Contract { return result.amount } - - /** - * fee is set to 0 by default. Manually set here for demonstration purposes. - * The `Sender` for the above is implied to be Global.currentApplicationAddress. - * - * If a different sender is needed, it'd have to be an account that has been - * rekeyed to the application address. - */ // example: PAYMENT // example: ASSET_CREATE @@ -64,10 +60,12 @@ export default class InnerTransactions extends Contract { } /** - * Creates a non-fungible asset (NFT) + * Creates a non-fungible asset (NFT). * Following the ARC3 standard, the total supply must be 1 for a non-fungible asset. * If you want to create fractional NFTs, `total` * `decimals` point must be 1. * ex) total=100, decimals=2, 100 * 0.01 = 1 + * The fee is set to 0 by default for inner transactions. + * The Sender is implied to be Global.currentApplicationAddress. * @returns The ID of the created asset */ @abimethod() @@ -93,7 +91,10 @@ export default class InnerTransactions extends Contract { // example: ASSET_OPT_IN /** - * Opts the application into an asset + * Opts the application into an asset. + * A zero amount asset transfer to one's self is a special type of asset transfer + * that is used to opt-in to an asset. + * To send an asset transfer, the asset must be an available resource. * @param asset The asset to opt into */ @abimethod() @@ -107,19 +108,14 @@ export default class InnerTransactions extends Contract { }) .submit() } - - /** - * A zero amount asset transfer to one's self is a special type of asset transfer - * that is used to opt-in to an asset. - * - * To send an asset transfer, the asset must be an available resource. - * Refer the Resource Availability section for more information. - */ // example: ASSET_OPT_IN // example: ASSET_TRANSFER /** - * Transfers an asset from the application to another account + * Transfers an asset from the application to another account. + * For a smart contract to transfer an asset, the app account must be opted into the asset + * and be holding non zero amount of assets. + * To send an asset transfer, the asset must be an available resource. * @param asset The asset to transfer * @param receiver The account to receive the asset * @param amount The amount to transfer @@ -136,18 +132,13 @@ export default class InnerTransactions extends Contract { .submit() } - /** - * For a smart contract to transfer an asset, the app account must be opted into the asset - * and be holding non zero amount of assets. - * - * To send an asset transfer, the asset must be an available resource. - * Refer the Resource Availability section for more information. - */ // example: ASSET_TRANSFER // example: ASSET_FREEZE /** - * Freezes an asset for a specific account + * Freezes an asset for a specific account. + * To freeze an asset, the asset must be a freezable asset + * by having an account with freeze authority. * @param acctToBeFrozen The account to freeze the asset for * @param asset The asset to freeze */ @@ -162,16 +153,14 @@ export default class InnerTransactions extends Contract { }) .submit() } - - /** - * To freeze an asset, the asset must be a freezable asset - * by having an account with freeze authority. - */ // example: ASSET_FREEZE // example: ASSET_REVOKE /** - * Revokes (clawbacks) an asset from an account + * Revokes (clawbacks) an asset from an account. + * To revoke an asset, the asset must be a revocable asset + * by having an account with clawback authority. + * The Sender is implied to be current_application_address. * @param asset The asset to revoke * @param accountToBeRevoked The account to revoke the asset from * @param amount The amount to revoke @@ -188,18 +177,15 @@ export default class InnerTransactions extends Contract { }) .submit() } - - /** - * To revoke an asset, the asset must be a revocable asset - * by having an account with clawback authority. - * - * Sender is implied to be current_application_address - */ // example: ASSET_REVOKE // example: ASSET_CONFIG /** - * Reconfigures an existing asset + * Reconfigures an existing asset. + * For a smart contract to transfer an asset, the app account must be opted into the asset + * and be holding non zero amount of assets. + * To send an asset transfer, the asset must be an available resource. + * Refer the Resource Availability section for more information. * @param asset The asset to reconfigure */ @abimethod() @@ -215,19 +201,14 @@ export default class InnerTransactions extends Contract { }) .submit() } - - /** - * For a smart contract to transfer an asset, the app account must be opted into the asset - * and be holding non zero amount of assets. - * - * To send an asset transfer, the asset must be an available resource. - * Refer the Resource Availability section for more information. - */ // example: ASSET_CONFIG // example: ASSET_DELETE /** - * Deletes an asset + * Deletes an asset. + * To delete an asset, the asset must be a deleteable asset + * by having an account with delete authority. + * The Sender is implied to be current_application_address. * @param asset The asset to delete */ @abimethod() From 4c076fc7d163c6de72e8f8e88338f759f632c4d3 Mon Sep 17 00:00:00 2001 From: Gabriel Kuettel Date: Thu, 20 Mar 2025 20:40:47 -0600 Subject: [PATCH 3/5] feat: update account reference example --- .../algokit-utils-ts/references/account-reference.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/typescript-examples/algokit-utils-ts/references/account-reference.ts b/projects/typescript-examples/algokit-utils-ts/references/account-reference.ts index 335c82f..729ffdf 100644 --- a/projects/typescript-examples/algokit-utils-ts/references/account-reference.ts +++ b/projects/typescript-examples/algokit-utils-ts/references/account-reference.ts @@ -48,7 +48,7 @@ async function AccountReferenceExampleMethod3() { const { referenceAccountAppClient, referenceAccount } = await setupLocalnetEnvironment() // example: ACCOUNT_REFERENCE_EXAMPLE_METHOD_3 - // Include the account reference in the accountReferences array to be populated + // Include the account reference in the accountReferences array to be populated manually const result = await referenceAccountAppClient.send.getAccountBalance({ args: {}, accountReferences: [referenceAccount], From 4ce8e56ad54f8e12ca5c5d1c5f850240dd645cf7 Mon Sep 17 00:00:00 2001 From: Gabriel Kuettel Date: Thu, 20 Mar 2025 20:45:49 -0600 Subject: [PATCH 4/5] feat: add example comment tag --- .../typescript-examples/contracts/ReferenceApp/contract.algo.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/typescript-examples/contracts/ReferenceApp/contract.algo.ts b/projects/typescript-examples/contracts/ReferenceApp/contract.algo.ts index 02a1bfc..9c804b2 100644 --- a/projects/typescript-examples/contracts/ReferenceApp/contract.algo.ts +++ b/projects/typescript-examples/contracts/ReferenceApp/contract.algo.ts @@ -9,6 +9,7 @@ import { } from '@algorandfoundation/algorand-typescript' import type { uint64 } from '@algorandfoundation/algorand-typescript' +// example: APP_REFERENCE_EXAMPLE /** * A contract that increments a counter */ @@ -75,3 +76,4 @@ export default class ReferenceApp extends Contract { return arc4.decodeArc4(appCallTxn.lastLog, 'log') } } +// example: APP_REFERENCE_EXAMPLE From 044c29293973a9a5b2c36611b6cd2b287702bf65 Mon Sep 17 00:00:00 2001 From: Gabriel Kuettel Date: Thu, 20 Mar 2025 20:47:23 -0600 Subject: [PATCH 5/5] feat: add example comment tag --- .../contracts/ReferenceAccountApp/contract.algo.ts | 2 ++ .../contracts/ReferenceAccountAsset/contract.algo.ts | 2 ++ .../contracts/ReferenceAppBox/contract.algo.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/projects/typescript-examples/contracts/ReferenceAccountApp/contract.algo.ts b/projects/typescript-examples/contracts/ReferenceAccountApp/contract.algo.ts index d864600..9914f55 100644 --- a/projects/typescript-examples/contracts/ReferenceAccountApp/contract.algo.ts +++ b/projects/typescript-examples/contracts/ReferenceAccountApp/contract.algo.ts @@ -13,6 +13,7 @@ import { import type { uint64 } from '@algorandfoundation/algorand-typescript' import { Address } from '@algorandfoundation/algorand-typescript/arc4' +// example: REFERENCE_ACCOUNT_APP_EXAMPLE /** * A contract that maintains a per-account counter in local state * Accounts must opt in to use the counter @@ -87,3 +88,4 @@ export default class ReferenceAccountApp extends Contract { return value } } +// example: REFERENCE_ACCOUNT_APP_EXAMPLE diff --git a/projects/typescript-examples/contracts/ReferenceAccountAsset/contract.algo.ts b/projects/typescript-examples/contracts/ReferenceAccountAsset/contract.algo.ts index 27546be..3826f14 100644 --- a/projects/typescript-examples/contracts/ReferenceAccountAsset/contract.algo.ts +++ b/projects/typescript-examples/contracts/ReferenceAccountAsset/contract.algo.ts @@ -1,6 +1,7 @@ import { Contract, abimethod, Account, Asset, assert } from '@algorandfoundation/algorand-typescript' import { Address } from '@algorandfoundation/algorand-typescript/arc4' +// example: REFERENCE_ACCOUNT_ASSET_EXAMPLE /** * A contract that demonstrates how to reference both accounts and assets in a smart contract */ @@ -34,3 +35,4 @@ export default class ReferenceAccountAsset extends Contract { return asset.balance(account) } } +// example: REFERENCE_ACCOUNT_ASSET_EXAMPLE diff --git a/projects/typescript-examples/contracts/ReferenceAppBox/contract.algo.ts b/projects/typescript-examples/contracts/ReferenceAppBox/contract.algo.ts index 4736241..6dd9ff8 100644 --- a/projects/typescript-examples/contracts/ReferenceAppBox/contract.algo.ts +++ b/projects/typescript-examples/contracts/ReferenceAppBox/contract.algo.ts @@ -13,6 +13,7 @@ import { } from '@algorandfoundation/algorand-typescript' import type { uint64 } from '@algorandfoundation/algorand-typescript' +// example: REFERENCE_APP_BOX_EXAMPLE /** * A contract that uses box storage to maintain a counter for each account * Each account needs to pay for the Minimum Balance Requirement (MBR) for their box @@ -128,3 +129,4 @@ export default class ReferenceAppBox extends Contract { this.boxMbr.value = Uint64(2500) + this.boxSize.value * Uint64(400) } } +// example: REFERENCE_APP_BOX_EXAMPLE