@ottochain/sdk 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -32,7 +32,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.IMMUTABLE_POLICY = exports.immutable = exports.unconstrained = exports.constrained = exports.defineFiberApp = exports.toProtoDefinition = 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.GENESIS_MANIFEST_VERSION = exports.buildGenesisManifest = exports.dropNulls = exports.MetagraphNetworkError = exports.HttpClient = exports.createMetagraphClient = exports.MetagraphClient = exports.batchSign = exports.addSignature = exports.createSignedObject = exports.signDataUpdate = exports.verify = void 0;
35
- exports.SHIELDED_POOL_STATE = exports.shieldApp = exports.RESERVED_EFFECT_KEYS = exports.toWallet = exports.toFiber = exports.emit = exports.spawn = exports.triggers = exports.transferAsset = exports.setDependencyActive = exports.addDependency = exports.actorNotInArray = exports.depInState = exports.signerHasRoleVia = exports.signerHasReputationVia = exports.signerHasRole = exports.signerHasReputation = exports.actorHasEntry = exports.actorInSet = exports.actorIsSigner = exports.assetSignerIs = exports.signerHasEntry = exports.signerIsNotParty = exports.signerInSet = exports.signerIsAnyParty = exports.signerIsParty = exports.projectFiberPolicy = void 0;
35
+ exports.SHIELDED_POOL_STATE = exports.shieldApp = exports.RESERVED_EFFECT_KEYS = exports.toWallet = exports.toFiber = exports.scriptCall = exports.emit = exports.spawn = exports.triggers = exports.transferAsset = exports.setDependencyActive = exports.addDependency = exports.actorNotInArray = exports.depInState = exports.signerHasRoleVia = exports.signerHasReputationVia = exports.signerHasRole = exports.signerHasReputation = exports.actorHasEntry = exports.actorInSet = exports.actorIsSigner = exports.assetSignerIs = exports.signerHasEntry = exports.signerIsNotParty = exports.signerInSet = exports.signerIsAnyParty = exports.signerIsParty = exports.projectFiberPolicy = void 0;
36
36
  // ─── Core metagraph SDK ───────────────────────────────────────────────────────
37
37
  // Consumers can also import directly from '@constellation-network/metagraph-sdk'
38
38
  __exportStar(require("@constellation-network/metagraph-sdk"), exports);
@@ -150,6 +150,7 @@ Object.defineProperty(exports, "transferAsset", { enumerable: true, get: functio
150
150
  Object.defineProperty(exports, "triggers", { enumerable: true, get: function () { return effects_js_1.triggers; } });
151
151
  Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return effects_js_1.spawn; } });
152
152
  Object.defineProperty(exports, "emit", { enumerable: true, get: function () { return effects_js_1.emit; } });
153
+ Object.defineProperty(exports, "scriptCall", { enumerable: true, get: function () { return effects_js_1.scriptCall; } });
153
154
  Object.defineProperty(exports, "toFiber", { enumerable: true, get: function () { return effects_js_1.toFiber; } });
154
155
  Object.defineProperty(exports, "toWallet", { enumerable: true, get: function () { return effects_js_1.toWallet; } });
155
156
  Object.defineProperty(exports, "RESERVED_EFFECT_KEYS", { enumerable: true, get: function () { return effects_js_1.RESERVED_EFFECT_KEYS; } });
@@ -119,7 +119,11 @@ class MetagraphClient {
119
119
  // -------------------------------------------------------------------------
120
120
  // Registry, audit, state-proofs, fee estimates (ML0 /data-application/v1/*)
121
121
  // -------------------------------------------------------------------------
122
- /** Get the metagraph version string. */
122
+ /**
123
+ * Get the node's service identity + build metadata. The chain's `GET …/version` returns a
124
+ * `VersionInfo` OBJECT (`{ service, version, name, scalaVersion, sbtVersion, gitCommit, buildTime,
125
+ * tessellationVersion }`) — chain `ServiceMeta.scala` — NOT a bare string.
126
+ */
123
127
  async getVersion() {
124
128
  return this.ml0.get('/data-application/v1/version');
125
129
  }
@@ -165,15 +169,55 @@ class MetagraphClient {
165
169
  async getAssetStateProof(assetId, field) {
166
170
  return this.ml0.get(`/data-application/v1/assets/${assetId}/state-proof?field=${encodeURIComponent(field)}`);
167
171
  }
168
- /** Estimate the fee/gas for a transition event on a state-machine fiber. */
172
+ /**
173
+ * Estimate the fee/gas for a transition event on a state-machine fiber. Returns a
174
+ * {@link TransitionFeeEstimate} (`{ fiberId, currentState, event, gasEstimate, opCount, maxDepth,
175
+ * candidateTransitions, note }`) — chain `FeeEstimates.scala`.
176
+ */
169
177
  async estimateTransitionFee(fiberId, eventName) {
170
178
  return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/estimate-fee?event=${encodeURIComponent(eventName)}`);
171
179
  }
172
- /** Estimate the fee/gas for invoking a script fiber. */
180
+ /**
181
+ * Estimate the fee/gas for invoking a script fiber. Returns a {@link ScriptFeeEstimate}
182
+ * (`{ scriptId, gasEstimate, opCount, maxDepth, note }`) — chain `FeeEstimates.scala`.
183
+ */
173
184
  async estimateScriptFee(fiberId) {
174
185
  return this.ml0.get(`/data-application/v1/scripts/${fiberId}/estimate-fee`);
175
186
  }
176
187
  // -------------------------------------------------------------------------
188
+ // Webhook subscriptions (ML0 /data-application/v1/webhooks/*)
189
+ // -------------------------------------------------------------------------
190
+ /**
191
+ * Subscribe a callback URL to snapshot-notification webhooks.
192
+ *
193
+ * `POST …/webhooks/subscribe` with `SubscribeRequest { callbackUrl, secret? }`; the chain replies
194
+ * `201 Created` with `SubscribeResponse { id, callbackUrl, createdAt }`. Chain: `ML0Routes.scala`
195
+ * (`webhook.subscribe`) + `webhooks/Subscriber.scala`.
196
+ */
197
+ async subscribeWebhook(request) {
198
+ return this.ml0.post('/data-application/v1/webhooks/subscribe', request);
199
+ }
200
+ /**
201
+ * Unsubscribe a webhook by its subscriber id.
202
+ *
203
+ * `DELETE …/webhooks/subscribe/{id}` → `204 No Content` (empty body) on success, or `404` if the id is
204
+ * unknown. Chain: `ML0Routes.scala` (`webhook.unsubscribe`). The vendored `HttpClient` exposes only
205
+ * `get`/`post`, so this reuses its shared private `request` helper — same `NetworkError`/timeout
206
+ * handling as every other call — to issue the DELETE.
207
+ */
208
+ async unsubscribeWebhook(id) {
209
+ await this.ml0.request('DELETE', `/data-application/v1/webhooks/subscribe/${encodeURIComponent(id)}`);
210
+ }
211
+ /**
212
+ * List the current webhook subscribers (secrets are redacted server-side).
213
+ *
214
+ * `GET …/webhooks/subscribers` → `SubscriberList { subscribers: Subscriber[] }`. Chain:
215
+ * `ML0Routes.scala` (`webhook.list`) + `webhooks/Subscriber.scala`.
216
+ */
217
+ async listWebhookSubscribers() {
218
+ return this.ml0.get('/data-application/v1/webhooks/subscribers');
219
+ }
220
+ // -------------------------------------------------------------------------
177
221
  // Framework snapshot endpoints (ML0 /snapshots/*)
178
222
  // -------------------------------------------------------------------------
179
223
  /**
@@ -16,7 +16,7 @@
16
16
  * ```
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.RESERVED_EFFECT_KEYS = exports.emit = exports.spawn = exports.triggers = exports.toWallet = exports.toFiber = exports.transferAsset = exports.setDependencyActive = exports.addDependency = void 0;
19
+ exports.RESERVED_EFFECT_KEYS = exports.scriptCall = exports.emit = exports.spawn = exports.triggers = exports.toWallet = exports.toFiber = exports.transferAsset = exports.setDependencyActive = exports.addDependency = void 0;
20
20
  /**
21
21
  * `_addDependency` (#24): add — or re-activate — a runtime DYNAMIC dependency on `fiberId`, so that
22
22
  * fiber's state appears in `machines.<fiberId>` for SUBSEQUENT transitions of this fiber. `fiberId` may
@@ -139,6 +139,34 @@ const emit = (es) => ({
139
139
  _emit: es,
140
140
  });
141
141
  exports.emit = emit;
142
+ /**
143
+ * `_scriptCall`: invoke a SCRIPT fiber's `method` from an effect. Unlike the array-valued directives,
144
+ * `_scriptCall` is a SINGLE object `{ fiberId, method, args }` (chain `ReservedKeys.scala` `SCRIPT_CALL` /
145
+ * `EffectExtractor.extractScriptCall`). `fiberId` is the target script's UUID (a literal or an expression,
146
+ * e.g. `{ var: "state.resolverId" }`); `method` is the script method NAME; `args` is the argument body —
147
+ * a JSON-Logic value the chain EVALUATES against the transition context before dispatch.
148
+ *
149
+ * The chain's extractor requires ALL THREE fields — if `args` is absent the whole call is silently DROPPED
150
+ * (fail-silent, like the other extractors). So the builder ALWAYS emits `args`, defaulting an omitted one
151
+ * to `{}` (no-args), mirroring how {@link triggers} defaults an absent `payload`. Authoring this as a
152
+ * builder makes a typo'd `_scriptcall` / wrong field a TypeScript error rather than a silently-merged
153
+ * state field. Place the fragment INSIDE the effect's state-update map so it rides in the evaluated result.
154
+ *
155
+ * @example
156
+ * effect: { merge: [ { var: "state" }, {
157
+ * status: "resolving",
158
+ * ...scriptCall({ fiberId: { var: "state.resolverId" }, method: "resolve",
159
+ * args: { marketId: { var: "machineId" } } }),
160
+ * } ] }
161
+ */
162
+ const scriptCall = (call) => ({
163
+ _scriptCall: {
164
+ fiberId: call.fiberId,
165
+ method: call.method,
166
+ args: call.args ?? {},
167
+ },
168
+ });
169
+ exports.scriptCall = scriptCall;
142
170
  /**
143
171
  * The complete set of `_`-prefixed RESERVED effect keys the chain's `EffectExtractor` consumes and
144
172
  * `StateMerger` strips from state (`ReservedKeys.scala:12-49`). Exported so a validator (Proposal 01)
@@ -194,8 +194,13 @@ function toProtoDefinition(def) {
194
194
  from: t.from,
195
195
  to: t.to,
196
196
  eventName: t.eventName,
197
- guard: t.guard, // Required - Scala has no default
198
- effect: t.effect, // Required - Scala has no default
197
+ // guard/effect are REQUIRED by the Scala `Transition` case class (no defaults). The authoring
198
+ // `Transition` types them OPTIONAL for ergonomics, so ALWAYS project a concrete value here — an
199
+ // omitted key would serialize to `undefined`, get dropped, and fail the chain's decode (HTTP 400).
200
+ // The defaults are the exact shapes the chain's `PublishVersionSigningCanonicalSuite` accepts:
201
+ // an always-true guard `{"==":[1,1]}` and an empty (no-op) effect `{}`.
202
+ guard: t.guard ?? { '==': [1, 1] },
203
+ effect: t.effect ?? {},
199
204
  // Chain `Transition.dependencies: Set[UUID]` is REQUIRED (no Scala default), and each
200
205
  // element must be a fiber UUID string. A `DependencySpec` object is a build-time-only
201
206
  // authoring affordance with no wire representation (concrete dependency UUIDs are per
package/dist/esm/index.js CHANGED
@@ -67,7 +67,7 @@ depInState,
67
67
  actorNotInArray, } from './schema/guards.js';
68
68
  // Reserved EFFECT-directive builders (dynamic dependencies, #24; whole-asset custody moves;
69
69
  // cross-fiber triggers, spawn, emit + recipient-intent helpers; the reserved-key set for validators).
70
- export { addDependency, setDependencyActive, transferAsset, triggers, spawn, emit, toFiber, toWallet, RESERVED_EFFECT_KEYS, } from './schema/effects.js';
70
+ export { addDependency, setDependencyActive, transferAsset, triggers, spawn, emit, scriptCall, toFiber, toWallet, RESERVED_EFFECT_KEYS, } from './schema/effects.js';
71
71
  // ─── Privacy: shield any fiber app into a zk-jlvm-shielded private-state pool ──
72
72
  // See docs/design/zk-private-contract-state-rfc.md.
73
73
  export { shieldApp, SHIELDED_POOL_STATE } from './privacy/shield-app.js';
@@ -116,7 +116,11 @@ export class MetagraphClient {
116
116
  // -------------------------------------------------------------------------
117
117
  // Registry, audit, state-proofs, fee estimates (ML0 /data-application/v1/*)
118
118
  // -------------------------------------------------------------------------
119
- /** Get the metagraph version string. */
119
+ /**
120
+ * Get the node's service identity + build metadata. The chain's `GET …/version` returns a
121
+ * `VersionInfo` OBJECT (`{ service, version, name, scalaVersion, sbtVersion, gitCommit, buildTime,
122
+ * tessellationVersion }`) — chain `ServiceMeta.scala` — NOT a bare string.
123
+ */
120
124
  async getVersion() {
121
125
  return this.ml0.get('/data-application/v1/version');
122
126
  }
@@ -162,15 +166,55 @@ export class MetagraphClient {
162
166
  async getAssetStateProof(assetId, field) {
163
167
  return this.ml0.get(`/data-application/v1/assets/${assetId}/state-proof?field=${encodeURIComponent(field)}`);
164
168
  }
165
- /** Estimate the fee/gas for a transition event on a state-machine fiber. */
169
+ /**
170
+ * Estimate the fee/gas for a transition event on a state-machine fiber. Returns a
171
+ * {@link TransitionFeeEstimate} (`{ fiberId, currentState, event, gasEstimate, opCount, maxDepth,
172
+ * candidateTransitions, note }`) — chain `FeeEstimates.scala`.
173
+ */
166
174
  async estimateTransitionFee(fiberId, eventName) {
167
175
  return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/estimate-fee?event=${encodeURIComponent(eventName)}`);
168
176
  }
169
- /** Estimate the fee/gas for invoking a script fiber. */
177
+ /**
178
+ * Estimate the fee/gas for invoking a script fiber. Returns a {@link ScriptFeeEstimate}
179
+ * (`{ scriptId, gasEstimate, opCount, maxDepth, note }`) — chain `FeeEstimates.scala`.
180
+ */
170
181
  async estimateScriptFee(fiberId) {
171
182
  return this.ml0.get(`/data-application/v1/scripts/${fiberId}/estimate-fee`);
172
183
  }
173
184
  // -------------------------------------------------------------------------
185
+ // Webhook subscriptions (ML0 /data-application/v1/webhooks/*)
186
+ // -------------------------------------------------------------------------
187
+ /**
188
+ * Subscribe a callback URL to snapshot-notification webhooks.
189
+ *
190
+ * `POST …/webhooks/subscribe` with `SubscribeRequest { callbackUrl, secret? }`; the chain replies
191
+ * `201 Created` with `SubscribeResponse { id, callbackUrl, createdAt }`. Chain: `ML0Routes.scala`
192
+ * (`webhook.subscribe`) + `webhooks/Subscriber.scala`.
193
+ */
194
+ async subscribeWebhook(request) {
195
+ return this.ml0.post('/data-application/v1/webhooks/subscribe', request);
196
+ }
197
+ /**
198
+ * Unsubscribe a webhook by its subscriber id.
199
+ *
200
+ * `DELETE …/webhooks/subscribe/{id}` → `204 No Content` (empty body) on success, or `404` if the id is
201
+ * unknown. Chain: `ML0Routes.scala` (`webhook.unsubscribe`). The vendored `HttpClient` exposes only
202
+ * `get`/`post`, so this reuses its shared private `request` helper — same `NetworkError`/timeout
203
+ * handling as every other call — to issue the DELETE.
204
+ */
205
+ async unsubscribeWebhook(id) {
206
+ await this.ml0.request('DELETE', `/data-application/v1/webhooks/subscribe/${encodeURIComponent(id)}`);
207
+ }
208
+ /**
209
+ * List the current webhook subscribers (secrets are redacted server-side).
210
+ *
211
+ * `GET …/webhooks/subscribers` → `SubscriberList { subscribers: Subscriber[] }`. Chain:
212
+ * `ML0Routes.scala` (`webhook.list`) + `webhooks/Subscriber.scala`.
213
+ */
214
+ async listWebhookSubscribers() {
215
+ return this.ml0.get('/data-application/v1/webhooks/subscribers');
216
+ }
217
+ // -------------------------------------------------------------------------
174
218
  // Framework snapshot endpoints (ML0 /snapshots/*)
175
219
  // -------------------------------------------------------------------------
176
220
  /**
@@ -128,6 +128,33 @@ export const spawn = (ds) => ({ _spawn: ds });
128
128
  export const emit = (es) => ({
129
129
  _emit: es,
130
130
  });
131
+ /**
132
+ * `_scriptCall`: invoke a SCRIPT fiber's `method` from an effect. Unlike the array-valued directives,
133
+ * `_scriptCall` is a SINGLE object `{ fiberId, method, args }` (chain `ReservedKeys.scala` `SCRIPT_CALL` /
134
+ * `EffectExtractor.extractScriptCall`). `fiberId` is the target script's UUID (a literal or an expression,
135
+ * e.g. `{ var: "state.resolverId" }`); `method` is the script method NAME; `args` is the argument body —
136
+ * a JSON-Logic value the chain EVALUATES against the transition context before dispatch.
137
+ *
138
+ * The chain's extractor requires ALL THREE fields — if `args` is absent the whole call is silently DROPPED
139
+ * (fail-silent, like the other extractors). So the builder ALWAYS emits `args`, defaulting an omitted one
140
+ * to `{}` (no-args), mirroring how {@link triggers} defaults an absent `payload`. Authoring this as a
141
+ * builder makes a typo'd `_scriptcall` / wrong field a TypeScript error rather than a silently-merged
142
+ * state field. Place the fragment INSIDE the effect's state-update map so it rides in the evaluated result.
143
+ *
144
+ * @example
145
+ * effect: { merge: [ { var: "state" }, {
146
+ * status: "resolving",
147
+ * ...scriptCall({ fiberId: { var: "state.resolverId" }, method: "resolve",
148
+ * args: { marketId: { var: "machineId" } } }),
149
+ * } ] }
150
+ */
151
+ export const scriptCall = (call) => ({
152
+ _scriptCall: {
153
+ fiberId: call.fiberId,
154
+ method: call.method,
155
+ args: call.args ?? {},
156
+ },
157
+ });
131
158
  /**
132
159
  * The complete set of `_`-prefixed RESERVED effect keys the chain's `EffectExtractor` consumes and
133
160
  * `StateMerger` strips from state (`ReservedKeys.scala:12-49`). Exported so a validator (Proposal 01)
@@ -181,8 +181,13 @@ export function toProtoDefinition(def) {
181
181
  from: t.from,
182
182
  to: t.to,
183
183
  eventName: t.eventName,
184
- guard: t.guard, // Required - Scala has no default
185
- effect: t.effect, // Required - Scala has no default
184
+ // guard/effect are REQUIRED by the Scala `Transition` case class (no defaults). The authoring
185
+ // `Transition` types them OPTIONAL for ergonomics, so ALWAYS project a concrete value here — an
186
+ // omitted key would serialize to `undefined`, get dropped, and fail the chain's decode (HTTP 400).
187
+ // The defaults are the exact shapes the chain's `PublishVersionSigningCanonicalSuite` accepts:
188
+ // an always-true guard `{"==":[1,1]}` and an empty (no-op) effect `{}`.
189
+ guard: t.guard ?? { '==': [1, 1] },
190
+ effect: t.effect ?? {},
186
191
  // Chain `Transition.dependencies: Set[UUID]` is REQUIRED (no Scala default), and each
187
192
  // element must be a fiber UUID string. A `DependencySpec` object is a build-time-only
188
193
  // authoring affordance with no wire representation (concrete dependency UUIDs are per
@@ -33,6 +33,6 @@ export { MetagraphClient as OttoMetagraphClient } from './ottochain/metagraph-cl
33
33
  export type { MetagraphClientConfig, Checkpoint, SubscribeOptions, FiberStateCallback, Unsubscribe, } from './ottochain/metagraph-client.js';
34
34
  export { toProtoDefinition, defineFiberApp, constrained, unconstrained, immutable, IMMUTABLE_POLICY, projectFiberPolicy, type ProtoStateMachineDefinition, type FiberAppDefinition, type FiberAppMetadata, type FiberPolicy, type FiberPolicyDials, type ImmutablePolicy, type EffectKind, type SpawnOwnerPolicy, type DependencyMode, type TransferPolicy, type DependencyPolicy, type MigrationAuthority, type UpgradePolicy, type VersionRange, type StateDefinition, type StdStateMetadata, type StateCategory, type Transition, } from './schema/fiber-app.js';
35
35
  export { type GuardRule, signerIsParty, signerIsAnyParty, signerInSet, signerIsNotParty, signerHasEntry, assetSignerIs, actorIsSigner, actorInSet, actorHasEntry, signerHasReputation, signerHasRole, signerHasReputationVia, signerHasRoleVia, depInState, actorNotInArray, } from './schema/guards.js';
36
- export { addDependency, setDependencyActive, transferAsset, triggers, spawn, emit, toFiber, toWallet, RESERVED_EFFECT_KEYS, } from './schema/effects.js';
36
+ export { addDependency, setDependencyActive, transferAsset, triggers, spawn, emit, scriptCall, toFiber, toWallet, RESERVED_EFFECT_KEYS, } from './schema/effects.js';
37
37
  export { shieldApp, SHIELDED_POOL_STATE, type ShieldOptions } from './privacy/shield-app.js';
38
38
  export type { paths as ApiPaths, operations as ApiOperations, components as ApiComponents, VersionInfo, TransitionFeeEstimate, ScriptFeeEstimate, SubscribeRequest, SubscribeResponse, Subscriber, SubscriberList, } from './openapi.js';
@@ -10,7 +10,7 @@ export type { Address, FiberId, StateId, HashValue, FiberOrdinal, SnapshotOrdina
10
10
  export { OTTOCHAIN_MESSAGE_TYPES, TOKEN_BEHAVIOR_BITS } from './types.js';
11
11
  export type { CurrencySnapshotResponse } from './snapshot.js';
12
12
  export { decodeOnChainState, getSnapshotOnChainState, getLatestOnChainState, getLogsForFiber, getEventReceipts, getScriptInvocations, extractOnChainState, } from './snapshot.js';
13
- export type { Checkpoint, StateProof, FeeEstimate, MetagraphClientConfig, SubscribeOptions, FiberStateCallback, Unsubscribe, } from './metagraph-client.js';
13
+ export type { Checkpoint, StateProof, FeeEstimate, TransitionFeeEstimate, ScriptFeeEstimate, VersionInfo, SubscribeRequest, SubscribeResponse, SubscriberList, MetagraphClientConfig, SubscribeOptions, FiberStateCallback, Unsubscribe, } from './metagraph-client.js';
14
14
  export { MetagraphClient } from './metagraph-client.js';
15
15
  export { createTransitionPayload, createArchivePayload, createInvokeScriptPayload, signTransaction, addTransactionSignature, getPublicKeyForRegistration, createStateMachinePayload, createScriptPayload, createDataTransactionRequest, createAssetPolicyPayload, createMintAssetPayload, createApplyMorphismPayload, createAuthorizeComposePayload, } from './transaction.js';
16
16
  export type { CreateStateMachineParams, CreateStateMachineMessage, CreateScriptParams, CreateScriptMessage, DataTransactionRequest, TransitionParams, TransitionStateMachineMessage, ArchiveParams, ArchiveStateMachineMessage, InvokeScriptParams, InvokeScriptMessage, } from './transaction.js';
@@ -10,6 +10,8 @@
10
10
  */
11
11
  import type { Signed } from '@constellation-network/metagraph-sdk';
12
12
  import type { OnChain, CalculatedState, StateMachineFiberRecord, ScriptFiberRecord, EventReceipt, ScriptInvocation, FiberStatus, RegistryEntry } from './types.js';
13
+ import type { VersionInfo, TransitionFeeEstimate, ScriptFeeEstimate, SubscribeRequest, SubscribeResponse, SubscriberList } from '../openapi.js';
14
+ export type { VersionInfo, TransitionFeeEstimate, ScriptFeeEstimate, SubscribeRequest, SubscribeResponse, SubscriberList, } from '../openapi.js';
13
15
  /**
14
16
  * Checkpoint response from the metagraph (ordinal + calculated state).
15
17
  */
@@ -23,22 +25,39 @@ export interface Checkpoint {
23
25
  * endpoints.
24
26
  */
25
27
  export interface StateProof {
26
- /** The record (or projected field) the proof attests to. */
27
- record: unknown;
28
+ /**
29
+ * The trie key the proof is keyed on — the fiber/asset id (optionally suffixed with the requested
30
+ * field). Chain: `StateProofResponse.key: String` (required).
31
+ */
32
+ key: string;
33
+ ordinal: number;
28
34
  /** The committed-state combined root (= the snapshot's `calculatedStateProof`). */
29
35
  committedRoot: string;
30
36
  /** The Merkle-Patricia trie root. */
31
37
  mptRoot: string;
32
- ordinal: number;
38
+ /** The record (or projected field) the proof attests to. */
39
+ record: unknown;
33
40
  /** The Merkle-Patricia inclusion proof. */
34
41
  proof: unknown;
42
+ /**
43
+ * The `stateData` field name that was projected, present ONLY when a `?field=` was requested
44
+ * (chain `field: Option[String]`, `dropNullValues`-stripped otherwise).
45
+ */
46
+ field?: string;
47
+ /**
48
+ * The value of the projected `field`, present ONLY when a `?field=` was requested
49
+ * (chain `fieldValue: Option[Json]`, `dropNullValues`-stripped otherwise).
50
+ */
51
+ fieldValue?: unknown;
35
52
  }
36
- /** A fee/gas estimate for a transition or script invocation (shape is advisory / may evolve). */
37
- export interface FeeEstimate {
38
- gas?: number;
39
- fee?: number;
40
- [key: string]: unknown;
41
- }
53
+ /**
54
+ * A static fee/gas estimate. The wire is one of two per-endpoint shapes — {@link TransitionFeeEstimate}
55
+ * (state-machine transition) or {@link ScriptFeeEstimate} (script invocation) — that mirror the chain's
56
+ * `FeeEstimates.scala` case classes byte-for-byte. Prefer the per-endpoint types on
57
+ * {@link MetagraphClient.estimateTransitionFee} / {@link MetagraphClient.estimateScriptFee}; this union is
58
+ * a convenience for code that handles either.
59
+ */
60
+ export type FeeEstimate = TransitionFeeEstimate | ScriptFeeEstimate;
42
61
  /**
43
62
  * Options for subscribeFiberState polling behaviour.
44
63
  */
@@ -151,8 +170,12 @@ export declare class MetagraphClient {
151
170
  * Get script invocations from the current ordinal's logs.
152
171
  */
153
172
  getScriptInvocations(scriptId: string): Promise<ScriptInvocation[]>;
154
- /** Get the metagraph version string. */
155
- getVersion(): Promise<string>;
173
+ /**
174
+ * Get the node's service identity + build metadata. The chain's `GET …/version` returns a
175
+ * `VersionInfo` OBJECT (`{ service, version, name, scalaVersion, sbtVersion, gitCommit, buildTime,
176
+ * tessellationVersion }`) — chain `ServiceMeta.scala` — NOT a bare string.
177
+ */
178
+ getVersion(): Promise<VersionInfo>;
156
179
  /** Get the full registry namespace, keyed by full registry name `labels.tld`. */
157
180
  getRegistry(): Promise<Record<string, RegistryEntry>>;
158
181
  /** Resolve a single registry entry by full name (`labels.tld`), or null if unregistered. */
@@ -167,10 +190,41 @@ export declare class MetagraphClient {
167
190
  getScriptStateProof(fiberId: string, field: string): Promise<StateProof>;
168
191
  /** Light-client state proof for a field of an asset instance. */
169
192
  getAssetStateProof(assetId: string, field: string): Promise<StateProof>;
170
- /** Estimate the fee/gas for a transition event on a state-machine fiber. */
171
- estimateTransitionFee(fiberId: string, eventName: string): Promise<FeeEstimate>;
172
- /** Estimate the fee/gas for invoking a script fiber. */
173
- estimateScriptFee(fiberId: string): Promise<FeeEstimate>;
193
+ /**
194
+ * Estimate the fee/gas for a transition event on a state-machine fiber. Returns a
195
+ * {@link TransitionFeeEstimate} (`{ fiberId, currentState, event, gasEstimate, opCount, maxDepth,
196
+ * candidateTransitions, note }`) — chain `FeeEstimates.scala`.
197
+ */
198
+ estimateTransitionFee(fiberId: string, eventName: string): Promise<TransitionFeeEstimate>;
199
+ /**
200
+ * Estimate the fee/gas for invoking a script fiber. Returns a {@link ScriptFeeEstimate}
201
+ * (`{ scriptId, gasEstimate, opCount, maxDepth, note }`) — chain `FeeEstimates.scala`.
202
+ */
203
+ estimateScriptFee(fiberId: string): Promise<ScriptFeeEstimate>;
204
+ /**
205
+ * Subscribe a callback URL to snapshot-notification webhooks.
206
+ *
207
+ * `POST …/webhooks/subscribe` with `SubscribeRequest { callbackUrl, secret? }`; the chain replies
208
+ * `201 Created` with `SubscribeResponse { id, callbackUrl, createdAt }`. Chain: `ML0Routes.scala`
209
+ * (`webhook.subscribe`) + `webhooks/Subscriber.scala`.
210
+ */
211
+ subscribeWebhook(request: SubscribeRequest): Promise<SubscribeResponse>;
212
+ /**
213
+ * Unsubscribe a webhook by its subscriber id.
214
+ *
215
+ * `DELETE …/webhooks/subscribe/{id}` → `204 No Content` (empty body) on success, or `404` if the id is
216
+ * unknown. Chain: `ML0Routes.scala` (`webhook.unsubscribe`). The vendored `HttpClient` exposes only
217
+ * `get`/`post`, so this reuses its shared private `request` helper — same `NetworkError`/timeout
218
+ * handling as every other call — to issue the DELETE.
219
+ */
220
+ unsubscribeWebhook(id: string): Promise<void>;
221
+ /**
222
+ * List the current webhook subscribers (secrets are redacted server-side).
223
+ *
224
+ * `GET …/webhooks/subscribers` → `SubscriberList { subscribers: Subscriber[] }`. Chain:
225
+ * `ML0Routes.scala` (`webhook.list`) + `webhooks/Subscriber.scala`.
226
+ */
227
+ listWebhookSubscribers(): Promise<SubscriberList>;
174
228
  /**
175
229
  * Get the latest snapshot and decode its on-chain state.
176
230
  */
@@ -131,6 +131,31 @@ export declare const emit: (es: {
131
131
  data: JsonLogicValue;
132
132
  destination?: string;
133
133
  }[]) => Record<string, unknown>;
134
+ /**
135
+ * `_scriptCall`: invoke a SCRIPT fiber's `method` from an effect. Unlike the array-valued directives,
136
+ * `_scriptCall` is a SINGLE object `{ fiberId, method, args }` (chain `ReservedKeys.scala` `SCRIPT_CALL` /
137
+ * `EffectExtractor.extractScriptCall`). `fiberId` is the target script's UUID (a literal or an expression,
138
+ * e.g. `{ var: "state.resolverId" }`); `method` is the script method NAME; `args` is the argument body —
139
+ * a JSON-Logic value the chain EVALUATES against the transition context before dispatch.
140
+ *
141
+ * The chain's extractor requires ALL THREE fields — if `args` is absent the whole call is silently DROPPED
142
+ * (fail-silent, like the other extractors). So the builder ALWAYS emits `args`, defaulting an omitted one
143
+ * to `{}` (no-args), mirroring how {@link triggers} defaults an absent `payload`. Authoring this as a
144
+ * builder makes a typo'd `_scriptcall` / wrong field a TypeScript error rather than a silently-merged
145
+ * state field. Place the fragment INSIDE the effect's state-update map so it rides in the evaluated result.
146
+ *
147
+ * @example
148
+ * effect: { merge: [ { var: "state" }, {
149
+ * status: "resolving",
150
+ * ...scriptCall({ fiberId: { var: "state.resolverId" }, method: "resolve",
151
+ * args: { marketId: { var: "machineId" } } }),
152
+ * } ] }
153
+ */
154
+ export declare const scriptCall: (call: {
155
+ fiberId: JsonLogicValue;
156
+ method: string;
157
+ args?: JsonLogicValue;
158
+ }) => Record<string, unknown>;
134
159
  /**
135
160
  * The complete set of `_`-prefixed RESERVED effect keys the chain's `EffectExtractor` consumes and
136
161
  * `StateMerger` strips from state (`ReservedKeys.scala:12-49`). Exported so a validator (Proposal 01)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottochain/sdk",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "TypeScript SDK for ottochain metagraph operations - signing, encoding, and network interactions",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",