@totemsdk/omnia-factory 0.7.2 → 0.8.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/dist/types.d.ts CHANGED
@@ -109,6 +109,14 @@ export interface ChannelFactory {
109
109
  allocations: Record<string, bigint>;
110
110
  /** Currently open virtual channels backed by this factory's shared UTXO. */
111
111
  virtualChannels: OmniaChannel[];
112
+ /**
113
+ * OMN-058: the covenant only permits cooperative spends that recreate the
114
+ * coin at the same script/value with the checkpoint sequence advanced
115
+ * (`enforceCheckpoints`). When set, off-chain allocation changes (virtual
116
+ * channels) are refused until they can be committed as a checkpoint, so a
117
+ * unilateral escape can never pay a stale split.
118
+ */
119
+ enforceCheckpoints?: boolean;
112
120
  /** Monotonically increasing. Incremented on every committed state transition. */
113
121
  currentSequence: number;
114
122
  status: FactoryStatus;
package/dist/virtual.js CHANGED
@@ -47,6 +47,14 @@ export function buildVirtualChannelOpen(factory, parties, amounts, channelId) {
47
47
  if (factory.status !== 'active') {
48
48
  throw new Error(`openVirtualChannel requires factory status 'active', got '${factory.status}'`);
49
49
  }
50
+ if (factory.enforceCheckpoints) {
51
+ // OMN-058: an off-chain allocation change would leave the on-chain coin
52
+ // paying the previous split. Refuse until the change can be committed as a
53
+ // checkpoint transaction (same script, same value, sequence + 1).
54
+ throw new Error(`factory ${factory.factoryId} uses checkpoint mode: opening a virtual channel changes the committed allocation `
55
+ + 'and must be committed with a factory checkpoint transaction first. '
56
+ + 'Create the factory with { enforceCheckpoints: false } only for a factory that will not rely on unilateral exits.');
57
+ }
50
58
  const [partyAId, partyBId] = parties;
51
59
  const amountA = amounts[partyAId] ?? 0n;
52
60
  const amountB = amounts[partyBId] ?? 0n;
@@ -219,6 +227,10 @@ export function buildVirtualChannelClose(factory, channel) {
219
227
  const existing = factory.virtualChannels.find(c => c.channelId === channel.channelId);
220
228
  if (!existing)
221
229
  throw new Error(`Virtual channel '${channel.channelId}' not found in factory`);
230
+ if (factory.enforceCheckpoints) {
231
+ throw new Error(`factory ${factory.factoryId} uses checkpoint mode: closing a virtual channel changes the committed allocation `
232
+ + 'and must be committed with a factory checkpoint transaction first.');
233
+ }
222
234
  const finalAllocations = channel.latestState?.balances ?? { ...channel.balances };
223
235
  const finalSum = Object.values(finalAllocations).reduce((a, b) => a + b, 0n);
224
236
  if (finalSum !== channel.totalValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-factory",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Channel factory layer for Omnia — N-of-N MULTISIG funding, virtual channel management, and factory settlement",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -25,13 +25,13 @@
25
25
  "NOTICE"
26
26
  ],
27
27
  "dependencies": {
28
+ "@totemsdk/core": "^1.6.1",
28
29
  "@totemsdk/wots-lease": "^1.0.3",
29
- "@totemsdk/omnia": "^2.4.4",
30
+ "@totemsdk/omnia": "^3.0.0",
30
31
  "@totemsdk/txpow": "^1.1.1",
31
- "@totemsdk/chain-provider": "^0.3.3",
32
- "@totemsdk/tx-builder": "^0.3.3",
33
- "@totemsdk/storage": "^0.2.2",
34
- "@totemsdk/core": "^1.5.0"
32
+ "@totemsdk/tx-builder": "^0.3.5",
33
+ "@totemsdk/chain-provider": "^0.4.0",
34
+ "@totemsdk/storage": "^0.2.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.0.0",