@ottochain/sdk 0.2.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/README.md +305 -0
- package/dist/apps/contracts/index.d.ts +21 -0
- package/dist/apps/contracts/index.js +39 -0
- package/dist/apps/contracts/types.d.ts +24 -0
- package/dist/apps/contracts/types.js +48 -0
- package/dist/apps/identity/index.d.ts +22 -0
- package/dist/apps/identity/index.js +40 -0
- package/dist/apps/identity/types.d.ts +30 -0
- package/dist/apps/identity/types.js +53 -0
- package/dist/apps/index.d.ts +29 -0
- package/dist/apps/index.js +60 -0
- package/dist/apps/markets/index.d.ts +26 -0
- package/dist/apps/markets/index.js +46 -0
- package/dist/apps/markets/types.d.ts +185 -0
- package/dist/apps/markets/types.js +252 -0
- package/dist/apps/oracles/index.d.ts +26 -0
- package/dist/apps/oracles/index.js +46 -0
- package/dist/apps/oracles/types.d.ts +211 -0
- package/dist/apps/oracles/types.js +306 -0
- package/dist/cjs/apps/contracts/index.js +60 -0
- package/dist/cjs/apps/contracts/state-machines/contract.json +420 -0
- package/dist/cjs/apps/contracts/state-machines/escrow.json +426 -0
- package/dist/cjs/apps/contracts/types.js +48 -0
- package/dist/cjs/apps/corporate/index.js +112 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-board.json +1064 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-bylaws.json +751 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-committee.json +957 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-compliance.json +1293 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-entity.json +861 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-officers.json +843 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-proxy.json +783 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-resolution.json +1174 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-securities.json +1215 -0
- package/dist/cjs/apps/corporate/state-machines/corporate-shareholders.json +1298 -0
- package/dist/cjs/apps/corporate/types.js +44 -0
- package/dist/cjs/apps/governance/index.js +203 -0
- package/dist/cjs/apps/governance/state-machines/dao-multisig.json +711 -0
- package/dist/cjs/apps/governance/state-machines/dao-single.json +258 -0
- package/dist/cjs/apps/governance/state-machines/dao-threshold.json +660 -0
- package/dist/cjs/apps/governance/state-machines/dao-token.json +680 -0
- package/dist/cjs/apps/governance/state-machines/governance-constitution.json +401 -0
- package/dist/cjs/apps/governance/state-machines/governance-executive.json +441 -0
- package/dist/cjs/apps/governance/state-machines/governance-judiciary.json +626 -0
- package/dist/cjs/apps/governance/state-machines/governance-legislature.json +726 -0
- package/dist/cjs/apps/governance/state-machines/governance-simple.json +679 -0
- package/dist/cjs/apps/governance/types.js +42 -0
- package/dist/cjs/apps/identity/constants.js +58 -0
- package/dist/cjs/apps/identity/index.js +78 -0
- package/dist/cjs/apps/identity/state-machines/agent-identity.json +320 -0
- package/dist/cjs/apps/identity/types.js +53 -0
- package/dist/cjs/apps/index.js +58 -0
- package/dist/cjs/apps/markets/index.js +55 -0
- package/dist/cjs/apps/markets/state-machines/market-universal.json +354 -0
- package/dist/cjs/apps/markets/types.js +219 -0
- package/dist/cjs/apps/oracles/index.js +62 -0
- package/dist/cjs/apps/oracles/state-machines/oracle.json +452 -0
- package/dist/cjs/apps/oracles/types.js +282 -0
- package/dist/cjs/errors.js +293 -0
- package/dist/cjs/generated/google/protobuf/struct.js +514 -0
- package/dist/cjs/generated/google/protobuf/timestamp.js +92 -0
- package/dist/cjs/generated/index.js +150 -0
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +873 -0
- package/dist/cjs/generated/ottochain/apps/contracts/v1/contract_pb.js +100 -0
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +4515 -0
- package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate_pb.js +392 -0
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +3255 -0
- package/dist/cjs/generated/ottochain/apps/governance/v1/governance_pb.js +235 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/agent.js +619 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/agent_pb.js +116 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +780 -0
- package/dist/cjs/generated/ottochain/apps/identity/v1/attestation_pb.js +79 -0
- package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +1261 -0
- package/dist/cjs/generated/ottochain/apps/markets/v1/market_pb.js +151 -0
- package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle.js +1223 -0
- package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle_pb.js +109 -0
- package/dist/cjs/generated/ottochain/v1/common.js +10 -0
- package/dist/cjs/generated/ottochain/v1/common_pb.js +37 -0
- package/dist/cjs/generated/ottochain/v1/fiber.js +1057 -0
- package/dist/cjs/generated/ottochain/v1/fiber_pb.js +86 -0
- package/dist/cjs/generated/ottochain/v1/messages.js +740 -0
- package/dist/cjs/generated/ottochain/v1/messages_pb.js +44 -0
- package/dist/cjs/generated/ottochain/v1/records.js +1253 -0
- package/dist/cjs/generated/ottochain/v1/records_pb.js +44 -0
- package/dist/cjs/index.js +79 -0
- package/dist/cjs/metakit/binary.js +58 -0
- package/dist/cjs/metakit/canonicalize.js +40 -0
- package/dist/cjs/metakit/codec.js +45 -0
- package/dist/cjs/metakit/currency-transaction.js +319 -0
- package/dist/cjs/metakit/currency-types.js +13 -0
- package/dist/cjs/metakit/hash.js +84 -0
- package/dist/cjs/metakit/index.js +74 -0
- package/dist/cjs/metakit/network/client.js +78 -0
- package/dist/cjs/metakit/network/currency-l1-client.js +101 -0
- package/dist/cjs/metakit/network/data-l1-client.js +76 -0
- package/dist/cjs/metakit/network/index.js +16 -0
- package/dist/cjs/metakit/network/types.js +20 -0
- package/dist/cjs/metakit/sign.js +120 -0
- package/dist/cjs/metakit/signed-object.js +100 -0
- package/dist/cjs/metakit/types.js +14 -0
- package/dist/cjs/metakit/verify.js +217 -0
- package/dist/cjs/metakit/wallet.js +127 -0
- package/dist/cjs/ottochain/index.js +47 -0
- package/dist/cjs/ottochain/metagraph-client.js +157 -0
- package/dist/cjs/ottochain/snapshot.js +110 -0
- package/dist/cjs/ottochain/types.js +11 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.js +25 -0
- package/dist/cjs/validation.js +312 -0
- package/dist/errors.d.ts +221 -0
- package/dist/errors.js +293 -0
- package/dist/esm/apps/contracts/index.js +42 -0
- package/dist/esm/apps/contracts/state-machines/contract.json +420 -0
- package/dist/esm/apps/contracts/state-machines/escrow.json +426 -0
- package/dist/esm/apps/contracts/types.js +44 -0
- package/dist/esm/apps/corporate/index.js +57 -0
- package/dist/esm/apps/corporate/state-machines/corporate-board.json +1064 -0
- package/dist/esm/apps/corporate/state-machines/corporate-bylaws.json +751 -0
- package/dist/esm/apps/corporate/state-machines/corporate-committee.json +957 -0
- package/dist/esm/apps/corporate/state-machines/corporate-compliance.json +1293 -0
- package/dist/esm/apps/corporate/state-machines/corporate-entity.json +861 -0
- package/dist/esm/apps/corporate/state-machines/corporate-officers.json +843 -0
- package/dist/esm/apps/corporate/state-machines/corporate-proxy.json +783 -0
- package/dist/esm/apps/corporate/state-machines/corporate-resolution.json +1174 -0
- package/dist/esm/apps/corporate/state-machines/corporate-securities.json +1215 -0
- package/dist/esm/apps/corporate/state-machines/corporate-shareholders.json +1298 -0
- package/dist/esm/apps/corporate/types.js +38 -0
- package/dist/esm/apps/governance/index.js +154 -0
- package/dist/esm/apps/governance/state-machines/dao-multisig.json +711 -0
- package/dist/esm/apps/governance/state-machines/dao-single.json +258 -0
- package/dist/esm/apps/governance/state-machines/dao-threshold.json +660 -0
- package/dist/esm/apps/governance/state-machines/dao-token.json +680 -0
- package/dist/esm/apps/governance/state-machines/governance-constitution.json +401 -0
- package/dist/esm/apps/governance/state-machines/governance-executive.json +441 -0
- package/dist/esm/apps/governance/state-machines/governance-judiciary.json +626 -0
- package/dist/esm/apps/governance/state-machines/governance-legislature.json +726 -0
- package/dist/esm/apps/governance/state-machines/governance-simple.json +679 -0
- package/dist/esm/apps/governance/types.js +35 -0
- package/dist/esm/apps/identity/constants.js +53 -0
- package/dist/esm/apps/identity/index.js +50 -0
- package/dist/esm/apps/identity/state-machines/agent-identity.json +320 -0
- package/dist/esm/apps/identity/types.js +50 -0
- package/dist/esm/apps/index.js +32 -0
- package/dist/esm/apps/markets/index.js +34 -0
- package/dist/esm/apps/markets/state-machines/market-universal.json +354 -0
- package/dist/esm/apps/markets/types.js +206 -0
- package/dist/esm/apps/oracles/index.js +42 -0
- package/dist/esm/apps/oracles/state-machines/oracle.json +452 -0
- package/dist/esm/apps/oracles/types.js +267 -0
- package/dist/esm/errors.js +283 -0
- package/dist/esm/generated/google/protobuf/struct.js +508 -0
- package/dist/esm/generated/google/protobuf/timestamp.js +89 -0
- package/dist/esm/generated/index.js +26 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +867 -0
- package/dist/esm/generated/ottochain/apps/contracts/v1/contract_pb.js +97 -0
- package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +4493 -0
- package/dist/esm/generated/ottochain/apps/corporate/v1/corporate_pb.js +389 -0
- package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +3240 -0
- package/dist/esm/generated/ottochain/apps/governance/v1/governance_pb.js +232 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +610 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/agent_pb.js +113 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +774 -0
- package/dist/esm/generated/ottochain/apps/identity/v1/attestation_pb.js +76 -0
- package/dist/esm/generated/ottochain/apps/markets/v1/market.js +1252 -0
- package/dist/esm/generated/ottochain/apps/markets/v1/market_pb.js +148 -0
- package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +1217 -0
- package/dist/esm/generated/ottochain/apps/oracles/v1/oracle_pb.js +106 -0
- package/dist/esm/generated/ottochain/v1/common.js +7 -0
- package/dist/esm/generated/ottochain/v1/common_pb.js +34 -0
- package/dist/esm/generated/ottochain/v1/fiber.js +1051 -0
- package/dist/esm/generated/ottochain/v1/fiber_pb.js +83 -0
- package/dist/esm/generated/ottochain/v1/messages.js +737 -0
- package/dist/esm/generated/ottochain/v1/messages_pb.js +41 -0
- package/dist/esm/generated/ottochain/v1/records.js +1250 -0
- package/dist/esm/generated/ottochain/v1/records_pb.js +41 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/metakit/binary.js +53 -0
- package/dist/esm/metakit/canonicalize.js +33 -0
- package/dist/esm/metakit/codec.js +38 -0
- package/dist/esm/metakit/currency-transaction.js +306 -0
- package/dist/esm/metakit/currency-types.js +10 -0
- package/dist/esm/metakit/hash.js +77 -0
- package/dist/esm/metakit/index.js +30 -0
- package/dist/esm/metakit/network/client.js +74 -0
- package/dist/esm/metakit/network/currency-l1-client.js +97 -0
- package/dist/esm/metakit/network/data-l1-client.js +72 -0
- package/dist/esm/metakit/network/index.js +9 -0
- package/dist/esm/metakit/network/types.js +16 -0
- package/dist/esm/metakit/sign.js +114 -0
- package/dist/esm/metakit/signed-object.js +94 -0
- package/dist/esm/metakit/types.js +11 -0
- package/dist/esm/metakit/verify.js +210 -0
- package/dist/esm/metakit/wallet.js +117 -0
- package/dist/esm/ottochain/index.js +13 -0
- package/dist/esm/ottochain/metagraph-client.js +153 -0
- package/dist/esm/ottochain/snapshot.js +100 -0
- package/dist/esm/ottochain/types.js +10 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.js +20 -0
- package/dist/esm/validation.js +301 -0
- package/dist/generated/index.d.ts +15 -0
- package/dist/generated/index.js +34 -0
- package/dist/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +274 -0
- package/dist/generated/ottochain/apps/contracts/v1/contract_pb.js +100 -0
- package/dist/generated/ottochain/apps/identity/v1/agent_pb.d.ts +211 -0
- package/dist/generated/ottochain/apps/identity/v1/agent_pb.js +116 -0
- package/dist/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +238 -0
- package/dist/generated/ottochain/apps/identity/v1/attestation_pb.js +79 -0
- package/dist/generated/ottochain/apps/markets/v1/market_pb.d.ts +436 -0
- package/dist/generated/ottochain/apps/markets/v1/market_pb.js +151 -0
- package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +393 -0
- package/dist/generated/ottochain/apps/oracles/v1/oracle_pb.js +109 -0
- package/dist/generated/ottochain/v1/common_pb.d.ts +86 -0
- package/dist/generated/ottochain/v1/common_pb.js +37 -0
- package/dist/generated/ottochain/v1/fiber_pb.d.ts +292 -0
- package/dist/generated/ottochain/v1/fiber_pb.js +86 -0
- package/dist/generated/ottochain/v1/messages_pb.d.ts +190 -0
- package/dist/generated/ottochain/v1/messages_pb.js +44 -0
- package/dist/generated/ottochain/v1/records_pb.d.ts +221 -0
- package/dist/generated/ottochain/v1/records_pb.js +44 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +77 -0
- package/dist/metakit/binary.d.ts +38 -0
- package/dist/metakit/binary.js +58 -0
- package/dist/metakit/canonicalize.d.ts +26 -0
- package/dist/metakit/canonicalize.js +40 -0
- package/dist/metakit/codec.d.ts +16 -0
- package/dist/metakit/codec.js +45 -0
- package/dist/metakit/currency-transaction.d.ts +157 -0
- package/dist/metakit/currency-transaction.js +319 -0
- package/dist/metakit/currency-types.d.ts +55 -0
- package/dist/metakit/currency-types.js +13 -0
- package/dist/metakit/hash.d.ts +50 -0
- package/dist/metakit/hash.js +84 -0
- package/dist/metakit/index.d.ts +23 -0
- package/dist/metakit/index.js +74 -0
- package/dist/metakit/network/client.d.ts +23 -0
- package/dist/metakit/network/client.js +78 -0
- package/dist/metakit/network/currency-l1-client.d.ts +71 -0
- package/dist/metakit/network/currency-l1-client.js +101 -0
- package/dist/metakit/network/data-l1-client.d.ts +57 -0
- package/dist/metakit/network/data-l1-client.js +76 -0
- package/dist/metakit/network/index.d.ts +10 -0
- package/dist/metakit/network/index.js +16 -0
- package/dist/metakit/network/types.d.ts +74 -0
- package/dist/metakit/network/types.js +20 -0
- package/dist/metakit/sign.d.ts +65 -0
- package/dist/metakit/sign.js +120 -0
- package/dist/metakit/signed-object.d.ts +66 -0
- package/dist/metakit/signed-object.js +100 -0
- package/dist/metakit/types.d.ts +67 -0
- package/dist/metakit/types.js +14 -0
- package/dist/metakit/verify.d.ts +55 -0
- package/dist/metakit/verify.js +217 -0
- package/dist/metakit/wallet.d.ts +70 -0
- package/dist/metakit/wallet.js +127 -0
- package/dist/ottochain/index.d.ts +13 -0
- package/dist/ottochain/index.js +45 -0
- package/dist/ottochain/metagraph-client.d.ts +111 -0
- package/dist/ottochain/metagraph-client.js +157 -0
- package/dist/ottochain/snapshot.d.ts +86 -0
- package/dist/ottochain/snapshot.js +110 -0
- package/dist/ottochain/types.d.ts +278 -0
- package/dist/ottochain/types.js +11 -0
- package/dist/types/apps/contracts/index.d.ts +30 -0
- package/dist/types/apps/contracts/types.d.ts +24 -0
- package/dist/types/apps/corporate/index.d.ts +27 -0
- package/dist/types/apps/corporate/types.d.ts +9861 -0
- package/dist/types/apps/governance/index.d.ts +77 -0
- package/dist/types/apps/governance/types.d.ts +344 -0
- package/dist/types/apps/identity/constants.d.ts +27 -0
- package/dist/types/apps/identity/index.d.ts +39 -0
- package/dist/types/apps/identity/types.d.ts +30 -0
- package/dist/types/apps/index.d.ts +31 -0
- package/dist/types/apps/markets/index.d.ts +26 -0
- package/dist/types/apps/markets/types.d.ts +155 -0
- package/dist/types/apps/oracles/index.d.ts +34 -0
- package/dist/types/apps/oracles/types.d.ts +193 -0
- package/dist/types/errors.d.ts +221 -0
- package/dist/types/generated/google/protobuf/struct.d.ts +134 -0
- package/dist/types/generated/google/protobuf/timestamp.d.ts +134 -0
- package/dist/types/generated/index.d.ts +18 -0
- package/dist/types/generated/ottochain/apps/contracts/v1/contract.d.ts +112 -0
- package/dist/types/generated/ottochain/apps/contracts/v1/contract_pb.d.ts +274 -0
- package/dist/types/generated/ottochain/apps/corporate/v1/corporate.d.ts +376 -0
- package/dist/types/generated/ottochain/apps/corporate/v1/corporate_pb.d.ts +1172 -0
- package/dist/types/generated/ottochain/apps/governance/v1/governance.d.ts +296 -0
- package/dist/types/generated/ottochain/apps/governance/v1/governance_pb.d.ts +772 -0
- package/dist/types/generated/ottochain/apps/identity/v1/agent.d.ts +94 -0
- package/dist/types/generated/ottochain/apps/identity/v1/agent_pb.d.ts +211 -0
- package/dist/types/generated/ottochain/apps/identity/v1/attestation.d.ts +102 -0
- package/dist/types/generated/ottochain/apps/identity/v1/attestation_pb.d.ts +238 -0
- package/dist/types/generated/ottochain/apps/markets/v1/market.d.ts +174 -0
- package/dist/types/generated/ottochain/apps/markets/v1/market_pb.d.ts +436 -0
- package/dist/types/generated/ottochain/apps/oracles/v1/oracle.d.ts +150 -0
- package/dist/types/generated/ottochain/apps/oracles/v1/oracle_pb.d.ts +393 -0
- package/dist/types/generated/ottochain/v1/common.d.ts +1 -0
- package/dist/types/generated/ottochain/v1/common_pb.d.ts +86 -0
- package/dist/types/generated/ottochain/v1/fiber.d.ts +130 -0
- package/dist/types/generated/ottochain/v1/fiber_pb.d.ts +292 -0
- package/dist/types/generated/ottochain/v1/messages.d.ts +89 -0
- package/dist/types/generated/ottochain/v1/messages_pb.d.ts +190 -0
- package/dist/types/generated/ottochain/v1/records.d.ts +128 -0
- package/dist/types/generated/ottochain/v1/records_pb.d.ts +221 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/metakit/binary.d.ts +38 -0
- package/dist/types/metakit/canonicalize.d.ts +26 -0
- package/dist/types/metakit/codec.d.ts +16 -0
- package/dist/types/metakit/currency-transaction.d.ts +157 -0
- package/dist/types/metakit/currency-types.d.ts +55 -0
- package/dist/types/metakit/hash.d.ts +50 -0
- package/dist/types/metakit/index.d.ts +23 -0
- package/dist/types/metakit/network/client.d.ts +23 -0
- package/dist/types/metakit/network/currency-l1-client.d.ts +71 -0
- package/dist/types/metakit/network/data-l1-client.d.ts +57 -0
- package/dist/types/metakit/network/index.d.ts +10 -0
- package/dist/types/metakit/network/types.d.ts +74 -0
- package/dist/types/metakit/sign.d.ts +65 -0
- package/dist/types/metakit/signed-object.d.ts +66 -0
- package/dist/types/metakit/types.d.ts +67 -0
- package/dist/types/metakit/verify.d.ts +55 -0
- package/dist/types/metakit/wallet.d.ts +70 -0
- package/dist/types/ottochain/index.d.ts +13 -0
- package/dist/types/ottochain/metagraph-client.d.ts +111 -0
- package/dist/types/ottochain/snapshot.d.ts +86 -0
- package/dist/types/ottochain/types.d.ts +210 -0
- package/dist/types/types.d.ts +51 -0
- package/dist/types/validation.d.ts +449 -0
- package/dist/validation.d.ts +449 -0
- package/dist/validation.js +312 -0
- package/package.json +136 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Validation with Zod Schemas
|
|
3
|
+
*
|
|
4
|
+
* Provides runtime validation for SDK types using Zod.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { ValidationError } from './errors.js';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Primitive Schemas
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Schema for a hex string of specific length
|
|
15
|
+
*/
|
|
16
|
+
const hexString = (length) => {
|
|
17
|
+
let schema = z.string().regex(/^[0-9a-fA-F]+$/, 'Must be a valid hex string');
|
|
18
|
+
if (length !== undefined) {
|
|
19
|
+
schema = schema.length(length, `Must be exactly ${length} characters`);
|
|
20
|
+
}
|
|
21
|
+
return schema;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Schema for a DAG address
|
|
25
|
+
*/
|
|
26
|
+
export const DagAddressSchema = z
|
|
27
|
+
.string()
|
|
28
|
+
.regex(/^DAG[0-9][a-zA-Z0-9]{36}$/, 'Must be a valid DAG address');
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Core Type Schemas
|
|
31
|
+
// ============================================================================
|
|
32
|
+
/**
|
|
33
|
+
* Schema for a private key (64-character hex string)
|
|
34
|
+
*/
|
|
35
|
+
export const PrivateKeySchema = hexString(64).describe('Private key in hex format (64 characters)');
|
|
36
|
+
/**
|
|
37
|
+
* Schema for a public key (128 or 130 character hex string)
|
|
38
|
+
*/
|
|
39
|
+
export const PublicKeySchema = z
|
|
40
|
+
.string()
|
|
41
|
+
.regex(/^(04)?[0-9a-fA-F]{128}$/, 'Must be a valid public key (128 or 130 hex chars)')
|
|
42
|
+
.describe('Public key in hex format (with optional 04 prefix)');
|
|
43
|
+
/**
|
|
44
|
+
* Schema for a KeyPair
|
|
45
|
+
*/
|
|
46
|
+
export const KeyPairSchema = z.object({
|
|
47
|
+
/** Private key in hex format */
|
|
48
|
+
privateKey: PrivateKeySchema,
|
|
49
|
+
/** Public key in hex format (uncompressed, with 04 prefix) */
|
|
50
|
+
publicKey: PublicKeySchema,
|
|
51
|
+
/** DAG address derived from the public key */
|
|
52
|
+
address: DagAddressSchema,
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Schema for a SignatureProof
|
|
56
|
+
*/
|
|
57
|
+
export const SignatureProofSchema = z.object({
|
|
58
|
+
/** Public key hex (uncompressed, without 04 prefix) - 128 characters */
|
|
59
|
+
id: hexString(128),
|
|
60
|
+
/** DER-encoded ECDSA signature in hex format */
|
|
61
|
+
signature: hexString(),
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Schema for a Signed object (generic)
|
|
65
|
+
*/
|
|
66
|
+
export const SignedSchema = (valueSchema) => z.object({
|
|
67
|
+
value: valueSchema,
|
|
68
|
+
proofs: z.array(SignatureProofSchema).min(1, 'At least one proof is required'),
|
|
69
|
+
});
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// Transaction Schemas
|
|
72
|
+
// ============================================================================
|
|
73
|
+
/**
|
|
74
|
+
* Schema for TransactionReference
|
|
75
|
+
*/
|
|
76
|
+
export const TransactionReferenceSchema = z.object({
|
|
77
|
+
ordinal: z.number().int().min(0),
|
|
78
|
+
hash: z.string().min(1),
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Schema for CurrencyTransactionValue
|
|
82
|
+
*/
|
|
83
|
+
export const CurrencyTransactionValueSchema = z.object({
|
|
84
|
+
source: DagAddressSchema,
|
|
85
|
+
destination: DagAddressSchema,
|
|
86
|
+
amount: z.number().int().positive('Amount must be positive'),
|
|
87
|
+
fee: z.number().int().min(0).default(0),
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Schema for CurrencyTransaction
|
|
91
|
+
*/
|
|
92
|
+
export const CurrencyTransactionSchema = z.object({
|
|
93
|
+
value: CurrencyTransactionValueSchema,
|
|
94
|
+
parent: TransactionReferenceSchema,
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Schema for TransferParams
|
|
98
|
+
*/
|
|
99
|
+
export const TransferParamsSchema = z.object({
|
|
100
|
+
from: DagAddressSchema,
|
|
101
|
+
to: DagAddressSchema,
|
|
102
|
+
amount: z.number().positive('Amount must be positive'),
|
|
103
|
+
fee: z.number().min(0).optional().default(0),
|
|
104
|
+
});
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// Identity Schemas
|
|
107
|
+
// ============================================================================
|
|
108
|
+
/**
|
|
109
|
+
* Schema for AgentIdentity registration
|
|
110
|
+
*/
|
|
111
|
+
export const AgentIdentityRegistrationSchema = z.object({
|
|
112
|
+
/** Public key in hex format */
|
|
113
|
+
publicKey: PublicKeySchema,
|
|
114
|
+
/** Display name for the agent */
|
|
115
|
+
displayName: z.string().min(1).max(64),
|
|
116
|
+
/** Initial reputation (default: 10) */
|
|
117
|
+
reputation: z.number().int().min(0).optional().default(10),
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* Schema for PlatformLink
|
|
121
|
+
*/
|
|
122
|
+
export const PlatformLinkSchema = z.object({
|
|
123
|
+
platform: z.enum(['DISCORD', 'TELEGRAM', 'TWITTER', 'GITHUB', 'CUSTOM']),
|
|
124
|
+
platformUserId: z.string().min(1),
|
|
125
|
+
platformUsername: z.string().min(1),
|
|
126
|
+
verified: z.boolean().optional().default(false),
|
|
127
|
+
});
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// Contract Schemas
|
|
130
|
+
// ============================================================================
|
|
131
|
+
/**
|
|
132
|
+
* Schema for contract terms (flexible structure)
|
|
133
|
+
*/
|
|
134
|
+
export const ContractTermsSchema = z.record(z.unknown());
|
|
135
|
+
/**
|
|
136
|
+
* Schema for ProposeContractRequest
|
|
137
|
+
*/
|
|
138
|
+
export const ProposeContractRequestSchema = z.object({
|
|
139
|
+
/** Proposer's DAG address */
|
|
140
|
+
proposer: DagAddressSchema,
|
|
141
|
+
/** Counterparty's DAG address */
|
|
142
|
+
counterparty: DagAddressSchema,
|
|
143
|
+
/** Contract terms */
|
|
144
|
+
terms: ContractTermsSchema,
|
|
145
|
+
/** Human-readable description */
|
|
146
|
+
description: z.string().min(1).max(1000),
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* Schema for AcceptContractRequest
|
|
150
|
+
*/
|
|
151
|
+
export const AcceptContractRequestSchema = z.object({
|
|
152
|
+
/** Contract ID to accept */
|
|
153
|
+
contractId: z.string().min(1),
|
|
154
|
+
/** Acceptor's DAG address */
|
|
155
|
+
acceptor: DagAddressSchema,
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* Schema for CompleteContractRequest
|
|
159
|
+
*/
|
|
160
|
+
export const CompleteContractRequestSchema = z.object({
|
|
161
|
+
/** Contract ID to complete */
|
|
162
|
+
contractId: z.string().min(1),
|
|
163
|
+
/** Completer's DAG address */
|
|
164
|
+
completer: DagAddressSchema,
|
|
165
|
+
/** Proof of completion */
|
|
166
|
+
proof: z.string().min(1),
|
|
167
|
+
});
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// Validation Helpers
|
|
170
|
+
// ============================================================================
|
|
171
|
+
/**
|
|
172
|
+
* Validate data against a Zod schema
|
|
173
|
+
*
|
|
174
|
+
* @param schema - Zod schema to validate against
|
|
175
|
+
* @param data - Data to validate
|
|
176
|
+
* @param fieldName - Optional field name for error context
|
|
177
|
+
* @returns Validated and typed data
|
|
178
|
+
* @throws {ValidationError} If validation fails
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const keyPair = validate(KeyPairSchema, inputData, 'keyPair');
|
|
183
|
+
* // keyPair is now typed as ValidatedKeyPair
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export function validate(schema, data, fieldName) {
|
|
187
|
+
const result = schema.safeParse(data);
|
|
188
|
+
if (!result.success) {
|
|
189
|
+
const issues = result.error.issues;
|
|
190
|
+
const firstIssue = issues[0];
|
|
191
|
+
// Build a helpful error message
|
|
192
|
+
const path = firstIssue.path.length > 0 ? firstIssue.path.join('.') : fieldName || 'input';
|
|
193
|
+
const message = `Validation failed for '${path}': ${firstIssue.message}`;
|
|
194
|
+
throw new ValidationError(message, {
|
|
195
|
+
field: path,
|
|
196
|
+
value: data,
|
|
197
|
+
details: {
|
|
198
|
+
issues: issues.map((issue) => ({
|
|
199
|
+
path: issue.path.join('.'),
|
|
200
|
+
message: issue.message,
|
|
201
|
+
code: issue.code,
|
|
202
|
+
})),
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return result.data;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Validate a private key
|
|
210
|
+
*
|
|
211
|
+
* @param privateKey - Private key to validate
|
|
212
|
+
* @returns Validated private key
|
|
213
|
+
* @throws {ValidationError} If validation fails
|
|
214
|
+
*/
|
|
215
|
+
export function validatePrivateKey(privateKey) {
|
|
216
|
+
return validate(PrivateKeySchema, privateKey, 'privateKey');
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Validate a public key
|
|
220
|
+
*
|
|
221
|
+
* @param publicKey - Public key to validate
|
|
222
|
+
* @returns Validated public key
|
|
223
|
+
* @throws {ValidationError} If validation fails
|
|
224
|
+
*/
|
|
225
|
+
export function validatePublicKey(publicKey) {
|
|
226
|
+
return validate(PublicKeySchema, publicKey, 'publicKey');
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Validate a DAG address
|
|
230
|
+
*
|
|
231
|
+
* @param address - Address to validate
|
|
232
|
+
* @returns Validated address
|
|
233
|
+
* @throws {ValidationError} If validation fails
|
|
234
|
+
*/
|
|
235
|
+
export function validateAddress(address) {
|
|
236
|
+
return validate(DagAddressSchema, address, 'address');
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate a KeyPair
|
|
240
|
+
*
|
|
241
|
+
* @param keyPair - KeyPair to validate
|
|
242
|
+
* @returns Validated KeyPair
|
|
243
|
+
* @throws {ValidationError} If validation fails
|
|
244
|
+
*/
|
|
245
|
+
export function validateKeyPair(keyPair) {
|
|
246
|
+
return validate(KeyPairSchema, keyPair, 'keyPair');
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Safe validation that returns a result object instead of throwing
|
|
250
|
+
*
|
|
251
|
+
* @param schema - Zod schema to validate against
|
|
252
|
+
* @param data - Data to validate
|
|
253
|
+
* @returns Object with success status and data or error
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const result = safeParse(KeyPairSchema, inputData);
|
|
258
|
+
* if (result.success) {
|
|
259
|
+
* console.log(result.data.address);
|
|
260
|
+
* } else {
|
|
261
|
+
* console.log(result.error.message);
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export function safeParse(schema, data) {
|
|
266
|
+
const result = schema.safeParse(data);
|
|
267
|
+
if (result.success) {
|
|
268
|
+
return { success: true, data: result.data };
|
|
269
|
+
}
|
|
270
|
+
const issues = result.error.issues;
|
|
271
|
+
const firstIssue = issues[0];
|
|
272
|
+
const path = firstIssue.path.length > 0 ? firstIssue.path.join('.') : 'input';
|
|
273
|
+
const message = `Validation failed for '${path}': ${firstIssue.message}`;
|
|
274
|
+
return {
|
|
275
|
+
success: false,
|
|
276
|
+
error: new ValidationError(message, {
|
|
277
|
+
field: path,
|
|
278
|
+
value: data,
|
|
279
|
+
details: {
|
|
280
|
+
issues: issues.map((issue) => ({
|
|
281
|
+
path: issue.path.join('.'),
|
|
282
|
+
message: issue.message,
|
|
283
|
+
code: issue.code,
|
|
284
|
+
})),
|
|
285
|
+
},
|
|
286
|
+
}),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Assert that a condition is true, throwing ValidationError if not
|
|
291
|
+
*
|
|
292
|
+
* @param condition - Condition to check
|
|
293
|
+
* @param message - Error message if condition is false
|
|
294
|
+
* @param field - Optional field name for context
|
|
295
|
+
* @throws {ValidationError} If condition is false
|
|
296
|
+
*/
|
|
297
|
+
export function assert(condition, message, field) {
|
|
298
|
+
if (!condition) {
|
|
299
|
+
throw new ValidationError(message, { field });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated Protobuf Types
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated from proto/ definitions.
|
|
5
|
+
* DO NOT EDIT - regenerate with `npm run generate`
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export * from './ottochain/v1/common_pb.js';
|
|
10
|
+
export * from './ottochain/v1/fiber_pb.js';
|
|
11
|
+
export * from './ottochain/v1/messages_pb.js';
|
|
12
|
+
export * from './ottochain/v1/records_pb.js';
|
|
13
|
+
export * from './ottochain/apps/identity/v1/agent_pb.js';
|
|
14
|
+
export * from './ottochain/apps/identity/v1/attestation_pb.js';
|
|
15
|
+
export * from './ottochain/apps/contracts/v1/contract_pb.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generated Protobuf Types
|
|
4
|
+
*
|
|
5
|
+
* Auto-generated from proto/ definitions.
|
|
6
|
+
* DO NOT EDIT - regenerate with `npm run generate`
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
// Core types
|
|
26
|
+
__exportStar(require("./ottochain/v1/common_pb.js"), exports);
|
|
27
|
+
__exportStar(require("./ottochain/v1/fiber_pb.js"), exports);
|
|
28
|
+
__exportStar(require("./ottochain/v1/messages_pb.js"), exports);
|
|
29
|
+
__exportStar(require("./ottochain/v1/records_pb.js"), exports);
|
|
30
|
+
// App: Identity
|
|
31
|
+
__exportStar(require("./ottochain/apps/identity/v1/agent_pb.js"), exports);
|
|
32
|
+
__exportStar(require("./ottochain/apps/identity/v1/attestation_pb.js"), exports);
|
|
33
|
+
// App: Contracts
|
|
34
|
+
__exportStar(require("./ottochain/apps/contracts/v1/contract_pb.js"), exports);
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
|
|
2
|
+
import type { Address } from "../../../v1/common_pb.js";
|
|
3
|
+
import type { Timestamp } from "@bufbuild/protobuf/wkt";
|
|
4
|
+
import type { JsonObject, Message } from "@bufbuild/protobuf";
|
|
5
|
+
/**
|
|
6
|
+
* Describes the file ottochain/apps/contracts/v1/contract.proto.
|
|
7
|
+
*/
|
|
8
|
+
export declare const file_ottochain_apps_contracts_v1_contract: GenFile;
|
|
9
|
+
/**
|
|
10
|
+
* Contract between two agents
|
|
11
|
+
*
|
|
12
|
+
* @generated from message ottochain.apps.contracts.v1.Contract
|
|
13
|
+
*/
|
|
14
|
+
export type Contract = Message<"ottochain.apps.contracts.v1.Contract"> & {
|
|
15
|
+
/**
|
|
16
|
+
* @generated from field: string id = 1;
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Human-readable ID
|
|
21
|
+
*
|
|
22
|
+
* @generated from field: string contract_id = 2;
|
|
23
|
+
*/
|
|
24
|
+
contractId: string;
|
|
25
|
+
/**
|
|
26
|
+
* @generated from field: ottochain.v1.Address proposer = 3;
|
|
27
|
+
*/
|
|
28
|
+
proposer?: Address;
|
|
29
|
+
/**
|
|
30
|
+
* @generated from field: ottochain.v1.Address counterparty = 4;
|
|
31
|
+
*/
|
|
32
|
+
counterparty?: Address;
|
|
33
|
+
/**
|
|
34
|
+
* @generated from field: ottochain.apps.contracts.v1.ContractState state = 5;
|
|
35
|
+
*/
|
|
36
|
+
state: ContractState;
|
|
37
|
+
/**
|
|
38
|
+
* Flexible terms structure
|
|
39
|
+
*
|
|
40
|
+
* @generated from field: google.protobuf.Struct terms = 6;
|
|
41
|
+
*/
|
|
42
|
+
terms?: JsonObject;
|
|
43
|
+
/**
|
|
44
|
+
* @generated from field: google.protobuf.Timestamp proposed_at = 7;
|
|
45
|
+
*/
|
|
46
|
+
proposedAt?: Timestamp;
|
|
47
|
+
/**
|
|
48
|
+
* @generated from field: google.protobuf.Timestamp accepted_at = 8;
|
|
49
|
+
*/
|
|
50
|
+
acceptedAt?: Timestamp;
|
|
51
|
+
/**
|
|
52
|
+
* @generated from field: google.protobuf.Timestamp completed_at = 9;
|
|
53
|
+
*/
|
|
54
|
+
completedAt?: Timestamp;
|
|
55
|
+
/**
|
|
56
|
+
* Evidence of completion
|
|
57
|
+
*
|
|
58
|
+
* @generated from field: string completion_proof = 10;
|
|
59
|
+
*/
|
|
60
|
+
completionProof: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Describes the message ottochain.apps.contracts.v1.Contract.
|
|
64
|
+
* Use `create(ContractSchema)` to create a new message.
|
|
65
|
+
*/
|
|
66
|
+
export declare const ContractSchema: GenMessage<Contract>;
|
|
67
|
+
/**
|
|
68
|
+
* Propose a new contract
|
|
69
|
+
*
|
|
70
|
+
* @generated from message ottochain.apps.contracts.v1.ProposeContractRequest
|
|
71
|
+
*/
|
|
72
|
+
export type ProposeContractRequest = Message<"ottochain.apps.contracts.v1.ProposeContractRequest"> & {
|
|
73
|
+
/**
|
|
74
|
+
* @generated from field: ottochain.v1.Address proposer = 1;
|
|
75
|
+
*/
|
|
76
|
+
proposer?: Address;
|
|
77
|
+
/**
|
|
78
|
+
* @generated from field: ottochain.v1.Address counterparty = 2;
|
|
79
|
+
*/
|
|
80
|
+
counterparty?: Address;
|
|
81
|
+
/**
|
|
82
|
+
* @generated from field: google.protobuf.Struct terms = 3;
|
|
83
|
+
*/
|
|
84
|
+
terms?: JsonObject;
|
|
85
|
+
/**
|
|
86
|
+
* @generated from field: string description = 4;
|
|
87
|
+
*/
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Describes the message ottochain.apps.contracts.v1.ProposeContractRequest.
|
|
92
|
+
* Use `create(ProposeContractRequestSchema)` to create a new message.
|
|
93
|
+
*/
|
|
94
|
+
export declare const ProposeContractRequestSchema: GenMessage<ProposeContractRequest>;
|
|
95
|
+
/**
|
|
96
|
+
* Accept a proposed contract
|
|
97
|
+
*
|
|
98
|
+
* @generated from message ottochain.apps.contracts.v1.AcceptContractRequest
|
|
99
|
+
*/
|
|
100
|
+
export type AcceptContractRequest = Message<"ottochain.apps.contracts.v1.AcceptContractRequest"> & {
|
|
101
|
+
/**
|
|
102
|
+
* @generated from field: string contract_id = 1;
|
|
103
|
+
*/
|
|
104
|
+
contractId: string;
|
|
105
|
+
/**
|
|
106
|
+
* @generated from field: ottochain.v1.Address acceptor = 2;
|
|
107
|
+
*/
|
|
108
|
+
acceptor?: Address;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Describes the message ottochain.apps.contracts.v1.AcceptContractRequest.
|
|
112
|
+
* Use `create(AcceptContractRequestSchema)` to create a new message.
|
|
113
|
+
*/
|
|
114
|
+
export declare const AcceptContractRequestSchema: GenMessage<AcceptContractRequest>;
|
|
115
|
+
/**
|
|
116
|
+
* Complete a contract with proof
|
|
117
|
+
*
|
|
118
|
+
* @generated from message ottochain.apps.contracts.v1.CompleteContractRequest
|
|
119
|
+
*/
|
|
120
|
+
export type CompleteContractRequest = Message<"ottochain.apps.contracts.v1.CompleteContractRequest"> & {
|
|
121
|
+
/**
|
|
122
|
+
* @generated from field: string contract_id = 1;
|
|
123
|
+
*/
|
|
124
|
+
contractId: string;
|
|
125
|
+
/**
|
|
126
|
+
* @generated from field: ottochain.v1.Address completer = 2;
|
|
127
|
+
*/
|
|
128
|
+
completer?: Address;
|
|
129
|
+
/**
|
|
130
|
+
* @generated from field: string proof = 3;
|
|
131
|
+
*/
|
|
132
|
+
proof: string;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Describes the message ottochain.apps.contracts.v1.CompleteContractRequest.
|
|
136
|
+
* Use `create(CompleteContractRequestSchema)` to create a new message.
|
|
137
|
+
*/
|
|
138
|
+
export declare const CompleteContractRequestSchema: GenMessage<CompleteContractRequest>;
|
|
139
|
+
/**
|
|
140
|
+
* Reject a proposed contract
|
|
141
|
+
*
|
|
142
|
+
* @generated from message ottochain.apps.contracts.v1.RejectContractRequest
|
|
143
|
+
*/
|
|
144
|
+
export type RejectContractRequest = Message<"ottochain.apps.contracts.v1.RejectContractRequest"> & {
|
|
145
|
+
/**
|
|
146
|
+
* @generated from field: string contract_id = 1;
|
|
147
|
+
*/
|
|
148
|
+
contractId: string;
|
|
149
|
+
/**
|
|
150
|
+
* @generated from field: ottochain.v1.Address rejector = 2;
|
|
151
|
+
*/
|
|
152
|
+
rejector?: Address;
|
|
153
|
+
/**
|
|
154
|
+
* @generated from field: string reason = 3;
|
|
155
|
+
*/
|
|
156
|
+
reason: string;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Describes the message ottochain.apps.contracts.v1.RejectContractRequest.
|
|
160
|
+
* Use `create(RejectContractRequestSchema)` to create a new message.
|
|
161
|
+
*/
|
|
162
|
+
export declare const RejectContractRequestSchema: GenMessage<RejectContractRequest>;
|
|
163
|
+
/**
|
|
164
|
+
* Dispute a contract
|
|
165
|
+
*
|
|
166
|
+
* @generated from message ottochain.apps.contracts.v1.DisputeContractRequest
|
|
167
|
+
*/
|
|
168
|
+
export type DisputeContractRequest = Message<"ottochain.apps.contracts.v1.DisputeContractRequest"> & {
|
|
169
|
+
/**
|
|
170
|
+
* @generated from field: string contract_id = 1;
|
|
171
|
+
*/
|
|
172
|
+
contractId: string;
|
|
173
|
+
/**
|
|
174
|
+
* @generated from field: ottochain.v1.Address disputant = 2;
|
|
175
|
+
*/
|
|
176
|
+
disputant?: Address;
|
|
177
|
+
/**
|
|
178
|
+
* @generated from field: string evidence = 3;
|
|
179
|
+
*/
|
|
180
|
+
evidence: string;
|
|
181
|
+
/**
|
|
182
|
+
* @generated from field: string reason = 4;
|
|
183
|
+
*/
|
|
184
|
+
reason: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Describes the message ottochain.apps.contracts.v1.DisputeContractRequest.
|
|
188
|
+
* Use `create(DisputeContractRequestSchema)` to create a new message.
|
|
189
|
+
*/
|
|
190
|
+
export declare const DisputeContractRequestSchema: GenMessage<DisputeContractRequest>;
|
|
191
|
+
/**
|
|
192
|
+
* Contract state machine definition
|
|
193
|
+
*
|
|
194
|
+
* Valid transitions:
|
|
195
|
+
* PROPOSED -> ACTIVE (accept)
|
|
196
|
+
* PROPOSED -> REJECTED (reject)
|
|
197
|
+
* PROPOSED -> CANCELLED (cancel)
|
|
198
|
+
* ACTIVE -> COMPLETED (complete)
|
|
199
|
+
* ACTIVE -> DISPUTED (dispute)
|
|
200
|
+
* DISPUTED -> COMPLETED (resolve_for_completer)
|
|
201
|
+
* DISPUTED -> REJECTED (resolve_for_disputant)
|
|
202
|
+
*
|
|
203
|
+
* @generated from message ottochain.apps.contracts.v1.ContractDefinition
|
|
204
|
+
*/
|
|
205
|
+
export type ContractDefinition = Message<"ottochain.apps.contracts.v1.ContractDefinition"> & {
|
|
206
|
+
/**
|
|
207
|
+
* Both parties must sign completion
|
|
208
|
+
*
|
|
209
|
+
* @generated from field: bool require_both_signatures = 1;
|
|
210
|
+
*/
|
|
211
|
+
requireBothSignatures: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* How long after completion disputes allowed
|
|
214
|
+
*
|
|
215
|
+
* @generated from field: int32 dispute_window_epochs = 2;
|
|
216
|
+
*/
|
|
217
|
+
disputeWindowEpochs: number;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Describes the message ottochain.apps.contracts.v1.ContractDefinition.
|
|
221
|
+
* Use `create(ContractDefinitionSchema)` to create a new message.
|
|
222
|
+
*/
|
|
223
|
+
export declare const ContractDefinitionSchema: GenMessage<ContractDefinition>;
|
|
224
|
+
/**
|
|
225
|
+
* Contract lifecycle states
|
|
226
|
+
*
|
|
227
|
+
* @generated from enum ottochain.apps.contracts.v1.ContractState
|
|
228
|
+
*/
|
|
229
|
+
export declare enum ContractState {
|
|
230
|
+
/**
|
|
231
|
+
* @generated from enum value: CONTRACT_STATE_UNSPECIFIED = 0;
|
|
232
|
+
*/
|
|
233
|
+
UNSPECIFIED = 0,
|
|
234
|
+
/**
|
|
235
|
+
* Awaiting counterparty acceptance
|
|
236
|
+
*
|
|
237
|
+
* @generated from enum value: CONTRACT_STATE_PROPOSED = 1;
|
|
238
|
+
*/
|
|
239
|
+
PROPOSED = 1,
|
|
240
|
+
/**
|
|
241
|
+
* Both parties agreed, in progress
|
|
242
|
+
*
|
|
243
|
+
* @generated from enum value: CONTRACT_STATE_ACTIVE = 2;
|
|
244
|
+
*/
|
|
245
|
+
ACTIVE = 2,
|
|
246
|
+
/**
|
|
247
|
+
* Successfully fulfilled (terminal)
|
|
248
|
+
*
|
|
249
|
+
* @generated from enum value: CONTRACT_STATE_COMPLETED = 3;
|
|
250
|
+
*/
|
|
251
|
+
COMPLETED = 3,
|
|
252
|
+
/**
|
|
253
|
+
* Counterparty declined (terminal)
|
|
254
|
+
*
|
|
255
|
+
* @generated from enum value: CONTRACT_STATE_REJECTED = 4;
|
|
256
|
+
*/
|
|
257
|
+
REJECTED = 4,
|
|
258
|
+
/**
|
|
259
|
+
* Under dispute resolution
|
|
260
|
+
*
|
|
261
|
+
* @generated from enum value: CONTRACT_STATE_DISPUTED = 5;
|
|
262
|
+
*/
|
|
263
|
+
DISPUTED = 5,
|
|
264
|
+
/**
|
|
265
|
+
* Cancelled by proposer before acceptance (terminal)
|
|
266
|
+
*
|
|
267
|
+
* @generated from enum value: CONTRACT_STATE_CANCELLED = 6;
|
|
268
|
+
*/
|
|
269
|
+
CANCELLED = 6
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Describes the enum ottochain.apps.contracts.v1.ContractState.
|
|
273
|
+
*/
|
|
274
|
+
export declare const ContractStateSchema: GenEnum<ContractState>;
|