Skip to content

Commit 98c005e

Browse files
authored
fix: chore subscriber-ts tweaks (#66)
1 parent 788baa3 commit 98c005e

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"pre-commit": "run-s check-types lint:fix audit test"
2323
},
2424
"dependencies": {
25-
"@algorandfoundation/algokit-subscriber": "^1.3.0-beta.3",
26-
"@algorandfoundation/algokit-utils": "^6.0.0-beta.1",
25+
"@algorandfoundation/algokit-subscriber": "^1.3.0-beta.6",
26+
"@algorandfoundation/algokit-utils": "^6.0.4",
2727
"@radix-ui/react-dialog": "^1.0.5",
2828
"@radix-ui/react-dropdown-menu": "^2.0.6",
2929
"@radix-ui/react-icons": "^1.3.0",

src/features/blocks/data/latest-blocks.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ const subscribeToBlocksEffect = atomEffect((get, set) => {
151151
bc.roles.includes(BalanceChangeRole.Sender) &&
152152
bc.roles.includes(BalanceChangeRole.Receiver)
153153
const isNonZeroAmount = bc.amount !== 0n // Can either be negative (decreased balance) or positive (increased balance)
154-
return isAssetOptIn || isNonZeroAmount
154+
const isAssetCreate = bc.roles.includes(BalanceChangeRole.AssetCreator) && bc.amount > 0n
155+
// This is technically not the correct handling, as the asset manager (assigned as the address in the balance change) must destroy the asset, however it's the creator who must hold the balance on destruction.
156+
// Unfortunately determining the asset creator is tricky once the asset is destroyed.
157+
// It's fairly common for the asset creator to be the asset manager, so simply assume that.
158+
const isAssetDestroy = bc.roles.includes(BalanceChangeRole.AssetDestroyer)
159+
return isAssetOptIn || isNonZeroAmount || isAssetCreate || isAssetDestroy
155160
})
156161
.map((bc) => bc.address)
157162
.filter(distinct((x) => x)) ?? []

0 commit comments

Comments
 (0)