@ottochain/sdk 2.3.0 → 2.5.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 +16 -9
- package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +134 -161
- package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +192 -170
- package/dist/cjs/apps/contracts/state-machines/contract-universal.js +46 -58
- package/dist/cjs/apps/corporate/index.js +2 -2
- package/dist/cjs/apps/corporate/state-machines/corp-board.js +500 -456
- package/dist/cjs/apps/corporate/state-machines/corp-entity.js +487 -361
- package/dist/cjs/apps/corporate/state-machines/corp-securities.js +769 -576
- package/dist/cjs/apps/corporate/state-machines/corp-shareholders.js +567 -557
- package/dist/cjs/apps/governance/index.js +21 -21
- package/dist/cjs/apps/governance/state-machines/dao-multisig.js +188 -209
- package/dist/cjs/apps/governance/state-machines/dao-reputation.js +181 -228
- package/dist/cjs/apps/governance/state-machines/dao-single.js +105 -88
- package/dist/cjs/apps/governance/state-machines/dao-token.js +199 -227
- package/dist/cjs/apps/governance/state-machines/governance-simple.js +231 -231
- package/dist/cjs/apps/governance/state-machines/governance-universal.js +64 -64
- package/dist/cjs/apps/identity/constants.js +55 -22
- package/dist/cjs/apps/identity/index.js +28 -12
- package/dist/cjs/apps/identity/state-machines/identity-agent.js +124 -158
- package/dist/cjs/apps/identity/state-machines/identity-oracle.js +158 -173
- package/dist/cjs/apps/identity/state-machines/identity-registry.js +262 -0
- package/dist/cjs/apps/identity/state-machines/identity-universal.js +51 -57
- package/dist/cjs/apps/identity/state-machines/index.js +3 -1
- package/dist/cjs/apps/index.js +22 -8
- package/dist/cjs/apps/lending/assets.js +247 -0
- package/dist/cjs/apps/lending/credit-scoring.js +87 -0
- package/dist/cjs/apps/lending/eligibility.js +105 -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 +433 -0
- package/dist/cjs/apps/markets/index.js +22 -12
- package/dist/cjs/apps/markets/state-machines/market-auction.js +116 -134
- package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +131 -141
- package/dist/cjs/apps/markets/state-machines/market-group-buy.js +163 -184
- package/dist/cjs/apps/markets/state-machines/market-prediction.js +226 -233
- package/dist/cjs/apps/markets/state-machines/market-universal.js +65 -80
- package/dist/cjs/apps/oracles/index.js +3 -3
- 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/errors.js +3 -3
- package/dist/cjs/generated/google/protobuf/struct.js +5 -5
- package/dist/cjs/generated/google/protobuf/timestamp.js +1 -1
- 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 +51 -51
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +20 -21
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +14 -14
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +5 -5
- package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +125 -131
- package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +108 -108
- package/dist/cjs/generated/ottochain/v1/common.js +5 -5
- package/dist/cjs/generated/ottochain/v1/fiber.js +44 -6
- 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 +58 -7
- package/dist/cjs/openapi.js +2 -0
- package/dist/cjs/ottochain/drop-nulls.js +1 -2
- package/dist/cjs/ottochain/genesis-manifest.js +17 -11
- package/dist/cjs/ottochain/index.js +23 -13
- package/dist/cjs/ottochain/metagraph-client.js +81 -16
- package/dist/cjs/ottochain/snapshot.js +13 -16
- package/dist/cjs/ottochain/transaction.js +67 -14
- package/dist/cjs/ottochain/types.js +16 -2
- package/dist/cjs/privacy/index.js +14 -0
- package/dist/cjs/privacy/sealed-bid.js +213 -0
- package/dist/cjs/privacy/shield-app.js +131 -0
- package/dist/cjs/schema/effects.js +156 -0
- package/dist/cjs/schema/fiber-app.js +150 -15
- package/dist/cjs/schema/guard-lint.js +343 -0
- package/dist/cjs/schema/guards.js +246 -0
- package/dist/cjs/signing.js +80 -0
- 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/types.js +2 -3
- package/dist/cjs/validation.js +9 -11
- 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/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 +9 -5
- package/dist/esm/apps/contracts/state-machines/contract-agreement.js +135 -162
- package/dist/esm/apps/contracts/state-machines/contract-escrow.js +193 -171
- 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 +501 -457
- package/dist/esm/apps/corporate/state-machines/corp-entity.js +488 -362
- package/dist/esm/apps/corporate/state-machines/corp-securities.js +770 -577
- package/dist/esm/apps/corporate/state-machines/corp-shareholders.js +568 -558
- package/dist/esm/apps/governance/index.js +10 -10
- package/dist/esm/apps/governance/state-machines/dao-multisig.js +189 -210
- package/dist/esm/apps/governance/state-machines/dao-reputation.js +182 -229
- package/dist/esm/apps/governance/state-machines/dao-single.js +106 -89
- package/dist/esm/apps/governance/state-machines/dao-token.js +200 -228
- package/dist/esm/apps/governance/state-machines/governance-simple.js +232 -232
- package/dist/esm/apps/governance/state-machines/governance-universal.js +65 -65
- package/dist/esm/apps/identity/constants.js +52 -21
- package/dist/esm/apps/identity/index.js +14 -9
- package/dist/esm/apps/identity/state-machines/identity-agent.js +125 -159
- package/dist/esm/apps/identity/state-machines/identity-oracle.js +159 -174
- package/dist/esm/apps/identity/state-machines/identity-registry.js +259 -0
- package/dist/esm/apps/identity/state-machines/identity-universal.js +52 -58
- package/dist/esm/apps/identity/state-machines/index.js +1 -0
- package/dist/esm/apps/index.js +9 -5
- package/dist/esm/apps/lending/assets.js +231 -0
- package/dist/esm/apps/lending/credit-scoring.js +81 -0
- package/dist/esm/apps/lending/eligibility.js +99 -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 +430 -0
- package/dist/esm/apps/markets/index.js +11 -7
- package/dist/esm/apps/markets/state-machines/market-auction.js +117 -135
- package/dist/esm/apps/markets/state-machines/market-crowdfund.js +132 -142
- package/dist/esm/apps/markets/state-machines/market-group-buy.js +164 -185
- package/dist/esm/apps/markets/state-machines/market-prediction.js +227 -234
- 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/index.js +9 -5
- package/dist/esm/generated/openapi.js +5 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +47 -47
- 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 +115 -121
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +101 -101
- 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 +28 -3
- package/dist/esm/openapi.js +1 -0
- package/dist/esm/ottochain/genesis-manifest.js +15 -9
- package/dist/esm/ottochain/index.js +2 -3
- package/dist/esm/ottochain/metagraph-client.js +81 -16
- package/dist/esm/ottochain/snapshot.js +6 -8
- package/dist/esm/ottochain/transaction.js +51 -3
- package/dist/esm/ottochain/types.js +15 -1
- package/dist/esm/privacy/index.js +6 -0
- package/dist/esm/privacy/sealed-bid.js +209 -0
- package/dist/esm/privacy/shield-app.js +127 -0
- package/dist/esm/schema/effects.js +145 -0
- package/dist/esm/schema/fiber-app.js +139 -8
- package/dist/esm/schema/guard-lint.js +337 -0
- package/dist/esm/schema/guards.js +228 -0
- package/dist/esm/signing.js +74 -0
- 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/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/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 +81 -221
- package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +23 -98
- package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +49 -115
- package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +4 -4
- package/dist/types/apps/corporate/index.d.ts +1176 -440
- package/dist/types/apps/corporate/state-machines/corp-board.d.ts +271 -135
- package/dist/types/apps/corporate/state-machines/corp-entity.d.ts +279 -74
- package/dist/types/apps/corporate/state-machines/corp-securities.d.ts +373 -149
- package/dist/types/apps/corporate/state-machines/corp-shareholders.d.ts +252 -80
- package/dist/types/apps/governance/index.d.ts +368 -470
- package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +92 -107
- package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +61 -85
- package/dist/types/apps/governance/state-machines/dao-single.d.ts +25 -47
- package/dist/types/apps/governance/state-machines/dao-token.d.ts +79 -68
- package/dist/types/apps/governance/state-machines/governance-simple.d.ts +95 -125
- package/dist/types/apps/governance/state-machines/governance-universal.d.ts +6 -6
- package/dist/types/apps/identity/constants.d.ts +33 -5
- package/dist/types/apps/identity/index.d.ts +415 -131
- package/dist/types/apps/identity/state-machines/identity-agent.d.ts +23 -23
- package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +27 -98
- package/dist/types/apps/identity/state-machines/identity-registry.d.ts +379 -0
- package/dist/types/apps/identity/state-machines/identity-universal.d.ts +4 -4
- package/dist/types/apps/identity/state-machines/index.d.ts +1 -0
- package/dist/types/apps/index.d.ts +9 -5
- 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 +556 -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 +536 -0
- package/dist/types/apps/markets/index.d.ts +181 -276
- package/dist/types/apps/markets/state-machines/market-auction.d.ts +25 -49
- package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +35 -53
- package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +35 -61
- package/dist/types/apps/markets/state-machines/market-prediction.d.ts +65 -86
- package/dist/types/apps/markets/state-machines/market-universal.d.ts +12 -12
- 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/index.d.ts +5 -5
- package/dist/types/generated/openapi.d.ts +1270 -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/fiber.d.ts +7 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/openapi.d.ts +24 -0
- package/dist/types/ottochain/genesis-manifest.d.ts +11 -5
- package/dist/types/ottochain/index.d.ts +5 -6
- 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 +41 -1
- package/dist/types/ottochain/types.d.ts +336 -31
- 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 +141 -0
- package/dist/types/schema/fiber-app.d.ts +282 -2
- package/dist/types/schema/guard-lint.d.ts +111 -0
- package/dist/types/schema/guards.d.ts +146 -0
- package/dist/types/signing.d.ts +45 -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/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 +47 -15
- 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,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();
|
|
@@ -22,15 +22,19 @@ export { FiberStatus, AccessControlPolicy, PublicAccess, WhitelistAccess, FiberO
|
|
|
22
22
|
export { CreateStateMachine, TransitionStateMachine, ArchiveStateMachine, CreateScript, InvokeScript, OttochainMessage, } from './ottochain/v1/messages.js';
|
|
23
23
|
export { StateMachineFiberRecord, ScriptFiberRecord, FiberCommit, OnChainState, CalculatedState, } from './ottochain/v1/records.js';
|
|
24
24
|
// App: Identity (unified in v2.1)
|
|
25
|
-
|
|
25
|
+
// The nested lifecycle/kind enums dropped their app prefix in the proto
|
|
26
|
+
// (now Type/State, disambiguated by package ottochain.apps.identity.v1).
|
|
27
|
+
// This flat barrel re-aliases them back to app-qualified names so the global
|
|
28
|
+
// export namespace stays collision-free across apps.
|
|
29
|
+
export { Type as IdentityType, State as IdentityState, Platform, PlatformLink, Reputation, PenaltyEvent, Identity, RegisterIdentityRequest, ActivateIdentityRequest, LinkPlatformRequest, ChallengeIdentityRequest, AddStakeRequest, WithdrawIdentityRequest, IdentityDefinition, } from './ottochain/apps/identity/v1/identity.js';
|
|
26
30
|
// Legacy aliases for backward compatibility
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
31
|
+
export { State as AgentState } from './ottochain/apps/identity/v1/identity.js';
|
|
32
|
+
export { State as OracleState } from './ottochain/apps/identity/v1/identity.js';
|
|
29
33
|
export { AttestationType, ReputationDelta, Attestation, VouchRequest, ChallengeRequest, ReputationConfig, } from './ottochain/apps/identity/v1/attestation.js';
|
|
30
34
|
// App: Contracts
|
|
31
|
-
export { ContractState, Contract, ProposeContractRequest, AcceptContractRequest, CompleteContractRequest, RejectContractRequest, DisputeContractRequest, ContractDefinition, } from './ottochain/apps/contracts/v1/contract.js';
|
|
35
|
+
export { State as ContractState, Contract, ProposeContractRequest, AcceptContractRequest, CompleteContractRequest, RejectContractRequest, DisputeContractRequest, ContractDefinition, } from './ottochain/apps/contracts/v1/contract.js';
|
|
32
36
|
// App: Markets
|
|
33
|
-
export { MarketType, MarketState, Commitment, Resolution, Market, CreateMarketRequest, CommitToMarketRequest, SubmitResolutionRequest, CancelMarketRequest, MarketDefinition, } from './ottochain/apps/markets/v1/market.js';
|
|
37
|
+
export { Type as MarketType, State as MarketState, Commitment, Resolution, Market, CreateMarketRequest, CommitToMarketRequest, SubmitResolutionRequest, CancelMarketRequest, MarketDefinition, } from './ottochain/apps/markets/v1/market.js';
|
|
34
38
|
// App: Oracles - REMOVED in v2.1 (absorbed into identity)
|
|
35
39
|
// OracleState is now an alias for IdentityState (see above)
|
|
36
40
|
// Oracle-specific messages moved to identity.proto
|
|
@@ -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/apps/contracts/v1/contract.proto
|
|
6
6
|
/* eslint-disable */
|
|
@@ -9,90 +9,90 @@ import { Struct } from "../../../../google/protobuf/struct.js";
|
|
|
9
9
|
import { Timestamp } from "../../../../google/protobuf/timestamp.js";
|
|
10
10
|
export const protobufPackage = "ottochain.apps.contracts.v1";
|
|
11
11
|
/** Contract lifecycle states */
|
|
12
|
-
export var
|
|
13
|
-
(function (
|
|
14
|
-
|
|
12
|
+
export var State;
|
|
13
|
+
(function (State) {
|
|
14
|
+
State["CONTRACT_STATE_UNSPECIFIED"] = "CONTRACT_STATE_UNSPECIFIED";
|
|
15
15
|
/** CONTRACT_STATE_PROPOSED - Awaiting counterparty acceptance */
|
|
16
|
-
|
|
16
|
+
State["CONTRACT_STATE_PROPOSED"] = "CONTRACT_STATE_PROPOSED";
|
|
17
17
|
/** CONTRACT_STATE_ACTIVE - Both parties agreed, in progress */
|
|
18
|
-
|
|
18
|
+
State["CONTRACT_STATE_ACTIVE"] = "CONTRACT_STATE_ACTIVE";
|
|
19
19
|
/** CONTRACT_STATE_COMPLETED - Successfully fulfilled (terminal) */
|
|
20
|
-
|
|
20
|
+
State["CONTRACT_STATE_COMPLETED"] = "CONTRACT_STATE_COMPLETED";
|
|
21
21
|
/** CONTRACT_STATE_REJECTED - Counterparty declined (terminal) */
|
|
22
|
-
|
|
22
|
+
State["CONTRACT_STATE_REJECTED"] = "CONTRACT_STATE_REJECTED";
|
|
23
23
|
/** CONTRACT_STATE_DISPUTED - Under dispute resolution */
|
|
24
|
-
|
|
24
|
+
State["CONTRACT_STATE_DISPUTED"] = "CONTRACT_STATE_DISPUTED";
|
|
25
25
|
/** CONTRACT_STATE_CANCELLED - Cancelled by proposer before acceptance (terminal) */
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})(
|
|
29
|
-
export function
|
|
26
|
+
State["CONTRACT_STATE_CANCELLED"] = "CONTRACT_STATE_CANCELLED";
|
|
27
|
+
State["UNRECOGNIZED"] = "UNRECOGNIZED";
|
|
28
|
+
})(State || (State = {}));
|
|
29
|
+
export function stateFromJSON(object) {
|
|
30
30
|
switch (object) {
|
|
31
31
|
case 0:
|
|
32
32
|
case "CONTRACT_STATE_UNSPECIFIED":
|
|
33
|
-
return
|
|
33
|
+
return State.CONTRACT_STATE_UNSPECIFIED;
|
|
34
34
|
case 1:
|
|
35
35
|
case "CONTRACT_STATE_PROPOSED":
|
|
36
|
-
return
|
|
36
|
+
return State.CONTRACT_STATE_PROPOSED;
|
|
37
37
|
case 2:
|
|
38
38
|
case "CONTRACT_STATE_ACTIVE":
|
|
39
|
-
return
|
|
39
|
+
return State.CONTRACT_STATE_ACTIVE;
|
|
40
40
|
case 3:
|
|
41
41
|
case "CONTRACT_STATE_COMPLETED":
|
|
42
|
-
return
|
|
42
|
+
return State.CONTRACT_STATE_COMPLETED;
|
|
43
43
|
case 4:
|
|
44
44
|
case "CONTRACT_STATE_REJECTED":
|
|
45
|
-
return
|
|
45
|
+
return State.CONTRACT_STATE_REJECTED;
|
|
46
46
|
case 5:
|
|
47
47
|
case "CONTRACT_STATE_DISPUTED":
|
|
48
|
-
return
|
|
48
|
+
return State.CONTRACT_STATE_DISPUTED;
|
|
49
49
|
case 6:
|
|
50
50
|
case "CONTRACT_STATE_CANCELLED":
|
|
51
|
-
return
|
|
51
|
+
return State.CONTRACT_STATE_CANCELLED;
|
|
52
52
|
case -1:
|
|
53
53
|
case "UNRECOGNIZED":
|
|
54
54
|
default:
|
|
55
|
-
return
|
|
55
|
+
return State.UNRECOGNIZED;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
export function
|
|
58
|
+
export function stateToJSON(object) {
|
|
59
59
|
switch (object) {
|
|
60
|
-
case
|
|
60
|
+
case State.CONTRACT_STATE_UNSPECIFIED:
|
|
61
61
|
return "CONTRACT_STATE_UNSPECIFIED";
|
|
62
|
-
case
|
|
62
|
+
case State.CONTRACT_STATE_PROPOSED:
|
|
63
63
|
return "CONTRACT_STATE_PROPOSED";
|
|
64
|
-
case
|
|
64
|
+
case State.CONTRACT_STATE_ACTIVE:
|
|
65
65
|
return "CONTRACT_STATE_ACTIVE";
|
|
66
|
-
case
|
|
66
|
+
case State.CONTRACT_STATE_COMPLETED:
|
|
67
67
|
return "CONTRACT_STATE_COMPLETED";
|
|
68
|
-
case
|
|
68
|
+
case State.CONTRACT_STATE_REJECTED:
|
|
69
69
|
return "CONTRACT_STATE_REJECTED";
|
|
70
|
-
case
|
|
70
|
+
case State.CONTRACT_STATE_DISPUTED:
|
|
71
71
|
return "CONTRACT_STATE_DISPUTED";
|
|
72
|
-
case
|
|
72
|
+
case State.CONTRACT_STATE_CANCELLED:
|
|
73
73
|
return "CONTRACT_STATE_CANCELLED";
|
|
74
|
-
case
|
|
74
|
+
case State.UNRECOGNIZED:
|
|
75
75
|
default:
|
|
76
76
|
return "UNRECOGNIZED";
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
export function
|
|
79
|
+
export function stateToNumber(object) {
|
|
80
80
|
switch (object) {
|
|
81
|
-
case
|
|
81
|
+
case State.CONTRACT_STATE_UNSPECIFIED:
|
|
82
82
|
return 0;
|
|
83
|
-
case
|
|
83
|
+
case State.CONTRACT_STATE_PROPOSED:
|
|
84
84
|
return 1;
|
|
85
|
-
case
|
|
85
|
+
case State.CONTRACT_STATE_ACTIVE:
|
|
86
86
|
return 2;
|
|
87
|
-
case
|
|
87
|
+
case State.CONTRACT_STATE_COMPLETED:
|
|
88
88
|
return 3;
|
|
89
|
-
case
|
|
89
|
+
case State.CONTRACT_STATE_REJECTED:
|
|
90
90
|
return 4;
|
|
91
|
-
case
|
|
91
|
+
case State.CONTRACT_STATE_DISPUTED:
|
|
92
92
|
return 5;
|
|
93
|
-
case
|
|
93
|
+
case State.CONTRACT_STATE_CANCELLED:
|
|
94
94
|
return 6;
|
|
95
|
-
case
|
|
95
|
+
case State.UNRECOGNIZED:
|
|
96
96
|
default:
|
|
97
97
|
return -1;
|
|
98
98
|
}
|
|
@@ -103,7 +103,7 @@ function createBaseContract() {
|
|
|
103
103
|
contractId: "",
|
|
104
104
|
proposer: "",
|
|
105
105
|
counterparty: "",
|
|
106
|
-
state:
|
|
106
|
+
state: State.CONTRACT_STATE_UNSPECIFIED,
|
|
107
107
|
terms: undefined,
|
|
108
108
|
proposedAt: undefined,
|
|
109
109
|
acceptedAt: undefined,
|
|
@@ -125,8 +125,8 @@ export const Contract = {
|
|
|
125
125
|
if (message.counterparty !== "") {
|
|
126
126
|
writer.uint32(34).string(message.counterparty);
|
|
127
127
|
}
|
|
128
|
-
if (message.state !==
|
|
129
|
-
writer.uint32(40).int32(
|
|
128
|
+
if (message.state !== State.CONTRACT_STATE_UNSPECIFIED) {
|
|
129
|
+
writer.uint32(40).int32(stateToNumber(message.state));
|
|
130
130
|
}
|
|
131
131
|
if (message.terms !== undefined) {
|
|
132
132
|
Struct.encode(Struct.wrap(message.terms), writer.uint32(50).fork()).join();
|
|
@@ -184,7 +184,7 @@ export const Contract = {
|
|
|
184
184
|
if (tag !== 40) {
|
|
185
185
|
break;
|
|
186
186
|
}
|
|
187
|
-
message.state =
|
|
187
|
+
message.state = stateFromJSON(reader.int32());
|
|
188
188
|
continue;
|
|
189
189
|
}
|
|
190
190
|
case 6: {
|
|
@@ -240,7 +240,7 @@ export const Contract = {
|
|
|
240
240
|
: "",
|
|
241
241
|
proposer: isSet(object.proposer) ? globalThis.String(object.proposer) : "",
|
|
242
242
|
counterparty: isSet(object.counterparty) ? globalThis.String(object.counterparty) : "",
|
|
243
|
-
state: isSet(object.state) ?
|
|
243
|
+
state: isSet(object.state) ? stateFromJSON(object.state) : State.CONTRACT_STATE_UNSPECIFIED,
|
|
244
244
|
terms: isObject(object.terms) ? object.terms : undefined,
|
|
245
245
|
proposedAt: isSet(object.proposedAt)
|
|
246
246
|
? fromJsonTimestamp(object.proposedAt)
|
|
@@ -278,8 +278,8 @@ export const Contract = {
|
|
|
278
278
|
if (message.counterparty !== "") {
|
|
279
279
|
obj.counterparty = message.counterparty;
|
|
280
280
|
}
|
|
281
|
-
if (message.state !==
|
|
282
|
-
obj.state =
|
|
281
|
+
if (message.state !== State.CONTRACT_STATE_UNSPECIFIED) {
|
|
282
|
+
obj.state = stateToJSON(message.state);
|
|
283
283
|
}
|
|
284
284
|
if (message.terms !== undefined) {
|
|
285
285
|
obj.terms = message.terms;
|
|
@@ -307,7 +307,7 @@ export const Contract = {
|
|
|
307
307
|
message.contractId = object.contractId ?? "";
|
|
308
308
|
message.proposer = object.proposer ?? "";
|
|
309
309
|
message.counterparty = object.counterparty ?? "";
|
|
310
|
-
message.state = object.state ??
|
|
310
|
+
message.state = object.state ?? State.CONTRACT_STATE_UNSPECIFIED;
|
|
311
311
|
message.terms = object.terms ?? undefined;
|
|
312
312
|
message.proposedAt = object.proposedAt ?? undefined;
|
|
313
313
|
message.acceptedAt = object.acceptedAt ?? undefined;
|