@totemsdk/omnia-host 0.7.0 → 0.8.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/api/methods.d.ts +5 -0
- package/dist/api/methods.js +61 -0
- package/package.json +5 -5
package/dist/api/methods.d.ts
CHANGED
|
@@ -34,4 +34,9 @@ export interface HostApiContext {
|
|
|
34
34
|
/** Boot-time signed EdgeServiceManifest. */
|
|
35
35
|
manifest?: unknown;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* CAN-006: a fully serializable channel-state view so RPC/HTTP consumers can
|
|
39
|
+
* read everything they need without reaching into `getStore()`/`getMethods()`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function channelStateView(channel: OmniaChannel): Record<string, unknown>;
|
|
37
42
|
export declare function createHostMethods(context: HostApiContext): Map<string, JsonRpcHandler>;
|
package/dist/api/methods.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.channelStateView = channelStateView;
|
|
3
4
|
exports.createHostMethods = createHostMethods;
|
|
4
5
|
const omnia_1 = require("@totemsdk/omnia");
|
|
5
6
|
const omnia_router_1 = require("@totemsdk/omnia-router");
|
|
@@ -17,6 +18,57 @@ function channelSummary(channel) {
|
|
|
17
18
|
currentSequence: channel.currentSequence,
|
|
18
19
|
};
|
|
19
20
|
}
|
|
21
|
+
/** Recursively JSON-safe: bigint → decimal string, bytes → 0x-hex. */
|
|
22
|
+
function jsonSafe(value) {
|
|
23
|
+
if (typeof value === 'bigint')
|
|
24
|
+
return value.toString();
|
|
25
|
+
if (value instanceof Uint8Array)
|
|
26
|
+
return `0x${Buffer.from(value).toString('hex')}`;
|
|
27
|
+
if (Array.isArray(value))
|
|
28
|
+
return value.map(jsonSafe);
|
|
29
|
+
if (value && typeof value === 'object') {
|
|
30
|
+
const out = {};
|
|
31
|
+
for (const [key, val] of Object.entries(value))
|
|
32
|
+
out[key] = jsonSafe(val);
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* CAN-006: a fully serializable channel-state view so RPC/HTTP consumers can
|
|
39
|
+
* read everything they need without reaching into `getStore()`/`getMethods()`.
|
|
40
|
+
*/
|
|
41
|
+
function channelStateView(channel) {
|
|
42
|
+
return jsonSafe({
|
|
43
|
+
channelId: channel.channelId,
|
|
44
|
+
status: channel.status,
|
|
45
|
+
channelType: channel.channelType,
|
|
46
|
+
tokenId: channel.tokenId,
|
|
47
|
+
tokenScale: channel.tokenScale ?? 0,
|
|
48
|
+
totalValue: channel.totalValue,
|
|
49
|
+
currentSequence: channel.currentSequence,
|
|
50
|
+
fundingAddress: channel.fundingAddress,
|
|
51
|
+
fundingTxId: channel.fundingTxId,
|
|
52
|
+
fundingCoinId: channel.fundingCoinId,
|
|
53
|
+
parties: channel.parties,
|
|
54
|
+
balances: channel.balances,
|
|
55
|
+
pendingHTLCs: channel.pendingHTLCs,
|
|
56
|
+
latestState: channel.latestState
|
|
57
|
+
? {
|
|
58
|
+
sequence: channel.latestState.sequence,
|
|
59
|
+
balances: channel.latestState.balances,
|
|
60
|
+
pendingHTLCs: channel.latestState.pendingHTLCs?.length ?? 0,
|
|
61
|
+
stateVariables: channel.latestState.stateVariables,
|
|
62
|
+
transactionHex: channel.latestState.transactionHex,
|
|
63
|
+
signatures: Object.keys(channel.latestState.signatures ?? {}),
|
|
64
|
+
signingIndices: channel.latestState.signingIndices,
|
|
65
|
+
}
|
|
66
|
+
: null,
|
|
67
|
+
stateLogLength: channel.stateLog?.length ?? 0,
|
|
68
|
+
createdAt: channel.createdAt,
|
|
69
|
+
updatedAt: channel.updatedAt,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
20
72
|
function paramsObject(params) {
|
|
21
73
|
if (!params || typeof params !== 'object' || Array.isArray(params))
|
|
22
74
|
return {};
|
|
@@ -149,6 +201,15 @@ function createHostMethods(context) {
|
|
|
149
201
|
return { channels };
|
|
150
202
|
};
|
|
151
203
|
register('totem_omniaGetChannels', getChannels, 'omnia/getChannels');
|
|
204
|
+
const getChannelState = (raw) => {
|
|
205
|
+
const params = paramsObject(raw);
|
|
206
|
+
const channelId = requiredString(params, 'channelId');
|
|
207
|
+
const channel = context.channels.get(channelId);
|
|
208
|
+
if (!channel)
|
|
209
|
+
throw new Error(`Channel ${channelId} not found`);
|
|
210
|
+
return channelStateView(channel);
|
|
211
|
+
};
|
|
212
|
+
register('totem_omniaGetChannelState', getChannelState, 'omnia/getChannelState');
|
|
152
213
|
const getRoute = async (raw) => {
|
|
153
214
|
context.refreshRouting?.();
|
|
154
215
|
const params = paramsObject(raw);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"better-sqlite3": "^12.2.0",
|
|
24
24
|
"ws": "^8.21.1",
|
|
25
25
|
"@totemsdk/chain-provider": "^0.2.1",
|
|
26
|
+
"@totemsdk/identity": "^1.0.1",
|
|
26
27
|
"@totemsdk/core": "^1.2.11",
|
|
27
28
|
"@totemsdk/manifest": "^2.0.0",
|
|
28
29
|
"@totemsdk/omnia": "^2.0.1",
|
|
29
|
-
"@totemsdk/identity": "^1.0.1",
|
|
30
|
-
"@totemsdk/omnia-router": "^0.3.0",
|
|
31
30
|
"@totemsdk/omnia-factory": "^0.5.0",
|
|
32
|
-
"@totemsdk/omnia-
|
|
31
|
+
"@totemsdk/omnia-router": "^0.3.0",
|
|
33
32
|
"@totemsdk/omnia-splice": "^0.3.0",
|
|
34
|
-
"@totemsdk/
|
|
33
|
+
"@totemsdk/omnia-vtxo": "^0.5.0",
|
|
35
34
|
"@totemsdk/minima-rpc": "^0.2.2",
|
|
35
|
+
"@totemsdk/storage": "^0.1.0",
|
|
36
36
|
"@totemsdk/wots-lease": "^1.0.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|