@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,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metakit SDK
|
|
3
|
+
*
|
|
4
|
+
* Reusable signing, encoding, and network operations for Constellation metagraphs.
|
|
5
|
+
* This module is framework-level functionality, independent of any specific metagraph domain.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type { SignatureProof, Signed, KeyPair, Hash, VerificationResult, SigningOptions, } from './types.js';
|
|
10
|
+
export { ALGORITHM, CONSTELLATION_PREFIX } from './types.js';
|
|
11
|
+
export { canonicalize } from './canonicalize.js';
|
|
12
|
+
export { toBytes, encodeDataUpdate } from './binary.js';
|
|
13
|
+
export { hash, hashBytes, hashData, computeDigest } from './hash.js';
|
|
14
|
+
export { decodeDataUpdate } from './codec.js';
|
|
15
|
+
export { sign, signDataUpdate, signHash } from './sign.js';
|
|
16
|
+
export { verify, verifyHash, verifySignature } from './verify.js';
|
|
17
|
+
export { createSignedObject, addSignature, batchSign } from './signed-object.js';
|
|
18
|
+
export { generateKeyPair, keyPairFromPrivateKey, getPublicKeyHex, getPublicKeyId, getAddress, isValidPrivateKey, isValidPublicKey, } from './wallet.js';
|
|
19
|
+
export type { TransactionReference, CurrencyTransactionValue, CurrencyTransaction, TransferParams, } from './currency-types.js';
|
|
20
|
+
export { TOKEN_DECIMALS } from './currency-types.js';
|
|
21
|
+
export { createCurrencyTransaction, createCurrencyTransactionBatch, signCurrencyTransaction, verifyCurrencyTransaction, encodeCurrencyTransaction, hashCurrencyTransaction, getTransactionReference, isValidDagAddress, tokenToUnits, unitsToToken, } from './currency-transaction.js';
|
|
22
|
+
export { CurrencyL1Client, DataL1Client, HttpClient, NetworkError } from './network/index.js';
|
|
23
|
+
export type { NetworkConfig, RequestOptions, TransactionStatus, PendingTransaction, PostTransactionResponse, EstimateFeeResponse, PostDataResponse, } from './network/index.js';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Metakit SDK
|
|
4
|
+
*
|
|
5
|
+
* Reusable signing, encoding, and network operations for Constellation metagraphs.
|
|
6
|
+
* This module is framework-level functionality, independent of any specific metagraph domain.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.NetworkError = exports.HttpClient = exports.DataL1Client = exports.CurrencyL1Client = exports.unitsToToken = exports.tokenToUnits = exports.isValidDagAddress = exports.getTransactionReference = exports.hashCurrencyTransaction = exports.encodeCurrencyTransaction = exports.verifyCurrencyTransaction = exports.signCurrencyTransaction = exports.createCurrencyTransactionBatch = exports.createCurrencyTransaction = exports.TOKEN_DECIMALS = exports.isValidPublicKey = exports.isValidPrivateKey = exports.getAddress = exports.getPublicKeyId = exports.getPublicKeyHex = exports.keyPairFromPrivateKey = exports.generateKeyPair = exports.batchSign = exports.addSignature = exports.createSignedObject = exports.verifySignature = exports.verifyHash = exports.verify = exports.signHash = exports.signDataUpdate = exports.sign = exports.decodeDataUpdate = exports.computeDigest = exports.hashData = exports.hashBytes = exports.hash = exports.encodeDataUpdate = exports.toBytes = exports.canonicalize = exports.CONSTELLATION_PREFIX = exports.ALGORITHM = void 0;
|
|
12
|
+
var types_js_1 = require("./types.js");
|
|
13
|
+
Object.defineProperty(exports, "ALGORITHM", { enumerable: true, get: function () { return types_js_1.ALGORITHM; } });
|
|
14
|
+
Object.defineProperty(exports, "CONSTELLATION_PREFIX", { enumerable: true, get: function () { return types_js_1.CONSTELLATION_PREFIX; } });
|
|
15
|
+
// Canonicalization
|
|
16
|
+
var canonicalize_js_1 = require("./canonicalize.js");
|
|
17
|
+
Object.defineProperty(exports, "canonicalize", { enumerable: true, get: function () { return canonicalize_js_1.canonicalize; } });
|
|
18
|
+
// Binary encoding
|
|
19
|
+
var binary_js_1 = require("./binary.js");
|
|
20
|
+
Object.defineProperty(exports, "toBytes", { enumerable: true, get: function () { return binary_js_1.toBytes; } });
|
|
21
|
+
Object.defineProperty(exports, "encodeDataUpdate", { enumerable: true, get: function () { return binary_js_1.encodeDataUpdate; } });
|
|
22
|
+
// Hashing
|
|
23
|
+
var hash_js_1 = require("./hash.js");
|
|
24
|
+
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return hash_js_1.hash; } });
|
|
25
|
+
Object.defineProperty(exports, "hashBytes", { enumerable: true, get: function () { return hash_js_1.hashBytes; } });
|
|
26
|
+
Object.defineProperty(exports, "hashData", { enumerable: true, get: function () { return hash_js_1.hashData; } });
|
|
27
|
+
Object.defineProperty(exports, "computeDigest", { enumerable: true, get: function () { return hash_js_1.computeDigest; } });
|
|
28
|
+
// Codec utilities
|
|
29
|
+
var codec_js_1 = require("./codec.js");
|
|
30
|
+
Object.defineProperty(exports, "decodeDataUpdate", { enumerable: true, get: function () { return codec_js_1.decodeDataUpdate; } });
|
|
31
|
+
// Signing
|
|
32
|
+
var sign_js_1 = require("./sign.js");
|
|
33
|
+
Object.defineProperty(exports, "sign", { enumerable: true, get: function () { return sign_js_1.sign; } });
|
|
34
|
+
Object.defineProperty(exports, "signDataUpdate", { enumerable: true, get: function () { return sign_js_1.signDataUpdate; } });
|
|
35
|
+
Object.defineProperty(exports, "signHash", { enumerable: true, get: function () { return sign_js_1.signHash; } });
|
|
36
|
+
// Verification
|
|
37
|
+
var verify_js_1 = require("./verify.js");
|
|
38
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_js_1.verify; } });
|
|
39
|
+
Object.defineProperty(exports, "verifyHash", { enumerable: true, get: function () { return verify_js_1.verifyHash; } });
|
|
40
|
+
Object.defineProperty(exports, "verifySignature", { enumerable: true, get: function () { return verify_js_1.verifySignature; } });
|
|
41
|
+
// High-level API
|
|
42
|
+
var signed_object_js_1 = require("./signed-object.js");
|
|
43
|
+
Object.defineProperty(exports, "createSignedObject", { enumerable: true, get: function () { return signed_object_js_1.createSignedObject; } });
|
|
44
|
+
Object.defineProperty(exports, "addSignature", { enumerable: true, get: function () { return signed_object_js_1.addSignature; } });
|
|
45
|
+
Object.defineProperty(exports, "batchSign", { enumerable: true, get: function () { return signed_object_js_1.batchSign; } });
|
|
46
|
+
// Wallet utilities
|
|
47
|
+
var wallet_js_1 = require("./wallet.js");
|
|
48
|
+
Object.defineProperty(exports, "generateKeyPair", { enumerable: true, get: function () { return wallet_js_1.generateKeyPair; } });
|
|
49
|
+
Object.defineProperty(exports, "keyPairFromPrivateKey", { enumerable: true, get: function () { return wallet_js_1.keyPairFromPrivateKey; } });
|
|
50
|
+
Object.defineProperty(exports, "getPublicKeyHex", { enumerable: true, get: function () { return wallet_js_1.getPublicKeyHex; } });
|
|
51
|
+
Object.defineProperty(exports, "getPublicKeyId", { enumerable: true, get: function () { return wallet_js_1.getPublicKeyId; } });
|
|
52
|
+
Object.defineProperty(exports, "getAddress", { enumerable: true, get: function () { return wallet_js_1.getAddress; } });
|
|
53
|
+
Object.defineProperty(exports, "isValidPrivateKey", { enumerable: true, get: function () { return wallet_js_1.isValidPrivateKey; } });
|
|
54
|
+
Object.defineProperty(exports, "isValidPublicKey", { enumerable: true, get: function () { return wallet_js_1.isValidPublicKey; } });
|
|
55
|
+
var currency_types_js_1 = require("./currency-types.js");
|
|
56
|
+
Object.defineProperty(exports, "TOKEN_DECIMALS", { enumerable: true, get: function () { return currency_types_js_1.TOKEN_DECIMALS; } });
|
|
57
|
+
// Currency transaction operations
|
|
58
|
+
var currency_transaction_js_1 = require("./currency-transaction.js");
|
|
59
|
+
Object.defineProperty(exports, "createCurrencyTransaction", { enumerable: true, get: function () { return currency_transaction_js_1.createCurrencyTransaction; } });
|
|
60
|
+
Object.defineProperty(exports, "createCurrencyTransactionBatch", { enumerable: true, get: function () { return currency_transaction_js_1.createCurrencyTransactionBatch; } });
|
|
61
|
+
Object.defineProperty(exports, "signCurrencyTransaction", { enumerable: true, get: function () { return currency_transaction_js_1.signCurrencyTransaction; } });
|
|
62
|
+
Object.defineProperty(exports, "verifyCurrencyTransaction", { enumerable: true, get: function () { return currency_transaction_js_1.verifyCurrencyTransaction; } });
|
|
63
|
+
Object.defineProperty(exports, "encodeCurrencyTransaction", { enumerable: true, get: function () { return currency_transaction_js_1.encodeCurrencyTransaction; } });
|
|
64
|
+
Object.defineProperty(exports, "hashCurrencyTransaction", { enumerable: true, get: function () { return currency_transaction_js_1.hashCurrencyTransaction; } });
|
|
65
|
+
Object.defineProperty(exports, "getTransactionReference", { enumerable: true, get: function () { return currency_transaction_js_1.getTransactionReference; } });
|
|
66
|
+
Object.defineProperty(exports, "isValidDagAddress", { enumerable: true, get: function () { return currency_transaction_js_1.isValidDagAddress; } });
|
|
67
|
+
Object.defineProperty(exports, "tokenToUnits", { enumerable: true, get: function () { return currency_transaction_js_1.tokenToUnits; } });
|
|
68
|
+
Object.defineProperty(exports, "unitsToToken", { enumerable: true, get: function () { return currency_transaction_js_1.unitsToToken; } });
|
|
69
|
+
// Network operations
|
|
70
|
+
var index_js_1 = require("./network/index.js");
|
|
71
|
+
Object.defineProperty(exports, "CurrencyL1Client", { enumerable: true, get: function () { return index_js_1.CurrencyL1Client; } });
|
|
72
|
+
Object.defineProperty(exports, "DataL1Client", { enumerable: true, get: function () { return index_js_1.DataL1Client; } });
|
|
73
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return index_js_1.HttpClient; } });
|
|
74
|
+
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return index_js_1.NetworkError; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base HTTP client for network operations
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { RequestOptions } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Simple HTTP client using native fetch
|
|
9
|
+
*/
|
|
10
|
+
export declare class HttpClient {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private defaultTimeout;
|
|
13
|
+
constructor(baseUrl: string, timeout?: number);
|
|
14
|
+
/**
|
|
15
|
+
* Make a GET request
|
|
16
|
+
*/
|
|
17
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Make a POST request
|
|
20
|
+
*/
|
|
21
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
22
|
+
private request;
|
|
23
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base HTTP client for network operations
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.HttpClient = void 0;
|
|
9
|
+
const types_js_1 = require("./types.js");
|
|
10
|
+
const DEFAULT_TIMEOUT = 30000;
|
|
11
|
+
/**
|
|
12
|
+
* Simple HTTP client using native fetch
|
|
13
|
+
*/
|
|
14
|
+
class HttpClient {
|
|
15
|
+
constructor(baseUrl, timeout = DEFAULT_TIMEOUT) {
|
|
16
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
17
|
+
this.defaultTimeout = timeout;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Make a GET request
|
|
21
|
+
*/
|
|
22
|
+
async get(path, options = {}) {
|
|
23
|
+
return this.request('GET', path, undefined, options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Make a POST request
|
|
27
|
+
*/
|
|
28
|
+
async post(path, body, options = {}) {
|
|
29
|
+
return this.request('POST', path, body, options);
|
|
30
|
+
}
|
|
31
|
+
async request(method, path, body, options = {}) {
|
|
32
|
+
const url = `${this.baseUrl}${path}`;
|
|
33
|
+
const timeout = options.timeout ?? this.defaultTimeout;
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
36
|
+
try {
|
|
37
|
+
const headers = {
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
Accept: 'application/json',
|
|
40
|
+
...options.headers,
|
|
41
|
+
};
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
method,
|
|
44
|
+
headers,
|
|
45
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
46
|
+
signal: controller.signal,
|
|
47
|
+
});
|
|
48
|
+
clearTimeout(timeoutId);
|
|
49
|
+
const text = await response.text();
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new types_js_1.NetworkError(`HTTP ${response.status}: ${response.statusText}`, response.status, text);
|
|
52
|
+
}
|
|
53
|
+
if (!text) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(text);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
clearTimeout(timeoutId);
|
|
65
|
+
if (error instanceof types_js_1.NetworkError) {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
if (error instanceof Error) {
|
|
69
|
+
if (error.name === 'AbortError') {
|
|
70
|
+
throw new types_js_1.NetworkError(`Request timeout after ${timeout}ms`);
|
|
71
|
+
}
|
|
72
|
+
throw new types_js_1.NetworkError(error.message);
|
|
73
|
+
}
|
|
74
|
+
throw new types_js_1.NetworkError('Unknown network error');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.HttpClient = HttpClient;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency L1 client for submitting and querying transactions
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { NetworkConfig, PendingTransaction, PostTransactionResponse, RequestOptions } from './types.js';
|
|
7
|
+
import type { TransactionReference, CurrencyTransaction } from '../currency-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Client for interacting with Currency L1 nodes
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new CurrencyL1Client({ l1Url: 'http://localhost:9010' });
|
|
14
|
+
*
|
|
15
|
+
* // Get last reference for an address
|
|
16
|
+
* const lastRef = await client.getLastReference('DAG...');
|
|
17
|
+
*
|
|
18
|
+
* // Submit a transaction
|
|
19
|
+
* const result = await client.postTransaction(signedTx);
|
|
20
|
+
*
|
|
21
|
+
* // Check transaction status
|
|
22
|
+
* const pending = await client.getPendingTransaction(result.hash);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class CurrencyL1Client {
|
|
26
|
+
private client;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new CurrencyL1Client
|
|
29
|
+
*
|
|
30
|
+
* @param config - Network configuration with l1Url
|
|
31
|
+
* @throws Error if l1Url is not provided
|
|
32
|
+
*/
|
|
33
|
+
constructor(config: NetworkConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Get the last accepted transaction reference for an address
|
|
36
|
+
*
|
|
37
|
+
* This is needed to create a new transaction that chains from
|
|
38
|
+
* the address's most recent transaction.
|
|
39
|
+
*
|
|
40
|
+
* @param address - DAG address to query
|
|
41
|
+
* @param options - Request options
|
|
42
|
+
* @returns Transaction reference with hash and ordinal
|
|
43
|
+
*/
|
|
44
|
+
getLastReference(address: string, options?: RequestOptions): Promise<TransactionReference>;
|
|
45
|
+
/**
|
|
46
|
+
* Submit a signed currency transaction to the L1 network
|
|
47
|
+
*
|
|
48
|
+
* @param transaction - Signed currency transaction
|
|
49
|
+
* @param options - Request options
|
|
50
|
+
* @returns Response containing the transaction hash
|
|
51
|
+
*/
|
|
52
|
+
postTransaction(transaction: CurrencyTransaction, options?: RequestOptions): Promise<PostTransactionResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a pending transaction by hash
|
|
55
|
+
*
|
|
56
|
+
* Use this to poll for transaction status after submission.
|
|
57
|
+
* Returns null if the transaction is not found (already confirmed or invalid).
|
|
58
|
+
*
|
|
59
|
+
* @param hash - Transaction hash
|
|
60
|
+
* @param options - Request options
|
|
61
|
+
* @returns Pending transaction details or null if not found
|
|
62
|
+
*/
|
|
63
|
+
getPendingTransaction(hash: string, options?: RequestOptions): Promise<PendingTransaction | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Check the health/availability of the L1 node
|
|
66
|
+
*
|
|
67
|
+
* @param options - Request options
|
|
68
|
+
* @returns True if the node is healthy
|
|
69
|
+
*/
|
|
70
|
+
checkHealth(options?: RequestOptions): Promise<boolean>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Currency L1 client for submitting and querying transactions
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CurrencyL1Client = void 0;
|
|
9
|
+
const client_js_1 = require("./client.js");
|
|
10
|
+
const types_js_1 = require("./types.js");
|
|
11
|
+
/**
|
|
12
|
+
* Client for interacting with Currency L1 nodes
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const client = new CurrencyL1Client({ l1Url: 'http://localhost:9010' });
|
|
17
|
+
*
|
|
18
|
+
* // Get last reference for an address
|
|
19
|
+
* const lastRef = await client.getLastReference('DAG...');
|
|
20
|
+
*
|
|
21
|
+
* // Submit a transaction
|
|
22
|
+
* const result = await client.postTransaction(signedTx);
|
|
23
|
+
*
|
|
24
|
+
* // Check transaction status
|
|
25
|
+
* const pending = await client.getPendingTransaction(result.hash);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class CurrencyL1Client {
|
|
29
|
+
/**
|
|
30
|
+
* Create a new CurrencyL1Client
|
|
31
|
+
*
|
|
32
|
+
* @param config - Network configuration with l1Url
|
|
33
|
+
* @throws Error if l1Url is not provided
|
|
34
|
+
*/
|
|
35
|
+
constructor(config) {
|
|
36
|
+
if (!config.l1Url) {
|
|
37
|
+
throw new Error('l1Url is required for CurrencyL1Client');
|
|
38
|
+
}
|
|
39
|
+
this.client = new client_js_1.HttpClient(config.l1Url, config.timeout);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the last accepted transaction reference for an address
|
|
43
|
+
*
|
|
44
|
+
* This is needed to create a new transaction that chains from
|
|
45
|
+
* the address's most recent transaction.
|
|
46
|
+
*
|
|
47
|
+
* @param address - DAG address to query
|
|
48
|
+
* @param options - Request options
|
|
49
|
+
* @returns Transaction reference with hash and ordinal
|
|
50
|
+
*/
|
|
51
|
+
async getLastReference(address, options) {
|
|
52
|
+
return this.client.get(`/transactions/last-reference/${address}`, options);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Submit a signed currency transaction to the L1 network
|
|
56
|
+
*
|
|
57
|
+
* @param transaction - Signed currency transaction
|
|
58
|
+
* @param options - Request options
|
|
59
|
+
* @returns Response containing the transaction hash
|
|
60
|
+
*/
|
|
61
|
+
async postTransaction(transaction, options) {
|
|
62
|
+
return this.client.post('/transactions', transaction, options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get a pending transaction by hash
|
|
66
|
+
*
|
|
67
|
+
* Use this to poll for transaction status after submission.
|
|
68
|
+
* Returns null if the transaction is not found (already confirmed or invalid).
|
|
69
|
+
*
|
|
70
|
+
* @param hash - Transaction hash
|
|
71
|
+
* @param options - Request options
|
|
72
|
+
* @returns Pending transaction details or null if not found
|
|
73
|
+
*/
|
|
74
|
+
async getPendingTransaction(hash, options) {
|
|
75
|
+
try {
|
|
76
|
+
return await this.client.get(`/transactions/${hash}`, options);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (error instanceof types_js_1.NetworkError && error.statusCode === 404) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check the health/availability of the L1 node
|
|
87
|
+
*
|
|
88
|
+
* @param options - Request options
|
|
89
|
+
* @returns True if the node is healthy
|
|
90
|
+
*/
|
|
91
|
+
async checkHealth(options) {
|
|
92
|
+
try {
|
|
93
|
+
await this.client.get('/cluster/info', options);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.CurrencyL1Client = CurrencyL1Client;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data L1 client for submitting data transactions to metagraphs
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { NetworkConfig, EstimateFeeResponse, PostDataResponse, RequestOptions } from './types.js';
|
|
7
|
+
import type { Signed } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Client for interacting with Data L1 nodes (metagraphs)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new DataL1Client({ dataL1Url: 'http://localhost:8080' });
|
|
14
|
+
*
|
|
15
|
+
* // Estimate fee for data submission
|
|
16
|
+
* const feeInfo = await client.estimateFee(signedData);
|
|
17
|
+
*
|
|
18
|
+
* // Submit data
|
|
19
|
+
* const result = await client.postData(signedData);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class DataL1Client {
|
|
23
|
+
private client;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new DataL1Client
|
|
26
|
+
*
|
|
27
|
+
* @param config - Network configuration with dataL1Url
|
|
28
|
+
* @throws Error if dataL1Url is not provided
|
|
29
|
+
*/
|
|
30
|
+
constructor(config: NetworkConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Estimate the fee for submitting data
|
|
33
|
+
*
|
|
34
|
+
* Some metagraphs charge fees for data submissions.
|
|
35
|
+
* Call this before postData to know the required fee.
|
|
36
|
+
*
|
|
37
|
+
* @param data - Signed data object to estimate fee for
|
|
38
|
+
* @param options - Request options
|
|
39
|
+
* @returns Fee estimate with amount and destination address
|
|
40
|
+
*/
|
|
41
|
+
estimateFee<T>(data: Signed<T>, options?: RequestOptions): Promise<EstimateFeeResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Submit signed data to the Data L1 node
|
|
44
|
+
*
|
|
45
|
+
* @param data - Signed data object to submit
|
|
46
|
+
* @param options - Request options
|
|
47
|
+
* @returns Response containing the data hash
|
|
48
|
+
*/
|
|
49
|
+
postData<T>(data: Signed<T>, options?: RequestOptions): Promise<PostDataResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Check the health/availability of the Data L1 node
|
|
52
|
+
*
|
|
53
|
+
* @param options - Request options
|
|
54
|
+
* @returns True if the node is healthy
|
|
55
|
+
*/
|
|
56
|
+
checkHealth(options?: RequestOptions): Promise<boolean>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Data L1 client for submitting data transactions to metagraphs
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DataL1Client = void 0;
|
|
9
|
+
const client_js_1 = require("./client.js");
|
|
10
|
+
/**
|
|
11
|
+
* Client for interacting with Data L1 nodes (metagraphs)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const client = new DataL1Client({ dataL1Url: 'http://localhost:8080' });
|
|
16
|
+
*
|
|
17
|
+
* // Estimate fee for data submission
|
|
18
|
+
* const feeInfo = await client.estimateFee(signedData);
|
|
19
|
+
*
|
|
20
|
+
* // Submit data
|
|
21
|
+
* const result = await client.postData(signedData);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class DataL1Client {
|
|
25
|
+
/**
|
|
26
|
+
* Create a new DataL1Client
|
|
27
|
+
*
|
|
28
|
+
* @param config - Network configuration with dataL1Url
|
|
29
|
+
* @throws Error if dataL1Url is not provided
|
|
30
|
+
*/
|
|
31
|
+
constructor(config) {
|
|
32
|
+
if (!config.dataL1Url) {
|
|
33
|
+
throw new Error('dataL1Url is required for DataL1Client');
|
|
34
|
+
}
|
|
35
|
+
this.client = new client_js_1.HttpClient(config.dataL1Url, config.timeout);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Estimate the fee for submitting data
|
|
39
|
+
*
|
|
40
|
+
* Some metagraphs charge fees for data submissions.
|
|
41
|
+
* Call this before postData to know the required fee.
|
|
42
|
+
*
|
|
43
|
+
* @param data - Signed data object to estimate fee for
|
|
44
|
+
* @param options - Request options
|
|
45
|
+
* @returns Fee estimate with amount and destination address
|
|
46
|
+
*/
|
|
47
|
+
async estimateFee(data, options) {
|
|
48
|
+
return this.client.post('/data/estimate-fee', data, options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Submit signed data to the Data L1 node
|
|
52
|
+
*
|
|
53
|
+
* @param data - Signed data object to submit
|
|
54
|
+
* @param options - Request options
|
|
55
|
+
* @returns Response containing the data hash
|
|
56
|
+
*/
|
|
57
|
+
async postData(data, options) {
|
|
58
|
+
return this.client.post('/data', data, options);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check the health/availability of the Data L1 node
|
|
62
|
+
*
|
|
63
|
+
* @param options - Request options
|
|
64
|
+
* @returns True if the node is healthy
|
|
65
|
+
*/
|
|
66
|
+
async checkHealth(options) {
|
|
67
|
+
try {
|
|
68
|
+
await this.client.get('/cluster/info', options);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.DataL1Client = DataL1Client;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network operations for L1 node interactions
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { CurrencyL1Client } from './currency-l1-client.js';
|
|
7
|
+
export { DataL1Client } from './data-l1-client.js';
|
|
8
|
+
export { HttpClient } from './client.js';
|
|
9
|
+
export { NetworkError } from './types.js';
|
|
10
|
+
export type { NetworkConfig, RequestOptions, TransactionStatus, PendingTransaction, PostTransactionResponse, EstimateFeeResponse, PostDataResponse, } from './types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network operations for L1 node interactions
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.NetworkError = exports.HttpClient = exports.DataL1Client = exports.CurrencyL1Client = void 0;
|
|
9
|
+
var currency_l1_client_js_1 = require("./currency-l1-client.js");
|
|
10
|
+
Object.defineProperty(exports, "CurrencyL1Client", { enumerable: true, get: function () { return currency_l1_client_js_1.CurrencyL1Client; } });
|
|
11
|
+
var data_l1_client_js_1 = require("./data-l1-client.js");
|
|
12
|
+
Object.defineProperty(exports, "DataL1Client", { enumerable: true, get: function () { return data_l1_client_js_1.DataL1Client; } });
|
|
13
|
+
var client_js_1 = require("./client.js");
|
|
14
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return client_js_1.HttpClient; } });
|
|
15
|
+
var types_js_1 = require("./types.js");
|
|
16
|
+
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return types_js_1.NetworkError; } });
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network types for L1 client operations
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { CurrencyTransaction } from '../currency-types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Network configuration for connecting to L1 nodes
|
|
9
|
+
*/
|
|
10
|
+
export interface NetworkConfig {
|
|
11
|
+
/** Currency L1 endpoint URL (e.g., 'http://localhost:9010') */
|
|
12
|
+
l1Url?: string;
|
|
13
|
+
/** Data L1 endpoint URL (e.g., 'http://localhost:8080') */
|
|
14
|
+
dataL1Url?: string;
|
|
15
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* HTTP request options
|
|
20
|
+
*/
|
|
21
|
+
export interface RequestOptions {
|
|
22
|
+
/** Request timeout in milliseconds */
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/** Additional headers */
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Transaction status in the network
|
|
29
|
+
*/
|
|
30
|
+
export type TransactionStatus = 'Waiting' | 'InProgress' | 'Accepted';
|
|
31
|
+
/**
|
|
32
|
+
* Pending transaction response from L1
|
|
33
|
+
*/
|
|
34
|
+
export interface PendingTransaction {
|
|
35
|
+
/** Transaction hash */
|
|
36
|
+
hash: string;
|
|
37
|
+
/** Current status */
|
|
38
|
+
status: TransactionStatus;
|
|
39
|
+
/** The transaction value */
|
|
40
|
+
transaction: CurrencyTransaction;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Response from posting a transaction
|
|
44
|
+
*/
|
|
45
|
+
export interface PostTransactionResponse {
|
|
46
|
+
/** Transaction hash */
|
|
47
|
+
hash: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Response from estimating data transaction fee
|
|
51
|
+
*/
|
|
52
|
+
export interface EstimateFeeResponse {
|
|
53
|
+
/** Estimated fee in smallest units */
|
|
54
|
+
fee: number;
|
|
55
|
+
/** Fee destination address */
|
|
56
|
+
address: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Response from posting data
|
|
60
|
+
*/
|
|
61
|
+
export interface PostDataResponse {
|
|
62
|
+
/** Data hash */
|
|
63
|
+
hash: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Network error with status code and response details
|
|
67
|
+
*/
|
|
68
|
+
export declare class NetworkError extends Error {
|
|
69
|
+
/** HTTP status code if applicable */
|
|
70
|
+
statusCode?: number;
|
|
71
|
+
/** Raw response body */
|
|
72
|
+
responseBody?: string;
|
|
73
|
+
constructor(message: string, statusCode?: number, responseBody?: string);
|
|
74
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network types for L1 client operations
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.NetworkError = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Network error with status code and response details
|
|
11
|
+
*/
|
|
12
|
+
class NetworkError extends Error {
|
|
13
|
+
constructor(message, statusCode, responseBody) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'NetworkError';
|
|
16
|
+
this.statusCode = statusCode;
|
|
17
|
+
this.responseBody = responseBody;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.NetworkError = NetworkError;
|