riskmarket-sdk 1.1.2 → 1.1.4

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/README.md CHANGED
@@ -828,9 +828,9 @@ off<E extends SocketEventName>(event: E, handler: SocketEventMap[E]): void
828
828
 
829
829
  ```ts
830
830
  const handler = (data: any) => console.log(data);
831
- sockets.on("gameCrashed", handler);
831
+ sockets.on("marketCrashed", handler);
832
832
  // later…
833
- sockets.off("gameCrashed", handler);
833
+ sockets.off("marketCrashed", handler);
834
834
  ```
835
835
 
836
836
  ---
@@ -898,8 +898,8 @@ if (sockets.connected) {
898
898
 
899
899
  | Event | Payload | Description |
900
900
  | ------------------------ | ----------------- | ----------------------------------------------------------------- |
901
- | `gameCrashed` | `any` | Fired when the current market round closes |
902
- | `gameStartedEventHit` | `any` | Fired when a new market round officially starts on-chain |
901
+ | `marketCrashed` | `any` | Fired when the current market round closes |
902
+ | `marketStartedEventHit` | `any` | Fired when a new market round officially starts on-chain |
903
903
  | `roundStarted` | `any` | Fired when the round begins (server-side) |
904
904
  | `userEnteredRound` | `any` | Fired when a user opens a position in the active round |
905
905
  | `userExitRound` | `any` | Fired when a user closes their position in the active round |
@@ -927,7 +927,7 @@ sockets.on("roundStarted", (data) => {
927
927
  console.log("Round started:", data);
928
928
  });
929
929
 
930
- sockets.on("gameCrashed", (data) => {
930
+ sockets.on("marketCrashed", (data) => {
931
931
  console.log("Market round closed:", data);
932
932
  sockets.disconnect();
933
933
  });
package/dist/Sockets.js CHANGED
@@ -30,13 +30,15 @@ class TypedEmitter {
30
30
  }
31
31
  }
32
32
  }
33
- const MARKET_EVENTS = [
34
- "gameCrashed",
35
- "gameStartedEventHit",
36
- "roundStarted",
37
- "userEnteredRound",
38
- "userExitRound",
39
- "timer",
33
+ // Backend event name → SDK-facing event name mapping.
34
+ // Events prefixed with "game" on the backend are exposed as "market" to consumers.
35
+ const EVENT_MAP = [
36
+ ["gameCrashed", "marketCrashed"],
37
+ ["gameStartedEventHit", "marketStartedEventHit"],
38
+ ["roundStarted", "roundStarted"],
39
+ ["userEnteredRound", "userEnteredRound"],
40
+ ["userExitRound", "userExitRound"],
41
+ ["timer", "timer"],
40
42
  ];
41
43
  export class Sockets {
42
44
  socket = null;
@@ -122,10 +124,10 @@ export class Sockets {
122
124
  this.socket.io.on("reconnect_attempt", () => {
123
125
  this.emitter.emit("connectionStatusChanged", "reconnecting");
124
126
  });
125
- // Relay each event straight through to SDK consumers.
126
- for (const eventName of MARKET_EVENTS) {
127
- this.socket.on(eventName, (data) => {
128
- this.emitter.emit(eventName, data);
127
+ // Relay backend events to SDK consumers, renaming game* → market* where applicable.
128
+ for (const [backendEvent, sdkEvent] of EVENT_MAP) {
129
+ this.socket.on(backendEvent, (data) => {
130
+ this.emitter.emit(sdkEvent, data);
129
131
  });
130
132
  }
131
133
  }
package/dist/types.d.ts CHANGED
@@ -26,8 +26,8 @@ export interface SocketConfig {
26
26
  }
27
27
  export type ConnectionStatus = "connected" | "disconnected" | "reconnecting";
28
28
  export interface SocketEventMap {
29
- gameCrashed: (data: any) => void;
30
- gameStartedEventHit: (data: any) => void;
29
+ marketCrashed: (data: any) => void;
30
+ marketStartedEventHit: (data: any) => void;
31
31
  roundStarted: (data: any) => void;
32
32
  userEnteredRound: (data: any) => void;
33
33
  userExitRound: (data: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "riskmarket-sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "SDK for Risk market Protocol",
6
6
  "main": "dist/index.js",