Skip to content

Commit 31df3ce

Browse files
authored
fix: correctly return group id when resource population is enabled (#381)
1 parent df9f82d commit 31df3ce

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

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)