Skip to content

Commit

Permalink
Merge pull request #42 from rabbitholegg/fix_delete
Browse files Browse the repository at this point in the history
Fix(filters): copy vs delete
  • Loading branch information
Quazia authored Oct 19, 2023
2 parents f829eed + 42cd83c commit 9a5fef8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-candles-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rabbitholegg/questdk": patch
---

Use shallow copies instead of true copies
13 changes: 7 additions & 6 deletions src/filter/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export const handleAbiDecode = (context: any, filter: AbiFilter) => {
},
{},
)
delete (filter as FilterObject).$abi
if (apply({ ...namedArgs, sighash, functionName }, filter)) {
const { $abi: _, ...newFilter } = filter
if (apply({ ...namedArgs, sighash, functionName }, newFilter)) {
return true
}
return null
Expand All @@ -212,7 +212,8 @@ export const handleAbstractAbiDecode = (
const decodedReturn: ReturnType<typeof handleAbiDecode>[] = []
const elementCount = filter.$abiAbstract!.length
const $abiAbstract = filter.$abiAbstract
delete (filter as FilterObject).$abiAbstract
const { $abiAbstract: _, ...newFilter } = filter

const contextMap = new Map<string, number>()
// Function selectors are 4 bytes long - 8 characters
for (let i = 2; i < context.length - 8; i++) {
Expand All @@ -228,7 +229,7 @@ export const handleAbstractAbiDecode = (
if (index !== undefined) {
decodedReturn.push(
handleAbiDecode(`0x${context.substring(index)}`, {
...filter,
...newFilter,
$abi: [abiItem],
}),
)
Expand Down Expand Up @@ -261,8 +262,8 @@ export const handleAbiParamDecode = (context: any, filter: AbiParamFilter) => {
},
{},
)
delete (filter as FilterObject).$abiParams
if (apply(namedArgs, filter)) {
const { $abiParams: _, ...newFilter } = filter
if (apply(namedArgs, newFilter)) {
return true
}
return null
Expand Down

0 comments on commit 9a5fef8

Please sign in to comment.