@totemsdk/omnia-factory 0.1.2 → 0.1.4
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/README.md +70 -0
- package/package.json +15 -7
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @totemsdk/omnia-factory
|
|
2
|
+
|
|
3
|
+
**Scale payment channels — N-of-N funded factory channels with virtual sub-channels.**
|
|
4
|
+
|
|
5
|
+
Enables a Lightning-like channel factory pattern: a single on-chain UTXO funds a factory, and virtual channels between factory participants open and close off-chain. Dramatically reduces on-chain footprint for active participants.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @totemsdk/omnia-factory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## What's inside
|
|
14
|
+
|
|
15
|
+
- **N-of-N MULTISIG funding** — one on-chain UTXO funds the factory; all participants co-sign the funding transaction
|
|
16
|
+
- **Virtual channel management** — open sub-channels between any factory participants without any on-chain transactions
|
|
17
|
+
- **Factory settlement** — settle multiple virtual channels in a single on-chain transaction when participants exit
|
|
18
|
+
- **Reduced footprint** — 10 participants with 45 active channels = still just 1 on-chain UTXO
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Create a factory
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createChannelFactory } from '@totemsdk/omnia-factory';
|
|
26
|
+
|
|
27
|
+
const factory = await createChannelFactory({
|
|
28
|
+
participants: [
|
|
29
|
+
{ address: 'MxAAA...', publicKey: '0x...' },
|
|
30
|
+
{ address: 'MxBBB...', publicKey: '0x...' },
|
|
31
|
+
{ address: 'MxCCC...', publicKey: '0x...' },
|
|
32
|
+
],
|
|
33
|
+
fundingAmount: '1000',
|
|
34
|
+
tokenid: '0x00',
|
|
35
|
+
signer,
|
|
36
|
+
provider,
|
|
37
|
+
leaseProvider,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log('Factory ID:', factory.id);
|
|
41
|
+
console.log('Funding TxPoW ID:', factory.fundingTxpowId);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Open a virtual channel inside the factory
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const virtualChannel = await factory.openVirtualChannel({
|
|
48
|
+
from: 'MxAAA...',
|
|
49
|
+
to: 'MxBBB...',
|
|
50
|
+
amount: '50',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Use like a regular OmniaChannel
|
|
54
|
+
await virtualChannel.pay({ amount: '5', tokenid: '0x00', recipient: 'MxBBB...' });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Settle and exit
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Settle all virtual channels involving a participant in one on-chain tx
|
|
61
|
+
const settlementHex = await factory.settle({ exitParticipant: 'MxAAA...' });
|
|
62
|
+
await provider.broadcastTxPoW(settlementHex);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## See also
|
|
66
|
+
|
|
67
|
+
- [`@totemsdk/omnia`](../omnia) — core channel state machine used by virtual channels
|
|
68
|
+
- [`@totemsdk/omnia-router`](../omnia-router) — route payments across factory and direct channels
|
|
69
|
+
- [`@totemsdk/wots-lease`](../wots-lease) — WOTS key safety for factory signing
|
|
70
|
+
- [`@totemsdk/tx-builder`](../tx-builder) — builds the N-of-N funding transaction
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-factory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Channel factory layer for Omnia — N-of-N MULTISIG funding, virtual channel management, and factory settlement",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,12 +16,20 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@totemsdk/core": "1.0.
|
|
20
|
-
"@totemsdk/omnia": "0.1.
|
|
21
|
-
"@totemsdk/wots-lease": "0.1.
|
|
22
|
-
"@totemsdk/
|
|
23
|
-
"@totemsdk/
|
|
24
|
-
"@totemsdk/chain-provider": "0.1.
|
|
19
|
+
"@totemsdk/core": "1.0.9",
|
|
20
|
+
"@totemsdk/omnia": "0.1.3",
|
|
21
|
+
"@totemsdk/wots-lease": "0.1.2",
|
|
22
|
+
"@totemsdk/txpow": "0.1.3",
|
|
23
|
+
"@totemsdk/tx-builder": "0.1.4",
|
|
24
|
+
"@totemsdk/chain-provider": "0.1.2"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@noble/hashes": ">=1.3.0 <2.0.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"@noble/hashes": {
|
|
31
|
+
"optional": false
|
|
32
|
+
}
|
|
25
33
|
},
|
|
26
34
|
"devDependencies": {
|
|
27
35
|
"@noble/hashes": "^1.3.0",
|