@velumx/sdk 1.1.0 → 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.
@@ -22,7 +22,8 @@ class VelumXClient {
22
22
  body: JSON.stringify({ intent })
23
23
  });
24
24
  if (!response.ok) {
25
- throw new Error(`Fee estimation failed: ${response.statusText}`);
25
+ const errData = await response.json().catch(() => ({}));
26
+ throw new Error(`Fee estimation failed: ${errData.error || errData.message || response.statusText}`);
26
27
  }
27
28
  return await response.json();
28
29
  }
@@ -47,7 +48,7 @@ class VelumXClient {
47
48
  });
48
49
  if (!response.ok) {
49
50
  const errData = await response.json().catch(() => ({}));
50
- throw new Error(`Intent sponsorship failed: ${errData.message || response.statusText}`);
51
+ throw new Error(`Intent sponsorship failed: ${errData.error || errData.message || response.statusText}`);
51
52
  }
52
53
  return await response.json();
53
54
  }
@@ -72,7 +73,7 @@ class VelumXClient {
72
73
  });
73
74
  if (!response.ok) {
74
75
  const errData = await response.json().catch(() => ({}));
75
- throw new Error(`Transaction broadcast failed: ${errData.message || response.statusText}`);
76
+ throw new Error(`Transaction broadcast failed: ${errData.error || errData.message || response.statusText}`);
76
77
  }
77
78
  return await response.json();
78
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velumx/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "VelumX Gas Abstraction Layer SDK for dApps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,8 @@ export class VelumXClient {
27
27
  });
28
28
 
29
29
  if (!response.ok) {
30
- throw new Error(`Fee estimation failed: ${response.statusText}`);
30
+ const errData = await response.json().catch(() => ({}));
31
+ throw new Error(`Fee estimation failed: ${errData.error || errData.message || response.statusText}`);
31
32
  }
32
33
 
33
34
  return await response.json();
@@ -55,7 +56,7 @@ export class VelumXClient {
55
56
 
56
57
  if (!response.ok) {
57
58
  const errData = await response.json().catch(() => ({}));
58
- throw new Error(`Intent sponsorship failed: ${errData.message || response.statusText}`);
59
+ throw new Error(`Intent sponsorship failed: ${errData.error || errData.message || response.statusText}`);
59
60
  }
60
61
 
61
62
  return await response.json();
@@ -83,7 +84,7 @@ export class VelumXClient {
83
84
 
84
85
  if (!response.ok) {
85
86
  const errData = await response.json().catch(() => ({}));
86
- throw new Error(`Transaction broadcast failed: ${errData.message || response.statusText}`);
87
+ throw new Error(`Transaction broadcast failed: ${errData.error || errData.message || response.statusText}`);
87
88
  }
88
89
 
89
90
  return await response.json();