-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bigint filter for jsondiffpatch (#3561)
In the current implementation, `bigints` are treated as objects and are incorrectly excluded from generated patches. This fixes `bigint` diffing by adding a handler for these cases to the `jsondiffpatch` pipeline. ## To Test - [x] Send assets - [x] Check that balance changes after transaction succeeds Latest build: [extension-builds-3561](https://github.com/tahowallet/extension/suites/14449081920/artifacts/815732866) (as of Thu, 20 Jul 2023 17:02:04 GMT).
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DiffContext, Filter, create } from "jsondiffpatch" | ||
|
||
const differ = create() | ||
|
||
const bigintDiffFilter: Filter<DiffContext> = (context) => { | ||
if (typeof context.left === "bigint" && typeof context.right === "bigint") { | ||
if (context.left !== context.right) { | ||
context.setResult([context.left, context.right]) | ||
} | ||
} | ||
} | ||
bigintDiffFilter.filterName = "bigint" | ||
|
||
differ.processor.pipes.diff.before("objects", bigintDiffFilter) | ||
|
||
export const diff = differ.diff.bind(differ) | ||
export const patch = differ.patch.bind(differ) | ||
export type { Delta } from "jsondiffpatch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters