privacycash 1.1.21 → 1.1.22

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/dist/deposit.js CHANGED
@@ -28,13 +28,14 @@ async function relayDepositToIndexer(signedTransaction, publicKey, referrer) {
28
28
  },
29
29
  body: JSON.stringify(params)
30
30
  });
31
+ let data = await response.json();
31
32
  if (!response.ok) {
32
- logger.error('res text:', await response.text());
33
- throw new Error('response not ok');
34
- // const errorData = await response.json() as { error?: string };
35
- // throw new Error(`Deposit relay failed: ${response.status} ${response.statusText} - ${errorData.error || 'Unknown error'}`);
33
+ throw new Error(data.error || 'Request failed');
36
34
  }
37
- const result = await response.json();
35
+ if (!data.success) {
36
+ throw new Error(data.error);
37
+ }
38
+ const result = data;
38
39
  logger.debug('Pre-signed deposit transaction relayed successfully!');
39
40
  logger.debug('Response:', result);
40
41
  return result.signature;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "privacycash",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://github.com/Privacy-Cash/privacy-cash-sdk",
package/src/deposit.ts CHANGED
@@ -35,14 +35,15 @@ async function relayDepositToIndexer(signedTransaction: string, publicKey: Publi
35
35
  body: JSON.stringify(params)
36
36
  });
37
37
 
38
+ let data = await response.json()
38
39
  if (!response.ok) {
39
- logger.error('res text:', await response.text())
40
- throw new Error('response not ok')
41
- // const errorData = await response.json() as { error?: string };
42
- // throw new Error(`Deposit relay failed: ${response.status} ${response.statusText} - ${errorData.error || 'Unknown error'}`);
40
+ throw new Error(data.error || 'Request failed');
41
+ }
42
+ if (!data.success) {
43
+ throw new Error(data.error);
43
44
  }
44
45
 
45
- const result = await response.json() as { signature: string, success: boolean };
46
+ const result = data as { signature: string, success: boolean };
46
47
  logger.debug('Pre-signed deposit transaction relayed successfully!');
47
48
  logger.debug('Response:', result);
48
49