@momo-cloud/gami-sdk 0.0.65 → 0.0.68

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
@@ -52,14 +52,8 @@ await GamiSDK.startGame();
52
52
 
53
53
  // Your game logic here...
54
54
 
55
- // Submit score
56
- const result = await GamiSDK.submit({
57
- steps: [
58
- { action: 'move', timestamp: Date.now() },
59
- { action: 'jump', timestamp: Date.now() }
60
- ],
61
- score: 1000
62
- });
55
+ // make spin to get reward
56
+ const result = await GamiSDK.spin();
63
57
 
64
58
  // End game session
65
59
  await GamiSDK.endGame();
@@ -135,6 +129,35 @@ console.log('Game config:', config);
135
129
 
136
130
  ---
137
131
 
132
+ #### `getCoinExchangeInfo()`
133
+
134
+ Load exchange metadata for the current game (coin → turn). The backend uses the fixed action `exchange_coin_to_turn`; the active `gameId` comes from `init`.
135
+
136
+ ```typescript
137
+ const res = await GamiSDK.getCoinExchangeInfo();
138
+ const { balance, exchangeRate, counter, counterLimit, fromCurrency, toCurrency } = res.result;
139
+ ```
140
+
141
+ **Returns:** `Promise<TGetExchangeResponse>` - Standard `response_info` plus `result` with rate, balances, counters, and currency pair
142
+
143
+ ---
144
+
145
+ #### `coinExchange(options)`
146
+
147
+ Submit a coin-to-turn exchange for the current game.
148
+
149
+ ```typescript
150
+ const res = await GamiSDK.coinExchange({ amount: 100 });
151
+ const { from, to, counter } = res.result;
152
+ ```
153
+
154
+ **Parameters:**
155
+ - `amount` (number): Coin amount to convert
156
+
157
+ **Returns:** `Promise<TPostExchangeResponse>` - Updated `from` / `to` wallet snapshots and `counter` state
158
+
159
+ ---
160
+
138
161
  #### `spin()`
139
162
 
140
163
  Perform a spinner spin for the current game. Sends `POST` to the twirler service with the active `gameId` (set via `init`).
@@ -799,11 +822,20 @@ Game Ready ✓
799
822
  The SDK is written in TypeScript and includes type definitions:
800
823
 
801
824
  ```typescript
802
- import GamiSDK, { TBalance, TLeaderboard, IUserInfo } from '@momo-cloud/gami-sdk';
825
+ import GamiSDK, {
826
+ TBalance,
827
+ TGetExchangeResponse,
828
+ TLeaderboard,
829
+ TPostExchangeResponse,
830
+ IUserInfo
831
+ } from '@momo-cloud/gami-sdk';
803
832
 
804
833
  const balance: TBalance = await GamiSDK.getBalance({
805
834
  balanceIds: ['coin']
806
835
  });
836
+
837
+ const exchangeInfo: TGetExchangeResponse = await GamiSDK.getCoinExchangeInfo();
838
+ const posted: TPostExchangeResponse = await GamiSDK.coinExchange({ amount: 100 });
807
839
  ```
808
840
 
809
841
  ### Vite Integration
@@ -57,6 +57,13 @@ declare const GamiSDK: {
57
57
  }) => Promise<any>;
58
58
  getBalanceConfig: () => Promise<any>;
59
59
  getConfig: () => Promise<any>;
60
+ getCoinExchangeInfo: (params?: {
61
+ actionId?: string;
62
+ }) => Promise<TGetExchangeResponse>;
63
+ coinExchange: (params: {
64
+ amount: number;
65
+ actionId?: string;
66
+ }) => Promise<TPostExchangeResponse>;
60
67
  spin: () => Promise<any>;
61
68
  getLeaderboard: (params: {
62
69
  boardId: string;
@@ -240,6 +247,48 @@ export declare type TDeviceInfo = {
240
247
  devicePerformance?: string;
241
248
  };
242
249
 
250
+ export declare type TGetExchangeResponse = {
251
+ response_info: {
252
+ error_message: string;
253
+ error_code: number;
254
+ event_tracking: string;
255
+ };
256
+ result: {
257
+ balance: number;
258
+ exchangeRate: number;
259
+ counter: number;
260
+ counterLimit: number;
261
+ fromCurrency: string;
262
+ toCurrency: string;
263
+ };
264
+ };
265
+
266
+ export declare type TPostExchangeResponse = {
267
+ response_info: {
268
+ error_message: string;
269
+ error_code: number;
270
+ event_tracking: string;
271
+ };
272
+ result: {
273
+ from: {
274
+ walletType: string;
275
+ currency: string;
276
+ before: number;
277
+ after: number;
278
+ };
279
+ to: {
280
+ walletType: string;
281
+ currency: string;
282
+ before: number;
283
+ after: number;
284
+ };
285
+ counter: {
286
+ value: number;
287
+ limit: number;
288
+ };
289
+ };
290
+ };
291
+
243
292
  export declare const Utils: {
244
293
  num10to11: (number: string) => string;
245
294
  num11to10: (number: string) => string;