@ottochain/sdk 1.2.0 → 1.4.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 (103) hide show
  1. package/LICENSE +190 -0
  2. package/dist/cjs/index.js +34 -15
  3. package/dist/cjs/ottochain/index.js +20 -1
  4. package/dist/cjs/ottochain/metagraph-client.js +7 -8
  5. package/dist/cjs/ottochain/snapshot.js +3 -3
  6. package/dist/cjs/{metakit → ottochain}/transaction.js +4 -5
  7. package/dist/cjs/verify.js +17 -0
  8. package/dist/esm/apps/contracts/index.js +28 -10
  9. package/dist/esm/apps/corporate/index.js +79 -24
  10. package/dist/esm/apps/governance/index.js +85 -36
  11. package/dist/esm/apps/identity/constants.js +27 -22
  12. package/dist/esm/apps/identity/index.js +35 -7
  13. package/dist/esm/apps/index.js +32 -6
  14. package/dist/esm/apps/markets/index.js +27 -6
  15. package/dist/esm/apps/oracles/index.js +27 -7
  16. package/dist/esm/errors.js +19 -9
  17. package/dist/esm/generated/google/protobuf/struct.js +39 -33
  18. package/dist/esm/generated/google/protobuf/timestamp.js +9 -6
  19. package/dist/esm/generated/index.js +134 -10
  20. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +54 -48
  21. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +357 -335
  22. package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +299 -284
  23. package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +47 -38
  24. package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +50 -44
  25. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +86 -77
  26. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +72 -66
  27. package/dist/esm/generated/ottochain/v1/common.js +4 -1
  28. package/dist/esm/generated/ottochain/v1/fiber.js +96 -90
  29. package/dist/esm/generated/ottochain/v1/messages.js +82 -79
  30. package/dist/esm/generated/ottochain/v1/records.js +140 -137
  31. package/dist/esm/index.js +86 -20
  32. package/dist/esm/{metakit → ottochain}/drop-nulls.js +5 -1
  33. package/dist/esm/ottochain/index.js +56 -3
  34. package/dist/esm/ottochain/metagraph-client.js +16 -13
  35. package/dist/esm/{metakit → ottochain}/normalize.js +11 -4
  36. package/dist/esm/ottochain/snapshot.js +20 -10
  37. package/dist/esm/{metakit → ottochain}/transaction.js +25 -14
  38. package/dist/esm/ottochain/types.js +2 -1
  39. package/dist/esm/types.js +7 -2
  40. package/dist/esm/validation.js +76 -65
  41. package/dist/esm/verify.js +17 -0
  42. package/dist/types/index.d.ts +14 -7
  43. package/dist/types/ottochain/index.d.ts +4 -0
  44. package/dist/types/ottochain/metagraph-client.d.ts +1 -1
  45. package/dist/types/{metakit → ottochain}/transaction.d.ts +1 -1
  46. package/dist/types/validation.d.ts +8 -8
  47. package/dist/types/verify.d.ts +9 -0
  48. package/package.json +5 -3
  49. package/dist/cjs/metakit/binary.js +0 -58
  50. package/dist/cjs/metakit/canonicalize.js +0 -40
  51. package/dist/cjs/metakit/codec.js +0 -45
  52. package/dist/cjs/metakit/currency-transaction.js +0 -319
  53. package/dist/cjs/metakit/currency-types.js +0 -13
  54. package/dist/cjs/metakit/hash.js +0 -84
  55. package/dist/cjs/metakit/index.js +0 -86
  56. package/dist/cjs/metakit/network/client.js +0 -78
  57. package/dist/cjs/metakit/network/currency-l1-client.js +0 -101
  58. package/dist/cjs/metakit/network/data-l1-client.js +0 -76
  59. package/dist/cjs/metakit/network/index.js +0 -16
  60. package/dist/cjs/metakit/network/types.js +0 -20
  61. package/dist/cjs/metakit/sign.js +0 -120
  62. package/dist/cjs/metakit/signed-object.js +0 -100
  63. package/dist/cjs/metakit/types.js +0 -14
  64. package/dist/cjs/metakit/verify.js +0 -217
  65. package/dist/cjs/metakit/wallet.js +0 -127
  66. package/dist/esm/metakit/binary.js +0 -53
  67. package/dist/esm/metakit/canonicalize.js +0 -33
  68. package/dist/esm/metakit/codec.js +0 -38
  69. package/dist/esm/metakit/currency-transaction.js +0 -306
  70. package/dist/esm/metakit/currency-types.js +0 -10
  71. package/dist/esm/metakit/hash.js +0 -77
  72. package/dist/esm/metakit/index.js +0 -33
  73. package/dist/esm/metakit/network/client.js +0 -74
  74. package/dist/esm/metakit/network/currency-l1-client.js +0 -97
  75. package/dist/esm/metakit/network/data-l1-client.js +0 -72
  76. package/dist/esm/metakit/network/index.js +0 -9
  77. package/dist/esm/metakit/network/types.js +0 -16
  78. package/dist/esm/metakit/sign.js +0 -114
  79. package/dist/esm/metakit/signed-object.js +0 -94
  80. package/dist/esm/metakit/types.js +0 -11
  81. package/dist/esm/metakit/verify.js +0 -210
  82. package/dist/esm/metakit/wallet.js +0 -117
  83. package/dist/types/metakit/binary.d.ts +0 -38
  84. package/dist/types/metakit/canonicalize.d.ts +0 -26
  85. package/dist/types/metakit/codec.d.ts +0 -16
  86. package/dist/types/metakit/currency-transaction.d.ts +0 -157
  87. package/dist/types/metakit/currency-types.d.ts +0 -55
  88. package/dist/types/metakit/hash.d.ts +0 -50
  89. package/dist/types/metakit/index.d.ts +0 -26
  90. package/dist/types/metakit/network/client.d.ts +0 -23
  91. package/dist/types/metakit/network/currency-l1-client.d.ts +0 -71
  92. package/dist/types/metakit/network/data-l1-client.d.ts +0 -57
  93. package/dist/types/metakit/network/index.d.ts +0 -10
  94. package/dist/types/metakit/network/types.d.ts +0 -74
  95. package/dist/types/metakit/sign.d.ts +0 -65
  96. package/dist/types/metakit/signed-object.d.ts +0 -66
  97. package/dist/types/metakit/types.d.ts +0 -67
  98. package/dist/types/metakit/verify.d.ts +0 -55
  99. package/dist/types/metakit/wallet.d.ts +0 -70
  100. /package/dist/cjs/{metakit → ottochain}/drop-nulls.js +0 -0
  101. /package/dist/cjs/{metakit → ottochain}/normalize.js +0 -0
  102. /package/dist/types/{metakit → ottochain}/drop-nulls.d.ts +0 -0
  103. /package/dist/types/{metakit → ottochain}/normalize.d.ts +0 -0
package/dist/esm/index.js CHANGED
@@ -1,10 +1,13 @@
1
+ "use strict";
1
2
  /**
2
3
  * Ottochain SDK
3
4
  *
4
- * Unified SDK combining metakit framework operations with ottochain domain types.
5
+ * Unified SDK combining @constellation-network/metagraph-sdk with OttoChain domain types.
5
6
  *
6
7
  * Structure:
7
- * - `metakit`Signing, encoding, hashing, and network clients for Constellation metagraphs
8
+ * - `@constellation-network/metagraph-sdk` — Core signing, hashing, encoding, wallet, currency transactions
9
+ * - `@constellation-network/metagraph-sdk/network` — HttpClient, MetagraphClient, NetworkError
10
+ * - `ottochain` — OttoChain-specific transaction helpers, types, snapshot, and client
8
11
  * - `generated` — Protobuf-generated types (source of truth)
9
12
  * - `apps/identity` — Agent Identity application types
10
13
  * - `apps/contracts` — Contract application types
@@ -13,23 +16,86 @@
13
16
  *
14
17
  * @packageDocumentation
15
18
  */
16
- // Type aliases for semantic clarity (matches wire format)
17
- export * from './types.js';
18
- // Metakit utilities (signing, hashing, HTTP client)
19
- export * from './metakit/index.js';
20
- // Generated protobuf types (canonical definitions)
21
- export * from './generated/index.js';
22
- // Custom error classes
23
- export { OttoChainError, NetworkError, ValidationError, SigningError, TransactionError, ErrorCode, isErrorCode, wrapError, } from './errors.js';
24
- // Validation schemas and helpers
25
- export {
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
+ // ─── Core metagraph SDK ───────────────────────────────────────────────────────
36
+ // Consumers can also import directly from '@constellation-network/metagraph-sdk'
37
+ __exportStar(require("@constellation-network/metagraph-sdk"), exports);
38
+ // Override verify — package embeds `mode` in signed objects and ignores isDataUpdate
39
+ // 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; } });
42
+ // ─── Network clients ──────────────────────────────────────────────────────────
43
+ // 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; } });
49
+ // ─── Type aliases for semantic clarity (matches wire format) ──────────────────
50
+ __exportStar(require("./types.js"), exports);
51
+ // ─── 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; } });
60
+ // ─── Generated protobuf types (canonical definitions) ────────────────────────
61
+ __exportStar(require("./generated/index.js"), exports);
62
+ // ─── 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; } });
72
+ // ─── Validation schemas and helpers ──────────────────────────────────────────
73
+ var validation_js_1 = require("./validation.js");
26
74
  // Schemas
27
- DagAddressSchema, PrivateKeySchema, PublicKeySchema, KeyPairSchema, SignatureProofSchema, SignedSchema, TransactionReferenceSchema, CurrencyTransactionValueSchema, CurrencyTransactionSchema, TransferParamsSchema, AgentIdentityRegistrationSchema, PlatformLinkSchema, ContractTermsSchema, ProposeContractRequestSchema, AcceptContractRequestSchema, CompleteContractRequestSchema,
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; } });
28
91
  // Helpers
29
- validate, validatePrivateKey, validatePublicKey, validateAddress, validateKeyPair, safeParse, assert, } from './validation.js';
30
- // Error classes
31
- export * from './errors.js';
32
- // Validation schemas and helpers
33
- export * from './validation.js';
34
- // Ottochain metagraph client
35
- export { MetagraphClient } from './ottochain/metagraph-client.js';
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; } });
99
+ // ─── 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; } });
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Drop Null Values from JSON Objects
3
4
  *
@@ -11,6 +12,8 @@
11
12
  * Note: null values inside arrays are preserved (to maintain index
12
13
  * positions). Only object field values that are null are removed.
13
14
  */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.dropNulls = void 0;
14
17
  /**
15
18
  * Recursively remove null values from objects
16
19
  *
@@ -26,7 +29,7 @@
26
29
  * // => [1, null, 3] (array nulls preserved)
27
30
  * ```
28
31
  */
29
- export function dropNulls(value) {
32
+ function dropNulls(value) {
30
33
  if (value === null || value === undefined) {
31
34
  return value;
32
35
  }
@@ -44,3 +47,4 @@ export function dropNulls(value) {
44
47
  }
45
48
  return value;
46
49
  }
50
+ exports.dropNulls = dropNulls;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Ottochain SDK
3
4
  *
@@ -5,9 +6,61 @@
5
6
  *
6
7
  * @packageDocumentation
7
8
  */
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;
8
34
  // Re-export generated protobuf types (for binary encoding)
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';
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; } });
46
+ // 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; } });
57
+ // 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; } });
12
65
  // Note: Governance and Corporate types are now in src/apps/
13
66
  // Import from '@ottochain/sdk/apps' instead
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Ottochain Metagraph Client
3
4
  *
@@ -8,10 +9,11 @@
8
9
  * @see modules/data_l1/src/main/scala/xyz/kd5ujc/data_l1/DataL1CustomRoutes.scala
9
10
  * @packageDocumentation
10
11
  */
11
- import { createDataTransactionRequest } from '../metakit/transaction.js';
12
- import { HttpClient } from '../metakit/network/client.js';
13
- import { NetworkError } from '../metakit/network/types.js';
14
- import { extractOnChainState } from './snapshot.js';
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");
15
17
  /**
16
18
  * Client for ottochain metagraph operations.
17
19
  *
@@ -35,15 +37,15 @@ import { extractOnChainState } from './snapshot.js';
35
37
  * const events = await client.getStateMachineEvents(fiberId);
36
38
  * ```
37
39
  */
38
- export class MetagraphClient {
40
+ class MetagraphClient {
39
41
  constructor(config) {
40
- this.ml0 = new HttpClient(config.ml0Url, config.timeout);
42
+ this.ml0 = new network_1.HttpClient(config.ml0Url, config.timeout);
41
43
  if (config.dl1Url) {
42
- this.dl1 = new HttpClient(config.dl1Url, config.timeout);
44
+ this.dl1 = new network_1.HttpClient(config.dl1Url, config.timeout);
43
45
  }
44
46
  // Build DL1 client pool from dl1Urls (falls back to dl1Url if provided)
45
47
  const urls = config.dl1Urls ?? (config.dl1Url ? [config.dl1Url] : []);
46
- this.dl1Clients = urls.map((url) => new HttpClient(url, config.timeout));
48
+ this.dl1Clients = urls.map((url) => new network_1.HttpClient(url, config.timeout));
47
49
  }
48
50
  // -------------------------------------------------------------------------
49
51
  // Custom routes (ML0 /data-application/v1/*)
@@ -75,7 +77,7 @@ export class MetagraphClient {
75
77
  return await this.ml0.get(`/data-application/v1/state-machines/${fiberId}`);
76
78
  }
77
79
  catch (error) {
78
- if (error instanceof NetworkError && error.statusCode === 404) {
80
+ if (error instanceof network_1.NetworkError && error.statusCode === 404) {
79
81
  return null;
80
82
  }
81
83
  throw error;
@@ -102,7 +104,7 @@ export class MetagraphClient {
102
104
  return await this.ml0.get(`/data-application/v1/oracles/${scriptId}`);
103
105
  }
104
106
  catch (error) {
105
- if (error instanceof NetworkError && error.statusCode === 404) {
107
+ if (error instanceof network_1.NetworkError && error.statusCode === 404) {
106
108
  return null;
107
109
  }
108
110
  throw error;
@@ -122,14 +124,14 @@ export class MetagraphClient {
122
124
  */
123
125
  async getLatestSnapshotOnChainState() {
124
126
  const snapshot = await this.ml0.get('/snapshots/latest');
125
- return extractOnChainState(snapshot);
127
+ return (0, snapshot_js_1.extractOnChainState)(snapshot);
126
128
  }
127
129
  /**
128
130
  * Get a snapshot by ordinal and decode its on-chain state.
129
131
  */
130
132
  async getSnapshotOnChainState(ordinal) {
131
133
  const snapshot = await this.ml0.get(`/snapshots/${ordinal}`);
132
- return extractOnChainState(snapshot);
134
+ return (0, snapshot_js_1.extractOnChainState)(snapshot);
133
135
  }
134
136
  /**
135
137
  * Get the latest snapshot ordinal.
@@ -326,7 +328,7 @@ export class MetagraphClient {
326
328
  if (this.dl1Clients.length === 0) {
327
329
  throw new Error('dl1Url or dl1Urls is required for submitData');
328
330
  }
329
- const request = createDataTransactionRequest(signed);
331
+ const request = (0, transaction_js_1.createDataTransactionRequest)(signed);
330
332
  if (this.dl1Clients.length === 1) {
331
333
  return this.dl1Clients[0].post('/data', request);
332
334
  }
@@ -350,3 +352,4 @@ export class MetagraphClient {
350
352
  });
351
353
  }
352
354
  }
355
+ exports.MetagraphClient = MetagraphClient;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Normalize OttoChain Messages for Signing
3
4
  *
@@ -17,6 +18,8 @@
17
18
  * - `List.empty` → `[]`
18
19
  * - `Map.empty` → `{}`
19
20
  */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.normalizeMessage = exports.normalizeArchiveStateMachine = exports.normalizeTransitionStateMachine = exports.normalizeCreateStateMachine = void 0;
20
23
  /**
21
24
  * Normalize a State object for wire format
22
25
  */
@@ -80,7 +83,7 @@ function normalizeDefinition(def) {
80
83
  * // message now has parentFiberId: null, definition.metadata: null, etc.
81
84
  * ```
82
85
  */
83
- export function normalizeCreateStateMachine(msg) {
86
+ function normalizeCreateStateMachine(msg) {
84
87
  return {
85
88
  fiberId: msg.fiberId,
86
89
  definition: normalizeDefinition(msg.definition),
@@ -88,10 +91,11 @@ export function normalizeCreateStateMachine(msg) {
88
91
  parentFiberId: msg.parentFiberId ?? null,
89
92
  };
90
93
  }
94
+ exports.normalizeCreateStateMachine = normalizeCreateStateMachine;
91
95
  /**
92
96
  * Normalize a TransitionStateMachine message for wire format
93
97
  */
94
- export function normalizeTransitionStateMachine(msg) {
98
+ function normalizeTransitionStateMachine(msg) {
95
99
  return {
96
100
  fiberId: msg.fiberId,
97
101
  eventName: msg.eventName,
@@ -99,15 +103,17 @@ export function normalizeTransitionStateMachine(msg) {
99
103
  fiberOrdinal: msg.fiberOrdinal,
100
104
  };
101
105
  }
106
+ exports.normalizeTransitionStateMachine = normalizeTransitionStateMachine;
102
107
  /**
103
108
  * Normalize an ArchiveStateMachine message for wire format
104
109
  */
105
- export function normalizeArchiveStateMachine(msg) {
110
+ function normalizeArchiveStateMachine(msg) {
106
111
  return {
107
112
  fiberId: msg.fiberId,
108
113
  reason: msg.reason ?? null,
109
114
  };
110
115
  }
116
+ exports.normalizeArchiveStateMachine = normalizeArchiveStateMachine;
111
117
  /**
112
118
  * Normalize any OttochainMessage wrapper for wire format.
113
119
  *
@@ -125,7 +131,7 @@ export function normalizeArchiveStateMachine(msg) {
125
131
  * const signed = await signDataUpdate(normalized, privateKey);
126
132
  * ```
127
133
  */
128
- export function normalizeMessage(message) {
134
+ function normalizeMessage(message) {
129
135
  if ('CreateStateMachine' in message) {
130
136
  return { CreateStateMachine: normalizeCreateStateMachine(message.CreateStateMachine) };
131
137
  }
@@ -138,3 +144,4 @@ export function normalizeMessage(message) {
138
144
  // CreateScript and InvokeScript — pass through (no optional fields)
139
145
  return message;
140
146
  }
147
+ exports.normalizeMessage = normalizeMessage;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Snapshot decoder for ottochain on-chain state
3
4
  *
@@ -9,7 +10,9 @@
9
10
  * @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
10
11
  * @packageDocumentation
11
12
  */
12
- import { HttpClient } from '../metakit/network/client.js';
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");
13
16
  /**
14
17
  * Decode on-chain state from binary (JsonBinaryCodec format).
15
18
  *
@@ -19,10 +22,11 @@ import { HttpClient } from '../metakit/network/client.js';
19
22
  * @param bytes - UTF-8 encoded canonical JSON bytes
20
23
  * @returns Decoded OnChain state
21
24
  */
22
- export function decodeOnChainState(bytes) {
25
+ function decodeOnChainState(bytes) {
23
26
  const json = new TextDecoder().decode(bytes);
24
27
  return JSON.parse(json);
25
28
  }
29
+ exports.decodeOnChainState = decodeOnChainState;
26
30
  /**
27
31
  * Fetch and decode the on-chain state from a specific snapshot ordinal.
28
32
  *
@@ -30,26 +34,28 @@ export function decodeOnChainState(bytes) {
30
34
  * @param ordinal - Snapshot ordinal number
31
35
  * @returns Decoded OnChain state, or null if no data application part
32
36
  */
33
- export async function getSnapshotOnChainState(ml0BaseUrl, ordinal) {
34
- const client = new HttpClient(ml0BaseUrl);
37
+ async function getSnapshotOnChainState(ml0BaseUrl, ordinal) {
38
+ const client = new network_1.HttpClient(ml0BaseUrl);
35
39
  const snapshot = await client.get(`/snapshots/${ordinal}`);
36
40
  return extractOnChainState(snapshot);
37
41
  }
42
+ exports.getSnapshotOnChainState = getSnapshotOnChainState;
38
43
  /**
39
44
  * Fetch and decode the on-chain state from the latest snapshot.
40
45
  *
41
46
  * @param ml0BaseUrl - Metagraph L0 node base URL (e.g., 'http://localhost:9200')
42
47
  * @returns Decoded OnChain state, or null if no data application part
43
48
  */
44
- export async function getLatestOnChainState(ml0BaseUrl) {
45
- const client = new HttpClient(ml0BaseUrl);
49
+ async function getLatestOnChainState(ml0BaseUrl) {
50
+ const client = new network_1.HttpClient(ml0BaseUrl);
46
51
  const snapshot = await client.get('/snapshots/latest');
47
52
  return extractOnChainState(snapshot);
48
53
  }
54
+ exports.getLatestOnChainState = getLatestOnChainState;
49
55
  /**
50
56
  * Extract and decode on-chain state from a snapshot response.
51
57
  */
52
- export function extractOnChainState(snapshot) {
58
+ function extractOnChainState(snapshot) {
53
59
  const dataPart = snapshot.value?.dataApplication;
54
60
  if (!dataPart?.onChainState) {
55
61
  return null;
@@ -57,6 +63,7 @@ export function extractOnChainState(snapshot) {
57
63
  const bytes = new Uint8Array(dataPart.onChainState);
58
64
  return decodeOnChainState(bytes);
59
65
  }
66
+ exports.extractOnChainState = extractOnChainState;
60
67
  // ---------------------------------------------------------------------------
61
68
  // Log filtering helpers
62
69
  // ---------------------------------------------------------------------------
@@ -67,9 +74,10 @@ export function extractOnChainState(snapshot) {
67
74
  * @param fiberId - Fiber UUID to filter by
68
75
  * @returns Array of log entries for the fiber, or empty array
69
76
  */
70
- export function getLogsForFiber(onChain, fiberId) {
77
+ function getLogsForFiber(onChain, fiberId) {
71
78
  return onChain.latestLogs[fiberId] ?? [];
72
79
  }
80
+ exports.getLogsForFiber = getLogsForFiber;
73
81
  /**
74
82
  * Get EventReceipt log entries for a specific fiber.
75
83
  *
@@ -80,10 +88,11 @@ export function getLogsForFiber(onChain, fiberId) {
80
88
  * @param fiberId - Fiber UUID to filter by
81
89
  * @returns Array of EventReceipt entries
82
90
  */
83
- export function getEventReceipts(onChain, fiberId) {
91
+ function getEventReceipts(onChain, fiberId) {
84
92
  return getLogsForFiber(onChain, fiberId)
85
93
  .filter((entry) => 'eventName' in entry && 'success' in entry);
86
94
  }
95
+ exports.getEventReceipts = getEventReceipts;
87
96
  /**
88
97
  * Get OracleInvocation log entries for a specific fiber.
89
98
  *
@@ -94,7 +103,8 @@ export function getEventReceipts(onChain, fiberId) {
94
103
  * @param fiberId - Fiber UUID to filter by
95
104
  * @returns Array of OracleInvocation entries
96
105
  */
97
- export function getScriptInvocations(onChain, fiberId) {
106
+ function getScriptInvocations(onChain, fiberId) {
98
107
  return getLogsForFiber(onChain, fiberId)
99
108
  .filter((entry) => 'method' in entry && 'result' in entry);
100
109
  }
110
+ exports.getScriptInvocations = getScriptInvocations;
@@ -1,11 +1,13 @@
1
+ "use strict";
1
2
  /**
2
3
  * Transaction Helpers for Self-Signed Mode
3
4
  *
4
5
  * These helpers create properly formatted payloads for the bridge's
5
6
  * self-signed mode, where clients sign their own transactions.
6
7
  */
7
- import { signDataUpdate } from './sign.js';
8
- import { getPublicKeyId } from './wallet.js';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getPublicKeyForRegistration = exports.addTransactionSignature = exports.createDataTransactionRequest = exports.signTransaction = exports.createInvokeScriptPayload = exports.createScriptPayload = exports.createArchivePayload = exports.createTransitionPayload = exports.createStateMachinePayload = void 0;
10
+ const metagraph_sdk_1 = require("@constellation-network/metagraph-sdk");
9
11
  /**
10
12
  * Create a new state machine fiber payload.
11
13
  *
@@ -25,7 +27,7 @@ import { getPublicKeyId } from './wallet.js';
25
27
  * const signed = await signTransaction(create, privateKey);
26
28
  * ```
27
29
  */
28
- export function createStateMachinePayload(params) {
30
+ function createStateMachinePayload(params) {
29
31
  return {
30
32
  CreateStateMachine: {
31
33
  fiberId: params.fiberId,
@@ -35,6 +37,7 @@ export function createStateMachinePayload(params) {
35
37
  },
36
38
  };
37
39
  }
40
+ exports.createStateMachinePayload = createStateMachinePayload;
38
41
  /**
39
42
  * Create a transition payload ready for signing.
40
43
  *
@@ -53,7 +56,7 @@ export function createStateMachinePayload(params) {
53
56
  * });
54
57
  * ```
55
58
  */
56
- export function createTransitionPayload(params) {
59
+ function createTransitionPayload(params) {
57
60
  return {
58
61
  TransitionStateMachine: {
59
62
  fiberId: params.fiberId,
@@ -63,13 +66,14 @@ export function createTransitionPayload(params) {
63
66
  },
64
67
  };
65
68
  }
69
+ exports.createTransitionPayload = createTransitionPayload;
66
70
  /**
67
71
  * Create an archive payload ready for signing.
68
72
  *
69
73
  * @param params - Archive parameters
70
74
  * @returns An ArchiveStateMachine message ready for signing
71
75
  */
72
- export function createArchivePayload(params) {
76
+ function createArchivePayload(params) {
73
77
  return {
74
78
  ArchiveStateMachine: {
75
79
  fiberId: params.fiberId,
@@ -77,6 +81,7 @@ export function createArchivePayload(params) {
77
81
  },
78
82
  };
79
83
  }
84
+ exports.createArchivePayload = createArchivePayload;
80
85
  /**
81
86
  * Create a new script fiber payload.
82
87
  *
@@ -100,7 +105,7 @@ export function createArchivePayload(params) {
100
105
  * const signed = await signTransaction(script, privateKey);
101
106
  * ```
102
107
  */
103
- export function createScriptPayload(params) {
108
+ function createScriptPayload(params) {
104
109
  return {
105
110
  CreateScript: {
106
111
  fiberId: params.fiberId,
@@ -110,13 +115,14 @@ export function createScriptPayload(params) {
110
115
  },
111
116
  };
112
117
  }
118
+ exports.createScriptPayload = createScriptPayload;
113
119
  /**
114
120
  * Create an invoke script payload ready for signing.
115
121
  *
116
122
  * @param params - Invoke script parameters
117
123
  * @returns An InvokeScript message ready for signing
118
124
  */
119
- export function createInvokeScriptPayload(params) {
125
+ function createInvokeScriptPayload(params) {
120
126
  return {
121
127
  InvokeScript: {
122
128
  fiberId: params.fiberId,
@@ -126,6 +132,7 @@ export function createInvokeScriptPayload(params) {
126
132
  },
127
133
  };
128
134
  }
135
+ exports.createInvokeScriptPayload = createInvokeScriptPayload;
129
136
  /**
130
137
  * Sign a transaction payload for self-signed mode.
131
138
  *
@@ -163,13 +170,14 @@ export function createInvokeScriptPayload(params) {
163
170
  * });
164
171
  * ```
165
172
  */
166
- export async function signTransaction(message, privateKey) {
167
- const proof = await signDataUpdate(message, privateKey);
173
+ async function signTransaction(message, privateKey) {
174
+ const proof = await (0, metagraph_sdk_1.signDataUpdate)(message, privateKey);
168
175
  return {
169
176
  value: message,
170
177
  proofs: [proof],
171
178
  };
172
179
  }
180
+ exports.signTransaction = signTransaction;
173
181
  /**
174
182
  * Wrap a signed transaction in the DataTransactionRequest format
175
183
  * expected by tessellation's DL1 `/data` endpoint.
@@ -191,9 +199,10 @@ export async function signTransaction(message, privateKey) {
191
199
  * });
192
200
  * ```
193
201
  */
194
- export function createDataTransactionRequest(signed) {
202
+ function createDataTransactionRequest(signed) {
195
203
  return { data: signed, fee: null };
196
204
  }
205
+ exports.createDataTransactionRequest = createDataTransactionRequest;
197
206
  /**
198
207
  * Add an additional signature to a signed transaction.
199
208
  *
@@ -204,13 +213,14 @@ export function createDataTransactionRequest(signed) {
204
213
  * @param privateKey - Additional signer's private key
205
214
  * @returns Transaction with additional signature
206
215
  */
207
- export async function addTransactionSignature(signed, privateKey) {
208
- const newProof = await signDataUpdate(signed.value, privateKey);
216
+ async function addTransactionSignature(signed, privateKey) {
217
+ const newProof = await (0, metagraph_sdk_1.signDataUpdate)(signed.value, privateKey);
209
218
  return {
210
219
  value: signed.value,
211
220
  proofs: [...signed.proofs, newProof],
212
221
  };
213
222
  }
223
+ exports.addTransactionSignature = addTransactionSignature;
214
224
  /**
215
225
  * Get the public key ID from a private key in the format expected by registration.
216
226
  *
@@ -235,6 +245,7 @@ export async function addTransactionSignature(signed, privateKey) {
235
245
  * });
236
246
  * ```
237
247
  */
238
- export function getPublicKeyForRegistration(privateKey) {
239
- return getPublicKeyId(privateKey);
248
+ function getPublicKeyForRegistration(privateKey) {
249
+ return (0, metagraph_sdk_1.getPublicKeyId)(privateKey);
240
250
  }
251
+ exports.getPublicKeyForRegistration = getPublicKeyForRegistration;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Ottochain-specific type definitions
3
4
  *
@@ -7,4 +8,4 @@
7
8
  * @see modules/models/src/main/scala/xyz/kd5ujc/schema/
8
9
  * @packageDocumentation
9
10
  */
10
- export {};
11
+ Object.defineProperty(exports, "__esModule", { value: true });