@sequence0/sdk 1.1.2 → 1.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.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/chains/algorand.d.ts +44 -0
  3. package/dist/chains/algorand.d.ts.map +1 -0
  4. package/dist/chains/algorand.js +148 -0
  5. package/dist/chains/algorand.js.map +1 -0
  6. package/dist/chains/aptos.d.ts +39 -0
  7. package/dist/chains/aptos.d.ts.map +1 -0
  8. package/dist/chains/aptos.js +168 -0
  9. package/dist/chains/aptos.js.map +1 -0
  10. package/dist/chains/cardano.d.ts +42 -0
  11. package/dist/chains/cardano.d.ts.map +1 -0
  12. package/dist/chains/cardano.js +188 -0
  13. package/dist/chains/cardano.js.map +1 -0
  14. package/dist/chains/cosmos.d.ts +42 -0
  15. package/dist/chains/cosmos.d.ts.map +1 -0
  16. package/dist/chains/cosmos.js +216 -0
  17. package/dist/chains/cosmos.js.map +1 -0
  18. package/dist/chains/dogecoin-litecoin.d.ts +57 -0
  19. package/dist/chains/dogecoin-litecoin.d.ts.map +1 -0
  20. package/dist/chains/dogecoin-litecoin.js +521 -0
  21. package/dist/chains/dogecoin-litecoin.js.map +1 -0
  22. package/dist/chains/ethereum.d.ts.map +1 -1
  23. package/dist/chains/ethereum.js +16 -0
  24. package/dist/chains/ethereum.js.map +1 -1
  25. package/dist/chains/hedera.d.ts +113 -0
  26. package/dist/chains/hedera.d.ts.map +1 -0
  27. package/dist/chains/hedera.js +302 -0
  28. package/dist/chains/hedera.js.map +1 -0
  29. package/dist/chains/icp.d.ts +95 -0
  30. package/dist/chains/icp.d.ts.map +1 -0
  31. package/dist/chains/icp.js +520 -0
  32. package/dist/chains/icp.js.map +1 -0
  33. package/dist/chains/kaspa.d.ts +152 -0
  34. package/dist/chains/kaspa.d.ts.map +1 -0
  35. package/dist/chains/kaspa.js +790 -0
  36. package/dist/chains/kaspa.js.map +1 -0
  37. package/dist/chains/multiversx.d.ts +143 -0
  38. package/dist/chains/multiversx.d.ts.map +1 -0
  39. package/dist/chains/multiversx.js +524 -0
  40. package/dist/chains/multiversx.js.map +1 -0
  41. package/dist/chains/near.d.ts +40 -0
  42. package/dist/chains/near.d.ts.map +1 -0
  43. package/dist/chains/near.js +170 -0
  44. package/dist/chains/near.js.map +1 -0
  45. package/dist/chains/polkadot.d.ts +43 -0
  46. package/dist/chains/polkadot.d.ts.map +1 -0
  47. package/dist/chains/polkadot.js +179 -0
  48. package/dist/chains/polkadot.js.map +1 -0
  49. package/dist/chains/ripple.d.ts +41 -0
  50. package/dist/chains/ripple.d.ts.map +1 -0
  51. package/dist/chains/ripple.js +190 -0
  52. package/dist/chains/ripple.js.map +1 -0
  53. package/dist/chains/stellar.d.ts +40 -0
  54. package/dist/chains/stellar.d.ts.map +1 -0
  55. package/dist/chains/stellar.js +156 -0
  56. package/dist/chains/stellar.js.map +1 -0
  57. package/dist/chains/sui.d.ts +44 -0
  58. package/dist/chains/sui.d.ts.map +1 -0
  59. package/dist/chains/sui.js +157 -0
  60. package/dist/chains/sui.js.map +1 -0
  61. package/dist/chains/tezos.d.ts +43 -0
  62. package/dist/chains/tezos.d.ts.map +1 -0
  63. package/dist/chains/tezos.js +162 -0
  64. package/dist/chains/tezos.js.map +1 -0
  65. package/dist/chains/ton.d.ts +40 -0
  66. package/dist/chains/ton.d.ts.map +1 -0
  67. package/dist/chains/ton.js +168 -0
  68. package/dist/chains/ton.js.map +1 -0
  69. package/dist/chains/tron.d.ts +41 -0
  70. package/dist/chains/tron.d.ts.map +1 -0
  71. package/dist/chains/tron.js +124 -0
  72. package/dist/chains/tron.js.map +1 -0
  73. package/dist/core/types.d.ts +161 -1
  74. package/dist/core/types.d.ts.map +1 -1
  75. package/dist/index.d.ts +19 -2
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +79 -4
  78. package/dist/index.js.map +1 -1
  79. package/dist/utils/optional-deps.d.ts +9 -0
  80. package/dist/utils/optional-deps.d.ts.map +1 -0
  81. package/dist/utils/optional-deps.js +21 -0
  82. package/dist/utils/optional-deps.js.map +1 -0
  83. package/dist/utils/validation.d.ts.map +1 -1
  84. package/dist/utils/validation.js +6 -1
  85. package/dist/utils/validation.js.map +1 -1
  86. package/dist/wallet/wallet.d.ts.map +1 -1
  87. package/dist/wallet/wallet.js +61 -33
  88. package/dist/wallet/wallet.js.map +1 -1
  89. package/package.json +35 -1
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Kaspa Chain Adapter
3
+ *
4
+ * Builds Kaspa UTXO transactions, computes per-input sighashes for
5
+ * BIP-340 Schnorr signing via the FROST threshold signing network,
6
+ * and broadcasts via the Kaspa REST API.
7
+ *
8
+ * Kaspa uses secp256k1 with BIP-340 Schnorr signatures (64 bytes),
9
+ * the same signature scheme as Bitcoin Taproot. FROST-secp256k1
10
+ * produces native BIP-340 compatible Schnorr signatures.
11
+ *
12
+ * Key features:
13
+ * - UTXO-based transaction model (similar to Bitcoin)
14
+ * - BIP-340 Schnorr signatures (64 bytes, same as Taproot)
15
+ * - ~1 second block time (BlockDAG architecture)
16
+ * - Per-input sighash computation for multi-input transactions
17
+ *
18
+ * No external dependencies — uses raw HTTP API calls and Node.js crypto.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { KaspaAdapter } from '@sequence0/sdk';
23
+ *
24
+ * const kaspa = new KaspaAdapter('mainnet');
25
+ *
26
+ * // Build a transfer transaction
27
+ * const unsignedTx = await kaspa.buildTransaction(
28
+ * { to: 'kaspa:qr...recipient', amount: 100000000 }, // 1 KAS
29
+ * 'kaspa:qr...sender'
30
+ * );
31
+ *
32
+ * // ... sign each sighash via FROST Schnorr ...
33
+ * const signedTx = await kaspa.attachSignature(unsignedTx, signatureHex);
34
+ * const txId = await kaspa.broadcast(signedTx);
35
+ * ```
36
+ */
37
+ import { ChainAdapter, KaspaTransaction } from '../core/types';
38
+ export declare class KaspaAdapter implements ChainAdapter {
39
+ private network;
40
+ private apiUrl;
41
+ /**
42
+ * Create a Kaspa adapter.
43
+ *
44
+ * @param network - Network to connect to: 'mainnet' or 'testnet'
45
+ * @param apiUrl - Custom API URL (overrides the default for the network)
46
+ */
47
+ constructor(network?: 'mainnet' | 'testnet', apiUrl?: string);
48
+ getRpcUrl(): string;
49
+ /**
50
+ * Build an unsigned Kaspa transaction.
51
+ *
52
+ * Fetches UTXOs for the sender, selects inputs to cover the amount
53
+ * plus fees, builds outputs (payment + change), and computes
54
+ * per-input sighashes for Schnorr signing.
55
+ *
56
+ * Returns hex-encoded JSON containing the TX data and sighashes.
57
+ * Each sighash must be independently signed via FROST Schnorr.
58
+ *
59
+ * @param tx - Transaction parameters (to, amount, feeRate)
60
+ * @param fromAddress - Sender kaspa:... address
61
+ * @returns Hex-encoded payload with sighashes and TX structure
62
+ */
63
+ buildTransaction(tx: KaspaTransaction, fromAddress: string): Promise<string>;
64
+ /**
65
+ * Extract the signing payload from the buildTransaction output.
66
+ *
67
+ * Returns the primary sighash (first input). For multi-input
68
+ * transactions, callers should decode the full payload to get
69
+ * all sighashes from the `sighashes` array.
70
+ */
71
+ getSigningPayload(unsignedTx: string): string;
72
+ /**
73
+ * Attach BIP-340 Schnorr signature(s) to the Kaspa transaction.
74
+ *
75
+ * Each input requires its own 64-byte Schnorr signature. For
76
+ * multi-input transactions, pass comma-separated signatures or
77
+ * concatenated 64-byte signatures.
78
+ *
79
+ * @param unsignedTx - Hex-encoded unsigned transaction from buildTransaction
80
+ * @param signature - 64-byte Schnorr signature(s) (hex-encoded)
81
+ * @returns Hex-encoded signed transaction payload
82
+ */
83
+ attachSignature(unsignedTx: string, signature: string): Promise<string>;
84
+ /**
85
+ * Broadcast a signed Kaspa transaction.
86
+ *
87
+ * Constructs the RPC-compatible transaction object with inputs,
88
+ * outputs, and witness signatures, then sends it to the Kaspa
89
+ * REST API for propagation to the network.
90
+ *
91
+ * @param signedTx - Hex-encoded signed transaction from attachSignature
92
+ * @returns Transaction ID
93
+ */
94
+ broadcast(signedTx: string): Promise<string>;
95
+ /**
96
+ * Get the KAS balance for an address.
97
+ *
98
+ * Returns balance in sompi (1 KAS = 1e8 sompi).
99
+ *
100
+ * @param address - Kaspa kaspa:... address
101
+ * @returns Balance in sompi as a string
102
+ */
103
+ getBalance(address: string): Promise<string>;
104
+ /**
105
+ * Fetch UTXOs for a Kaspa address from the REST API.
106
+ *
107
+ * @param address - kaspa:... address
108
+ * @returns Array of UTXOs
109
+ */
110
+ private fetchUtxos;
111
+ /**
112
+ * Validate a Kaspa address format.
113
+ *
114
+ * @param address - Address to validate
115
+ * @throws Error if the address is invalid
116
+ */
117
+ private validateAddress;
118
+ /**
119
+ * Derive a kaspa:... address from a 32-byte x-only public key.
120
+ *
121
+ * FROST-secp256k1 produces a group verifying key (compressed point).
122
+ * Extract the x-only (32-byte) key and encode as a Kaspa P2PK Schnorr address.
123
+ *
124
+ * @param pubkeyHex - 32-byte x-only public key (hex-encoded), or 33-byte compressed
125
+ * @returns kaspa:... address
126
+ */
127
+ deriveAddress(pubkeyHex: string): string;
128
+ /**
129
+ * Estimate the fee for a transaction.
130
+ *
131
+ * @param numInputs - Number of inputs
132
+ * @param numOutputs - Number of outputs
133
+ * @param feeRate - Fee rate in sompi per gram (default: 1)
134
+ * @returns Estimated fee in sompi
135
+ */
136
+ estimateFee(numInputs: number, numOutputs: number, feeRate?: number): number;
137
+ }
138
+ /**
139
+ * Create a Kaspa mainnet adapter
140
+ *
141
+ * @param apiUrl - Optional custom API URL
142
+ * @returns KaspaAdapter configured for mainnet
143
+ */
144
+ export declare function createKaspaAdapter(apiUrl?: string): KaspaAdapter;
145
+ /**
146
+ * Create a Kaspa testnet adapter
147
+ *
148
+ * @param apiUrl - Optional custom API URL
149
+ * @returns KaspaAdapter configured for testnet
150
+ */
151
+ export declare function createKaspaTestnetAdapter(apiUrl?: string): KaspaAdapter;
152
+ //# sourceMappingURL=kaspa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kaspa.d.ts","sourceRoot":"","sources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