@fatsolutions/privacy-pools-core-starknet-sdk 0.0.5 → 0.0.7

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 ADDED
@@ -0,0 +1,326 @@
1
+ # Privacy Pool Starknet SDK
2
+
3
+ A TypeScript SDK for interacting with Privacy Pool contracts on Starknet, featuring Garaga proof verification and comprehensive contract interaction capabilities.
4
+
5
+ ## Overview
6
+
7
+ The Privacy Pool Starknet SDK extends the core Privacy Pool SDK with Starknet-specific functionality. It provides:
8
+
9
+ - **Garaga Integration**: Converts zero-knowledge proofs to Garaga format for efficient verification on Starknet
10
+ - **Contract Interactions**: Type-safe interfaces for all Privacy Pool operations (deposits, withdrawals, relays, ragequits)
11
+ - **Event Fetching**: Comprehensive event parsing and data retrieval from Starknet networks
12
+ - **Admin Operations**: Full support for pool management and configuration
13
+ - **Error Handling**: Detailed error codes with human-readable contract error parsing
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @fatsolutions/privacy-pools-core-starknet-sdk
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { PrivacyPoolStarknetSDK, StarknetDataService, Mode } from '@fatsolutions/privacy-pools-core-starknet-sdk';
25
+ import { Account, RpcProvider } from 'starknet';
26
+
27
+ // Initialize the SDK
28
+ const circuits = new YourCircuitsImplementation(); // Implement CircuitsInterface
29
+ const sdk = new PrivacyPoolStarknetSDK(circuits);
30
+
31
+ // Create contract service
32
+ const account = new Account(provider, accountAddress, privateKey);
33
+ const contractService = sdk.createSNContractInstance(entrypointAddress, account);
34
+
35
+ // Deposit ETH
36
+ const depositCall = await contractService.depositETH(
37
+ BigInt("1000000000000000000"), // 1 ETH in wei
38
+ precommitment,
39
+ { mode: Mode.EXECUTE }
40
+ );
41
+
42
+ // Generate withdrawal proof and execute
43
+ const { withdrawalProof, calldata } = await sdk.proveWithdrawalSN(commitment, withdrawalInput);
44
+ const withdrawResult = await contractService.withdraw(
45
+ withdrawal,
46
+ calldata,
47
+ scope,
48
+ { mode: Mode.EXECUTE }
49
+ );
50
+ ```
51
+
52
+ ## Core Components
53
+
54
+ ### PrivacyPoolStarknetSDK
55
+
56
+ The main SDK class that extends the core Privacy Pool SDK with Starknet-specific functionality.
57
+
58
+ ```typescript
59
+ // Initialize SDK
60
+ const sdk = new PrivacyPoolStarknetSDK(circuits);
61
+
62
+ // Create contract service
63
+ const contractService = sdk.createSNContractInstance(entrypointAddress, account);
64
+
65
+ // Generate Starknet-optimized proofs
66
+ const { withdrawalProof, calldata } = await sdk.proveWithdrawalSN(commitment, input);
67
+ const { commitmentProof, calldata: commitCalldata } = await sdk.proveCommitmentSN(commitment);
68
+ ```
69
+
70
+ ### Contract Interactions Service
71
+
72
+ The `SNContractInteractionsService` provides methods for all Privacy Pool operations with support for both simulation and execution modes.
73
+
74
+ ```typescript
75
+ // Deposit operations
76
+ await contractService.depositETH(amount, precommitment, { mode: Mode.EXECUTE });
77
+ await contractService.depositERC20(tokenAddress, amount, precommitment, { mode: Mode.SIMULATE });
78
+
79
+ // Withdrawal operations
80
+ await contractService.withdraw(withdrawal, proof, scope, { mode: Mode.EXECUTE });
81
+ await contractService.relay(withdrawal, proof, scope, { mode: Mode.EXECUTE });
82
+
83
+ // Ragequit operation
84
+ await contractService.ragequit(ragequitProof, poolAddress, { mode: Mode.EXECUTE });
85
+
86
+ // Approve and deposit in one transaction
87
+ await contractService.approveAndDeposit(
88
+ entrypointAddress,
89
+ tokenAddress,
90
+ amount,
91
+ precommitment,
92
+ { mode: Mode.EXECUTE }
93
+ );
94
+ ```
95
+
96
+ ### Data Service
97
+
98
+ The `StarknetDataService` fetches and parses events from Starknet networks.
99
+
100
+ ```typescript
101
+ const provider = new RpcProvider({ nodeUrl: "https://starknet-mainnet.public.blastapi.io" });
102
+ const dataService = new StarknetDataService(provider);
103
+
104
+ // Fetch pool events
105
+ const deposits = await dataService.getDeposits(poolInfo);
106
+ const withdrawals = await dataService.getWithdrawals(poolInfo);
107
+ const ragequits = await dataService.getRagequits(poolInfo);
108
+ ```
109
+
110
+ ### Admin Operations
111
+
112
+ Administrative functions for pool management:
113
+
114
+ ```typescript
115
+ // Register a new pool
116
+ await contractService.admin.registerPool(
117
+ assetAddress,
118
+ poolAddress,
119
+ minimumDepositAmount,
120
+ vettingFeeBPS,
121
+ maxRelayFeeBPS,
122
+ { mode: Mode.EXECUTE }
123
+ );
124
+
125
+ // Update pool configuration
126
+ await contractService.admin.updatePoolConfiguration(
127
+ assetAddress,
128
+ newMinimumDepositAmount,
129
+ newVettingFeeBPS,
130
+ newMaxRelayFeeBPS,
131
+ { mode: Mode.EXECUTE }
132
+ );
133
+
134
+ // Update merkle root
135
+ await contractService.admin.updateRoot(newRoot, ipfsCID, { mode: Mode.EXECUTE });
136
+ ```
137
+
138
+ ## Execution Modes
139
+
140
+ The SDK supports different execution modes for all operations:
141
+
142
+ - **`Mode.EXECUTE`**: Execute the transaction on-chain
143
+ - **`Mode.SIMULATE`**: Simulate the transaction without executing
144
+ - **No mode specified**: Returns a `Call` object for manual execution
145
+
146
+ ```typescript
147
+ // Execute immediately
148
+ const result = await contractService.depositETH(amount, precommitment, { mode: Mode.EXECUTE });
149
+
150
+ // Simulate first
151
+ const simulation = await contractService.depositETH(amount, precommitment, { mode: Mode.SIMULATE });
152
+
153
+ // Get call for manual execution
154
+ const call = await contractService.depositETH(amount, precommitment);
155
+ // Execute manually with account.execute([call])
156
+ ```
157
+
158
+ ## Error Handling
159
+
160
+ The SDK provides comprehensive error handling with specific error types:
161
+
162
+ ```typescript
163
+ import {
164
+ StarknetSDKError,
165
+ SNPoolError,
166
+ SNContractError,
167
+ SNFormatError,
168
+ parseContractError
169
+ } from '@fatsolutions/privacy-pools-core-starknet-sdk';
170
+
171
+ try {
172
+ await contractService.depositETH(tooSmallAmount, precommitment, { mode: Mode.EXECUTE });
173
+ } catch (error) {
174
+ if (error instanceof SNPoolError) {
175
+ console.log('Pool validation error:', error.message);
176
+ } else if (error instanceof SNContractError) {
177
+ console.log('Contract error:', error.message);
178
+ // Parse contract error for human-readable message
179
+ const readable = parseContractError(error.message);
180
+ if (readable) console.log('Readable error:', readable);
181
+ }
182
+ }
183
+ ```
184
+
185
+ ## Types and Interfaces
186
+
187
+ ### Core Types
188
+
189
+ ```typescript
190
+ // Withdrawal data structure
191
+ interface Withdrawal {
192
+ processor: BigNumberish;
193
+ data: BigNumberish[];
194
+ }
195
+
196
+ // Relay data for withdrawal processing
197
+ interface RelayData {
198
+ recipient: BigNumberish;
199
+ feeRecipient: BigNumberish;
200
+ relayFeeBPS: BigNumberish;
201
+ }
202
+
203
+ // Garaga proof structures
204
+ interface Groth16Proof {
205
+ a: G1Point$1;
206
+ b: G2Point$1;
207
+ c: G1Point$1;
208
+ publicInputs: bigint[];
209
+ }
210
+ ```
211
+
212
+ ### Utility Functions
213
+
214
+ ```typescript
215
+ // Compute scope for a privacy pool
216
+ const scope = computeScope(poolAddress, chainId, assetAddress);
217
+
218
+ // Compute context for withdrawals
219
+ const context = computeContext(withdrawal, scope);
220
+
221
+ // Convert proof to Garaga calldata
222
+ const calldata = await withdrawalProofToGaragaCalldata(withdrawalProof, vkeyRaw);
223
+ ```
224
+
225
+ ## Contract Error Codes
226
+
227
+ The SDK automatically parses common contract errors:
228
+
229
+ | Error Code | Description |
230
+ |------------|-------------|
231
+ | `0x496e76616c69642050726f6f66` | Invalid Proof |
232
+ | `0x4e756c6c69666965722075736564` | Nullifier used |
233
+ | `0x496e76616c696420416d6f756e74` | Invalid Amount |
234
+ | `0x506f6f6c206e6f7420666f756e64` | Pool not found |
235
+ | `0x56616c7565206c6573732074686174206d696e696d756d` | Value less than minimum |
236
+
237
+ ## Development
238
+
239
+ ### Building
240
+
241
+ ```bash
242
+ npm run build
243
+ ```
244
+
245
+ ### Testing
246
+
247
+ ```bash
248
+ npm test
249
+ npm run test:cov # With coverage
250
+ ```
251
+
252
+ ### Type Checking
253
+
254
+ ```bash
255
+ npx tsc --noEmit
256
+ ```
257
+
258
+ ## Examples
259
+
260
+ ### Complete Deposit Flow
261
+
262
+ ```typescript
263
+ import { PrivacyPoolStarknetSDK, Mode } from '@fatsolutions/privacy-pools-core-starknet-sdk';
264
+ import { Account, RpcProvider } from 'starknet';
265
+
266
+ async function depositExample() {
267
+ // Setup
268
+ const provider = new RpcProvider({ nodeUrl: "your-starknet-node" });
269
+ const account = new Account(provider, accountAddress, privateKey);
270
+ const sdk = new PrivacyPoolStarknetSDK(circuits);
271
+ const contractService = sdk.createSNContractInstance(entrypointAddress, account);
272
+
273
+ // Generate precommitment
274
+ const { precommitment } = generatePrecommitment(nullifier, secret);
275
+
276
+ // Execute deposit
277
+ try {
278
+ const result = await contractService.depositETH(
279
+ BigInt("1000000000000000000"), // 1 ETH
280
+ precommitment,
281
+ { mode: Mode.EXECUTE }
282
+ );
283
+ console.log('Deposit successful:', result.transaction_hash);
284
+ } catch (error) {
285
+ console.error('Deposit failed:', error.message);
286
+ }
287
+ }
288
+ ```
289
+
290
+ ### Complete Withdrawal Flow
291
+
292
+ ```typescript
293
+ async function withdrawalExample() {
294
+ // Generate withdrawal proof
295
+ const { withdrawalProof, calldata } = await sdk.proveWithdrawalSN(commitment, {
296
+ nullifier: commitment.preimage.precommitment.nullifier,
297
+ secret: commitment.preimage.precommitment.secret,
298
+ recipient: recipientAddress,
299
+ relayerFee: BigInt(0)
300
+ });
301
+
302
+ // Prepare withdrawal data
303
+ const withdrawal: Withdrawal = {
304
+ processor: processorAddress,
305
+ data: [recipientAddress, BigInt(0)] // recipient, relayer fee
306
+ };
307
+
308
+ // Execute withdrawal
309
+ const result = await contractService.withdraw(
310
+ withdrawal,
311
+ calldata,
312
+ scope,
313
+ { mode: Mode.EXECUTE }
314
+ );
315
+
316
+ console.log('Withdrawal successful:', result.transaction_hash);
317
+ }
318
+ ```
319
+
320
+ ## License
321
+
322
+ Apache-2.0
323
+
324
+ ## Support
325
+
326
+ For questions and support, please open an issue on the GitHub repository.
@@ -1,5 +1,24 @@
1
- import { RpcProvider } from "starknet";
1
+ import { RpcProvider, EmittedEvent } from "starknet";
2
2
  import { DepositEvent, WithdrawalEvent, RagequitEvent, PoolInfo } from "@0xbow/privacy-pools-core-sdk";
3
+ interface StarknetDepositedEventData {
4
+ depositor: bigint;
5
+ commitment: bigint;
6
+ label: bigint;
7
+ value: bigint;
8
+ preCommitmentHash: bigint;
9
+ }
10
+ interface StarknetWithdrawnEventData {
11
+ procesoor: bigint;
12
+ newCommitmentHash: bigint;
13
+ withdrawnValue: bigint;
14
+ existingNullifierHash: bigint;
15
+ }
16
+ interface StarknetRageQuitEventData {
17
+ depositor: bigint;
18
+ commitment: bigint;
19
+ label: bigint;
20
+ value: bigint;
21
+ }
3
22
  /**
4
23
  * Starknet implementation of DataService for privacy pool event fetching.
5
24
  *
@@ -41,4 +60,21 @@ export declare class StarknetDataService {
41
60
  * @throws {StarknetSDKError} If provider is not configured or network error occurs
42
61
  */
43
62
  getRagequits(pool: PoolInfo, fromBlock?: bigint): Promise<RagequitEvent[]>;
63
+ private static parseGenericEvents;
64
+ static parseDepositEvents(rawEvents: EmittedEvent[]): {
65
+ eventData: StarknetDepositedEventData;
66
+ blockNumber: import("starknet").BlockNumber | undefined;
67
+ transactionHash: string | undefined;
68
+ }[];
69
+ static parseWithdrawalEvents(rawEvents: EmittedEvent[]): {
70
+ eventData: StarknetWithdrawnEventData;
71
+ blockNumber: import("starknet").BlockNumber | undefined;
72
+ transactionHash: string | undefined;
73
+ }[];
74
+ static parseRagequitEvents(rawEvents: EmittedEvent[]): {
75
+ eventData: StarknetRageQuitEventData;
76
+ blockNumber: import("starknet").BlockNumber | undefined;
77
+ transactionHash: string | undefined;
78
+ }[];
44
79
  }
80
+ export {};
@@ -134,18 +134,7 @@ class StarknetDataService {
134
134
  keys: [[RAGEQUIT_EVENT_SELECTOR]],
135
135
  chunk_size: 1000,
136
136
  });
137
- // Parse all events at once using starknet.js event parser
138
- const abiEvents = starknet_1.events.getAbiEvents(PrivacyPool_abi_js_1.PrivacyPoolABI);
139
- const abiStructs = {}; // Could extract from ABI if needed
140
- const abiEnums = {}; // Could extract from ABI if needed
141
- const parsedEvents = starknet_1.events.parseEvents(eventsResult.events, abiEvents, abiStructs, abiEnums);
142
- return parsedEvents
143
- .filter((parsedEvent) => parsedEvent[RAGEQUIT_EVENT_ABI_NAME] !== undefined)
144
- .map((parsedEvent) => ({
145
- eventData: parsedEvent[RAGEQUIT_EVENT_ABI_NAME],
146
- blockNumber: parsedEvent.block_number,
147
- transactionHash: parsedEvent.transaction_hash
148
- }))
137
+ return StarknetDataService.parseRagequitEvents(eventsResult.events)
149
138
  .map(({ eventData, blockNumber, transactionHash }) => ({
150
139
  ragequitter: starknet_1.num.toHex(eventData.depositor),
151
140
  commitment: eventData.commitment,
@@ -161,6 +150,26 @@ class StarknetDataService {
161
150
  throw new index_js_1.StarknetSDKError(`Failed to fetch ragequits: ${error instanceof Error ? error.message : "Unknown error"}`, index_js_1.SNBaseErrorCode.UNKNOWN);
162
151
  }
163
152
  }
153
+ static parseGenericEvents(rawEvents, abiEventName) {
154
+ const abiEvents = starknet_1.events.getAbiEvents(PrivacyPool_abi_js_1.PrivacyPoolABI);
155
+ const parsedEvents = starknet_1.events.parseEvents(rawEvents, abiEvents, {}, {});
156
+ return parsedEvents
157
+ .filter((parsedEvent) => parsedEvent[abiEventName] !== undefined)
158
+ .map((parsedEvent) => ({
159
+ eventData: parsedEvent[abiEventName],
160
+ blockNumber: parsedEvent.block_number,
161
+ transactionHash: parsedEvent.transaction_hash
162
+ }));
163
+ }
164
+ static parseDepositEvents(rawEvents) {
165
+ return StarknetDataService.parseGenericEvents(rawEvents, DEPOSIT_EVENT_ABI_NAME);
166
+ }
167
+ static parseWithdrawalEvents(rawEvents) {
168
+ return StarknetDataService.parseGenericEvents(rawEvents, WITHDRAWAL_EVENT_ABI_NAME);
169
+ }
170
+ static parseRagequitEvents(rawEvents) {
171
+ return StarknetDataService.parseGenericEvents(rawEvents, RAGEQUIT_EVENT_ABI_NAME);
172
+ }
164
173
  }
165
174
  exports.StarknetDataService = StarknetDataService;
166
175
  //# sourceMappingURL=data.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data.service.js","sourceRoot":"","sources":["../src/data.service.ts"],"names":[],"mappings":";;;AAAA,uCAAuF;AACvF,gDAAsE;AACtE,kEAA2D;AAS3D,kDAAkD;AAClD,MAAM,sBAAsB,GAAG,cAAG,CAAC,KAAK,CAAC,eAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;AAC3E,MAAM,yBAAyB,GAAG,cAAG,CAAC,KAAK,CAAC,eAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,MAAM,uBAAuB,GAAG,cAAG,CAAC,KAAK,CAAC,eAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AAE3E,uCAAuC;AACvC,MAAM,sBAAsB,GAAG,6CAA6C,CAAC;AAC7E,MAAM,yBAAyB,GAAG,6CAA6C,CAAC;AAChF,MAAM,uBAAuB,GAAG,4CAA4C,CAAC;AAyB7E;;;;;;GAMG;AACH,MAAa,mBAAmB;IACb,QAAQ,CAAc;IAEvC;;;;OAIG;IACH,YAAY,QAAqB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAC,IAAc;QAC9B,IAAI,CAAC;YAEH,uCAAuC;YACvC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;gBACjD,UAAU,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;gBAC1D,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,IAAI,EAAE,CAAC,CAAC,sBAAsB,CAAC,CAAC,EAAE,mCAAmC;gBACrE,UAAU,EAAE,IAAI,EAAE,sBAAsB;aACz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AAE,EACxF,0BAAe,CAAC,OAAO,CACxB,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAI,SAAyB,EAAE,YAA0B;QACxF,MAAM,SAAS,GAAG,iBAAM,CAAC,YAAY,CAAC,mCAAc,CAAC,CAAC;QACtD,MAAM,YAAY,GAAG,iBAAM,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO,YAAY;aAChB,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;aAChE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACrB,SAAS,EAAE,WAAW,CAAC,YAAY,CAAiB;YACpD,WAAW,EAAE,WAAW,CAAC,YAAY;YACrC,eAAe,EAAE,WAAW,CAAC,gBAAgB;SAC9C,CAAC,CAAC,CAAC;IACR,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,SAAyB;QACjD,OAAO,mBAAmB,CAAC,kBAAkB,CAA6B,SAAS,EAAE,sBAAsB,CAAC,CAAC;IAC/G,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,SAAyB;QACpD,OAAO,mBAAmB,CAAC,kBAAkB,CAA6B,SAAS,EAAE,yBAAyB,CAAC,CAAC;IAClH,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,SAAyB;QAClD,OAAO,mBAAmB,CAAC,kBAAkB,CAA4B,SAAS,EAAE,uBAAuB,CAAC,CAAC;IAC/G,CAAC;CAEF;AAhLD,kDAgLC"}
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Mapping of hexadecimal error codes to human-readable error messages.
3
+ *
4
+ * These error codes correspond to custom errors thrown by Privacy Pool smart contracts
5
+ * on Starknet. The hex codes are the encoded error messages that appear in transaction
6
+ * failure reasons.
7
+ *
8
+ * @constant
9
+ */
1
10
  export declare const CONTRACT_ERROR_CODES: {
2
11
  readonly "0x4173736574204d6973736d61746368": "Asset Missmatch";
3
12
  readonly "0x43616c6c6572206973206e6f7420456e747279706f696e74": "Caller is not Entrypoint";
@@ -24,4 +33,20 @@ export declare const CONTRACT_ERROR_CODES: {
24
33
  readonly "0x72656c617965722066656520544f2048494748": "relayer fee TO HIGH";
25
34
  readonly "0x56616c7565206c6573732074686174206d696e696d756d": "Value less that minimum";
26
35
  };
36
+ /**
37
+ * Parses a contract error string to extract a human-readable error message.
38
+ *
39
+ * This function searches through the error string for known hexadecimal error codes
40
+ * and returns the corresponding human-readable description. This is useful for
41
+ * providing better error messages to users when transactions fail.
42
+ *
43
+ * @param errorString - The error string from a failed transaction
44
+ * @returns The human-readable error message if found, null otherwise
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const error = "execution failed with error: 0x496e76616c69642050726f6f66";
49
+ * const readable = parseContractError(error); // Returns "Invalid Proof"
50
+ * ```
51
+ */
27
52
  export declare function parseContractError(errorString: string): string | null;
@@ -2,6 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CONTRACT_ERROR_CODES = void 0;
4
4
  exports.parseContractError = parseContractError;
5
+ /**
6
+ * Mapping of hexadecimal error codes to human-readable error messages.
7
+ *
8
+ * These error codes correspond to custom errors thrown by Privacy Pool smart contracts
9
+ * on Starknet. The hex codes are the encoded error messages that appear in transaction
10
+ * failure reasons.
11
+ *
12
+ * @constant
13
+ */
5
14
  exports.CONTRACT_ERROR_CODES = {
6
15
  "0x4173736574204d6973736d61746368": "Asset Missmatch",
7
16
  "0x43616c6c6572206973206e6f7420456e747279706f696e74": "Caller is not Entrypoint",
@@ -28,6 +37,22 @@ exports.CONTRACT_ERROR_CODES = {
28
37
  "0x72656c617965722066656520544f2048494748": "relayer fee TO HIGH",
29
38
  "0x56616c7565206c6573732074686174206d696e696d756d": "Value less that minimum"
30
39
  };
40
+ /**
41
+ * Parses a contract error string to extract a human-readable error message.
42
+ *
43
+ * This function searches through the error string for known hexadecimal error codes
44
+ * and returns the corresponding human-readable description. This is useful for
45
+ * providing better error messages to users when transactions fail.
46
+ *
47
+ * @param errorString - The error string from a failed transaction
48
+ * @returns The human-readable error message if found, null otherwise
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const error = "execution failed with error: 0x496e76616c69642050726f6f66";
53
+ * const readable = parseContractError(error); // Returns "Invalid Proof"
54
+ * ```
55
+ */
31
56
  function parseContractError(errorString) {
32
57
  for (const [hexCode, description] of Object.entries(exports.CONTRACT_ERROR_CODES)) {
33
58
  if (errorString.includes(hexCode)) {
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.errors.js","sourceRoot":"","sources":["../../src/errors/contracts.errors.ts"],"names":[],"mappings":";;;AA2BA,gDAOC;AAlCY,QAAA,oBAAoB,GAAG;IAClC,kCAAkC,EAAE,iBAAiB;IACrD,oDAAoD,EAAE,0BAA0B;IAChF,4CAA4C,EAAE,sBAAsB;IACpE,wCAAwC,EAAE,oBAAoB;IAC9D,wCAAwC,EAAE,oBAAoB;IAC9D,gCAAgC,EAAE,gBAAgB;IAClD,kCAAkC,EAAE,iBAAiB;IACrD,wCAAwC,EAAE,oBAAoB;IAC9D,wCAAwC,EAAE,oBAAoB;IAC9D,sCAAsC,EAAE,mBAAmB;IAC3D,8BAA8B,EAAE,eAAe;IAC/C,4BAA4B,EAAE,cAAc;IAC5C,wCAAwC,EAAE,oBAAoB;IAC9D,wCAAwC,EAAE,oBAAoB;IAC9D,gDAAgD,EAAE,wBAAwB;IAC1E,gCAAgC,EAAE,gBAAgB;IAClD,kDAAkD,EAAE,yBAAyB;IAC7E,0CAA0C,EAAE,qBAAqB;IACjE,4BAA4B,EAAE,cAAc;IAC5C,gCAAgC,EAAE,gBAAgB;IAClD,0CAA0C,EAAE,qBAAqB;IACjE,wCAAwC,EAAE,oBAAoB;IAC9D,0CAA0C,EAAE,qBAAqB;IACjE,kDAAkD,EAAE,yBAAyB;CACrE,CAAC;AAEX,SAAgB,kBAAkB,CAAC,W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M,CAAC,OAAO,CAAC,4BAAoB,CAAC,EAAE,CAAC;QAC1E,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,37 +1,109 @@
1
+ /** Base error codes for fundamental SDK errors */
1
2
  export declare enum SNBaseErrorCode {
2
3
  UNKNOWN = 0,
3
4
  UNREACHABLE = 1,
4
5
  INTERNAL = 2
5
6
  }
7
+ /** Error codes specific to privacy pool validation */
6
8
  export declare enum SNPoolErrorCode {
7
9
  AMOUNT_TOO_SMALL = 0
8
10
  }
11
+ /** Error codes for contract interaction failures */
9
12
  export declare enum SNContractErrorCode {
10
13
  DEPOSIT_FAILED = 0,
11
14
  INVALID_IPFS_CID = 1,
12
15
  REVERT = 2
13
16
  }
17
+ /** Error codes for data format and conversion issues */
14
18
  export declare enum SNFormatErrorCode {
15
19
  CONVERSION = 0
16
20
  }
21
+ /** Union type of all possible error codes in the Starknet SDK */
17
22
  export type SNErrorCode = SNBaseErrorCode | SNPoolErrorCode | SNContractErrorCode | SNFormatErrorCode;
23
+ /**
24
+ * Base error class for all Starknet SDK errors.
25
+ *
26
+ * This class extends the standard Error class and provides additional context
27
+ * through error codes. All SDK-specific errors should inherit from this class.
28
+ */
18
29
  export declare class StarknetSDKError extends Error {
19
30
  readonly code: SNErrorCode;
20
31
  readonly name: string;
21
32
  message: string;
33
+ /**
34
+ * Creates a new StarknetSDKError.
35
+ *
36
+ * @param message - The error message
37
+ * @param code - The specific error code for categorization
38
+ */
22
39
  constructor(message: string, code: SNErrorCode);
40
+ /**
41
+ * Creates an unknown error instance.
42
+ * @returns StarknetSDKError with UNKNOWN code
43
+ */
23
44
  static unknown(): StarknetSDKError;
45
+ /**
46
+ * Creates an unreachable code error instance.
47
+ * @returns StarknetSDKError with UNREACHABLE code
48
+ */
24
49
  static unreachable(): StarknetSDKError;
50
+ /**
51
+ * Creates an internal error instance.
52
+ * @param msg - Optional custom error message
53
+ * @returns StarknetSDKError with INTERNAL code
54
+ */
25
55
  static internal(msg?: string): StarknetSDKError;
26
56
  }
57
+ /**
58
+ * Error class for data format and conversion issues.
59
+ *
60
+ * This error is thrown when data conversion operations fail, such as
61
+ * converting between different proof formats or parsing verification keys.
62
+ */
27
63
  export declare class SNFormatError extends StarknetSDKError {
28
- static conversion(conetxt?: string): SNFormatError;
64
+ /**
65
+ * Creates a conversion error instance.
66
+ * @param context - Optional context about what conversion failed
67
+ * @returns SNFormatError with CONVERSION code
68
+ */
69
+ static conversion(context?: string): SNFormatError;
29
70
  }
71
+ /**
72
+ * Error class for privacy pool validation failures.
73
+ *
74
+ * This error is thrown when privacy pool operations fail validation,
75
+ * such as insufficient deposit amounts or invalid pool parameters.
76
+ */
30
77
  export declare class SNPoolError extends StarknetSDKError {
31
- static amountTooSmall(conetxt?: string): SNPoolError;
78
+ /**
79
+ * Creates an error for deposit amounts that are too small.
80
+ * @param context - Optional context about the minimum amount requirement
81
+ * @returns SNPoolError with AMOUNT_TOO_SMALL code
82
+ */
83
+ static amountTooSmall(context?: string): SNPoolError;
32
84
  }
85
+ /**
86
+ * Error class for smart contract interaction failures.
87
+ *
88
+ * This error is thrown when contract calls fail or return unexpected results,
89
+ * including transaction reverts and invalid parameters.
90
+ */
33
91
  export declare class SNContractError extends StarknetSDKError {
92
+ /**
93
+ * Creates an error for failed deposit operations.
94
+ * @returns SNContractError with DEPOSIT_FAILED code
95
+ */
34
96
  static depositFailed(): SNContractError;
97
+ /**
98
+ * Creates an error for invalid IPFS CID sizes.
99
+ * @param ipfsCID - The invalid IPFS CID
100
+ * @returns SNContractError with INVALID_IPFS_CID code
101
+ */
35
102
  static invalidIPFSsize(ipfsCID: string): SNContractError;
103
+ /**
104
+ * Creates an error for contract execution reverts.
105
+ * @param reason - The revert reason from the contract
106
+ * @returns SNContractError with REVERT code
107
+ */
36
108
  static revert(reason: string): SNContractError;
37
109
  }