@arkadiuminc/sdk 2.14.1 → 2.16.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.
@@ -8,10 +8,12 @@ declare enum LifecycleEvent {
8
8
  GAME_END = 5,
9
9
  PAUSE_READY = 6,
10
10
  GAME_PAUSE = 7,
11
- GAME_RESUME = 8
11
+ GAME_RESUME = 8,
12
+ GEMS_UPDATE = 9
12
13
  }
13
14
  declare type LifecycleFn = (event: LifecycleEvent, payload?: any) => void;
14
15
  export interface GameLifecycleContract {
16
+ subscribe(fn: LifecycleFn): void;
15
17
  onTestReady(): Promise<void>;
16
18
  onPauseReady(): Promise<void>;
17
19
  onGamePause(): Promise<void>;
@@ -20,7 +22,7 @@ export interface GameLifecycleContract {
20
22
  onInteract(): Promise<void>;
21
23
  onChangeScore(score: number): Promise<void>;
22
24
  onGameEnd(): Promise<void>;
23
- subscribe(fn: LifecycleFn): void;
25
+ onGemsUpdate(): Promise<void>;
24
26
  }
25
27
  /** @hidden */
26
28
  export declare class GameLifecycle implements GameLifecycleContract {
@@ -28,15 +30,16 @@ export declare class GameLifecycle implements GameLifecycleContract {
28
30
  private subscribers;
29
31
  constructor(rpcProvider: RpcProvider);
30
32
  private processLifecycleEvent;
33
+ subscribe(cb: LifecycleFn): void;
31
34
  onTestReady(): Promise<void>;
32
35
  onGameStart(): Promise<void>;
33
36
  onInteract(): Promise<void>;
34
37
  onChangeScore(score: number): Promise<void>;
35
38
  onGameEnd(): Promise<void>;
36
- subscribe(cb: LifecycleFn): void;
37
39
  onGamePause(): Promise<void>;
38
40
  onGameResume(): Promise<void>;
39
41
  onPauseReady(): Promise<void>;
42
+ onGemsUpdate(): Promise<void>;
40
43
  }
41
44
  export declare class GameLifecycleProxy implements GameLifecycleContract {
42
45
  private rpcProvider;
@@ -54,5 +57,6 @@ export declare class GameLifecycleProxy implements GameLifecycleContract {
54
57
  onGamePause(): Promise<void>;
55
58
  onGameResume(): Promise<void>;
56
59
  onPauseReady(): Promise<void>;
60
+ onGemsUpdate(): Promise<void>;
57
61
  }
58
62
  export {};
@@ -0,0 +1,28 @@
1
+ import { ApiEnv, Backend } from '../backend/backend.api';
2
+ import { GameLifecycleContract } from '../game-lifecycle/game-lifecycle.api';
3
+
4
+ export interface Wallet {
5
+ init(env: ApiEnv): Promise<void>;
6
+ getGems(): Promise<number>;
7
+ consumeGems(amount: number): Promise<boolean>;
8
+ }
9
+ export declare class WalletGame implements Wallet {
10
+ private backendApi;
11
+ private lifecycle;
12
+ private virtualItemsApi;
13
+ private virtualItemGateway;
14
+ private currencySku;
15
+ constructor(backendApi: Backend, lifecycle: GameLifecycleContract);
16
+ init(env: ApiEnv): Promise<void>;
17
+ /**
18
+ * Allows querying for the wallet balance
19
+ * @returns the amount of gems in the user wallet
20
+ */
21
+ getGems(): Promise<number>;
22
+ /**
23
+ * Consumes the desired amount of gems from the user wallet
24
+ * @param amount
25
+ * @returns true if the spending of the gem amount was successful, false otherwise
26
+ */
27
+ consumeGems(amount: number): Promise<boolean>;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -6,6 +6,7 @@ import { AnalyticsApiContract } from './api/features/analytics/analytics.api';
6
6
  import { RpcProvider } from './api/core/rpc';
7
7
  import { TimeoutTesterContract } from './api/core/timeout-tester';
8
8
  import { PersistenceGame } from './api/features/persistence';
9
+ import { Wallet, WalletGame } from './api/features/wallet';
9
10
  import { HostGame } from './api/features/host';
10
11
 
11
12
  export declare class ArkadiumGameSdk {
@@ -22,7 +23,8 @@ export declare class ArkadiumGameSdk {
22
23
  analytics: AnalyticsApiContract;
23
24
  private timeoutTester;
24
25
  persistence: PersistenceGame;
25
- constructor({ rpcProvider, backendApi, host, lifecycle, ads, auth, analytics, timeoutTester, persistence }: {
26
+ wallet: Wallet;
27
+ constructor({ rpcProvider, backendApi, host, lifecycle, ads, auth, analytics, timeoutTester, persistence, wallet }: {
26
28
  rpcProvider: RpcProvider;
27
29
  backendApi: Backend;
28
30
  host: HostGame;
@@ -32,6 +34,7 @@ export declare class ArkadiumGameSdk {
32
34
  analytics: AnalyticsApiContract;
33
35
  timeoutTester: TimeoutTesterContract;
34
36
  persistence: PersistenceGame;
37
+ wallet: WalletGame;
35
38
  });
36
39
  initialize(env: ApiEnv, isGameSide: boolean, sessionStorage?: SessionStorageType | null): Promise<void>;
37
40
  getEnv(): ApiEnv;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkadiuminc/sdk",
3
- "version": "2.14.1",
3
+ "version": "2.16.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/pkg/arkadium-sdk.umd.js",
@@ -62,6 +62,7 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@arkadium/eagle-payments-api-client": "^0.0.35",
65
+ "@arkadium/eagle-virtual-items-api-client": "^0.1.3",
65
66
  "@arkadium/eagle-user-client": "^0.0.90",
66
67
  "@commitlint/cli": "^17.8.1",
67
68
  "@commitlint/config-conventional": "^17.8.1",