@ottochain/sdk 2.2.5 → 2.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 (222) hide show
  1. package/dist/cjs/apps/contracts/index.js +15 -8
  2. package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +89 -46
  3. package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +152 -45
  4. package/dist/cjs/apps/contracts/state-machines/contract-universal.js +40 -8
  5. package/dist/cjs/apps/corporate/index.js +2 -2
  6. package/dist/cjs/apps/corporate/state-machines/corp-board.js +169 -59
  7. package/dist/cjs/apps/corporate/state-machines/corp-entity.js +245 -47
  8. package/dist/cjs/apps/corporate/state-machines/corp-securities.js +407 -99
  9. package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +151 -37
  10. package/dist/cjs/apps/governance/index.js +14 -14
  11. package/dist/cjs/apps/governance/state-machines/dao-multisig.js +85 -43
  12. package/dist/cjs/apps/governance/state-machines/dao-reputation.js +73 -43
  13. package/dist/cjs/apps/governance/state-machines/dao-single.js +55 -14
  14. package/dist/cjs/apps/governance/state-machines/dao-token.js +103 -45
  15. package/dist/cjs/apps/governance/state-machines/governance-simple.js +129 -65
  16. package/dist/cjs/apps/governance/state-machines/governance-universal.js +29 -5
  17. package/dist/cjs/apps/identity/constants.js +55 -14
  18. package/dist/cjs/apps/identity/index.js +27 -11
  19. package/dist/cjs/apps/identity/state-machines/identity-agent.js +57 -9
  20. package/dist/cjs/apps/identity/state-machines/identity-oracle.js +70 -27
  21. package/dist/cjs/apps/identity/state-machines/identity-registry.js +288 -0
  22. package/dist/cjs/apps/identity/state-machines/identity-universal.js +30 -6
  23. package/dist/cjs/apps/identity/state-machines/index.js +3 -1
  24. package/dist/cjs/apps/index.js +19 -8
  25. package/dist/cjs/apps/lending/assets.js +223 -0
  26. package/dist/cjs/apps/lending/credit-scoring.js +87 -0
  27. package/dist/cjs/apps/lending/eligibility.js +121 -0
  28. package/dist/cjs/apps/lending/index.js +91 -0
  29. package/dist/cjs/apps/lending/state-machines/index.js +9 -0
  30. package/dist/cjs/apps/lending/state-machines/lending-zk-loan.js +412 -0
  31. package/dist/cjs/apps/markets/index.js +21 -11
  32. package/dist/cjs/apps/markets/state-machines/market-auction.js +44 -19
  33. package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +54 -29
  34. package/dist/cjs/apps/markets/state-machines/market-group-buy.js +53 -31
  35. package/dist/cjs/apps/markets/state-machines/market-prediction.js +120 -61
  36. package/dist/cjs/apps/markets/state-machines/market-universal.js +50 -10
  37. package/dist/cjs/apps/oracles/index.js +2 -2
  38. package/dist/cjs/errors.js +3 -3
  39. package/dist/cjs/generated/google/protobuf/struct.js +4 -4
  40. package/dist/cjs/generated/index.js +11 -7
  41. package/dist/cjs/generated/openapi.js +6 -0
  42. package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +50 -50
  43. package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +19 -20
  44. package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +13 -13
  45. package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +4 -4
  46. package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +124 -130
  47. package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +107 -107
  48. package/dist/cjs/generated/ottochain/v1/common.js +1722 -1
  49. package/dist/cjs/generated/ottochain/v1/fiber.js +355 -5
  50. package/dist/cjs/generated/ottochain/v1/messages.js +775 -3
  51. package/dist/cjs/generated/ottochain/v1/records.js +350 -3
  52. package/dist/cjs/index.js +45 -7
  53. package/dist/cjs/openapi.js +2 -0
  54. package/dist/cjs/ottochain/drop-nulls.js +1 -2
  55. package/dist/cjs/ottochain/genesis-manifest.js +193 -0
  56. package/dist/cjs/ottochain/index.js +27 -13
  57. package/dist/cjs/ottochain/metagraph-client.js +65 -8
  58. package/dist/cjs/ottochain/snapshot.js +11 -12
  59. package/dist/cjs/ottochain/transaction.js +57 -14
  60. package/dist/cjs/ottochain/types.js +19 -1
  61. package/dist/cjs/privacy/index.js +14 -0
  62. package/dist/cjs/privacy/sealed-bid.js +210 -0
  63. package/dist/cjs/privacy/shield-app.js +131 -0
  64. package/dist/cjs/schema/effects.js +40 -0
  65. package/dist/cjs/schema/fiber-app.js +19 -13
  66. package/dist/cjs/schema/guard-lint.js +352 -0
  67. package/dist/cjs/schema/guards.js +246 -0
  68. package/dist/cjs/signing.js +80 -0
  69. package/dist/cjs/types.js +2 -3
  70. package/dist/cjs/validation.js +8 -8
  71. package/dist/cjs/verify.js +9 -4
  72. package/dist/cjs/zk/commit.js +53 -0
  73. package/dist/cjs/zk/guard.js +107 -0
  74. package/dist/cjs/zk/index.js +48 -0
  75. package/dist/cjs/zk/preimage.js +37 -0
  76. package/dist/cjs/zk/prover.js +87 -0
  77. package/dist/cjs/zk/registry.js +62 -0
  78. package/dist/cjs/zk/types.js +28 -0
  79. package/dist/cjs/zk/witness.js +19 -0
  80. package/dist/esm/apps/contracts/index.js +7 -3
  81. package/dist/esm/apps/contracts/state-machines/contract-agreement.js +89 -46
  82. package/dist/esm/apps/contracts/state-machines/contract-escrow.js +152 -45
  83. package/dist/esm/apps/contracts/state-machines/contract-universal.js +40 -8
  84. package/dist/esm/apps/corporate/state-machines/corp-board.js +169 -59
  85. package/dist/esm/apps/corporate/state-machines/corp-entity.js +245 -47
  86. package/dist/esm/apps/corporate/state-machines/corp-securities.js +407 -99
  87. package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +151 -37
  88. package/dist/esm/apps/governance/state-machines/dao-multisig.js +85 -43
  89. package/dist/esm/apps/governance/state-machines/dao-reputation.js +73 -43
  90. package/dist/esm/apps/governance/state-machines/dao-single.js +55 -14
  91. package/dist/esm/apps/governance/state-machines/dao-token.js +103 -45
  92. package/dist/esm/apps/governance/state-machines/governance-simple.js +129 -65
  93. package/dist/esm/apps/governance/state-machines/governance-universal.js +29 -5
  94. package/dist/esm/apps/identity/constants.js +51 -12
  95. package/dist/esm/apps/identity/index.js +12 -7
  96. package/dist/esm/apps/identity/state-machines/identity-agent.js +57 -9
  97. package/dist/esm/apps/identity/state-machines/identity-oracle.js +70 -27
  98. package/dist/esm/apps/identity/state-machines/identity-registry.js +285 -0
  99. package/dist/esm/apps/identity/state-machines/identity-universal.js +30 -6
  100. package/dist/esm/apps/identity/state-machines/index.js +1 -0
  101. package/dist/esm/apps/index.js +1 -0
  102. package/dist/esm/apps/lending/assets.js +207 -0
  103. package/dist/esm/apps/lending/credit-scoring.js +81 -0
  104. package/dist/esm/apps/lending/eligibility.js +115 -0
  105. package/dist/esm/apps/lending/index.js +69 -0
  106. package/dist/esm/apps/lending/state-machines/index.js +5 -0
  107. package/dist/esm/apps/lending/state-machines/lending-zk-loan.js +409 -0
  108. package/dist/esm/apps/markets/index.js +8 -4
  109. package/dist/esm/apps/markets/state-machines/market-auction.js +44 -19
  110. package/dist/esm/apps/markets/state-machines/market-crowdfund.js +54 -29
  111. package/dist/esm/apps/markets/state-machines/market-group-buy.js +53 -31
  112. package/dist/esm/apps/markets/state-machines/market-prediction.js +120 -61
  113. package/dist/esm/apps/markets/state-machines/market-universal.js +50 -10
  114. package/dist/esm/generated/index.js +9 -5
  115. package/dist/esm/generated/openapi.js +5 -0
  116. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +46 -46
  117. package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +114 -120
  118. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +100 -100
  119. package/dist/esm/generated/ottochain/v1/common.js +1718 -0
  120. package/dist/esm/generated/ottochain/v1/fiber.js +351 -1
  121. package/dist/esm/generated/ottochain/v1/messages.js +774 -2
  122. package/dist/esm/generated/ottochain/v1/records.js +349 -2
  123. package/dist/esm/index.js +23 -2
  124. package/dist/esm/openapi.js +1 -0
  125. package/dist/esm/ottochain/genesis-manifest.js +189 -0
  126. package/dist/esm/ottochain/index.js +4 -3
  127. package/dist/esm/ottochain/metagraph-client.js +65 -8
  128. package/dist/esm/ottochain/snapshot.js +4 -4
  129. package/dist/esm/ottochain/transaction.js +43 -3
  130. package/dist/esm/ottochain/types.js +18 -0
  131. package/dist/esm/privacy/index.js +6 -0
  132. package/dist/esm/privacy/sealed-bid.js +206 -0
  133. package/dist/esm/privacy/shield-app.js +127 -0
  134. package/dist/esm/schema/effects.js +35 -0
  135. package/dist/esm/schema/fiber-app.js +13 -6
  136. package/dist/esm/schema/guard-lint.js +346 -0
  137. package/dist/esm/schema/guards.js +229 -0
  138. package/dist/esm/signing.js +74 -0
  139. package/dist/esm/verify.js +8 -2
  140. package/dist/esm/zk/commit.js +44 -0
  141. package/dist/esm/zk/guard.js +99 -0
  142. package/dist/esm/zk/index.js +19 -0
  143. package/dist/esm/zk/preimage.js +30 -0
  144. package/dist/esm/zk/prover.js +82 -0
  145. package/dist/esm/zk/registry.js +55 -0
  146. package/dist/esm/zk/types.js +25 -0
  147. package/dist/esm/zk/witness.js +15 -0
  148. package/dist/types/apps/contracts/index.d.ts +159 -227
  149. package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +50 -101
  150. package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +86 -120
  151. package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +20 -4
  152. package/dist/types/apps/corporate/index.d.ts +1040 -304
  153. package/dist/types/apps/corporate/state-machines/corp-board.d.ts +188 -52
  154. package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +267 -62
  155. package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +355 -131
  156. package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +225 -53
  157. package/dist/types/apps/governance/index.d.ts +396 -417
  158. package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +92 -95
  159. package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +57 -69
  160. package/dist/types/apps/governance/state-machines/dao-single.d.ts +40 -50
  161. package/dist/types/apps/governance/state-machines/dao-token.d.ts +80 -53
  162. package/dist/types/apps/governance/state-machines/governance-simple.d.ts +107 -121
  163. package/dist/types/apps/governance/state-machines/governance-universal.d.ts +17 -5
  164. package/dist/types/apps/identity/constants.d.ts +32 -4
  165. package/dist/types/apps/identity/index.d.ts +449 -100
  166. package/dist/types/apps/identity/state-machines/identity-agent.d.ts +30 -0
  167. package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +41 -87
  168. package/dist/types/apps/identity/state-machines/identity-registry.d.ts +379 -0
  169. package/dist/types/apps/identity/state-machines/identity-universal.d.ts +15 -0
  170. package/dist/types/apps/identity/state-machines/index.d.ts +1 -0
  171. package/dist/types/apps/index.d.ts +1 -0
  172. package/dist/types/apps/lending/assets.d.ts +258 -0
  173. package/dist/types/apps/lending/credit-scoring.d.ts +80 -0
  174. package/dist/types/apps/lending/eligibility.d.ts +83 -0
  175. package/dist/types/apps/lending/index.d.ts +548 -0
  176. package/dist/types/apps/lending/state-machines/index.d.ts +5 -0
  177. package/dist/types/apps/lending/state-machines/lending-zk-loan.d.ts +528 -0
  178. package/dist/types/apps/markets/index.d.ts +184 -204
  179. package/dist/types/apps/markets/state-machines/market-auction.d.ts +25 -37
  180. package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +26 -34
  181. package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +31 -43
  182. package/dist/types/apps/markets/state-machines/market-prediction.d.ts +67 -72
  183. package/dist/types/apps/markets/state-machines/market-universal.d.ts +30 -10
  184. package/dist/types/generated/index.d.ts +5 -5
  185. package/dist/types/generated/openapi.d.ts +1257 -0
  186. package/dist/types/generated/ottochain/apps/contracts/v1/contract.d.ts +5 -5
  187. package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +12 -12
  188. package/dist/types/generated/ottochain/apps/markets/v1/market.d.ts +11 -11
  189. package/dist/types/generated/ottochain/v1/common.d.ts +228 -0
  190. package/dist/types/generated/ottochain/v1/fiber.d.ts +32 -1
  191. package/dist/types/generated/ottochain/v1/messages.d.ts +84 -0
  192. package/dist/types/generated/ottochain/v1/records.d.ts +34 -0
  193. package/dist/types/index.d.ts +8 -2
  194. package/dist/types/openapi.d.ts +22 -0
  195. package/dist/types/ottochain/genesis-manifest.d.ts +130 -0
  196. package/dist/types/ottochain/index.d.ts +6 -5
  197. package/dist/types/ottochain/metagraph-client.d.ts +49 -7
  198. package/dist/types/ottochain/snapshot.d.ts +6 -6
  199. package/dist/types/ottochain/transaction.d.ts +33 -1
  200. package/dist/types/ottochain/types.d.ts +602 -11
  201. package/dist/types/privacy/index.d.ts +6 -0
  202. package/dist/types/privacy/sealed-bid.d.ts +348 -0
  203. package/dist/types/privacy/shield-app.d.ts +48 -0
  204. package/dist/types/schema/effects.d.ts +34 -0
  205. package/dist/types/schema/fiber-app.d.ts +41 -3
  206. package/dist/types/schema/guard-lint.d.ts +111 -0
  207. package/dist/types/schema/guards.d.ts +134 -0
  208. package/dist/types/signing.d.ts +45 -0
  209. package/dist/types/validation.d.ts +22 -217
  210. package/dist/types/verify.d.ts +4 -0
  211. package/dist/types/zk/commit.d.ts +28 -0
  212. package/dist/types/zk/guard.d.ts +46 -0
  213. package/dist/types/zk/index.d.ts +19 -0
  214. package/dist/types/zk/preimage.d.ts +10 -0
  215. package/dist/types/zk/prover.d.ts +34 -0
  216. package/dist/types/zk/registry.d.ts +34 -0
  217. package/dist/types/zk/types.d.ts +33 -0
  218. package/dist/types/zk/witness.d.ts +40 -0
  219. package/package.json +52 -35
  220. package/dist/cjs/ottochain/normalize.js +0 -186
  221. package/dist/esm/ottochain/normalize.js +0 -179
  222. package/dist/types/ottochain/normalize.d.ts +0 -79
@@ -17,16 +17,22 @@
17
17
  */
18
18
  export * from '@constellation-network/metagraph-sdk';
19
19
  export { verify } from './verify.js';
20
+ export { signDataUpdate, createSignedObject, addSignature, batchSign } from './signing.js';
20
21
  export { MetagraphClient, createMetagraphClient, HttpClient, NetworkError as MetagraphNetworkError, } from '@constellation-network/metagraph-sdk/network';
21
22
  export type { MetagraphClientConfig as BaseMetagraphClientConfig, LayerType, ClusterInfo, } from '@constellation-network/metagraph-sdk/network';
22
23
  export type { RequestOptions, TransactionStatus, PendingTransaction, PostTransactionResponse, EstimateFeeResponse, PostDataResponse, } from '@constellation-network/metagraph-sdk/network';
23
24
  export * from './types.js';
24
25
  export * from './ottochain/transaction.js';
25
- export { normalizeCreateStateMachine, normalizeTransitionStateMachine, normalizeArchiveStateMachine, normalizeMessage } from './ottochain/normalize.js';
26
26
  export { dropNulls } from './ottochain/drop-nulls.js';
27
+ export { buildGenesisManifest, GENESIS_MANIFEST_VERSION } from './ottochain/genesis-manifest.js';
28
+ export type { GenesisManifest, GenesisPackage, GenesisMachineShape, GenesisMessageShape, GenesisFieldShape, GenesisStateMachineDefinition, } from './ottochain/index.js';
27
29
  export * from './generated/index.js';
28
30
  export { OttoChainError, NetworkError, ValidationError, SigningError, TransactionError, ErrorCode, isErrorCode, wrapError, } from './errors.js';
29
31
  export { DagAddressSchema, PrivateKeySchema, PublicKeySchema, KeyPairSchema, SignatureProofSchema, SignedSchema, TransactionReferenceSchema, CurrencyTransactionValueSchema, CurrencyTransactionSchema, TransferParamsSchema, AgentIdentityRegistrationSchema, PlatformLinkSchema, ContractTermsSchema, ProposeContractRequestSchema, AcceptContractRequestSchema, CompleteContractRequestSchema, validate, validatePrivateKey, validatePublicKey, validateAddress, validateKeyPair, safeParse, assert, type ValidatedKeyPair, type ValidatedSignatureProof, type ValidatedCurrencyTransaction, type ValidatedTransferParams, type ValidatedAgentIdentityRegistration, type ValidatedPlatformLink, type ValidatedProposeContractRequest, type ValidatedAcceptContractRequest, type ValidatedCompleteContractRequest, } from './validation.js';
30
32
  export { MetagraphClient as OttoMetagraphClient } from './ottochain/metagraph-client.js';
31
33
  export type { MetagraphClientConfig, Checkpoint, SubscribeOptions, FiberStateCallback, Unsubscribe, } from './ottochain/metagraph-client.js';
32
- export { toProtoDefinition, defineFiberApp, type ProtoStateMachineDefinition, type FiberAppDefinition, type FiberAppMetadata, type StateDefinition, type Transition, } from './schema/fiber-app.js';
34
+ export { toProtoDefinition, defineFiberApp, type ProtoStateMachineDefinition, type FiberAppDefinition, type FiberAppMetadata, type StateDefinition, type StdStateMetadata, type StateCategory, type Transition, } from './schema/fiber-app.js';
35
+ export { type GuardRule, signerIsParty, signerIsAnyParty, signerInSet, signerIsNotParty, signerHasEntry, assetSignerIs, actorIsSigner, actorInSet, actorHasEntry, signerHasReputation, signerHasRole, signerHasReputationVia, signerHasRoleVia, depInState, } from './schema/guards.js';
36
+ export { addDependency, setDependencyActive } from './schema/effects.js';
37
+ export { shieldApp, SHIELDED_POOL_STATE, type ShieldOptions } from './privacy/shield-app.js';
38
+ export type { paths as ApiPaths, operations as ApiOperations, components as ApiComponents, VersionInfo, TransitionFeeEstimate, ScriptFeeEstimate, SubscribeRequest, SubscribeResponse, Subscriber, SubscriberList, } from './openapi.js';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Typed OttoChain HTTP API surface.
3
+ *
4
+ * These types are generated from the metagraph's OpenAPI contract
5
+ * (`openapi/ottochain-openapi.json`, emitted by ottochain's tapir `ApiEndpoints`) — so the SDK and the
6
+ * chain share ONE source of truth for request/response shapes, instead of reverse-engineering them inline.
7
+ *
8
+ * Regenerate after the contract changes with `pnpm gen:openapi`. The raw generated module is
9
+ * `src/generated/openapi.ts`; this file gives consumers stable, named aliases for the precise response
10
+ * DTOs. Heavy domain bodies (onchain, checkpoint, records, state proofs) are typed `unknown`/opaque in
11
+ * the contract for now — see ottochain `docs/proposals/typed-network-interface.md` §3.
12
+ */
13
+ import type { components, operations, paths } from './generated/openapi.js';
14
+ export type { components, operations, paths };
15
+ type Schemas = components['schemas'];
16
+ export type VersionInfo = Schemas['VersionInfo'];
17
+ export type TransitionFeeEstimate = Schemas['TransitionFeeEstimate'];
18
+ export type ScriptFeeEstimate = Schemas['ScriptFeeEstimate'];
19
+ export type SubscribeRequest = Schemas['SubscribeRequest'];
20
+ export type SubscribeResponse = Schemas['SubscribeResponse'];
21
+ export type Subscriber = Schemas['Subscriber'];
22
+ export type SubscriberList = Schemas['SubscriberList'];
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Genesis Manifest Exporter
3
+ *
4
+ * The ottochain metagraph can boot from a NON-EMPTY genesis: a set of standard
5
+ * packages pre-registered in the registry before any user transaction. This SDK
6
+ * is the source of truth for those std apps (their proto schemas + JSON-Logic
7
+ * state-machine definitions), so it is also the source of truth for the
8
+ * *genesis manifest* — the per-app CONTENT the chain needs to pre-register each
9
+ * package at genesis.
10
+ *
11
+ * DESIGN — content, not consensus hashes:
12
+ * The manifest ships CONTENT only: the `machineShape` (the typed, proto-faithful
13
+ * projection of the app's state message) and the `definition` (the JSON-Logic
14
+ * `StateMachineDefinition`, verbatim — the same object the chain decodes for any
15
+ * fiber). The CHAIN computes the consensus values itself from this content:
16
+ * - `logicHash` = `StateMachineDefinition.computeDigest(definition)`
17
+ * - `schemaHash` = commitment over the FileDescriptorSet (off-chain/Bridge)
18
+ * We deliberately do NOT replicate the chain's canonical hashing here, so there
19
+ * is ZERO hash-parity risk. No advisory hashes are emitted (see HONESTY notes in
20
+ * the PR description); add them later only if an off-chain consumer needs them,
21
+ * clearly marked advisory.
22
+ *
23
+ * NAMING — the reserved `std` label:
24
+ * Each package is named `std.<app>.package`. `RegistryName` reserves the `std`
25
+ * label in-protocol (`RegistryName.isReserved`), so ordinary user registrations
26
+ * of `std.*` are rejected — only the privileged genesis path may claim them.
27
+ * That is exactly the point: users cannot squat the standard names.
28
+ *
29
+ * SCHEMA SHAPES — chain-verified ground truth:
30
+ * The three `stateMessage` shapes are reproduced verbatim from the chain's own
31
+ * conformance suite (`StandardAppsConformanceSuite`, the `identity` / `proposal`
32
+ * / `market` `MessageShape` vals), which proves the on-chain shape validator and
33
+ * the conformance gate accept them. `commands` is left EMPTY for this first cut —
34
+ * the conformance suite itself models all three apps with `SortedMap.empty`
35
+ * commands, and the proto `*Request` messages are transaction-layer DTOs that do
36
+ * not map cleanly onto the universal state machines' free-form JSON-Logic event
37
+ * payloads. Deriving per-event command shapes is a flagged follow-up.
38
+ *
39
+ * The JSON shape emitted here is built to deserialize against the chain's circe
40
+ * codecs (`MachineShape` / `FieldShape` / `MessageShape` and
41
+ * `StateMachineDefinition`), whose magnolia config is camelCase with defaults.
42
+ *
43
+ * @packageDocumentation
44
+ */
45
+ /**
46
+ * One field of a protobuf message, mirroring a `FieldDescriptorProto` at the
47
+ * field level. Matches the chain's `FieldShape` (camelCase, defaults for
48
+ * `repeated`/`optional`).
49
+ */
50
+ export interface FieldShape {
51
+ name: string;
52
+ number: number;
53
+ typeName: string;
54
+ repeated: boolean;
55
+ optional: boolean;
56
+ }
57
+ /** A protobuf message projection. Matches the chain's `MessageShape`. */
58
+ export interface MessageShape {
59
+ typeName: string;
60
+ fields: FieldShape[];
61
+ }
62
+ /**
63
+ * The typed, proto-faithful projection of a registered schema. Matches the
64
+ * chain's `MachineShape`: the state message plus one message per command/event,
65
+ * keyed by event name.
66
+ */
67
+ export interface MachineShape {
68
+ stateMessage: MessageShape;
69
+ commands: Record<string, MessageShape>;
70
+ }
71
+ /**
72
+ * A JSON-Logic `StateMachineDefinition` as the chain decodes it. Kept as an
73
+ * opaque JSON object: the chain owns its meaning and its hashing. `from`/`to`
74
+ * and the `states` keys are bare strings (the chain's `StateId` encodes as a
75
+ * string); `dependencies` defaults to `[]` and state `metadata` to `null`.
76
+ */
77
+ export interface StateMachineDefinition {
78
+ states: Record<string, {
79
+ id: string;
80
+ isFinal: boolean;
81
+ metadata: unknown | null;
82
+ }>;
83
+ initialState: string;
84
+ transitions: Array<{
85
+ from: string;
86
+ to: string;
87
+ eventName: string;
88
+ guard: unknown;
89
+ effect: unknown;
90
+ dependencies: unknown[];
91
+ }>;
92
+ metadata: unknown | null;
93
+ }
94
+ /**
95
+ * One package to pre-register at genesis. This is the genesis INPUT, not the
96
+ * chain's stored `RegisteredVersion`: it carries CONTENT only and the chain
97
+ * derives `schemaHash` / `logicHash` from it.
98
+ */
99
+ export interface GenesisPackage {
100
+ /** RegistryName `"<labels>.package"`, e.g. `std.identity.package`. */
101
+ name: string;
102
+ /** SemVer of this initial version. */
103
+ semver: string;
104
+ /** Opt-in runtime conformance gate (`RegisteredVersion.strict`). */
105
+ strict: boolean;
106
+ /** Free-form notes map (<=8 entries, key <=32 chars, value <=128 chars). */
107
+ metadata: Record<string, string>;
108
+ /** Typed, proto-faithful projection of the app's schema. */
109
+ machineShape: MachineShape;
110
+ /** The JSON-Logic state-machine definition, verbatim. */
111
+ definition: StateMachineDefinition;
112
+ }
113
+ /** The full genesis manifest the chain consumes to bootstrap its registry. */
114
+ export interface GenesisManifest {
115
+ version: number;
116
+ packages: GenesisPackage[];
117
+ }
118
+ /** Manifest schema version. Bump on any breaking change to the shape. */
119
+ export declare const GENESIS_MANIFEST_VERSION = 1;
120
+ /**
121
+ * Assemble the genesis manifest for the standard apps.
122
+ *
123
+ * Covers THREE apps in this first cut — identity, governance, markets (all the
124
+ * `universal` variant). The other std apps (contracts, oracles, corporate) and
125
+ * non-universal variants are a flagged follow-up.
126
+ *
127
+ * @returns a `GenesisManifest` whose JSON deserializes against the chain's circe
128
+ * codecs. Hashes are intentionally absent — the chain derives them.
129
+ */
130
+ export declare function buildGenesisManifest(): GenesisManifest;
@@ -6,13 +6,14 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  export * as proto from '../generated/index.js';
9
- export type { Address, FiberId, StateId, HashValue, FiberOrdinal, SnapshotOrdinal, JsonLogicValue, JsonLogicExpression, FiberStatus, AccessControlPolicy, StateMachineDefinition, EmittedEvent, EventReceipt, OracleInvocation, FiberLogEntry, StateMachineFiberRecord, ScriptFiberRecord, FiberRecord, FiberCommit, OnChain, CalculatedState, CreateStateMachine, TransitionStateMachine, ArchiveStateMachine, CreateScript, InvokeScript, OttochainMessage, OttochainMessageType, } from './types.js';
10
- export { OTTOCHAIN_MESSAGE_TYPES } from './types.js';
9
+ export type { Address, FiberId, StateId, HashValue, FiberOrdinal, SnapshotOrdinal, JsonLogicValue, JsonLogicExpression, FiberStatus, AccessControlPolicy, StateMachineDefinition, SemVer, RegistryStatus, VersionReq, SchemaRef, FieldShape, MessageShape, MachineShape, ScriptShape, RegistryShape, SchemaBinding, RegisteredVersion, VersionLineage, RegistryTarget, RegistryEntry, EmittedEvent, EventReceipt, ScriptInvocation, CreationReceipt, UpgradeReceipt, RejectionReceipt, FiberLogEntry, StateMachineFiberRecord, ScriptFiberRecord, FiberRecord, FiberCommit, OnChain, CalculatedState, CreateStateMachine, TransitionStateMachine, ArchiveStateMachine, UpgradeFiber, CreateScript, InvokeScript, UpgradeScript, PublishMachineVersion, PublishScriptVersion, SetVersionStatus, RegisterAlias, CreateAssetPolicy, MintAsset, ApplyMorphism, AuthorizeCompose, OttochainMessage, OttochainMessageType, MorphismKind, MorphismVisibility, TokenBehavior, SupplyPolicy, MorphismSpec, AssetHolder, OriginProvenance, ComponentWitness, AssetRecord, AssetCommit, } from './types.js';
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, MetagraphClientConfig, SubscribeOptions, FiberStateCallback, Unsubscribe, } from './metagraph-client.js';
13
+ export type { Checkpoint, StateProof, FeeEstimate, MetagraphClientConfig, SubscribeOptions, FiberStateCallback, Unsubscribe, } from './metagraph-client.js';
14
14
  export { MetagraphClient } from './metagraph-client.js';
15
- export { createTransitionPayload, createArchivePayload, createInvokeScriptPayload, signTransaction, addTransactionSignature, getPublicKeyForRegistration, createStateMachinePayload, createScriptPayload, createDataTransactionRequest, } from './transaction.js';
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';
17
- export { normalizeCreateStateMachine, normalizeTransitionStateMachine, normalizeArchiveStateMachine, normalizeMessage, } from './normalize.js';
18
17
  export { dropNulls } from './drop-nulls.js';
18
+ export { buildGenesisManifest, GENESIS_MANIFEST_VERSION } from './genesis-manifest.js';
19
+ export type { GenesisManifest, GenesisPackage, MachineShape as GenesisMachineShape, MessageShape as GenesisMessageShape, FieldShape as GenesisFieldShape, StateMachineDefinition as GenesisStateMachineDefinition, } from './genesis-manifest.js';
@@ -4,12 +4,12 @@
4
4
  * Client for interacting with ottochain ML0 custom routes (/v1 prefix)
5
5
  * and framework snapshot endpoints.
6
6
  *
7
- * @see modules/l0/src/main/scala/xyz/kd5ujc/metagraph_l0/ML0CustomRoutes.scala
7
+ * @see modules/l0/src/main/scala/xyz/kd5ujc/metagraph_l0/ML0Routes.scala
8
8
  * @see modules/data_l1/src/main/scala/xyz/kd5ujc/data_l1/DataL1CustomRoutes.scala
9
9
  * @packageDocumentation
10
10
  */
11
11
  import type { Signed } from '@constellation-network/metagraph-sdk';
12
- import type { OnChain, CalculatedState, StateMachineFiberRecord, ScriptFiberRecord, EventReceipt, OracleInvocation, FiberStatus } from './types.js';
12
+ import type { OnChain, CalculatedState, StateMachineFiberRecord, ScriptFiberRecord, EventReceipt, ScriptInvocation, FiberStatus, RegistryEntry } from './types.js';
13
13
  /**
14
14
  * Checkpoint response from the metagraph (ordinal + calculated state).
15
15
  */
@@ -17,6 +17,28 @@ export interface Checkpoint {
17
17
  ordinal: number;
18
18
  state: CalculatedState;
19
19
  }
20
+ /**
21
+ * A light-client state proof for one field of a fiber/asset record, verifiable against the
22
+ * consensus-signed committed-state root (Merkle-Patricia inclusion). Returned by the `state-proof`
23
+ * endpoints.
24
+ */
25
+ export interface StateProof {
26
+ /** The record (or projected field) the proof attests to. */
27
+ record: unknown;
28
+ /** The committed-state combined root (= the snapshot's `calculatedStateProof`). */
29
+ committedRoot: string;
30
+ /** The Merkle-Patricia trie root. */
31
+ mptRoot: string;
32
+ ordinal: number;
33
+ /** The Merkle-Patricia inclusion proof. */
34
+ proof: unknown;
35
+ }
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
+ }
20
42
  /**
21
43
  * Options for subscribeFiberState polling behaviour.
22
44
  */
@@ -86,7 +108,7 @@ export interface MetagraphClientConfig {
86
108
  * const onChain = await client.getOnChain();
87
109
  *
88
110
  * // Get all active state machines
89
- * const machines = await client.getStateMachines('Active');
111
+ * const machines = await client.getStateMachines('ACTIVE');
90
112
  *
91
113
  * // Get event receipts for a fiber
92
114
  * const events = await client.getStateMachineEvents(fiberId);
@@ -118,17 +140,37 @@ export declare class MetagraphClient {
118
140
  */
119
141
  getStateMachineEvents(fiberId: string): Promise<EventReceipt[]>;
120
142
  /**
121
- * Get all script oracles, optionally filtered by status.
143
+ * Get all scripts, optionally filtered by status.
122
144
  */
123
145
  getScripts(status?: FiberStatus): Promise<Record<string, ScriptFiberRecord>>;
124
146
  /**
125
- * Get a single script oracle by fiber ID.
147
+ * Get a single script by fiber ID.
126
148
  */
127
149
  getScript(scriptId: string): Promise<ScriptFiberRecord | null>;
128
150
  /**
129
- * Get oracle invocations from the current ordinal's logs.
151
+ * Get script invocations from the current ordinal's logs.
130
152
  */
131
- getScriptInvocations(scriptId: string): Promise<OracleInvocation[]>;
153
+ getScriptInvocations(scriptId: string): Promise<ScriptInvocation[]>;
154
+ /** Get the metagraph version string. */
155
+ getVersion(): Promise<string>;
156
+ /** Get the full registry namespace, keyed by full registry name `labels.tld`. */
157
+ getRegistry(): Promise<Record<string, RegistryEntry>>;
158
+ /** Resolve a single registry entry by full name (`labels.tld`), or null if unregistered. */
159
+ getRegistryEntry(name: string): Promise<RegistryEntry | null>;
160
+ /** Reverse-resolve a fiber UUID to its canonical registered name (#29), or null. */
161
+ getReverseName(fiberId: string): Promise<string | null>;
162
+ /** Get the rendered audit-trail lines for a state-machine fiber. */
163
+ getStateMachineAudit(fiberId: string): Promise<string[]>;
164
+ /** Light-client state proof for a field of a state-machine fiber, against the committed root. */
165
+ getStateMachineStateProof(fiberId: string, field: string): Promise<StateProof>;
166
+ /** Light-client state proof for a field of a script fiber. */
167
+ getScriptStateProof(fiberId: string, field: string): Promise<StateProof>;
168
+ /** Light-client state proof for a field of an asset instance. */
169
+ 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>;
132
174
  /**
133
175
  * Get the latest snapshot and decode its on-chain state.
134
176
  */
@@ -9,7 +9,7 @@
9
9
  * @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
10
10
  * @packageDocumentation
11
11
  */
12
- import type { OnChain, EventReceipt, OracleInvocation, FiberLogEntry } from './types.js';
12
+ import type { OnChain, EventReceipt, ScriptInvocation, FiberLogEntry } from './types.js';
13
13
  /**
14
14
  * Decode on-chain state from binary (JsonBinaryCodec format).
15
15
  *
@@ -65,7 +65,7 @@ export declare function getLogsForFiber(onChain: OnChain, fiberId: string): Fibe
65
65
  /**
66
66
  * Get EventReceipt log entries for a specific fiber.
67
67
  *
68
- * EventReceipts are distinguished from OracleInvocations by the presence
68
+ * EventReceipts are distinguished from ScriptInvocations by the presence
69
69
  * of the `eventName` field.
70
70
  *
71
71
  * @param onChain - Decoded on-chain state
@@ -74,13 +74,13 @@ export declare function getLogsForFiber(onChain: OnChain, fiberId: string): Fibe
74
74
  */
75
75
  export declare function getEventReceipts(onChain: OnChain, fiberId: string): EventReceipt[];
76
76
  /**
77
- * Get OracleInvocation log entries for a specific fiber.
77
+ * Get ScriptInvocation log entries for a specific fiber.
78
78
  *
79
- * OracleInvocations are distinguished from EventReceipts by the presence
79
+ * ScriptInvocations are distinguished from EventReceipts by the presence
80
80
  * of the `method` field.
81
81
  *
82
82
  * @param onChain - Decoded on-chain state
83
83
  * @param fiberId - Fiber UUID to filter by
84
- * @returns Array of OracleInvocation entries
84
+ * @returns Array of ScriptInvocation entries
85
85
  */
86
- export declare function getScriptInvocations(onChain: OnChain, fiberId: string): OracleInvocation[];
86
+ export declare function getScriptInvocations(onChain: OnChain, fiberId: string): ScriptInvocation[];
@@ -5,6 +5,7 @@
5
5
  * self-signed mode, where clients sign their own transactions.
6
6
  */
7
7
  import type { Signed } from '@constellation-network/metagraph-sdk';
8
+ import type { CreateAssetPolicy, MintAsset, ApplyMorphism, AuthorizeCompose } from './types.js';
8
9
  /**
9
10
  * Parameters for creating a new state machine fiber
10
11
  */
@@ -28,6 +29,13 @@ export interface CreateStateMachineMessage {
28
29
  /**
29
30
  * Create a new state machine fiber payload.
30
31
  *
32
+ * @remarks
33
+ * `params.definition` is signed VERBATIM. Pass the output of `toProtoDefinition(def)` (the
34
+ * allowlisted wire shape) — NOT a raw `FiberAppDefinition`: extra authoring fields
35
+ * (`createSchema` / `stateSchema` / `eventSchemas` / per-transition `emits`) would be signed
36
+ * but re-encoded away by the chain, diverging the canonical → opaque `InvalidSignature`.
37
+ * See `tests/ottochain/signing-parity.test.ts`.
38
+ *
31
39
  * @param params - State machine creation parameters
32
40
  * @returns A CreateStateMachine message ready for signing
33
41
  *
@@ -145,7 +153,7 @@ export interface CreateScriptMessage {
145
153
  * },
146
154
  * },
147
155
  * initialState: { value: 0 },
148
- * accessControl: { type: 'open' },
156
+ * accessControl: { Public: {} },
149
157
  * });
150
158
  * const signed = await signTransaction(script, privateKey);
151
159
  * ```
@@ -178,12 +186,33 @@ export interface InvokeScriptMessage {
178
186
  * @returns An InvokeScript message ready for signing
179
187
  */
180
188
  export declare function createInvokeScriptPayload(params: InvokeScriptParams): InvokeScriptMessage;
189
+ /** Wrap a {@link CreateAssetPolicy} (publish an asset-policy package version). */
190
+ export declare function createAssetPolicyPayload(params: CreateAssetPolicy): {
191
+ CreateAssetPolicy: CreateAssetPolicy;
192
+ };
193
+ /** Wrap a {@link MintAsset} (mint a new asset instance against a resolved policy version). */
194
+ export declare function createMintAssetPayload(params: MintAsset): {
195
+ MintAsset: MintAsset;
196
+ };
197
+ /** Wrap an {@link ApplyMorphism} (apply a typed morphism to an asset instance). */
198
+ export declare function createApplyMorphismPayload(params: ApplyMorphism): {
199
+ ApplyMorphism: ApplyMorphism;
200
+ };
201
+ /** Wrap an {@link AuthorizeCompose} (commit half of the symmetric-compose handshake). */
202
+ export declare function createAuthorizeComposePayload(params: AuthorizeCompose): {
203
+ AuthorizeCompose: AuthorizeCompose;
204
+ };
181
205
  /**
182
206
  * Sign a transaction payload for self-signed mode.
183
207
  *
184
208
  * This creates a Signed<T> object with the exact format expected by the bridge's
185
209
  * `/agent/transition` endpoint when using self-signed mode.
186
210
  *
211
+ * The signature is computed over the null-dropped canonical bytes (null
212
+ * object fields removed recursively, array nulls preserved, then RFC 8785),
213
+ * matching metakit's content-hash rule. Explicit-null and absent optional
214
+ * fields therefore produce identical signatures.
215
+ *
187
216
  * @param message - The message to sign (e.g., from createTransitionPayload)
188
217
  * @param privateKey - The private key in hex format (64 characters)
189
218
  * @returns A signed object ready for submission to the bridge
@@ -251,6 +280,9 @@ export declare function createDataTransactionRequest<T>(signed: Signed<T>): Data
251
280
  * Use this for multi-signature scenarios where multiple parties
252
281
  * need to sign the same transaction.
253
282
  *
283
+ * The new signature is computed over the null-dropped canonical bytes,
284
+ * matching metakit's content-hash rule (see {@link signTransaction}).
285
+ *
254
286
  * @param signed - The already-signed transaction
255
287
  * @param privateKey - Additional signer's private key
256
288
  * @returns Transaction with additional signature