@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.
- package/dist/VelumXClient.d.ts +7 -0
- package/dist/VelumXClient.js +25 -0
- package/package.json +1 -1
- package/src/VelumXClient.ts +28 -0
package/dist/VelumXClient.d.ts
CHANGED
package/dist/VelumXClient.js
CHANGED
|
@@ -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
package/src/VelumXClient.ts
CHANGED
|
@@ -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
|
}
|