@ottochain/sdk 2.4.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/apps/compute/index.js +33 -0
- package/dist/cjs/apps/compute/state-machines/compute-rule110.js +164 -0
- package/dist/cjs/apps/compute/state-machines/index.js +9 -0
- package/dist/cjs/apps/contracts/index.js +1 -1
- package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +126 -148
- package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +153 -174
- package/dist/cjs/apps/contracts/state-machines/contract-universal.js +46 -58
- package/dist/cjs/apps/corporate/state-machines/corp-board.js +415 -481
- package/dist/cjs/apps/corporate/state-machines/corp-entity.js +368 -440
- package/dist/cjs/apps/corporate/state-machines/corp-securities.js +532 -647
- package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +499 -603
- package/dist/cjs/apps/governance/index.js +7 -7
- package/dist/cjs/apps/governance/state-machines/dao-multisig.js +170 -209
- package/dist/cjs/apps/governance/state-machines/dao-reputation.js +161 -214
- package/dist/cjs/apps/governance/state-machines/dao-single.js +92 -92
- package/dist/cjs/apps/governance/state-machines/dao-token.js +169 -223
- package/dist/cjs/apps/governance/state-machines/governance-simple.js +185 -217
- package/dist/cjs/apps/governance/state-machines/governance-universal.js +64 -64
- package/dist/cjs/apps/identity/constants.js +16 -24
- package/dist/cjs/apps/identity/index.js +1 -1
- package/dist/cjs/apps/identity/state-machines/identity-agent.js +124 -158
- package/dist/cjs/apps/identity/state-machines/identity-oracle.js +151 -169
- package/dist/cjs/apps/identity/state-machines/identity-registry.js +89 -115
- package/dist/cjs/apps/identity/state-machines/identity-universal.js +51 -57
- package/dist/cjs/apps/index.js +4 -1
- package/dist/cjs/apps/lending/assets.js +41 -17
- package/dist/cjs/apps/lending/credit-scoring.js +4 -4
- package/dist/cjs/apps/lending/eligibility.js +9 -25
- package/dist/cjs/apps/lending/index.js +1 -1
- package/dist/cjs/apps/lending/state-machines/lending-zk-loan.js +177 -156
- package/dist/cjs/apps/markets/index.js +1 -1
- package/dist/cjs/apps/markets/state-machines/market-auction.js +115 -134
- package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +122 -137
- package/dist/cjs/apps/markets/state-machines/market-group-buy.js +158 -177
- package/dist/cjs/apps/markets/state-machines/market-prediction.js +193 -227
- package/dist/cjs/apps/markets/state-machines/market-universal.js +65 -80
- package/dist/cjs/apps/oracles/index.js +1 -1
- package/dist/cjs/apps/privacy/index.js +67 -0
- package/dist/cjs/apps/privacy/state-machines/index.js +17 -0
- package/dist/cjs/apps/privacy/state-machines/mixer-ddhRing.js +286 -0
- package/dist/cjs/apps/privacy/state-machines/note-pool.js +476 -0
- package/dist/cjs/apps/staked-pool/assets.js +103 -0
- package/dist/cjs/apps/staked-pool/base.js +498 -0
- package/dist/cjs/apps/staked-pool/consumer.js +55 -0
- package/dist/cjs/apps/staked-pool/index.js +83 -0
- package/dist/cjs/apps/staked-pool/state-machines/index.js +12 -0
- package/dist/cjs/apps/staked-pool/state-machines/staked-pool-base.js +49 -0
- package/dist/cjs/apps/staked-pool/state-machines/staked-pool-oracle.js +131 -0
- package/dist/cjs/generated/google/protobuf/struct.js +1 -1
- package/dist/cjs/generated/google/protobuf/timestamp.js +1 -1
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +1 -1
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +1 -1
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +1 -1
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +1 -1
- package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +1 -1
- package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +1 -1
- package/dist/cjs/generated/ottochain/v1/common.js +1 -1
- package/dist/cjs/generated/ottochain/v1/fiber.js +40 -2
- package/dist/cjs/generated/ottochain/v1/messages.js +1 -1
- package/dist/cjs/generated/ottochain/v1/records.js +1 -1
- package/dist/cjs/index.js +21 -3
- package/dist/cjs/ottochain/genesis-manifest.js +6 -0
- package/dist/cjs/ottochain/metagraph-client.js +63 -11
- package/dist/cjs/ottochain/snapshot.js +2 -4
- package/dist/cjs/ottochain/transaction.js +10 -0
- package/dist/cjs/privacy/sealed-bid.js +85 -82
- package/dist/cjs/privacy/shield-app.js +32 -32
- package/dist/cjs/schema/effects.js +145 -1
- package/dist/cjs/schema/fiber-app.js +139 -5
- package/dist/cjs/schema/guard-lint.js +3 -12
- package/dist/cjs/schema/guards.js +38 -38
- package/dist/cjs/templates/asset-policy.js +190 -0
- package/dist/cjs/templates/index.js +86 -0
- package/dist/cjs/templates/machine.js +130 -0
- package/dist/cjs/templates/migration.js +39 -0
- package/dist/cjs/templates/state-shape.js +38 -0
- package/dist/cjs/validation.js +1 -3
- package/dist/esm/apps/compute/index.js +29 -0
- package/dist/esm/apps/compute/state-machines/compute-rule110.js +161 -0
- package/dist/esm/apps/compute/state-machines/index.js +5 -0
- package/dist/esm/apps/contracts/index.js +4 -4
- package/dist/esm/apps/contracts/state-machines/contract-agreement.js +128 -150
- package/dist/esm/apps/contracts/state-machines/contract-escrow.js +155 -176
- package/dist/esm/apps/contracts/state-machines/contract-universal.js +47 -59
- package/dist/esm/apps/corporate/index.js +2 -2
- package/dist/esm/apps/corporate/state-machines/corp-board.js +418 -484
- package/dist/esm/apps/corporate/state-machines/corp-entity.js +371 -443
- package/dist/esm/apps/corporate/state-machines/corp-securities.js +535 -650
- package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +502 -606
- package/dist/esm/apps/governance/index.js +10 -10
- package/dist/esm/apps/governance/state-machines/dao-multisig.js +172 -211
- package/dist/esm/apps/governance/state-machines/dao-reputation.js +163 -216
- package/dist/esm/apps/governance/state-machines/dao-single.js +94 -94
- package/dist/esm/apps/governance/state-machines/dao-token.js +171 -225
- package/dist/esm/apps/governance/state-machines/governance-simple.js +187 -219
- package/dist/esm/apps/governance/state-machines/governance-universal.js +65 -65
- package/dist/esm/apps/identity/constants.js +18 -26
- package/dist/esm/apps/identity/index.js +8 -8
- package/dist/esm/apps/identity/state-machines/identity-agent.js +125 -159
- package/dist/esm/apps/identity/state-machines/identity-oracle.js +153 -171
- package/dist/esm/apps/identity/state-machines/identity-registry.js +91 -117
- package/dist/esm/apps/identity/state-machines/identity-universal.js +52 -58
- package/dist/esm/apps/index.js +9 -6
- package/dist/esm/apps/lending/assets.js +41 -17
- package/dist/esm/apps/lending/credit-scoring.js +6 -6
- package/dist/esm/apps/lending/eligibility.js +10 -26
- package/dist/esm/apps/lending/index.js +5 -5
- package/dist/esm/apps/lending/state-machines/lending-zk-loan.js +178 -157
- package/dist/esm/apps/markets/index.js +5 -5
- package/dist/esm/apps/markets/state-machines/market-auction.js +117 -136
- package/dist/esm/apps/markets/state-machines/market-crowdfund.js +124 -139
- package/dist/esm/apps/markets/state-machines/market-group-buy.js +160 -179
- package/dist/esm/apps/markets/state-machines/market-prediction.js +195 -229
- package/dist/esm/apps/markets/state-machines/market-universal.js +66 -81
- package/dist/esm/apps/oracles/index.js +3 -3
- package/dist/esm/apps/privacy/index.js +56 -0
- package/dist/esm/apps/privacy/state-machines/index.js +6 -0
- package/dist/esm/apps/privacy/state-machines/mixer-ddhRing.js +282 -0
- package/dist/esm/apps/privacy/state-machines/note-pool.js +470 -0
- package/dist/esm/apps/staked-pool/assets.js +91 -0
- package/dist/esm/apps/staked-pool/base.js +493 -0
- package/dist/esm/apps/staked-pool/consumer.js +49 -0
- package/dist/esm/apps/staked-pool/index.js +60 -0
- package/dist/esm/apps/staked-pool/state-machines/index.js +6 -0
- package/dist/esm/apps/staked-pool/state-machines/staked-pool-base.js +46 -0
- package/dist/esm/apps/staked-pool/state-machines/staked-pool-oracle.js +127 -0
- package/dist/esm/generated/google/protobuf/struct.js +1 -1
- package/dist/esm/generated/google/protobuf/timestamp.js +1 -1
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +1 -1
- package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +1 -1
- package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +1 -1
- package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +1 -1
- package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +1 -1
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +1 -1
- package/dist/esm/generated/ottochain/v1/common.js +1 -1
- package/dist/esm/generated/ottochain/v1/fiber.js +40 -2
- package/dist/esm/generated/ottochain/v1/messages.js +1 -1
- package/dist/esm/generated/ottochain/v1/records.js +1 -1
- package/dist/esm/index.js +10 -4
- package/dist/esm/ottochain/genesis-manifest.js +6 -0
- package/dist/esm/ottochain/metagraph-client.js +63 -11
- package/dist/esm/ottochain/snapshot.js +2 -4
- package/dist/esm/ottochain/transaction.js +8 -0
- package/dist/esm/privacy/index.js +2 -2
- package/dist/esm/privacy/sealed-bid.js +87 -84
- package/dist/esm/privacy/shield-app.js +33 -33
- package/dist/esm/schema/effects.js +137 -0
- package/dist/esm/schema/fiber-app.js +134 -5
- package/dist/esm/schema/guard-lint.js +3 -12
- package/dist/esm/schema/guards.js +36 -37
- package/dist/esm/templates/asset-policy.js +182 -0
- package/dist/esm/templates/index.js +41 -0
- package/dist/esm/templates/machine.js +125 -0
- package/dist/esm/templates/migration.js +34 -0
- package/dist/esm/templates/state-shape.js +34 -0
- package/dist/esm/validation.js +1 -3
- package/dist/esm/zk/index.js +4 -4
- package/dist/types/apps/compute/index.d.ts +176 -0
- package/dist/types/apps/compute/state-machines/compute-rule110.d.ts +157 -0
- package/dist/types/apps/compute/state-machines/index.d.ts +5 -0
- package/dist/types/apps/contracts/index.d.ts +14 -14
- package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +3 -3
- package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +3 -3
- package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +4 -4
- package/dist/types/apps/corporate/index.d.ts +162 -162
- package/dist/types/apps/corporate/state-machines/corp-board.d.ts +88 -88
- package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +14 -14
- package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +18 -18
- package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +43 -43
- package/dist/types/apps/governance/index.d.ts +81 -81
- package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +16 -16
- package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +22 -22
- package/dist/types/apps/governance/state-machines/dao-token.d.ts +21 -21
- package/dist/types/apps/governance/state-machines/governance-simple.d.ts +11 -11
- package/dist/types/apps/governance/state-machines/governance-universal.d.ts +4 -4
- package/dist/types/apps/identity/constants.d.ts +2 -2
- package/dist/types/apps/identity/index.d.ts +70 -70
- package/dist/types/apps/identity/state-machines/identity-agent.d.ts +23 -23
- package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +11 -11
- package/dist/types/apps/identity/state-machines/identity-registry.d.ts +27 -27
- package/dist/types/apps/identity/state-machines/identity-universal.d.ts +4 -4
- package/dist/types/apps/index.d.ts +9 -6
- package/dist/types/apps/lending/assets.d.ts +2 -2
- package/dist/types/apps/lending/credit-scoring.d.ts +5 -5
- package/dist/types/apps/lending/eligibility.d.ts +2 -2
- package/dist/types/apps/lending/index.d.ts +20 -12
- package/dist/types/apps/lending/state-machines/lending-zk-loan.d.ts +15 -7
- package/dist/types/apps/markets/index.d.ts +76 -76
- package/dist/types/apps/markets/state-machines/market-auction.d.ts +12 -12
- package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +19 -19
- package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +18 -18
- package/dist/types/apps/markets/state-machines/market-prediction.d.ts +15 -15
- package/dist/types/apps/markets/state-machines/market-universal.d.ts +7 -7
- package/dist/types/apps/oracles/index.d.ts +1 -1
- package/dist/types/apps/privacy/index.d.ts +328 -0
- package/dist/types/apps/privacy/state-machines/index.d.ts +6 -0
- package/dist/types/apps/privacy/state-machines/mixer-ddhRing.d.ts +337 -0
- package/dist/types/apps/privacy/state-machines/note-pool.d.ts +196 -0
- package/dist/types/apps/staked-pool/assets.d.ts +53 -0
- package/dist/types/apps/staked-pool/base.d.ts +80 -0
- package/dist/types/apps/staked-pool/consumer.d.ts +29 -0
- package/dist/types/apps/staked-pool/index.d.ts +51 -0
- package/dist/types/apps/staked-pool/state-machines/index.d.ts +6 -0
- package/dist/types/apps/staked-pool/state-machines/staked-pool-base.d.ts +8 -0
- package/dist/types/apps/staked-pool/state-machines/staked-pool-oracle.d.ts +34 -0
- package/dist/types/generated/openapi.d.ts +13 -0
- package/dist/types/generated/ottochain/v1/fiber.d.ts +7 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/openapi.d.ts +4 -2
- package/dist/types/ottochain/genesis-manifest.d.ts +6 -0
- package/dist/types/ottochain/index.d.ts +1 -1
- package/dist/types/ottochain/metagraph-client.d.ts +69 -15
- package/dist/types/ottochain/transaction.d.ts +9 -1
- package/dist/types/ottochain/types.d.ts +1 -1
- package/dist/types/privacy/index.d.ts +2 -2
- package/dist/types/privacy/sealed-bid.d.ts +9 -9
- package/dist/types/privacy/shield-app.d.ts +1 -1
- package/dist/types/schema/effects.d.ts +132 -0
- package/dist/types/schema/fiber-app.d.ts +281 -0
- package/dist/types/schema/guards.d.ts +12 -0
- package/dist/types/templates/asset-policy.d.ts +119 -0
- package/dist/types/templates/index.d.ts +26 -0
- package/dist/types/templates/machine.d.ts +139 -0
- package/dist/types/templates/migration.d.ts +34 -0
- package/dist/types/templates/state-shape.d.ts +30 -0
- package/dist/types/zk/index.d.ts +4 -4
- package/package.json +31 -13
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle-pool specialization of the staked-pool base (`StakedPoolOracle`).
|
|
3
|
+
*
|
|
4
|
+
* `submit` appends a numeric datapoint `{ addr, value }` (the base default arm).
|
|
5
|
+
* `finalize` (COLLECTING→SETTLED) aggregates the array with an outlier-bounded mean and publishes the
|
|
6
|
+
* answer + the in-consensus address set — emitting ZERO asset transfers (the entitlement ledger is
|
|
7
|
+
* `inConsensus`; rewards are pulled per-claim via the base `claim_reward` arm).
|
|
8
|
+
*
|
|
9
|
+
* Aggregation (default `trimmedMean`):
|
|
10
|
+
* 1. vals = map(submissions, .value)
|
|
11
|
+
* 2. trimmed = filter(submissions, value != min(vals) && value != max(vals)) — drop single min + single max
|
|
12
|
+
* 3. center = sum(trimmed.value) / count(trimmed) — EXACT rational (no truncation)
|
|
13
|
+
* 4. kept = filter(submissions, abs(value - center) <= outlierBound) — the in-consensus set
|
|
14
|
+
* 5. answer = sum(kept.value) / count(kept)
|
|
15
|
+
*
|
|
16
|
+
* CRITICAL JLVM SCOPING (verified against @constellation-network/metagraph-sdk-jlvm@1.8.0-rc.5):
|
|
17
|
+
* - Inside a `map`/`filter` callback the data scope is the BARE element, BUT the outer `state.*` is
|
|
18
|
+
* still readable (verified: `{cat:[addr,"|",{var:"state.epoch"}]}` reads epoch correctly).
|
|
19
|
+
* - A `let`-bound name does NOT cross into a `map`/`filter` callback. So `center` is INLINED into the
|
|
20
|
+
* `kept` predicate (it reads `state.submissions`, which IS visible) rather than `let`-hoisted — a
|
|
21
|
+
* `let`-bound `center` resolves to null inside `filter`, evicting every submission (div-by-zero).
|
|
22
|
+
* - A `reduce` with a MAP initial accumulator is rejected (`opReduce` requires `isPrimitive(init)`),
|
|
23
|
+
* so the reward ledger is NOT a folded `{addr:int}` map — it is the `inConsensus` array (membership =
|
|
24
|
+
* entitlement), consumed by `claim_reward` + a `claimed` dedup map.
|
|
25
|
+
*/
|
|
26
|
+
import { makeStakedPoolDef } from '../base.js';
|
|
27
|
+
const sum = (arr) => ({
|
|
28
|
+
reduce: [arr, { '+': [{ var: 'accumulator' }, { var: 'current' }] }, 0],
|
|
29
|
+
});
|
|
30
|
+
const meanOf = (arr) => ({ '/': [sum(arr), { count: [arr] }] });
|
|
31
|
+
/** vals = map(submissions, .value) */
|
|
32
|
+
const VALS = { map: [{ var: 'state.submissions' }, { get: [{ var: '' }, 'value'] }] };
|
|
33
|
+
/**
|
|
34
|
+
* The aggregation `center` as a CLOSED expression over `state.submissions` (must be inlined into the
|
|
35
|
+
* `kept` filter — see file header). `trimmedMean` drops the single min + single max before averaging.
|
|
36
|
+
*/
|
|
37
|
+
function centerExpr(aggregation) {
|
|
38
|
+
if (aggregation === 'mean')
|
|
39
|
+
return meanOf(VALS);
|
|
40
|
+
const trimmed = {
|
|
41
|
+
filter: [
|
|
42
|
+
{ var: 'state.submissions' },
|
|
43
|
+
{
|
|
44
|
+
and: [
|
|
45
|
+
{ '!==': [{ get: [{ var: '' }, 'value'] }, { min: [VALS] }] },
|
|
46
|
+
{ '!==': [{ get: [{ var: '' }, 'value'] }, { max: [VALS] }] },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
const trimmedVals = { map: [trimmed, { get: [{ var: '' }, 'value'] }] };
|
|
52
|
+
return meanOf(trimmedVals);
|
|
53
|
+
}
|
|
54
|
+
/** finalize COLLECTING→SETTLED — publish answer + inConsensus; ZERO asset transfers. */
|
|
55
|
+
function finalizeArm(aggregation) {
|
|
56
|
+
const center = centerExpr(aggregation);
|
|
57
|
+
// kept = the in-consensus submissions; `center` is INLINED (visible state.submissions inside filter).
|
|
58
|
+
const kept = {
|
|
59
|
+
filter: [
|
|
60
|
+
{ var: 'state.submissions' },
|
|
61
|
+
{
|
|
62
|
+
'<=': [{ abs: [{ '-': [{ get: [{ var: '' }, 'value'] }, center] }] }, { var: 'state.outlierBound' }],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
const keptVals = { map: [kept, { get: [{ var: '' }, 'value'] }] };
|
|
67
|
+
const inConsensus = { map: [kept, { get: [{ var: '' }, 'addr'] }] };
|
|
68
|
+
return {
|
|
69
|
+
from: 'COLLECTING',
|
|
70
|
+
to: 'SETTLED',
|
|
71
|
+
eventName: 'finalize',
|
|
72
|
+
// Authority finalizes once quorum is met AND the window has elapsed.
|
|
73
|
+
guard: {
|
|
74
|
+
and: [
|
|
75
|
+
{ in: [{ var: 'state.authority' }, { map: [{ var: 'proofs' }, { var: 'address' }] }] },
|
|
76
|
+
{ '>=': [{ count: [{ var: 'state.submissions' }] }, { var: 'state.quorum' }] },
|
|
77
|
+
{
|
|
78
|
+
'>=': [{ var: '$ordinal' }, { '+': [{ var: 'state.epochStartedAt' }, { var: 'state.epochLength' }] }],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
// ZERO _transferAsset: publish result + record the in-consensus entitlement set + reset claimed.
|
|
83
|
+
effect: {
|
|
84
|
+
merge: [
|
|
85
|
+
{ var: 'state' },
|
|
86
|
+
{
|
|
87
|
+
status: 'SETTLED',
|
|
88
|
+
inConsensus,
|
|
89
|
+
claimed: {},
|
|
90
|
+
result: {
|
|
91
|
+
value: meanOf(keptVals),
|
|
92
|
+
epoch: { var: 'state.epoch' },
|
|
93
|
+
finalizedAt: { var: '$ordinal' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
dependencies: [],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Build the oracle-pool definition. `outlierPenalty` is soft-only (no-credit for outliers); hard slash is v2. */
|
|
102
|
+
export function makeOraclePoolDef(options = {}) {
|
|
103
|
+
const aggregation = options.aggregation ?? 'trimmedMean';
|
|
104
|
+
return makeStakedPoolDef({
|
|
105
|
+
metadata: {
|
|
106
|
+
name: 'StakedPoolOracle',
|
|
107
|
+
type: 'oraclePool',
|
|
108
|
+
description: 'Reputation-gated staked oracle pool: participants stake + submit numeric datapoints; finalize ' +
|
|
109
|
+
'publishes an outlier-bounded (default trimmed-mean) consensus answer and credits the in-consensus ' +
|
|
110
|
+
'set as a claim entitlement (zero finalize-time transfers); a consumer reads the published value ' +
|
|
111
|
+
'cross-fiber via an epoch-pinned depInState(SETTLED) gate.',
|
|
112
|
+
},
|
|
113
|
+
finalize: finalizeArm(aggregation),
|
|
114
|
+
extraCreateProperties: {
|
|
115
|
+
rewardPolicy: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
description: 'Asset policy of the shared fungible reward token.',
|
|
118
|
+
immutable: true,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
extraStateProperties: {
|
|
122
|
+
rewardPolicy: { type: 'string', immutable: true },
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** Default oracle-pool definition (trimmed-mean). */
|
|
127
|
+
export const stakedPoolOracleDef = makeOraclePoolDef();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.11.
|
|
3
|
+
// protoc-gen-ts_proto v2.11.8
|
|
4
4
|
// protoc unknown
|
|
5
5
|
// source: ottochain/v1/fiber.proto
|
|
6
6
|
/* eslint-disable */
|
|
@@ -427,7 +427,7 @@ export const StateMachineDefinition = {
|
|
|
427
427
|
},
|
|
428
428
|
};
|
|
429
429
|
function createBaseEmittedEvent() {
|
|
430
|
-
return { name: "", data: undefined, destination: undefined };
|
|
430
|
+
return { name: "", data: undefined, destination: undefined, emitterFiberId: "", emissionIndex: 0 };
|
|
431
431
|
}
|
|
432
432
|
export const EmittedEvent = {
|
|
433
433
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -440,6 +440,12 @@ export const EmittedEvent = {
|
|
|
440
440
|
if (message.destination !== undefined) {
|
|
441
441
|
writer.uint32(26).string(message.destination);
|
|
442
442
|
}
|
|
443
|
+
if (message.emitterFiberId !== "") {
|
|
444
|
+
writer.uint32(34).string(message.emitterFiberId);
|
|
445
|
+
}
|
|
446
|
+
if (message.emissionIndex !== 0) {
|
|
447
|
+
writer.uint32(40).int32(message.emissionIndex);
|
|
448
|
+
}
|
|
443
449
|
return writer;
|
|
444
450
|
},
|
|
445
451
|
decode(input, length) {
|
|
@@ -470,6 +476,20 @@ export const EmittedEvent = {
|
|
|
470
476
|
message.destination = reader.string();
|
|
471
477
|
continue;
|
|
472
478
|
}
|
|
479
|
+
case 4: {
|
|
480
|
+
if (tag !== 34) {
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
message.emitterFiberId = reader.string();
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
case 5: {
|
|
487
|
+
if (tag !== 40) {
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
message.emissionIndex = reader.int32();
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
473
493
|
}
|
|
474
494
|
if ((tag & 7) === 4 || tag === 0) {
|
|
475
495
|
break;
|
|
@@ -483,6 +503,16 @@ export const EmittedEvent = {
|
|
|
483
503
|
name: isSet(object.name) ? globalThis.String(object.name) : "",
|
|
484
504
|
data: isSet(object?.data) ? object.data : undefined,
|
|
485
505
|
destination: isSet(object.destination) ? globalThis.String(object.destination) : undefined,
|
|
506
|
+
emitterFiberId: isSet(object.emitterFiberId)
|
|
507
|
+
? globalThis.String(object.emitterFiberId)
|
|
508
|
+
: isSet(object.emitter_fiber_id)
|
|
509
|
+
? globalThis.String(object.emitter_fiber_id)
|
|
510
|
+
: "",
|
|
511
|
+
emissionIndex: isSet(object.emissionIndex)
|
|
512
|
+
? globalThis.Number(object.emissionIndex)
|
|
513
|
+
: isSet(object.emission_index)
|
|
514
|
+
? globalThis.Number(object.emission_index)
|
|
515
|
+
: 0,
|
|
486
516
|
};
|
|
487
517
|
},
|
|
488
518
|
toJSON(message) {
|
|
@@ -496,6 +526,12 @@ export const EmittedEvent = {
|
|
|
496
526
|
if (message.destination !== undefined) {
|
|
497
527
|
obj.destination = message.destination;
|
|
498
528
|
}
|
|
529
|
+
if (message.emitterFiberId !== "") {
|
|
530
|
+
obj.emitterFiberId = message.emitterFiberId;
|
|
531
|
+
}
|
|
532
|
+
if (message.emissionIndex !== 0) {
|
|
533
|
+
obj.emissionIndex = Math.round(message.emissionIndex);
|
|
534
|
+
}
|
|
499
535
|
return obj;
|
|
500
536
|
},
|
|
501
537
|
create(base) {
|
|
@@ -506,6 +542,8 @@ export const EmittedEvent = {
|
|
|
506
542
|
message.name = object.name ?? "";
|
|
507
543
|
message.data = object.data ?? undefined;
|
|
508
544
|
message.destination = object.destination ?? undefined;
|
|
545
|
+
message.emitterFiberId = object.emitterFiberId ?? "";
|
|
546
|
+
message.emissionIndex = object.emissionIndex ?? 0;
|
|
509
547
|
return message;
|
|
510
548
|
},
|
|
511
549
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -49,7 +49,10 @@ validate, validatePrivateKey, validatePublicKey, validateAddress, validateKeyPai
|
|
|
49
49
|
// ─── OttoChain metagraph client ───────────────────────────────────────────────
|
|
50
50
|
export { MetagraphClient as OttoMetagraphClient } from './ottochain/metagraph-client.js';
|
|
51
51
|
// Proto definition helper
|
|
52
|
-
export { toProtoDefinition, defineFiberApp,
|
|
52
|
+
export { toProtoDefinition, defineFiberApp,
|
|
53
|
+
// Fiber policy (the fiber constitution): mirrors the chain ADT
|
|
54
|
+
// `FiberPolicy = Unconstrained | Immutable | Constrained(<dials>)`.
|
|
55
|
+
constrained, unconstrained, immutable, IMMUTABLE_POLICY, projectFiberPolicy, } from './schema/fiber-app.js';
|
|
53
56
|
// Canonical authorization-guard builders (bind to verified signers, not attacker payloads).
|
|
54
57
|
export { signerIsParty, signerIsAnyParty, signerInSet, signerIsNotParty, signerHasEntry, assetSignerIs,
|
|
55
58
|
// effect-key coupling (S1): bind a dynamic map key to a verified signer
|
|
@@ -59,9 +62,12 @@ signerHasReputation, signerHasRole,
|
|
|
59
62
|
// identity-registry reads (runtime-bound registry id, #24)
|
|
60
63
|
signerHasReputationVia, signerHasRoleVia,
|
|
61
64
|
// cross-fiber state gate (runtime-bound dependency, #24) — replaces object-form deps
|
|
62
|
-
depInState,
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
+
depInState,
|
|
66
|
+
// append-only-array dedup: actor not yet present in an array of records
|
|
67
|
+
actorNotInArray, } from './schema/guards.js';
|
|
68
|
+
// Reserved EFFECT-directive builders (dynamic dependencies, #24; whole-asset custody moves;
|
|
69
|
+
// cross-fiber triggers, spawn, emit + recipient-intent helpers; the reserved-key set for validators).
|
|
70
|
+
export { addDependency, setDependencyActive, transferAsset, triggers, spawn, emit, scriptCall, toFiber, toWallet, RESERVED_EFFECT_KEYS, } from './schema/effects.js';
|
|
65
71
|
// ─── Privacy: shield any fiber app into a zk-jlvm-shielded private-state pool ──
|
|
66
72
|
// See docs/design/zk-private-contract-state-rfc.md.
|
|
67
73
|
export { shieldApp, SHIELDED_POOL_STATE } from './privacy/shield-app.js';
|
|
@@ -145,6 +145,12 @@ function toWireDefinition(def) {
|
|
|
145
145
|
})),
|
|
146
146
|
// Strip FiberAppMetadata — the chain's `metadata` is `Option[JsonLogicValue]`.
|
|
147
147
|
metadata: null,
|
|
148
|
+
// Carry the fiber constitution through verbatim from the shared projector: PRESENT for
|
|
149
|
+
// `Constrained` (a bare object of set dials) and `Immutable` (the bare string
|
|
150
|
+
// `"Immutable"`), ABSENT for `Unconstrained`. The `policy` key is only set here when
|
|
151
|
+
// `toProtoDefinition` emitted one, so an unconstrained def keeps NO `policy` key
|
|
152
|
+
// (omit-on-unconstrained wire parity).
|
|
153
|
+
...(proto.policy !== undefined ? { policy: proto.policy } : {}),
|
|
148
154
|
};
|
|
149
155
|
}
|
|
150
156
|
// ─── Builder ──────────────────────────────────────────────────────────────────
|
|
@@ -116,7 +116,11 @@ export class MetagraphClient {
|
|
|
116
116
|
// -------------------------------------------------------------------------
|
|
117
117
|
// Registry, audit, state-proofs, fee estimates (ML0 /data-application/v1/*)
|
|
118
118
|
// -------------------------------------------------------------------------
|
|
119
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
/**
|
|
@@ -244,7 +288,9 @@ export class MetagraphClient {
|
|
|
244
288
|
try {
|
|
245
289
|
onError(cbErr instanceof Error ? cbErr : new Error(String(cbErr)));
|
|
246
290
|
}
|
|
247
|
-
catch {
|
|
291
|
+
catch {
|
|
292
|
+
/* ignore */
|
|
293
|
+
}
|
|
248
294
|
}
|
|
249
295
|
};
|
|
250
296
|
const poll = async () => {
|
|
@@ -261,7 +307,9 @@ export class MetagraphClient {
|
|
|
261
307
|
try {
|
|
262
308
|
onError(err instanceof Error ? err : new Error(String(err)));
|
|
263
309
|
}
|
|
264
|
-
catch {
|
|
310
|
+
catch {
|
|
311
|
+
/* ignore */
|
|
312
|
+
}
|
|
265
313
|
if (active)
|
|
266
314
|
setTimeout(poll, intervalMs);
|
|
267
315
|
return;
|
|
@@ -294,7 +342,9 @@ export class MetagraphClient {
|
|
|
294
342
|
// callers can unsubscribe before the first poll runs, and each
|
|
295
343
|
// jest.runOnlyPendingTimersAsync() advances exactly one poll cycle.
|
|
296
344
|
setTimeout(poll, 0);
|
|
297
|
-
return () => {
|
|
345
|
+
return () => {
|
|
346
|
+
active = false;
|
|
347
|
+
};
|
|
298
348
|
}
|
|
299
349
|
/**
|
|
300
350
|
* Wait for a fiber to reach a specific state, with an optional timeout.
|
|
@@ -392,14 +442,16 @@ export class MetagraphClient {
|
|
|
392
442
|
let settled = false;
|
|
393
443
|
let pending = this.dl1Clients.length;
|
|
394
444
|
for (const client of this.dl1Clients) {
|
|
395
|
-
client.post('/data', request).then((result) => {
|
|
396
|
-
settled
|
|
397
|
-
|
|
398
|
-
|
|
445
|
+
client.post('/data', request).then((result) => {
|
|
446
|
+
if (!settled) {
|
|
447
|
+
settled = true;
|
|
448
|
+
resolve(result);
|
|
449
|
+
}
|
|
450
|
+
}, (err) => {
|
|
399
451
|
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
400
452
|
pending--;
|
|
401
453
|
if (pending === 0 && !settled) {
|
|
402
|
-
reject(new Error('All DL1 nodes failed: ' + errors.map(e => e.message).join('; ')));
|
|
454
|
+
reject(new Error('All DL1 nodes failed: ' + errors.map((e) => e.message).join('; ')));
|
|
403
455
|
}
|
|
404
456
|
});
|
|
405
457
|
}
|
|
@@ -81,8 +81,7 @@ export function getLogsForFiber(onChain, fiberId) {
|
|
|
81
81
|
* @returns Array of EventReceipt entries
|
|
82
82
|
*/
|
|
83
83
|
export function getEventReceipts(onChain, fiberId) {
|
|
84
|
-
return getLogsForFiber(onChain, fiberId)
|
|
85
|
-
.filter((entry) => 'eventName' in entry && 'success' in entry);
|
|
84
|
+
return getLogsForFiber(onChain, fiberId).filter((entry) => 'eventName' in entry && 'success' in entry);
|
|
86
85
|
}
|
|
87
86
|
/**
|
|
88
87
|
* Get ScriptInvocation log entries for a specific fiber.
|
|
@@ -95,6 +94,5 @@ export function getEventReceipts(onChain, fiberId) {
|
|
|
95
94
|
* @returns Array of ScriptInvocation entries
|
|
96
95
|
*/
|
|
97
96
|
export function getScriptInvocations(onChain, fiberId) {
|
|
98
|
-
return getLogsForFiber(onChain, fiberId)
|
|
99
|
-
.filter((entry) => 'method' in entry && 'result' in entry);
|
|
97
|
+
return getLogsForFiber(onChain, fiberId).filter((entry) => 'method' in entry && 'result' in entry);
|
|
100
98
|
}
|
|
@@ -157,6 +157,14 @@ export function createApplyMorphismPayload(params) {
|
|
|
157
157
|
export function createAuthorizeComposePayload(params) {
|
|
158
158
|
return { AuthorizeCompose: params };
|
|
159
159
|
}
|
|
160
|
+
/** Wrap a {@link PublishMachineVersion} (create-or-append a STATE-MACHINE registry version). */
|
|
161
|
+
export function createPublishMachineVersionPayload(params) {
|
|
162
|
+
return { PublishMachineVersion: params };
|
|
163
|
+
}
|
|
164
|
+
/** Wrap an {@link UpgradeFiber} (re-pin a fiber to another registered version of the SAME package). */
|
|
165
|
+
export function createUpgradeFiberPayload(params) {
|
|
166
|
+
return { UpgradeFiber: params };
|
|
167
|
+
}
|
|
160
168
|
/**
|
|
161
169
|
* Sign a transaction payload for self-signed mode.
|
|
162
170
|
*
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Privacy: shield any fiber app into a zk-jlvm-shielded private-state pool.
|
|
3
3
|
* See docs/design/zk-private-contract-state-rfc.md.
|
|
4
4
|
*/
|
|
5
|
-
export { shieldApp, SHIELDED_POOL_STATE } from
|
|
6
|
-
export { sealedBidAccountDef, shieldedSealedBidDef, vickreyAuctionDef } from
|
|
5
|
+
export { shieldApp, SHIELDED_POOL_STATE } from './shield-app.js';
|
|
6
|
+
export { sealedBidAccountDef, shieldedSealedBidDef, vickreyAuctionDef } from './sealed-bid.js';
|