@swapkit/plugins 4.6.35 → 4.6.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ import type { Mock } from "bun:test";
2
+ /**
3
+ * Extracts the first argument of the first call to a mocked function, typed
4
+ * as `T` so assertions can destructure without manual casts.
5
+ *
6
+ * Prefer this over `mock.mock.calls[0]?.[0] as T` because bun types
7
+ * `mock.calls` as `[]` in some positions which silently widens to `unknown`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const arg = firstCallArg<{ data: string; to: string }>(mockSendTransaction);
12
+ * expect(arg).toMatchObject({ data: "0xabc", to: "0xdef" });
13
+ * ```
14
+ */
15
+ export declare function firstCallArg<T = Record<string, unknown>>(fn: Mock<(...args: never[]) => unknown>): T | undefined;
16
+ /** One entry in the `AssetValue.staticAssets` cache — identifier + decimal count. */
17
+ export type StaticAssetEntry = readonly [key: string, value: {
18
+ decimal: number;
19
+ identifier: string;
20
+ }];
21
+ /**
22
+ * Populates `AssetValue.staticAssets` with the given entries **without** clobbering
23
+ * state set by other test files in the same bun process.
24
+ *
25
+ * Background: `AssetValue.setStaticAssets()` calls `staticTokensMap.clear()` internally,
26
+ * so calling it in one test file wipes the cache entries populated by another. In a
27
+ * `bun test` run every file shares one process, so this turns into cross-file pollution.
28
+ *
29
+ * This helper only inserts entries that are missing, and returns a cleanup function
30
+ * that deletes exactly the entries it added — safe to call from `afterAll`.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const cleanup = populateStaticAssets([
35
+ * ["BTC.BTC", { decimal: 8, identifier: "BTC.BTC" }],
36
+ * ["ETH.ETH", { decimal: 18, identifier: "ETH.ETH" }],
37
+ * ]);
38
+ * afterAll(cleanup);
39
+ * ```
40
+ */
41
+ export declare function populateStaticAssets(entries: ReadonlyArray<StaticAssetEntry>): () => void;
42
+ /**
43
+ * Captures a plain-object snapshot of an ESM namespace import so it can be
44
+ * re-installed via `mock.module(...)` in `afterAll`.
45
+ *
46
+ * Why this exists: bun's `mock.module` mutates the namespace binding in place.
47
+ * If you spread the namespace inside `afterAll` (e.g. `mock.module("foo", () => ({ ...realFoo }))`),
48
+ * you get the **mocked** version, not the real one, because `realFoo` has already been replaced.
49
+ * Taking the snapshot at module load time (before any `mock.module` runs) captures the
50
+ * genuine exports.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import * as realSolanaWeb3 from "@solana/web3.js";
55
+ * const realSolanaSnapshot = snapshotModule(realSolanaWeb3);
56
+ *
57
+ * mock.module("@solana/web3.js", () => ({ VersionedTransaction: fakeClass }));
58
+ *
59
+ * afterAll(() => {
60
+ * mock.module("@solana/web3.js", () => realSolanaSnapshot);
61
+ * });
62
+ * ```
63
+ */
64
+ export declare function snapshotModule<T extends object>(namespace: T): T;
65
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGrC;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAEhH;AAED,qFAAqF;AACrF,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,MAAM,IAAI,CAUzF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAEhE"}
package/package.json CHANGED
@@ -7,9 +7,9 @@
7
7
  "@noble/hashes": "2.0.1",
8
8
  "@scure/base": "2.0.0",
9
9
  "@solana/web3.js": "~1.98.4",
10
- "@swapkit/helpers": "4.13.5",
11
- "@swapkit/toolboxes": "4.15.8",
12
- "@swapkit/utxo-signer": "2.1.1",
10
+ "@swapkit/helpers": "4.13.6",
11
+ "@swapkit/toolboxes": "4.15.9",
12
+ "@swapkit/utxo-signer": "2.1.2",
13
13
  "ethers": "^6.14.0",
14
14
  "ts-pattern": "^5.9.0"
15
15
  },
@@ -82,5 +82,5 @@
82
82
  "type-check:go": "tsgo"
83
83
  },
84
84
  "type": "module",
85
- "version": "4.6.35"
85
+ "version": "4.6.36"
86
86
  }