@ottochain/sdk 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/esm/apps/contracts/index.js +10 -28
- package/dist/esm/apps/corporate/index.js +24 -79
- package/dist/esm/apps/governance/index.js +36 -85
- package/dist/esm/apps/identity/constants.js +22 -27
- package/dist/esm/apps/identity/index.js +7 -35
- package/dist/esm/apps/index.js +6 -32
- package/dist/esm/apps/markets/index.js +6 -27
- package/dist/esm/apps/oracles/index.js +7 -27
- package/dist/esm/errors.js +9 -19
- package/dist/esm/generated/google/protobuf/struct.js +33 -39
- package/dist/esm/generated/google/protobuf/timestamp.js +6 -9
- package/dist/esm/generated/index.js +10 -134
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +48 -54
- package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +335 -357
- package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +284 -299
- package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +38 -47
- package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +44 -50
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +77 -86
- package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +66 -72
- package/dist/esm/generated/ottochain/v1/common.js +1 -4
- package/dist/esm/generated/ottochain/v1/fiber.js +90 -96
- package/dist/esm/generated/ottochain/v1/messages.js +79 -82
- package/dist/esm/generated/ottochain/v1/records.js +137 -140
- package/dist/esm/index.js +13 -70
- package/dist/esm/ottochain/drop-nulls.js +1 -5
- package/dist/esm/ottochain/index.js +6 -54
- package/dist/esm/ottochain/metagraph-client.js +12 -16
- package/dist/esm/ottochain/normalize.js +4 -11
- package/dist/esm/ottochain/snapshot.js +10 -20
- package/dist/esm/ottochain/transaction.js +13 -25
- package/dist/esm/ottochain/types.js +1 -2
- package/dist/esm/types.js +2 -7
- package/dist/esm/validation.js +65 -76
- package/dist/esm/verify.js +3 -7
- package/package.json +21 -17
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
28
|
+
export * from './types.js';
|
|
51
29
|
// ─── OttoChain-specific transaction helpers ───────────────────────────────────
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
34
|
+
export * from './generated/index.js';
|
|
62
35
|
// ─── Custom error classes ─────────────────────────────────────────────────────
|
|
63
|
-
|
|
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
|
-
|
|
38
|
+
export {
|
|
74
39
|
// Schemas
|
|
75
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
39
|
+
this.ml0 = new HttpClient(config.ml0Url, config.timeout);
|
|
43
40
|
if (config.dl1Url) {
|
|
44
|
-
this.dl1 = new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
*/
|
|
@@ -83,7 +80,7 @@ function normalizeDefinition(def) {
|
|
|
83
80
|
* // message now has parentFiberId: null, definition.metadata: null, etc.
|
|
84
81
|
* ```
|
|
85
82
|
*/
|
|
86
|
-
function normalizeCreateStateMachine(msg) {
|
|
83
|
+
export function normalizeCreateStateMachine(msg) {
|
|
87
84
|
return {
|
|
88
85
|
fiberId: msg.fiberId,
|
|
89
86
|
definition: normalizeDefinition(msg.definition),
|
|
@@ -91,11 +88,10 @@ function normalizeCreateStateMachine(msg) {
|
|
|
91
88
|
parentFiberId: msg.parentFiberId ?? null,
|
|
92
89
|
};
|
|
93
90
|
}
|
|
94
|
-
exports.normalizeCreateStateMachine = normalizeCreateStateMachine;
|
|
95
91
|
/**
|
|
96
92
|
* Normalize a TransitionStateMachine message for wire format
|
|
97
93
|
*/
|
|
98
|
-
function normalizeTransitionStateMachine(msg) {
|
|
94
|
+
export function normalizeTransitionStateMachine(msg) {
|
|
99
95
|
return {
|
|
100
96
|
fiberId: msg.fiberId,
|
|
101
97
|
eventName: msg.eventName,
|
|
@@ -103,17 +99,15 @@ function normalizeTransitionStateMachine(msg) {
|
|
|
103
99
|
fiberOrdinal: msg.fiberOrdinal,
|
|
104
100
|
};
|
|
105
101
|
}
|
|
106
|
-
exports.normalizeTransitionStateMachine = normalizeTransitionStateMachine;
|
|
107
102
|
/**
|
|
108
103
|
* Normalize an ArchiveStateMachine message for wire format
|
|
109
104
|
*/
|
|
110
|
-
function normalizeArchiveStateMachine(msg) {
|
|
105
|
+
export function normalizeArchiveStateMachine(msg) {
|
|
111
106
|
return {
|
|
112
107
|
fiberId: msg.fiberId,
|
|
113
108
|
reason: msg.reason ?? null,
|
|
114
109
|
};
|
|
115
110
|
}
|
|
116
|
-
exports.normalizeArchiveStateMachine = normalizeArchiveStateMachine;
|
|
117
111
|
/**
|
|
118
112
|
* Normalize any OttochainMessage wrapper for wire format.
|
|
119
113
|
*
|
|
@@ -131,7 +125,7 @@ exports.normalizeArchiveStateMachine = normalizeArchiveStateMachine;
|
|
|
131
125
|
* const signed = await signDataUpdate(normalized, privateKey);
|
|
132
126
|
* ```
|
|
133
127
|
*/
|
|
134
|
-
function normalizeMessage(message) {
|
|
128
|
+
export function normalizeMessage(message) {
|
|
135
129
|
if ('CreateStateMachine' in message) {
|
|
136
130
|
return { CreateStateMachine: normalizeCreateStateMachine(message.CreateStateMachine) };
|
|
137
131
|
}
|
|
@@ -144,4 +138,3 @@ function normalizeMessage(message) {
|
|
|
144
138
|
// CreateScript and InvokeScript — pass through (no optional fields)
|
|
145
139
|
return message;
|
|
146
140
|
}
|
|
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
|
-
|
|
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
|
|
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
|
|
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;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Transaction Helpers for Self-Signed Mode
|
|
4
3
|
*
|
|
5
4
|
* These helpers create properly formatted payloads for the bridge's
|
|
6
5
|
* self-signed mode, where clients sign their own transactions.
|
|
7
6
|
*/
|
|
8
|
-
|
|
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");
|
|
7
|
+
import { signDataUpdate, getPublicKeyId } from '@constellation-network/metagraph-sdk';
|
|
11
8
|
/**
|
|
12
9
|
* Create a new state machine fiber payload.
|
|
13
10
|
*
|
|
@@ -27,7 +24,7 @@ const metagraph_sdk_1 = require("@constellation-network/metagraph-sdk");
|
|
|
27
24
|
* const signed = await signTransaction(create, privateKey);
|
|
28
25
|
* ```
|
|
29
26
|
*/
|
|
30
|
-
function createStateMachinePayload(params) {
|
|
27
|
+
export function createStateMachinePayload(params) {
|
|
31
28
|
return {
|
|
32
29
|
CreateStateMachine: {
|
|
33
30
|
fiberId: params.fiberId,
|
|
@@ -37,7 +34,6 @@ function createStateMachinePayload(params) {
|
|
|
37
34
|
},
|
|
38
35
|
};
|
|
39
36
|
}
|
|
40
|
-
exports.createStateMachinePayload = createStateMachinePayload;
|
|
41
37
|
/**
|
|
42
38
|
* Create a transition payload ready for signing.
|
|
43
39
|
*
|
|
@@ -56,7 +52,7 @@ exports.createStateMachinePayload = createStateMachinePayload;
|
|
|
56
52
|
* });
|
|
57
53
|
* ```
|
|
58
54
|
*/
|
|
59
|
-
function createTransitionPayload(params) {
|
|
55
|
+
export function createTransitionPayload(params) {
|
|
60
56
|
return {
|
|
61
57
|
TransitionStateMachine: {
|
|
62
58
|
fiberId: params.fiberId,
|
|
@@ -66,14 +62,13 @@ function createTransitionPayload(params) {
|
|
|
66
62
|
},
|
|
67
63
|
};
|
|
68
64
|
}
|
|
69
|
-
exports.createTransitionPayload = createTransitionPayload;
|
|
70
65
|
/**
|
|
71
66
|
* Create an archive payload ready for signing.
|
|
72
67
|
*
|
|
73
68
|
* @param params - Archive parameters
|
|
74
69
|
* @returns An ArchiveStateMachine message ready for signing
|
|
75
70
|
*/
|
|
76
|
-
function createArchivePayload(params) {
|
|
71
|
+
export function createArchivePayload(params) {
|
|
77
72
|
return {
|
|
78
73
|
ArchiveStateMachine: {
|
|
79
74
|
fiberId: params.fiberId,
|
|
@@ -81,7 +76,6 @@ function createArchivePayload(params) {
|
|
|
81
76
|
},
|
|
82
77
|
};
|
|
83
78
|
}
|
|
84
|
-
exports.createArchivePayload = createArchivePayload;
|
|
85
79
|
/**
|
|
86
80
|
* Create a new script fiber payload.
|
|
87
81
|
*
|
|
@@ -105,7 +99,7 @@ exports.createArchivePayload = createArchivePayload;
|
|
|
105
99
|
* const signed = await signTransaction(script, privateKey);
|
|
106
100
|
* ```
|
|
107
101
|
*/
|
|
108
|
-
function createScriptPayload(params) {
|
|
102
|
+
export function createScriptPayload(params) {
|
|
109
103
|
return {
|
|
110
104
|
CreateScript: {
|
|
111
105
|
fiberId: params.fiberId,
|
|
@@ -115,14 +109,13 @@ function createScriptPayload(params) {
|
|
|
115
109
|
},
|
|
116
110
|
};
|
|
117
111
|
}
|
|
118
|
-
exports.createScriptPayload = createScriptPayload;
|
|
119
112
|
/**
|
|
120
113
|
* Create an invoke script payload ready for signing.
|
|
121
114
|
*
|
|
122
115
|
* @param params - Invoke script parameters
|
|
123
116
|
* @returns An InvokeScript message ready for signing
|
|
124
117
|
*/
|
|
125
|
-
function createInvokeScriptPayload(params) {
|
|
118
|
+
export function createInvokeScriptPayload(params) {
|
|
126
119
|
return {
|
|
127
120
|
InvokeScript: {
|
|
128
121
|
fiberId: params.fiberId,
|
|
@@ -132,7 +125,6 @@ function createInvokeScriptPayload(params) {
|
|
|
132
125
|
},
|
|
133
126
|
};
|
|
134
127
|
}
|
|
135
|
-
exports.createInvokeScriptPayload = createInvokeScriptPayload;
|
|
136
128
|
/**
|
|
137
129
|
* Sign a transaction payload for self-signed mode.
|
|
138
130
|
*
|
|
@@ -170,14 +162,13 @@ exports.createInvokeScriptPayload = createInvokeScriptPayload;
|
|
|
170
162
|
* });
|
|
171
163
|
* ```
|
|
172
164
|
*/
|
|
173
|
-
async function signTransaction(message, privateKey) {
|
|
174
|
-
const proof = await
|
|
165
|
+
export async function signTransaction(message, privateKey) {
|
|
166
|
+
const proof = await signDataUpdate(message, privateKey);
|
|
175
167
|
return {
|
|
176
168
|
value: message,
|
|
177
169
|
proofs: [proof],
|
|
178
170
|
};
|
|
179
171
|
}
|
|
180
|
-
exports.signTransaction = signTransaction;
|
|
181
172
|
/**
|
|
182
173
|
* Wrap a signed transaction in the DataTransactionRequest format
|
|
183
174
|
* expected by tessellation's DL1 `/data` endpoint.
|
|
@@ -199,10 +190,9 @@ exports.signTransaction = signTransaction;
|
|
|
199
190
|
* });
|
|
200
191
|
* ```
|
|
201
192
|
*/
|
|
202
|
-
function createDataTransactionRequest(signed) {
|
|
193
|
+
export function createDataTransactionRequest(signed) {
|
|
203
194
|
return { data: signed, fee: null };
|
|
204
195
|
}
|
|
205
|
-
exports.createDataTransactionRequest = createDataTransactionRequest;
|
|
206
196
|
/**
|
|
207
197
|
* Add an additional signature to a signed transaction.
|
|
208
198
|
*
|
|
@@ -213,14 +203,13 @@ exports.createDataTransactionRequest = createDataTransactionRequest;
|
|
|
213
203
|
* @param privateKey - Additional signer's private key
|
|
214
204
|
* @returns Transaction with additional signature
|
|
215
205
|
*/
|
|
216
|
-
async function addTransactionSignature(signed, privateKey) {
|
|
217
|
-
const newProof = await
|
|
206
|
+
export async function addTransactionSignature(signed, privateKey) {
|
|
207
|
+
const newProof = await signDataUpdate(signed.value, privateKey);
|
|
218
208
|
return {
|
|
219
209
|
value: signed.value,
|
|
220
210
|
proofs: [...signed.proofs, newProof],
|
|
221
211
|
};
|
|
222
212
|
}
|
|
223
|
-
exports.addTransactionSignature = addTransactionSignature;
|
|
224
213
|
/**
|
|
225
214
|
* Get the public key ID from a private key in the format expected by registration.
|
|
226
215
|
*
|
|
@@ -245,7 +234,6 @@ exports.addTransactionSignature = addTransactionSignature;
|
|
|
245
234
|
* });
|
|
246
235
|
* ```
|
|
247
236
|
*/
|
|
248
|
-
function getPublicKeyForRegistration(privateKey) {
|
|
249
|
-
return
|
|
237
|
+
export function getPublicKeyForRegistration(privateKey) {
|
|
238
|
+
return getPublicKeyId(privateKey);
|
|
250
239
|
}
|
|
251
|
-
exports.getPublicKeyForRegistration = getPublicKeyForRegistration;
|