@totemsdk/omnia-host 0.10.0 → 0.11.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/LICENSE +202 -21
- package/NOTICE +60 -0
- package/README.md +44 -0
- package/dist/api/jsonrpc.d.ts +12 -0
- package/dist/api/jsonrpc.js +100 -1
- package/dist/api/methods.d.ts +101 -3
- package/dist/api/methods.js +1664 -23
- package/dist/chain/totem-node-adapter.js +1 -1
- package/dist/cli.js +65 -0
- package/dist/config.d.ts +20 -0
- package/dist/config.js +33 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -1
- package/dist/lifecycle.d.ts +15 -0
- package/dist/lifecycle.js +171 -0
- package/dist/observe/bus.d.ts +13 -0
- package/dist/observe/bus.js +29 -0
- package/dist/observe/emitter.d.ts +61 -0
- package/dist/observe/emitter.js +133 -0
- package/dist/observe/index.d.ts +5 -0
- package/dist/observe/index.js +21 -0
- package/dist/observe/snapshot.d.ts +38 -0
- package/dist/observe/snapshot.js +101 -0
- package/dist/observe/store.d.ts +31 -0
- package/dist/observe/store.js +82 -0
- package/dist/observe/types.d.ts +106 -0
- package/dist/observe/types.js +14 -0
- package/dist/pairing.d.ts +109 -0
- package/dist/pairing.js +231 -0
- package/dist/signer-port.d.ts +27 -0
- package/dist/signer-port.js +79 -0
- package/dist/stores/operations.d.ts +3 -2
- package/dist/stores/operations.js +96 -83
- package/dist/stores/sqlite-store.d.ts +8 -5
- package/dist/stores/sqlite-store.js +45 -42
- package/package.json +11 -9
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type OmniaChannel, type ChannelSigner } from '@totemsdk/omnia';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Synchronous Map facade accepted by @totemsdk/omnia's ChannelStore type,
|
|
4
|
+
* persisted through `@totemsdk/storage` (`SyncSqliteStore`, same codec/envelope
|
|
5
|
+
* as `SqliteStore`). Legacy `omnia_channels` tables are migrated on open.
|
|
6
|
+
*/
|
|
3
7
|
export declare class SqliteChannelStore extends Map<string, OmniaChannel> {
|
|
4
|
-
private readonly
|
|
5
|
-
private readonly readStatement;
|
|
6
|
-
private readonly writeStatement;
|
|
7
|
-
private readonly deleteStatement;
|
|
8
|
+
private readonly kv;
|
|
8
9
|
/**
|
|
9
10
|
* CAN-002: a recovered channel loses `localSigner` (it is not serializable),
|
|
10
11
|
* so the router's `counterpartPkd()` cannot tell which party is local and
|
|
@@ -15,6 +16,8 @@ export declare class SqliteChannelStore extends Map<string, OmniaChannel> {
|
|
|
15
16
|
/** Attach the host's signer so recovered channels carry it (CAN-002). */
|
|
16
17
|
setLocalSigner(signer?: ChannelSigner): void;
|
|
17
18
|
private rebind;
|
|
19
|
+
private channelKeys;
|
|
20
|
+
private idOf;
|
|
18
21
|
get(channelId: string): OmniaChannel | undefined;
|
|
19
22
|
set(channelId: string, channel: OmniaChannel): this;
|
|
20
23
|
has(channelId: string): boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.SqliteChannelStore = void 0;
|
|
7
|
-
const
|
|
4
|
+
const sqlite_sync_1 = require("@totemsdk/storage/sqlite-sync");
|
|
8
5
|
const omnia_1 = require("@totemsdk/omnia");
|
|
6
|
+
const PREFIX = 'omnia:channel:';
|
|
7
|
+
const FORMAT_KEY = 'omnia:store:channel:format';
|
|
8
|
+
const STORE_FORMAT = 1;
|
|
9
9
|
function iterator(values) {
|
|
10
10
|
let index = 0;
|
|
11
11
|
return {
|
|
@@ -22,12 +22,13 @@ function iterator(values) {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Synchronous Map facade accepted by @totemsdk/omnia's ChannelStore type,
|
|
27
|
+
* persisted through `@totemsdk/storage` (`SyncSqliteStore`, same codec/envelope
|
|
28
|
+
* as `SqliteStore`). Legacy `omnia_channels` tables are migrated on open.
|
|
29
|
+
*/
|
|
26
30
|
class SqliteChannelStore extends Map {
|
|
27
|
-
|
|
28
|
-
readStatement;
|
|
29
|
-
writeStatement;
|
|
30
|
-
deleteStatement;
|
|
31
|
+
kv;
|
|
31
32
|
/**
|
|
32
33
|
* CAN-002: a recovered channel loses `localSigner` (it is not serializable),
|
|
33
34
|
* so the router's `counterpartPkd()` cannot tell which party is local and
|
|
@@ -36,24 +37,20 @@ class SqliteChannelStore extends Map {
|
|
|
36
37
|
localSigner;
|
|
37
38
|
constructor(dbPath) {
|
|
38
39
|
super();
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
channel_json = excluded.channel_json,
|
|
54
|
-
updated_at = excluded.updated_at
|
|
55
|
-
`);
|
|
56
|
-
this.deleteStatement = this.db.prepare('DELETE FROM omnia_channels WHERE channel_id = ?');
|
|
40
|
+
this.kv = new sqlite_sync_1.SyncSqliteStore(dbPath);
|
|
41
|
+
const version = this.kv.get(FORMAT_KEY);
|
|
42
|
+
if (version !== null && version !== STORE_FORMAT) {
|
|
43
|
+
this.kv.close();
|
|
44
|
+
throw new Error(`Unsupported SqliteChannelStore format ${version} (this build supports ${STORE_FORMAT}) — refusing to open`);
|
|
45
|
+
}
|
|
46
|
+
if (version === null) {
|
|
47
|
+
// One-time migration from the pre-storage direct-SQLite table.
|
|
48
|
+
this.kv.migrateLegacyTable('omnia_channels', (row) => ({
|
|
49
|
+
key: PREFIX + String(row['channel_id']),
|
|
50
|
+
value: String(row['channel_json']),
|
|
51
|
+
}));
|
|
52
|
+
this.kv.set(FORMAT_KEY, STORE_FORMAT);
|
|
53
|
+
}
|
|
57
54
|
}
|
|
58
55
|
/** Attach the host's signer so recovered channels carry it (CAN-002). */
|
|
59
56
|
setLocalSigner(signer) {
|
|
@@ -62,36 +59,42 @@ class SqliteChannelStore extends Map {
|
|
|
62
59
|
rebind(channel) {
|
|
63
60
|
return this.localSigner ? { ...channel, localSigner: this.localSigner } : channel;
|
|
64
61
|
}
|
|
62
|
+
channelKeys() {
|
|
63
|
+
return this.kv.keys().filter((key) => key.startsWith(PREFIX));
|
|
64
|
+
}
|
|
65
|
+
idOf(key) {
|
|
66
|
+
return key.slice(PREFIX.length);
|
|
67
|
+
}
|
|
65
68
|
get(channelId) {
|
|
66
|
-
const
|
|
67
|
-
return
|
|
69
|
+
const snapshot = this.kv.get(PREFIX + channelId);
|
|
70
|
+
return snapshot ? this.rebind((0, omnia_1.recoverChannel)(snapshot)) : undefined;
|
|
68
71
|
}
|
|
69
72
|
set(channelId, channel) {
|
|
70
|
-
this.
|
|
73
|
+
this.kv.set(PREFIX + channelId, (0, omnia_1.serializeChannelSnapshot)(channel));
|
|
71
74
|
return this;
|
|
72
75
|
}
|
|
73
76
|
has(channelId) {
|
|
74
|
-
return this.
|
|
77
|
+
return this.kv.has(PREFIX + channelId);
|
|
75
78
|
}
|
|
76
79
|
delete(channelId) {
|
|
77
|
-
return this.
|
|
80
|
+
return this.kv.remove(PREFIX + channelId);
|
|
78
81
|
}
|
|
79
82
|
clear() {
|
|
80
|
-
this.
|
|
83
|
+
for (const key of this.channelKeys())
|
|
84
|
+
this.kv.remove(key);
|
|
81
85
|
}
|
|
82
86
|
get size() {
|
|
83
|
-
|
|
84
|
-
return row.count;
|
|
87
|
+
return this.channelKeys().length;
|
|
85
88
|
}
|
|
86
89
|
entries() {
|
|
87
|
-
const rows = this.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const rows = this.channelKeys().map((key) => {
|
|
91
|
+
const snapshot = this.kv.get(key);
|
|
92
|
+
return [this.idOf(key), this.rebind((0, omnia_1.recoverChannel)(snapshot))];
|
|
93
|
+
});
|
|
94
|
+
return iterator(rows);
|
|
92
95
|
}
|
|
93
96
|
keys() {
|
|
94
|
-
return iterator(
|
|
97
|
+
return iterator(this.channelKeys().map((key) => this.idOf(key)));
|
|
95
98
|
}
|
|
96
99
|
values() {
|
|
97
100
|
return iterator(Array.from(this.entries(), ([, channel]) => channel));
|
|
@@ -104,7 +107,7 @@ class SqliteChannelStore extends Map {
|
|
|
104
107
|
callbackfn(value, key, this);
|
|
105
108
|
}
|
|
106
109
|
close() {
|
|
107
|
-
this.
|
|
110
|
+
this.kv.close();
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
exports.SqliteChannelStore = SqliteChannelStore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Durable Omnia node daemon for channel lifecycle, routing, and control APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,27 +17,29 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
19
|
"README.md",
|
|
20
|
-
"LICENSE"
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"NOTICE"
|
|
21
22
|
],
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"better-sqlite3": "^12.2.0",
|
|
24
24
|
"ws": "^8.21.1",
|
|
25
|
-
"@totemsdk/chain-provider": "^0.3.0",
|
|
26
25
|
"@totemsdk/core": "^1.4.0",
|
|
27
26
|
"@totemsdk/identity": "^1.0.2",
|
|
27
|
+
"@totemsdk/chain-provider": "^0.3.0",
|
|
28
|
+
"@totemsdk/liquidity-bond": "^0.3.1",
|
|
28
29
|
"@totemsdk/manifest": "^2.0.1",
|
|
29
|
-
"@totemsdk/
|
|
30
|
+
"@totemsdk/minima-rpc": "^0.4.0",
|
|
31
|
+
"@totemsdk/omnia": "^2.3.1",
|
|
30
32
|
"@totemsdk/omnia-factory": "^0.7.0",
|
|
31
33
|
"@totemsdk/omnia-router": "^0.4.0",
|
|
34
|
+
"@totemsdk/omnia-pool": "^0.5.3",
|
|
32
35
|
"@totemsdk/omnia-splice": "^0.3.0",
|
|
33
|
-
"@totemsdk/
|
|
36
|
+
"@totemsdk/p2p-hub": "^0.1.0",
|
|
34
37
|
"@totemsdk/omnia-vtxo": "^0.6.1",
|
|
35
|
-
"@totemsdk/
|
|
38
|
+
"@totemsdk/storage": "^0.2.0",
|
|
36
39
|
"@totemsdk/wots-lease": "^1.0.1"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
42
|
"@types/jest": "^30.0.0",
|
|
40
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
41
43
|
"@types/node": "^20.19.43",
|
|
42
44
|
"@types/ws": "^8.5.0",
|
|
43
45
|
"jest": "^30.4.2",
|
|
@@ -51,7 +53,7 @@
|
|
|
51
53
|
"publishConfig": {
|
|
52
54
|
"access": "public"
|
|
53
55
|
},
|
|
54
|
-
"license": "
|
|
56
|
+
"license": "Apache-2.0",
|
|
55
57
|
"author": "Totem SDK",
|
|
56
58
|
"homepage": "https://docs.totem.ing",
|
|
57
59
|
"repository": {
|