@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,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ottochain Metagraph Client
|
|
4
|
+
*
|
|
5
|
+
* Client for interacting with ottochain ML0 custom routes (/v1 prefix)
|
|
6
|
+
* and framework snapshot endpoints.
|
|
7
|
+
*
|
|
8
|
+
* @see modules/l0/src/main/scala/xyz/kd5ujc/metagraph_l0/ML0CustomRoutes.scala
|
|
9
|
+
* @see modules/data_l1/src/main/scala/xyz/kd5ujc/data_l1/DataL1CustomRoutes.scala
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MetagraphClient = void 0;
|
|
14
|
+
const client_js_1 = require("../metakit/network/client.js");
|
|
15
|
+
const types_js_1 = require("../metakit/network/types.js");
|
|
16
|
+
const snapshot_js_1 = require("./snapshot.js");
|
|
17
|
+
/**
|
|
18
|
+
* Client for ottochain metagraph operations.
|
|
19
|
+
*
|
|
20
|
+
* Provides typed access to all ML0 custom routes (under /data-application/v1/)
|
|
21
|
+
* and framework snapshot endpoints.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const client = new MetagraphClient({
|
|
26
|
+
* ml0Url: 'http://localhost:9200',
|
|
27
|
+
* dl1Url: 'http://localhost:9400',
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Query on-chain state
|
|
31
|
+
* const onChain = await client.getOnChain();
|
|
32
|
+
*
|
|
33
|
+
* // Get all active state machines
|
|
34
|
+
* const machines = await client.getStateMachines('Active');
|
|
35
|
+
*
|
|
36
|
+
* // Get event receipts for a fiber
|
|
37
|
+
* const events = await client.getStateMachineEvents(fiberId);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class MetagraphClient {
|
|
41
|
+
constructor(config) {
|
|
42
|
+
this.ml0 = new client_js_1.HttpClient(config.ml0Url, config.timeout);
|
|
43
|
+
if (config.dl1Url) {
|
|
44
|
+
this.dl1 = new client_js_1.HttpClient(config.dl1Url, config.timeout);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// -------------------------------------------------------------------------
|
|
48
|
+
// Custom routes (ML0 /data-application/v1/*)
|
|
49
|
+
// -------------------------------------------------------------------------
|
|
50
|
+
/**
|
|
51
|
+
* Get the current on-chain state (directly from L0 context).
|
|
52
|
+
*/
|
|
53
|
+
async getOnChain() {
|
|
54
|
+
return this.ml0.get('/data-application/v1/onchain');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the latest checkpoint (ordinal + calculated state).
|
|
58
|
+
*/
|
|
59
|
+
async getCheckpoint() {
|
|
60
|
+
return this.ml0.get('/data-application/v1/checkpoint');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get all state machines, optionally filtered by status.
|
|
64
|
+
*/
|
|
65
|
+
async getStateMachines(status) {
|
|
66
|
+
const query = status ? `?status=${status}` : '';
|
|
67
|
+
return this.ml0.get(`/data-application/v1/state-machines${query}`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get a single state machine by fiber ID.
|
|
71
|
+
*/
|
|
72
|
+
async getStateMachine(fiberId) {
|
|
73
|
+
try {
|
|
74
|
+
return await this.ml0.get(`/data-application/v1/state-machines/${fiberId}`);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (error instanceof types_js_1.NetworkError && error.statusCode === 404) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get event receipts for a state machine from the current ordinal's logs.
|
|
85
|
+
*/
|
|
86
|
+
async getStateMachineEvents(fiberId) {
|
|
87
|
+
return this.ml0.get(`/data-application/v1/state-machines/${fiberId}/events`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get all script oracles, optionally filtered by status.
|
|
91
|
+
*/
|
|
92
|
+
async getScripts(status) {
|
|
93
|
+
const query = status ? `?status=${status}` : '';
|
|
94
|
+
return this.ml0.get(`/data-application/v1/oracles${query}`);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get a single script oracle by fiber ID.
|
|
98
|
+
*/
|
|
99
|
+
async getScript(scriptId) {
|
|
100
|
+
try {
|
|
101
|
+
return await this.ml0.get(`/data-application/v1/oracles/${scriptId}`);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error instanceof types_js_1.NetworkError && error.statusCode === 404) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get oracle invocations from the current ordinal's logs.
|
|
112
|
+
*/
|
|
113
|
+
async getScriptInvocations(scriptId) {
|
|
114
|
+
return this.ml0.get(`/data-application/v1/oracles/${scriptId}/invocations`);
|
|
115
|
+
}
|
|
116
|
+
// -------------------------------------------------------------------------
|
|
117
|
+
// Framework snapshot endpoints (ML0 /snapshots/*)
|
|
118
|
+
// -------------------------------------------------------------------------
|
|
119
|
+
/**
|
|
120
|
+
* Get the latest snapshot and decode its on-chain state.
|
|
121
|
+
*/
|
|
122
|
+
async getLatestSnapshotOnChainState() {
|
|
123
|
+
const snapshot = await this.ml0.get('/snapshots/latest');
|
|
124
|
+
return (0, snapshot_js_1.extractOnChainState)(snapshot);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get a snapshot by ordinal and decode its on-chain state.
|
|
128
|
+
*/
|
|
129
|
+
async getSnapshotOnChainState(ordinal) {
|
|
130
|
+
const snapshot = await this.ml0.get(`/snapshots/${ordinal}`);
|
|
131
|
+
return (0, snapshot_js_1.extractOnChainState)(snapshot);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get the latest snapshot ordinal.
|
|
135
|
+
*/
|
|
136
|
+
async getLatestOrdinal() {
|
|
137
|
+
const snapshot = await this.ml0.get('/snapshots/latest');
|
|
138
|
+
return snapshot.value.ordinal;
|
|
139
|
+
}
|
|
140
|
+
// -------------------------------------------------------------------------
|
|
141
|
+
// DL1 data submission (framework POST /data)
|
|
142
|
+
// -------------------------------------------------------------------------
|
|
143
|
+
/**
|
|
144
|
+
* Submit a signed data update to the DL1 node.
|
|
145
|
+
* The POST /data endpoint is framework-provided (no /v1 prefix).
|
|
146
|
+
*
|
|
147
|
+
* @param signedData - Signed OttochainMessage
|
|
148
|
+
* @returns Response hash
|
|
149
|
+
*/
|
|
150
|
+
async postData(signedData) {
|
|
151
|
+
if (!this.dl1) {
|
|
152
|
+
throw new Error('dl1Url is required for postData');
|
|
153
|
+
}
|
|
154
|
+
return this.dl1.post('/data', signedData);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.MetagraphClient = MetagraphClient;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot decoder for ottochain on-chain state
|
|
3
|
+
*
|
|
4
|
+
* Fetches currency incremental snapshots from metagraph L0 and decodes the
|
|
5
|
+
* on-chain state from the DataApplicationPart's binary payload.
|
|
6
|
+
*
|
|
7
|
+
* The on-chain state is serialized using JsonBinaryCodec (canonical JSON → UTF-8 bytes).
|
|
8
|
+
*
|
|
9
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { OnChain, EventReceipt, OracleInvocation, FiberLogEntry } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Decode on-chain state from binary (JsonBinaryCodec format).
|
|
15
|
+
*
|
|
16
|
+
* JsonBinaryCodec serialization is: canonical JSON → UTF-8 bytes.
|
|
17
|
+
* So decoding is simply: UTF-8 bytes → JSON.parse.
|
|
18
|
+
*
|
|
19
|
+
* @param bytes - UTF-8 encoded canonical JSON bytes
|
|
20
|
+
* @returns Decoded OnChain state
|
|
21
|
+
*/
|
|
22
|
+
export declare function decodeOnChainState(bytes: Uint8Array): OnChain;
|
|
23
|
+
/**
|
|
24
|
+
* Snapshot response shape from GET /snapshots/{ordinal} or /snapshots/latest
|
|
25
|
+
* on the metagraph L0 node (port 9200 by default).
|
|
26
|
+
*/
|
|
27
|
+
export interface CurrencySnapshotResponse {
|
|
28
|
+
value: {
|
|
29
|
+
ordinal: number;
|
|
30
|
+
dataApplication?: {
|
|
31
|
+
onChainState: number[];
|
|
32
|
+
blocks: unknown[];
|
|
33
|
+
};
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
proofs: unknown[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetch and decode the on-chain state from a specific snapshot ordinal.
|
|
40
|
+
*
|
|
41
|
+
* @param ml0BaseUrl - Metagraph L0 node base URL (e.g., 'http://localhost:9200')
|
|
42
|
+
* @param ordinal - Snapshot ordinal number
|
|
43
|
+
* @returns Decoded OnChain state, or null if no data application part
|
|
44
|
+
*/
|
|
45
|
+
export declare function getSnapshotOnChainState(ml0BaseUrl: string, ordinal: number): Promise<OnChain | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch and decode the on-chain state from the latest snapshot.
|
|
48
|
+
*
|
|
49
|
+
* @param ml0BaseUrl - Metagraph L0 node base URL (e.g., 'http://localhost:9200')
|
|
50
|
+
* @returns Decoded OnChain state, or null if no data application part
|
|
51
|
+
*/
|
|
52
|
+
export declare function getLatestOnChainState(ml0BaseUrl: string): Promise<OnChain | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Extract and decode on-chain state from a snapshot response.
|
|
55
|
+
*/
|
|
56
|
+
export declare function extractOnChainState(snapshot: CurrencySnapshotResponse): OnChain | null;
|
|
57
|
+
/**
|
|
58
|
+
* Get all log entries for a specific fiber from on-chain state.
|
|
59
|
+
*
|
|
60
|
+
* @param onChain - Decoded on-chain state
|
|
61
|
+
* @param fiberId - Fiber UUID to filter by
|
|
62
|
+
* @returns Array of log entries for the fiber, or empty array
|
|
63
|
+
*/
|
|
64
|
+
export declare function getLogsForFiber(onChain: OnChain, fiberId: string): FiberLogEntry[];
|
|
65
|
+
/**
|
|
66
|
+
* Get EventReceipt log entries for a specific fiber.
|
|
67
|
+
*
|
|
68
|
+
* EventReceipts are distinguished from OracleInvocations by the presence
|
|
69
|
+
* of the `eventName` field.
|
|
70
|
+
*
|
|
71
|
+
* @param onChain - Decoded on-chain state
|
|
72
|
+
* @param fiberId - Fiber UUID to filter by
|
|
73
|
+
* @returns Array of EventReceipt entries
|
|
74
|
+
*/
|
|
75
|
+
export declare function getEventReceipts(onChain: OnChain, fiberId: string): EventReceipt[];
|
|
76
|
+
/**
|
|
77
|
+
* Get OracleInvocation log entries for a specific fiber.
|
|
78
|
+
*
|
|
79
|
+
* OracleInvocations are distinguished from EventReceipts by the presence
|
|
80
|
+
* of the `method` field.
|
|
81
|
+
*
|
|
82
|
+
* @param onChain - Decoded on-chain state
|
|
83
|
+
* @param fiberId - Fiber UUID to filter by
|
|
84
|
+
* @returns Array of OracleInvocation entries
|
|
85
|
+
*/
|
|
86
|
+
export declare function getScriptInvocations(onChain: OnChain, fiberId: string): OracleInvocation[];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Snapshot decoder for ottochain on-chain state
|
|
4
|
+
*
|
|
5
|
+
* Fetches currency incremental snapshots from metagraph L0 and decodes the
|
|
6
|
+
* on-chain state from the DataApplicationPart's binary payload.
|
|
7
|
+
*
|
|
8
|
+
* The on-chain state is serialized using JsonBinaryCodec (canonical JSON → UTF-8 bytes).
|
|
9
|
+
*
|
|
10
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getScriptInvocations = exports.getEventReceipts = exports.getLogsForFiber = exports.extractOnChainState = exports.getLatestOnChainState = exports.getSnapshotOnChainState = exports.decodeOnChainState = void 0;
|
|
15
|
+
const client_js_1 = require("../metakit/network/client.js");
|
|
16
|
+
/**
|
|
17
|
+
* Decode on-chain state from binary (JsonBinaryCodec format).
|
|
18
|
+
*
|
|
19
|
+
* JsonBinaryCodec serialization is: canonical JSON → UTF-8 bytes.
|
|
20
|
+
* So decoding is simply: UTF-8 bytes → JSON.parse.
|
|
21
|
+
*
|
|
22
|
+
* @param bytes - UTF-8 encoded canonical JSON bytes
|
|
23
|
+
* @returns Decoded OnChain state
|
|
24
|
+
*/
|
|
25
|
+
function decodeOnChainState(bytes) {
|
|
26
|
+
const json = new TextDecoder().decode(bytes);
|
|
27
|
+
return JSON.parse(json);
|
|
28
|
+
}
|
|
29
|
+
exports.decodeOnChainState = decodeOnChainState;
|
|
30
|
+
/**
|
|
31
|
+
* Fetch and decode the on-chain state from a specific snapshot ordinal.
|
|
32
|
+
*
|
|
33
|
+
* @param ml0BaseUrl - Metagraph L0 node base URL (e.g., 'http://localhost:9200')
|
|
34
|
+
* @param ordinal - Snapshot ordinal number
|
|
35
|
+
* @returns Decoded OnChain state, or null if no data application part
|
|
36
|
+
*/
|
|
37
|
+
async function getSnapshotOnChainState(ml0BaseUrl, ordinal) {
|
|
38
|
+
const client = new client_js_1.HttpClient(ml0BaseUrl);
|
|
39
|
+
const snapshot = await client.get(`/snapshots/${ordinal}`);
|
|
40
|
+
return extractOnChainState(snapshot);
|
|
41
|
+
}
|
|
42
|
+
exports.getSnapshotOnChainState = getSnapshotOnChainState;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch and decode the on-chain state from the latest snapshot.
|
|
45
|
+
*
|
|
46
|
+
* @param ml0BaseUrl - Metagraph L0 node base URL (e.g., 'http://localhost:9200')
|
|
47
|
+
* @returns Decoded OnChain state, or null if no data application part
|
|
48
|
+
*/
|
|
49
|
+
async function getLatestOnChainState(ml0BaseUrl) {
|
|
50
|
+
const client = new client_js_1.HttpClient(ml0BaseUrl);
|
|
51
|
+
const snapshot = await client.get('/snapshots/latest');
|
|
52
|
+
return extractOnChainState(snapshot);
|
|
53
|
+
}
|
|
54
|
+
exports.getLatestOnChainState = getLatestOnChainState;
|
|
55
|
+
/**
|
|
56
|
+
* Extract and decode on-chain state from a snapshot response.
|
|
57
|
+
*/
|
|
58
|
+
function extractOnChainState(snapshot) {
|
|
59
|
+
const dataPart = snapshot.value?.dataApplication;
|
|
60
|
+
if (!dataPart?.onChainState) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const bytes = new Uint8Array(dataPart.onChainState);
|
|
64
|
+
return decodeOnChainState(bytes);
|
|
65
|
+
}
|
|
66
|
+
exports.extractOnChainState = extractOnChainState;
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Log filtering helpers
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Get all log entries for a specific fiber from on-chain state.
|
|
72
|
+
*
|
|
73
|
+
* @param onChain - Decoded on-chain state
|
|
74
|
+
* @param fiberId - Fiber UUID to filter by
|
|
75
|
+
* @returns Array of log entries for the fiber, or empty array
|
|
76
|
+
*/
|
|
77
|
+
function getLogsForFiber(onChain, fiberId) {
|
|
78
|
+
return onChain.latestLogs[fiberId] ?? [];
|
|
79
|
+
}
|
|
80
|
+
exports.getLogsForFiber = getLogsForFiber;
|
|
81
|
+
/**
|
|
82
|
+
* Get EventReceipt log entries for a specific fiber.
|
|
83
|
+
*
|
|
84
|
+
* EventReceipts are distinguished from OracleInvocations by the presence
|
|
85
|
+
* of the `eventName` field.
|
|
86
|
+
*
|
|
87
|
+
* @param onChain - Decoded on-chain state
|
|
88
|
+
* @param fiberId - Fiber UUID to filter by
|
|
89
|
+
* @returns Array of EventReceipt entries
|
|
90
|
+
*/
|
|
91
|
+
function getEventReceipts(onChain, fiberId) {
|
|
92
|
+
return getLogsForFiber(onChain, fiberId)
|
|
93
|
+
.filter((entry) => 'eventName' in entry && 'success' in entry);
|
|
94
|
+
}
|
|
95
|
+
exports.getEventReceipts = getEventReceipts;
|
|
96
|
+
/**
|
|
97
|
+
* Get OracleInvocation log entries for a specific fiber.
|
|
98
|
+
*
|
|
99
|
+
* OracleInvocations are distinguished from EventReceipts by the presence
|
|
100
|
+
* of the `method` field.
|
|
101
|
+
*
|
|
102
|
+
* @param onChain - Decoded on-chain state
|
|
103
|
+
* @param fiberId - Fiber UUID to filter by
|
|
104
|
+
* @returns Array of OracleInvocation entries
|
|
105
|
+
*/
|
|
106
|
+
function getScriptInvocations(onChain, fiberId) {
|
|
107
|
+
return getLogsForFiber(onChain, fiberId)
|
|
108
|
+
.filter((entry) => 'method' in entry && 'result' in entry);
|
|
109
|
+
}
|
|
110
|
+
exports.getScriptInvocations = getScriptInvocations;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ottochain-specific type definitions
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interfaces mirroring the Scala domain model for ottochain metagraphs.
|
|
5
|
+
* These types represent the on-chain state, fiber records, log entries, and message formats.
|
|
6
|
+
*
|
|
7
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Fiber sequence number (non-negative integer).
|
|
12
|
+
* Serializes as a plain number in JSON.
|
|
13
|
+
*
|
|
14
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/FiberOrdinal.scala
|
|
15
|
+
*/
|
|
16
|
+
export type FiberOrdinal = number;
|
|
17
|
+
/**
|
|
18
|
+
* Snapshot ordinal from the Constellation framework.
|
|
19
|
+
* Serializes as `{ value: number }` in JSON.
|
|
20
|
+
*/
|
|
21
|
+
export interface SnapshotOrdinal {
|
|
22
|
+
value: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* State identifier for state machines.
|
|
26
|
+
* Serializes as `{ value: string }` in JSON.
|
|
27
|
+
*
|
|
28
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/StateId.scala
|
|
29
|
+
*/
|
|
30
|
+
export interface StateId {
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Constellation network address (DAG address string).
|
|
35
|
+
*/
|
|
36
|
+
export type Address = string;
|
|
37
|
+
/**
|
|
38
|
+
* Hash value from the Constellation framework.
|
|
39
|
+
* Serializes as `{ value: string }` in JSON.
|
|
40
|
+
*/
|
|
41
|
+
export interface HashValue {
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* JSON logic value - arbitrary JSON data used for state data and payloads.
|
|
46
|
+
*/
|
|
47
|
+
export type JsonLogicValue = unknown;
|
|
48
|
+
/**
|
|
49
|
+
* JSON logic expression - a JsonLogic program definition.
|
|
50
|
+
*/
|
|
51
|
+
export type JsonLogicExpression = unknown;
|
|
52
|
+
/**
|
|
53
|
+
* Lifecycle status of a fiber.
|
|
54
|
+
*
|
|
55
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/FiberStatus.scala
|
|
56
|
+
*/
|
|
57
|
+
export type FiberStatus = 'Active' | 'Archived' | 'Failed';
|
|
58
|
+
/**
|
|
59
|
+
* Access control policy for script oracles.
|
|
60
|
+
*
|
|
61
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/AccessControlPolicy.scala
|
|
62
|
+
*/
|
|
63
|
+
export type AccessControlPolicy = {
|
|
64
|
+
Public: Record<string, never>;
|
|
65
|
+
} | {
|
|
66
|
+
Whitelist: {
|
|
67
|
+
addresses: Address[];
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
FiberOwned: {
|
|
71
|
+
fiberId: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Definition of a state machine's structure and transitions.
|
|
76
|
+
*
|
|
77
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/StateMachineDefinition.scala
|
|
78
|
+
*/
|
|
79
|
+
export interface StateMachineDefinition {
|
|
80
|
+
states: Record<string, unknown>;
|
|
81
|
+
initialState: StateId;
|
|
82
|
+
transitions: unknown[];
|
|
83
|
+
metadata?: JsonLogicValue;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Event emitted by a state machine transition trigger.
|
|
87
|
+
*
|
|
88
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/EmittedEvent.scala
|
|
89
|
+
*/
|
|
90
|
+
export interface EmittedEvent {
|
|
91
|
+
name: string;
|
|
92
|
+
data: JsonLogicValue;
|
|
93
|
+
destination?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Receipt of a state machine event processing.
|
|
97
|
+
* Emitted as a FiberLogEntry after each TransitionStateMachine.
|
|
98
|
+
*
|
|
99
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/FiberLogEntry.scala
|
|
100
|
+
*/
|
|
101
|
+
export interface EventReceipt {
|
|
102
|
+
fiberId: string;
|
|
103
|
+
sequenceNumber: FiberOrdinal;
|
|
104
|
+
eventName: string;
|
|
105
|
+
ordinal: SnapshotOrdinal;
|
|
106
|
+
fromState: StateId;
|
|
107
|
+
toState: StateId;
|
|
108
|
+
success: boolean;
|
|
109
|
+
gasUsed: number;
|
|
110
|
+
triggersFired: number;
|
|
111
|
+
errorMessage?: string;
|
|
112
|
+
sourceFiberId?: string;
|
|
113
|
+
emittedEvents: EmittedEvent[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Log entry for a script oracle invocation.
|
|
117
|
+
* Emitted as a FiberLogEntry after each InvokeScript.
|
|
118
|
+
*
|
|
119
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/fiber/FiberLogEntry.scala
|
|
120
|
+
*/
|
|
121
|
+
export interface OracleInvocation {
|
|
122
|
+
fiberId: string;
|
|
123
|
+
method: string;
|
|
124
|
+
args: JsonLogicValue;
|
|
125
|
+
result: JsonLogicValue;
|
|
126
|
+
gasUsed: number;
|
|
127
|
+
invokedAt: SnapshotOrdinal;
|
|
128
|
+
invokedBy: Address;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Union type for all fiber log entries.
|
|
132
|
+
* The runtime JSON is discriminated by the presence of type-specific fields.
|
|
133
|
+
*/
|
|
134
|
+
export type FiberLogEntry = EventReceipt | OracleInvocation;
|
|
135
|
+
/**
|
|
136
|
+
* On-chain record for a state machine fiber.
|
|
137
|
+
*
|
|
138
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Records.scala
|
|
139
|
+
*/
|
|
140
|
+
export interface StateMachineFiberRecord {
|
|
141
|
+
fiberId: string;
|
|
142
|
+
creationOrdinal: SnapshotOrdinal;
|
|
143
|
+
previousUpdateOrdinal: SnapshotOrdinal;
|
|
144
|
+
latestUpdateOrdinal: SnapshotOrdinal;
|
|
145
|
+
definition: StateMachineDefinition;
|
|
146
|
+
currentState: StateId;
|
|
147
|
+
stateData: JsonLogicValue;
|
|
148
|
+
stateDataHash: HashValue;
|
|
149
|
+
sequenceNumber: FiberOrdinal;
|
|
150
|
+
owners: Address[];
|
|
151
|
+
status: FiberStatus;
|
|
152
|
+
lastReceipt?: EventReceipt;
|
|
153
|
+
parentFiberId?: string;
|
|
154
|
+
childFiberIds: string[];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* On-chain record for a script oracle fiber.
|
|
158
|
+
*
|
|
159
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Records.scala
|
|
160
|
+
*/
|
|
161
|
+
export interface ScriptFiberRecord {
|
|
162
|
+
fiberId: string;
|
|
163
|
+
creationOrdinal: SnapshotOrdinal;
|
|
164
|
+
latestUpdateOrdinal: SnapshotOrdinal;
|
|
165
|
+
scriptProgram: JsonLogicExpression;
|
|
166
|
+
stateData?: JsonLogicValue;
|
|
167
|
+
stateDataHash?: HashValue;
|
|
168
|
+
accessControl: AccessControlPolicy;
|
|
169
|
+
sequenceNumber: FiberOrdinal;
|
|
170
|
+
owners: Address[];
|
|
171
|
+
status: FiberStatus;
|
|
172
|
+
lastInvocation?: OracleInvocation;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Union type for all fiber records.
|
|
176
|
+
*/
|
|
177
|
+
export type FiberRecord = StateMachineFiberRecord | ScriptFiberRecord;
|
|
178
|
+
/**
|
|
179
|
+
* Commit hash for a single fiber in the on-chain state.
|
|
180
|
+
*
|
|
181
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
|
|
182
|
+
*/
|
|
183
|
+
export interface FiberCommit {
|
|
184
|
+
recordHash: HashValue;
|
|
185
|
+
stateDataHash?: HashValue;
|
|
186
|
+
sequenceNumber: FiberOrdinal;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Full on-chain state of the ottochain metagraph.
|
|
190
|
+
*
|
|
191
|
+
* - `fiberCommits`: Map of fiber UUID → commit hashes (lightweight proof)
|
|
192
|
+
* - `latestLogs`: Map of fiber UUID → log entries from the current ordinal (ephemeral)
|
|
193
|
+
*
|
|
194
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/OnChain.scala
|
|
195
|
+
*/
|
|
196
|
+
export interface OnChain {
|
|
197
|
+
fiberCommits: Record<string, FiberCommit>;
|
|
198
|
+
latestLogs: Record<string, FiberLogEntry[]>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Full calculated state of the metagraph (served by ML0 /v1/ endpoints).
|
|
202
|
+
*
|
|
203
|
+
* Contains the materialized view of all fiber records, queryable by fiber type.
|
|
204
|
+
*/
|
|
205
|
+
export interface CalculatedState {
|
|
206
|
+
stateMachines: Record<string, StateMachineFiberRecord>;
|
|
207
|
+
scripts: Record<string, ScriptFiberRecord>;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a new state machine fiber.
|
|
211
|
+
*
|
|
212
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Updates.scala
|
|
213
|
+
*/
|
|
214
|
+
export interface CreateStateMachine {
|
|
215
|
+
fiberId: string;
|
|
216
|
+
definition: StateMachineDefinition;
|
|
217
|
+
initialData: JsonLogicValue;
|
|
218
|
+
parentFiberId?: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Trigger a state machine transition.
|
|
222
|
+
*
|
|
223
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Updates.scala
|
|
224
|
+
*/
|
|
225
|
+
export interface TransitionStateMachine {
|
|
226
|
+
fiberId: string;
|
|
227
|
+
eventName: string;
|
|
228
|
+
payload: JsonLogicValue;
|
|
229
|
+
targetSequenceNumber: FiberOrdinal;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Archive a state machine fiber.
|
|
233
|
+
*
|
|
234
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Updates.scala
|
|
235
|
+
*/
|
|
236
|
+
export interface ArchiveStateMachine {
|
|
237
|
+
fiberId: string;
|
|
238
|
+
targetSequenceNumber: FiberOrdinal;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Create a new script oracle fiber.
|
|
242
|
+
*
|
|
243
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Updates.scala
|
|
244
|
+
*/
|
|
245
|
+
export interface CreateScript {
|
|
246
|
+
fiberId: string;
|
|
247
|
+
scriptProgram: JsonLogicExpression;
|
|
248
|
+
initialState?: JsonLogicValue;
|
|
249
|
+
accessControl: AccessControlPolicy;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Invoke a script oracle.
|
|
253
|
+
*
|
|
254
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/Updates.scala
|
|
255
|
+
*/
|
|
256
|
+
export interface InvokeScript {
|
|
257
|
+
fiberId: string;
|
|
258
|
+
method: string;
|
|
259
|
+
args: JsonLogicValue;
|
|
260
|
+
targetSequenceNumber: FiberOrdinal;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Union type for all ottochain messages (DataUpdate payloads).
|
|
264
|
+
*
|
|
265
|
+
* JSON is wrapped as `{ MessageName: { ...fields } }` where MessageName
|
|
266
|
+
* is the class name (e.g., `{ CreateStateMachine: { fiberId: "...", ... } }`).
|
|
267
|
+
*/
|
|
268
|
+
export type OttochainMessage = {
|
|
269
|
+
CreateStateMachine: CreateStateMachine;
|
|
270
|
+
} | {
|
|
271
|
+
TransitionStateMachine: TransitionStateMachine;
|
|
272
|
+
} | {
|
|
273
|
+
ArchiveStateMachine: ArchiveStateMachine;
|
|
274
|
+
} | {
|
|
275
|
+
CreateScript: CreateScript;
|
|
276
|
+
} | {
|
|
277
|
+
InvokeScript: InvokeScript;
|
|
278
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ottochain-specific type definitions
|
|
4
|
+
*
|
|
5
|
+
* TypeScript interfaces mirroring the Scala domain model for ottochain metagraphs.
|
|
6
|
+
* These types represent the on-chain state, fiber records, log entries, and message formats.
|
|
7
|
+
*
|
|
8
|
+
* @see modules/models/src/main/scala/xyz/kd5ujc/schema/
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts Application
|
|
3
|
+
*
|
|
4
|
+
* Types and utilities for smart contracts on OttoChain.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import {
|
|
9
|
+
* ContractState,
|
|
10
|
+
* Contract,
|
|
11
|
+
* getContractDefinition,
|
|
12
|
+
* getEscrowDefinition
|
|
13
|
+
* } from '@ottochain/sdk/apps/contracts';
|
|
14
|
+
*
|
|
15
|
+
* const contractDef = getContractDefinition();
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
export { ContractState, Contract, ProposeContractRequest, AcceptContractRequest, CompleteContractRequest, RejectContractRequest, DisputeContractRequest, ContractDefinition, contractStateFromJSON, contractStateToJSON, } from '../../generated/ottochain/apps/contracts/v1/contract.js';
|
|
21
|
+
export type ContractDefinitionType = 'Contract' | 'Escrow';
|
|
22
|
+
export declare const CONTRACT_DEFINITIONS: Record<ContractDefinitionType, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Get the contract state machine definition.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getContractDefinition(): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Get the escrow state machine definition.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getEscrowDefinition(): unknown;
|
|
@@ -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;
|