Skip to content

Commit 39136ef

Browse files
Merge pull request #47 from algorandfoundation/example-code-fixes
fix: update group txn example to exclude setup code
2 parents 9b939c0 + 044c292 commit 39136ef

File tree

7 files changed

+42
-55
lines changed

7 files changed

+42
-55
lines changed

Diff for: projects/python-examples/algokit_utils_py_examples/transactions/atomic_transaction_groups.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55

66
def atomic_transaction_groups() -> None:
7-
# example: ATOMIC_TRANSACTION_GROUP
8-
97
algorand_client, dispenser, account_a, account_b, account_c = (
108
setup_localnet_environment()
119
)
1210

11+
# example: ATOMIC_TRANSACTION_GROUP
1312
"""
1413
Create a transaction group that will execute atomically
1514
Either all transactions succeed, or they all fail
@@ -31,7 +30,6 @@ def atomic_transaction_groups() -> None:
3130
note=b"Second payment in atomic group",
3231
)
3332
).send() # Send the atomic group of transactions
34-
3533
# example: ATOMIC_TRANSACTION_GROUP
3634

3735
# example: ATOMIC_GROUP_SIMULATE

Diff for: projects/typescript-examples/algokit-utils-ts/references/account-reference.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async function AccountReferenceExampleMethod3() {
4848
const { referenceAccountAppClient, referenceAccount } = await setupLocalnetEnvironment()
4949

5050
// example: ACCOUNT_REFERENCE_EXAMPLE_METHOD_3
51-
// Include the account reference in the accountReferences array to be populated
51+
// Include the account reference in the accountReferences array to be populated manually
5252
const result = await referenceAccountAppClient.send.getAccountBalance({
5353
args: {},
5454
accountReferences: [referenceAccount],

Diff for: projects/typescript-examples/contracts/InnerTransactions/contract.algo.ts

+32-51
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import type { uint64 } from '@algorandfoundation/algorand-typescript'
1919
export default class InnerTransactions extends Contract {
2020
// example: PAYMENT
2121
/**
22-
* Demonstrates a simple payment inner transaction
22+
* Demonstrates a simple payment inner transaction.
23+
* The fee is set to 0 by default. Manually set here for demonstration purposes.
24+
* The `Sender` for the payment is implied to be Global.currentApplicationAddress.
25+
* If a different sender is needed, it'd have to be an account that has been
26+
* rekeyed to the application address.
2327
* @returns The amount of the payment
2428
*/
2529
@abimethod()
@@ -34,14 +38,6 @@ export default class InnerTransactions extends Contract {
3438

3539
return result.amount
3640
}
37-
38-
/**
39-
* fee is set to 0 by default. Manually set here for demonstration purposes.
40-
* The `Sender` for the above is implied to be Global.currentApplicationAddress.
41-
*
42-
* If a different sender is needed, it'd have to be an account that has been
43-
* rekeyed to the application address.
44-
*/
4541
// example: PAYMENT
4642

4743
// example: ASSET_CREATE
@@ -64,10 +60,12 @@ export default class InnerTransactions extends Contract {
6460
}
6561

6662
/**
67-
* Creates a non-fungible asset (NFT)
63+
* Creates a non-fungible asset (NFT).
6864
* Following the ARC3 standard, the total supply must be 1 for a non-fungible asset.
6965
* If you want to create fractional NFTs, `total` * `decimals` point must be 1.
7066
* ex) total=100, decimals=2, 100 * 0.01 = 1
67+
* The fee is set to 0 by default for inner transactions.
68+
* The Sender is implied to be Global.currentApplicationAddress.
7169
* @returns The ID of the created asset
7270
*/
7371
@abimethod()
@@ -93,7 +91,10 @@ export default class InnerTransactions extends Contract {
9391

9492
// example: ASSET_OPT_IN
9593
/**
96-
* Opts the application into an asset
94+
* Opts the application into an asset.
95+
* A zero amount asset transfer to one's self is a special type of asset transfer
96+
* that is used to opt-in to an asset.
97+
* To send an asset transfer, the asset must be an available resource.
9798
* @param asset The asset to opt into
9899
*/
99100
@abimethod()
@@ -107,19 +108,14 @@ export default class InnerTransactions extends Contract {
107108
})
108109
.submit()
109110
}
110-
111-
/**
112-
* A zero amount asset transfer to one's self is a special type of asset transfer
113-
* that is used to opt-in to an asset.
114-
*
115-
* To send an asset transfer, the asset must be an available resource.
116-
* Refer the Resource Availability section for more information.
117-
*/
118111
// example: ASSET_OPT_IN
119112

120113
// example: ASSET_TRANSFER
121114
/**
122-
* Transfers an asset from the application to another account
115+
* Transfers an asset from the application to another account.
116+
* For a smart contract to transfer an asset, the app account must be opted into the asset
117+
* and be holding non zero amount of assets.
118+
* To send an asset transfer, the asset must be an available resource.
123119
* @param asset The asset to transfer
124120
* @param receiver The account to receive the asset
125121
* @param amount The amount to transfer
@@ -136,18 +132,13 @@ export default class InnerTransactions extends Contract {
136132
.submit()
137133
}
138134

139-
/**
140-
* For a smart contract to transfer an asset, the app account must be opted into the asset
141-
* and be holding non zero amount of assets.
142-
*
143-
* To send an asset transfer, the asset must be an available resource.
144-
* Refer the Resource Availability section for more information.
145-
*/
146135
// example: ASSET_TRANSFER
147136

148137
// example: ASSET_FREEZE
149138
/**
150-
* Freezes an asset for a specific account
139+
* Freezes an asset for a specific account.
140+
* To freeze an asset, the asset must be a freezable asset
141+
* by having an account with freeze authority.
151142
* @param acctToBeFrozen The account to freeze the asset for
152143
* @param asset The asset to freeze
153144
*/
@@ -162,16 +153,14 @@ export default class InnerTransactions extends Contract {
162153
})
163154
.submit()
164155
}
165-
166-
/**
167-
* To freeze an asset, the asset must be a freezable asset
168-
* by having an account with freeze authority.
169-
*/
170156
// example: ASSET_FREEZE
171157

172158
// example: ASSET_REVOKE
173159
/**
174-
* Revokes (clawbacks) an asset from an account
160+
* Revokes (clawbacks) an asset from an account.
161+
* To revoke an asset, the asset must be a revocable asset
162+
* by having an account with clawback authority.
163+
* The Sender is implied to be current_application_address.
175164
* @param asset The asset to revoke
176165
* @param accountToBeRevoked The account to revoke the asset from
177166
* @param amount The amount to revoke
@@ -188,18 +177,15 @@ export default class InnerTransactions extends Contract {
188177
})
189178
.submit()
190179
}
191-
192-
/**
193-
* To revoke an asset, the asset must be a revocable asset
194-
* by having an account with clawback authority.
195-
*
196-
* Sender is implied to be current_application_address
197-
*/
198180
// example: ASSET_REVOKE
199181

200182
// example: ASSET_CONFIG
201183
/**
202-
* Reconfigures an existing asset
184+
* Reconfigures an existing asset.
185+
* For a smart contract to transfer an asset, the app account must be opted into the asset
186+
* and be holding non zero amount of assets.
187+
* To send an asset transfer, the asset must be an available resource.
188+
* Refer the Resource Availability section for more information.
203189
* @param asset The asset to reconfigure
204190
*/
205191
@abimethod()
@@ -215,19 +201,14 @@ export default class InnerTransactions extends Contract {
215201
})
216202
.submit()
217203
}
218-
219-
/**
220-
* For a smart contract to transfer an asset, the app account must be opted into the asset
221-
* and be holding non zero amount of assets.
222-
*
223-
* To send an asset transfer, the asset must be an available resource.
224-
* Refer the Resource Availability section for more information.
225-
*/
226204
// example: ASSET_CONFIG
227205

228206
// example: ASSET_DELETE
229207
/**
230-
* Deletes an asset
208+
* Deletes an asset.
209+
* To delete an asset, the asset must be a deleteable asset
210+
* by having an account with delete authority.
211+
* The Sender is implied to be current_application_address.
231212
* @param asset The asset to delete
232213
*/
233214
@abimethod()

Diff for: projects/typescript-examples/contracts/ReferenceAccountApp/contract.algo.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import type { uint64 } from '@algorandfoundation/algorand-typescript'
1414
import { Address } from '@algorandfoundation/algorand-typescript/arc4'
1515

16+
// example: REFERENCE_ACCOUNT_APP_EXAMPLE
1617
/**
1718
* A contract that maintains a per-account counter in local state
1819
* Accounts must opt in to use the counter
@@ -87,3 +88,4 @@ export default class ReferenceAccountApp extends Contract {
8788
return value
8889
}
8990
}
91+
// example: REFERENCE_ACCOUNT_APP_EXAMPLE

Diff for: projects/typescript-examples/contracts/ReferenceAccountAsset/contract.algo.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Contract, abimethod, Account, Asset, assert } from '@algorandfoundation/algorand-typescript'
22
import { Address } from '@algorandfoundation/algorand-typescript/arc4'
33

4+
// example: REFERENCE_ACCOUNT_ASSET_EXAMPLE
45
/**
56
* A contract that demonstrates how to reference both accounts and assets in a smart contract
67
*/
@@ -34,3 +35,4 @@ export default class ReferenceAccountAsset extends Contract {
3435
return asset.balance(account)
3536
}
3637
}
38+
// example: REFERENCE_ACCOUNT_ASSET_EXAMPLE

Diff for: projects/typescript-examples/contracts/ReferenceApp/contract.algo.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '@algorandfoundation/algorand-typescript'
1010
import type { uint64 } from '@algorandfoundation/algorand-typescript'
1111

12+
// example: APP_REFERENCE_EXAMPLE
1213
/**
1314
* A contract that increments a counter
1415
*/
@@ -75,3 +76,4 @@ export default class ReferenceApp extends Contract {
7576
return arc4.decodeArc4<uint64>(appCallTxn.lastLog, 'log')
7677
}
7778
}
79+
// example: APP_REFERENCE_EXAMPLE

Diff for: projects/typescript-examples/contracts/ReferenceAppBox/contract.algo.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '@algorandfoundation/algorand-typescript'
1414
import type { uint64 } from '@algorandfoundation/algorand-typescript'
1515

16+
// example: REFERENCE_APP_BOX_EXAMPLE
1617
/**
1718
* A contract that uses box storage to maintain a counter for each account
1819
* Each account needs to pay for the Minimum Balance Requirement (MBR) for their box
@@ -128,3 +129,4 @@ export default class ReferenceAppBox extends Contract {
128129
this.boxMbr.value = Uint64(2500) + this.boxSize.value * Uint64(400)
129130
}
130131
}
132+
// example: REFERENCE_APP_BOX_EXAMPLE

0 commit comments

Comments
 (0)