@omen.foundation/game-sdk 1.0.15 → 1.0.17
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 +51 -0
- package/dist/index.d.mts +193 -5
- package/dist/index.d.ts +193 -5
- package/dist/index.js +148 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -12,6 +12,12 @@ The SDK supports two modes:
|
|
|
12
12
|
npm install @omen.foundation/game-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
For **real-time updates** (balance & inventory), also install Ably:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install ably
|
|
19
|
+
```
|
|
20
|
+
|
|
15
21
|
## Quick Start
|
|
16
22
|
|
|
17
23
|
### Client Mode (OAuth Authentication)
|
|
@@ -188,6 +194,51 @@ if (sdk.isAuthenticated()) {
|
|
|
188
194
|
await sdk.logout();
|
|
189
195
|
```
|
|
190
196
|
|
|
197
|
+
### Real-Time Updates (Balance & Inventory)
|
|
198
|
+
|
|
199
|
+
So your game stays in sync when the user spends or receives OmenX / NFTs on the website or in another client, subscribe to the per-wallet Ably channel. The SDK provides the channel name, event names, and a subscribe helper with idempotency (eventId dedupe).
|
|
200
|
+
|
|
201
|
+
**Requires:** `ably` installed in your app. Use the same Ably API key as the OmenX frontend (subscribe capability for `wallet:*`).
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { subscribeWalletRealtime, getWalletChannelName, REALTIME_EVENTS } from '@omen.foundation/game-sdk';
|
|
205
|
+
import * as Ably from 'ably';
|
|
206
|
+
|
|
207
|
+
// After user logs in and you have their wallet address:
|
|
208
|
+
const ably = new Ably.Realtime({ key: 'YOUR_ABLY_API_KEY' });
|
|
209
|
+
|
|
210
|
+
const unsubscribe = subscribeWalletRealtime(ably, walletAddress, {
|
|
211
|
+
onBalance: (payload) => {
|
|
212
|
+
// Refetch balances (e.g. call your backend or GetPlayerBalances)
|
|
213
|
+
refetchBalances();
|
|
214
|
+
},
|
|
215
|
+
onInventory: (payload) => {
|
|
216
|
+
// Refetch inventory / NFTs (backend cache is source of truth)
|
|
217
|
+
refetchInventory();
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// When user logs out or wallet changes:
|
|
222
|
+
unsubscribe();
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
With React and `ably/react`, pass the client from `useAbly()`:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { useAbly } from 'ably/react';
|
|
229
|
+
import { subscribeWalletRealtime } from '@omen.foundation/game-sdk';
|
|
230
|
+
|
|
231
|
+
// Inside your component, after wallet is available:
|
|
232
|
+
const ably = useAbly();
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (!walletAddress || !ably) return;
|
|
235
|
+
return subscribeWalletRealtime(ably, walletAddress, {
|
|
236
|
+
onBalance: () => refetchBalances(),
|
|
237
|
+
onInventory: () => refetchInventory(),
|
|
238
|
+
});
|
|
239
|
+
}, [ably, walletAddress]);
|
|
240
|
+
```
|
|
241
|
+
|
|
191
242
|
## API Reference
|
|
192
243
|
|
|
193
244
|
See the [full documentation](./docs/README.md) for detailed API reference.
|
package/dist/index.d.mts
CHANGED
|
@@ -107,6 +107,38 @@ interface ApiCallOptions {
|
|
|
107
107
|
*/
|
|
108
108
|
includeAuth?: boolean;
|
|
109
109
|
}
|
|
110
|
+
interface VipTierInfo {
|
|
111
|
+
tierIndex: number;
|
|
112
|
+
tierKey: string;
|
|
113
|
+
displayName: string;
|
|
114
|
+
allocationBoundary: number;
|
|
115
|
+
usdPrice?: number;
|
|
116
|
+
perksDescription?: string;
|
|
117
|
+
active?: boolean;
|
|
118
|
+
/** Structured perks from tiers JSON (e.g. GAME_BONUS_POINTS_LEVEL). */
|
|
119
|
+
perks?: Record<string, unknown>;
|
|
120
|
+
tierPerksShortDescription?: string;
|
|
121
|
+
/** Games read this (1–21) for Game Alpha Access (higher tiers), Game Beta Access (lower tiers), or in-game gifts. */
|
|
122
|
+
gameBonusPointsLevel?: number;
|
|
123
|
+
}
|
|
124
|
+
interface VipStatus {
|
|
125
|
+
walletAddress: string;
|
|
126
|
+
entitlement: number;
|
|
127
|
+
claimed: number;
|
|
128
|
+
claimable: number;
|
|
129
|
+
tier: VipTierInfo;
|
|
130
|
+
nextTier: VipTierInfo | null;
|
|
131
|
+
phaseIndex: number;
|
|
132
|
+
claimingAllowed: boolean;
|
|
133
|
+
phaseClaimingClosed?: boolean;
|
|
134
|
+
currentEpoch?: {
|
|
135
|
+
epochId: string;
|
|
136
|
+
startAt: string;
|
|
137
|
+
endAt: string;
|
|
138
|
+
epochPoolAmount: number;
|
|
139
|
+
estimatedShare?: number;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
110
142
|
|
|
111
143
|
/**
|
|
112
144
|
* OmenX Game SDK
|
|
@@ -154,6 +186,16 @@ declare class OmenXGameSDK {
|
|
|
154
186
|
* Handle auth data from iframe
|
|
155
187
|
*/
|
|
156
188
|
private handleAuthData;
|
|
189
|
+
/**
|
|
190
|
+
* Get current VIP status for the authenticated user (tier, allocation, claimable, perks).
|
|
191
|
+
* Games can read tier.gameBonusPointsLevel (1–21) for Alpha/Beta access or in-game gifts.
|
|
192
|
+
*/
|
|
193
|
+
getVipStatus(): Promise<VipStatus | null>;
|
|
194
|
+
/**
|
|
195
|
+
* Get the current user's game bonus points level (1–21) from their VIP tier.
|
|
196
|
+
* Use for Game Alpha Access (e.g. level >= 6), Game Beta Access (e.g. level >= 1), or in-game gifts.
|
|
197
|
+
*/
|
|
198
|
+
getGameBonusPointsLevel(): Promise<number | null>;
|
|
157
199
|
/**
|
|
158
200
|
* Refresh access token using refresh token
|
|
159
201
|
*/
|
|
@@ -234,13 +276,15 @@ declare class OmenXServerSDK {
|
|
|
234
276
|
* NFT Template Operations
|
|
235
277
|
*/
|
|
236
278
|
/**
|
|
237
|
-
* Get all NFT templates for
|
|
279
|
+
* Get all NFT templates for the authenticated game (game is derived from API key).
|
|
280
|
+
* gameId is optional and ignored by the API; included for backward compatibility.
|
|
238
281
|
*/
|
|
239
|
-
getNftTemplates(
|
|
282
|
+
getNftTemplates(_gameId?: string): Promise<any>;
|
|
240
283
|
/**
|
|
241
|
-
* Get NFT contract address for
|
|
284
|
+
* Get NFT contract address for the authenticated game (game is derived from API key).
|
|
285
|
+
* gameId is optional and ignored by the API; included for backward compatibility.
|
|
242
286
|
*/
|
|
243
|
-
getNftContract(
|
|
287
|
+
getNftContract(_gameId?: string): Promise<any>;
|
|
244
288
|
/**
|
|
245
289
|
* Mint NFTs (single or batch)
|
|
246
290
|
*/
|
|
@@ -281,6 +325,150 @@ declare class OmenXServerSDK {
|
|
|
281
325
|
dropTableId: string;
|
|
282
326
|
recipientAddress: string;
|
|
283
327
|
}): Promise<any>;
|
|
328
|
+
/**
|
|
329
|
+
* VIP Points (Developer pool)
|
|
330
|
+
* Requires scope: vip_points:write.
|
|
331
|
+
* Grants VIP points to a player from this game's allocated pool. Enforces total allocation and max per quest.
|
|
332
|
+
* Call from your game backend only (API key auth); not for client-side use.
|
|
333
|
+
*/
|
|
334
|
+
grantVipPoints(params: {
|
|
335
|
+
/** Player wallet address (0x-prefixed, 40 hex chars). */
|
|
336
|
+
wallet: string;
|
|
337
|
+
/** Points to grant (positive integer). Capped by pool remaining and max per quest. */
|
|
338
|
+
amount: number;
|
|
339
|
+
/** Optional quest/activity id for idempotency or auditing. */
|
|
340
|
+
questId?: string;
|
|
341
|
+
}): Promise<{
|
|
342
|
+
success: boolean;
|
|
343
|
+
data?: {
|
|
344
|
+
wallet: string;
|
|
345
|
+
amount: number;
|
|
346
|
+
phaseIndex?: number;
|
|
347
|
+
};
|
|
348
|
+
}>;
|
|
349
|
+
/**
|
|
350
|
+
* Quests API (game quests only).
|
|
351
|
+
* Requires scope: quests:read for getQuestsForPlayer; quests:write for assign, progress, complete, claim.
|
|
352
|
+
*/
|
|
353
|
+
/** Get assigned quests for a player. Optional questType filter. */
|
|
354
|
+
getQuestsForPlayer(wallet: string, options?: {
|
|
355
|
+
questType?: 'daily' | 'weekly' | 'monthly' | 'oneTime';
|
|
356
|
+
}): Promise<{
|
|
357
|
+
success: boolean;
|
|
358
|
+
data: {
|
|
359
|
+
quests: any[];
|
|
360
|
+
};
|
|
361
|
+
}>;
|
|
362
|
+
/** Assign quests of a type to a player. Use idempotencyKey for safe retries. */
|
|
363
|
+
assignQuests(wallet: string, questType: 'daily' | 'weekly' | 'monthly' | 'oneTime', count: number, options?: {
|
|
364
|
+
idempotencyKey?: string;
|
|
365
|
+
}): Promise<{
|
|
366
|
+
success: boolean;
|
|
367
|
+
data: {
|
|
368
|
+
assigned: number;
|
|
369
|
+
assignmentIds?: string[];
|
|
370
|
+
};
|
|
371
|
+
}>;
|
|
372
|
+
/** Report progress for a quest step. Quest auto-completes when all steps meet targets. */
|
|
373
|
+
reportQuestProgress(wallet: string, questKey: string, value: number, options?: {
|
|
374
|
+
stepKey?: string;
|
|
375
|
+
}): Promise<{
|
|
376
|
+
success: boolean;
|
|
377
|
+
data?: object;
|
|
378
|
+
}>;
|
|
379
|
+
/** Mark a quest complete (all steps set to targets). */
|
|
380
|
+
completeQuest(wallet: string, questKey: string): Promise<{
|
|
381
|
+
success: boolean;
|
|
382
|
+
data?: object;
|
|
383
|
+
}>;
|
|
384
|
+
/** Claim VIP reward for a completed quest (from game pool). Use idempotencyKey for safe retries. */
|
|
385
|
+
claimQuestReward(wallet: string, questKey: string, options?: {
|
|
386
|
+
idempotencyKey?: string;
|
|
387
|
+
}): Promise<{
|
|
388
|
+
success: boolean;
|
|
389
|
+
data?: {
|
|
390
|
+
pointsGranted?: number;
|
|
391
|
+
};
|
|
392
|
+
}>;
|
|
393
|
+
/**
|
|
394
|
+
* Reset or wipe a player's quest state for this game. Requires quests:write.
|
|
395
|
+
* - wipe: delete all quest assignments for this game for the player.
|
|
396
|
+
* - reset: delete assignments for the specified questKey only (questKey required).
|
|
397
|
+
*/
|
|
398
|
+
resetPlayerQuests(wallet: string, action: 'wipe' | 'reset', questKey?: string): Promise<{
|
|
399
|
+
success: boolean;
|
|
400
|
+
data: {
|
|
401
|
+
action: string;
|
|
402
|
+
deleted: number;
|
|
403
|
+
questKey?: string;
|
|
404
|
+
};
|
|
405
|
+
}>;
|
|
284
406
|
}
|
|
285
407
|
|
|
286
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Real-time wallet updates (balance & inventory) for game clients.
|
|
410
|
+
* Subscribe to the per-wallet Ably channel so the game stays in sync when the user
|
|
411
|
+
* spends or receives OmenX / NFTs on the website or in another client.
|
|
412
|
+
*
|
|
413
|
+
* Requires the app to install `ably` and pass an Ably Realtime instance.
|
|
414
|
+
*/
|
|
415
|
+
/** Payload for balance and inventory events. Use eventId for idempotency (ignore if already processed). */
|
|
416
|
+
interface RealtimeWalletPayload {
|
|
417
|
+
eventId: string;
|
|
418
|
+
timestamp: number;
|
|
419
|
+
reason?: string;
|
|
420
|
+
}
|
|
421
|
+
/** Ably channel name prefix. Full channel = "wallet:" + normalized wallet address. */
|
|
422
|
+
declare const WALLET_CHANNEL_PREFIX = "wallet:";
|
|
423
|
+
/** Event names published by the OmenX backend on the wallet channel. */
|
|
424
|
+
declare const REALTIME_EVENTS: {
|
|
425
|
+
/** Currency balance changed. Refetch via GetPlayerBalances or your balance API. */
|
|
426
|
+
readonly balance: "balance";
|
|
427
|
+
/** NFT/inventory changed. Refetch via GetPlayerNfts or your inventory API (cache is source of truth). */
|
|
428
|
+
readonly inventory: "inventory";
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Get the Ably channel name for a wallet. Use this when subscribing with your Ably client.
|
|
432
|
+
*/
|
|
433
|
+
declare function getWalletChannelName(walletAddress: string): string;
|
|
434
|
+
/**
|
|
435
|
+
* Minimal Ably Realtime interface so the SDK works with any Ably.Realtime instance.
|
|
436
|
+
* The app provides the real Ably client from AblyProvider or new Ably.Realtime({ key }).
|
|
437
|
+
*/
|
|
438
|
+
interface AblyRealtimeLike {
|
|
439
|
+
channels: {
|
|
440
|
+
get(name: string): {
|
|
441
|
+
subscribe(eventOrCallback: string | ((message: {
|
|
442
|
+
name: string;
|
|
443
|
+
data: unknown;
|
|
444
|
+
}) => void), callback?: (message: {
|
|
445
|
+
name: string;
|
|
446
|
+
data: unknown;
|
|
447
|
+
}) => void): void;
|
|
448
|
+
unsubscribe(eventOrCallback?: string | ((message: {
|
|
449
|
+
name: string;
|
|
450
|
+
data: unknown;
|
|
451
|
+
}) => void), callback?: (message: {
|
|
452
|
+
name: string;
|
|
453
|
+
data: unknown;
|
|
454
|
+
}) => void): void;
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Subscribe to real-time balance and inventory events for a wallet.
|
|
460
|
+
* Call when the user logs in; call the returned unsubscribe when they log out or wallet changes.
|
|
461
|
+
*
|
|
462
|
+
* Uses eventId to dedupe (ignores already-seen events). Refetch in your app on each callback.
|
|
463
|
+
*
|
|
464
|
+
* @param ably - Ably Realtime instance (e.g. from useAbly() or new Ably.Realtime({ key }))
|
|
465
|
+
* @param walletAddress - Current player wallet (0x...)
|
|
466
|
+
* @param callbacks - onBalance and/or onInventory; each receives the payload (eventId, timestamp, reason?)
|
|
467
|
+
* @returns Unsubscribe function
|
|
468
|
+
*/
|
|
469
|
+
declare function subscribeWalletRealtime(ably: AblyRealtimeLike, walletAddress: string, callbacks: {
|
|
470
|
+
onBalance?: (payload: RealtimeWalletPayload) => void;
|
|
471
|
+
onInventory?: (payload: RealtimeWalletPayload) => void;
|
|
472
|
+
}): () => void;
|
|
473
|
+
|
|
474
|
+
export { type AblyRealtimeLike, type ApiCallOptions, type AuthData, type OAuthOptions, OmenXGameSDK, type OmenXGameSDKConfig, OmenXServerSDK, REALTIME_EVENTS, type RealtimeWalletPayload, type UserInfo, type VipStatus, type VipTierInfo, WALLET_CHANNEL_PREFIX, getWalletChannelName, subscribeWalletRealtime };
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,38 @@ interface ApiCallOptions {
|
|
|
107
107
|
*/
|
|
108
108
|
includeAuth?: boolean;
|
|
109
109
|
}
|
|
110
|
+
interface VipTierInfo {
|
|
111
|
+
tierIndex: number;
|
|
112
|
+
tierKey: string;
|
|
113
|
+
displayName: string;
|
|
114
|
+
allocationBoundary: number;
|
|
115
|
+
usdPrice?: number;
|
|
116
|
+
perksDescription?: string;
|
|
117
|
+
active?: boolean;
|
|
118
|
+
/** Structured perks from tiers JSON (e.g. GAME_BONUS_POINTS_LEVEL). */
|
|
119
|
+
perks?: Record<string, unknown>;
|
|
120
|
+
tierPerksShortDescription?: string;
|
|
121
|
+
/** Games read this (1–21) for Game Alpha Access (higher tiers), Game Beta Access (lower tiers), or in-game gifts. */
|
|
122
|
+
gameBonusPointsLevel?: number;
|
|
123
|
+
}
|
|
124
|
+
interface VipStatus {
|
|
125
|
+
walletAddress: string;
|
|
126
|
+
entitlement: number;
|
|
127
|
+
claimed: number;
|
|
128
|
+
claimable: number;
|
|
129
|
+
tier: VipTierInfo;
|
|
130
|
+
nextTier: VipTierInfo | null;
|
|
131
|
+
phaseIndex: number;
|
|
132
|
+
claimingAllowed: boolean;
|
|
133
|
+
phaseClaimingClosed?: boolean;
|
|
134
|
+
currentEpoch?: {
|
|
135
|
+
epochId: string;
|
|
136
|
+
startAt: string;
|
|
137
|
+
endAt: string;
|
|
138
|
+
epochPoolAmount: number;
|
|
139
|
+
estimatedShare?: number;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
110
142
|
|
|
111
143
|
/**
|
|
112
144
|
* OmenX Game SDK
|
|
@@ -154,6 +186,16 @@ declare class OmenXGameSDK {
|
|
|
154
186
|
* Handle auth data from iframe
|
|
155
187
|
*/
|
|
156
188
|
private handleAuthData;
|
|
189
|
+
/**
|
|
190
|
+
* Get current VIP status for the authenticated user (tier, allocation, claimable, perks).
|
|
191
|
+
* Games can read tier.gameBonusPointsLevel (1–21) for Alpha/Beta access or in-game gifts.
|
|
192
|
+
*/
|
|
193
|
+
getVipStatus(): Promise<VipStatus | null>;
|
|
194
|
+
/**
|
|
195
|
+
* Get the current user's game bonus points level (1–21) from their VIP tier.
|
|
196
|
+
* Use for Game Alpha Access (e.g. level >= 6), Game Beta Access (e.g. level >= 1), or in-game gifts.
|
|
197
|
+
*/
|
|
198
|
+
getGameBonusPointsLevel(): Promise<number | null>;
|
|
157
199
|
/**
|
|
158
200
|
* Refresh access token using refresh token
|
|
159
201
|
*/
|
|
@@ -234,13 +276,15 @@ declare class OmenXServerSDK {
|
|
|
234
276
|
* NFT Template Operations
|
|
235
277
|
*/
|
|
236
278
|
/**
|
|
237
|
-
* Get all NFT templates for
|
|
279
|
+
* Get all NFT templates for the authenticated game (game is derived from API key).
|
|
280
|
+
* gameId is optional and ignored by the API; included for backward compatibility.
|
|
238
281
|
*/
|
|
239
|
-
getNftTemplates(
|
|
282
|
+
getNftTemplates(_gameId?: string): Promise<any>;
|
|
240
283
|
/**
|
|
241
|
-
* Get NFT contract address for
|
|
284
|
+
* Get NFT contract address for the authenticated game (game is derived from API key).
|
|
285
|
+
* gameId is optional and ignored by the API; included for backward compatibility.
|
|
242
286
|
*/
|
|
243
|
-
getNftContract(
|
|
287
|
+
getNftContract(_gameId?: string): Promise<any>;
|
|
244
288
|
/**
|
|
245
289
|
* Mint NFTs (single or batch)
|
|
246
290
|
*/
|
|
@@ -281,6 +325,150 @@ declare class OmenXServerSDK {
|
|
|
281
325
|
dropTableId: string;
|
|
282
326
|
recipientAddress: string;
|
|
283
327
|
}): Promise<any>;
|
|
328
|
+
/**
|
|
329
|
+
* VIP Points (Developer pool)
|
|
330
|
+
* Requires scope: vip_points:write.
|
|
331
|
+
* Grants VIP points to a player from this game's allocated pool. Enforces total allocation and max per quest.
|
|
332
|
+
* Call from your game backend only (API key auth); not for client-side use.
|
|
333
|
+
*/
|
|
334
|
+
grantVipPoints(params: {
|
|
335
|
+
/** Player wallet address (0x-prefixed, 40 hex chars). */
|
|
336
|
+
wallet: string;
|
|
337
|
+
/** Points to grant (positive integer). Capped by pool remaining and max per quest. */
|
|
338
|
+
amount: number;
|
|
339
|
+
/** Optional quest/activity id for idempotency or auditing. */
|
|
340
|
+
questId?: string;
|
|
341
|
+
}): Promise<{
|
|
342
|
+
success: boolean;
|
|
343
|
+
data?: {
|
|
344
|
+
wallet: string;
|
|
345
|
+
amount: number;
|
|
346
|
+
phaseIndex?: number;
|
|
347
|
+
};
|
|
348
|
+
}>;
|
|
349
|
+
/**
|
|
350
|
+
* Quests API (game quests only).
|
|
351
|
+
* Requires scope: quests:read for getQuestsForPlayer; quests:write for assign, progress, complete, claim.
|
|
352
|
+
*/
|
|
353
|
+
/** Get assigned quests for a player. Optional questType filter. */
|
|
354
|
+
getQuestsForPlayer(wallet: string, options?: {
|
|
355
|
+
questType?: 'daily' | 'weekly' | 'monthly' | 'oneTime';
|
|
356
|
+
}): Promise<{
|
|
357
|
+
success: boolean;
|
|
358
|
+
data: {
|
|
359
|
+
quests: any[];
|
|
360
|
+
};
|
|
361
|
+
}>;
|
|
362
|
+
/** Assign quests of a type to a player. Use idempotencyKey for safe retries. */
|
|
363
|
+
assignQuests(wallet: string, questType: 'daily' | 'weekly' | 'monthly' | 'oneTime', count: number, options?: {
|
|
364
|
+
idempotencyKey?: string;
|
|
365
|
+
}): Promise<{
|
|
366
|
+
success: boolean;
|
|
367
|
+
data: {
|
|
368
|
+
assigned: number;
|
|
369
|
+
assignmentIds?: string[];
|
|
370
|
+
};
|
|
371
|
+
}>;
|
|
372
|
+
/** Report progress for a quest step. Quest auto-completes when all steps meet targets. */
|
|
373
|
+
reportQuestProgress(wallet: string, questKey: string, value: number, options?: {
|
|
374
|
+
stepKey?: string;
|
|
375
|
+
}): Promise<{
|
|
376
|
+
success: boolean;
|
|
377
|
+
data?: object;
|
|
378
|
+
}>;
|
|
379
|
+
/** Mark a quest complete (all steps set to targets). */
|
|
380
|
+
completeQuest(wallet: string, questKey: string): Promise<{
|
|
381
|
+
success: boolean;
|
|
382
|
+
data?: object;
|
|
383
|
+
}>;
|
|
384
|
+
/** Claim VIP reward for a completed quest (from game pool). Use idempotencyKey for safe retries. */
|
|
385
|
+
claimQuestReward(wallet: string, questKey: string, options?: {
|
|
386
|
+
idempotencyKey?: string;
|
|
387
|
+
}): Promise<{
|
|
388
|
+
success: boolean;
|
|
389
|
+
data?: {
|
|
390
|
+
pointsGranted?: number;
|
|
391
|
+
};
|
|
392
|
+
}>;
|
|
393
|
+
/**
|
|
394
|
+
* Reset or wipe a player's quest state for this game. Requires quests:write.
|
|
395
|
+
* - wipe: delete all quest assignments for this game for the player.
|
|
396
|
+
* - reset: delete assignments for the specified questKey only (questKey required).
|
|
397
|
+
*/
|
|
398
|
+
resetPlayerQuests(wallet: string, action: 'wipe' | 'reset', questKey?: string): Promise<{
|
|
399
|
+
success: boolean;
|
|
400
|
+
data: {
|
|
401
|
+
action: string;
|
|
402
|
+
deleted: number;
|
|
403
|
+
questKey?: string;
|
|
404
|
+
};
|
|
405
|
+
}>;
|
|
284
406
|
}
|
|
285
407
|
|
|
286
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Real-time wallet updates (balance & inventory) for game clients.
|
|
410
|
+
* Subscribe to the per-wallet Ably channel so the game stays in sync when the user
|
|
411
|
+
* spends or receives OmenX / NFTs on the website or in another client.
|
|
412
|
+
*
|
|
413
|
+
* Requires the app to install `ably` and pass an Ably Realtime instance.
|
|
414
|
+
*/
|
|
415
|
+
/** Payload for balance and inventory events. Use eventId for idempotency (ignore if already processed). */
|
|
416
|
+
interface RealtimeWalletPayload {
|
|
417
|
+
eventId: string;
|
|
418
|
+
timestamp: number;
|
|
419
|
+
reason?: string;
|
|
420
|
+
}
|
|
421
|
+
/** Ably channel name prefix. Full channel = "wallet:" + normalized wallet address. */
|
|
422
|
+
declare const WALLET_CHANNEL_PREFIX = "wallet:";
|
|
423
|
+
/** Event names published by the OmenX backend on the wallet channel. */
|
|
424
|
+
declare const REALTIME_EVENTS: {
|
|
425
|
+
/** Currency balance changed. Refetch via GetPlayerBalances or your balance API. */
|
|
426
|
+
readonly balance: "balance";
|
|
427
|
+
/** NFT/inventory changed. Refetch via GetPlayerNfts or your inventory API (cache is source of truth). */
|
|
428
|
+
readonly inventory: "inventory";
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Get the Ably channel name for a wallet. Use this when subscribing with your Ably client.
|
|
432
|
+
*/
|
|
433
|
+
declare function getWalletChannelName(walletAddress: string): string;
|
|
434
|
+
/**
|
|
435
|
+
* Minimal Ably Realtime interface so the SDK works with any Ably.Realtime instance.
|
|
436
|
+
* The app provides the real Ably client from AblyProvider or new Ably.Realtime({ key }).
|
|
437
|
+
*/
|
|
438
|
+
interface AblyRealtimeLike {
|
|
439
|
+
channels: {
|
|
440
|
+
get(name: string): {
|
|
441
|
+
subscribe(eventOrCallback: string | ((message: {
|
|
442
|
+
name: string;
|
|
443
|
+
data: unknown;
|
|
444
|
+
}) => void), callback?: (message: {
|
|
445
|
+
name: string;
|
|
446
|
+
data: unknown;
|
|
447
|
+
}) => void): void;
|
|
448
|
+
unsubscribe(eventOrCallback?: string | ((message: {
|
|
449
|
+
name: string;
|
|
450
|
+
data: unknown;
|
|
451
|
+
}) => void), callback?: (message: {
|
|
452
|
+
name: string;
|
|
453
|
+
data: unknown;
|
|
454
|
+
}) => void): void;
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Subscribe to real-time balance and inventory events for a wallet.
|
|
460
|
+
* Call when the user logs in; call the returned unsubscribe when they log out or wallet changes.
|
|
461
|
+
*
|
|
462
|
+
* Uses eventId to dedupe (ignores already-seen events). Refetch in your app on each callback.
|
|
463
|
+
*
|
|
464
|
+
* @param ably - Ably Realtime instance (e.g. from useAbly() or new Ably.Realtime({ key }))
|
|
465
|
+
* @param walletAddress - Current player wallet (0x...)
|
|
466
|
+
* @param callbacks - onBalance and/or onInventory; each receives the payload (eventId, timestamp, reason?)
|
|
467
|
+
* @returns Unsubscribe function
|
|
468
|
+
*/
|
|
469
|
+
declare function subscribeWalletRealtime(ably: AblyRealtimeLike, walletAddress: string, callbacks: {
|
|
470
|
+
onBalance?: (payload: RealtimeWalletPayload) => void;
|
|
471
|
+
onInventory?: (payload: RealtimeWalletPayload) => void;
|
|
472
|
+
}): () => void;
|
|
473
|
+
|
|
474
|
+
export { type AblyRealtimeLike, type ApiCallOptions, type AuthData, type OAuthOptions, OmenXGameSDK, type OmenXGameSDKConfig, OmenXServerSDK, REALTIME_EVENTS, type RealtimeWalletPayload, type UserInfo, type VipStatus, type VipTierInfo, WALLET_CHANNEL_PREFIX, getWalletChannelName, subscribeWalletRealtime };
|