@provex/utils 1.9.2-rc.20260725134754.714d99f → 1.9.2-rc.20260725154152.dfd6bd9

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.
package/dist/deposit.d.ts CHANGED
@@ -68,3 +68,39 @@ export type EscrowVersion = (typeof escrowVersions)[keyof typeof escrowVersions]
68
68
  * Array of escrow version values for use with onchainEnum in ponder.schema.ts.
69
69
  */
70
70
  export declare const ESCROW_VERSIONS: readonly EscrowVersion[];
71
+ /**
72
+ * A currency entry as the escrow's `createDeposit` / `addPaymentMethods` /
73
+ * `addCurrencies` calls expect it, before generation-specific fields.
74
+ */
75
+ export type EscrowCurrency = {
76
+ code: `0x${string}`;
77
+ minConversionRate: bigint;
78
+ };
79
+ /**
80
+ * v4's currency struct carries an `oracleRateConfig`; a zeroed config means
81
+ * "no oracle — settle at the fixed `minConversionRate`", which reproduces v3
82
+ * behaviour exactly. Deposits that do not price off an oracle use this.
83
+ */
84
+ export declare const EMPTY_ORACLE_RATE_CONFIG: {
85
+ readonly adapter: `0x${string}`;
86
+ readonly adapterConfig: `0x${string}`;
87
+ readonly spreadBps: 0;
88
+ readonly maxStaleness: 0;
89
+ };
90
+ /**
91
+ * Shape currency entries for a given escrow generation.
92
+ *
93
+ * Three escrow writes changed their currency tuple in v4 — `createDeposit`,
94
+ * `addPaymentMethods` and `addCurrencies` all gained the oracle rate config,
95
+ * which changes their selector. Sending v3-shaped currencies to EscrowV2
96
+ * produces a call it cannot decode; sending v4-shaped currencies to a v3
97
+ * escrow does the same. Route every currency list through here so the two
98
+ * stay paired with the interface the caller selected.
99
+ *
100
+ * @param currencies - The currency entries to shape
101
+ * @param version - The escrow generation being written to
102
+ * @returns The entries, with the zeroed oracle config attached for v4
103
+ */
104
+ export declare const toEscrowCurrencies: <T extends EscrowCurrency>(currencies: readonly T[], version: EscrowVersion) => readonly (T | (T & {
105
+ oracleRateConfig: typeof EMPTY_ORACLE_RATE_CONFIG;
106
+ }))[];
package/dist/deposit.js CHANGED
@@ -51,3 +51,31 @@ export const escrowVersions = {
51
51
  * Array of escrow version values for use with onchainEnum in ponder.schema.ts.
52
52
  */
53
53
  export const ESCROW_VERSIONS = Object.values(escrowVersions);
54
+ /**
55
+ * v4's currency struct carries an `oracleRateConfig`; a zeroed config means
56
+ * "no oracle — settle at the fixed `minConversionRate`", which reproduces v3
57
+ * behaviour exactly. Deposits that do not price off an oracle use this.
58
+ */
59
+ export const EMPTY_ORACLE_RATE_CONFIG = {
60
+ adapter: '0x0000000000000000000000000000000000000000',
61
+ adapterConfig: '0x',
62
+ spreadBps: 0,
63
+ maxStaleness: 0,
64
+ };
65
+ /**
66
+ * Shape currency entries for a given escrow generation.
67
+ *
68
+ * Three escrow writes changed their currency tuple in v4 — `createDeposit`,
69
+ * `addPaymentMethods` and `addCurrencies` all gained the oracle rate config,
70
+ * which changes their selector. Sending v3-shaped currencies to EscrowV2
71
+ * produces a call it cannot decode; sending v4-shaped currencies to a v3
72
+ * escrow does the same. Route every currency list through here so the two
73
+ * stay paired with the interface the caller selected.
74
+ *
75
+ * @param currencies - The currency entries to shape
76
+ * @param version - The escrow generation being written to
77
+ * @returns The entries, with the zeroed oracle config attached for v4
78
+ */
79
+ export const toEscrowCurrencies = (currencies, version) => version === 'v4'
80
+ ? currencies.map((currency) => ({ ...currency, oracleRateConfig: EMPTY_ORACLE_RATE_CONFIG }))
81
+ : currencies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provex/utils",
3
- "version": "1.9.2-rc.20260725134754.714d99f",
3
+ "version": "1.9.2-rc.20260725154152.dfd6bd9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",