@ottochain/sdk 1.4.1 → 1.5.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.
Files changed (38) hide show
  1. package/dist/cjs/ottochain/normalize.js +23 -12
  2. package/dist/esm/apps/contracts/index.js +10 -28
  3. package/dist/esm/apps/corporate/index.js +24 -79
  4. package/dist/esm/apps/governance/index.js +36 -85
  5. package/dist/esm/apps/identity/constants.js +22 -27
  6. package/dist/esm/apps/identity/index.js +7 -35
  7. package/dist/esm/apps/index.js +6 -32
  8. package/dist/esm/apps/markets/index.js +6 -27
  9. package/dist/esm/apps/oracles/index.js +7 -27
  10. package/dist/esm/errors.js +9 -19
  11. package/dist/esm/generated/google/protobuf/struct.js +33 -39
  12. package/dist/esm/generated/google/protobuf/timestamp.js +6 -9
  13. package/dist/esm/generated/index.js +10 -134
  14. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +48 -54
  15. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +335 -357
  16. package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +284 -299
  17. package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +38 -47
  18. package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +44 -50
  19. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +77 -86
  20. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +66 -72
  21. package/dist/esm/generated/ottochain/v1/common.js +1 -4
  22. package/dist/esm/generated/ottochain/v1/fiber.js +90 -96
  23. package/dist/esm/generated/ottochain/v1/messages.js +79 -82
  24. package/dist/esm/generated/ottochain/v1/records.js +137 -140
  25. package/dist/esm/index.js +13 -70
  26. package/dist/esm/ottochain/drop-nulls.js +1 -5
  27. package/dist/esm/ottochain/index.js +6 -54
  28. package/dist/esm/ottochain/metagraph-client.js +12 -16
  29. package/dist/esm/ottochain/normalize.js +27 -23
  30. package/dist/esm/ottochain/snapshot.js +10 -20
  31. package/dist/esm/ottochain/transaction.js +13 -25
  32. package/dist/esm/ottochain/types.js +1 -2
  33. package/dist/esm/types.js +2 -7
  34. package/dist/esm/validation.js +65 -76
  35. package/dist/esm/verify.js +3 -7
  36. package/dist/types/ottochain/normalize.d.ts +7 -8
  37. package/dist/types/ottochain/types.d.ts +3 -1
  38. package/package.json +7 -7
package/dist/esm/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Ottochain SDK
4
3
  *
@@ -16,86 +15,30 @@
16
15
  *
17
16
  * @packageDocumentation
18
17
  */
19
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- var desc = Object.getOwnPropertyDescriptor(m, k);
22
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
- desc = { enumerable: true, get: function() { return m[k]; } };
24
- }
25
- Object.defineProperty(o, k2, desc);
26
- }) : (function(o, m, k, k2) {
27
- if (k2 === undefined) k2 = k;
28
- o[k2] = m[k];
29
- }));
30
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32
- };
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.OttoMetagraphClient = exports.assert = exports.safeParse = exports.validateKeyPair = exports.validateAddress = exports.validatePublicKey = exports.validatePrivateKey = exports.validate = exports.CompleteContractRequestSchema = exports.AcceptContractRequestSchema = exports.ProposeContractRequestSchema = exports.ContractTermsSchema = exports.PlatformLinkSchema = exports.AgentIdentityRegistrationSchema = exports.TransferParamsSchema = exports.CurrencyTransactionSchema = exports.CurrencyTransactionValueSchema = exports.TransactionReferenceSchema = exports.SignedSchema = exports.SignatureProofSchema = exports.KeyPairSchema = exports.PublicKeySchema = exports.PrivateKeySchema = exports.DagAddressSchema = exports.wrapError = exports.isErrorCode = exports.ErrorCode = exports.TransactionError = exports.SigningError = exports.ValidationError = exports.NetworkError = exports.OttoChainError = exports.dropNulls = exports.normalizeMessage = exports.normalizeArchiveStateMachine = exports.normalizeTransitionStateMachine = exports.normalizeCreateStateMachine = exports.MetagraphNetworkError = exports.HttpClient = exports.createMetagraphClient = exports.MetagraphClient = exports.verify = void 0;
35
18
  // ─── Core metagraph SDK ───────────────────────────────────────────────────────
36
19
  // Consumers can also import directly from '@constellation-network/metagraph-sdk'
37
- __exportStar(require("@constellation-network/metagraph-sdk"), exports);
20
+ export * from '@constellation-network/metagraph-sdk';
38
21
  // Override verify — package embeds `mode` in signed objects and ignores isDataUpdate
39
22
  // when mode is present. Our wrapper strips mode so isDataUpdate always wins.
40
- var verify_js_1 = require("./verify.js");
41
- Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_js_1.verify; } });
23
+ export { verify } from './verify.js';
42
24
  // ─── Network clients ──────────────────────────────────────────────────────────
43
25
  // Re-export from package network subpath
44
- var network_1 = require("@constellation-network/metagraph-sdk/network");
45
- Object.defineProperty(exports, "MetagraphClient", { enumerable: true, get: function () { return network_1.MetagraphClient; } });
46
- Object.defineProperty(exports, "createMetagraphClient", { enumerable: true, get: function () { return network_1.createMetagraphClient; } });
47
- Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return network_1.HttpClient; } });
48
- Object.defineProperty(exports, "MetagraphNetworkError", { enumerable: true, get: function () { return network_1.NetworkError; } });
26
+ export { MetagraphClient, createMetagraphClient, HttpClient, NetworkError as MetagraphNetworkError, } from '@constellation-network/metagraph-sdk/network';
49
27
  // ─── Type aliases for semantic clarity (matches wire format) ──────────────────
50
- __exportStar(require("./types.js"), exports);
28
+ export * from './types.js';
51
29
  // ─── OttoChain-specific transaction helpers ───────────────────────────────────
52
- __exportStar(require("./ottochain/transaction.js"), exports);
53
- var normalize_js_1 = require("./ottochain/normalize.js");
54
- Object.defineProperty(exports, "normalizeCreateStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeCreateStateMachine; } });
55
- Object.defineProperty(exports, "normalizeTransitionStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeTransitionStateMachine; } });
56
- Object.defineProperty(exports, "normalizeArchiveStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeArchiveStateMachine; } });
57
- Object.defineProperty(exports, "normalizeMessage", { enumerable: true, get: function () { return normalize_js_1.normalizeMessage; } });
58
- var drop_nulls_js_1 = require("./ottochain/drop-nulls.js");
59
- Object.defineProperty(exports, "dropNulls", { enumerable: true, get: function () { return drop_nulls_js_1.dropNulls; } });
30
+ export * from './ottochain/transaction.js';
31
+ export { normalizeCreateStateMachine, normalizeTransitionStateMachine, normalizeArchiveStateMachine, normalizeMessage } from './ottochain/normalize.js';
32
+ export { dropNulls } from './ottochain/drop-nulls.js';
60
33
  // ─── Generated protobuf types (canonical definitions) ────────────────────────
61
- __exportStar(require("./generated/index.js"), exports);
34
+ export * from './generated/index.js';
62
35
  // ─── Custom error classes ─────────────────────────────────────────────────────
63
- var errors_js_1 = require("./errors.js");
64
- Object.defineProperty(exports, "OttoChainError", { enumerable: true, get: function () { return errors_js_1.OttoChainError; } });
65
- Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return errors_js_1.NetworkError; } });
66
- Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_js_1.ValidationError; } });
67
- Object.defineProperty(exports, "SigningError", { enumerable: true, get: function () { return errors_js_1.SigningError; } });
68
- Object.defineProperty(exports, "TransactionError", { enumerable: true, get: function () { return errors_js_1.TransactionError; } });
69
- Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return errors_js_1.ErrorCode; } });
70
- Object.defineProperty(exports, "isErrorCode", { enumerable: true, get: function () { return errors_js_1.isErrorCode; } });
71
- Object.defineProperty(exports, "wrapError", { enumerable: true, get: function () { return errors_js_1.wrapError; } });
36
+ export { OttoChainError, NetworkError, ValidationError, SigningError, TransactionError, ErrorCode, isErrorCode, wrapError, } from './errors.js';
72
37
  // ─── Validation schemas and helpers ──────────────────────────────────────────
73
- var validation_js_1 = require("./validation.js");
38
+ export {
74
39
  // Schemas
75
- Object.defineProperty(exports, "DagAddressSchema", { enumerable: true, get: function () { return validation_js_1.DagAddressSchema; } });
76
- Object.defineProperty(exports, "PrivateKeySchema", { enumerable: true, get: function () { return validation_js_1.PrivateKeySchema; } });
77
- Object.defineProperty(exports, "PublicKeySchema", { enumerable: true, get: function () { return validation_js_1.PublicKeySchema; } });
78
- Object.defineProperty(exports, "KeyPairSchema", { enumerable: true, get: function () { return validation_js_1.KeyPairSchema; } });
79
- Object.defineProperty(exports, "SignatureProofSchema", { enumerable: true, get: function () { return validation_js_1.SignatureProofSchema; } });
80
- Object.defineProperty(exports, "SignedSchema", { enumerable: true, get: function () { return validation_js_1.SignedSchema; } });
81
- Object.defineProperty(exports, "TransactionReferenceSchema", { enumerable: true, get: function () { return validation_js_1.TransactionReferenceSchema; } });
82
- Object.defineProperty(exports, "CurrencyTransactionValueSchema", { enumerable: true, get: function () { return validation_js_1.CurrencyTransactionValueSchema; } });
83
- Object.defineProperty(exports, "CurrencyTransactionSchema", { enumerable: true, get: function () { return validation_js_1.CurrencyTransactionSchema; } });
84
- Object.defineProperty(exports, "TransferParamsSchema", { enumerable: true, get: function () { return validation_js_1.TransferParamsSchema; } });
85
- Object.defineProperty(exports, "AgentIdentityRegistrationSchema", { enumerable: true, get: function () { return validation_js_1.AgentIdentityRegistrationSchema; } });
86
- Object.defineProperty(exports, "PlatformLinkSchema", { enumerable: true, get: function () { return validation_js_1.PlatformLinkSchema; } });
87
- Object.defineProperty(exports, "ContractTermsSchema", { enumerable: true, get: function () { return validation_js_1.ContractTermsSchema; } });
88
- Object.defineProperty(exports, "ProposeContractRequestSchema", { enumerable: true, get: function () { return validation_js_1.ProposeContractRequestSchema; } });
89
- Object.defineProperty(exports, "AcceptContractRequestSchema", { enumerable: true, get: function () { return validation_js_1.AcceptContractRequestSchema; } });
90
- Object.defineProperty(exports, "CompleteContractRequestSchema", { enumerable: true, get: function () { return validation_js_1.CompleteContractRequestSchema; } });
40
+ DagAddressSchema, PrivateKeySchema, PublicKeySchema, KeyPairSchema, SignatureProofSchema, SignedSchema, TransactionReferenceSchema, CurrencyTransactionValueSchema, CurrencyTransactionSchema, TransferParamsSchema, AgentIdentityRegistrationSchema, PlatformLinkSchema, ContractTermsSchema, ProposeContractRequestSchema, AcceptContractRequestSchema, CompleteContractRequestSchema,
91
41
  // Helpers
92
- Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validation_js_1.validate; } });
93
- Object.defineProperty(exports, "validatePrivateKey", { enumerable: true, get: function () { return validation_js_1.validatePrivateKey; } });
94
- Object.defineProperty(exports, "validatePublicKey", { enumerable: true, get: function () { return validation_js_1.validatePublicKey; } });
95
- Object.defineProperty(exports, "validateAddress", { enumerable: true, get: function () { return validation_js_1.validateAddress; } });
96
- Object.defineProperty(exports, "validateKeyPair", { enumerable: true, get: function () { return validation_js_1.validateKeyPair; } });
97
- Object.defineProperty(exports, "safeParse", { enumerable: true, get: function () { return validation_js_1.safeParse; } });
98
- Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return validation_js_1.assert; } });
42
+ validate, validatePrivateKey, validatePublicKey, validateAddress, validateKeyPair, safeParse, assert, } from './validation.js';
99
43
  // ─── OttoChain metagraph client ───────────────────────────────────────────────
100
- var metagraph_client_js_1 = require("./ottochain/metagraph-client.js");
101
- Object.defineProperty(exports, "OttoMetagraphClient", { enumerable: true, get: function () { return metagraph_client_js_1.MetagraphClient; } });
44
+ export { MetagraphClient as OttoMetagraphClient } from './ottochain/metagraph-client.js';
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Drop Null Values from JSON Objects
4
3
  *
@@ -12,8 +11,6 @@
12
11
  * Note: null values inside arrays are preserved (to maintain index
13
12
  * positions). Only object field values that are null are removed.
14
13
  */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.dropNulls = void 0;
17
14
  /**
18
15
  * Recursively remove null values from objects
19
16
  *
@@ -29,7 +26,7 @@ exports.dropNulls = void 0;
29
26
  * // => [1, null, 3] (array nulls preserved)
30
27
  * ```
31
28
  */
32
- function dropNulls(value) {
29
+ export function dropNulls(value) {
33
30
  if (value === null || value === undefined) {
34
31
  return value;
35
32
  }
@@ -47,4 +44,3 @@ function dropNulls(value) {
47
44
  }
48
45
  return value;
49
46
  }
50
- exports.dropNulls = dropNulls;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Ottochain SDK
4
3
  *
@@ -6,61 +5,14 @@
6
5
  *
7
6
  * @packageDocumentation
8
7
  */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.dropNulls = exports.normalizeMessage = exports.normalizeArchiveStateMachine = exports.normalizeTransitionStateMachine = exports.normalizeCreateStateMachine = exports.createDataTransactionRequest = exports.createScriptPayload = exports.createStateMachinePayload = exports.getPublicKeyForRegistration = exports.addTransactionSignature = exports.signTransaction = exports.createInvokeScriptPayload = exports.createArchivePayload = exports.createTransitionPayload = exports.MetagraphClient = exports.extractOnChainState = exports.getScriptInvocations = exports.getEventReceipts = exports.getLogsForFiber = exports.getLatestOnChainState = exports.getSnapshotOnChainState = exports.decodeOnChainState = exports.proto = void 0;
34
8
  // Re-export generated protobuf types (for binary encoding)
35
- exports.proto = __importStar(require("../generated/index.js"));
36
- var snapshot_js_1 = require("./snapshot.js");
37
- Object.defineProperty(exports, "decodeOnChainState", { enumerable: true, get: function () { return snapshot_js_1.decodeOnChainState; } });
38
- Object.defineProperty(exports, "getSnapshotOnChainState", { enumerable: true, get: function () { return snapshot_js_1.getSnapshotOnChainState; } });
39
- Object.defineProperty(exports, "getLatestOnChainState", { enumerable: true, get: function () { return snapshot_js_1.getLatestOnChainState; } });
40
- Object.defineProperty(exports, "getLogsForFiber", { enumerable: true, get: function () { return snapshot_js_1.getLogsForFiber; } });
41
- Object.defineProperty(exports, "getEventReceipts", { enumerable: true, get: function () { return snapshot_js_1.getEventReceipts; } });
42
- Object.defineProperty(exports, "getScriptInvocations", { enumerable: true, get: function () { return snapshot_js_1.getScriptInvocations; } });
43
- Object.defineProperty(exports, "extractOnChainState", { enumerable: true, get: function () { return snapshot_js_1.extractOnChainState; } });
44
- var metagraph_client_js_1 = require("./metagraph-client.js");
45
- Object.defineProperty(exports, "MetagraphClient", { enumerable: true, get: function () { return metagraph_client_js_1.MetagraphClient; } });
9
+ export * as proto from '../generated/index.js';
10
+ export { decodeOnChainState, getSnapshotOnChainState, getLatestOnChainState, getLogsForFiber, getEventReceipts, getScriptInvocations, extractOnChainState, } from './snapshot.js';
11
+ export { MetagraphClient } from './metagraph-client.js';
46
12
  // Transaction helpers (state machine payloads, signing)
47
- var transaction_js_1 = require("./transaction.js");
48
- Object.defineProperty(exports, "createTransitionPayload", { enumerable: true, get: function () { return transaction_js_1.createTransitionPayload; } });
49
- Object.defineProperty(exports, "createArchivePayload", { enumerable: true, get: function () { return transaction_js_1.createArchivePayload; } });
50
- Object.defineProperty(exports, "createInvokeScriptPayload", { enumerable: true, get: function () { return transaction_js_1.createInvokeScriptPayload; } });
51
- Object.defineProperty(exports, "signTransaction", { enumerable: true, get: function () { return transaction_js_1.signTransaction; } });
52
- Object.defineProperty(exports, "addTransactionSignature", { enumerable: true, get: function () { return transaction_js_1.addTransactionSignature; } });
53
- Object.defineProperty(exports, "getPublicKeyForRegistration", { enumerable: true, get: function () { return transaction_js_1.getPublicKeyForRegistration; } });
54
- Object.defineProperty(exports, "createStateMachinePayload", { enumerable: true, get: function () { return transaction_js_1.createStateMachinePayload; } });
55
- Object.defineProperty(exports, "createScriptPayload", { enumerable: true, get: function () { return transaction_js_1.createScriptPayload; } });
56
- Object.defineProperty(exports, "createDataTransactionRequest", { enumerable: true, get: function () { return transaction_js_1.createDataTransactionRequest; } });
13
+ export { createTransitionPayload, createArchivePayload, createInvokeScriptPayload, signTransaction, addTransactionSignature, getPublicKeyForRegistration, createStateMachinePayload, createScriptPayload, createDataTransactionRequest, } from './transaction.js';
57
14
  // Data utilities
58
- var normalize_js_1 = require("./normalize.js");
59
- Object.defineProperty(exports, "normalizeCreateStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeCreateStateMachine; } });
60
- Object.defineProperty(exports, "normalizeTransitionStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeTransitionStateMachine; } });
61
- Object.defineProperty(exports, "normalizeArchiveStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeArchiveStateMachine; } });
62
- Object.defineProperty(exports, "normalizeMessage", { enumerable: true, get: function () { return normalize_js_1.normalizeMessage; } });
63
- var drop_nulls_js_1 = require("./drop-nulls.js");
64
- Object.defineProperty(exports, "dropNulls", { enumerable: true, get: function () { return drop_nulls_js_1.dropNulls; } });
15
+ export { normalizeCreateStateMachine, normalizeTransitionStateMachine, normalizeArchiveStateMachine, normalizeMessage, } from './normalize.js';
16
+ export { dropNulls } from './drop-nulls.js';
65
17
  // Note: Governance and Corporate types are now in src/apps/
66
18
  // Import from '@ottochain/sdk/apps' instead
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Ottochain Metagraph Client
4
3
  *
@@ -9,11 +8,9 @@
9
8
  * @see modules/data_l1/src/main/scala/xyz/kd5ujc/data_l1/DataL1CustomRoutes.scala
10
9
  * @packageDocumentation
11
10
  */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.MetagraphClient = void 0;
14
- const transaction_js_1 = require("./transaction.js");
15
- const network_1 = require("@constellation-network/metagraph-sdk/network");
16
- const snapshot_js_1 = require("./snapshot.js");
11
+ import { createDataTransactionRequest } from './transaction.js';
12
+ import { HttpClient, NetworkError } from '@constellation-network/metagraph-sdk/network';
13
+ import { extractOnChainState } from './snapshot.js';
17
14
  /**
18
15
  * Client for ottochain metagraph operations.
19
16
  *
@@ -37,15 +34,15 @@ const snapshot_js_1 = require("./snapshot.js");
37
34
  * const events = await client.getStateMachineEvents(fiberId);
38
35
  * ```
39
36
  */
40
- class MetagraphClient {
37
+ export class MetagraphClient {
41
38
  constructor(config) {
42
- this.ml0 = new network_1.HttpClient(config.ml0Url, config.timeout);
39
+ this.ml0 = new HttpClient(config.ml0Url, config.timeout);
43
40
  if (config.dl1Url) {
44
- this.dl1 = new network_1.HttpClient(config.dl1Url, config.timeout);
41
+ this.dl1 = new HttpClient(config.dl1Url, config.timeout);
45
42
  }
46
43
  // Build DL1 client pool from dl1Urls (falls back to dl1Url if provided)
47
44
  const urls = config.dl1Urls ?? (config.dl1Url ? [config.dl1Url] : []);
48
- this.dl1Clients = urls.map((url) => new network_1.HttpClient(url, config.timeout));
45
+ this.dl1Clients = urls.map((url) => new HttpClient(url, config.timeout));
49
46
  }
50
47
  // -------------------------------------------------------------------------
51
48
  // Custom routes (ML0 /data-application/v1/*)
@@ -77,7 +74,7 @@ class MetagraphClient {
77
74
  return await this.ml0.get(`/data-application/v1/state-machines/${fiberId}`);
78
75
  }
79
76
  catch (error) {
80
- if (error instanceof network_1.NetworkError && error.statusCode === 404) {
77
+ if (error instanceof NetworkError && error.statusCode === 404) {
81
78
  return null;
82
79
  }
83
80
  throw error;
@@ -104,7 +101,7 @@ class MetagraphClient {
104
101
  return await this.ml0.get(`/data-application/v1/oracles/${scriptId}`);
105
102
  }
106
103
  catch (error) {
107
- if (error instanceof network_1.NetworkError && error.statusCode === 404) {
104
+ if (error instanceof NetworkError && error.statusCode === 404) {
108
105
  return null;
109
106
  }
110
107
  throw error;
@@ -124,14 +121,14 @@ class MetagraphClient {
124
121
  */
125
122
  async getLatestSnapshotOnChainState() {
126
123
  const snapshot = await this.ml0.get('/snapshots/latest');
127
- return (0, snapshot_js_1.extractOnChainState)(snapshot);
124
+ return extractOnChainState(snapshot);
128
125
  }
129
126
  /**
130
127
  * Get a snapshot by ordinal and decode its on-chain state.
131
128
  */
132
129
  async getSnapshotOnChainState(ordinal) {
133
130
  const snapshot = await this.ml0.get(`/snapshots/${ordinal}`);
134
- return (0, snapshot_js_1.extractOnChainState)(snapshot);
131
+ return extractOnChainState(snapshot);
135
132
  }
136
133
  /**
137
134
  * Get the latest snapshot ordinal.
@@ -328,7 +325,7 @@ class MetagraphClient {
328
325
  if (this.dl1Clients.length === 0) {
329
326
  throw new Error('dl1Url or dl1Urls is required for submitData');
330
327
  }
331
- const request = (0, transaction_js_1.createDataTransactionRequest)(signed);
328
+ const request = createDataTransactionRequest(signed);
332
329
  if (this.dl1Clients.length === 1) {
333
330
  return this.dl1Clients[0].post('/data', request);
334
331
  }
@@ -352,4 +349,3 @@ class MetagraphClient {
352
349
  });
353
350
  }
354
351
  }
355
- exports.MetagraphClient = MetagraphClient;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Normalize OttoChain Messages for Signing
4
3
  *
@@ -18,8 +17,6 @@
18
17
  * - `List.empty` → `[]`
19
18
  * - `Map.empty` → `{}`
20
19
  */
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.normalizeMessage = exports.normalizeArchiveStateMachine = exports.normalizeTransitionStateMachine = exports.normalizeCreateStateMachine = void 0;
23
20
  /**
24
21
  * Normalize a State object for wire format
25
22
  */
@@ -32,15 +29,26 @@ function normalizeState(state) {
32
29
  }
33
30
  /**
34
31
  * Normalize a Transition object for wire format
32
+ *
33
+ * Scala Transition schema:
34
+ * from: StateId (required)
35
+ * to: StateId (required)
36
+ * eventName: String (required)
37
+ * guard: JsonLogicExpression (required)
38
+ * effect: JsonLogicExpression (required)
39
+ * dependencies: Set[UUID] = Set.empty
40
+ *
41
+ * `dependencies` serializes as `[]` when empty (default). Both `guard`
42
+ * and `effect` are required non-optional fields.
35
43
  */
36
44
  function normalizeTransition(t) {
37
45
  return {
38
46
  from: t.from,
39
- eventName: t.eventName,
40
47
  to: t.to,
41
- guard: t.guard ?? null,
42
- actions: t.actions ?? null,
43
- metadata: t.metadata ?? null,
48
+ eventName: t.eventName,
49
+ guard: t.guard,
50
+ effect: t.effect,
51
+ dependencies: t.dependencies ?? [],
44
52
  };
45
53
  }
46
54
  /**
@@ -65,13 +73,12 @@ function normalizeDefinition(def) {
65
73
  /**
66
74
  * Normalize a CreateStateMachine message for wire format
67
75
  *
68
- * Ensures all Option fields are explicit null:
69
- * - definition.metadata
70
- * - definition.states[*].metadata
71
- * - definition.transitions[*].guard
72
- * - definition.transitions[*].actions
73
- * - definition.transitions[*].metadata
74
- * - parentFiberId
76
+ * Ensures all Option/default fields are explicit in wire format:
77
+ * - definition.metadata → null when absent
78
+ * - definition.states[*].metadata → null when absent
79
+ * - definition.transitions[*].dependencies → [] when absent
80
+ * - parentFiberId → null when absent
81
+ * - participants → null when absent (Optional Set[Address] for multi-party signing)
75
82
  *
76
83
  * @example
77
84
  * ```typescript
@@ -80,22 +87,22 @@ function normalizeDefinition(def) {
80
87
  * definition: { states: { INIT: { id: { value: 'INIT' }, isFinal: false } }, ... },
81
88
  * initialData: {}
82
89
  * });
83
- * // message now has parentFiberId: null, definition.metadata: null, etc.
90
+ * // message now has parentFiberId: null, participants: null, definition.metadata: null, etc.
84
91
  * ```
85
92
  */
86
- function normalizeCreateStateMachine(msg) {
93
+ export function normalizeCreateStateMachine(msg) {
87
94
  return {
88
95
  fiberId: msg.fiberId,
89
96
  definition: normalizeDefinition(msg.definition),
90
97
  initialData: msg.initialData ?? {},
91
98
  parentFiberId: msg.parentFiberId ?? null,
99
+ participants: msg.participants ?? null,
92
100
  };
93
101
  }
94
- exports.normalizeCreateStateMachine = normalizeCreateStateMachine;
95
102
  /**
96
103
  * Normalize a TransitionStateMachine message for wire format
97
104
  */
98
- function normalizeTransitionStateMachine(msg) {
105
+ export function normalizeTransitionStateMachine(msg) {
99
106
  return {
100
107
  fiberId: msg.fiberId,
101
108
  eventName: msg.eventName,
@@ -103,17 +110,15 @@ function normalizeTransitionStateMachine(msg) {
103
110
  fiberOrdinal: msg.fiberOrdinal,
104
111
  };
105
112
  }
106
- exports.normalizeTransitionStateMachine = normalizeTransitionStateMachine;
107
113
  /**
108
114
  * Normalize an ArchiveStateMachine message for wire format
109
115
  */
110
- function normalizeArchiveStateMachine(msg) {
116
+ export function normalizeArchiveStateMachine(msg) {
111
117
  return {
112
118
  fiberId: msg.fiberId,
113
119
  reason: msg.reason ?? null,
114
120
  };
115
121
  }
116
- exports.normalizeArchiveStateMachine = normalizeArchiveStateMachine;
117
122
  /**
118
123
  * Normalize any OttochainMessage wrapper for wire format.
119
124
  *
@@ -131,7 +136,7 @@ exports.normalizeArchiveStateMachine = normalizeArchiveStateMachine;
131
136
  * const signed = await signDataUpdate(normalized, privateKey);
132
137
  * ```
133
138
  */
134
- function normalizeMessage(message) {
139
+ export function normalizeMessage(message) {
135
140
  if ('CreateStateMachine' in message) {
136
141
  return { CreateStateMachine: normalizeCreateStateMachine(message.CreateStateMachine) };
137
142
  }
@@ -144,4 +149,3 @@ function normalizeMessage(message) {
144
149
  // CreateScript and InvokeScript — pass through (no optional fields)
145
150
  return message;
146
151
  }
147
- exports.normalizeMessage = normalizeMessage;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Snapshot decoder for ottochain on-chain state
4
3
  *
@@ -10,9 +9,7 @@
10
9
  * @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
11
10
  * @packageDocumentation
12
11
  */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.getScriptInvocations = exports.getEventReceipts = exports.getLogsForFiber = exports.extractOnChainState = exports.getLatestOnChainState = exports.getSnapshotOnChainState = exports.decodeOnChainState = void 0;
15
- const network_1 = require("@constellation-network/metagraph-sdk/network");
12
+ import { HttpClient } from '@constellation-network/metagraph-sdk/network';
16
13
  /**
17
14
  * Decode on-chain state from binary (JsonBinaryCodec format).
18
15
  *
@@ -22,11 +19,10 @@ const network_1 = require("@constellation-network/metagraph-sdk/network");
22
19
  * @param bytes - UTF-8 encoded canonical JSON bytes
23
20
  * @returns Decoded OnChain state
24
21
  */
25
- function decodeOnChainState(bytes) {
22
+ export function decodeOnChainState(bytes) {
26
23
  const json = new TextDecoder().decode(bytes);
27
24
  return JSON.parse(json);
28
25
  }
29
- exports.decodeOnChainState = decodeOnChainState;
30
26
  /**
31
27
  * Fetch and decode the on-chain state from a specific snapshot ordinal.
32
28
  *
@@ -34,28 +30,26 @@ exports.decodeOnChainState = decodeOnChainState;
34
30
  * @param ordinal - Snapshot ordinal number
35
31
  * @returns Decoded OnChain state, or null if no data application part
36
32
  */
37
- async function getSnapshotOnChainState(ml0BaseUrl, ordinal) {
38
- const client = new network_1.HttpClient(ml0BaseUrl);
33
+ export async function getSnapshotOnChainState(ml0BaseUrl, ordinal) {
34
+ const client = new HttpClient(ml0BaseUrl);
39
35
  const snapshot = await client.get(`/snapshots/${ordinal}`);
40
36
  return extractOnChainState(snapshot);
41
37
  }
42
- exports.getSnapshotOnChainState = getSnapshotOnChainState;
43
38
  /**
44
39
  * Fetch and decode the on-chain state from the latest snapshot.
45
40
  *
46
41
  * @param ml0BaseUrl - Metagraph L0 node base URL (e.g., 'http://localhost:9200')
47
42
  * @returns Decoded OnChain state, or null if no data application part
48
43
  */
49
- async function getLatestOnChainState(ml0BaseUrl) {
50
- const client = new network_1.HttpClient(ml0BaseUrl);
44
+ export async function getLatestOnChainState(ml0BaseUrl) {
45
+ const client = new HttpClient(ml0BaseUrl);
51
46
  const snapshot = await client.get('/snapshots/latest');
52
47
  return extractOnChainState(snapshot);
53
48
  }
54
- exports.getLatestOnChainState = getLatestOnChainState;
55
49
  /**
56
50
  * Extract and decode on-chain state from a snapshot response.
57
51
  */
58
- function extractOnChainState(snapshot) {
52
+ export function extractOnChainState(snapshot) {
59
53
  const dataPart = snapshot.value?.dataApplication;
60
54
  if (!dataPart?.onChainState) {
61
55
  return null;
@@ -63,7 +57,6 @@ function extractOnChainState(snapshot) {
63
57
  const bytes = new Uint8Array(dataPart.onChainState);
64
58
  return decodeOnChainState(bytes);
65
59
  }
66
- exports.extractOnChainState = extractOnChainState;
67
60
  // ---------------------------------------------------------------------------
68
61
  // Log filtering helpers
69
62
  // ---------------------------------------------------------------------------
@@ -74,10 +67,9 @@ exports.extractOnChainState = extractOnChainState;
74
67
  * @param fiberId - Fiber UUID to filter by
75
68
  * @returns Array of log entries for the fiber, or empty array
76
69
  */
77
- function getLogsForFiber(onChain, fiberId) {
70
+ export function getLogsForFiber(onChain, fiberId) {
78
71
  return onChain.latestLogs[fiberId] ?? [];
79
72
  }
80
- exports.getLogsForFiber = getLogsForFiber;
81
73
  /**
82
74
  * Get EventReceipt log entries for a specific fiber.
83
75
  *
@@ -88,11 +80,10 @@ exports.getLogsForFiber = getLogsForFiber;
88
80
  * @param fiberId - Fiber UUID to filter by
89
81
  * @returns Array of EventReceipt entries
90
82
  */
91
- function getEventReceipts(onChain, fiberId) {
83
+ export function getEventReceipts(onChain, fiberId) {
92
84
  return getLogsForFiber(onChain, fiberId)
93
85
  .filter((entry) => 'eventName' in entry && 'success' in entry);
94
86
  }
95
- exports.getEventReceipts = getEventReceipts;
96
87
  /**
97
88
  * Get OracleInvocation log entries for a specific fiber.
98
89
  *
@@ -103,8 +94,7 @@ exports.getEventReceipts = getEventReceipts;
103
94
  * @param fiberId - Fiber UUID to filter by
104
95
  * @returns Array of OracleInvocation entries
105
96
  */
106
- function getScriptInvocations(onChain, fiberId) {
97
+ export function getScriptInvocations(onChain, fiberId) {
107
98
  return getLogsForFiber(onChain, fiberId)
108
99
  .filter((entry) => 'method' in entry && 'result' in entry);
109
100
  }
110
- exports.getScriptInvocations = getScriptInvocations;