Skip to content

Commit

Permalink
fix: remove all duplicate resources in resource population (#243)
Browse files Browse the repository at this point in the history
* fix: double addr in resource population

* fix: remove all duplicate resources

* docs

---------

Co-authored-by: Joe Polny <joepolny@gmail.com>
  • Loading branch information
robdmoore and joe-p authored Mar 13, 2024
1 parent 2a327f8 commit e323559
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/code/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ the estimated rate.

#### Defined in

[src/transaction/transaction.ts:667](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L667)
[src/transaction/transaction.ts:675](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L675)

___

Expand Down Expand Up @@ -405,7 +405,7 @@ Allows for control of fees on a `Transaction` or `SuggestedParams` object

#### Defined in

[src/transaction/transaction.ts:690](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L690)
[src/transaction/transaction.ts:698](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L698)

___

Expand Down Expand Up @@ -1477,7 +1477,7 @@ The array of transactions with signers

#### Defined in

[src/transaction/transaction.ts:722](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L722)
[src/transaction/transaction.ts:730](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L730)

___

Expand Down Expand Up @@ -1810,7 +1810,7 @@ The suggested transaction parameters

#### Defined in

[src/transaction/transaction.ts:713](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L713)
[src/transaction/transaction.ts:721](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L721)

___

Expand Down Expand Up @@ -2145,7 +2145,7 @@ The dryrun result

#### Defined in

[src/transaction/transaction.ts:547](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L547)
[src/transaction/transaction.ts:555](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L555)

___

Expand Down Expand Up @@ -2436,7 +2436,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa

#### Defined in

[src/transaction/transaction.ts:419](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L419)
[src/transaction/transaction.ts:427](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L427)

___

Expand All @@ -2461,7 +2461,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa

#### Defined in

[src/transaction/transaction.ts:565](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L565)
[src/transaction/transaction.ts:573](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L573)

___

Expand Down Expand Up @@ -2740,4 +2740,4 @@ Throws an error if the transaction is not confirmed or rejected in the next `tim

#### Defined in

[src/transaction/transaction.ts:610](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L610)
[src/transaction/transaction.ts:618](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction/transaction.ts#L618)
8 changes: 8 additions & 0 deletions src/transaction/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,20 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
const txnIndex = findTxnBelowRefLimit(group, 'appLocal')
group[txnIndex].txn.appForeignApps?.push(Number(a.app))
group[txnIndex].txn.appAccounts?.push(algosdk.decodeAddress(a.account))

// Remove resources from the group if we're adding them here
g.accounts = g.accounts?.filter((acc) => acc !== a.account)
g.apps = g.apps?.filter((app) => BigInt(app) !== BigInt(a.app))
})

g.assetHoldings?.forEach((a) => {
const txnIndex = findTxnBelowRefLimit(group, 'assetHolding')
group[txnIndex].txn.appForeignAssets?.push(Number(a.asset))
group[txnIndex].txn.appAccounts?.push(algosdk.decodeAddress(a.account))

// Remove resources from the group if we're adding them here
g.accounts = g.accounts?.filter((acc) => acc !== a.account)
g.assets = g.assets?.filter((asset) => BigInt(asset) !== BigInt(a.asset))
})

// Do accounts next because the account limit is 4
Expand Down

0 comments on commit e323559

Please sign in to comment.