@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,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markets Application Types
|
|
3
|
+
*
|
|
4
|
+
* Constants, types, and utilities for the Markets application on OttoChain.
|
|
5
|
+
*
|
|
6
|
+
* Core types (MarketType, MarketState, Market, Commitment, Resolution) are
|
|
7
|
+
* exported from proto-generated types in index.ts.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import { MarketType, MarketState } from '../../generated/ottochain/apps/markets/v1/market_pb.js';
|
|
12
|
+
/**
|
|
13
|
+
* Commitment direction (for prediction markets)
|
|
14
|
+
*/
|
|
15
|
+
export declare enum CommitmentSide {
|
|
16
|
+
UNSPECIFIED = 0,
|
|
17
|
+
YES = 1,
|
|
18
|
+
NO = 2
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Market configuration type
|
|
22
|
+
*/
|
|
23
|
+
export interface MarketConfig {
|
|
24
|
+
/** Platform fee as percentage (0.01 = 1%) */
|
|
25
|
+
platformFeePercent: number;
|
|
26
|
+
/** Market creator fee as percentage */
|
|
27
|
+
creatorFeePercent: number;
|
|
28
|
+
/** Oracle fee as percentage */
|
|
29
|
+
oracleFeePercent: number;
|
|
30
|
+
/** Minimum quorum for market validity (in tokens) */
|
|
31
|
+
minQuorum: bigint;
|
|
32
|
+
/** Default resolution window in epochs */
|
|
33
|
+
resolutionWindowEpochs: number;
|
|
34
|
+
/** Dispute window after resolution in epochs */
|
|
35
|
+
disputeWindowEpochs: number;
|
|
36
|
+
/** Minimum commitment amount */
|
|
37
|
+
minCommitment: bigint;
|
|
38
|
+
/** Maximum slippage for AMM-style markets */
|
|
39
|
+
maxSlippagePercent: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Default market configuration
|
|
43
|
+
*/
|
|
44
|
+
export declare const DEFAULT_MARKET_CONFIG: MarketConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Type-specific market configurations
|
|
47
|
+
*/
|
|
48
|
+
export declare const MARKET_TYPE_CONFIGS: Record<MarketType, Partial<MarketConfig>>;
|
|
49
|
+
/**
|
|
50
|
+
* Valid transitions for each market state (aligned with proto MarketState enum)
|
|
51
|
+
*/
|
|
52
|
+
export declare const MARKET_TRANSITIONS: Record<MarketState, readonly string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a market state is terminal
|
|
55
|
+
*/
|
|
56
|
+
export declare function isTerminalMarketState(state: MarketState): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Calculate effective commitment after fees
|
|
59
|
+
*
|
|
60
|
+
* @param amount - Raw commitment amount
|
|
61
|
+
* @param config - Market configuration (uses defaults if not provided)
|
|
62
|
+
* @returns Net commitment amount after platform fees
|
|
63
|
+
*/
|
|
64
|
+
export declare function calculateNetCommitment(amount: bigint, config?: Partial<MarketConfig>): bigint;
|
|
65
|
+
/**
|
|
66
|
+
* Calculate total fees for a commitment
|
|
67
|
+
*
|
|
68
|
+
* @param amount - Commitment amount
|
|
69
|
+
* @param marketType - Type of market for type-specific fees
|
|
70
|
+
* @returns Fee breakdown object
|
|
71
|
+
*/
|
|
72
|
+
export declare function calculateFees(amount: bigint, marketType?: MarketType): {
|
|
73
|
+
platform: bigint;
|
|
74
|
+
creator: bigint;
|
|
75
|
+
oracle: bigint;
|
|
76
|
+
total: bigint;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Outcome shares for payout calculation
|
|
80
|
+
*/
|
|
81
|
+
export interface OutcomeShares {
|
|
82
|
+
/** Total committed to winning outcome */
|
|
83
|
+
winningPool: bigint;
|
|
84
|
+
/** Total committed to losing outcome(s) */
|
|
85
|
+
losingPool: bigint;
|
|
86
|
+
/** Individual's commitment to winning outcome */
|
|
87
|
+
userCommitment: bigint;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Calculate payout for a winning commitment in a prediction market
|
|
91
|
+
*
|
|
92
|
+
* Winner receives: their original + proportional share of losing pool (minus fees)
|
|
93
|
+
*
|
|
94
|
+
* @param shares - Pool and commitment details
|
|
95
|
+
* @param marketType - Type of market for fee calculation
|
|
96
|
+
* @returns Payout amount
|
|
97
|
+
*/
|
|
98
|
+
export declare function calculatePayout(shares: OutcomeShares, marketType?: MarketType): bigint;
|
|
99
|
+
/**
|
|
100
|
+
* Calculate refund for cancelled market
|
|
101
|
+
*
|
|
102
|
+
* @param commitment - Original commitment amount
|
|
103
|
+
* @param refundFeePercent - Optional fee retained on refund (default 0)
|
|
104
|
+
* @returns Refund amount
|
|
105
|
+
*/
|
|
106
|
+
export declare function calculateRefund(commitment: bigint, refundFeePercent?: number): bigint;
|
|
107
|
+
/**
|
|
108
|
+
* Validate a commitment meets market requirements
|
|
109
|
+
*/
|
|
110
|
+
export interface CommitmentValidation {
|
|
111
|
+
valid: boolean;
|
|
112
|
+
reason?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validate a commitment against market rules
|
|
116
|
+
*/
|
|
117
|
+
export declare function validateCommitment(amount: bigint, marketState: MarketState, config?: Partial<MarketConfig>): CommitmentValidation;
|
|
118
|
+
/**
|
|
119
|
+
* Calculate crowdfund progress
|
|
120
|
+
*/
|
|
121
|
+
export interface CrowdfundProgress {
|
|
122
|
+
/** Current total committed */
|
|
123
|
+
current: bigint;
|
|
124
|
+
/** Target goal */
|
|
125
|
+
goal: bigint;
|
|
126
|
+
/** Percentage complete (0-100) */
|
|
127
|
+
percentComplete: number;
|
|
128
|
+
/** Whether goal has been reached */
|
|
129
|
+
goalReached: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Calculate crowdfund campaign progress
|
|
133
|
+
*/
|
|
134
|
+
export declare function calculateCrowdfundProgress(current: bigint, goal: bigint): CrowdfundProgress;
|
|
135
|
+
/**
|
|
136
|
+
* Tier definition for group buys
|
|
137
|
+
*/
|
|
138
|
+
export interface GroupBuyTier {
|
|
139
|
+
/** Minimum participants for this tier */
|
|
140
|
+
minParticipants: number;
|
|
141
|
+
/** Discount percentage for this tier */
|
|
142
|
+
discountPercent: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Calculate applicable discount based on participant count
|
|
146
|
+
*/
|
|
147
|
+
export declare function calculateGroupBuyDiscount(participantCount: number, tiers: GroupBuyTier[]): number;
|
|
148
|
+
/**
|
|
149
|
+
* Check if a value is a valid MarketState
|
|
150
|
+
*/
|
|
151
|
+
export declare function isMarketState(value: unknown): value is MarketState;
|
|
152
|
+
/**
|
|
153
|
+
* Check if a value is a valid MarketType
|
|
154
|
+
*/
|
|
155
|
+
export declare function isMarketType(value: unknown): value is MarketType;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracles Application
|
|
3
|
+
*
|
|
4
|
+
* Types and utilities for oracles on OttoChain.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import {
|
|
9
|
+
* OracleState,
|
|
10
|
+
* Oracle,
|
|
11
|
+
* getOracleDefinition,
|
|
12
|
+
* DEFAULT_ORACLE_CONFIG
|
|
13
|
+
* } from '@ottochain/sdk/apps/oracles';
|
|
14
|
+
*
|
|
15
|
+
* const oracleDef = getOracleDefinition();
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
export { OracleState, OracleReputation, SlashingEvent, Oracle, RegisterOracleRequest, ActivateOracleRequest, AddStakeRequest, WithdrawStakeRequest, SlashOracleRequest, WithdrawOracleRequest, OracleDefinition, oracleStateFromJSON, oracleStateToJSON, } from '../../generated/ottochain/apps/oracles/v1/oracle.js';
|
|
21
|
+
export type OracleDefinitionType = 'Oracle';
|
|
22
|
+
export declare const ORACLE_DEFINITIONS: Record<OracleDefinitionType, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Get the oracle state machine definition.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getOracleDefinition(type?: OracleDefinitionType): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Default oracle configuration.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_ORACLE_CONFIG: {
|
|
31
|
+
minStake: number;
|
|
32
|
+
baseReputation: number;
|
|
33
|
+
reputationDecay: number;
|
|
34
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracles Application Types
|
|
3
|
+
*
|
|
4
|
+
* Constants, types, and utilities for the Oracle system on OttoChain.
|
|
5
|
+
* Oracles provide truth resolution for markets and disputes.
|
|
6
|
+
*
|
|
7
|
+
* Core types (OracleState, Oracle, etc.) are exported from proto-generated
|
|
8
|
+
* types in index.ts.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import { OracleState } from '../../generated/ottochain/apps/oracles/v1/oracle_pb.js';
|
|
13
|
+
/**
|
|
14
|
+
* Types of oracle resolutions
|
|
15
|
+
*/
|
|
16
|
+
export declare enum ResolutionType {
|
|
17
|
+
UNSPECIFIED = 0,
|
|
18
|
+
/** Binary yes/no outcome */
|
|
19
|
+
BINARY = 1,
|
|
20
|
+
/** One of multiple predefined outcomes */
|
|
21
|
+
MULTI_CHOICE = 2,
|
|
22
|
+
/** Numeric value (e.g., price) */
|
|
23
|
+
NUMERIC = 3,
|
|
24
|
+
/** Free-form attestation */
|
|
25
|
+
ATTESTATION = 4
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reasons for slashing oracle stake
|
|
29
|
+
*/
|
|
30
|
+
export declare enum SlashingReason {
|
|
31
|
+
UNSPECIFIED = 0,
|
|
32
|
+
/** Failed to submit resolution in time */
|
|
33
|
+
TIMEOUT = 1,
|
|
34
|
+
/** Resolution overturned by dispute */
|
|
35
|
+
INCORRECT_RESOLUTION = 2,
|
|
36
|
+
/** Evidence of collusion or manipulation */
|
|
37
|
+
COLLUSION = 3,
|
|
38
|
+
/** Violation of oracle protocol */
|
|
39
|
+
PROTOCOL_VIOLATION = 4
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Oracle configuration type
|
|
43
|
+
*/
|
|
44
|
+
export interface OracleConfig {
|
|
45
|
+
/** Minimum stake required to become an oracle (in base units) */
|
|
46
|
+
minStake: bigint;
|
|
47
|
+
/** Stake slashed for timeout (percentage) */
|
|
48
|
+
timeoutSlashPercent: number;
|
|
49
|
+
/** Stake slashed for incorrect resolution (percentage) */
|
|
50
|
+
incorrectSlashPercent: number;
|
|
51
|
+
/** Stake slashed for collusion (percentage) */
|
|
52
|
+
collusionSlashPercent: number;
|
|
53
|
+
/** Stake slashed for protocol violation (percentage) */
|
|
54
|
+
violationSlashPercent: number;
|
|
55
|
+
/** Epochs to wait before withdrawal after unstaking */
|
|
56
|
+
cooldownEpochs: number;
|
|
57
|
+
/** Base reputation for new oracles */
|
|
58
|
+
baseReputation: number;
|
|
59
|
+
/** Minimum reputation to accept high-value markets */
|
|
60
|
+
highValueThreshold: number;
|
|
61
|
+
/** Resolution window in epochs */
|
|
62
|
+
resolutionWindowEpochs: number;
|
|
63
|
+
/** Challenge window after submission in epochs */
|
|
64
|
+
challengeWindowEpochs: number;
|
|
65
|
+
/** Reward percentage from resolved market fees */
|
|
66
|
+
oracleRewardPercent: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Default oracle configuration
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFAULT_ORACLE_CONFIG: OracleConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Slashing percentages by reason
|
|
74
|
+
*/
|
|
75
|
+
export declare const SLASHING_PERCENTAGES: Record<SlashingReason, number>;
|
|
76
|
+
/**
|
|
77
|
+
* Valid transitions for each oracle state (aligned with proto OracleState enum)
|
|
78
|
+
*/
|
|
79
|
+
export declare const ORACLE_TRANSITIONS: Record<OracleState, readonly string[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Check if an oracle state is terminal
|
|
82
|
+
*/
|
|
83
|
+
export declare function isTerminalOracleState(state: OracleState): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Check if an oracle can accept new assignments
|
|
86
|
+
*/
|
|
87
|
+
export declare function canAcceptAssignment(state: OracleState): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Reputation update factors
|
|
90
|
+
*/
|
|
91
|
+
export declare const REPUTATION_DELTAS: {
|
|
92
|
+
/** Successfully resolved market without challenge */
|
|
93
|
+
readonly successfulResolution: 5;
|
|
94
|
+
/** Resolution upheld after challenge */
|
|
95
|
+
readonly upheldChallenge: 10;
|
|
96
|
+
/** Resolution overturned (negative) */
|
|
97
|
+
readonly overturnedResolution: -25;
|
|
98
|
+
/** Timeout on assigned market (negative) */
|
|
99
|
+
readonly timeout: -15;
|
|
100
|
+
/** Collusion detected (negative) */
|
|
101
|
+
readonly collusion: -100;
|
|
102
|
+
/** Protocol violation (negative) */
|
|
103
|
+
readonly violation: -20;
|
|
104
|
+
/** Bonus for high-value market resolution */
|
|
105
|
+
readonly highValueBonus: 3;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Calculate new reputation after an event
|
|
109
|
+
*
|
|
110
|
+
* @param currentReputation - Current reputation score
|
|
111
|
+
* @param delta - Reputation change (positive or negative)
|
|
112
|
+
* @param minReputation - Minimum reputation floor (default 0)
|
|
113
|
+
* @returns New reputation score
|
|
114
|
+
*/
|
|
115
|
+
export declare function calculateReputation(currentReputation: number, delta: number, minReputation?: number): number;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate weighted reputation considering history
|
|
118
|
+
*
|
|
119
|
+
* @param baseReputation - Current base reputation
|
|
120
|
+
* @param successCount - Number of successful resolutions
|
|
121
|
+
* @param failureCount - Number of failed/overturned resolutions
|
|
122
|
+
* @returns Weighted reputation score
|
|
123
|
+
*/
|
|
124
|
+
export declare function calculateWeightedReputation(baseReputation: number, successCount: number, failureCount: number): number;
|
|
125
|
+
/**
|
|
126
|
+
* Check if oracle qualifies for high-value markets
|
|
127
|
+
*/
|
|
128
|
+
export declare function qualifiesForHighValue(reputation: number, stake: bigint, threshold?: number, minStakeMultiplier?: number): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Slashing condition definition
|
|
131
|
+
*/
|
|
132
|
+
export interface SlashingCondition {
|
|
133
|
+
reason: SlashingReason;
|
|
134
|
+
slashPercent: number;
|
|
135
|
+
description: string;
|
|
136
|
+
appealable: boolean;
|
|
137
|
+
suspensionEpochs: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Predefined slashing conditions
|
|
141
|
+
*/
|
|
142
|
+
export declare const SLASHING_CONDITIONS: Record<SlashingReason, SlashingCondition>;
|
|
143
|
+
/**
|
|
144
|
+
* Calculate slash amount for a given stake and reason
|
|
145
|
+
*
|
|
146
|
+
* @param stake - Oracle's current stake
|
|
147
|
+
* @param reason - Reason for slashing
|
|
148
|
+
* @returns Amount to be slashed
|
|
149
|
+
*/
|
|
150
|
+
export declare function calculateSlashAmount(stake: bigint, reason: SlashingReason): bigint;
|
|
151
|
+
/**
|
|
152
|
+
* Calculate remaining stake after slashing
|
|
153
|
+
*/
|
|
154
|
+
export declare function calculateStakeAfterSlash(stake: bigint, reason: SlashingReason): bigint;
|
|
155
|
+
/**
|
|
156
|
+
* Oracle candidate for selection
|
|
157
|
+
*/
|
|
158
|
+
export interface OracleCandidate {
|
|
159
|
+
address: string;
|
|
160
|
+
reputation: number;
|
|
161
|
+
stake: bigint;
|
|
162
|
+
activeAssignments: number;
|
|
163
|
+
successRate: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Calculate oracle selection score
|
|
167
|
+
* Higher score = more likely to be selected
|
|
168
|
+
*
|
|
169
|
+
* @param candidate - Oracle candidate details
|
|
170
|
+
* @param marketValue - Value of market to resolve (affects weight for high-value markets)
|
|
171
|
+
* @returns Selection score
|
|
172
|
+
*/
|
|
173
|
+
export declare function calculateSelectionScore(candidate: OracleCandidate, marketValue?: bigint): number;
|
|
174
|
+
/**
|
|
175
|
+
* Calculate oracle reward for successful resolution
|
|
176
|
+
*
|
|
177
|
+
* @param marketFees - Total fees collected from market
|
|
178
|
+
* @param rewardPercent - Oracle's reward percentage (default from config)
|
|
179
|
+
* @returns Oracle reward amount
|
|
180
|
+
*/
|
|
181
|
+
export declare function calculateOracleReward(marketFees: bigint, rewardPercent?: number): bigint;
|
|
182
|
+
/**
|
|
183
|
+
* Check if a value is a valid OracleState
|
|
184
|
+
*/
|
|
185
|
+
export declare function isOracleState(value: unknown): value is OracleState;
|
|
186
|
+
/**
|
|
187
|
+
* Check if a value is a valid SlashingReason
|
|
188
|
+
*/
|
|
189
|
+
export declare function isSlashingReason(value: unknown): value is SlashingReason;
|
|
190
|
+
/**
|
|
191
|
+
* Check if a value is a valid ResolutionType
|
|
192
|
+
*/
|
|
193
|
+
export declare function isResolutionType(value: unknown): value is ResolutionType;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error Classes for OttoChain SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides structured error handling with error codes and causes.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Error codes for OttoChain SDK errors
|
|
10
|
+
*/
|
|
11
|
+
export declare enum ErrorCode {
|
|
12
|
+
/** Unknown or unclassified error */
|
|
13
|
+
UNKNOWN = "UNKNOWN",
|
|
14
|
+
/** Network/HTTP connection failure */
|
|
15
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
16
|
+
/** Request timeout */
|
|
17
|
+
NETWORK_TIMEOUT = "NETWORK_TIMEOUT",
|
|
18
|
+
/** Input validation failed */
|
|
19
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
20
|
+
/** Invalid private key format */
|
|
21
|
+
INVALID_PRIVATE_KEY = "INVALID_PRIVATE_KEY",
|
|
22
|
+
/** Invalid public key format */
|
|
23
|
+
INVALID_PUBLIC_KEY = "INVALID_PUBLIC_KEY",
|
|
24
|
+
/** Invalid DAG address format */
|
|
25
|
+
INVALID_ADDRESS = "INVALID_ADDRESS",
|
|
26
|
+
/** Signature creation failed */
|
|
27
|
+
SIGNING_ERROR = "SIGNING_ERROR",
|
|
28
|
+
/** Signature verification failed */
|
|
29
|
+
VERIFICATION_ERROR = "VERIFICATION_ERROR",
|
|
30
|
+
/** Transaction rejected by network */
|
|
31
|
+
TRANSACTION_REJECTED = "TRANSACTION_REJECTED",
|
|
32
|
+
/** Transaction not found */
|
|
33
|
+
TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
|
|
34
|
+
/** Invalid transaction format */
|
|
35
|
+
INVALID_TRANSACTION = "INVALID_TRANSACTION"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Base error class for all OttoChain SDK errors
|
|
39
|
+
*
|
|
40
|
+
* Provides consistent error structure with:
|
|
41
|
+
* - Error code for programmatic handling
|
|
42
|
+
* - Human-readable message
|
|
43
|
+
* - Optional cause for error chaining
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* try {
|
|
48
|
+
* await signTransaction(data, invalidKey);
|
|
49
|
+
* } catch (error) {
|
|
50
|
+
* if (error instanceof OttoChainError) {
|
|
51
|
+
* console.log(error.code); // 'INVALID_PRIVATE_KEY'
|
|
52
|
+
* console.log(error.message); // 'Invalid private key format'
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare class OttoChainError extends Error {
|
|
58
|
+
/** Error code for programmatic handling */
|
|
59
|
+
readonly code: ErrorCode;
|
|
60
|
+
/** Original error that caused this error */
|
|
61
|
+
readonly cause?: Error;
|
|
62
|
+
constructor(code: ErrorCode, message: string, cause?: Error);
|
|
63
|
+
/**
|
|
64
|
+
* Create a string representation of the error
|
|
65
|
+
*/
|
|
66
|
+
toString(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Convert error to a plain object for logging/serialization
|
|
69
|
+
*/
|
|
70
|
+
toJSON(): Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Error thrown when network operations fail
|
|
74
|
+
*
|
|
75
|
+
* Covers HTTP failures, connection errors, and timeouts.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* try {
|
|
80
|
+
* await client.postTransaction(signed);
|
|
81
|
+
* } catch (error) {
|
|
82
|
+
* if (error instanceof NetworkError) {
|
|
83
|
+
* console.log(error.statusCode); // 503
|
|
84
|
+
* console.log(error.responseBody); // '{"error": "Service unavailable"}'
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare class NetworkError extends OttoChainError {
|
|
90
|
+
/** HTTP status code if applicable */
|
|
91
|
+
readonly statusCode?: number;
|
|
92
|
+
/** Response body if available */
|
|
93
|
+
readonly responseBody?: string;
|
|
94
|
+
constructor(message: string, statusCode?: number, responseBody?: string, cause?: Error);
|
|
95
|
+
/**
|
|
96
|
+
* Create a timeout error
|
|
97
|
+
*/
|
|
98
|
+
static timeout(timeoutMs: number): NetworkError;
|
|
99
|
+
toJSON(): Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Error thrown when input validation fails
|
|
103
|
+
*
|
|
104
|
+
* Used when function parameters don't meet expected format or constraints.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* try {
|
|
109
|
+
* const keyPair = keyPairFromPrivateKey('invalid');
|
|
110
|
+
* } catch (error) {
|
|
111
|
+
* if (error instanceof ValidationError) {
|
|
112
|
+
* console.log(error.field); // 'privateKey'
|
|
113
|
+
* console.log(error.value); // 'invalid'
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare class ValidationError extends OttoChainError {
|
|
119
|
+
/** Field that failed validation */
|
|
120
|
+
readonly field?: string;
|
|
121
|
+
/** Value that failed validation (sanitized) */
|
|
122
|
+
readonly value?: unknown;
|
|
123
|
+
/** Validation details/constraints */
|
|
124
|
+
readonly details?: Record<string, unknown>;
|
|
125
|
+
constructor(message: string, options?: {
|
|
126
|
+
field?: string;
|
|
127
|
+
value?: unknown;
|
|
128
|
+
details?: Record<string, unknown>;
|
|
129
|
+
cause?: Error;
|
|
130
|
+
});
|
|
131
|
+
toJSON(): Record<string, unknown>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Error thrown when cryptographic signing operations fail
|
|
135
|
+
*
|
|
136
|
+
* Covers key derivation, signature creation, and related crypto operations.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* try {
|
|
141
|
+
* const signature = await signHash(hash, privateKey);
|
|
142
|
+
* } catch (error) {
|
|
143
|
+
* if (error instanceof SigningError) {
|
|
144
|
+
* console.log(error.operation); // 'sign'
|
|
145
|
+
* }
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare class SigningError extends OttoChainError {
|
|
150
|
+
/** The operation that failed */
|
|
151
|
+
readonly operation?: string;
|
|
152
|
+
constructor(message: string, options?: {
|
|
153
|
+
operation?: string;
|
|
154
|
+
cause?: Error;
|
|
155
|
+
});
|
|
156
|
+
toJSON(): Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Error thrown when transaction operations fail
|
|
160
|
+
*
|
|
161
|
+
* Used when transactions are rejected, not found, or invalid.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* try {
|
|
166
|
+
* await client.postTransaction(signed);
|
|
167
|
+
* } catch (error) {
|
|
168
|
+
* if (error instanceof TransactionError) {
|
|
169
|
+
* console.log(error.transactionHash); // 'abc123...'
|
|
170
|
+
* console.log(error.rejectionReason); // 'Insufficient balance'
|
|
171
|
+
* }
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare class TransactionError extends OttoChainError {
|
|
176
|
+
/** Transaction hash if available */
|
|
177
|
+
readonly transactionHash?: string;
|
|
178
|
+
/** Reason for rejection if available */
|
|
179
|
+
readonly rejectionReason?: string;
|
|
180
|
+
constructor(code: ErrorCode, message: string, options?: {
|
|
181
|
+
transactionHash?: string;
|
|
182
|
+
rejectionReason?: string;
|
|
183
|
+
cause?: Error;
|
|
184
|
+
});
|
|
185
|
+
/**
|
|
186
|
+
* Create a transaction rejected error
|
|
187
|
+
*/
|
|
188
|
+
static rejected(reason: string, transactionHash?: string): TransactionError;
|
|
189
|
+
/**
|
|
190
|
+
* Create a transaction not found error
|
|
191
|
+
*/
|
|
192
|
+
static notFound(transactionHash: string): TransactionError;
|
|
193
|
+
/**
|
|
194
|
+
* Create an invalid transaction error
|
|
195
|
+
*/
|
|
196
|
+
static invalid(message: string, cause?: Error): TransactionError;
|
|
197
|
+
toJSON(): Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if an error is an OttoChain error with a specific code
|
|
201
|
+
*
|
|
202
|
+
* @param error - Error to check
|
|
203
|
+
* @param code - Error code to match
|
|
204
|
+
* @returns True if error matches the code
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* if (isErrorCode(error, ErrorCode.NETWORK_TIMEOUT)) {
|
|
209
|
+
* // Retry the request
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export declare function isErrorCode(error: unknown, code: ErrorCode): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Wrap an unknown error in an OttoChainError
|
|
216
|
+
*
|
|
217
|
+
* @param error - Error to wrap
|
|
218
|
+
* @param defaultMessage - Default message if error has no message
|
|
219
|
+
* @returns OttoChainError wrapping the original error
|
|
220
|
+
*/
|
|
221
|
+
export declare function wrapError(error: unknown, defaultMessage?: string): OttoChainError;
|