@ottochain/sdk 1.2.0 → 1.4.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.
Files changed (103) hide show
  1. package/LICENSE +190 -0
  2. package/dist/cjs/index.js +34 -15
  3. package/dist/cjs/ottochain/index.js +20 -1
  4. package/dist/cjs/ottochain/metagraph-client.js +7 -8
  5. package/dist/cjs/ottochain/snapshot.js +3 -3
  6. package/dist/cjs/{metakit → ottochain}/transaction.js +4 -5
  7. package/dist/cjs/verify.js +17 -0
  8. package/dist/esm/apps/contracts/index.js +28 -10
  9. package/dist/esm/apps/corporate/index.js +79 -24
  10. package/dist/esm/apps/governance/index.js +85 -36
  11. package/dist/esm/apps/identity/constants.js +27 -22
  12. package/dist/esm/apps/identity/index.js +35 -7
  13. package/dist/esm/apps/index.js +32 -6
  14. package/dist/esm/apps/markets/index.js +27 -6
  15. package/dist/esm/apps/oracles/index.js +27 -7
  16. package/dist/esm/errors.js +19 -9
  17. package/dist/esm/generated/google/protobuf/struct.js +39 -33
  18. package/dist/esm/generated/google/protobuf/timestamp.js +9 -6
  19. package/dist/esm/generated/index.js +134 -10
  20. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +54 -48
  21. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +357 -335
  22. package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +299 -284
  23. package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +47 -38
  24. package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +50 -44
  25. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +86 -77
  26. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +72 -66
  27. package/dist/esm/generated/ottochain/v1/common.js +4 -1
  28. package/dist/esm/generated/ottochain/v1/fiber.js +96 -90
  29. package/dist/esm/generated/ottochain/v1/messages.js +82 -79
  30. package/dist/esm/generated/ottochain/v1/records.js +140 -137
  31. package/dist/esm/index.js +86 -20
  32. package/dist/esm/{metakit → ottochain}/drop-nulls.js +5 -1
  33. package/dist/esm/ottochain/index.js +56 -3
  34. package/dist/esm/ottochain/metagraph-client.js +16 -13
  35. package/dist/esm/{metakit → ottochain}/normalize.js +11 -4
  36. package/dist/esm/ottochain/snapshot.js +20 -10
  37. package/dist/esm/{metakit → ottochain}/transaction.js +25 -14
  38. package/dist/esm/ottochain/types.js +2 -1
  39. package/dist/esm/types.js +7 -2
  40. package/dist/esm/validation.js +76 -65
  41. package/dist/esm/verify.js +17 -0
  42. package/dist/types/index.d.ts +14 -7
  43. package/dist/types/ottochain/index.d.ts +4 -0
  44. package/dist/types/ottochain/metagraph-client.d.ts +1 -1
  45. package/dist/types/{metakit → ottochain}/transaction.d.ts +1 -1
  46. package/dist/types/validation.d.ts +8 -8
  47. package/dist/types/verify.d.ts +9 -0
  48. package/package.json +5 -3
  49. package/dist/cjs/metakit/binary.js +0 -58
  50. package/dist/cjs/metakit/canonicalize.js +0 -40
  51. package/dist/cjs/metakit/codec.js +0 -45
  52. package/dist/cjs/metakit/currency-transaction.js +0 -319
  53. package/dist/cjs/metakit/currency-types.js +0 -13
  54. package/dist/cjs/metakit/hash.js +0 -84
  55. package/dist/cjs/metakit/index.js +0 -86
  56. package/dist/cjs/metakit/network/client.js +0 -78
  57. package/dist/cjs/metakit/network/currency-l1-client.js +0 -101
  58. package/dist/cjs/metakit/network/data-l1-client.js +0 -76
  59. package/dist/cjs/metakit/network/index.js +0 -16
  60. package/dist/cjs/metakit/network/types.js +0 -20
  61. package/dist/cjs/metakit/sign.js +0 -120
  62. package/dist/cjs/metakit/signed-object.js +0 -100
  63. package/dist/cjs/metakit/types.js +0 -14
  64. package/dist/cjs/metakit/verify.js +0 -217
  65. package/dist/cjs/metakit/wallet.js +0 -127
  66. package/dist/esm/metakit/binary.js +0 -53
  67. package/dist/esm/metakit/canonicalize.js +0 -33
  68. package/dist/esm/metakit/codec.js +0 -38
  69. package/dist/esm/metakit/currency-transaction.js +0 -306
  70. package/dist/esm/metakit/currency-types.js +0 -10
  71. package/dist/esm/metakit/hash.js +0 -77
  72. package/dist/esm/metakit/index.js +0 -33
  73. package/dist/esm/metakit/network/client.js +0 -74
  74. package/dist/esm/metakit/network/currency-l1-client.js +0 -97
  75. package/dist/esm/metakit/network/data-l1-client.js +0 -72
  76. package/dist/esm/metakit/network/index.js +0 -9
  77. package/dist/esm/metakit/network/types.js +0 -16
  78. package/dist/esm/metakit/sign.js +0 -114
  79. package/dist/esm/metakit/signed-object.js +0 -94
  80. package/dist/esm/metakit/types.js +0 -11
  81. package/dist/esm/metakit/verify.js +0 -210
  82. package/dist/esm/metakit/wallet.js +0 -117
  83. package/dist/types/metakit/binary.d.ts +0 -38
  84. package/dist/types/metakit/canonicalize.d.ts +0 -26
  85. package/dist/types/metakit/codec.d.ts +0 -16
  86. package/dist/types/metakit/currency-transaction.d.ts +0 -157
  87. package/dist/types/metakit/currency-types.d.ts +0 -55
  88. package/dist/types/metakit/hash.d.ts +0 -50
  89. package/dist/types/metakit/index.d.ts +0 -26
  90. package/dist/types/metakit/network/client.d.ts +0 -23
  91. package/dist/types/metakit/network/currency-l1-client.d.ts +0 -71
  92. package/dist/types/metakit/network/data-l1-client.d.ts +0 -57
  93. package/dist/types/metakit/network/index.d.ts +0 -10
  94. package/dist/types/metakit/network/types.d.ts +0 -74
  95. package/dist/types/metakit/sign.d.ts +0 -65
  96. package/dist/types/metakit/signed-object.d.ts +0 -66
  97. package/dist/types/metakit/types.d.ts +0 -67
  98. package/dist/types/metakit/verify.d.ts +0 -55
  99. package/dist/types/metakit/wallet.d.ts +0 -70
  100. /package/dist/cjs/{metakit → ottochain}/drop-nulls.js +0 -0
  101. /package/dist/cjs/{metakit → ottochain}/normalize.js +0 -0
  102. /package/dist/types/{metakit → ottochain}/drop-nulls.d.ts +0 -0
  103. /package/dist/types/{metakit → ottochain}/normalize.d.ts +0 -0
@@ -1,117 +0,0 @@
1
- /**
2
- * Wallet and Key Management Utilities
3
- *
4
- * Functions for generating and managing cryptographic keys.
5
- */
6
- import { dag4 } from '@stardust-collective/dag4';
7
- /**
8
- * Generate a new random key pair
9
- *
10
- * @returns KeyPair with private key, public key, and DAG address
11
- *
12
- * @example
13
- * ```typescript
14
- * const keyPair = generateKeyPair();
15
- * console.log(keyPair.address); // DAG address
16
- * console.log(keyPair.privateKey); // 64 char hex
17
- * console.log(keyPair.publicKey); // 130 char hex (with 04 prefix)
18
- * ```
19
- */
20
- export function generateKeyPair() {
21
- const privateKey = dag4.keyStore.generatePrivateKey();
22
- return keyPairFromPrivateKey(privateKey);
23
- }
24
- /**
25
- * Derive a key pair from an existing private key
26
- *
27
- * @param privateKey - Private key in hex format (64 characters)
28
- * @returns KeyPair with private key, public key, and DAG address
29
- *
30
- * @example
31
- * ```typescript
32
- * const keyPair = keyPairFromPrivateKey(existingPrivateKey);
33
- * ```
34
- */
35
- export function keyPairFromPrivateKey(privateKey) {
36
- // Get uncompressed public key (with 04 prefix)
37
- const publicKey = dag4.keyStore.getPublicKeyFromPrivate(privateKey, false);
38
- // Derive DAG address
39
- const address = dag4.keyStore.getDagAddressFromPublicKey(publicKey);
40
- return {
41
- privateKey,
42
- publicKey: normalizePublicKey(publicKey),
43
- address,
44
- };
45
- }
46
- /**
47
- * Get the public key hex from a private key
48
- *
49
- * @param privateKey - Private key in hex format
50
- * @param compressed - If true, returns compressed public key (33 bytes)
51
- * @returns Public key in hex format
52
- */
53
- export function getPublicKeyHex(privateKey, compressed = false) {
54
- return dag4.keyStore.getPublicKeyFromPrivate(privateKey, compressed);
55
- }
56
- /**
57
- * Get the public key ID (without 04 prefix) from a private key
58
- *
59
- * This format is used in SignatureProof.id
60
- *
61
- * @param privateKey - Private key in hex format
62
- * @returns Public key ID (128 characters, no 04 prefix)
63
- */
64
- export function getPublicKeyId(privateKey) {
65
- const publicKey = dag4.keyStore.getPublicKeyFromPrivate(privateKey, false);
66
- // Remove 04 prefix if present
67
- if (publicKey.length === 130 && publicKey.startsWith('04')) {
68
- return publicKey.substring(2);
69
- }
70
- return publicKey;
71
- }
72
- /**
73
- * Get DAG address from a public key
74
- *
75
- * @param publicKey - Public key in hex format (with or without 04 prefix)
76
- * @returns DAG address string
77
- */
78
- export function getAddress(publicKey) {
79
- const normalizedKey = normalizePublicKey(publicKey);
80
- return dag4.keyStore.getDagAddressFromPublicKey(normalizedKey);
81
- }
82
- /**
83
- * Validate that a private key is correctly formatted
84
- *
85
- * @param privateKey - Private key to validate
86
- * @returns true if valid hex string of correct length
87
- */
88
- export function isValidPrivateKey(privateKey) {
89
- if (typeof privateKey !== 'string')
90
- return false;
91
- if (privateKey.length !== 64)
92
- return false;
93
- return /^[0-9a-fA-F]+$/.test(privateKey);
94
- }
95
- /**
96
- * Validate that a public key is correctly formatted
97
- *
98
- * @param publicKey - Public key to validate
99
- * @returns true if valid hex string of correct length
100
- */
101
- export function isValidPublicKey(publicKey) {
102
- if (typeof publicKey !== 'string')
103
- return false;
104
- // With 04 prefix: 130 chars, without: 128 chars
105
- if (publicKey.length !== 128 && publicKey.length !== 130)
106
- return false;
107
- return /^[0-9a-fA-F]+$/.test(publicKey);
108
- }
109
- /**
110
- * Normalize public key to include 04 prefix
111
- */
112
- function normalizePublicKey(publicKey) {
113
- if (publicKey.length === 128) {
114
- return '04' + publicKey;
115
- }
116
- return publicKey;
117
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Binary Encoding
3
- *
4
- * Converts JSON data to binary format for cryptographic operations.
5
- * Supports both regular encoding and DataUpdate encoding with Constellation prefix.
6
- */
7
- /**
8
- * Convert data to binary bytes for signing
9
- *
10
- * For regular data:
11
- * JSON -> RFC 8785 canonicalization -> UTF-8 bytes
12
- *
13
- * For DataUpdate (isDataUpdate=true):
14
- * JSON -> RFC 8785 -> UTF-8 -> Base64 -> prepend Constellation prefix -> UTF-8 bytes
15
- *
16
- * @param data - Any JSON-serializable object
17
- * @param isDataUpdate - If true, applies DataUpdate encoding with Constellation prefix
18
- * @returns Binary bytes as Uint8Array
19
- *
20
- * @example
21
- * ```typescript
22
- * // Regular encoding
23
- * const bytes = toBytes({ action: 'test' });
24
- *
25
- * // DataUpdate encoding
26
- * const updateBytes = toBytes({ action: 'test' }, true);
27
- * ```
28
- */
29
- export declare function toBytes<T>(data: T, isDataUpdate?: boolean): Uint8Array;
30
- /**
31
- * Encode data as a DataUpdate with Constellation prefix
32
- *
33
- * This is equivalent to `toBytes(data, true)`.
34
- *
35
- * @param data - Any JSON-serializable object
36
- * @returns Binary bytes with Constellation prefix
37
- */
38
- export declare function encodeDataUpdate<T>(data: T): Uint8Array;
@@ -1,26 +0,0 @@
1
- /**
2
- * RFC 8785 JSON Canonicalization
3
- *
4
- * Provides deterministic JSON serialization according to RFC 8785.
5
- * This ensures identical JSON objects always produce identical strings.
6
- */
7
- /**
8
- * Canonicalize JSON data according to RFC 8785
9
- *
10
- * Key features:
11
- * - Object keys sorted by UTF-16BE binary comparison
12
- * - Numbers serialized in shortest decimal representation
13
- * - No whitespace
14
- * - Proper Unicode escaping
15
- *
16
- * @param data - Any JSON-serializable object
17
- * @returns Canonical JSON string
18
- * @throws Error if data cannot be serialized to JSON
19
- *
20
- * @example
21
- * ```typescript
22
- * const canonical = canonicalize({ b: 2, a: 1 });
23
- * // Returns: '{"a":1,"b":2}'
24
- * ```
25
- */
26
- export declare function canonicalize<T>(data: T): string;
@@ -1,16 +0,0 @@
1
- /**
2
- * Codec Utilities
3
- *
4
- * Encoding/decoding utilities for the Constellation signature protocol.
5
- * Re-exports from binary.ts for backwards compatibility and provides additional utilities.
6
- */
7
- export { toBytes, encodeDataUpdate } from './binary.js';
8
- export { CONSTELLATION_PREFIX } from './types.js';
9
- /**
10
- * Decode a DataUpdate encoded message back to its original JSON
11
- *
12
- * @param bytes - DataUpdate encoded bytes
13
- * @returns Decoded JSON object
14
- * @throws Error if bytes are not valid DataUpdate encoding
15
- */
16
- export declare function decodeDataUpdate<T>(bytes: Uint8Array): T;
@@ -1,157 +0,0 @@
1
- /**
2
- * Currency transaction operations for metagraph token transfers
3
- *
4
- * @packageDocumentation
5
- */
6
- import type { CurrencyTransaction, TransactionReference, TransferParams } from './currency-types.js';
7
- import type { VerificationResult } from './types.js';
8
- /**
9
- * Convert token amount to smallest units
10
- *
11
- * @param amount - Amount in token units (e.g., 100.5)
12
- * @returns Amount in smallest units (1e-8)
13
- *
14
- * @example
15
- * ```typescript
16
- * const units = tokenToUnits(100.5); // 10050000000
17
- * ```
18
- */
19
- export declare function tokenToUnits(amount: number): number;
20
- /**
21
- * Convert smallest units to token amount
22
- *
23
- * @param units - Amount in smallest units
24
- * @returns Amount in token units
25
- *
26
- * @example
27
- * ```typescript
28
- * const tokens = unitsToToken(10050000000); // 100.5
29
- * ```
30
- */
31
- export declare function unitsToToken(units: number): number;
32
- /**
33
- * Validate DAG address format
34
- *
35
- * @param address - DAG address to validate
36
- * @returns True if address is valid
37
- *
38
- * @example
39
- * ```typescript
40
- * const valid = isValidDagAddress('DAG...');
41
- * ```
42
- */
43
- export declare function isValidDagAddress(address: string): boolean;
44
- /**
45
- * Create a metagraph token transaction
46
- *
47
- * @param params - Transfer parameters
48
- * @param privateKey - Private key to sign with (hex string)
49
- * @param lastRef - Reference to last accepted transaction
50
- * @returns Signed currency transaction
51
- *
52
- * @throws If addresses are invalid or amount is too small
53
- *
54
- * @example
55
- * ```typescript
56
- * const tx = await createCurrencyTransaction(
57
- * { destination: 'DAG...', amount: 100.5, fee: 0 },
58
- * privateKey,
59
- * { hash: 'abc123...', ordinal: 5 }
60
- * );
61
- * ```
62
- */
63
- export declare function createCurrencyTransaction(params: TransferParams, privateKey: string, lastRef: TransactionReference): Promise<CurrencyTransaction>;
64
- /**
65
- * Create multiple metagraph token transactions (batch)
66
- *
67
- * @param transfers - Array of transfer parameters
68
- * @param privateKey - Private key to sign with
69
- * @param lastRef - Reference to last accepted transaction
70
- * @returns Array of signed currency transactions
71
- *
72
- * @throws If any address is invalid or amount is too small
73
- *
74
- * @example
75
- * ```typescript
76
- * const txns = await createCurrencyTransactionBatch(
77
- * [
78
- * { destination: 'DAG...1', amount: 10 },
79
- * { destination: 'DAG...2', amount: 20 },
80
- * ],
81
- * privateKey,
82
- * { hash: 'abc123...', ordinal: 5 }
83
- * );
84
- * ```
85
- */
86
- export declare function createCurrencyTransactionBatch(transfers: TransferParams[], privateKey: string, lastRef: TransactionReference): Promise<CurrencyTransaction[]>;
87
- /**
88
- * Add a signature to an existing currency transaction (for multi-sig)
89
- *
90
- * @param transaction - Transaction to sign
91
- * @param privateKey - Private key to sign with
92
- * @returns Transaction with additional signature
93
- *
94
- * @throws If sign-verify fails
95
- *
96
- * @example
97
- * ```typescript
98
- * const signedTx = await signCurrencyTransaction(tx, privateKey2);
99
- * ```
100
- */
101
- export declare function signCurrencyTransaction(transaction: CurrencyTransaction, privateKey: string): Promise<CurrencyTransaction>;
102
- /**
103
- * Verify all signatures on a currency transaction
104
- *
105
- * @param transaction - Transaction to verify
106
- * @returns Verification result with valid/invalid proofs
107
- *
108
- * @example
109
- * ```typescript
110
- * const result = await verifyCurrencyTransaction(tx);
111
- * console.log('Valid:', result.isValid);
112
- * ```
113
- */
114
- export declare function verifyCurrencyTransaction(transaction: CurrencyTransaction): Promise<VerificationResult>;
115
- /**
116
- * Encode a currency transaction for hashing
117
- *
118
- * @param transaction - Transaction to encode
119
- * @returns Hex-encoded string
120
- *
121
- * @example
122
- * ```typescript
123
- * const encoded = encodeCurrencyTransaction(tx);
124
- * ```
125
- */
126
- export declare function encodeCurrencyTransaction(transaction: CurrencyTransaction): string;
127
- /**
128
- * Hash a currency transaction
129
- *
130
- * @param transaction - Transaction to hash
131
- * @returns Hash object with value and bytes
132
- *
133
- * @example
134
- * ```typescript
135
- * const hash = await hashCurrencyTransaction(tx);
136
- * console.log('Hash:', hash.value);
137
- * ```
138
- */
139
- export declare function hashCurrencyTransaction(transaction: CurrencyTransaction): Promise<{
140
- value: string;
141
- bytes: Uint8Array;
142
- }>;
143
- /**
144
- * Get transaction reference from a currency transaction
145
- * Useful for chaining transactions
146
- *
147
- * @param transaction - Transaction to extract reference from
148
- * @param ordinal - Ordinal number for this transaction
149
- * @returns Transaction reference
150
- *
151
- * @example
152
- * ```typescript
153
- * const ref = await getTransactionReference(tx, 6);
154
- * // Use ref as lastRef for next transaction
155
- * ```
156
- */
157
- export declare function getTransactionReference(transaction: CurrencyTransaction, ordinal: number): Promise<TransactionReference>;
@@ -1,55 +0,0 @@
1
- /**
2
- * Currency transaction types for metagraph token transfers
3
- *
4
- * @packageDocumentation
5
- */
6
- import type { Signed } from './types.js';
7
- /**
8
- * Reference to a previous transaction for chaining
9
- */
10
- export interface TransactionReference {
11
- /** Transaction hash */
12
- hash: string;
13
- /** Transaction ordinal number */
14
- ordinal: number;
15
- }
16
- /**
17
- * Currency transaction value structure (v2)
18
- * Contains the actual transaction data before signing
19
- */
20
- export interface CurrencyTransactionValue {
21
- /** Source DAG address */
22
- source: string;
23
- /** Destination DAG address */
24
- destination: string;
25
- /** Amount in smallest units (1e-8) */
26
- amount: number;
27
- /** Fee in smallest units (1e-8) */
28
- fee: number;
29
- /** Reference to parent transaction */
30
- parent: TransactionReference;
31
- /** Random salt for uniqueness (as string) */
32
- salt: string;
33
- }
34
- /**
35
- * Currency transaction structure (v2)
36
- * A signed currency transaction value
37
- * Used for metagraph token transfers
38
- */
39
- export type CurrencyTransaction = Signed<CurrencyTransactionValue>;
40
- /**
41
- * Parameters for creating a token transfer
42
- */
43
- export interface TransferParams {
44
- /** Destination DAG address */
45
- destination: string;
46
- /** Amount in token units (e.g., 100.5 tokens) */
47
- amount: number;
48
- /** Fee in token units (defaults to 0) */
49
- fee?: number;
50
- }
51
- /**
52
- * Token decimals constant (1e-8)
53
- * Same as DAG_DECIMALS from dag4.js
54
- */
55
- export declare const TOKEN_DECIMALS = 1e-8;
@@ -1,50 +0,0 @@
1
- /**
2
- * Hashing Utilities
3
- *
4
- * SHA-256 and SHA-512 hashing for the Constellation signature protocol.
5
- */
6
- import { Hash } from './types.js';
7
- /**
8
- * Compute SHA-256 hash of canonical JSON data
9
- *
10
- * @param data - Any JSON-serializable object
11
- * @returns Hash object with hex string and raw bytes
12
- *
13
- * @example
14
- * ```typescript
15
- * const hashResult = hash({ action: 'test' });
16
- * console.log(hashResult.value); // 64-char hex string
17
- * ```
18
- */
19
- export declare function hash<T>(data: T): Hash;
20
- /**
21
- * Compute SHA-256 hash of raw bytes
22
- *
23
- * @param bytes - Input bytes
24
- * @returns Hash object with hex string and raw bytes
25
- */
26
- export declare function hashBytes(bytes: Uint8Array): Hash;
27
- /**
28
- * Compute the full signing digest according to Constellation protocol
29
- *
30
- * Protocol:
31
- * 1. Serialize data to binary (with optional DataUpdate prefix)
32
- * 2. Compute SHA-256 hash
33
- * 3. Convert hash to hex string
34
- * 4. Treat hex string as UTF-8 bytes (NOT hex decode)
35
- * 5. Compute SHA-512 of those bytes
36
- * 6. Truncate to 32 bytes for secp256k1 signing
37
- *
38
- * @param data - Any JSON-serializable object
39
- * @param isDataUpdate - Whether to apply DataUpdate encoding
40
- * @returns 32-byte digest ready for ECDSA signing
41
- */
42
- export declare function computeDigest<T>(data: T, isDataUpdate?: boolean): Uint8Array;
43
- /**
44
- * Compute SHA-256 hash of data with optional DataUpdate encoding
45
- *
46
- * @param data - Any JSON-serializable object
47
- * @param isDataUpdate - Whether to apply DataUpdate encoding
48
- * @returns Hash object
49
- */
50
- export declare function hashData<T>(data: T, isDataUpdate?: boolean): Hash;
@@ -1,26 +0,0 @@
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';
24
- export { createTransitionPayload, createArchivePayload, createInvokeScriptPayload, signTransaction, addTransactionSignature, getPublicKeyForRegistration, } from './transaction.js';
25
- export { createStateMachinePayload, createScriptPayload, createDataTransactionRequest, } from './transaction.js';
26
- export type { CreateStateMachineParams, CreateStateMachineMessage, CreateScriptParams, CreateScriptMessage, DataTransactionRequest, TransitionParams, TransitionStateMachineMessage, ArchiveParams, ArchiveStateMachineMessage, InvokeScriptParams, InvokeScriptMessage, } from './transaction.js';
@@ -1,23 +0,0 @@
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
- }
@@ -1,71 +0,0 @@
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
- }
@@ -1,57 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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';