blockchain-utils-service 1.0.4 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockchain-utils-service",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A lightweight service for deploying contracts, writing transactions, reading events, and checking block numbers.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -18,11 +18,10 @@ import axios from "axios";
18
18
  * @param {string} config.subscriptionType - The type of webhook e.g. "activityType" or "eventType"
19
19
  * @returns {Promise<Object>} - Result of the webhook subscription, typically includes subscription ID or status.
20
20
  */
21
- //#Pending , pass stremaing auth dynamic
22
- export async function contractSubscribeWebhook({
21
+ export async function subscribeContract({
23
22
  chainId,
24
23
  address,
25
- inhouseStreamUrl,
24
+ streamingServiceUrl,
26
25
  eventSignatures,
27
26
  streamingWebhookUrl,
28
27
  environment,
@@ -31,7 +30,7 @@ export async function contractSubscribeWebhook({
31
30
  streamingPassAuth
32
31
  }) {
33
32
  try {
34
- const uri = `${inhouseStreamUrl}/streams/evm`;
33
+ const uri = `${streamingServiceUrl}/streams/evm`;
35
34
  const body = {
36
35
  chainId,
37
36
  address,
@@ -40,15 +39,15 @@ export async function contractSubscribeWebhook({
40
39
  environment,
41
40
  subscriptionType
42
41
  };
43
- const token = btoa(`${streamingUserAuth}:${streamingPassAuth}`);
42
+ const token = Buffer.from(`${streamingUserAuth}:${streamingPassAuth}`).toString("base64");
44
43
  const headers = {
45
44
  "Content-Type": "application/json",
46
45
  "Authorization": `Basic ${token}`,
47
46
  };
48
- const res = await axios.post(uri, body, {
47
+ const response = await axios.post(uri, body, {
49
48
  headers: headers
50
49
  });
51
- return { isSuccess: true, data: { webhookResponse: res.data } };
50
+ return { isSuccess: true, data: response.data };
52
51
  } catch (error) {
53
52
  const errData = error.response?.data || error.message;
54
53
  return { isSuccess: false, data: `Webhook creation failed: ${JSON.stringify(errData)}` };
@@ -61,21 +60,21 @@ export async function contractSubscribeWebhook({
61
60
  *
62
61
  * @param {string} subscriptionId – The ID of the webhook to be updated.
63
62
  * @param {boolean} disabledFlag – The new status for the webhook, either "true" (to disable) or "false" (to enable).
64
- * @param {string} inhouseStreamUrl - The base URL for the Thirdweb Insight API.
63
+ * @param {string} streamingServiceUrl - The base URL for the Thirdweb Insight API.
65
64
  * @returns {Promise<{isSuccess: boolean, data: any}>}
66
65
  */
67
- export async function updateWebhookStatus({
66
+ export async function updateTrackerStatus({
68
67
  subscriptionId,
69
68
  status,
70
- inhouseStreamUrl,
69
+ streamingServiceUrl,
71
70
  streamingUserAuth,
72
71
  streamingPassAuth
73
72
  }) {
74
- if (!subscriptionId || !inhouseStreamUrl || !status) {
75
- return { isSuccess: false, data: "Missing required parameters" };
73
+ if (!subscriptionId || !streamingServiceUrl || !status) {
74
+ throw new Error(`Required Key Value Missing!`);
76
75
  }
77
76
  try {
78
- const uri = `${inhouseStreamUrl}/streams/evm/${subscriptionId}/status`;
77
+ const uri = `${streamingServiceUrl}/streams/evm/${subscriptionId}/status`;
79
78
  const body = { status };
80
79
  const token = btoa(`${streamingUserAuth}:${streamingPassAuth}`);
81
80
  const headers = {
package/src/getEvents.js CHANGED
@@ -62,6 +62,7 @@ export async function fetchContractEvents({
62
62
  const response = await axios.get(url, { params, headers });
63
63
  return response.data;
64
64
  } catch (error) {
65
+ // #Recheck that
65
66
  throw new Error(`Failed to fetch events: ${error.response?.data?.error || error.message}`);
66
67
  }
67
68
  }
package/src/index.js CHANGED
@@ -2,7 +2,7 @@ export { deployNewContract } from "./deploy.js";
2
2
  export { writeTransaction } from "./writeTransaction.js";
3
3
  export { fetchContractEvents } from "./getEvents.js";
4
4
  export { hasBlockNumberReached } from "./getBlockNumberReached.js";
5
- export { contractSubscribeWebhook, updateWebhookStatus } from "./contractSubscribeWebhook.js";
5
+ export { subscribeContract, updateTrackerStatus } from "./contractSubscribeWebhook.js";
6
6
  export { getTransactionHash } from "./getTransactionHash.js";
7
7
  export { getTokenPrice } from "./getTokenPrice.js";
8
8
  export { findDeploymentTxHash } from "./getCreatorTxHash.js";