@totemsdk/omnia-factory 0.9.0 → 0.10.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.
@@ -40,6 +40,14 @@ function createDurableFactoryStore(adapter, options = {}) {
40
40
  return {
41
41
  async saveFactory(factory) {
42
42
  await mutate((state) => {
43
+ const existing = state.factories[factory.factoryId];
44
+ // OMN-115: factory state is ordered by `currentSequence`. A delayed
45
+ // writer holding an older record must not roll the factory back, even
46
+ // though the snapshot CAS accepts the write itself.
47
+ if (existing && factory.currentSequence < existing.currentSequence) {
48
+ throw new errors_1.StorageError(`refusing to overwrite factory ${factory.factoryId} sequence ${existing.currentSequence} `
49
+ + `with stale sequence ${factory.currentSequence}`, 'write-failed', { key: factory.factoryId });
50
+ }
43
51
  const factories = { ...state.factories, [factory.factoryId]: factory };
44
52
  return { ...state, factories };
45
53
  });
@@ -67,6 +67,11 @@ function buildVirtualChannelOpen(factory, parties, amounts, channelId) {
67
67
  + 'Create the factory with { enforceCheckpoints: false } only for a factory that will not rely on unilateral exits.');
68
68
  }
69
69
  const [partyAId, partyBId] = parties;
70
+ // OMN-127: identical participants would make both allocation deductions write
71
+ // the same key, silently overwriting one side.
72
+ if (!partyAId || !partyBId || partyAId === partyBId) {
73
+ throw new Error('Virtual channel participants must be two distinct party ids');
74
+ }
70
75
  const amountA = amounts[partyAId] ?? 0n;
71
76
  const amountB = amounts[partyBId] ?? 0n;
72
77
  if (amountA < 0n || amountB < 0n)
@@ -37,6 +37,14 @@ export function createDurableFactoryStore(adapter, options = {}) {
37
37
  return {
38
38
  async saveFactory(factory) {
39
39
  await mutate((state) => {
40
+ const existing = state.factories[factory.factoryId];
41
+ // OMN-115: factory state is ordered by `currentSequence`. A delayed
42
+ // writer holding an older record must not roll the factory back, even
43
+ // though the snapshot CAS accepts the write itself.
44
+ if (existing && factory.currentSequence < existing.currentSequence) {
45
+ throw new StorageError(`refusing to overwrite factory ${factory.factoryId} sequence ${existing.currentSequence} `
46
+ + `with stale sequence ${factory.currentSequence}`, 'write-failed', { key: factory.factoryId });
47
+ }
40
48
  const factories = { ...state.factories, [factory.factoryId]: factory };
41
49
  return { ...state, factories };
42
50
  });
package/dist/virtual.js CHANGED
@@ -56,6 +56,11 @@ export function buildVirtualChannelOpen(factory, parties, amounts, channelId) {
56
56
  + 'Create the factory with { enforceCheckpoints: false } only for a factory that will not rely on unilateral exits.');
57
57
  }
58
58
  const [partyAId, partyBId] = parties;
59
+ // OMN-127: identical participants would make both allocation deductions write
60
+ // the same key, silently overwriting one side.
61
+ if (!partyAId || !partyBId || partyAId === partyBId) {
62
+ throw new Error('Virtual channel participants must be two distinct party ids');
63
+ }
59
64
  const amountA = amounts[partyAId] ?? 0n;
60
65
  const amountB = amounts[partyBId] ?? 0n;
61
66
  if (amountA < 0n || amountB < 0n)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-factory",
3
- "version": "0.9.0",
3
+ "version": "0.10.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",
29
- "@totemsdk/omnia": "^4.0.0",
30
- "@totemsdk/wots-lease": "^1.0.3",
28
+ "@totemsdk/core": "^1.7.0",
29
+ "@totemsdk/omnia": "^5.0.0",
31
30
  "@totemsdk/tx-builder": "^0.4.0",
32
- "@totemsdk/txpow": "^1.1.1",
33
- "@totemsdk/chain-provider": "^0.5.0",
34
- "@totemsdk/storage": "^0.2.3"
31
+ "@totemsdk/wots-lease": "^1.1.0",
32
+ "@totemsdk/txpow": "^1.2.0",
33
+ "@totemsdk/chain-provider": "^0.6.0",
34
+ "@totemsdk/storage": "^0.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.0.0",