@totemsdk/omnia-factory 0.4.0 → 0.5.1
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/script.d.ts +5 -5
- package/dist/cjs/script.js +14 -8
- package/dist/script.d.ts +5 -5
- package/dist/script.js +14 -8
- package/package.json +2 -2
package/dist/cjs/script.d.ts
CHANGED
|
@@ -33,11 +33,11 @@ export declare function factoryEscapeStateVariable(escapeBlock: number): {
|
|
|
33
33
|
* - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
|
|
34
34
|
* `SETTLEMENT=true` closes after minimal coinage (1 block).
|
|
35
35
|
* - **Unilateral escape** (after the absolute block in `STATE(103)`): any
|
|
36
|
-
* single party k may withdraw its allocation `SHARE_k =
|
|
37
|
-
* own settlement address, zero its state
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
36
|
+
* single party k may withdraw its allocation `SHARE_k = PREVSTATE(200+k)`
|
|
37
|
+
* (the spent coin's share) to its own settlement address, zero its state in
|
|
38
|
+
* the successor (`STATE(200+k) EQ 0`), keep the other parties' balances
|
|
39
|
+
* unchanged, and return the remainder to the factory script. Repeated
|
|
40
|
+
* withdrawals cannot double-claim because each zeroes its own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
41
41
|
* so the escape clock cannot be pushed by any counterparty.
|
|
42
42
|
*
|
|
43
43
|
* Minimum 2 participants required.
|
package/dist/cjs/script.js
CHANGED
|
@@ -49,11 +49,11 @@ function factoryEscapeStateVariable(escapeBlock) {
|
|
|
49
49
|
* - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
|
|
50
50
|
* `SETTLEMENT=true` closes after minimal coinage (1 block).
|
|
51
51
|
* - **Unilateral escape** (after the absolute block in `STATE(103)`): any
|
|
52
|
-
* single party k may withdraw its allocation `SHARE_k =
|
|
53
|
-
* own settlement address, zero its state
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
52
|
+
* single party k may withdraw its allocation `SHARE_k = PREVSTATE(200+k)`
|
|
53
|
+
* (the spent coin's share) to its own settlement address, zero its state in
|
|
54
|
+
* the successor (`STATE(200+k) EQ 0`), keep the other parties' balances
|
|
55
|
+
* unchanged, and return the remainder to the factory script. Repeated
|
|
56
|
+
* withdrawals cannot double-claim because each zeroes its own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
57
57
|
* so the escape clock cannot be pushed by any counterparty.
|
|
58
58
|
*
|
|
59
59
|
* Minimum 2 participants required.
|
|
@@ -68,11 +68,11 @@ function buildFactoryScript(participants, _options = {}) {
|
|
|
68
68
|
const lines = [
|
|
69
69
|
'LET SETTLEMENT=STATE(100)',
|
|
70
70
|
`ASSERT SAMESTATE(${exports.FACTORY_ESCAPE_PORT} ${exports.FACTORY_ESCAPE_PORT})`,
|
|
71
|
-
`IF @BLOCK GT
|
|
71
|
+
`IF @BLOCK GT PREVSTATE(${exports.FACTORY_ESCAPE_PORT}) THEN`,
|
|
72
72
|
];
|
|
73
73
|
participants.forEach((_, k) => {
|
|
74
74
|
const port = exports.FACTORY_BALANCE_PORT_BASE + k;
|
|
75
|
-
lines.push(` LET SHARE${k}=
|
|
75
|
+
lines.push(` LET SHARE${k}=PREVSTATE(${port})`);
|
|
76
76
|
lines.push(` IF SIGNEDBY(${pks[k]}) THEN`);
|
|
77
77
|
lines.push(` IF SHARE${k} GT 0 THEN`);
|
|
78
78
|
lines.push(` ASSERT VERIFYOUT(0 ${payouts[k]} SHARE${k} @TOKENID FALSE)`);
|
|
@@ -82,7 +82,13 @@ function buildFactoryScript(participants, _options = {}) {
|
|
|
82
82
|
lines.push(` ASSERT STATE(${exports.FACTORY_BALANCE_PORT_BASE + j}) EQ PREVSTATE(${exports.FACTORY_BALANCE_PORT_BASE + j})`);
|
|
83
83
|
}
|
|
84
84
|
lines.push(` ASSERT STATE(${port}) EQ 0`);
|
|
85
|
-
|
|
85
|
+
// Whole-share guard (mirrors the VTXO script): when the withdrawing party's
|
|
86
|
+
// share is the entire output there is no remainder, so a 0-amount output is
|
|
87
|
+
// never required.
|
|
88
|
+
lines.push(` IF @AMOUNT GT SHARE${k} THEN`);
|
|
89
|
+
lines.push(` RETURN VERIFYOUT(@INPUT @ADDRESS @AMOUNT SUB SHARE${k} @TOKENID TRUE)`);
|
|
90
|
+
lines.push(' ENDIF');
|
|
91
|
+
lines.push(' RETURN TRUE');
|
|
86
92
|
lines.push(' ENDIF');
|
|
87
93
|
lines.push(' ENDIF');
|
|
88
94
|
});
|
package/dist/script.d.ts
CHANGED
|
@@ -33,11 +33,11 @@ export declare function factoryEscapeStateVariable(escapeBlock: number): {
|
|
|
33
33
|
* - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
|
|
34
34
|
* `SETTLEMENT=true` closes after minimal coinage (1 block).
|
|
35
35
|
* - **Unilateral escape** (after the absolute block in `STATE(103)`): any
|
|
36
|
-
* single party k may withdraw its allocation `SHARE_k =
|
|
37
|
-
* own settlement address, zero its state
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
36
|
+
* single party k may withdraw its allocation `SHARE_k = PREVSTATE(200+k)`
|
|
37
|
+
* (the spent coin's share) to its own settlement address, zero its state in
|
|
38
|
+
* the successor (`STATE(200+k) EQ 0`), keep the other parties' balances
|
|
39
|
+
* unchanged, and return the remainder to the factory script. Repeated
|
|
40
|
+
* withdrawals cannot double-claim because each zeroes its own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
41
41
|
* so the escape clock cannot be pushed by any counterparty.
|
|
42
42
|
*
|
|
43
43
|
* Minimum 2 participants required.
|
package/dist/script.js
CHANGED
|
@@ -40,11 +40,11 @@ export function factoryEscapeStateVariable(escapeBlock) {
|
|
|
40
40
|
* - **Cooperative / update** (any time): `MULTISIG(N …)` — all parties sign.
|
|
41
41
|
* `SETTLEMENT=true` closes after minimal coinage (1 block).
|
|
42
42
|
* - **Unilateral escape** (after the absolute block in `STATE(103)`): any
|
|
43
|
-
* single party k may withdraw its allocation `SHARE_k =
|
|
44
|
-
* own settlement address, zero its state
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
43
|
+
* single party k may withdraw its allocation `SHARE_k = PREVSTATE(200+k)`
|
|
44
|
+
* (the spent coin's share) to its own settlement address, zero its state in
|
|
45
|
+
* the successor (`STATE(200+k) EQ 0`), keep the other parties' balances
|
|
46
|
+
* unchanged, and return the remainder to the factory script. Repeated
|
|
47
|
+
* withdrawals cannot double-claim because each zeroes its own port. `STATE(103)` is immutable on every spend (`SAMESTATE(103 103)`),
|
|
48
48
|
* so the escape clock cannot be pushed by any counterparty.
|
|
49
49
|
*
|
|
50
50
|
* Minimum 2 participants required.
|
|
@@ -59,11 +59,11 @@ export function buildFactoryScript(participants, _options = {}) {
|
|
|
59
59
|
const lines = [
|
|
60
60
|
'LET SETTLEMENT=STATE(100)',
|
|
61
61
|
`ASSERT SAMESTATE(${FACTORY_ESCAPE_PORT} ${FACTORY_ESCAPE_PORT})`,
|
|
62
|
-
`IF @BLOCK GT
|
|
62
|
+
`IF @BLOCK GT PREVSTATE(${FACTORY_ESCAPE_PORT}) THEN`,
|
|
63
63
|
];
|
|
64
64
|
participants.forEach((_, k) => {
|
|
65
65
|
const port = FACTORY_BALANCE_PORT_BASE + k;
|
|
66
|
-
lines.push(` LET SHARE${k}=
|
|
66
|
+
lines.push(` LET SHARE${k}=PREVSTATE(${port})`);
|
|
67
67
|
lines.push(` IF SIGNEDBY(${pks[k]}) THEN`);
|
|
68
68
|
lines.push(` IF SHARE${k} GT 0 THEN`);
|
|
69
69
|
lines.push(` ASSERT VERIFYOUT(0 ${payouts[k]} SHARE${k} @TOKENID FALSE)`);
|
|
@@ -73,7 +73,13 @@ export function buildFactoryScript(participants, _options = {}) {
|
|
|
73
73
|
lines.push(` ASSERT STATE(${FACTORY_BALANCE_PORT_BASE + j}) EQ PREVSTATE(${FACTORY_BALANCE_PORT_BASE + j})`);
|
|
74
74
|
}
|
|
75
75
|
lines.push(` ASSERT STATE(${port}) EQ 0`);
|
|
76
|
-
|
|
76
|
+
// Whole-share guard (mirrors the VTXO script): when the withdrawing party's
|
|
77
|
+
// share is the entire output there is no remainder, so a 0-amount output is
|
|
78
|
+
// never required.
|
|
79
|
+
lines.push(` IF @AMOUNT GT SHARE${k} THEN`);
|
|
80
|
+
lines.push(` RETURN VERIFYOUT(@INPUT @ADDRESS @AMOUNT SUB SHARE${k} @TOKENID TRUE)`);
|
|
81
|
+
lines.push(' ENDIF');
|
|
82
|
+
lines.push(' RETURN TRUE');
|
|
77
83
|
lines.push(' ENDIF');
|
|
78
84
|
lines.push(' ENDIF');
|
|
79
85
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-factory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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,8 +24,8 @@
|
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@totemsdk/core": "^1.3.0",
|
|
27
28
|
"@totemsdk/omnia": "^2.0.1",
|
|
28
|
-
"@totemsdk/core": "^1.2.11",
|
|
29
29
|
"@totemsdk/wots-lease": "^1.0.1",
|
|
30
30
|
"@totemsdk/tx-builder": "^0.2.1",
|
|
31
31
|
"@totemsdk/txpow": "^1.0.2",
|