@totemsdk/omnia-factory 0.8.0 → 0.9.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/cjs/factory.js +9 -0
- package/dist/cjs/script.d.ts +14 -2
- package/dist/cjs/types.d.ts +18 -0
- package/dist/factory.js +9 -0
- package/dist/script.d.ts +14 -2
- package/dist/types.d.ts +18 -0
- package/package.json +5 -5
package/dist/cjs/factory.js
CHANGED
|
@@ -205,6 +205,14 @@ scriptOptions = { settlement: 'full-distribution', enforceCheckpoints: true }) {
|
|
|
205
205
|
if (participants.length < 2) {
|
|
206
206
|
throw new Error(`Factory requires at least 2 participants, got ${participants.length}`);
|
|
207
207
|
}
|
|
208
|
+
// OMN-095: without checkpoint enforcement a unilateral exit pays the funding
|
|
209
|
+
// split, so the latest off-chain allocation is unenforceable. Refuse to build
|
|
210
|
+
// that silently; it is allowed only as an explicit, acknowledged mode.
|
|
211
|
+
if (scriptOptions.enforceCheckpoints !== true && scriptOptions.allowUnenforceableAllocations !== true) {
|
|
212
|
+
throw new Error('refusing to build a factory whose allocations are not checkpoint-enforced: '
|
|
213
|
+
+ 'a unilateral exit would pay the funding split, not the latest allocation. '
|
|
214
|
+
+ 'Pass { allowUnenforceableAllocations: true } only for a factory that will never rely on unilateral exits.');
|
|
215
|
+
}
|
|
208
216
|
const totalValue = participants.reduce((sum, p) => sum + p.contributionAmount, 0n);
|
|
209
217
|
const allocations = {};
|
|
210
218
|
for (const p of participants)
|
|
@@ -273,6 +281,7 @@ scriptOptions = { settlement: 'full-distribution', enforceCheckpoints: true }) {
|
|
|
273
281
|
pendingCommitment: Buffer.from(pendingCommitment).toString('hex'),
|
|
274
282
|
pendingSignatures: {},
|
|
275
283
|
enforceCheckpoints: scriptOptions.enforceCheckpoints === true,
|
|
284
|
+
allocationEnforcement: scriptOptions.enforceCheckpoints === true ? 'checkpoint' : 'none',
|
|
276
285
|
};
|
|
277
286
|
return {
|
|
278
287
|
factory,
|
package/dist/cjs/script.d.ts
CHANGED
|
@@ -137,10 +137,22 @@ export interface FactoryScriptOptions {
|
|
|
137
137
|
* Every allocation change then has an on-chain artifact, and the unilateral
|
|
138
138
|
* escape pays the latest checkpoint instead of the original funding split.
|
|
139
139
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
140
|
+
* The factory builders (`buildFactoryOpening`, `openFactory`) pass `true`;
|
|
141
|
+
* this option only defaults to off when the script is built directly.
|
|
142
|
+
*
|
|
143
|
+
* Setting it to `false` selects the legacy off-chain mode, where a unilateral
|
|
144
|
+
* exit pays the funding split and a newer allocation is **not** enforceable.
|
|
145
|
+
* OMN-095: that mode now requires `allowUnenforceableAllocations` so it is a
|
|
146
|
+
* deliberate release restriction rather than an accidental default.
|
|
142
147
|
*/
|
|
143
148
|
enforceCheckpoints?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* OMN-095: acknowledge that `enforceCheckpoints: false` produces a factory
|
|
151
|
+
* whose latest off-chain allocation cannot be enforced on chain. Required to
|
|
152
|
+
* build such a factory; the resulting `ChannelFactory.allocationEnforcement`
|
|
153
|
+
* is `'none'`.
|
|
154
|
+
*/
|
|
155
|
+
allowUnenforceableAllocations?: boolean;
|
|
144
156
|
/**
|
|
145
157
|
* OMN-058/RFC-079 §4A: add the output-enforced full-distribution branch.
|
|
146
158
|
* Any participant can settle every committed share in one transaction; the
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -92,6 +92,13 @@ export interface FactoryLogEntry {
|
|
|
92
92
|
allocations: Record<string, bigint>;
|
|
93
93
|
virtualChannelIds: string[];
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* OMN-095: the two production capability levels of a factory.
|
|
97
|
+
*
|
|
98
|
+
* `checkpoint` is the only mode that can back a unilateral exit. `none` is a
|
|
99
|
+
* release restriction, not an equivalent alternative.
|
|
100
|
+
*/
|
|
101
|
+
export type FactoryAllocationEnforcement = 'checkpoint' | 'none';
|
|
95
102
|
export interface ChannelFactory {
|
|
96
103
|
factoryId: string;
|
|
97
104
|
participants: FactoryParticipant[];
|
|
@@ -117,6 +124,17 @@ export interface ChannelFactory {
|
|
|
117
124
|
* unilateral escape can never pay a stale split.
|
|
118
125
|
*/
|
|
119
126
|
enforceCheckpoints?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* OMN-095: what a participant's latest allocation is enforceable to.
|
|
129
|
+
*
|
|
130
|
+
* - `checkpoint` — the covenant only accepts a same-script, same-value
|
|
131
|
+
* successor whose sequence advanced by one, so a unilateral exit pays the
|
|
132
|
+
* latest **confirmed** allocation.
|
|
133
|
+
* - `none` — the legacy off-chain mode. The timeout escape pays the original
|
|
134
|
+
* funding split, so a newer off-chain allocation is *not* unilaterally
|
|
135
|
+
* enforceable. Creating this mode requires an explicit opt-in.
|
|
136
|
+
*/
|
|
137
|
+
allocationEnforcement?: FactoryAllocationEnforcement;
|
|
120
138
|
/** Monotonically increasing. Incremented on every committed state transition. */
|
|
121
139
|
currentSequence: number;
|
|
122
140
|
status: FactoryStatus;
|
package/dist/factory.js
CHANGED
|
@@ -191,6 +191,14 @@ scriptOptions = { settlement: 'full-distribution', enforceCheckpoints: true }) {
|
|
|
191
191
|
if (participants.length < 2) {
|
|
192
192
|
throw new Error(`Factory requires at least 2 participants, got ${participants.length}`);
|
|
193
193
|
}
|
|
194
|
+
// OMN-095: without checkpoint enforcement a unilateral exit pays the funding
|
|
195
|
+
// split, so the latest off-chain allocation is unenforceable. Refuse to build
|
|
196
|
+
// that silently; it is allowed only as an explicit, acknowledged mode.
|
|
197
|
+
if (scriptOptions.enforceCheckpoints !== true && scriptOptions.allowUnenforceableAllocations !== true) {
|
|
198
|
+
throw new Error('refusing to build a factory whose allocations are not checkpoint-enforced: '
|
|
199
|
+
+ 'a unilateral exit would pay the funding split, not the latest allocation. '
|
|
200
|
+
+ 'Pass { allowUnenforceableAllocations: true } only for a factory that will never rely on unilateral exits.');
|
|
201
|
+
}
|
|
194
202
|
const totalValue = participants.reduce((sum, p) => sum + p.contributionAmount, 0n);
|
|
195
203
|
const allocations = {};
|
|
196
204
|
for (const p of participants)
|
|
@@ -259,6 +267,7 @@ scriptOptions = { settlement: 'full-distribution', enforceCheckpoints: true }) {
|
|
|
259
267
|
pendingCommitment: Buffer.from(pendingCommitment).toString('hex'),
|
|
260
268
|
pendingSignatures: {},
|
|
261
269
|
enforceCheckpoints: scriptOptions.enforceCheckpoints === true,
|
|
270
|
+
allocationEnforcement: scriptOptions.enforceCheckpoints === true ? 'checkpoint' : 'none',
|
|
262
271
|
};
|
|
263
272
|
return {
|
|
264
273
|
factory,
|
package/dist/script.d.ts
CHANGED
|
@@ -137,10 +137,22 @@ export interface FactoryScriptOptions {
|
|
|
137
137
|
* Every allocation change then has an on-chain artifact, and the unilateral
|
|
138
138
|
* escape pays the latest checkpoint instead of the original funding split.
|
|
139
139
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
140
|
+
* The factory builders (`buildFactoryOpening`, `openFactory`) pass `true`;
|
|
141
|
+
* this option only defaults to off when the script is built directly.
|
|
142
|
+
*
|
|
143
|
+
* Setting it to `false` selects the legacy off-chain mode, where a unilateral
|
|
144
|
+
* exit pays the funding split and a newer allocation is **not** enforceable.
|
|
145
|
+
* OMN-095: that mode now requires `allowUnenforceableAllocations` so it is a
|
|
146
|
+
* deliberate release restriction rather than an accidental default.
|
|
142
147
|
*/
|
|
143
148
|
enforceCheckpoints?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* OMN-095: acknowledge that `enforceCheckpoints: false` produces a factory
|
|
151
|
+
* whose latest off-chain allocation cannot be enforced on chain. Required to
|
|
152
|
+
* build such a factory; the resulting `ChannelFactory.allocationEnforcement`
|
|
153
|
+
* is `'none'`.
|
|
154
|
+
*/
|
|
155
|
+
allowUnenforceableAllocations?: boolean;
|
|
144
156
|
/**
|
|
145
157
|
* OMN-058/RFC-079 §4A: add the output-enforced full-distribution branch.
|
|
146
158
|
* Any participant can settle every committed share in one transaction; the
|
package/dist/types.d.ts
CHANGED
|
@@ -92,6 +92,13 @@ export interface FactoryLogEntry {
|
|
|
92
92
|
allocations: Record<string, bigint>;
|
|
93
93
|
virtualChannelIds: string[];
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* OMN-095: the two production capability levels of a factory.
|
|
97
|
+
*
|
|
98
|
+
* `checkpoint` is the only mode that can back a unilateral exit. `none` is a
|
|
99
|
+
* release restriction, not an equivalent alternative.
|
|
100
|
+
*/
|
|
101
|
+
export type FactoryAllocationEnforcement = 'checkpoint' | 'none';
|
|
95
102
|
export interface ChannelFactory {
|
|
96
103
|
factoryId: string;
|
|
97
104
|
participants: FactoryParticipant[];
|
|
@@ -117,6 +124,17 @@ export interface ChannelFactory {
|
|
|
117
124
|
* unilateral escape can never pay a stale split.
|
|
118
125
|
*/
|
|
119
126
|
enforceCheckpoints?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* OMN-095: what a participant's latest allocation is enforceable to.
|
|
129
|
+
*
|
|
130
|
+
* - `checkpoint` — the covenant only accepts a same-script, same-value
|
|
131
|
+
* successor whose sequence advanced by one, so a unilateral exit pays the
|
|
132
|
+
* latest **confirmed** allocation.
|
|
133
|
+
* - `none` — the legacy off-chain mode. The timeout escape pays the original
|
|
134
|
+
* funding split, so a newer off-chain allocation is *not* unilaterally
|
|
135
|
+
* enforceable. Creating this mode requires an explicit opt-in.
|
|
136
|
+
*/
|
|
137
|
+
allocationEnforcement?: FactoryAllocationEnforcement;
|
|
120
138
|
/** Monotonically increasing. Incremented on every committed state transition. */
|
|
121
139
|
currentSequence: number;
|
|
122
140
|
status: FactoryStatus;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-factory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@totemsdk/core": "^1.6.1",
|
|
29
|
+
"@totemsdk/omnia": "^4.0.0",
|
|
29
30
|
"@totemsdk/wots-lease": "^1.0.3",
|
|
30
|
-
"@totemsdk/
|
|
31
|
+
"@totemsdk/tx-builder": "^0.4.0",
|
|
31
32
|
"@totemsdk/txpow": "^1.1.1",
|
|
32
|
-
"@totemsdk/
|
|
33
|
-
"@totemsdk/
|
|
34
|
-
"@totemsdk/storage": "^0.2.2"
|
|
33
|
+
"@totemsdk/chain-provider": "^0.5.0",
|
|
34
|
+
"@totemsdk/storage": "^0.2.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^20.0.0",
|