@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.
- package/dist/cjs/apps/contracts/index.js +15 -8
- package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +89 -46
- package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +152 -45
- package/dist/cjs/apps/contracts/state-machines/contract-universal.js +40 -8
- package/dist/cjs/apps/corporate/index.js +2 -2
- package/dist/cjs/apps/corporate/state-machines/corp-board.js +169 -59
- package/dist/cjs/apps/corporate/state-machines/corp-entity.js +245 -47
- package/dist/cjs/apps/corporate/state-machines/corp-securities.js +407 -99
- package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +151 -37
- package/dist/cjs/apps/governance/index.js +14 -14
- package/dist/cjs/apps/governance/state-machines/dao-multisig.js +85 -43
- package/dist/cjs/apps/governance/state-machines/dao-reputation.js +73 -43
- package/dist/cjs/apps/governance/state-machines/dao-single.js +55 -14
- package/dist/cjs/apps/governance/state-machines/dao-token.js +103 -45
- package/dist/cjs/apps/governance/state-machines/governance-simple.js +129 -65
- package/dist/cjs/apps/governance/state-machines/governance-universal.js +29 -5
- package/dist/cjs/apps/identity/constants.js +55 -14
- package/dist/cjs/apps/identity/index.js +27 -11
- package/dist/cjs/apps/identity/state-machines/identity-agent.js +57 -9
- package/dist/cjs/apps/identity/state-machines/identity-oracle.js +70 -27
- package/dist/cjs/apps/identity/state-machines/identity-registry.js +288 -0
- package/dist/cjs/apps/identity/state-machines/identity-universal.js +30 -6
- package/dist/cjs/apps/identity/state-machines/index.js +3 -1
- package/dist/cjs/apps/index.js +19 -8
- package/dist/cjs/apps/lending/assets.js +223 -0
- package/dist/cjs/apps/lending/credit-scoring.js +87 -0
- package/dist/cjs/apps/lending/eligibility.js +121 -0
- package/dist/cjs/apps/lending/index.js +91 -0
- package/dist/cjs/apps/lending/state-machines/index.js +9 -0
- package/dist/cjs/apps/lending/state-machines/lending-zk-loan.js +412 -0
- package/dist/cjs/apps/markets/index.js +21 -11
- package/dist/cjs/apps/markets/state-machines/market-auction.js +44 -19
- package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +54 -29
- package/dist/cjs/apps/markets/state-machines/market-group-buy.js +53 -31
- package/dist/cjs/apps/markets/state-machines/market-prediction.js +120 -61
- package/dist/cjs/apps/markets/state-machines/market-universal.js +50 -10
- package/dist/cjs/apps/oracles/index.js +2 -2
- package/dist/cjs/errors.js +3 -3
- package/dist/cjs/generated/google/protobuf/struct.js +4 -4
- package/dist/cjs/generated/index.js +11 -7
- package/dist/cjs/generated/openapi.js +6 -0
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +50 -50
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +19 -20
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +13 -13
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +4 -4
- package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +124 -130
- package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +107 -107
- package/dist/cjs/generated/ottochain/v1/common.js +1722 -1
- package/dist/cjs/generated/ottochain/v1/fiber.js +355 -5
- package/dist/cjs/generated/ottochain/v1/messages.js +775 -3
- package/dist/cjs/generated/ottochain/v1/records.js +350 -3
- package/dist/cjs/index.js +45 -7
- package/dist/cjs/openapi.js +2 -0
- package/dist/cjs/ottochain/drop-nulls.js +1 -2
- package/dist/cjs/ottochain/genesis-manifest.js +193 -0
- package/dist/cjs/ottochain/index.js +27 -13
- package/dist/cjs/ottochain/metagraph-client.js +65 -8
- package/dist/cjs/ottochain/snapshot.js +11 -12
- package/dist/cjs/ottochain/transaction.js +57 -14
- package/dist/cjs/ottochain/types.js +19 -1
- package/dist/cjs/privacy/index.js +14 -0
- package/dist/cjs/privacy/sealed-bid.js +210 -0
- package/dist/cjs/privacy/shield-app.js +131 -0
- package/dist/cjs/schema/effects.js +40 -0
- package/dist/cjs/schema/fiber-app.js +19 -13
- package/dist/cjs/schema/guard-lint.js +352 -0
- package/dist/cjs/schema/guards.js +246 -0
- package/dist/cjs/signing.js +80 -0
- package/dist/cjs/types.js +2 -3
- package/dist/cjs/validation.js +8 -8
- package/dist/cjs/verify.js +9 -4
- package/dist/cjs/zk/commit.js +53 -0
- package/dist/cjs/zk/guard.js +107 -0
- package/dist/cjs/zk/index.js +48 -0
- package/dist/cjs/zk/preimage.js +37 -0
- package/dist/cjs/zk/prover.js +87 -0
- package/dist/cjs/zk/registry.js +62 -0
- package/dist/cjs/zk/types.js +28 -0
- package/dist/cjs/zk/witness.js +19 -0
- package/dist/esm/apps/contracts/index.js +7 -3
- package/dist/esm/apps/contracts/state-machines/contract-agreement.js +89 -46
- package/dist/esm/apps/contracts/state-machines/contract-escrow.js +152 -45
- package/dist/esm/apps/contracts/state-machines/contract-universal.js +40 -8
- package/dist/esm/apps/corporate/state-machines/corp-board.js +169 -59
- package/dist/esm/apps/corporate/state-machines/corp-entity.js +245 -47
- package/dist/esm/apps/corporate/state-machines/corp-securities.js +407 -99
- package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +151 -37
- package/dist/esm/apps/governance/state-machines/dao-multisig.js +85 -43
- package/dist/esm/apps/governance/state-machines/dao-reputation.js +73 -43
- package/dist/esm/apps/governance/state-machines/dao-single.js +55 -14
- package/dist/esm/apps/governance/state-machines/dao-token.js +103 -45
- package/dist/esm/apps/governance/state-machines/governance-simple.js +129 -65
- package/dist/esm/apps/governance/state-machines/governance-universal.js +29 -5
- package/dist/esm/apps/identity/constants.js +51 -12
- package/dist/esm/apps/identity/index.js +12 -7
- package/dist/esm/apps/identity/state-machines/identity-agent.js +57 -9
- package/dist/esm/apps/identity/state-machines/identity-oracle.js +70 -27
- package/dist/esm/apps/identity/state-machines/identity-registry.js +285 -0
- package/dist/esm/apps/identity/state-machines/identity-universal.js +30 -6
- package/dist/esm/apps/identity/state-machines/index.js +1 -0
- package/dist/esm/apps/index.js +1 -0
- package/dist/esm/apps/lending/assets.js +207 -0
- package/dist/esm/apps/lending/credit-scoring.js +81 -0
- package/dist/esm/apps/lending/eligibility.js +115 -0
- package/dist/esm/apps/lending/index.js +69 -0
- package/dist/esm/apps/lending/state-machines/index.js +5 -0
- package/dist/esm/apps/lending/state-machines/lending-zk-loan.js +409 -0
- package/dist/esm/apps/markets/index.js +8 -4
- package/dist/esm/apps/markets/state-machines/market-auction.js +44 -19
- package/dist/esm/apps/markets/state-machines/market-crowdfund.js +54 -29
- package/dist/esm/apps/markets/state-machines/market-group-buy.js +53 -31
- package/dist/esm/apps/markets/state-machines/market-prediction.js +120 -61
- package/dist/esm/apps/markets/state-machines/market-universal.js +50 -10
- package/dist/esm/generated/index.js +9 -5
- package/dist/esm/generated/openapi.js +5 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +46 -46
- package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +114 -120
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +100 -100
- package/dist/esm/generated/ottochain/v1/common.js +1718 -0
- package/dist/esm/generated/ottochain/v1/fiber.js +351 -1
- package/dist/esm/generated/ottochain/v1/messages.js +774 -2
- package/dist/esm/generated/ottochain/v1/records.js +349 -2
- package/dist/esm/index.js +23 -2
- package/dist/esm/openapi.js +1 -0
- package/dist/esm/ottochain/genesis-manifest.js +189 -0
- package/dist/esm/ottochain/index.js +4 -3
- package/dist/esm/ottochain/metagraph-client.js +65 -8
- package/dist/esm/ottochain/snapshot.js +4 -4
- package/dist/esm/ottochain/transaction.js +43 -3
- package/dist/esm/ottochain/types.js +18 -0
- package/dist/esm/privacy/index.js +6 -0
- package/dist/esm/privacy/sealed-bid.js +206 -0
- package/dist/esm/privacy/shield-app.js +127 -0
- package/dist/esm/schema/effects.js +35 -0
- package/dist/esm/schema/fiber-app.js +13 -6
- package/dist/esm/schema/guard-lint.js +346 -0
- package/dist/esm/schema/guards.js +229 -0
- package/dist/esm/signing.js +74 -0
- package/dist/esm/verify.js +8 -2
- package/dist/esm/zk/commit.js +44 -0
- package/dist/esm/zk/guard.js +99 -0
- package/dist/esm/zk/index.js +19 -0
- package/dist/esm/zk/preimage.js +30 -0
- package/dist/esm/zk/prover.js +82 -0
- package/dist/esm/zk/registry.js +55 -0
- package/dist/esm/zk/types.js +25 -0
- package/dist/esm/zk/witness.js +15 -0
- package/dist/types/apps/contracts/index.d.ts +159 -227
- package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +50 -101
- package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +86 -120
- package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +20 -4
- package/dist/types/apps/corporate/index.d.ts +1040 -304
- package/dist/types/apps/corporate/state-machines/corp-board.d.ts +188 -52
- package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +267 -62
- package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +355 -131
- package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +225 -53
- package/dist/types/apps/governance/index.d.ts +396 -417
- package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +92 -95
- package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +57 -69
- package/dist/types/apps/governance/state-machines/dao-single.d.ts +40 -50
- package/dist/types/apps/governance/state-machines/dao-token.d.ts +80 -53
- package/dist/types/apps/governance/state-machines/governance-simple.d.ts +107 -121
- package/dist/types/apps/governance/state-machines/governance-universal.d.ts +17 -5
- package/dist/types/apps/identity/constants.d.ts +32 -4
- package/dist/types/apps/identity/index.d.ts +449 -100
- package/dist/types/apps/identity/state-machines/identity-agent.d.ts +30 -0
- package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +41 -87
- package/dist/types/apps/identity/state-machines/identity-registry.d.ts +379 -0
- package/dist/types/apps/identity/state-machines/identity-universal.d.ts +15 -0
- package/dist/types/apps/identity/state-machines/index.d.ts +1 -0
- package/dist/types/apps/index.d.ts +1 -0
- package/dist/types/apps/lending/assets.d.ts +258 -0
- package/dist/types/apps/lending/credit-scoring.d.ts +80 -0
- package/dist/types/apps/lending/eligibility.d.ts +83 -0
- package/dist/types/apps/lending/index.d.ts +548 -0
- package/dist/types/apps/lending/state-machines/index.d.ts +5 -0
- package/dist/types/apps/lending/state-machines/lending-zk-loan.d.ts +528 -0
- package/dist/types/apps/markets/index.d.ts +184 -204
- package/dist/types/apps/markets/state-machines/market-auction.d.ts +25 -37
- package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +26 -34
- package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +31 -43
- package/dist/types/apps/markets/state-machines/market-prediction.d.ts +67 -72
- package/dist/types/apps/markets/state-machines/market-universal.d.ts +30 -10
- package/dist/types/generated/index.d.ts +5 -5
- package/dist/types/generated/openapi.d.ts +1257 -0
- package/dist/types/generated/ottochain/apps/contracts/v1/contract.d.ts +5 -5
- package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +12 -12
- package/dist/types/generated/ottochain/apps/markets/v1/market.d.ts +11 -11
- package/dist/types/generated/ottochain/v1/common.d.ts +228 -0
- package/dist/types/generated/ottochain/v1/fiber.d.ts +32 -1
- package/dist/types/generated/ottochain/v1/messages.d.ts +84 -0
- package/dist/types/generated/ottochain/v1/records.d.ts +34 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/types/openapi.d.ts +22 -0
- package/dist/types/ottochain/genesis-manifest.d.ts +130 -0
- package/dist/types/ottochain/index.d.ts +6 -5
- package/dist/types/ottochain/metagraph-client.d.ts +49 -7
- package/dist/types/ottochain/snapshot.d.ts +6 -6
- package/dist/types/ottochain/transaction.d.ts +33 -1
- package/dist/types/ottochain/types.d.ts +602 -11
- package/dist/types/privacy/index.d.ts +6 -0
- package/dist/types/privacy/sealed-bid.d.ts +348 -0
- package/dist/types/privacy/shield-app.d.ts +48 -0
- package/dist/types/schema/effects.d.ts +34 -0
- package/dist/types/schema/fiber-app.d.ts +41 -3
- package/dist/types/schema/guard-lint.d.ts +111 -0
- package/dist/types/schema/guards.d.ts +134 -0
- package/dist/types/signing.d.ts +45 -0
- package/dist/types/validation.d.ts +22 -217
- package/dist/types/verify.d.ts +4 -0
- package/dist/types/zk/commit.d.ts +28 -0
- package/dist/types/zk/guard.d.ts +46 -0
- package/dist/types/zk/index.d.ts +19 -0
- package/dist/types/zk/preimage.d.ts +10 -0
- package/dist/types/zk/prover.d.ts +34 -0
- package/dist/types/zk/registry.d.ts +34 -0
- package/dist/types/zk/types.d.ts +33 -0
- package/dist/types/zk/witness.d.ts +40 -0
- package/package.json +52 -35
- package/dist/cjs/ottochain/normalize.js +0 -186
- package/dist/esm/ottochain/normalize.js +0 -179
- package/dist/types/ottochain/normalize.d.ts +0 -79
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis Manifest Exporter
|
|
4
|
+
*
|
|
5
|
+
* The ottochain metagraph can boot from a NON-EMPTY genesis: a set of standard
|
|
6
|
+
* packages pre-registered in the registry before any user transaction. This SDK
|
|
7
|
+
* is the source of truth for those std apps (their proto schemas + JSON-Logic
|
|
8
|
+
* state-machine definitions), so it is also the source of truth for the
|
|
9
|
+
* *genesis manifest* — the per-app CONTENT the chain needs to pre-register each
|
|
10
|
+
* package at genesis.
|
|
11
|
+
*
|
|
12
|
+
* DESIGN — content, not consensus hashes:
|
|
13
|
+
* The manifest ships CONTENT only: the `machineShape` (the typed, proto-faithful
|
|
14
|
+
* projection of the app's state message) and the `definition` (the JSON-Logic
|
|
15
|
+
* `StateMachineDefinition`, verbatim — the same object the chain decodes for any
|
|
16
|
+
* fiber). The CHAIN computes the consensus values itself from this content:
|
|
17
|
+
* - `logicHash` = `StateMachineDefinition.computeDigest(definition)`
|
|
18
|
+
* - `schemaHash` = commitment over the FileDescriptorSet (off-chain/Bridge)
|
|
19
|
+
* We deliberately do NOT replicate the chain's canonical hashing here, so there
|
|
20
|
+
* is ZERO hash-parity risk. No advisory hashes are emitted (see HONESTY notes in
|
|
21
|
+
* the PR description); add them later only if an off-chain consumer needs them,
|
|
22
|
+
* clearly marked advisory.
|
|
23
|
+
*
|
|
24
|
+
* NAMING — the reserved `std` label:
|
|
25
|
+
* Each package is named `std.<app>.package`. `RegistryName` reserves the `std`
|
|
26
|
+
* label in-protocol (`RegistryName.isReserved`), so ordinary user registrations
|
|
27
|
+
* of `std.*` are rejected — only the privileged genesis path may claim them.
|
|
28
|
+
* That is exactly the point: users cannot squat the standard names.
|
|
29
|
+
*
|
|
30
|
+
* SCHEMA SHAPES — chain-verified ground truth:
|
|
31
|
+
* The three `stateMessage` shapes are reproduced verbatim from the chain's own
|
|
32
|
+
* conformance suite (`StandardAppsConformanceSuite`, the `identity` / `proposal`
|
|
33
|
+
* / `market` `MessageShape` vals), which proves the on-chain shape validator and
|
|
34
|
+
* the conformance gate accept them. `commands` is left EMPTY for this first cut —
|
|
35
|
+
* the conformance suite itself models all three apps with `SortedMap.empty`
|
|
36
|
+
* commands, and the proto `*Request` messages are transaction-layer DTOs that do
|
|
37
|
+
* not map cleanly onto the universal state machines' free-form JSON-Logic event
|
|
38
|
+
* payloads. Deriving per-event command shapes is a flagged follow-up.
|
|
39
|
+
*
|
|
40
|
+
* The JSON shape emitted here is built to deserialize against the chain's circe
|
|
41
|
+
* codecs (`MachineShape` / `FieldShape` / `MessageShape` and
|
|
42
|
+
* `StateMachineDefinition`), whose magnolia config is camelCase with defaults.
|
|
43
|
+
*
|
|
44
|
+
* @packageDocumentation
|
|
45
|
+
*/
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.GENESIS_MANIFEST_VERSION = void 0;
|
|
48
|
+
exports.buildGenesisManifest = buildGenesisManifest;
|
|
49
|
+
const identity_universal_js_1 = require("../apps/identity/state-machines/identity-universal.js");
|
|
50
|
+
const governance_universal_js_1 = require("../apps/governance/state-machines/governance-universal.js");
|
|
51
|
+
const market_universal_js_1 = require("../apps/markets/state-machines/market-universal.js");
|
|
52
|
+
const fiber_app_js_1 = require("../schema/fiber-app.js");
|
|
53
|
+
/** Manifest schema version. Bump on any breaking change to the shape. */
|
|
54
|
+
exports.GENESIS_MANIFEST_VERSION = 1;
|
|
55
|
+
// ─── Chain-verified state-message shapes ──────────────────────────────────────
|
|
56
|
+
// Reproduced VERBATIM from ottochain
|
|
57
|
+
// modules/shared-data/.../StandardAppsConformanceSuite.scala — the `identity`,
|
|
58
|
+
// `proposal`, and `market` MessageShape vals. Keep these byte-for-byte in step
|
|
59
|
+
// with that suite; it is what guarantees the chain accepts them.
|
|
60
|
+
/** Helper: a FieldShape with the two boolean defaults made explicit. */
|
|
61
|
+
function field(name, number, typeName, repeated = false, optional = false) {
|
|
62
|
+
return { name, number, typeName, repeated, optional };
|
|
63
|
+
}
|
|
64
|
+
/** ottochain.apps.identity.v1.Identity */
|
|
65
|
+
const identityStateMessage = {
|
|
66
|
+
typeName: 'ottochain.apps.identity.v1.Identity',
|
|
67
|
+
fields: [
|
|
68
|
+
field('id', 1, 'string'),
|
|
69
|
+
field('address', 2, 'string'),
|
|
70
|
+
field('public_key', 3, 'string'),
|
|
71
|
+
field('display_name', 4, 'string'),
|
|
72
|
+
field('identity_type', 5, 'ottochain.apps.identity.v1.Type'),
|
|
73
|
+
field('state', 6, 'ottochain.apps.identity.v1.State'),
|
|
74
|
+
field('reputation', 7, 'ottochain.apps.identity.v1.Reputation'),
|
|
75
|
+
field('stake', 8, 'int64'),
|
|
76
|
+
field('domains', 9, 'string', true),
|
|
77
|
+
field('platform_links', 10, 'ottochain.apps.identity.v1.PlatformLink', true),
|
|
78
|
+
field('penalty_history', 11, 'ottochain.apps.identity.v1.PenaltyEvent', true),
|
|
79
|
+
field('created_at', 12, 'google.protobuf.Timestamp'),
|
|
80
|
+
field('updated_at', 13, 'google.protobuf.Timestamp'),
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
/** ottochain.apps.governance.v1.Proposal */
|
|
84
|
+
const governanceStateMessage = {
|
|
85
|
+
typeName: 'ottochain.apps.governance.v1.Proposal',
|
|
86
|
+
fields: [
|
|
87
|
+
field('id', 1, 'string'),
|
|
88
|
+
field('title', 2, 'string'),
|
|
89
|
+
field('description', 3, 'string'),
|
|
90
|
+
field('action_type', 4, 'string'),
|
|
91
|
+
field('payload', 5, 'google.protobuf.Struct'),
|
|
92
|
+
field('proposer', 6, 'string'),
|
|
93
|
+
field('proposed_at', 7, 'google.protobuf.Timestamp'),
|
|
94
|
+
field('deadline', 8, 'google.protobuf.Timestamp'),
|
|
95
|
+
field('queued_at', 9, 'google.protobuf.Timestamp'),
|
|
96
|
+
field('executable_at', 10, 'google.protobuf.Timestamp'),
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
/** ottochain.apps.markets.v1.Market */
|
|
100
|
+
const marketStateMessage = {
|
|
101
|
+
typeName: 'ottochain.apps.markets.v1.Market',
|
|
102
|
+
fields: [
|
|
103
|
+
field('id', 1, 'string'),
|
|
104
|
+
field('market_type', 2, 'ottochain.apps.markets.v1.Type'),
|
|
105
|
+
field('creator', 3, 'string'),
|
|
106
|
+
field('title', 4, 'string'),
|
|
107
|
+
field('terms', 5, 'google.protobuf.Struct'),
|
|
108
|
+
field('deadline', 6, 'google.protobuf.Timestamp'),
|
|
109
|
+
field('threshold', 7, 'int64'),
|
|
110
|
+
field('commitments', 8, 'ottochain.apps.markets.v1.Commitment', true),
|
|
111
|
+
field('oracles', 9, 'string', true),
|
|
112
|
+
field('quorum', 10, 'int32'),
|
|
113
|
+
field('resolutions', 11, 'ottochain.apps.markets.v1.Resolution', true),
|
|
114
|
+
field('status', 12, 'ottochain.apps.markets.v1.State'),
|
|
115
|
+
field('created_at', 13, 'google.protobuf.Timestamp'),
|
|
116
|
+
field('updated_at', 14, 'google.protobuf.Timestamp'),
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
// ─── Definition projection (single source of truth = the exported defs) ───────
|
|
120
|
+
/**
|
|
121
|
+
* Project a `FiberAppDefinition` into the chain's wire `StateMachineDefinition`,
|
|
122
|
+
* matching the `json-archive/*.json` convention exactly:
|
|
123
|
+
* - states carry explicit `metadata: null`,
|
|
124
|
+
* - transitions carry explicit `dependencies: []`,
|
|
125
|
+
* - the TypeScript-only `FiberAppMetadata` is stripped (`metadata: null`).
|
|
126
|
+
*
|
|
127
|
+
* Built on the shared `toProtoDefinition` projector so the manifest never drifts
|
|
128
|
+
* from the SDK's own exported app definitions. The chain decodes `dependencies:
|
|
129
|
+
* []` / `metadata: null` identically to their absent forms (its codecs use
|
|
130
|
+
* defaults), so this is consensus-equivalent to the archives while staying
|
|
131
|
+
* byte-identical to the checked-in `json-archive/*.json` files.
|
|
132
|
+
*/
|
|
133
|
+
function toWireDefinition(def) {
|
|
134
|
+
const proto = (0, fiber_app_js_1.toProtoDefinition)(def);
|
|
135
|
+
const states = {};
|
|
136
|
+
for (const [key, st] of Object.entries(proto.states)) {
|
|
137
|
+
states[key] = { id: st.id, isFinal: st.isFinal, metadata: null };
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
states,
|
|
141
|
+
initialState: proto.initialState,
|
|
142
|
+
transitions: proto.transitions.map((t) => ({
|
|
143
|
+
from: t.from,
|
|
144
|
+
to: t.to,
|
|
145
|
+
eventName: t.eventName,
|
|
146
|
+
guard: t.guard,
|
|
147
|
+
effect: t.effect,
|
|
148
|
+
dependencies: t.dependencies ?? [],
|
|
149
|
+
})),
|
|
150
|
+
// Strip FiberAppMetadata — the chain's `metadata` is `Option[JsonLogicValue]`.
|
|
151
|
+
metadata: null,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// ─── Builder ──────────────────────────────────────────────────────────────────
|
|
155
|
+
/**
|
|
156
|
+
* Assemble the genesis manifest for the standard apps.
|
|
157
|
+
*
|
|
158
|
+
* Covers THREE apps in this first cut — identity, governance, markets (all the
|
|
159
|
+
* `universal` variant). The other std apps (contracts, oracles, corporate) and
|
|
160
|
+
* non-universal variants are a flagged follow-up.
|
|
161
|
+
*
|
|
162
|
+
* @returns a `GenesisManifest` whose JSON deserializes against the chain's circe
|
|
163
|
+
* codecs. Hashes are intentionally absent — the chain derives them.
|
|
164
|
+
*/
|
|
165
|
+
function buildGenesisManifest() {
|
|
166
|
+
const packages = [
|
|
167
|
+
{
|
|
168
|
+
name: 'std.identity.package',
|
|
169
|
+
semver: '1.0.0',
|
|
170
|
+
strict: false,
|
|
171
|
+
metadata: {},
|
|
172
|
+
machineShape: { stateMessage: identityStateMessage, commands: {} },
|
|
173
|
+
definition: toWireDefinition(identity_universal_js_1.identityUniversalDef),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'std.governance.package',
|
|
177
|
+
semver: '1.0.0',
|
|
178
|
+
strict: false,
|
|
179
|
+
metadata: {},
|
|
180
|
+
machineShape: { stateMessage: governanceStateMessage, commands: {} },
|
|
181
|
+
definition: toWireDefinition(governance_universal_js_1.govUniversalDef),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'std.markets.package',
|
|
185
|
+
semver: '1.0.0',
|
|
186
|
+
strict: false,
|
|
187
|
+
metadata: {},
|
|
188
|
+
machineShape: { stateMessage: marketStateMessage, commands: {} },
|
|
189
|
+
definition: toWireDefinition(market_universal_js_1.marketUniversalDef),
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
return { version: exports.GENESIS_MANIFEST_VERSION, packages };
|
|
193
|
+
}
|
|
@@ -22,20 +22,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
32
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.dropNulls = exports.
|
|
43
|
+
exports.GENESIS_MANIFEST_VERSION = exports.buildGenesisManifest = exports.dropNulls = exports.createAuthorizeComposePayload = exports.createApplyMorphismPayload = exports.createMintAssetPayload = exports.createAssetPolicyPayload = 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.TOKEN_BEHAVIOR_BITS = exports.OTTOCHAIN_MESSAGE_TYPES = exports.proto = void 0;
|
|
34
44
|
// Re-export generated protobuf types (for binary encoding)
|
|
35
45
|
exports.proto = __importStar(require("../generated/index.js"));
|
|
36
46
|
// Runtime message type validation
|
|
37
47
|
var types_js_1 = require("./types.js");
|
|
38
48
|
Object.defineProperty(exports, "OTTOCHAIN_MESSAGE_TYPES", { enumerable: true, get: function () { return types_js_1.OTTOCHAIN_MESSAGE_TYPES; } });
|
|
49
|
+
Object.defineProperty(exports, "TOKEN_BEHAVIOR_BITS", { enumerable: true, get: function () { return types_js_1.TOKEN_BEHAVIOR_BITS; } });
|
|
39
50
|
var snapshot_js_1 = require("./snapshot.js");
|
|
40
51
|
Object.defineProperty(exports, "decodeOnChainState", { enumerable: true, get: function () { return snapshot_js_1.decodeOnChainState; } });
|
|
41
52
|
Object.defineProperty(exports, "getSnapshotOnChainState", { enumerable: true, get: function () { return snapshot_js_1.getSnapshotOnChainState; } });
|
|
@@ -57,13 +68,16 @@ Object.defineProperty(exports, "getPublicKeyForRegistration", { enumerable: true
|
|
|
57
68
|
Object.defineProperty(exports, "createStateMachinePayload", { enumerable: true, get: function () { return transaction_js_1.createStateMachinePayload; } });
|
|
58
69
|
Object.defineProperty(exports, "createScriptPayload", { enumerable: true, get: function () { return transaction_js_1.createScriptPayload; } });
|
|
59
70
|
Object.defineProperty(exports, "createDataTransactionRequest", { enumerable: true, get: function () { return transaction_js_1.createDataTransactionRequest; } });
|
|
71
|
+
Object.defineProperty(exports, "createAssetPolicyPayload", { enumerable: true, get: function () { return transaction_js_1.createAssetPolicyPayload; } });
|
|
72
|
+
Object.defineProperty(exports, "createMintAssetPayload", { enumerable: true, get: function () { return transaction_js_1.createMintAssetPayload; } });
|
|
73
|
+
Object.defineProperty(exports, "createApplyMorphismPayload", { enumerable: true, get: function () { return transaction_js_1.createApplyMorphismPayload; } });
|
|
74
|
+
Object.defineProperty(exports, "createAuthorizeComposePayload", { enumerable: true, get: function () { return transaction_js_1.createAuthorizeComposePayload; } });
|
|
60
75
|
// Data utilities
|
|
61
|
-
var normalize_js_1 = require("./normalize.js");
|
|
62
|
-
Object.defineProperty(exports, "normalizeCreateStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeCreateStateMachine; } });
|
|
63
|
-
Object.defineProperty(exports, "normalizeTransitionStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeTransitionStateMachine; } });
|
|
64
|
-
Object.defineProperty(exports, "normalizeArchiveStateMachine", { enumerable: true, get: function () { return normalize_js_1.normalizeArchiveStateMachine; } });
|
|
65
|
-
Object.defineProperty(exports, "normalizeMessage", { enumerable: true, get: function () { return normalize_js_1.normalizeMessage; } });
|
|
66
76
|
var drop_nulls_js_1 = require("./drop-nulls.js");
|
|
67
77
|
Object.defineProperty(exports, "dropNulls", { enumerable: true, get: function () { return drop_nulls_js_1.dropNulls; } });
|
|
78
|
+
// Genesis manifest exporter (std-app pre-registration content)
|
|
79
|
+
var genesis_manifest_js_1 = require("./genesis-manifest.js");
|
|
80
|
+
Object.defineProperty(exports, "buildGenesisManifest", { enumerable: true, get: function () { return genesis_manifest_js_1.buildGenesisManifest; } });
|
|
81
|
+
Object.defineProperty(exports, "GENESIS_MANIFEST_VERSION", { enumerable: true, get: function () { return genesis_manifest_js_1.GENESIS_MANIFEST_VERSION; } });
|
|
68
82
|
// Note: Governance and Corporate types are now in src/apps/
|
|
69
83
|
// Import from '@ottochain/sdk/apps' instead
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Client for interacting with ottochain ML0 custom routes (/v1 prefix)
|
|
6
6
|
* and framework snapshot endpoints.
|
|
7
7
|
*
|
|
8
|
-
* @see modules/l0/src/main/scala/xyz/kd5ujc/metagraph_l0/
|
|
8
|
+
* @see modules/l0/src/main/scala/xyz/kd5ujc/metagraph_l0/ML0Routes.scala
|
|
9
9
|
* @see modules/data_l1/src/main/scala/xyz/kd5ujc/data_l1/DataL1CustomRoutes.scala
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
@@ -31,7 +31,7 @@ const snapshot_js_1 = require("./snapshot.js");
|
|
|
31
31
|
* const onChain = await client.getOnChain();
|
|
32
32
|
*
|
|
33
33
|
* // Get all active state machines
|
|
34
|
-
* const machines = await client.getStateMachines('
|
|
34
|
+
* const machines = await client.getStateMachines('ACTIVE');
|
|
35
35
|
*
|
|
36
36
|
* // Get event receipts for a fiber
|
|
37
37
|
* const events = await client.getStateMachineEvents(fiberId);
|
|
@@ -90,18 +90,18 @@ class MetagraphClient {
|
|
|
90
90
|
return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/events`);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* Get all
|
|
93
|
+
* Get all scripts, optionally filtered by status.
|
|
94
94
|
*/
|
|
95
95
|
async getScripts(status) {
|
|
96
96
|
const query = status ? `?status=${status}` : '';
|
|
97
|
-
return this.ml0.get(`/data-application/v1/
|
|
97
|
+
return this.ml0.get(`/data-application/v1/scripts${query}`);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
* Get a single script
|
|
100
|
+
* Get a single script by fiber ID.
|
|
101
101
|
*/
|
|
102
102
|
async getScript(scriptId) {
|
|
103
103
|
try {
|
|
104
|
-
return await this.ml0.get(`/data-application/v1/
|
|
104
|
+
return await this.ml0.get(`/data-application/v1/scripts/${scriptId}`);
|
|
105
105
|
}
|
|
106
106
|
catch (error) {
|
|
107
107
|
if (error instanceof network_1.NetworkError && error.statusCode === 404) {
|
|
@@ -111,10 +111,67 @@ class MetagraphClient {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* Get
|
|
114
|
+
* Get script invocations from the current ordinal's logs.
|
|
115
115
|
*/
|
|
116
116
|
async getScriptInvocations(scriptId) {
|
|
117
|
-
return this.ml0.get(`/data-application/v1/
|
|
117
|
+
return this.ml0.get(`/data-application/v1/scripts/${scriptId}/invocations`);
|
|
118
|
+
}
|
|
119
|
+
// -------------------------------------------------------------------------
|
|
120
|
+
// Registry, audit, state-proofs, fee estimates (ML0 /data-application/v1/*)
|
|
121
|
+
// -------------------------------------------------------------------------
|
|
122
|
+
/** Get the metagraph version string. */
|
|
123
|
+
async getVersion() {
|
|
124
|
+
return this.ml0.get('/data-application/v1/version');
|
|
125
|
+
}
|
|
126
|
+
/** Get the full registry namespace, keyed by full registry name `labels.tld`. */
|
|
127
|
+
async getRegistry() {
|
|
128
|
+
return this.ml0.get('/data-application/v1/registry');
|
|
129
|
+
}
|
|
130
|
+
/** Resolve a single registry entry by full name (`labels.tld`), or null if unregistered. */
|
|
131
|
+
async getRegistryEntry(name) {
|
|
132
|
+
try {
|
|
133
|
+
return await this.ml0.get(`/data-application/v1/registry/${encodeURIComponent(name)}`);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (error instanceof network_1.NetworkError && error.statusCode === 404)
|
|
137
|
+
return null;
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Reverse-resolve a fiber UUID to its canonical registered name (#29), or null. */
|
|
142
|
+
async getReverseName(fiberId) {
|
|
143
|
+
try {
|
|
144
|
+
return await this.ml0.get(`/data-application/v1/registry/reverse/${fiberId}`);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error instanceof network_1.NetworkError && error.statusCode === 404)
|
|
148
|
+
return null;
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** Get the rendered audit-trail lines for a state-machine fiber. */
|
|
153
|
+
async getStateMachineAudit(fiberId) {
|
|
154
|
+
return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/audit`);
|
|
155
|
+
}
|
|
156
|
+
/** Light-client state proof for a field of a state-machine fiber, against the committed root. */
|
|
157
|
+
async getStateMachineStateProof(fiberId, field) {
|
|
158
|
+
return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/state-proof?field=${encodeURIComponent(field)}`);
|
|
159
|
+
}
|
|
160
|
+
/** Light-client state proof for a field of a script fiber. */
|
|
161
|
+
async getScriptStateProof(fiberId, field) {
|
|
162
|
+
return this.ml0.get(`/data-application/v1/scripts/${fiberId}/state-proof?field=${encodeURIComponent(field)}`);
|
|
163
|
+
}
|
|
164
|
+
/** Light-client state proof for a field of an asset instance. */
|
|
165
|
+
async getAssetStateProof(assetId, field) {
|
|
166
|
+
return this.ml0.get(`/data-application/v1/assets/${assetId}/state-proof?field=${encodeURIComponent(field)}`);
|
|
167
|
+
}
|
|
168
|
+
/** Estimate the fee/gas for a transition event on a state-machine fiber. */
|
|
169
|
+
async estimateTransitionFee(fiberId, eventName) {
|
|
170
|
+
return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/estimate-fee?event=${encodeURIComponent(eventName)}`);
|
|
171
|
+
}
|
|
172
|
+
/** Estimate the fee/gas for invoking a script fiber. */
|
|
173
|
+
async estimateScriptFee(fiberId) {
|
|
174
|
+
return this.ml0.get(`/data-application/v1/scripts/${fiberId}/estimate-fee`);
|
|
118
175
|
}
|
|
119
176
|
// -------------------------------------------------------------------------
|
|
120
177
|
// Framework snapshot endpoints (ML0 /snapshots/*)
|
|
@@ -11,7 +11,13 @@
|
|
|
11
11
|
* @packageDocumentation
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.decodeOnChainState = decodeOnChainState;
|
|
15
|
+
exports.getSnapshotOnChainState = getSnapshotOnChainState;
|
|
16
|
+
exports.getLatestOnChainState = getLatestOnChainState;
|
|
17
|
+
exports.extractOnChainState = extractOnChainState;
|
|
18
|
+
exports.getLogsForFiber = getLogsForFiber;
|
|
19
|
+
exports.getEventReceipts = getEventReceipts;
|
|
20
|
+
exports.getScriptInvocations = getScriptInvocations;
|
|
15
21
|
const network_1 = require("@constellation-network/metagraph-sdk/network");
|
|
16
22
|
/**
|
|
17
23
|
* Decode on-chain state from binary (JsonBinaryCodec format).
|
|
@@ -26,7 +32,6 @@ function decodeOnChainState(bytes) {
|
|
|
26
32
|
const json = new TextDecoder().decode(bytes);
|
|
27
33
|
return JSON.parse(json);
|
|
28
34
|
}
|
|
29
|
-
exports.decodeOnChainState = decodeOnChainState;
|
|
30
35
|
/**
|
|
31
36
|
* Fetch and decode the on-chain state from a specific snapshot ordinal.
|
|
32
37
|
*
|
|
@@ -39,7 +44,6 @@ async function getSnapshotOnChainState(ml0BaseUrl, ordinal) {
|
|
|
39
44
|
const snapshot = await client.get(`/snapshots/${ordinal}`);
|
|
40
45
|
return extractOnChainState(snapshot);
|
|
41
46
|
}
|
|
42
|
-
exports.getSnapshotOnChainState = getSnapshotOnChainState;
|
|
43
47
|
/**
|
|
44
48
|
* Fetch and decode the on-chain state from the latest snapshot.
|
|
45
49
|
*
|
|
@@ -51,7 +55,6 @@ async function getLatestOnChainState(ml0BaseUrl) {
|
|
|
51
55
|
const snapshot = await client.get('/snapshots/latest');
|
|
52
56
|
return extractOnChainState(snapshot);
|
|
53
57
|
}
|
|
54
|
-
exports.getLatestOnChainState = getLatestOnChainState;
|
|
55
58
|
/**
|
|
56
59
|
* Extract and decode on-chain state from a snapshot response.
|
|
57
60
|
*/
|
|
@@ -63,7 +66,6 @@ function extractOnChainState(snapshot) {
|
|
|
63
66
|
const bytes = new Uint8Array(dataPart.onChainState);
|
|
64
67
|
return decodeOnChainState(bytes);
|
|
65
68
|
}
|
|
66
|
-
exports.extractOnChainState = extractOnChainState;
|
|
67
69
|
// ---------------------------------------------------------------------------
|
|
68
70
|
// Log filtering helpers
|
|
69
71
|
// ---------------------------------------------------------------------------
|
|
@@ -77,11 +79,10 @@ exports.extractOnChainState = extractOnChainState;
|
|
|
77
79
|
function getLogsForFiber(onChain, fiberId) {
|
|
78
80
|
return onChain.latestLogs[fiberId] ?? [];
|
|
79
81
|
}
|
|
80
|
-
exports.getLogsForFiber = getLogsForFiber;
|
|
81
82
|
/**
|
|
82
83
|
* Get EventReceipt log entries for a specific fiber.
|
|
83
84
|
*
|
|
84
|
-
* EventReceipts are distinguished from
|
|
85
|
+
* EventReceipts are distinguished from ScriptInvocations by the presence
|
|
85
86
|
* of the `eventName` field.
|
|
86
87
|
*
|
|
87
88
|
* @param onChain - Decoded on-chain state
|
|
@@ -92,19 +93,17 @@ function getEventReceipts(onChain, fiberId) {
|
|
|
92
93
|
return getLogsForFiber(onChain, fiberId)
|
|
93
94
|
.filter((entry) => 'eventName' in entry && 'success' in entry);
|
|
94
95
|
}
|
|
95
|
-
exports.getEventReceipts = getEventReceipts;
|
|
96
96
|
/**
|
|
97
|
-
* Get
|
|
97
|
+
* Get ScriptInvocation log entries for a specific fiber.
|
|
98
98
|
*
|
|
99
|
-
*
|
|
99
|
+
* ScriptInvocations are distinguished from EventReceipts by the presence
|
|
100
100
|
* of the `method` field.
|
|
101
101
|
*
|
|
102
102
|
* @param onChain - Decoded on-chain state
|
|
103
103
|
* @param fiberId - Fiber UUID to filter by
|
|
104
|
-
* @returns Array of
|
|
104
|
+
* @returns Array of ScriptInvocation entries
|
|
105
105
|
*/
|
|
106
106
|
function getScriptInvocations(onChain, fiberId) {
|
|
107
107
|
return getLogsForFiber(onChain, fiberId)
|
|
108
108
|
.filter((entry) => 'method' in entry && 'result' in entry);
|
|
109
109
|
}
|
|
110
|
-
exports.getScriptInvocations = getScriptInvocations;
|
|
@@ -6,11 +6,31 @@
|
|
|
6
6
|
* self-signed mode, where clients sign their own transactions.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.createStateMachinePayload = createStateMachinePayload;
|
|
10
|
+
exports.createTransitionPayload = createTransitionPayload;
|
|
11
|
+
exports.createArchivePayload = createArchivePayload;
|
|
12
|
+
exports.createScriptPayload = createScriptPayload;
|
|
13
|
+
exports.createInvokeScriptPayload = createInvokeScriptPayload;
|
|
14
|
+
exports.createAssetPolicyPayload = createAssetPolicyPayload;
|
|
15
|
+
exports.createMintAssetPayload = createMintAssetPayload;
|
|
16
|
+
exports.createApplyMorphismPayload = createApplyMorphismPayload;
|
|
17
|
+
exports.createAuthorizeComposePayload = createAuthorizeComposePayload;
|
|
18
|
+
exports.signTransaction = signTransaction;
|
|
19
|
+
exports.createDataTransactionRequest = createDataTransactionRequest;
|
|
20
|
+
exports.addTransactionSignature = addTransactionSignature;
|
|
21
|
+
exports.getPublicKeyForRegistration = getPublicKeyForRegistration;
|
|
10
22
|
const metagraph_sdk_1 = require("@constellation-network/metagraph-sdk");
|
|
23
|
+
const signing_js_1 = require("../signing.js");
|
|
11
24
|
/**
|
|
12
25
|
* Create a new state machine fiber payload.
|
|
13
26
|
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* `params.definition` is signed VERBATIM. Pass the output of `toProtoDefinition(def)` (the
|
|
29
|
+
* allowlisted wire shape) — NOT a raw `FiberAppDefinition`: extra authoring fields
|
|
30
|
+
* (`createSchema` / `stateSchema` / `eventSchemas` / per-transition `emits`) would be signed
|
|
31
|
+
* but re-encoded away by the chain, diverging the canonical → opaque `InvalidSignature`.
|
|
32
|
+
* See `tests/ottochain/signing-parity.test.ts`.
|
|
33
|
+
*
|
|
14
34
|
* @param params - State machine creation parameters
|
|
15
35
|
* @returns A CreateStateMachine message ready for signing
|
|
16
36
|
*
|
|
@@ -37,7 +57,6 @@ function createStateMachinePayload(params) {
|
|
|
37
57
|
},
|
|
38
58
|
};
|
|
39
59
|
}
|
|
40
|
-
exports.createStateMachinePayload = createStateMachinePayload;
|
|
41
60
|
/**
|
|
42
61
|
* Create a transition payload ready for signing.
|
|
43
62
|
*
|
|
@@ -66,7 +85,6 @@ function createTransitionPayload(params) {
|
|
|
66
85
|
},
|
|
67
86
|
};
|
|
68
87
|
}
|
|
69
|
-
exports.createTransitionPayload = createTransitionPayload;
|
|
70
88
|
/**
|
|
71
89
|
* Create an archive payload ready for signing.
|
|
72
90
|
*
|
|
@@ -81,7 +99,6 @@ function createArchivePayload(params) {
|
|
|
81
99
|
},
|
|
82
100
|
};
|
|
83
101
|
}
|
|
84
|
-
exports.createArchivePayload = createArchivePayload;
|
|
85
102
|
/**
|
|
86
103
|
* Create a new script fiber payload.
|
|
87
104
|
*
|
|
@@ -100,7 +117,7 @@ exports.createArchivePayload = createArchivePayload;
|
|
|
100
117
|
* },
|
|
101
118
|
* },
|
|
102
119
|
* initialState: { value: 0 },
|
|
103
|
-
* accessControl: {
|
|
120
|
+
* accessControl: { Public: {} },
|
|
104
121
|
* });
|
|
105
122
|
* const signed = await signTransaction(script, privateKey);
|
|
106
123
|
* ```
|
|
@@ -111,11 +128,10 @@ function createScriptPayload(params) {
|
|
|
111
128
|
fiberId: params.fiberId,
|
|
112
129
|
scriptProgram: params.scriptProgram,
|
|
113
130
|
initialState: params.initialState ?? null,
|
|
114
|
-
accessControl: params.accessControl ?? {
|
|
131
|
+
accessControl: params.accessControl ?? { Public: {} },
|
|
115
132
|
},
|
|
116
133
|
};
|
|
117
134
|
}
|
|
118
|
-
exports.createScriptPayload = createScriptPayload;
|
|
119
135
|
/**
|
|
120
136
|
* Create an invoke script payload ready for signing.
|
|
121
137
|
*
|
|
@@ -132,13 +148,41 @@ function createInvokeScriptPayload(params) {
|
|
|
132
148
|
},
|
|
133
149
|
};
|
|
134
150
|
}
|
|
135
|
-
|
|
151
|
+
// ============================================================================
|
|
152
|
+
// Asset Operations (asset-model.md §7)
|
|
153
|
+
// ============================================================================
|
|
154
|
+
//
|
|
155
|
+
// Thin typed wrappers: the chain message types ({@link CreateAssetPolicy}, etc.) already model
|
|
156
|
+
// every field (required vs `Option`), so these builders just apply the `{ MessageName: ... }`
|
|
157
|
+
// envelope, for API parity with the state-machine/script `create*Payload` helpers. Sign the result
|
|
158
|
+
// with {@link signTransaction} (the canonical `JCS(dropNulls)` path drops any omitted optionals).
|
|
159
|
+
/** Wrap a {@link CreateAssetPolicy} (publish an asset-policy package version). */
|
|
160
|
+
function createAssetPolicyPayload(params) {
|
|
161
|
+
return { CreateAssetPolicy: params };
|
|
162
|
+
}
|
|
163
|
+
/** Wrap a {@link MintAsset} (mint a new asset instance against a resolved policy version). */
|
|
164
|
+
function createMintAssetPayload(params) {
|
|
165
|
+
return { MintAsset: params };
|
|
166
|
+
}
|
|
167
|
+
/** Wrap an {@link ApplyMorphism} (apply a typed morphism to an asset instance). */
|
|
168
|
+
function createApplyMorphismPayload(params) {
|
|
169
|
+
return { ApplyMorphism: params };
|
|
170
|
+
}
|
|
171
|
+
/** Wrap an {@link AuthorizeCompose} (commit half of the symmetric-compose handshake). */
|
|
172
|
+
function createAuthorizeComposePayload(params) {
|
|
173
|
+
return { AuthorizeCompose: params };
|
|
174
|
+
}
|
|
136
175
|
/**
|
|
137
176
|
* Sign a transaction payload for self-signed mode.
|
|
138
177
|
*
|
|
139
178
|
* This creates a Signed<T> object with the exact format expected by the bridge's
|
|
140
179
|
* `/agent/transition` endpoint when using self-signed mode.
|
|
141
180
|
*
|
|
181
|
+
* The signature is computed over the null-dropped canonical bytes (null
|
|
182
|
+
* object fields removed recursively, array nulls preserved, then RFC 8785),
|
|
183
|
+
* matching metakit's content-hash rule. Explicit-null and absent optional
|
|
184
|
+
* fields therefore produce identical signatures.
|
|
185
|
+
*
|
|
142
186
|
* @param message - The message to sign (e.g., from createTransitionPayload)
|
|
143
187
|
* @param privateKey - The private key in hex format (64 characters)
|
|
144
188
|
* @returns A signed object ready for submission to the bridge
|
|
@@ -171,13 +215,12 @@ exports.createInvokeScriptPayload = createInvokeScriptPayload;
|
|
|
171
215
|
* ```
|
|
172
216
|
*/
|
|
173
217
|
async function signTransaction(message, privateKey) {
|
|
174
|
-
const proof = await (0,
|
|
218
|
+
const proof = await (0, signing_js_1.signDataUpdate)(message, privateKey);
|
|
175
219
|
return {
|
|
176
220
|
value: message,
|
|
177
221
|
proofs: [proof],
|
|
178
222
|
};
|
|
179
223
|
}
|
|
180
|
-
exports.signTransaction = signTransaction;
|
|
181
224
|
/**
|
|
182
225
|
* Wrap a signed transaction in the DataTransactionRequest format
|
|
183
226
|
* expected by tessellation's DL1 `/data` endpoint.
|
|
@@ -202,25 +245,26 @@ exports.signTransaction = signTransaction;
|
|
|
202
245
|
function createDataTransactionRequest(signed) {
|
|
203
246
|
return { data: signed, fee: null };
|
|
204
247
|
}
|
|
205
|
-
exports.createDataTransactionRequest = createDataTransactionRequest;
|
|
206
248
|
/**
|
|
207
249
|
* Add an additional signature to a signed transaction.
|
|
208
250
|
*
|
|
209
251
|
* Use this for multi-signature scenarios where multiple parties
|
|
210
252
|
* need to sign the same transaction.
|
|
211
253
|
*
|
|
254
|
+
* The new signature is computed over the null-dropped canonical bytes,
|
|
255
|
+
* matching metakit's content-hash rule (see {@link signTransaction}).
|
|
256
|
+
*
|
|
212
257
|
* @param signed - The already-signed transaction
|
|
213
258
|
* @param privateKey - Additional signer's private key
|
|
214
259
|
* @returns Transaction with additional signature
|
|
215
260
|
*/
|
|
216
261
|
async function addTransactionSignature(signed, privateKey) {
|
|
217
|
-
const newProof = await (0,
|
|
262
|
+
const newProof = await (0, signing_js_1.signDataUpdate)(signed.value, privateKey);
|
|
218
263
|
return {
|
|
219
264
|
value: signed.value,
|
|
220
265
|
proofs: [...signed.proofs, newProof],
|
|
221
266
|
};
|
|
222
267
|
}
|
|
223
|
-
exports.addTransactionSignature = addTransactionSignature;
|
|
224
268
|
/**
|
|
225
269
|
* Get the public key ID from a private key in the format expected by registration.
|
|
226
270
|
*
|
|
@@ -248,4 +292,3 @@ exports.addTransactionSignature = addTransactionSignature;
|
|
|
248
292
|
function getPublicKeyForRegistration(privateKey) {
|
|
249
293
|
return (0, metagraph_sdk_1.getPublicKeyId)(privateKey);
|
|
250
294
|
}
|
|
251
|
-
exports.getPublicKeyForRegistration = getPublicKeyForRegistration;
|
|
@@ -9,7 +9,15 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.OTTOCHAIN_MESSAGE_TYPES = void 0;
|
|
12
|
+
exports.OTTOCHAIN_MESSAGE_TYPES = exports.TOKEN_BEHAVIOR_BITS = void 0;
|
|
13
|
+
/** Bit weights for {@link TokenBehavior} (T=16, S=8, C=4, E=2, G=1). */
|
|
14
|
+
exports.TOKEN_BEHAVIOR_BITS = {
|
|
15
|
+
transferable: 16,
|
|
16
|
+
splittable: 8,
|
|
17
|
+
combinable: 4,
|
|
18
|
+
expirable: 2,
|
|
19
|
+
governable: 1,
|
|
20
|
+
};
|
|
13
21
|
/**
|
|
14
22
|
* Names of all valid OttochainMessage types.
|
|
15
23
|
* Use this for runtime validation (e.g., in API routes).
|
|
@@ -18,6 +26,16 @@ exports.OTTOCHAIN_MESSAGE_TYPES = [
|
|
|
18
26
|
'CreateStateMachine',
|
|
19
27
|
'TransitionStateMachine',
|
|
20
28
|
'ArchiveStateMachine',
|
|
29
|
+
'UpgradeFiber',
|
|
21
30
|
'CreateScript',
|
|
22
31
|
'InvokeScript',
|
|
32
|
+
'UpgradeScript',
|
|
33
|
+
'PublishMachineVersion',
|
|
34
|
+
'PublishScriptVersion',
|
|
35
|
+
'SetVersionStatus',
|
|
36
|
+
'RegisterAlias',
|
|
37
|
+
'CreateAssetPolicy',
|
|
38
|
+
'MintAsset',
|
|
39
|
+
'ApplyMorphism',
|
|
40
|
+
'AuthorizeCompose',
|
|
23
41
|
];
|