@ouronet/ouronet-core 4.4.0 → 4.5.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,43 @@ All notable changes to `@ouronet/ouronet-core`.
4
4
 
5
5
  This package is the historical continuation of `@ouronet/ouronet-core` v0.x–v3.3.8. v4.0.0 split it into a two-package npm workspace under `StoaChain/stoa-js` — chain-generic infrastructure moved out into [`@stoachain/stoa-core`](https://www.npmjs.com/package/@stoachain/stoa-core), this package retained the Ouronet-specific business logic. The `4.0.0` heading below is the first release after the split.
6
6
 
7
+ ## 4.5.0 — 2026-09-07
8
+
9
+ **MINOR — cross-chain gas payer switched to `stoa-xchain-gas`; live Yin-Engine gas pricing.**
10
+
11
+ ### What changed
12
+
13
+ `crossChainFunctions.ts`'s non-chain-0 gas payer moves off the legacy `kadena-xchain-gas`
14
+ account (a static `gasPrice <= 0.00000001` / `gasLimit <= 850` guard) onto StoaChain's own
15
+ `stoa-xchain-gas` account. Its guard (`pact/genesis/stoa/stoa-genesis-5.pact`) requires
16
+ `gasPrice <= UC_MinimumGasPriceANU()` — a **live floor**, not a fixed ceiling — so a hardcoded
17
+ price would eventually either be rejected by this guard's ceiling (once the floor rises above
18
+ whatever was hardcoded, that part is safe) or, more importantly, fall **below** the chain-wide
19
+ minimum price the Yin Engine enforces post-fork.
20
+
21
+ All four `gasPrice` call sites in this file now derive `{ creationTime, gasPrice }` from a
22
+ single local Yin-Engine helper instead of a hardcoded number or the static `GAS_PRICE_MIN_ANU`:
23
+
24
+ - `buildCrossChainTransfer` (legacy single-step `coin.transfer-crosschain`, self-paid gas)
25
+ - `buildCTransferAcross` — chain-0 branch (`DALOS.GAS_PAYER`, previously on the static
26
+ `anuToStoa(GAS_PRICE_MIN_ANU)`)
27
+ - `buildCTransferAcross` — non-chain-0 branch (now `stoa-xchain-gas`, was `kadena-xchain-gas`)
28
+ - `buildContinuationTransaction` — default `gasPayerAccount` (now `stoa-xchain-gas`)
29
+
30
+ The Yin-Engine helper is a **temporary local duplicate** of OuronetUI's `src/lib/gas-price.ts`
31
+ (same constants, same formula — genesis 10,000 ANU, +1 ANU/3h, capped at 400,000 ANU). It
32
+ belongs in `@stoachain/stoa-core/gas` once that package ships the same formula; that package
33
+ currently still only exports the static `GAS_PRICE_MIN_ANU = 10_000`. Consolidate then.
34
+
35
+ ### Verification
36
+
37
+ Confirmed against a live StoaChain node (not just simulated): both the initial
38
+ `C_TransferAcross` (chain-0, `DALOS.GAS_PAYER`) and the `stoa-xchain-gas`-paid continuation
39
+ landed successfully at **11,565 ANU/gas**, the live floor at time of testing.
40
+
41
+ Non-breaking. No exported function signatures changed — only the default `gasPayerAccount`
42
+ value and the internal price derivation. **787 specs pass.**
43
+
7
44
  ## 4.4.0 — 2026-07-22
8
45
 
9
46
  **MINOR — the codex writer is held at `"1.2"` while the reader keeps accepting `"1.2"` and `"1.3"`.**
package/README.md CHANGED
@@ -23,6 +23,8 @@ Chain-generic infrastructure (signing, wallet, crypto, network failover, gas, gu
23
23
 
24
24
  ## Status
25
25
 
26
+ **`4.5.0` on public npmjs** — **MINOR (cross-chain gas payer switched to `stoa-xchain-gas`; live Yin-Engine gas pricing).** Released 2026-09-07. `crossChainFunctions.ts`'s non-chain-0 gas payer moves off the legacy `kadena-xchain-gas` account (a static `gasPrice <= 0.00000001` / `gasLimit <= 850` guard) onto StoaChain's own `stoa-xchain-gas` account, whose guard (`pact/genesis/stoa/stoa-genesis-5.pact`) requires `gasPrice <= UC_MinimumGasPriceANU()` — a *live floor*, not a fixed ceiling. All four `gasPrice` call sites in this file (the legacy `buildCrossChainTransfer`, both `buildCTransferAcross` branches — including the chain-0 `DALOS.GAS_PAYER` path, previously on the static `GAS_PRICE_MIN_ANU` — and `buildContinuationTransaction`'s default payer) now derive `{ creationTime, gasPrice }` from a local Yin-Engine helper instead of a hardcoded price. That helper is a temporary duplicate of OuronetUI's `src/lib/gas-price.ts` — it belongs in `@stoachain/stoa-core/gas` once that package ships the same formula (it currently still exports only the static `GAS_PRICE_MIN_ANU = 10_000`); consolidate then. Verified against a live StoaChain node: both the initial `C_TransferAcross` (chain-0, `DALOS.GAS_PAYER`) and the `stoa-xchain-gas`-paid continuation landed successfully at 11,565 ANU/gas. Non-breaking — no exported signatures changed, only the default `gasPayerAccount` value and the internal price derivation. **787 specs pass.**
27
+
26
28
  **`4.4.0` on public npmjs** — **MINOR (codec writer held at 1.2; reader still accepts 1.2 and 1.3).** Released 2026-07-22. Corrects 4.3.6/4.3.7, which shipped an unreleased 1.3 *writer* and so produced backups that apps on a 1.2-only reader could not open. The reader is unchanged and still accepts both, so any 1.3 file already written stays readable; the writer stamps 1.2 again. Nothing is lost — this writer never emitted the 1.3-only `foreignKeys` block. Those two versions are deprecated and point here. **787 specs pass.**
27
29
 
28
30
  **`4.3.7` on public npmjs** — **PATCH (chain-peer realignment with `@stoachain/stoa-core@4.3.7` + `@stoachain/kadena-stoic-legacy@4.3.7`).** Released 2026-07-22. NO code changes in this package. The exact chain peers move 4.3.6 → 4.3.7 so consumers resolving the current chain layer get a satisfiable tree; stoa-js 4.3.7 repointed DALOS onto `@ouronet/dalos-crypto@4.0.4`. **785 specs pass.**
@@ -45,6 +47,8 @@ Chain-generic infrastructure (signing, wallet, crypto, network failover, gas, gu
45
47
 
46
48
  **`4.2.0` on public npmjs** — **MINOR (atomic with `@stoachain/stoa-core@4.2.0` + `@stoachain/kadena-stoic-legacy@4.2.0`).** Released 2026-05-09. Closes 6 audit findings: **F-ARCH-001** (Phase 1 dex god-file split — ~10 entity-oriented files + thin re-export shim), **F-ARCH-002** (Phase 2 ouro god-file split + chain/UI surgical separation — ~11 entity-oriented files + thin re-export shim), **F-ARCH-003** (Phase 3 parameterized liquidity executor — 5 thin wrappers + 1 internal `executeLiquidityOp`, LOC reduction ~600 → ~200), **F-API-002** (Phase 4 — 12 functions honor declared `Promise<T | null>` contract, return null on RPC failure instead of rethrowing), **F-API-018** (Phase 5 readonly sweep — ~50 public-type fields in `codex/types.ts` and all `*Params` interfaces), **F-TEST-006** (Phase 7 — +127 specs across 6 modules: `infoOneFunctions`, `coilFunctions`, `kpayFunctions`, `pensionFunctions`, `activateFunctions`, `guardFunctions`). NEW deliverable: [`INTEGRATION-GUIDE.md`](https://github.com/StoaChain/stoa-js/blob/main/INTEGRATION-GUIDE.md) at repo root — comprehensive cold-start consumer onboarding doc, 13 sections, full v4.0 → v4.1 → v4.2 architectural arc. 8 new `v4-2-0-*.test.ts` regression-lock files. Test count: **710 specs pass** (was ~330 in v4.1.1). Cross-reference: see [`MIGRATION-v4.2.md`](https://github.com/StoaChain/stoa-js/blob/main/MIGRATION-v4.2.md) at the monorepo root.
47
49
 
50
+ **v4.5.0** — cross-chain gas payer switched to `stoa-xchain-gas` with live Yin-Engine pricing (replaces the legacy `kadena-xchain-gas` static ceiling). Released 2026-09-07. All four `gasPrice` sites in `crossChainFunctions.ts` now derive price from the current Yin floor instead of a hardcoded value; verified landing on a live StoaChain node at 11,565 ANU/gas. No signature changes. **787 specs pass.**
51
+
48
52
  **v4.4.0** — codec writer held at `"1.2"`; reader still accepts `"1.2"` and `"1.3"`. Released 2026-07-22. Corrects the 4.3.6/4.3.7 mispublish, which shipped an unreleased 1.3 writer under version numbers the old `@stoachain` package had already used. **787 specs pass.**
49
53
 
50
54
  **v4.3.7** — chain-peer realignment bump (exact peers on `@stoachain/stoa-core@4.3.7` + `@stoachain/kadena-stoic-legacy@4.3.7`). Released 2026-07-22. NO code changes. Required because this package pins its chain peers exactly and stoa-js now releases independently. **785 specs pass.**
@@ -53,7 +53,7 @@ export interface CTransferAcrossParams {
53
53
  * Build a coin.C_TransferAcross transaction (step 0 of cross-chain transfer).
54
54
  *
55
55
  * Chain 0: Gas paid by Ouronet Gas Station (DALOS.GAS_PAYER).
56
- * Other chains: Gas paid by kadena-xchain-gas (unsigned).
56
+ * Other chains: Gas paid by stoa-xchain-gas (unsigned).
57
57
  */
58
58
  export declare function buildCTransferAcross(params: CTransferAcrossParams): any;
59
59
  /**
@@ -1,9 +1,49 @@
1
1
  import { Pact } from "@stoachain/kadena-stoic-legacy/client";
2
2
  import { getFailoverClient, withFailover } from "@stoachain/stoa-core/network";
3
3
  import { KADENA_NETWORK, getPactUrl, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NAMESPACE } from "../constants/index.js";
4
- import { GAS_PRICE_MIN_ANU, anuToStoa } from "@stoachain/stoa-core/gas";
5
4
  import { pactRead } from "@stoachain/stoa-core/reads";
6
5
  import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
6
+ /**
7
+ * Yin Engine — StoaChain's time-varying minimum gas price.
8
+ *
9
+ * TEMPORARY LOCAL COPY. This mirrors `OuronetUI/src/lib/gas-price.ts` exactly
10
+ * (same constants, same formula) because `@stoachain/stoa-core/gas` has not
11
+ * yet been upgraded past the static `GAS_PRICE_MIN_ANU = 10_000`. It belongs
12
+ * there long-term (chain-generic, not Ouronet-specific) — consolidate this
13
+ * away once stoa-core ships it.
14
+ *
15
+ * The floor starts at 10,000 ANU at genesis and rises by 1 ANU every 3 hours,
16
+ * capped at 400,000 ANU. Source of truth: `UC_MinimumGasPriceANU` in
17
+ * `pact/stoa-coin/new-coin.pact` (evaluated against `(at "block-time"
18
+ * (chain-data))` on-chain — creationTime is a close client-side proxy for it).
19
+ *
20
+ * `stoa-xchain-gas`'s own guard (`pact/genesis/stoa/stoa-genesis-5.pact`)
21
+ * requires `gasPrice <= UC_MinimumGasPriceANU()` (an upper bound, not a
22
+ * floor) — combined with the chain-wide "must be >= the floor" rule, the
23
+ * only value that satisfies both is the floor itself. Never overpay this
24
+ * account; it pays minimum-priced redemptions only.
25
+ */
26
+ const YIN_GENESIS_TIME_S = 1771869600; // 2026-02-23T18:00:00Z — tick 0
27
+ const YIN_GENESIS_MIN_GAS_ANU = 10000;
28
+ const YIN_MAX_GAS_ANU = 400000;
29
+ const YIN_GAS_PRICE_INTERVAL_S = 10800; // 3 h per tick
30
+ function minGasPriceAnu(creationTimeS) {
31
+ const elapsed = creationTimeS - YIN_GENESIS_TIME_S;
32
+ const ticks = elapsed <= 0 ? 0 : Math.floor(elapsed / YIN_GAS_PRICE_INTERVAL_S);
33
+ return Math.min(YIN_GENESIS_MIN_GAS_ANU + ticks, YIN_MAX_GAS_ANU);
34
+ }
35
+ /** Built by string padding, never float division — avoids exponential notation / precision loss. */
36
+ function anuToStoaNumber(anu) {
37
+ return Number("0." + String(anu).padStart(12, "0"));
38
+ }
39
+ /**
40
+ * One clock read: the `creationTime` to stamp and the `gasPrice` derived
41
+ * FROM THAT EXACT VALUE, so the two can never disagree.
42
+ */
43
+ function stoaGasMeta() {
44
+ const creationTime = safeCreationTime();
45
+ return { creationTime, gasPrice: anuToStoaNumber(minGasPriceAnu(creationTime)) };
46
+ }
7
47
  /**
8
48
  * Get KDA balance for an account on a specific chain.
9
49
  * exists=false means the account row does not exist on that chain (not just zero balance).
@@ -72,20 +112,17 @@ export function buildCrossChainTransfer(params) {
72
112
  .setMeta({
73
113
  chainId: sourceChain,
74
114
  senderAccount: sender,
75
- // v3.2.3: added `creationTime: safeCreationTime()` to close audit
76
- // finding F-BUG-002. The v2.3.0 audit consolidated `safeCreationTime()`
77
- // (returns `Date.now()/1000 - 30`) precisely so client-side clock drift
78
- // doesn't trigger chain-side "creation time too far in the future"
79
- // rejections; without this field, `@kadena/client` falls back to the
80
- // raw current time and any consumer with a clock slightly ahead of
81
- // node time gets sporadic submit failures. This was the lone builder
82
- // in interactions/* that omitted the helper after the v2.3.0 sweep —
83
- // every other setMeta block (including `buildCTransferAcross` two
84
- // functions below) already includes it.
85
- creationTime: safeCreationTime(),
115
+ // v3.2.3: `creationTime` closes audit finding F-BUG-002 — without it
116
+ // `@kadena/client` falls back to raw current time and a client clock
117
+ // slightly ahead of node time gets sporadic submit failures.
118
+ // `stoaGasMeta()` supplies both `creationTime` (via `safeCreationTime()`)
119
+ // and the `gasPrice` derived from that exact value, per the Yin Engine
120
+ // (see the module-level comment above) the chain-wide minimum price
121
+ // rises over time, so a hardcoded `gasPrice` would eventually be
122
+ // rejected as underpriced.
86
123
  gasLimit: 2500,
87
- gasPrice: 0.00000001,
88
124
  ttl: 28800,
125
+ ...stoaGasMeta(),
89
126
  })
90
127
  .setNetworkId(KADENA_NETWORK)
91
128
  .createTransaction();
@@ -95,7 +132,7 @@ export function buildCrossChainTransfer(params) {
95
132
  * Build a coin.C_TransferAcross transaction (step 0 of cross-chain transfer).
96
133
  *
97
134
  * Chain 0: Gas paid by Ouronet Gas Station (DALOS.GAS_PAYER).
98
- * Other chains: Gas paid by kadena-xchain-gas (unsigned).
135
+ * Other chains: Gas paid by stoa-xchain-gas (unsigned).
99
136
  */
100
137
  export function buildCTransferAcross(params) {
101
138
  const { sender, receiver, receiverGuard, amount, sourceChain, targetChain, senderPublicKey, gasStationPublicKey, } = params;
@@ -118,18 +155,19 @@ export function buildCTransferAcross(params) {
118
155
  .setMeta({
119
156
  chainId: "0",
120
157
  senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
121
- creationTime: safeCreationTime(),
122
158
  gasLimit: 2500,
123
- gasPrice: anuToStoa(GAS_PRICE_MIN_ANU),
124
159
  ttl: 28800,
160
+ ...stoaGasMeta(),
125
161
  })
126
162
  .setNetworkId(KADENA_NETWORK)
127
163
  .createTransaction();
128
164
  }
129
165
  else {
130
- // Non-chain-0: kadena-xchain-gas pays gas.
166
+ // Non-chain-0: stoa-xchain-gas pays gas (StoaChain's own xchain gas
167
+ // station — replaces the legacy `kadena-xchain-gas` account).
131
168
  // Its guard uses coin.gas-only (no signature needed) BUT requires:
132
- // - gasPrice <= 0.00000001
169
+ // - gasPrice <= UC_MinimumGasPriceANU() (the live Yin floor — an upper
170
+ // bound, not a static ceiling; see the module-level comment above)
133
171
  // - gasLimit <= 850
134
172
  // No signer needed for gas — only sender signs TRANSFER_XCHAIN cap.
135
173
  return Pact.builder
@@ -140,10 +178,10 @@ export function buildCTransferAcross(params) {
140
178
  ])
141
179
  .setMeta({
142
180
  chainId: sourceChain,
143
- senderAccount: "kadena-xchain-gas",
144
- gasLimit: 850, // must be 850 for kadena-xchain-gas guard
145
- gasPrice: 0.00000001, // must be ≤ 0.00000001 for kadena-xchain-gas guard
181
+ senderAccount: "stoa-xchain-gas",
182
+ gasLimit: 850, // must be <= 850 for the stoa-xchain-gas guard
146
183
  ttl: 28800,
184
+ ...stoaGasMeta(),
147
185
  })
148
186
  .setNetworkId(KADENA_NETWORK)
149
187
  .createTransaction();
@@ -326,7 +364,7 @@ export async function pollSpvProof(requestKey, sourceChain, targetChain, maxAtte
326
364
  * Build a continuation transaction for step 2 of cross-chain transfer
327
365
  * This can be executed by anyone - no signature required from original sender
328
366
  */
329
- export function buildContinuationTransaction(pactId, proof, targetChain, gasPayerAccount = "kadena-xchain-gas") {
367
+ export function buildContinuationTransaction(pactId, proof, targetChain, gasPayerAccount = "stoa-xchain-gas") {
330
368
  const transaction = Pact.builder
331
369
  .continuation({
332
370
  pactId,
@@ -337,9 +375,9 @@ export function buildContinuationTransaction(pactId, proof, targetChain, gasPaye
337
375
  .setMeta({
338
376
  chainId: targetChain,
339
377
  senderAccount: gasPayerAccount,
340
- gasLimit: 850,
341
- gasPrice: 0.00000001,
378
+ gasLimit: 850, // must be <= 850 for the stoa-xchain-gas guard
342
379
  ttl: 28800,
380
+ ...stoaGasMeta(),
343
381
  })
344
382
  .setNetworkId(KADENA_NETWORK)
345
383
  .createTransaction();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouronet/ouronet-core",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "Ouronet-specific business logic for the Ouronet protocol on StoaChain — interactions/* read+execute functions for the ouronet-ns Pact modules, the Codex encrypted-multi-wallet format, Ouronet protocol accounts and tokens. Depends on @stoachain/stoa-core for chain-generic infrastructure (signing, wallet, crypto, network, etc.).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",