diff --git a/background/differ.ts b/background/differ.ts new file mode 100644 index 0000000000..c43b1e8cf1 --- /dev/null +++ b/background/differ.ts @@ -0,0 +1,18 @@ +import { DiffContext, Filter, create } from "jsondiffpatch" + +const differ = create() + +const bigintDiffFilter: Filter = (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" diff --git a/background/index.ts b/background/index.ts index b80f9d4a90..3ef5b4f657 100644 --- a/background/index.ts +++ b/background/index.ts @@ -1,10 +1,10 @@ import browser from "webextension-polyfill" import { Store as ProxyStore } from "webext-redux" -import { Delta, patch as patchDeepDiff } from "jsondiffpatch" import { produce } from "immer" import { AnyAction } from "@reduxjs/toolkit" +import { Delta, patch as patchDeepDiff } from "./differ" import Main from "./main" import { encodeJSON, decodeJSON } from "./lib/utils" diff --git a/background/main.ts b/background/main.ts index 01eae2e1d9..fc60e83b1c 100644 --- a/background/main.ts +++ b/background/main.ts @@ -1,12 +1,12 @@ import browser, { runtime } from "webextension-polyfill" import { alias, wrapStore } from "webext-redux" -import { diff as deepDiff } from "jsondiffpatch" import { configureStore, isPlain, Middleware } from "@reduxjs/toolkit" import { devToolsEnhancer } from "@redux-devtools/remote" import { PermissionRequest } from "@tallyho/provider-bridge-shared" import { debounce } from "lodash" import { utils } from "ethers" +import { diff as deepDiff } from "./differ" import { decodeJSON, encodeJSON,