@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,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The generic staked-pool BASE definition (`StakedPool`) — the reusable epoch-pool skeleton with a
|
|
4
|
+
* minimal pass-through `finalize` (authority settles; publishes a trivial result and an EMPTY in-consensus
|
|
5
|
+
* set, zero transfers). It is the lowest-common-denominator def; downstream apps should prefer a
|
|
6
|
+
* specialization (e.g. the oracle pool) that supplies real aggregation. Exposed for definition-validity
|
|
7
|
+
* round-tripping and as the explicit "base, unspecialized" instance.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.stakedPoolBaseDef = void 0;
|
|
11
|
+
const base_js_1 = require("../base.js");
|
|
12
|
+
/** Minimal finalize: authority settles; no aggregation, empty entitlement set, zero transfers. */
|
|
13
|
+
const baseFinalizeArm = {
|
|
14
|
+
from: 'COLLECTING',
|
|
15
|
+
to: 'SETTLED',
|
|
16
|
+
eventName: 'finalize',
|
|
17
|
+
guard: {
|
|
18
|
+
and: [
|
|
19
|
+
{ in: [{ var: 'state.authority' }, { map: [{ var: 'proofs' }, { var: 'address' }] }] },
|
|
20
|
+
{ '>=': [{ count: [{ var: 'state.submissions' }] }, { var: 'state.quorum' }] },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
effect: {
|
|
24
|
+
merge: [
|
|
25
|
+
{ var: 'state' },
|
|
26
|
+
{
|
|
27
|
+
status: 'SETTLED',
|
|
28
|
+
inConsensus: [],
|
|
29
|
+
claimed: {},
|
|
30
|
+
result: {
|
|
31
|
+
submissionCount: { count: [{ var: 'state.submissions' }] },
|
|
32
|
+
epoch: { var: 'state.epoch' },
|
|
33
|
+
finalizedAt: { var: '$ordinal' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
dependencies: [],
|
|
39
|
+
};
|
|
40
|
+
exports.stakedPoolBaseDef = (0, base_js_1.makeStakedPoolDef)({
|
|
41
|
+
metadata: {
|
|
42
|
+
name: 'StakedPool',
|
|
43
|
+
type: 'base',
|
|
44
|
+
description: 'Generic staked-epoch-pool base (FORMING→COLLECTING→SETTLED→COLLECTING…→CLOSED): registry-gated ' +
|
|
45
|
+
'join with stake custody, append-only submissions, a state-resident claim entitlement ledger, and ' +
|
|
46
|
+
'one-whole-asset claim/withdraw transfers. Specialize `submit`/`finalize` for a concrete pool.',
|
|
47
|
+
},
|
|
48
|
+
finalize: baseFinalizeArm,
|
|
49
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Oracle-pool specialization of the staked-pool base (`StakedPoolOracle`).
|
|
4
|
+
*
|
|
5
|
+
* `submit` appends a numeric datapoint `{ addr, value }` (the base default arm).
|
|
6
|
+
* `finalize` (COLLECTING→SETTLED) aggregates the array with an outlier-bounded mean and publishes the
|
|
7
|
+
* answer + the in-consensus address set — emitting ZERO asset transfers (the entitlement ledger is
|
|
8
|
+
* `inConsensus`; rewards are pulled per-claim via the base `claim_reward` arm).
|
|
9
|
+
*
|
|
10
|
+
* Aggregation (default `trimmedMean`):
|
|
11
|
+
* 1. vals = map(submissions, .value)
|
|
12
|
+
* 2. trimmed = filter(submissions, value != min(vals) && value != max(vals)) — drop single min + single max
|
|
13
|
+
* 3. center = sum(trimmed.value) / count(trimmed) — EXACT rational (no truncation)
|
|
14
|
+
* 4. kept = filter(submissions, abs(value - center) <= outlierBound) — the in-consensus set
|
|
15
|
+
* 5. answer = sum(kept.value) / count(kept)
|
|
16
|
+
*
|
|
17
|
+
* CRITICAL JLVM SCOPING (verified against @constellation-network/metagraph-sdk-jlvm@1.8.0-rc.5):
|
|
18
|
+
* - Inside a `map`/`filter` callback the data scope is the BARE element, BUT the outer `state.*` is
|
|
19
|
+
* still readable (verified: `{cat:[addr,"|",{var:"state.epoch"}]}` reads epoch correctly).
|
|
20
|
+
* - A `let`-bound name does NOT cross into a `map`/`filter` callback. So `center` is INLINED into the
|
|
21
|
+
* `kept` predicate (it reads `state.submissions`, which IS visible) rather than `let`-hoisted — a
|
|
22
|
+
* `let`-bound `center` resolves to null inside `filter`, evicting every submission (div-by-zero).
|
|
23
|
+
* - A `reduce` with a MAP initial accumulator is rejected (`opReduce` requires `isPrimitive(init)`),
|
|
24
|
+
* so the reward ledger is NOT a folded `{addr:int}` map — it is the `inConsensus` array (membership =
|
|
25
|
+
* entitlement), consumed by `claim_reward` + a `claimed` dedup map.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.stakedPoolOracleDef = void 0;
|
|
29
|
+
exports.makeOraclePoolDef = makeOraclePoolDef;
|
|
30
|
+
const base_js_1 = require("../base.js");
|
|
31
|
+
const sum = (arr) => ({
|
|
32
|
+
reduce: [arr, { '+': [{ var: 'accumulator' }, { var: 'current' }] }, 0],
|
|
33
|
+
});
|
|
34
|
+
const meanOf = (arr) => ({ '/': [sum(arr), { count: [arr] }] });
|
|
35
|
+
/** vals = map(submissions, .value) */
|
|
36
|
+
const VALS = { map: [{ var: 'state.submissions' }, { get: [{ var: '' }, 'value'] }] };
|
|
37
|
+
/**
|
|
38
|
+
* The aggregation `center` as a CLOSED expression over `state.submissions` (must be inlined into the
|
|
39
|
+
* `kept` filter — see file header). `trimmedMean` drops the single min + single max before averaging.
|
|
40
|
+
*/
|
|
41
|
+
function centerExpr(aggregation) {
|
|
42
|
+
if (aggregation === 'mean')
|
|
43
|
+
return meanOf(VALS);
|
|
44
|
+
const trimmed = {
|
|
45
|
+
filter: [
|
|
46
|
+
{ var: 'state.submissions' },
|
|
47
|
+
{
|
|
48
|
+
and: [
|
|
49
|
+
{ '!==': [{ get: [{ var: '' }, 'value'] }, { min: [VALS] }] },
|
|
50
|
+
{ '!==': [{ get: [{ var: '' }, 'value'] }, { max: [VALS] }] },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
const trimmedVals = { map: [trimmed, { get: [{ var: '' }, 'value'] }] };
|
|
56
|
+
return meanOf(trimmedVals);
|
|
57
|
+
}
|
|
58
|
+
/** finalize COLLECTING→SETTLED — publish answer + inConsensus; ZERO asset transfers. */
|
|
59
|
+
function finalizeArm(aggregation) {
|
|
60
|
+
const center = centerExpr(aggregation);
|
|
61
|
+
// kept = the in-consensus submissions; `center` is INLINED (visible state.submissions inside filter).
|
|
62
|
+
const kept = {
|
|
63
|
+
filter: [
|
|
64
|
+
{ var: 'state.submissions' },
|
|
65
|
+
{
|
|
66
|
+
'<=': [{ abs: [{ '-': [{ get: [{ var: '' }, 'value'] }, center] }] }, { var: 'state.outlierBound' }],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
const keptVals = { map: [kept, { get: [{ var: '' }, 'value'] }] };
|
|
71
|
+
const inConsensus = { map: [kept, { get: [{ var: '' }, 'addr'] }] };
|
|
72
|
+
return {
|
|
73
|
+
from: 'COLLECTING',
|
|
74
|
+
to: 'SETTLED',
|
|
75
|
+
eventName: 'finalize',
|
|
76
|
+
// Authority finalizes once quorum is met AND the window has elapsed.
|
|
77
|
+
guard: {
|
|
78
|
+
and: [
|
|
79
|
+
{ in: [{ var: 'state.authority' }, { map: [{ var: 'proofs' }, { var: 'address' }] }] },
|
|
80
|
+
{ '>=': [{ count: [{ var: 'state.submissions' }] }, { var: 'state.quorum' }] },
|
|
81
|
+
{
|
|
82
|
+
'>=': [{ var: '$ordinal' }, { '+': [{ var: 'state.epochStartedAt' }, { var: 'state.epochLength' }] }],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
// ZERO _transferAsset: publish result + record the in-consensus entitlement set + reset claimed.
|
|
87
|
+
effect: {
|
|
88
|
+
merge: [
|
|
89
|
+
{ var: 'state' },
|
|
90
|
+
{
|
|
91
|
+
status: 'SETTLED',
|
|
92
|
+
inConsensus,
|
|
93
|
+
claimed: {},
|
|
94
|
+
result: {
|
|
95
|
+
value: meanOf(keptVals),
|
|
96
|
+
epoch: { var: 'state.epoch' },
|
|
97
|
+
finalizedAt: { var: '$ordinal' },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
dependencies: [],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** Build the oracle-pool definition. `outlierPenalty` is soft-only (no-credit for outliers); hard slash is v2. */
|
|
106
|
+
function makeOraclePoolDef(options = {}) {
|
|
107
|
+
const aggregation = options.aggregation ?? 'trimmedMean';
|
|
108
|
+
return (0, base_js_1.makeStakedPoolDef)({
|
|
109
|
+
metadata: {
|
|
110
|
+
name: 'StakedPoolOracle',
|
|
111
|
+
type: 'oraclePool',
|
|
112
|
+
description: 'Reputation-gated staked oracle pool: participants stake + submit numeric datapoints; finalize ' +
|
|
113
|
+
'publishes an outlier-bounded (default trimmed-mean) consensus answer and credits the in-consensus ' +
|
|
114
|
+
'set as a claim entitlement (zero finalize-time transfers); a consumer reads the published value ' +
|
|
115
|
+
'cross-fiber via an epoch-pinned depInState(SETTLED) gate.',
|
|
116
|
+
},
|
|
117
|
+
finalize: finalizeArm(aggregation),
|
|
118
|
+
extraCreateProperties: {
|
|
119
|
+
rewardPolicy: {
|
|
120
|
+
type: 'string',
|
|
121
|
+
description: 'Asset policy of the shared fungible reward token.',
|
|
122
|
+
immutable: true,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
extraStateProperties: {
|
|
126
|
+
rewardPolicy: { type: 'string', immutable: true },
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** Default oracle-pool definition (trimmed-mean). */
|
|
131
|
+
exports.stakedPoolOracleDef = makeOraclePoolDef();
|
package/dist/cjs/errors.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.TransactionError = exports.SigningError = exports.ValidationError = exports.NetworkError = exports.OttoChainError = exports.ErrorCode = void 0;
|
|
11
|
+
exports.isErrorCode = isErrorCode;
|
|
12
|
+
exports.wrapError = wrapError;
|
|
11
13
|
/**
|
|
12
14
|
* Error codes for OttoChain SDK errors
|
|
13
15
|
*/
|
|
@@ -273,7 +275,6 @@ exports.TransactionError = TransactionError;
|
|
|
273
275
|
function isErrorCode(error, code) {
|
|
274
276
|
return error instanceof OttoChainError && error.code === code;
|
|
275
277
|
}
|
|
276
|
-
exports.isErrorCode = isErrorCode;
|
|
277
278
|
/**
|
|
278
279
|
* Wrap an unknown error in an OttoChainError
|
|
279
280
|
*
|
|
@@ -290,4 +291,3 @@ function wrapError(error, defaultMessage = 'An error occurred') {
|
|
|
290
291
|
}
|
|
291
292
|
return new OttoChainError(ErrorCode.UNKNOWN, String(error) || defaultMessage);
|
|
292
293
|
}
|
|
293
|
-
exports.wrapError = wrapError;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.8
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/protobuf/struct.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ListValue = exports.Value = exports.Struct_FieldsEntry = exports.Struct = exports.
|
|
8
|
+
exports.ListValue = exports.Value = exports.Struct_FieldsEntry = exports.Struct = exports.NullValue = exports.protobufPackage = void 0;
|
|
9
|
+
exports.nullValueFromJSON = nullValueFromJSON;
|
|
10
|
+
exports.nullValueToJSON = nullValueToJSON;
|
|
11
|
+
exports.nullValueToNumber = nullValueToNumber;
|
|
9
12
|
/* eslint-disable */
|
|
10
13
|
const wire_1 = require("@bufbuild/protobuf/wire");
|
|
11
14
|
exports.protobufPackage = "google.protobuf";
|
|
@@ -32,7 +35,6 @@ function nullValueFromJSON(object) {
|
|
|
32
35
|
return NullValue.UNRECOGNIZED;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
exports.nullValueFromJSON = nullValueFromJSON;
|
|
36
38
|
function nullValueToJSON(object) {
|
|
37
39
|
switch (object) {
|
|
38
40
|
case NullValue.NULL_VALUE:
|
|
@@ -42,7 +44,6 @@ function nullValueToJSON(object) {
|
|
|
42
44
|
return "UNRECOGNIZED";
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
exports.nullValueToJSON = nullValueToJSON;
|
|
46
47
|
function nullValueToNumber(object) {
|
|
47
48
|
switch (object) {
|
|
48
49
|
case NullValue.NULL_VALUE:
|
|
@@ -52,7 +53,6 @@ function nullValueToNumber(object) {
|
|
|
52
53
|
return -1;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
exports.nullValueToNumber = nullValueToNumber;
|
|
56
56
|
function createBaseStruct() {
|
|
57
57
|
return { fields: {} };
|
|
58
58
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.8
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/protobuf/timestamp.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -48,9 +48,13 @@ Object.defineProperty(exports, "FiberCommit", { enumerable: true, get: function
|
|
|
48
48
|
Object.defineProperty(exports, "OnChainState", { enumerable: true, get: function () { return records_js_1.OnChainState; } });
|
|
49
49
|
Object.defineProperty(exports, "CalculatedState", { enumerable: true, get: function () { return records_js_1.CalculatedState; } });
|
|
50
50
|
// App: Identity (unified in v2.1)
|
|
51
|
+
// The nested lifecycle/kind enums dropped their app prefix in the proto
|
|
52
|
+
// (now Type/State, disambiguated by package ottochain.apps.identity.v1).
|
|
53
|
+
// This flat barrel re-aliases them back to app-qualified names so the global
|
|
54
|
+
// export namespace stays collision-free across apps.
|
|
51
55
|
var identity_js_1 = require("./ottochain/apps/identity/v1/identity.js");
|
|
52
|
-
Object.defineProperty(exports, "IdentityType", { enumerable: true, get: function () { return identity_js_1.
|
|
53
|
-
Object.defineProperty(exports, "IdentityState", { enumerable: true, get: function () { return identity_js_1.
|
|
56
|
+
Object.defineProperty(exports, "IdentityType", { enumerable: true, get: function () { return identity_js_1.Type; } });
|
|
57
|
+
Object.defineProperty(exports, "IdentityState", { enumerable: true, get: function () { return identity_js_1.State; } });
|
|
54
58
|
Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return identity_js_1.Platform; } });
|
|
55
59
|
Object.defineProperty(exports, "PlatformLink", { enumerable: true, get: function () { return identity_js_1.PlatformLink; } });
|
|
56
60
|
Object.defineProperty(exports, "Reputation", { enumerable: true, get: function () { return identity_js_1.Reputation; } });
|
|
@@ -65,9 +69,9 @@ Object.defineProperty(exports, "WithdrawIdentityRequest", { enumerable: true, ge
|
|
|
65
69
|
Object.defineProperty(exports, "IdentityDefinition", { enumerable: true, get: function () { return identity_js_1.IdentityDefinition; } });
|
|
66
70
|
// Legacy aliases for backward compatibility
|
|
67
71
|
var identity_js_2 = require("./ottochain/apps/identity/v1/identity.js");
|
|
68
|
-
Object.defineProperty(exports, "AgentState", { enumerable: true, get: function () { return identity_js_2.
|
|
72
|
+
Object.defineProperty(exports, "AgentState", { enumerable: true, get: function () { return identity_js_2.State; } });
|
|
69
73
|
var identity_js_3 = require("./ottochain/apps/identity/v1/identity.js");
|
|
70
|
-
Object.defineProperty(exports, "OracleState", { enumerable: true, get: function () { return identity_js_3.
|
|
74
|
+
Object.defineProperty(exports, "OracleState", { enumerable: true, get: function () { return identity_js_3.State; } });
|
|
71
75
|
var attestation_js_1 = require("./ottochain/apps/identity/v1/attestation.js");
|
|
72
76
|
Object.defineProperty(exports, "AttestationType", { enumerable: true, get: function () { return attestation_js_1.AttestationType; } });
|
|
73
77
|
Object.defineProperty(exports, "ReputationDelta", { enumerable: true, get: function () { return attestation_js_1.ReputationDelta; } });
|
|
@@ -77,7 +81,7 @@ Object.defineProperty(exports, "ChallengeRequest", { enumerable: true, get: func
|
|
|
77
81
|
Object.defineProperty(exports, "ReputationConfig", { enumerable: true, get: function () { return attestation_js_1.ReputationConfig; } });
|
|
78
82
|
// App: Contracts
|
|
79
83
|
var contract_js_1 = require("./ottochain/apps/contracts/v1/contract.js");
|
|
80
|
-
Object.defineProperty(exports, "ContractState", { enumerable: true, get: function () { return contract_js_1.
|
|
84
|
+
Object.defineProperty(exports, "ContractState", { enumerable: true, get: function () { return contract_js_1.State; } });
|
|
81
85
|
Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return contract_js_1.Contract; } });
|
|
82
86
|
Object.defineProperty(exports, "ProposeContractRequest", { enumerable: true, get: function () { return contract_js_1.ProposeContractRequest; } });
|
|
83
87
|
Object.defineProperty(exports, "AcceptContractRequest", { enumerable: true, get: function () { return contract_js_1.AcceptContractRequest; } });
|
|
@@ -87,8 +91,8 @@ Object.defineProperty(exports, "DisputeContractRequest", { enumerable: true, get
|
|
|
87
91
|
Object.defineProperty(exports, "ContractDefinition", { enumerable: true, get: function () { return contract_js_1.ContractDefinition; } });
|
|
88
92
|
// App: Markets
|
|
89
93
|
var market_js_1 = require("./ottochain/apps/markets/v1/market.js");
|
|
90
|
-
Object.defineProperty(exports, "MarketType", { enumerable: true, get: function () { return market_js_1.
|
|
91
|
-
Object.defineProperty(exports, "MarketState", { enumerable: true, get: function () { return market_js_1.
|
|
94
|
+
Object.defineProperty(exports, "MarketType", { enumerable: true, get: function () { return market_js_1.Type; } });
|
|
95
|
+
Object.defineProperty(exports, "MarketState", { enumerable: true, get: function () { return market_js_1.State; } });
|
|
92
96
|
Object.defineProperty(exports, "Commitment", { enumerable: true, get: function () { return market_js_1.Commitment; } });
|
|
93
97
|
Object.defineProperty(exports, "Resolution", { enumerable: true, get: function () { return market_js_1.Resolution; } });
|
|
94
98
|
Object.defineProperty(exports, "Market", { enumerable: true, get: function () { return market_js_1.Market; } });
|
|
@@ -1,115 +1,115 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.8
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: ottochain/apps/contracts/v1/contract.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ContractDefinition = exports.DisputeContractRequest = exports.RejectContractRequest = exports.CompleteContractRequest = exports.AcceptContractRequest = exports.ProposeContractRequest = exports.Contract = exports.
|
|
8
|
+
exports.ContractDefinition = exports.DisputeContractRequest = exports.RejectContractRequest = exports.CompleteContractRequest = exports.AcceptContractRequest = exports.ProposeContractRequest = exports.Contract = exports.State = exports.protobufPackage = void 0;
|
|
9
|
+
exports.stateFromJSON = stateFromJSON;
|
|
10
|
+
exports.stateToJSON = stateToJSON;
|
|
11
|
+
exports.stateToNumber = stateToNumber;
|
|
9
12
|
/* eslint-disable */
|
|
10
13
|
const wire_1 = require("@bufbuild/protobuf/wire");
|
|
11
14
|
const struct_js_1 = require("../../../../google/protobuf/struct.js");
|
|
12
15
|
const timestamp_js_1 = require("../../../../google/protobuf/timestamp.js");
|
|
13
16
|
exports.protobufPackage = "ottochain.apps.contracts.v1";
|
|
14
17
|
/** Contract lifecycle states */
|
|
15
|
-
var
|
|
16
|
-
(function (
|
|
17
|
-
|
|
18
|
+
var State;
|
|
19
|
+
(function (State) {
|
|
20
|
+
State["CONTRACT_STATE_UNSPECIFIED"] = "CONTRACT_STATE_UNSPECIFIED";
|
|
18
21
|
/** CONTRACT_STATE_PROPOSED - Awaiting counterparty acceptance */
|
|
19
|
-
|
|
22
|
+
State["CONTRACT_STATE_PROPOSED"] = "CONTRACT_STATE_PROPOSED";
|
|
20
23
|
/** CONTRACT_STATE_ACTIVE - Both parties agreed, in progress */
|
|
21
|
-
|
|
24
|
+
State["CONTRACT_STATE_ACTIVE"] = "CONTRACT_STATE_ACTIVE";
|
|
22
25
|
/** CONTRACT_STATE_COMPLETED - Successfully fulfilled (terminal) */
|
|
23
|
-
|
|
26
|
+
State["CONTRACT_STATE_COMPLETED"] = "CONTRACT_STATE_COMPLETED";
|
|
24
27
|
/** CONTRACT_STATE_REJECTED - Counterparty declined (terminal) */
|
|
25
|
-
|
|
28
|
+
State["CONTRACT_STATE_REJECTED"] = "CONTRACT_STATE_REJECTED";
|
|
26
29
|
/** CONTRACT_STATE_DISPUTED - Under dispute resolution */
|
|
27
|
-
|
|
30
|
+
State["CONTRACT_STATE_DISPUTED"] = "CONTRACT_STATE_DISPUTED";
|
|
28
31
|
/** CONTRACT_STATE_CANCELLED - Cancelled by proposer before acceptance (terminal) */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})(
|
|
32
|
-
function
|
|
32
|
+
State["CONTRACT_STATE_CANCELLED"] = "CONTRACT_STATE_CANCELLED";
|
|
33
|
+
State["UNRECOGNIZED"] = "UNRECOGNIZED";
|
|
34
|
+
})(State || (exports.State = State = {}));
|
|
35
|
+
function stateFromJSON(object) {
|
|
33
36
|
switch (object) {
|
|
34
37
|
case 0:
|
|
35
38
|
case "CONTRACT_STATE_UNSPECIFIED":
|
|
36
|
-
return
|
|
39
|
+
return State.CONTRACT_STATE_UNSPECIFIED;
|
|
37
40
|
case 1:
|
|
38
41
|
case "CONTRACT_STATE_PROPOSED":
|
|
39
|
-
return
|
|
42
|
+
return State.CONTRACT_STATE_PROPOSED;
|
|
40
43
|
case 2:
|
|
41
44
|
case "CONTRACT_STATE_ACTIVE":
|
|
42
|
-
return
|
|
45
|
+
return State.CONTRACT_STATE_ACTIVE;
|
|
43
46
|
case 3:
|
|
44
47
|
case "CONTRACT_STATE_COMPLETED":
|
|
45
|
-
return
|
|
48
|
+
return State.CONTRACT_STATE_COMPLETED;
|
|
46
49
|
case 4:
|
|
47
50
|
case "CONTRACT_STATE_REJECTED":
|
|
48
|
-
return
|
|
51
|
+
return State.CONTRACT_STATE_REJECTED;
|
|
49
52
|
case 5:
|
|
50
53
|
case "CONTRACT_STATE_DISPUTED":
|
|
51
|
-
return
|
|
54
|
+
return State.CONTRACT_STATE_DISPUTED;
|
|
52
55
|
case 6:
|
|
53
56
|
case "CONTRACT_STATE_CANCELLED":
|
|
54
|
-
return
|
|
57
|
+
return State.CONTRACT_STATE_CANCELLED;
|
|
55
58
|
case -1:
|
|
56
59
|
case "UNRECOGNIZED":
|
|
57
60
|
default:
|
|
58
|
-
return
|
|
61
|
+
return State.UNRECOGNIZED;
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
|
|
62
|
-
function contractStateToJSON(object) {
|
|
64
|
+
function stateToJSON(object) {
|
|
63
65
|
switch (object) {
|
|
64
|
-
case
|
|
66
|
+
case State.CONTRACT_STATE_UNSPECIFIED:
|
|
65
67
|
return "CONTRACT_STATE_UNSPECIFIED";
|
|
66
|
-
case
|
|
68
|
+
case State.CONTRACT_STATE_PROPOSED:
|
|
67
69
|
return "CONTRACT_STATE_PROPOSED";
|
|
68
|
-
case
|
|
70
|
+
case State.CONTRACT_STATE_ACTIVE:
|
|
69
71
|
return "CONTRACT_STATE_ACTIVE";
|
|
70
|
-
case
|
|
72
|
+
case State.CONTRACT_STATE_COMPLETED:
|
|
71
73
|
return "CONTRACT_STATE_COMPLETED";
|
|
72
|
-
case
|
|
74
|
+
case State.CONTRACT_STATE_REJECTED:
|
|
73
75
|
return "CONTRACT_STATE_REJECTED";
|
|
74
|
-
case
|
|
76
|
+
case State.CONTRACT_STATE_DISPUTED:
|
|
75
77
|
return "CONTRACT_STATE_DISPUTED";
|
|
76
|
-
case
|
|
78
|
+
case State.CONTRACT_STATE_CANCELLED:
|
|
77
79
|
return "CONTRACT_STATE_CANCELLED";
|
|
78
|
-
case
|
|
80
|
+
case State.UNRECOGNIZED:
|
|
79
81
|
default:
|
|
80
82
|
return "UNRECOGNIZED";
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
|
-
|
|
84
|
-
function contractStateToNumber(object) {
|
|
85
|
+
function stateToNumber(object) {
|
|
85
86
|
switch (object) {
|
|
86
|
-
case
|
|
87
|
+
case State.CONTRACT_STATE_UNSPECIFIED:
|
|
87
88
|
return 0;
|
|
88
|
-
case
|
|
89
|
+
case State.CONTRACT_STATE_PROPOSED:
|
|
89
90
|
return 1;
|
|
90
|
-
case
|
|
91
|
+
case State.CONTRACT_STATE_ACTIVE:
|
|
91
92
|
return 2;
|
|
92
|
-
case
|
|
93
|
+
case State.CONTRACT_STATE_COMPLETED:
|
|
93
94
|
return 3;
|
|
94
|
-
case
|
|
95
|
+
case State.CONTRACT_STATE_REJECTED:
|
|
95
96
|
return 4;
|
|
96
|
-
case
|
|
97
|
+
case State.CONTRACT_STATE_DISPUTED:
|
|
97
98
|
return 5;
|
|
98
|
-
case
|
|
99
|
+
case State.CONTRACT_STATE_CANCELLED:
|
|
99
100
|
return 6;
|
|
100
|
-
case
|
|
101
|
+
case State.UNRECOGNIZED:
|
|
101
102
|
default:
|
|
102
103
|
return -1;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
exports.contractStateToNumber = contractStateToNumber;
|
|
106
106
|
function createBaseContract() {
|
|
107
107
|
return {
|
|
108
108
|
id: "",
|
|
109
109
|
contractId: "",
|
|
110
110
|
proposer: "",
|
|
111
111
|
counterparty: "",
|
|
112
|
-
state:
|
|
112
|
+
state: State.CONTRACT_STATE_UNSPECIFIED,
|
|
113
113
|
terms: undefined,
|
|
114
114
|
proposedAt: undefined,
|
|
115
115
|
acceptedAt: undefined,
|
|
@@ -131,8 +131,8 @@ exports.Contract = {
|
|
|
131
131
|
if (message.counterparty !== "") {
|
|
132
132
|
writer.uint32(34).string(message.counterparty);
|
|
133
133
|
}
|
|
134
|
-
if (message.state !==
|
|
135
|
-
writer.uint32(40).int32(
|
|
134
|
+
if (message.state !== State.CONTRACT_STATE_UNSPECIFIED) {
|
|
135
|
+
writer.uint32(40).int32(stateToNumber(message.state));
|
|
136
136
|
}
|
|
137
137
|
if (message.terms !== undefined) {
|
|
138
138
|
struct_js_1.Struct.encode(struct_js_1.Struct.wrap(message.terms), writer.uint32(50).fork()).join();
|
|
@@ -190,7 +190,7 @@ exports.Contract = {
|
|
|
190
190
|
if (tag !== 40) {
|
|
191
191
|
break;
|
|
192
192
|
}
|
|
193
|
-
message.state =
|
|
193
|
+
message.state = stateFromJSON(reader.int32());
|
|
194
194
|
continue;
|
|
195
195
|
}
|
|
196
196
|
case 6: {
|
|
@@ -246,7 +246,7 @@ exports.Contract = {
|
|
|
246
246
|
: "",
|
|
247
247
|
proposer: isSet(object.proposer) ? globalThis.String(object.proposer) : "",
|
|
248
248
|
counterparty: isSet(object.counterparty) ? globalThis.String(object.counterparty) : "",
|
|
249
|
-
state: isSet(object.state) ?
|
|
249
|
+
state: isSet(object.state) ? stateFromJSON(object.state) : State.CONTRACT_STATE_UNSPECIFIED,
|
|
250
250
|
terms: isObject(object.terms) ? object.terms : undefined,
|
|
251
251
|
proposedAt: isSet(object.proposedAt)
|
|
252
252
|
? fromJsonTimestamp(object.proposedAt)
|
|
@@ -284,8 +284,8 @@ exports.Contract = {
|
|
|
284
284
|
if (message.counterparty !== "") {
|
|
285
285
|
obj.counterparty = message.counterparty;
|
|
286
286
|
}
|
|
287
|
-
if (message.state !==
|
|
288
|
-
obj.state =
|
|
287
|
+
if (message.state !== State.CONTRACT_STATE_UNSPECIFIED) {
|
|
288
|
+
obj.state = stateToJSON(message.state);
|
|
289
289
|
}
|
|
290
290
|
if (message.terms !== undefined) {
|
|
291
291
|
obj.terms = message.terms;
|
|
@@ -313,7 +313,7 @@ exports.Contract = {
|
|
|
313
313
|
message.contractId = object.contractId ?? "";
|
|
314
314
|
message.proposer = object.proposer ?? "";
|
|
315
315
|
message.counterparty = object.counterparty ?? "";
|
|
316
|
-
message.state = object.state ??
|
|
316
|
+
message.state = object.state ?? State.CONTRACT_STATE_UNSPECIFIED;
|
|
317
317
|
message.terms = object.terms ?? undefined;
|
|
318
318
|
message.proposedAt = object.proposedAt ?? undefined;
|
|
319
319
|
message.acceptedAt = object.acceptedAt ?? undefined;
|