@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
package/README.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# @ottochain/sdk
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ottobot-ai/ottochain-sdk/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/ottobot-ai/ottochain-sdk)
|
|
5
|
+
[](https://www.npmjs.com/package/@ottochain/sdk)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
TypeScript SDK for OttoChain metagraph on Constellation Network.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Transaction Signing** — Sign and batch-sign metagraph transactions
|
|
13
|
+
- **Key Management** — Generate and manage DAG keypairs
|
|
14
|
+
- **HTTP Client** — Interact with metagraph L0/L1 APIs
|
|
15
|
+
- **Type Definitions** — Full TypeScript types for OttoChain domain model
|
|
16
|
+
- **Input Validation** — Runtime validation with Zod schemas
|
|
17
|
+
- **Custom Errors** — Structured error handling with error codes
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# From npm (when published)
|
|
23
|
+
npm install @ottochain/sdk
|
|
24
|
+
|
|
25
|
+
# From GitHub (for development)
|
|
26
|
+
npm install github:ottobot-ai/ottochain-sdk#main
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import {
|
|
33
|
+
generateKeyPair,
|
|
34
|
+
createSignedObject,
|
|
35
|
+
DataL1Client
|
|
36
|
+
} from '@ottochain/sdk';
|
|
37
|
+
|
|
38
|
+
// Generate a new keypair
|
|
39
|
+
const keyPair = generateKeyPair();
|
|
40
|
+
console.log('Address:', keyPair.address);
|
|
41
|
+
|
|
42
|
+
// Create and sign a transaction
|
|
43
|
+
const payload = { action: 'RegisterAgent', data: { displayName: 'MyAgent' } };
|
|
44
|
+
const signed = await createSignedObject(payload, keyPair.privateKey, { isDataUpdate: true });
|
|
45
|
+
|
|
46
|
+
// Submit to network
|
|
47
|
+
const client = new DataL1Client('http://localhost:9300');
|
|
48
|
+
await client.postData(signed);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## API Documentation
|
|
52
|
+
|
|
53
|
+
### Key Management
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import {
|
|
57
|
+
generateKeyPair,
|
|
58
|
+
keyPairFromPrivateKey,
|
|
59
|
+
isValidPrivateKey,
|
|
60
|
+
isValidPublicKey,
|
|
61
|
+
getAddress
|
|
62
|
+
} from '@ottochain/sdk';
|
|
63
|
+
|
|
64
|
+
// Generate new keypair
|
|
65
|
+
const keyPair = generateKeyPair();
|
|
66
|
+
// { privateKey: '...', publicKey: '...', address: 'DAG...' }
|
|
67
|
+
|
|
68
|
+
// Import from existing private key
|
|
69
|
+
const imported = keyPairFromPrivateKey(privateKeyHex);
|
|
70
|
+
|
|
71
|
+
// Validation
|
|
72
|
+
if (isValidPrivateKey(key)) {
|
|
73
|
+
// Key is valid
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Signing Operations
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import {
|
|
81
|
+
createSignedObject,
|
|
82
|
+
batchSign,
|
|
83
|
+
addSignature,
|
|
84
|
+
sign,
|
|
85
|
+
signDataUpdate
|
|
86
|
+
} from '@ottochain/sdk';
|
|
87
|
+
|
|
88
|
+
// Sign a single object
|
|
89
|
+
const signed = await createSignedObject(data, privateKey);
|
|
90
|
+
|
|
91
|
+
// Sign for DataUpdate (metagraph L1 submission)
|
|
92
|
+
const signedUpdate = await createSignedObject(data, privateKey, { isDataUpdate: true });
|
|
93
|
+
|
|
94
|
+
// Multi-party signing
|
|
95
|
+
const multiSig = await batchSign(data, [key1, key2, key3]);
|
|
96
|
+
|
|
97
|
+
// Add signature to existing signed object
|
|
98
|
+
const withMoreSigs = await addSignature(signed, anotherPrivateKey);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Network Clients
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { DataL1Client, CurrencyL1Client, HttpClient } from '@ottochain/sdk';
|
|
105
|
+
|
|
106
|
+
// Data L1 client (for metagraph state)
|
|
107
|
+
const dataClient = new DataL1Client('http://localhost:9300');
|
|
108
|
+
await dataClient.postData(signedTransaction);
|
|
109
|
+
const state = await dataClient.get('/state');
|
|
110
|
+
|
|
111
|
+
// Currency L1 client (for token transfers)
|
|
112
|
+
const currencyClient = new CurrencyL1Client('http://localhost:9200');
|
|
113
|
+
const balance = await currencyClient.getBalance(address);
|
|
114
|
+
const lastRef = await currencyClient.getLastReference(address);
|
|
115
|
+
|
|
116
|
+
// Generic HTTP client with custom timeout
|
|
117
|
+
const httpClient = new HttpClient('http://localhost:9000', 30000);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Input Validation
|
|
121
|
+
|
|
122
|
+
The SDK uses [Zod](https://zod.dev) for runtime validation.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import {
|
|
126
|
+
validate,
|
|
127
|
+
validatePrivateKey,
|
|
128
|
+
validateAddress,
|
|
129
|
+
safeParse,
|
|
130
|
+
KeyPairSchema,
|
|
131
|
+
ProposeContractRequestSchema
|
|
132
|
+
} from '@ottochain/sdk';
|
|
133
|
+
|
|
134
|
+
// Validate and throw on error
|
|
135
|
+
const validKey = validatePrivateKey(input);
|
|
136
|
+
const validAddress = validateAddress(input);
|
|
137
|
+
|
|
138
|
+
// Validate complex objects
|
|
139
|
+
const keyPair = validate(KeyPairSchema, inputData);
|
|
140
|
+
const request = validate(ProposeContractRequestSchema, requestData);
|
|
141
|
+
|
|
142
|
+
// Safe parsing (returns result object)
|
|
143
|
+
const result = safeParse(KeyPairSchema, input);
|
|
144
|
+
if (result.success) {
|
|
145
|
+
console.log(result.data.address);
|
|
146
|
+
} else {
|
|
147
|
+
console.log(result.error.message);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Available schemas:
|
|
152
|
+
- `KeyPairSchema` - Private/public key and address
|
|
153
|
+
- `SignatureProofSchema` - Signature proof format
|
|
154
|
+
- `CurrencyTransactionSchema` - Currency transfer transactions
|
|
155
|
+
- `AgentIdentityRegistrationSchema` - Agent registration
|
|
156
|
+
- `ProposeContractRequestSchema` - Contract proposals
|
|
157
|
+
- `AcceptContractRequestSchema` - Contract acceptance
|
|
158
|
+
- `CompleteContractRequestSchema` - Contract completion
|
|
159
|
+
|
|
160
|
+
## Error Handling
|
|
161
|
+
|
|
162
|
+
The SDK provides custom error classes for structured error handling.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import {
|
|
166
|
+
OttoChainError,
|
|
167
|
+
NetworkError,
|
|
168
|
+
ValidationError,
|
|
169
|
+
SigningError,
|
|
170
|
+
TransactionError,
|
|
171
|
+
ErrorCode,
|
|
172
|
+
isErrorCode
|
|
173
|
+
} from '@ottochain/sdk';
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
await client.postData(signed);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (error instanceof NetworkError) {
|
|
179
|
+
console.log('Network failed:', error.statusCode, error.message);
|
|
180
|
+
if (error.responseBody) {
|
|
181
|
+
console.log('Response:', error.responseBody);
|
|
182
|
+
}
|
|
183
|
+
} else if (error instanceof ValidationError) {
|
|
184
|
+
console.log('Invalid input:', error.field, error.message);
|
|
185
|
+
console.log('Details:', error.details);
|
|
186
|
+
} else if (error instanceof SigningError) {
|
|
187
|
+
console.log('Signing failed:', error.operation);
|
|
188
|
+
} else if (error instanceof TransactionError) {
|
|
189
|
+
console.log('Transaction failed:', error.rejectionReason);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Check specific error codes
|
|
193
|
+
if (isErrorCode(error, ErrorCode.NETWORK_TIMEOUT)) {
|
|
194
|
+
// Implement retry logic
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Error codes:
|
|
200
|
+
- `NETWORK_ERROR` - HTTP/connection failures
|
|
201
|
+
- `NETWORK_TIMEOUT` - Request timeout
|
|
202
|
+
- `VALIDATION_ERROR` - Input validation failed
|
|
203
|
+
- `SIGNING_ERROR` - Signature creation failed
|
|
204
|
+
- `TRANSACTION_REJECTED` - Transaction rejected by network
|
|
205
|
+
- `TRANSACTION_NOT_FOUND` - Transaction not found
|
|
206
|
+
|
|
207
|
+
## Examples
|
|
208
|
+
|
|
209
|
+
See the [examples/](./examples/) directory for complete working examples:
|
|
210
|
+
|
|
211
|
+
| Example | Description |
|
|
212
|
+
|---------|-------------|
|
|
213
|
+
| [agent-registration.ts](./examples/agent-registration.ts) | Register an agent identity |
|
|
214
|
+
| [contract-flow.ts](./examples/contract-flow.ts) | Full contract lifecycle (propose → accept → complete) |
|
|
215
|
+
| [batch-transactions.ts](./examples/batch-transactions.ts) | Multi-party signing and batch operations |
|
|
216
|
+
| [wallet-management.ts](./examples/wallet-management.ts) | Key generation, import, export, validation |
|
|
217
|
+
| [query-state.ts](./examples/query-state.ts) | Query network state and handle errors |
|
|
218
|
+
|
|
219
|
+
Run an example:
|
|
220
|
+
```bash
|
|
221
|
+
npx ts-node examples/wallet-management.ts
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Module Imports
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
// Core SDK (signing, HTTP client, validation, errors)
|
|
228
|
+
import {
|
|
229
|
+
generateKeyPair,
|
|
230
|
+
batchSign,
|
|
231
|
+
HttpClient,
|
|
232
|
+
validate,
|
|
233
|
+
ValidationError
|
|
234
|
+
} from '@ottochain/sdk';
|
|
235
|
+
|
|
236
|
+
// Core types (fiber, state machine)
|
|
237
|
+
import { Fiber, StateMachineDefinition } from '@ottochain/sdk/core';
|
|
238
|
+
|
|
239
|
+
// Agent Identity application
|
|
240
|
+
import { AgentState, AttestationType, AgentIdentity } from '@ottochain/sdk/apps/identity';
|
|
241
|
+
|
|
242
|
+
// Contracts application
|
|
243
|
+
import { ContractState, Contract } from '@ottochain/sdk/apps/contracts';
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Development
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Install dependencies
|
|
250
|
+
npm install
|
|
251
|
+
|
|
252
|
+
# Build
|
|
253
|
+
npm run build
|
|
254
|
+
|
|
255
|
+
# Run tests
|
|
256
|
+
npm test
|
|
257
|
+
|
|
258
|
+
# Run tests with coverage
|
|
259
|
+
npm run test:coverage
|
|
260
|
+
|
|
261
|
+
# Lint
|
|
262
|
+
npm run lint
|
|
263
|
+
|
|
264
|
+
# Generate documentation
|
|
265
|
+
npm run docs
|
|
266
|
+
|
|
267
|
+
# Generate protobuf types
|
|
268
|
+
npm run generate
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Project Structure
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
ottochain-sdk/
|
|
275
|
+
├── proto/ # Protobuf definitions (source of truth)
|
|
276
|
+
│ └── ottochain/
|
|
277
|
+
│ ├── v1/ # Core metagraph types
|
|
278
|
+
│ │ ├── common.proto
|
|
279
|
+
│ │ ├── fiber.proto
|
|
280
|
+
│ │ ├── messages.proto
|
|
281
|
+
│ │ └── records.proto
|
|
282
|
+
│ └── apps/ # Application-specific types
|
|
283
|
+
│ ├── identity/v1/
|
|
284
|
+
│ │ ├── agent.proto
|
|
285
|
+
│ │ └── attestation.proto
|
|
286
|
+
│ └── contracts/v1/
|
|
287
|
+
│ └── contract.proto
|
|
288
|
+
├── src/
|
|
289
|
+
│ ├── metakit/ # Signing, hashing, HTTP client
|
|
290
|
+
│ ├── ottochain/ # Core domain types
|
|
291
|
+
│ ├── apps/ # Application modules
|
|
292
|
+
│ │ ├── identity/ # Agent Identity types
|
|
293
|
+
│ │ └── contracts/ # Contract types
|
|
294
|
+
│ ├── generated/ # Protobuf-generated code
|
|
295
|
+
│ ├── errors.ts # Custom error classes
|
|
296
|
+
│ ├── validation.ts # Zod validation schemas
|
|
297
|
+
│ └── index.ts # Main exports
|
|
298
|
+
├── examples/ # Working code examples
|
|
299
|
+
├── tests/ # Test suites
|
|
300
|
+
└── dist/ # Compiled output
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
Apache-2.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts Application
|
|
3
|
+
*
|
|
4
|
+
* Types and utilities for the Contract system on OttoChain.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { ContractState, ContractSchema } from '@ottochain/sdk/apps/contracts';
|
|
9
|
+
* import { create } from '@bufbuild/protobuf';
|
|
10
|
+
*
|
|
11
|
+
* const contract = create(ContractSchema, {
|
|
12
|
+
* id: 'fiber-123',
|
|
13
|
+
* contractId: 'contract-001',
|
|
14
|
+
* state: ContractState.PROPOSED,
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
export * from '../../generated/ottochain/apps/contracts/v1/contract_pb.js';
|
|
21
|
+
export * from './types.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contracts Application
|
|
4
|
+
*
|
|
5
|
+
* Types and utilities for the Contract system on OttoChain.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { ContractState, ContractSchema } from '@ottochain/sdk/apps/contracts';
|
|
10
|
+
* import { create } from '@bufbuild/protobuf';
|
|
11
|
+
*
|
|
12
|
+
* const contract = create(ContractSchema, {
|
|
13
|
+
* id: 'fiber-123',
|
|
14
|
+
* contractId: 'contract-001',
|
|
15
|
+
* state: ContractState.PROPOSED,
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
33
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
// Re-export generated protobuf types
|
|
37
|
+
__exportStar(require("../../generated/ottochain/apps/contracts/v1/contract_pb.js"), exports);
|
|
38
|
+
// Re-export convenience types and constants
|
|
39
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract Utilities
|
|
3
|
+
*
|
|
4
|
+
* Constants and utilities for the Contract application.
|
|
5
|
+
* Core types are generated from protobuf - see the generated exports.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { ContractState } from '../../generated/ottochain/apps/contracts/v1/contract_pb.js';
|
|
10
|
+
/**
|
|
11
|
+
* Default contract configuration
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_CONTRACT_CONFIG: {
|
|
14
|
+
readonly requireBothSignatures: false;
|
|
15
|
+
readonly disputeWindowEpochs: 10;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Valid transitions for each contract state
|
|
19
|
+
*/
|
|
20
|
+
export declare const CONTRACT_TRANSITIONS: Record<ContractState, readonly string[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a contract state is terminal (no further transitions allowed)
|
|
23
|
+
*/
|
|
24
|
+
export declare function isTerminalState(state: ContractState): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract Utilities
|
|
4
|
+
*
|
|
5
|
+
* Constants and utilities for the Contract application.
|
|
6
|
+
* Core types are generated from protobuf - see the generated exports.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.isTerminalState = exports.CONTRACT_TRANSITIONS = exports.DEFAULT_CONTRACT_CONFIG = void 0;
|
|
12
|
+
const contract_pb_js_1 = require("../../generated/ottochain/apps/contracts/v1/contract_pb.js");
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Configuration Defaults
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Default contract configuration
|
|
18
|
+
*/
|
|
19
|
+
exports.DEFAULT_CONTRACT_CONFIG = {
|
|
20
|
+
requireBothSignatures: false,
|
|
21
|
+
disputeWindowEpochs: 10,
|
|
22
|
+
};
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// State Machine Transitions
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* Valid transitions for each contract state
|
|
28
|
+
*/
|
|
29
|
+
exports.CONTRACT_TRANSITIONS = {
|
|
30
|
+
[contract_pb_js_1.ContractState.UNSPECIFIED]: [],
|
|
31
|
+
[contract_pb_js_1.ContractState.PROPOSED]: ['accept', 'reject', 'cancel'],
|
|
32
|
+
[contract_pb_js_1.ContractState.ACTIVE]: ['complete', 'dispute'],
|
|
33
|
+
[contract_pb_js_1.ContractState.DISPUTED]: ['resolve_for_completer', 'resolve_for_disputant'],
|
|
34
|
+
[contract_pb_js_1.ContractState.COMPLETED]: [], // Terminal state
|
|
35
|
+
[contract_pb_js_1.ContractState.REJECTED]: [], // Terminal state
|
|
36
|
+
[contract_pb_js_1.ContractState.CANCELLED]: [], // Terminal state
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Check if a contract state is terminal (no further transitions allowed)
|
|
40
|
+
*/
|
|
41
|
+
function isTerminalState(state) {
|
|
42
|
+
return [
|
|
43
|
+
contract_pb_js_1.ContractState.COMPLETED,
|
|
44
|
+
contract_pb_js_1.ContractState.REJECTED,
|
|
45
|
+
contract_pb_js_1.ContractState.CANCELLED,
|
|
46
|
+
].includes(state);
|
|
47
|
+
}
|
|
48
|
+
exports.isTerminalState = isTerminalState;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Identity Application
|
|
3
|
+
*
|
|
4
|
+
* Types and utilities for the Agent Identity system on OttoChain.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { AgentState, AttestationType, AgentIdentitySchema } from '@ottochain/sdk/apps/identity';
|
|
9
|
+
* import { create } from '@bufbuild/protobuf';
|
|
10
|
+
*
|
|
11
|
+
* const agent = create(AgentIdentitySchema, {
|
|
12
|
+
* publicKey: '...',
|
|
13
|
+
* reputation: 10,
|
|
14
|
+
* state: AgentState.REGISTERED,
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
export * from '../../generated/ottochain/apps/identity/v1/agent_pb.js';
|
|
21
|
+
export * from '../../generated/ottochain/apps/identity/v1/attestation_pb.js';
|
|
22
|
+
export * from './types.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Identity Application
|
|
4
|
+
*
|
|
5
|
+
* Types and utilities for the Agent Identity system on OttoChain.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AgentState, AttestationType, AgentIdentitySchema } from '@ottochain/sdk/apps/identity';
|
|
10
|
+
* import { create } from '@bufbuild/protobuf';
|
|
11
|
+
*
|
|
12
|
+
* const agent = create(AgentIdentitySchema, {
|
|
13
|
+
* publicKey: '...',
|
|
14
|
+
* reputation: 10,
|
|
15
|
+
* state: AgentState.REGISTERED,
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
33
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
// Re-export generated protobuf types
|
|
37
|
+
__exportStar(require("../../generated/ottochain/apps/identity/v1/agent_pb.js"), exports);
|
|
38
|
+
__exportStar(require("../../generated/ottochain/apps/identity/v1/attestation_pb.js"), exports);
|
|
39
|
+
// Re-export convenience types and constants
|
|
40
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Identity Utilities
|
|
3
|
+
*
|
|
4
|
+
* Constants and utilities for the Agent Identity application.
|
|
5
|
+
* Core types are generated from protobuf - see the generated exports.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { AgentState } from '../../generated/ottochain/apps/identity/v1/agent_pb.js';
|
|
10
|
+
import { AttestationType } from '../../generated/ottochain/apps/identity/v1/attestation_pb.js';
|
|
11
|
+
/**
|
|
12
|
+
* Default reputation configuration for agent identity
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_REPUTATION_CONFIG: {
|
|
15
|
+
readonly baseReputation: 10;
|
|
16
|
+
readonly completionDelta: 5;
|
|
17
|
+
readonly vouchDelta: 2;
|
|
18
|
+
readonly violationDelta: -10;
|
|
19
|
+
readonly behavioralDelta: 3;
|
|
20
|
+
readonly minReputation: 0;
|
|
21
|
+
readonly challengeThreshold: 5;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Valid transitions for each agent state
|
|
25
|
+
*/
|
|
26
|
+
export declare const AGENT_TRANSITIONS: Record<AgentState, readonly string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Reputation delta by attestation type
|
|
29
|
+
*/
|
|
30
|
+
export declare const ATTESTATION_DELTAS: Record<AttestationType, number>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Identity Utilities
|
|
4
|
+
*
|
|
5
|
+
* Constants and utilities for the Agent Identity application.
|
|
6
|
+
* Core types are generated from protobuf - see the generated exports.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ATTESTATION_DELTAS = exports.AGENT_TRANSITIONS = exports.DEFAULT_REPUTATION_CONFIG = void 0;
|
|
12
|
+
const agent_pb_js_1 = require("../../generated/ottochain/apps/identity/v1/agent_pb.js");
|
|
13
|
+
const attestation_pb_js_1 = require("../../generated/ottochain/apps/identity/v1/attestation_pb.js");
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Configuration Defaults
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/**
|
|
18
|
+
* Default reputation configuration for agent identity
|
|
19
|
+
*/
|
|
20
|
+
exports.DEFAULT_REPUTATION_CONFIG = {
|
|
21
|
+
baseReputation: 10,
|
|
22
|
+
completionDelta: 5,
|
|
23
|
+
vouchDelta: 2,
|
|
24
|
+
violationDelta: -10,
|
|
25
|
+
behavioralDelta: 3,
|
|
26
|
+
minReputation: 0,
|
|
27
|
+
challengeThreshold: 5,
|
|
28
|
+
};
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// State Machine Transitions
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
/**
|
|
33
|
+
* Valid transitions for each agent state
|
|
34
|
+
*/
|
|
35
|
+
exports.AGENT_TRANSITIONS = {
|
|
36
|
+
[agent_pb_js_1.AgentState.UNSPECIFIED]: [],
|
|
37
|
+
[agent_pb_js_1.AgentState.REGISTERED]: ['activate', 'withdraw'],
|
|
38
|
+
[agent_pb_js_1.AgentState.ACTIVE]: ['challenge', 'withdraw'],
|
|
39
|
+
[agent_pb_js_1.AgentState.CHALLENGED]: ['uphold_challenge', 'dismiss_challenge'],
|
|
40
|
+
[agent_pb_js_1.AgentState.SUSPENDED]: ['begin_probation'],
|
|
41
|
+
[agent_pb_js_1.AgentState.PROBATION]: ['complete_probation'],
|
|
42
|
+
[agent_pb_js_1.AgentState.WITHDRAWN]: [], // Terminal state
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Reputation delta by attestation type
|
|
46
|
+
*/
|
|
47
|
+
exports.ATTESTATION_DELTAS = {
|
|
48
|
+
[attestation_pb_js_1.AttestationType.UNSPECIFIED]: 0,
|
|
49
|
+
[attestation_pb_js_1.AttestationType.COMPLETION]: 5,
|
|
50
|
+
[attestation_pb_js_1.AttestationType.VOUCH]: 2,
|
|
51
|
+
[attestation_pb_js_1.AttestationType.VIOLATION]: -10,
|
|
52
|
+
[attestation_pb_js_1.AttestationType.BEHAVIORAL]: 3,
|
|
53
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OttoChain Applications
|
|
3
|
+
*
|
|
4
|
+
* Application-specific types and utilities for OttoChain SDK.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { identity, contracts, markets, oracles } from '@ottochain/sdk/apps';
|
|
9
|
+
*
|
|
10
|
+
* // Use identity types
|
|
11
|
+
* const { AgentState, AGENT_TRANSITIONS } = identity;
|
|
12
|
+
*
|
|
13
|
+
* // Use market calculations
|
|
14
|
+
* const payout = markets.calculatePayout(shares);
|
|
15
|
+
*
|
|
16
|
+
* // Check oracle reputation
|
|
17
|
+
* const newRep = oracles.calculateReputation(current, delta);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
export * as identity from './identity/index.js';
|
|
23
|
+
export * as contracts from './contracts/index.js';
|
|
24
|
+
export * as markets from './markets/index.js';
|
|
25
|
+
export * as oracles from './oracles/index.js';
|
|
26
|
+
export * from './identity/index.js';
|
|
27
|
+
export * from './contracts/index.js';
|
|
28
|
+
export * from './markets/index.js';
|
|
29
|
+
export * from './oracles/index.js';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OttoChain Applications
|
|
4
|
+
*
|
|
5
|
+
* Application-specific types and utilities for OttoChain SDK.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { identity, contracts, markets, oracles } from '@ottochain/sdk/apps';
|
|
10
|
+
*
|
|
11
|
+
* // Use identity types
|
|
12
|
+
* const { AgentState, AGENT_TRANSITIONS } = identity;
|
|
13
|
+
*
|
|
14
|
+
* // Use market calculations
|
|
15
|
+
* const payout = markets.calculatePayout(shares);
|
|
16
|
+
*
|
|
17
|
+
* // Check oracle reputation
|
|
18
|
+
* const newRep = oracles.calculateReputation(current, delta);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @packageDocumentation
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
47
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.oracles = exports.markets = exports.contracts = exports.identity = void 0;
|
|
51
|
+
// Re-export as namespaces for organized access
|
|
52
|
+
exports.identity = __importStar(require("./identity/index.js"));
|
|
53
|
+
exports.contracts = __importStar(require("./contracts/index.js"));
|
|
54
|
+
exports.markets = __importStar(require("./markets/index.js"));
|
|
55
|
+
exports.oracles = __importStar(require("./oracles/index.js"));
|
|
56
|
+
// Also allow direct imports
|
|
57
|
+
__exportStar(require("./identity/index.js"), exports);
|
|
58
|
+
__exportStar(require("./contracts/index.js"), exports);
|
|
59
|
+
__exportStar(require("./markets/index.js"), exports);
|
|
60
|
+
__exportStar(require("./oracles/index.js"), exports);
|