@sip-protocol/sdk 0.1.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/src/index.ts ADDED
@@ -0,0 +1,369 @@
1
+ /**
2
+ * @sip-protocol/sdk
3
+ *
4
+ * Core SDK for Shielded Intents Protocol (SIP)
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { SIP, PrivacyLevel } from '@sip-protocol/sdk'
9
+ *
10
+ * const sip = new SIP({ network: 'testnet' })
11
+ *
12
+ * const intent = await sip.createIntent({
13
+ * input: { chain: 'solana', token: 'SOL', amount: 10n },
14
+ * output: { chain: 'ethereum', token: 'ETH' },
15
+ * privacy: PrivacyLevel.SHIELDED,
16
+ * })
17
+ *
18
+ * const quotes = await sip.getQuotes(intent)
19
+ * const result = await sip.execute(intent, quotes[0])
20
+ * ```
21
+ */
22
+
23
+ // Errors and Error Utilities
24
+ export {
25
+ // Error codes
26
+ ErrorCode,
27
+ // Base error
28
+ SIPError,
29
+ // Specialized errors
30
+ ValidationError,
31
+ CryptoError,
32
+ ProofError,
33
+ IntentError,
34
+ NetworkError,
35
+ // Legacy errors (now extend proper parent classes)
36
+ ProofNotImplementedError,
37
+ EncryptionNotImplementedError,
38
+ // Utility functions
39
+ isSIPError,
40
+ hasErrorCode,
41
+ wrapError,
42
+ getErrorMessage,
43
+ } from './errors'
44
+
45
+ export type { SerializedError } from './errors'
46
+
47
+ // Main client
48
+ export { SIP, createSIP } from './sip'
49
+ export type { SIPConfig, WalletAdapter } from './sip'
50
+
51
+ // Intent creation
52
+ export {
53
+ IntentBuilder,
54
+ createShieldedIntent,
55
+ attachProofs,
56
+ hasRequiredProofs,
57
+ trackIntent,
58
+ isExpired,
59
+ getTimeRemaining,
60
+ serializeIntent,
61
+ deserializeIntent,
62
+ getIntentSummary,
63
+ } from './intent'
64
+ export type { CreateIntentOptions } from './intent'
65
+
66
+ // Stealth addresses
67
+ export {
68
+ generateStealthMetaAddress,
69
+ generateStealthAddress,
70
+ deriveStealthPrivateKey,
71
+ checkStealthAddress,
72
+ encodeStealthMetaAddress,
73
+ decodeStealthMetaAddress,
74
+ } from './stealth'
75
+
76
+ // Privacy utilities
77
+ export {
78
+ getPrivacyConfig,
79
+ generateViewingKey,
80
+ deriveViewingKey,
81
+ encryptForViewing,
82
+ decryptWithViewing,
83
+ getPrivacyDescription,
84
+ } from './privacy'
85
+ // Note: isValidPrivacyLevel is exported from validation.ts
86
+ export type { PrivacyConfig, TransactionData } from './privacy'
87
+
88
+ // Crypto utilities (legacy - use commitment module for new code)
89
+ // For ZK proofs, use ProofProvider from './proofs'
90
+ export {
91
+ createCommitment,
92
+ verifyCommitment,
93
+ generateIntentId,
94
+ hash,
95
+ generateRandomBytes,
96
+ } from './crypto'
97
+
98
+ // Pedersen Commitments (recommended for new code)
99
+ export {
100
+ commit,
101
+ verifyOpening,
102
+ commitZero,
103
+ addCommitments,
104
+ subtractCommitments,
105
+ addBlindings,
106
+ subtractBlindings,
107
+ getGenerators,
108
+ generateBlinding,
109
+ } from './commitment'
110
+
111
+ export type {
112
+ PedersenCommitment,
113
+ CommitmentPoint,
114
+ } from './commitment'
115
+
116
+ // Validation utilities
117
+ export {
118
+ isValidChainId,
119
+ isValidPrivacyLevel,
120
+ isValidHex,
121
+ isValidHexLength,
122
+ isValidAmount,
123
+ isNonNegativeAmount,
124
+ isValidSlippage,
125
+ isValidStealthMetaAddress,
126
+ isValidCompressedPublicKey,
127
+ isValidPrivateKey,
128
+ isValidScalar,
129
+ validateCreateIntentParams,
130
+ validateAsset,
131
+ validateIntentInput,
132
+ validateIntentOutput,
133
+ validateViewingKey,
134
+ validateScalar,
135
+ } from './validation'
136
+
137
+ // Proof providers
138
+ export {
139
+ MockProofProvider,
140
+ NoirProofProvider,
141
+ ProofGenerationError,
142
+ } from './proofs'
143
+
144
+ export type {
145
+ ProofProvider,
146
+ ProofFramework,
147
+ FundingProofParams,
148
+ ValidityProofParams,
149
+ FulfillmentProofParams,
150
+ OracleAttestation,
151
+ ProofResult,
152
+ NoirProviderConfig,
153
+ } from './proofs'
154
+
155
+ // Re-export types for convenience
156
+ export {
157
+ PrivacyLevel,
158
+ IntentStatus,
159
+ SIP_VERSION,
160
+ NATIVE_TOKENS,
161
+ isPrivate,
162
+ supportsViewingKey,
163
+ } from '@sip-protocol/types'
164
+
165
+ export type {
166
+ ShieldedIntent,
167
+ CreateIntentParams,
168
+ TrackedIntent,
169
+ Quote,
170
+ FulfillmentResult,
171
+ StealthMetaAddress,
172
+ StealthAddress,
173
+ StealthAddressRecovery,
174
+ Commitment,
175
+ ZKProof,
176
+ ViewingKey,
177
+ Asset,
178
+ ChainId,
179
+ HexString,
180
+ Hash,
181
+ } from '@sip-protocol/types'
182
+
183
+ // Network Adapters
184
+ export {
185
+ OneClickClient,
186
+ NEARIntentsAdapter,
187
+ createNEARIntentsAdapter,
188
+ } from './adapters'
189
+
190
+ export type {
191
+ SwapRequest,
192
+ PreparedSwap,
193
+ SwapResult,
194
+ NEARIntentsAdapterConfig,
195
+ } from './adapters'
196
+
197
+ // Solver
198
+ export { MockSolver, createMockSolver } from './solver'
199
+ export type { MockSolverConfig } from './solver'
200
+
201
+ // Re-export solver types
202
+ export type {
203
+ Solver,
204
+ SolverCapabilities,
205
+ SolverVisibleIntent,
206
+ SolverQuote,
207
+ SIPSolver,
208
+ FulfillmentStatus,
209
+ FulfillmentRequest,
210
+ FulfillmentCommitment,
211
+ FulfillmentProof,
212
+ SwapRoute,
213
+ SwapRouteStep,
214
+ SolverEvent,
215
+ SolverEventListener,
216
+ } from '@sip-protocol/types'
217
+
218
+ // Re-export NEAR Intents types for convenience
219
+ export {
220
+ OneClickSwapType,
221
+ OneClickSwapStatus,
222
+ OneClickDepositMode,
223
+ OneClickErrorCode,
224
+ } from '@sip-protocol/types'
225
+
226
+ export type {
227
+ OneClickConfig,
228
+ OneClickQuoteRequest,
229
+ OneClickQuoteResponse,
230
+ OneClickStatusResponse,
231
+ DefuseAssetId,
232
+ } from '@sip-protocol/types'
233
+
234
+ // Zcash
235
+ export {
236
+ ZcashRPCClient,
237
+ ZcashRPCError,
238
+ createZcashClient,
239
+ ZcashShieldedService,
240
+ createZcashShieldedService,
241
+ } from './zcash'
242
+ export { ZcashErrorCode } from '@sip-protocol/types'
243
+
244
+ export type {
245
+ ZcashShieldedServiceConfig,
246
+ ShieldedSendParams,
247
+ ShieldedSendResult,
248
+ ReceivedNote,
249
+ ShieldedBalance,
250
+ ExportedViewingKey,
251
+ } from './zcash'
252
+
253
+ export type {
254
+ ZcashConfig,
255
+ ZcashNetwork,
256
+ ZcashAddressType,
257
+ ZcashReceiverType,
258
+ ZcashAddressInfo,
259
+ ZcashNewAccount,
260
+ ZcashAccountAddress,
261
+ ZcashPoolBalance,
262
+ ZcashAccountBalance,
263
+ ZcashPool,
264
+ ZcashUnspentNote,
265
+ ZcashSendRecipient,
266
+ ZcashPrivacyPolicy,
267
+ ZcashShieldedSendParams,
268
+ ZcashOperationStatus,
269
+ ZcashOperationTxResult,
270
+ ZcashOperationError,
271
+ ZcashOperation,
272
+ ZcashBlockHeader,
273
+ ZcashBlock,
274
+ ZcashBlockchainInfo,
275
+ ZcashNetworkInfo,
276
+ } from '@sip-protocol/types'
277
+
278
+ // Wallet Adapters
279
+ export {
280
+ BaseWalletAdapter,
281
+ MockWalletAdapter,
282
+ WalletError,
283
+ notConnectedError,
284
+ featureNotSupportedError,
285
+ walletRegistry,
286
+ registerWallet,
287
+ createWalletFactory,
288
+ isPrivateWalletAdapter,
289
+ WalletErrorCode,
290
+ // Solana
291
+ SolanaWalletAdapter,
292
+ createSolanaAdapter,
293
+ MockSolanaAdapter,
294
+ createMockSolanaAdapter,
295
+ createMockSolanaProvider,
296
+ createMockSolanaConnection,
297
+ getSolanaProvider,
298
+ detectSolanaWallets,
299
+ solanaPublicKeyToHex,
300
+ base58ToHex,
301
+ // Ethereum
302
+ EthereumWalletAdapter,
303
+ createEthereumAdapter,
304
+ MockEthereumAdapter,
305
+ createMockEthereumAdapter,
306
+ createMockEthereumProvider,
307
+ getEthereumProvider,
308
+ detectEthereumWallets,
309
+ toHex,
310
+ fromHex,
311
+ hexToNumber,
312
+ normalizeAddress,
313
+ getDefaultRpcEndpoint,
314
+ EthereumChainId,
315
+ } from './wallet'
316
+
317
+ export type {
318
+ WalletConnectionState,
319
+ Signature,
320
+ UnsignedTransaction,
321
+ SignedTransaction,
322
+ TransactionReceipt,
323
+ WalletEventType,
324
+ WalletEvent,
325
+ WalletEventHandler,
326
+ WalletConnectEvent,
327
+ WalletDisconnectEvent,
328
+ WalletAccountChangedEvent,
329
+ WalletChainChangedEvent,
330
+ WalletErrorEvent,
331
+ WalletAdapter as IWalletAdapter,
332
+ PrivateWalletAdapter,
333
+ WalletShieldedSendParams,
334
+ WalletShieldedSendResult,
335
+ WalletInfo,
336
+ WalletAdapterFactory,
337
+ WalletRegistryEntry,
338
+ // Solana types
339
+ SolanaPublicKey,
340
+ SolanaTransaction,
341
+ SolanaVersionedTransaction,
342
+ SolanaWalletProvider,
343
+ SolanaWalletName,
344
+ SolanaCluster,
345
+ SolanaAdapterConfig,
346
+ SolanaConnection,
347
+ SolanaSendOptions,
348
+ SolanaUnsignedTransaction,
349
+ SolanaSignature,
350
+ MockSolanaAdapterConfig,
351
+ // Ethereum types
352
+ EIP1193Provider,
353
+ EIP1193RequestArguments,
354
+ EIP1193Event,
355
+ EIP1193ConnectInfo,
356
+ EIP1193ProviderRpcError,
357
+ EIP712Domain,
358
+ EIP712TypeDefinition,
359
+ EIP712Types,
360
+ EIP712TypedData,
361
+ EthereumTransactionRequest,
362
+ EthereumTransactionReceipt,
363
+ EthereumTokenMetadata,
364
+ EthereumChainMetadata,
365
+ EthereumWalletName,
366
+ EthereumAdapterConfig,
367
+ EthereumChainIdType,
368
+ MockEthereumAdapterConfig,
369
+ } from './wallet'