@velumx/sdk 1.0.0 → 1.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.
@@ -17,4 +17,11 @@ export declare class VelumXClient {
17
17
  txid: string;
18
18
  status: string;
19
19
  }>;
20
+ /**
21
+ * Submit a raw Stacks transaction hex for native sponsorship
22
+ */
23
+ submitRawTransaction(txHex: string): Promise<{
24
+ txid: string;
25
+ status: string;
26
+ }>;
20
27
  }
@@ -56,5 +56,30 @@ class VelumXClient {
56
56
  throw error;
57
57
  }
58
58
  }
59
+ /**
60
+ * Submit a raw Stacks transaction hex for native sponsorship
61
+ */
62
+ async submitRawTransaction(txHex) {
63
+ try {
64
+ const headers = { 'Content-Type': 'application/json' };
65
+ if (this.config.apiKey) {
66
+ headers['x-api-key'] = this.config.apiKey;
67
+ }
68
+ const response = await fetch(`${this.relayerUrl}/broadcast`, {
69
+ method: 'POST',
70
+ headers,
71
+ body: JSON.stringify({ txHex })
72
+ });
73
+ if (!response.ok) {
74
+ const errData = await response.json().catch(() => ({}));
75
+ throw new Error(`Transaction broadcast failed: ${errData.message || response.statusText}`);
76
+ }
77
+ return await response.json();
78
+ }
79
+ catch (error) {
80
+ console.error("VelumX Client Error (submitRawTransaction):", error);
81
+ throw error;
82
+ }
83
+ }
59
84
  }
60
85
  exports.VelumXClient = VelumXClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velumx/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "VelumX Gas Abstraction Layer SDK for dApps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -64,4 +64,32 @@ export class VelumXClient {
64
64
  throw error;
65
65
  }
66
66
  }
67
+
68
+ /**
69
+ * Submit a raw Stacks transaction hex for native sponsorship
70
+ */
71
+ public async submitRawTransaction(txHex: string): Promise<{ txid: string, status: string }> {
72
+ try {
73
+ const headers: Record<string, string> = { 'Content-Type': 'application/json' };
74
+ if (this.config.apiKey) {
75
+ headers['x-api-key'] = this.config.apiKey;
76
+ }
77
+
78
+ const response = await fetch(`${this.relayerUrl}/broadcast`, {
79
+ method: 'POST',
80
+ headers,
81
+ body: JSON.stringify({ txHex })
82
+ });
83
+
84
+ if (!response.ok) {
85
+ const errData = await response.json().catch(() => ({}));
86
+ throw new Error(`Transaction broadcast failed: ${errData.message || response.statusText}`);
87
+ }
88
+
89
+ return await response.json();
90
+ } catch (error) {
91
+ console.error("VelumX Client Error (submitRawTransaction):", error);
92
+ throw error;
93
+ }
94
+ }
67
95
  }