diff --git a/docs/code/modules/index.md b/docs/code/modules/index.md index f9ec4865..bc2f039c 100644 --- a/docs/code/modules/index.md +++ b/docs/code/modules/index.md @@ -370,7 +370,7 @@ the estimated rate. #### Defined in -[src/transaction/transaction.ts:796](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L796) +[src/transaction/transaction.ts:816](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L816) ___ @@ -426,7 +426,7 @@ Allows for control of fees on a `Transaction` or `SuggestedParams` object #### Defined in -[src/transaction/transaction.ts:819](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L819) +[src/transaction/transaction.ts:839](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L839) ___ @@ -1605,7 +1605,7 @@ The array of transactions with signers #### Defined in -[src/transaction/transaction.ts:851](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L851) +[src/transaction/transaction.ts:871](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L871) ___ @@ -1938,7 +1938,7 @@ The suggested transaction parameters #### Defined in -[src/transaction/transaction.ts:842](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L842) +[src/transaction/transaction.ts:862](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L862) ___ @@ -2300,7 +2300,7 @@ The dryrun result #### Defined in -[src/transaction/transaction.ts:676](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L676) +[src/transaction/transaction.ts:696](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L696) ___ @@ -2431,7 +2431,7 @@ A new ATC with the resources packed into the transactions #### Defined in -[src/transaction/transaction.ts:288](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L288) +[src/transaction/transaction.ts:308](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L308) ___ @@ -2591,7 +2591,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa #### Defined in -[src/transaction/transaction.ts:541](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L541) +[src/transaction/transaction.ts:561](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L561) ___ @@ -2616,7 +2616,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa #### Defined in -[src/transaction/transaction.ts:694](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L694) +[src/transaction/transaction.ts:714](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L714) ___ @@ -2895,4 +2895,4 @@ Throws an error if the transaction is not confirmed or rejected in the next `tim #### Defined in -[src/transaction/transaction.ts:739](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L739) +[src/transaction/transaction.ts:759](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L759) diff --git a/src/transaction/transaction.spec.ts b/src/transaction/transaction.spec.ts index 6a7bd4ef..410274ee 100644 --- a/src/transaction/transaction.spec.ts +++ b/src/transaction/transaction.spec.ts @@ -783,4 +783,35 @@ describe('Resource Packer: meta', () => { expect(res.transaction.appAccounts?.length || 0).toBe(0) }) + + test('rekeyed account', async () => { + const { testAccount } = fixture.context + const { algorand } = fixture + + const authAddr = algorand.account.random().account + + + await algorand.send.payment({ + sender: testAccount.addr, + receiver: testAccount.addr, + rekeyTo: authAddr.addr, + amount: algokit.microAlgos(0), + }) + + await externalClient.fundAppAccount(algokit.microAlgos(200_000)) + + await externalClient.call({ + method: 'createAsset', + methodArgs: [], + sendParams: { fee: algokit.microAlgos(2_000) }, + sender: { addr: testAccount.addr, signer: algosdk.makeBasicAccountTransactionSigner(authAddr) }, + }) + const res = await externalClient.call({ + method: 'senderAssetBalance', + methodArgs: [], + sender: { addr: testAccount.addr, signer: algosdk.makeBasicAccountTransactionSigner(authAddr) }, + }) + + expect(res.transaction.appAccounts?.length || 0).toBe(0) + }) }) diff --git a/src/transaction/transaction.ts b/src/transaction/transaction.ts index 94d999ea..6d7e7327 100644 --- a/src/transaction/transaction.ts +++ b/src/transaction/transaction.ts @@ -246,9 +246,29 @@ async function getUnnamedAppCallResourcesAccessed(atc: algosdk.AtomicTransaction allowEmptySignatures: true, }) + const signerWithFixedSgnr: algosdk.TransactionSigner = async (txns: algosdk.Transaction[], indexes: number[]) => { + const stxns = await algosdk.makeEmptyTransactionSigner()(txns, indexes) + return Promise.all( + stxns.map(async (stxn) => { + const decodedStxn = algosdk.decodeSignedTransaction(stxn) + const sender = algosdk.encodeAddress(decodedStxn.txn.from.publicKey) + + const authAddr = (await algod.accountInformation(sender).do())['auth-addr'] + + const stxnObj: { txn: algosdk.EncodedTransaction; sgnr?: Buffer } = { txn: decodedStxn.txn.get_obj_for_encoding() } + + if (authAddr !== undefined) { + stxnObj.sgnr = Buffer.from(algosdk.decodeAddress(authAddr).publicKey) + } + + return algosdk.encodeObj(stxnObj) + }), + ) + } + const emptySignerAtc = atc.clone() emptySignerAtc['transactions'].forEach((t: algosdk.TransactionWithSigner) => { - t.signer = algosdk.makeEmptyTransactionSigner() + t.signer = signerWithFixedSgnr }) const result = await emptySignerAtc.simulate(algod, simReq)