@totemsdk/omnia-factory 0.3.0 → 0.4.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.
@@ -140,7 +140,9 @@ async function createFactory(participants, tokenId, bundle, chainProvider, token
140
140
  let pendingCommitment;
141
141
  const allHaveCoinId = participants.every(p => p.fundingCoinId);
142
142
  if (allHaveCoinId && chainProvider) {
143
- const fundingDraft = (0, omnia_1.buildFundingTx)(script, address, totalValue, tokenId, tokenScale, participants.map(p => p.fundingCoinId), participants.map(p => p.contributionAmount), participants.map(p => p.settlementAddress ?? p.publicKeyDigest), (0, script_js_1.factoryBalanceStateVariables)(participants));
143
+ const tip = await chainProvider.getTip();
144
+ const escapeBlock = tip.block + script_js_1.FACTORY_ESCAPE_DELAY_BLOCKS;
145
+ const fundingDraft = (0, omnia_1.buildFundingTx)(script, address, totalValue, tokenId, tokenScale, participants.map(p => p.fundingCoinId), participants.map(p => p.contributionAmount), participants.map(p => p.settlementAddress ?? p.publicKeyDigest), [...(0, script_js_1.factoryBalanceStateVariables)(participants), (0, script_js_1.factoryEscapeStateVariable)(escapeBlock)]);
144
146
  // All parties co-sign the TX digest — the exact on-chain TX structure.
145
147
  pendingCommitment = (0, omnia_1.computeTxDraftDigest)(fundingDraft);
146
148
  const draftBytes = (0, omnia_1.omniaDraftToMinimaBytes)(fundingDraft);
@@ -1,5 +1,5 @@
1
1
  export type { FactoryStatus, FactoryParticipant, FactorySignature, FactoryLogEntry, ChannelFactory, FactorySettlementPayload, FactoryDisputePayload, FactoryLeaseOps, WotsLeaseBundle, OmniaChannel, } from './types.js';
2
- export { buildFactoryScript, buildAndHashFactoryScript, factoryBalanceStateVariables, scriptAddress, normalizeScript, } from './script.js';
2
+ export { buildFactoryScript, buildAndHashFactoryScript, factoryBalanceStateVariables, factoryEscapeStateVariable, scriptAddress, normalizeScript, } from './script.js';
3
3
  export { computeFactoryStateCommitment } from './commitment.js';
4
4
  export { createFactory, acceptFactory, reallocate, enforceConservation, signFactoryOpening, verifyFactorySignature, applyFactorySignature, } from './factory.js';
5
5
  export type { FactoryOpeningSignature } from './factory.js';
package/dist/cjs/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDurableFactoryStore = exports.assembleFactorySettlement = exports.verifyFactorySettlementSignature = exports.signFactorySettlement = exports.buildFactorySettlement = exports.buildDisputePayload = exports.closeFactory = exports.assembleVirtualChannelOpen = exports.verifyVirtualChannelOpenSignature = exports.signVirtualChannelOpen = exports.buildVirtualChannelOpen = exports.closeVirtualChannel = exports.openVirtualChannel = exports.createFactoryCoordination = exports.applyFactorySignature = exports.verifyFactorySignature = exports.signFactoryOpening = exports.enforceConservation = exports.reallocate = exports.acceptFactory = exports.createFactory = exports.computeFactoryStateCommitment = exports.normalizeScript = exports.scriptAddress = exports.factoryBalanceStateVariables = exports.buildAndHashFactoryScript = exports.buildFactoryScript = void 0;
3
+ exports.createDurableFactoryStore = exports.assembleFactorySettlement = exports.verifyFactorySettlementSignature = exports.signFactorySettlement = exports.buildFactorySettlement = exports.buildDisputePayload = exports.closeFactory = exports.assembleVirtualChannelOpen = exports.verifyVirtualChannelOpenSignature = exports.signVirtualChannelOpen = exports.buildVirtualChannelOpen = exports.closeVirtualChannel = exports.openVirtualChannel = exports.createFactoryCoordination = exports.applyFactorySignature = exports.verifyFactorySignature = exports.signFactoryOpening = exports.enforceConservation = exports.reallocate = exports.acceptFactory = exports.createFactory = exports.computeFactoryStateCommitment = exports.normalizeScript = exports.scriptAddress = exports.factoryEscapeStateVariable = exports.factoryBalanceStateVariables = exports.buildAndHashFactoryScript = exports.buildFactoryScript = void 0;
4
4
  var script_js_1 = require("./script.js");
5
5
  Object.defineProperty(exports, "buildFactoryScript", { enumerable: true, get: function () { return script_js_1.buildFactoryScript; } });
6
6
  Object.defineProperty(exports, "buildAndHashFactoryScript", { enumerable: true, get: function () { return script_js_1.buildAndHashFactoryScript; } });
7
7
  Object.defineProperty(exports, "factoryBalanceStateVariables", { enumerable: true, get: function () { return script_js_1.factoryBalanceStateVariables; } });
8
+ Object.defineProperty(exports, "factoryEscapeStateVariable", { enumerable: true, get: function () { return script_js_1.factoryEscapeStateVariable; } });
8
9
  Object.defineProperty(exports, "scriptAddress", { enumerable: true, get: function () { return script_js_1.scriptAddress; } });
9
10
  Object.defineProperty(exports, "normalizeScript", { enumerable: true, get: function () { return script_js_1.normalizeScript; } });
10
11
  var commitment_js_1 = require("./commitment.js");
@@ -1,11 +1,13 @@
1
1
  import type { FactoryParticipant } from './types.js';
2
- /** Default coinage (blocks) after which any party may unilaterally withdraw. */
3
- export declare const FACTORY_TIMEOUT_BLOCKS = 256;
2
+ /** Blocks after the funding tip at which the unilateral escape opens. */
3
+ export declare const FACTORY_ESCAPE_DELAY_BLOCKS = 256;
4
+ /** State port carrying the absolute escape block (STATE(103)). */
5
+ export declare const FACTORY_ESCAPE_PORT = 103;
4
6
  /** State port base for per-party allocations: party k ⇒ port 200+k. */
5
7
  export declare const FACTORY_BALANCE_PORT_BASE = 200;
6
8
  export interface FactoryScriptOptions {
7
- /** Coinage threshold for the unilateral per-party escape (default 256). */
8
- timeoutBlocks?: number;
9
+ /** Reserved for callers; the escape block is carried in STATE(103) at funding. */
10
+ escapeBlock?: number;
9
11
  }
10
12
  /**
11
13
  * Per-party allocation state variables (port 200+k = party k's balance), seeded
@@ -17,23 +19,30 @@ export declare function factoryBalanceStateVariables(participants: FactoryPartic
17
19
  value: bigint;
18
20
  type: 'number';
19
21
  }[];
22
+ /** Absolute escape-block state variable (STATE(103)) for the factory funding output. */
23
+ export declare function factoryEscapeStateVariable(escapeBlock: number): {
24
+ port: number;
25
+ value: bigint;
26
+ type: 'number';
27
+ };
20
28
  /**
21
29
  * Build the N-of-N MULTISIG MAST funding script for a channel factory
22
- * (RFC-044, CUSTODY-POLICY §2).
30
+ * (RFC-039, CUSTODY-POLICY §2).
23
31
  *
24
32
  * Spend paths:
25
33
  * - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
26
34
  * `SETTLEMENT=true` closes after minimal coinage (1 block).
27
- * - **Unilateral escape** (after `@COINAGE GTE timeoutBlocks`): any single
28
- * party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its own
29
- * settlement address, zero its state (`STATE(200+k) EQ 0`), keep the other
30
- * parties' balances unchanged, and return the remainder to the factory
35
+ * - **Unilateral escape** (after the absolute block in `STATE(103)`): any
36
+ * single party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its
37
+ * own settlement address, zero its state (`STATE(200+k) EQ 0`), keep the
38
+ * other parties' balances unchanged, and return the remainder to the factory
31
39
  * script. Repeated withdrawals cannot double-claim because each zeroes its
32
- * own port.
40
+ * own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
41
+ * so the escape clock cannot be pushed by any counterparty.
33
42
  *
34
43
  * Minimum 2 participants required.
35
44
  */
36
- export declare function buildFactoryScript(participants: FactoryParticipant[], options?: FactoryScriptOptions): string;
45
+ export declare function buildFactoryScript(participants: FactoryParticipant[], _options?: FactoryScriptOptions): string;
37
46
  export declare function normalizeScript(script: string): string;
38
47
  /** Compute the SHA3-256 script-hash address for a factory script. */
39
48
  export declare function scriptAddress(script: string): string;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FACTORY_BALANCE_PORT_BASE = exports.FACTORY_TIMEOUT_BLOCKS = void 0;
3
+ exports.FACTORY_BALANCE_PORT_BASE = exports.FACTORY_ESCAPE_PORT = exports.FACTORY_ESCAPE_DELAY_BLOCKS = void 0;
4
4
  exports.factoryBalanceStateVariables = factoryBalanceStateVariables;
5
+ exports.factoryEscapeStateVariable = factoryEscapeStateVariable;
5
6
  exports.buildFactoryScript = buildFactoryScript;
6
7
  exports.normalizeScript = normalizeScript;
7
8
  exports.scriptAddress = scriptAddress;
@@ -15,8 +16,10 @@ function kissHex(hex) {
15
16
  const raw = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
16
17
  return '0X' + raw.toUpperCase();
17
18
  }
18
- /** Default coinage (blocks) after which any party may unilaterally withdraw. */
19
- exports.FACTORY_TIMEOUT_BLOCKS = 256;
19
+ /** Blocks after the funding tip at which the unilateral escape opens. */
20
+ exports.FACTORY_ESCAPE_DELAY_BLOCKS = 256;
21
+ /** State port carrying the absolute escape block (STATE(103)). */
22
+ exports.FACTORY_ESCAPE_PORT = 103;
20
23
  /** State port base for per-party allocations: party k ⇒ port 200+k. */
21
24
  exports.FACTORY_BALANCE_PORT_BASE = 200;
22
25
  /**
@@ -31,36 +34,41 @@ function factoryBalanceStateVariables(participants) {
31
34
  type: 'number',
32
35
  }));
33
36
  }
37
+ /** Absolute escape-block state variable (STATE(103)) for the factory funding output. */
38
+ function factoryEscapeStateVariable(escapeBlock) {
39
+ if (!Number.isInteger(escapeBlock) || escapeBlock < 0) {
40
+ throw new Error(`escapeBlock must be a non-negative integer, got ${JSON.stringify(escapeBlock)}`);
41
+ }
42
+ return { port: exports.FACTORY_ESCAPE_PORT, value: BigInt(escapeBlock), type: 'number' };
43
+ }
34
44
  /**
35
45
  * Build the N-of-N MULTISIG MAST funding script for a channel factory
36
- * (RFC-044, CUSTODY-POLICY §2).
46
+ * (RFC-039, CUSTODY-POLICY §2).
37
47
  *
38
48
  * Spend paths:
39
49
  * - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
40
50
  * `SETTLEMENT=true` closes after minimal coinage (1 block).
41
- * - **Unilateral escape** (after `@COINAGE GTE timeoutBlocks`): any single
42
- * party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its own
43
- * settlement address, zero its state (`STATE(200+k) EQ 0`), keep the other
44
- * parties' balances unchanged, and return the remainder to the factory
51
+ * - **Unilateral escape** (after the absolute block in `STATE(103)`): any
52
+ * single party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its
53
+ * own settlement address, zero its state (`STATE(200+k) EQ 0`), keep the
54
+ * other parties' balances unchanged, and return the remainder to the factory
45
55
  * script. Repeated withdrawals cannot double-claim because each zeroes its
46
- * own port.
56
+ * own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
57
+ * so the escape clock cannot be pushed by any counterparty.
47
58
  *
48
59
  * Minimum 2 participants required.
49
60
  */
50
- function buildFactoryScript(participants, options = {}) {
61
+ function buildFactoryScript(participants, _options = {}) {
51
62
  if (participants.length < 2) {
52
63
  throw new Error(`Factory requires at least 2 participants, got ${participants.length}`);
53
64
  }
54
65
  const count = participants.length;
55
- const timeout = options.timeoutBlocks ?? exports.FACTORY_TIMEOUT_BLOCKS;
56
- if (!Number.isInteger(timeout) || timeout < 0) {
57
- throw new Error(`timeoutBlocks must be a non-negative integer, got ${JSON.stringify(timeout)}`);
58
- }
59
66
  const pks = participants.map((p) => kissHex(p.publicKeyDigest));
60
67
  const payouts = participants.map((p) => kissHex(p.settlementAddress ?? p.publicKeyDigest));
61
68
  const lines = [
62
69
  'LET SETTLEMENT=STATE(100)',
63
- `IF @COINAGE GTE ${timeout} THEN`,
70
+ `ASSERT SAMESTATE(${exports.FACTORY_ESCAPE_PORT} ${exports.FACTORY_ESCAPE_PORT})`,
71
+ `IF @BLOCK GT STATE(${exports.FACTORY_ESCAPE_PORT}) THEN`,
64
72
  ];
65
73
  participants.forEach((_, k) => {
66
74
  const port = exports.FACTORY_BALANCE_PORT_BASE + k;
package/dist/factory.js CHANGED
@@ -2,7 +2,7 @@ import { sha3_256 } from '@totemsdk/core/wasm';
2
2
  import { concatBytes } from '@totemsdk/core/wasm';
3
3
  import { buildFundingTx, omniaDraftToMinimaBytes, computeTxDraftDigest, verifyChannelSignature, } from '@totemsdk/omnia';
4
4
  import { mineTxPoW, TX_POW_MIN_DIFFICULTY, serializeTxBody } from '@totemsdk/txpow';
5
- import { buildAndHashFactoryScript, factoryBalanceStateVariables } from './script.js';
5
+ import { buildAndHashFactoryScript, factoryBalanceStateVariables, factoryEscapeStateVariable, FACTORY_ESCAPE_DELAY_BLOCKS } from './script.js';
6
6
  import { computeFactoryStateCommitment } from './commitment.js';
7
7
  // ─── Balance conservation ────────────────────────────────────────────────────
8
8
  /**
@@ -131,7 +131,9 @@ export async function createFactory(participants, tokenId, bundle, chainProvider
131
131
  let pendingCommitment;
132
132
  const allHaveCoinId = participants.every(p => p.fundingCoinId);
133
133
  if (allHaveCoinId && chainProvider) {
134
- const fundingDraft = buildFundingTx(script, address, totalValue, tokenId, tokenScale, participants.map(p => p.fundingCoinId), participants.map(p => p.contributionAmount), participants.map(p => p.settlementAddress ?? p.publicKeyDigest), factoryBalanceStateVariables(participants));
134
+ const tip = await chainProvider.getTip();
135
+ const escapeBlock = tip.block + FACTORY_ESCAPE_DELAY_BLOCKS;
136
+ const fundingDraft = buildFundingTx(script, address, totalValue, tokenId, tokenScale, participants.map(p => p.fundingCoinId), participants.map(p => p.contributionAmount), participants.map(p => p.settlementAddress ?? p.publicKeyDigest), [...factoryBalanceStateVariables(participants), factoryEscapeStateVariable(escapeBlock)]);
135
137
  // All parties co-sign the TX digest — the exact on-chain TX structure.
136
138
  pendingCommitment = computeTxDraftDigest(fundingDraft);
137
139
  const draftBytes = omniaDraftToMinimaBytes(fundingDraft);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { FactoryStatus, FactoryParticipant, FactorySignature, FactoryLogEntry, ChannelFactory, FactorySettlementPayload, FactoryDisputePayload, FactoryLeaseOps, WotsLeaseBundle, OmniaChannel, } from './types.js';
2
- export { buildFactoryScript, buildAndHashFactoryScript, factoryBalanceStateVariables, scriptAddress, normalizeScript, } from './script.js';
2
+ export { buildFactoryScript, buildAndHashFactoryScript, factoryBalanceStateVariables, factoryEscapeStateVariable, scriptAddress, normalizeScript, } from './script.js';
3
3
  export { computeFactoryStateCommitment } from './commitment.js';
4
4
  export { createFactory, acceptFactory, reallocate, enforceConservation, signFactoryOpening, verifyFactorySignature, applyFactorySignature, } from './factory.js';
5
5
  export type { FactoryOpeningSignature } from './factory.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { buildFactoryScript, buildAndHashFactoryScript, factoryBalanceStateVariables, scriptAddress, normalizeScript, } from './script.js';
1
+ export { buildFactoryScript, buildAndHashFactoryScript, factoryBalanceStateVariables, factoryEscapeStateVariable, scriptAddress, normalizeScript, } from './script.js';
2
2
  export { computeFactoryStateCommitment } from './commitment.js';
3
3
  export { createFactory, acceptFactory, reallocate, enforceConservation, signFactoryOpening, verifyFactorySignature, applyFactorySignature, } from './factory.js';
4
4
  // RFC-035 B2 — factory opening round-trip over the coordination transport.
package/dist/script.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import type { FactoryParticipant } from './types.js';
2
- /** Default coinage (blocks) after which any party may unilaterally withdraw. */
3
- export declare const FACTORY_TIMEOUT_BLOCKS = 256;
2
+ /** Blocks after the funding tip at which the unilateral escape opens. */
3
+ export declare const FACTORY_ESCAPE_DELAY_BLOCKS = 256;
4
+ /** State port carrying the absolute escape block (STATE(103)). */
5
+ export declare const FACTORY_ESCAPE_PORT = 103;
4
6
  /** State port base for per-party allocations: party k ⇒ port 200+k. */
5
7
  export declare const FACTORY_BALANCE_PORT_BASE = 200;
6
8
  export interface FactoryScriptOptions {
7
- /** Coinage threshold for the unilateral per-party escape (default 256). */
8
- timeoutBlocks?: number;
9
+ /** Reserved for callers; the escape block is carried in STATE(103) at funding. */
10
+ escapeBlock?: number;
9
11
  }
10
12
  /**
11
13
  * Per-party allocation state variables (port 200+k = party k's balance), seeded
@@ -17,23 +19,30 @@ export declare function factoryBalanceStateVariables(participants: FactoryPartic
17
19
  value: bigint;
18
20
  type: 'number';
19
21
  }[];
22
+ /** Absolute escape-block state variable (STATE(103)) for the factory funding output. */
23
+ export declare function factoryEscapeStateVariable(escapeBlock: number): {
24
+ port: number;
25
+ value: bigint;
26
+ type: 'number';
27
+ };
20
28
  /**
21
29
  * Build the N-of-N MULTISIG MAST funding script for a channel factory
22
- * (RFC-044, CUSTODY-POLICY §2).
30
+ * (RFC-039, CUSTODY-POLICY §2).
23
31
  *
24
32
  * Spend paths:
25
33
  * - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
26
34
  * `SETTLEMENT=true` closes after minimal coinage (1 block).
27
- * - **Unilateral escape** (after `@COINAGE GTE timeoutBlocks`): any single
28
- * party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its own
29
- * settlement address, zero its state (`STATE(200+k) EQ 0`), keep the other
30
- * parties' balances unchanged, and return the remainder to the factory
35
+ * - **Unilateral escape** (after the absolute block in `STATE(103)`): any
36
+ * single party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its
37
+ * own settlement address, zero its state (`STATE(200+k) EQ 0`), keep the
38
+ * other parties' balances unchanged, and return the remainder to the factory
31
39
  * script. Repeated withdrawals cannot double-claim because each zeroes its
32
- * own port.
40
+ * own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
41
+ * so the escape clock cannot be pushed by any counterparty.
33
42
  *
34
43
  * Minimum 2 participants required.
35
44
  */
36
- export declare function buildFactoryScript(participants: FactoryParticipant[], options?: FactoryScriptOptions): string;
45
+ export declare function buildFactoryScript(participants: FactoryParticipant[], _options?: FactoryScriptOptions): string;
37
46
  export declare function normalizeScript(script: string): string;
38
47
  /** Compute the SHA3-256 script-hash address for a factory script. */
39
48
  export declare function scriptAddress(script: string): string;
package/dist/script.js CHANGED
@@ -7,8 +7,10 @@ function kissHex(hex) {
7
7
  const raw = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
8
8
  return '0X' + raw.toUpperCase();
9
9
  }
10
- /** Default coinage (blocks) after which any party may unilaterally withdraw. */
11
- export const FACTORY_TIMEOUT_BLOCKS = 256;
10
+ /** Blocks after the funding tip at which the unilateral escape opens. */
11
+ export const FACTORY_ESCAPE_DELAY_BLOCKS = 256;
12
+ /** State port carrying the absolute escape block (STATE(103)). */
13
+ export const FACTORY_ESCAPE_PORT = 103;
12
14
  /** State port base for per-party allocations: party k ⇒ port 200+k. */
13
15
  export const FACTORY_BALANCE_PORT_BASE = 200;
14
16
  /**
@@ -23,36 +25,41 @@ export function factoryBalanceStateVariables(participants) {
23
25
  type: 'number',
24
26
  }));
25
27
  }
28
+ /** Absolute escape-block state variable (STATE(103)) for the factory funding output. */
29
+ export function factoryEscapeStateVariable(escapeBlock) {
30
+ if (!Number.isInteger(escapeBlock) || escapeBlock < 0) {
31
+ throw new Error(`escapeBlock must be a non-negative integer, got ${JSON.stringify(escapeBlock)}`);
32
+ }
33
+ return { port: FACTORY_ESCAPE_PORT, value: BigInt(escapeBlock), type: 'number' };
34
+ }
26
35
  /**
27
36
  * Build the N-of-N MULTISIG MAST funding script for a channel factory
28
- * (RFC-044, CUSTODY-POLICY §2).
37
+ * (RFC-039, CUSTODY-POLICY §2).
29
38
  *
30
39
  * Spend paths:
31
40
  * - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
32
41
  * `SETTLEMENT=true` closes after minimal coinage (1 block).
33
- * - **Unilateral escape** (after `@COINAGE GTE timeoutBlocks`): any single
34
- * party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its own
35
- * settlement address, zero its state (`STATE(200+k) EQ 0`), keep the other
36
- * parties' balances unchanged, and return the remainder to the factory
42
+ * - **Unilateral escape** (after the absolute block in `STATE(103)`): any
43
+ * single party k may withdraw its allocation `SHARE_k = STATE(200+k)` to its
44
+ * own settlement address, zero its state (`STATE(200+k) EQ 0`), keep the
45
+ * other parties' balances unchanged, and return the remainder to the factory
37
46
  * script. Repeated withdrawals cannot double-claim because each zeroes its
38
- * own port.
47
+ * own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
48
+ * so the escape clock cannot be pushed by any counterparty.
39
49
  *
40
50
  * Minimum 2 participants required.
41
51
  */
42
- export function buildFactoryScript(participants, options = {}) {
52
+ export function buildFactoryScript(participants, _options = {}) {
43
53
  if (participants.length < 2) {
44
54
  throw new Error(`Factory requires at least 2 participants, got ${participants.length}`);
45
55
  }
46
56
  const count = participants.length;
47
- const timeout = options.timeoutBlocks ?? FACTORY_TIMEOUT_BLOCKS;
48
- if (!Number.isInteger(timeout) || timeout < 0) {
49
- throw new Error(`timeoutBlocks must be a non-negative integer, got ${JSON.stringify(timeout)}`);
50
- }
51
57
  const pks = participants.map((p) => kissHex(p.publicKeyDigest));
52
58
  const payouts = participants.map((p) => kissHex(p.settlementAddress ?? p.publicKeyDigest));
53
59
  const lines = [
54
60
  'LET SETTLEMENT=STATE(100)',
55
- `IF @COINAGE GTE ${timeout} THEN`,
61
+ `ASSERT SAMESTATE(${FACTORY_ESCAPE_PORT} ${FACTORY_ESCAPE_PORT})`,
62
+ `IF @BLOCK GT STATE(${FACTORY_ESCAPE_PORT}) THEN`,
56
63
  ];
57
64
  participants.forEach((_, k) => {
58
65
  const port = FACTORY_BALANCE_PORT_BASE + k;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-factory",
3
- "version": "0.3.0",
3
+ "version": "0.4.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",
@@ -24,12 +24,12 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
+ "@totemsdk/omnia": "^2.0.1",
27
28
  "@totemsdk/core": "^1.2.11",
28
29
  "@totemsdk/wots-lease": "^1.0.1",
29
- "@totemsdk/txpow": "^1.0.2",
30
30
  "@totemsdk/tx-builder": "^0.2.1",
31
+ "@totemsdk/txpow": "^1.0.2",
31
32
  "@totemsdk/chain-provider": "^0.2.1",
32
- "@totemsdk/omnia": "^2.0.0",
33
33
  "@totemsdk/storage": "^0.1.0"
34
34
  },
35
35
  "devDependencies": {