@autogames/sdk 1.1.1

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.
Files changed (72) hide show
  1. package/README.md +732 -0
  2. package/dist/PhArrowCircleDown-Db_5u1DC.js +73 -0
  3. package/dist/PhArrowClockwise-D5uNEUen.js +73 -0
  4. package/dist/PhArrowDown-CKkl0Ow8.js +73 -0
  5. package/dist/PhArrowLeft-5Y_-c8ih.js +73 -0
  6. package/dist/PhArrowRight-BAENQRa7.js +73 -0
  7. package/dist/PhArrowSquareOut-DlfAcw2e.js +73 -0
  8. package/dist/PhArrowUp-8KZkS1Bo.js +73 -0
  9. package/dist/PhArrowUpRight-DU3GSwzb.js +73 -0
  10. package/dist/PhArrowsClockwise-CShJ-Teu.js +73 -0
  11. package/dist/PhArrowsDownUp-BL_LzwqW.js +73 -0
  12. package/dist/PhArrowsLeftRight-B8vh7AsL.js +73 -0
  13. package/dist/PhBank-CP_QveNf.js +73 -0
  14. package/dist/PhBrowser-CCSpUQte.js +73 -0
  15. package/dist/PhCaretDown-C4u7yn0j.js +73 -0
  16. package/dist/PhCaretLeft-BSbx9BBc.js +73 -0
  17. package/dist/PhCaretRight-B1CumbxI.js +73 -0
  18. package/dist/PhCaretUp-CqiATiNS.js +73 -0
  19. package/dist/PhCheck-DNkwyplN.js +73 -0
  20. package/dist/PhCircleHalf-D4fgYYPo.js +73 -0
  21. package/dist/PhClock-DkIJeKoF.js +73 -0
  22. package/dist/PhCompass-CwVX0Z1y.js +73 -0
  23. package/dist/PhCopy-C0BiDhpw.js +73 -0
  24. package/dist/PhCreditCard-Bv5P9lrI.js +73 -0
  25. package/dist/PhCurrencyDollar-BCl4tAtz.js +73 -0
  26. package/dist/PhDesktop-DREPgw1q.js +73 -0
  27. package/dist/PhDeviceMobile-CM6lQlUa.js +73 -0
  28. package/dist/PhDotsThree-dmgI5Eht.js +73 -0
  29. package/dist/PhEnvelope-D7EatbfP.js +73 -0
  30. package/dist/PhFunnelSimple-Bs-Zsz_A.js +73 -0
  31. package/dist/PhGlobe-Azwq0DDw.js +73 -0
  32. package/dist/PhIdentificationCard-BZpHUHrg.js +73 -0
  33. package/dist/PhImage-CuSFzxM3.js +73 -0
  34. package/dist/PhInfo-B4SBturW.js +73 -0
  35. package/dist/PhLightbulb-79sWB45x.js +73 -0
  36. package/dist/PhMagnifyingGlass-CojwRGSu.js +73 -0
  37. package/dist/PhPaperPlaneRight-C3krm3eP.js +73 -0
  38. package/dist/PhPlus-DDYz48cV.js +73 -0
  39. package/dist/PhPower-CZWV02MF.js +73 -0
  40. package/dist/PhPuzzlePiece-fazdHBSU.js +73 -0
  41. package/dist/PhQrCode-BbBdb_ct.js +73 -0
  42. package/dist/PhQuestion-B6cc25Dw.js +73 -0
  43. package/dist/PhQuestionMark-TmZ4Sxa8.js +73 -0
  44. package/dist/PhSealCheck-CdKeNk5K.js +73 -0
  45. package/dist/PhSignOut-BBNQiKWI.js +73 -0
  46. package/dist/PhSpinner-BwqRA0He.js +73 -0
  47. package/dist/PhTrash-CXtQYiKu.js +73 -0
  48. package/dist/PhUser-DVV5XCqw.js +73 -0
  49. package/dist/PhVault-B73IPDB0.js +73 -0
  50. package/dist/PhWarning-BEhs8fc4.js +73 -0
  51. package/dist/PhWarningCircle-BA0Qvc1c.js +73 -0
  52. package/dist/PhX-CifUIiFs.js +73 -0
  53. package/dist/autogames-sdk.esm.js +5 -0
  54. package/dist/autogames-sdk.js +5247 -0
  55. package/dist/basic-R2aK52rX.js +4875 -0
  56. package/dist/bridge-mount-Bhf05oeO.js +89817 -0
  57. package/dist/ccip-Bg_nydEz.js +145 -0
  58. package/dist/ccip-CjgrAp_t.js +147 -0
  59. package/dist/core-CnCeDQAm.js +17712 -0
  60. package/dist/features-BrlR4_0m.js +268 -0
  61. package/dist/index-C9RsDt_J.js +8044 -0
  62. package/dist/index-Chq42DrS.js +2010 -0
  63. package/dist/index-HQNbtrlg.js +341 -0
  64. package/dist/index-zA8BVXWW.js +264 -0
  65. package/dist/main-oRLGGL0R.js +2284 -0
  66. package/dist/main.d.ts +342 -0
  67. package/dist/parseSignature-DFDCc7FD.js +131 -0
  68. package/dist/property-DkPmFHg2.js +587 -0
  69. package/dist/secp256k1-UpZfvHa8.js +1347 -0
  70. package/dist/stats-confirm.html +4949 -0
  71. package/dist/w3m-modal-ClvdQLsb.js +2822 -0
  72. package/package.json +48 -0
package/dist/main.d.ts ADDED
@@ -0,0 +1,342 @@
1
+ import { PersistOptions } from 'zustand/middleware';
2
+ import { PrivyClientConfig } from '@privy-io/react-auth';
3
+ import { StoreApi } from 'zustand';
4
+ import { UseBoundStore } from 'zustand';
5
+
6
+ export declare interface AuthState {
7
+ isAuthenticated: boolean;
8
+ isReady: boolean;
9
+ user: AutoGamesSDKUser | null;
10
+ }
11
+
12
+ /**
13
+ * Auth store state
14
+ */
15
+ declare interface AuthStoreState {
16
+ accessToken: string | null;
17
+ accessTokenUpdatedAt: string | null;
18
+ user: AutoGamesSDKUser | null;
19
+ isAuthenticated: boolean;
20
+ isReady: boolean;
21
+ error: string | null;
22
+ isLoggingIn: boolean;
23
+ _privyInstance: PrivyInstance | null;
24
+ login: () => Promise<void>;
25
+ logout: () => Promise<void>;
26
+ setAccessToken: (token: string) => void;
27
+ setUser: (user: AutoGamesSDKUser) => void;
28
+ _setAuthState: (state: {
29
+ isReady: boolean;
30
+ }) => void;
31
+ _setPrivyInstance: (instance: PrivyInstance) => void;
32
+ _resolveLogin: (accessToken: string, user: AutoGamesSDKUser) => void;
33
+ _rejectLogin: (error: string) => void;
34
+ }
35
+
36
+ export declare const AutoGamesSDK: AutoGamesSDKClass;
37
+
38
+ declare class AutoGamesSDKClass {
39
+ private static readonly DEFAULT_PRIVY_APP_ID;
40
+ private config;
41
+ private initPromise;
42
+ private unsubscribe;
43
+ /**
44
+ * Initialize the SDK with optional configuration
45
+ * @param config - Optional SDK configuration. If privyAppId is not provided, uses bundled default.
46
+ */
47
+ init(config: SDKConfig): Promise<void>;
48
+ /**
49
+ * Trigger login flow
50
+ * Note: With OAuth providers (e.g., Google), the page may reload during authentication.
51
+ * Use the onAuthStateChange callback in init() or poll isAuthenticated()/getProfile() to detect when login completes.
52
+ */
53
+ login(): Promise<void>;
54
+ /**
55
+ * Logout the current user
56
+ */
57
+ logout(): Promise<void>;
58
+ /**
59
+ * Get current user profile (cached)
60
+ */
61
+ getProfile(): AutoGamesSDKUser | null;
62
+ /**
63
+ * Fetch fresh user profile from backend and update cache
64
+ * @returns User profile or null if not authenticated
65
+ */
66
+ fetchProfile(): Promise<AutoGamesSDKUser | null>;
67
+ /**
68
+ * Vote on a voting
69
+ * @param votingId - The ID of the voting
70
+ * @param body - Vote request body containing option_id and votingID
71
+ * @returns Vote response with message
72
+ */
73
+ vote(votingId: number, body: VoteRequest): Promise<VoteResponse>;
74
+ /**
75
+ * Recall a vote on a voting
76
+ * @param votingId - The ID of the voting
77
+ * @returns Recall response with message
78
+ */
79
+ recall(votingId: number): Promise<RecallResponse>;
80
+ /**
81
+ * Fetch user assets
82
+ * @param userId - The ID of the user
83
+ * @param params - Optional query parameters (limit, prev_user_token, next_user_token)
84
+ * @returns User assets response with array of assets
85
+ */
86
+ fetchUserAssets(userId: number, params?: UserAssetsParams): Promise<UserAssetsResponse>;
87
+ /**
88
+ * Fetch user created tokens
89
+ * @param userId - The ID of the user
90
+ * @param params - Optional query parameters (limit, prev_token, next_token)
91
+ * @returns User created tokens response with array of created tokens
92
+ */
93
+ fetchUserCreatedTokens(userId: number, params?: UserCreatedTokensParams): Promise<UserCreatedTokensResponse>;
94
+ /**
95
+ * Check if user is authenticated
96
+ */
97
+ isAuthenticated(): boolean;
98
+ /**
99
+ * Check if SDK is ready
100
+ */
101
+ isReady(): boolean;
102
+ /**
103
+ * Get current authentication state
104
+ */
105
+ getAuthState(): AuthState;
106
+ /**
107
+ * Clean up subscriptions
108
+ */
109
+ destroy(): void;
110
+ /* Excluded from this release type: waitForReady */
111
+ /* Excluded from this release type: mountBridge */
112
+ private ensureInitialized;
113
+ }
114
+
115
+ export declare type AutoGamesSDKUser = BaseEntity & {
116
+ BalanceUSD: number;
117
+ Email: string;
118
+ GeoInfo: string;
119
+ ImageThumbnailURL: string;
120
+ ImageURL: string;
121
+ IsEmailVerified: boolean;
122
+ Name: string;
123
+ PrivyUserID: string;
124
+ WalletPublicKey: string;
125
+ EthereumAddress: string;
126
+ SolanaAddress: string;
127
+ SolanaBalanceLamports: number;
128
+ };
129
+
130
+ declare interface BaseEntity {
131
+ ID: number;
132
+ CreatedAt: string;
133
+ UpdatedAt: string;
134
+ }
135
+
136
+ declare type CreatedToken = {
137
+ token: Token;
138
+ user_token: UserToken;
139
+ };
140
+
141
+ declare type Game = BaseEntity & {
142
+ Color: string;
143
+ CoverImage: string;
144
+ Description: string;
145
+ DescriptionPreview: string;
146
+ Icon: string;
147
+ Metrics: GameMetrics;
148
+ TickInterval: number;
149
+ Title: string;
150
+ TokenAgentPrice: number;
151
+ TokenLaunchMinStart: number;
152
+ TokensPerLvl: number;
153
+ URL: string;
154
+ };
155
+
156
+ declare type GameMetrics = BaseEntity & {
157
+ game_id: number;
158
+ holders_count: number;
159
+ market_cap_change_1h: number;
160
+ market_cap_change_24h: number;
161
+ market_cap_change_5m: number;
162
+ market_cap_change_6h: number;
163
+ token_count: number;
164
+ total_market_cap: number;
165
+ trades_count_24h: number;
166
+ volume_24h: number;
167
+ };
168
+
169
+ export { PrivyClientConfig }
170
+
171
+ /**
172
+ * Privy instance interface (minimal subset we need)
173
+ */
174
+ declare interface PrivyInstance {
175
+ login: () => Promise<void>;
176
+ logout: () => Promise<void>;
177
+ ready: boolean;
178
+ }
179
+
180
+ declare type RecallResponse = {
181
+ message: string;
182
+ };
183
+
184
+ export declare interface SDKConfig {
185
+ /**
186
+ * Agent ID. Game ID in the AutoGames platform.
187
+ */
188
+ agentId: number;
189
+ /**
190
+ * Optional: Privy App ID. If not provided, uses the bundled default.
191
+ * Only needed if you want to use a different Privy app for isolated user base.
192
+ */
193
+ privyAppId?: string;
194
+ /**
195
+ * Optional: Customize the appearance of Privy UI elements.
196
+ * Uses Privy's native appearance configuration.
197
+ * @see https://docs.privy.io/reference/react-auth/modules#privyclientconfig
198
+ */
199
+ appearance?: PrivyClientConfig['appearance'];
200
+ /**
201
+ * Optional: Configure which login methods are available.
202
+ * Pass an array of enabled methods, e.g. ['email', 'wallet', 'google']
203
+ * Uses Privy's native login methods configuration.
204
+ * @see https://docs.privy.io/reference/react-auth/modules#privyclientconfig
205
+ */
206
+ loginMethods?: PrivyClientConfig['loginMethods'];
207
+ /**
208
+ * Optional: Advanced login methods configuration with ordering.
209
+ * If both loginMethodsAndOrder and loginMethods are defined, loginMethodsAndOrder takes precedence.
210
+ * @see https://docs.privy.io/reference/react-auth/modules#privyclientconfig
211
+ */
212
+ loginMethodsAndOrder?: PrivyClientConfig['loginMethodsAndOrder'];
213
+ /**
214
+ * Optional: Additional Privy client configuration options.
215
+ * This allows you to pass any other PrivyClientConfig options directly.
216
+ * @see https://docs.privy.io/reference/react-auth/modules#privyclientconfig
217
+ */
218
+ config?: Omit<PrivyClientConfig, 'appearance' | 'loginMethods' | 'loginMethodsAndOrder'>;
219
+ /**
220
+ * Optional: Callback fired when authentication state changes
221
+ */
222
+ onAuthStateChange?: (user: AutoGamesSDKUser | null) => void;
223
+ }
224
+
225
+ declare type Token = BaseEntity & {
226
+ AgentLaunchPrice: number;
227
+ AgentLaunchPriceCollected: number;
228
+ CirculatingSupply: number;
229
+ CreatorUserID: number;
230
+ Description: string;
231
+ Game: Game;
232
+ GameID: number;
233
+ HoldersCount: number;
234
+ IsAgent: boolean;
235
+ MarketCap: number;
236
+ MaxSupply: number;
237
+ Meta: Record<string, unknown>;
238
+ Metrics: TokenMetrics;
239
+ MintAddress: string;
240
+ PriceUsd: number;
241
+ Status: string;
242
+ TelegramURL: string;
243
+ Ticker: string;
244
+ Title: string;
245
+ TwitterURL: string;
246
+ WebsiteURL: string;
247
+ };
248
+
249
+ declare type TokenMetrics = BaseEntity & {
250
+ current_price: number;
251
+ holders_count: number;
252
+ market_cap: number;
253
+ market_cap_change_1h: number;
254
+ market_cap_change_24h: number;
255
+ market_cap_change_5m: number;
256
+ market_cap_change_6h: number;
257
+ price_change_1h: number;
258
+ price_change_24h: number;
259
+ price_change_5m: number;
260
+ price_change_6h: number;
261
+ token_id: number;
262
+ trades_count_24h: number;
263
+ volume_24h: number;
264
+ };
265
+
266
+ /**
267
+ * Create auth store with Zustand
268
+ */
269
+ export declare const useAuthStore: UseBoundStore<Omit<Omit<StoreApi<AuthStoreState>, "setState" | "persist"> & {
270
+ setState(partial: AuthStoreState | Partial<AuthStoreState> | ((state: AuthStoreState) => AuthStoreState | Partial<AuthStoreState>), replace?: false | undefined): unknown;
271
+ setState(state: AuthStoreState | ((state: AuthStoreState) => AuthStoreState), replace: true): unknown;
272
+ persist: {
273
+ setOptions: (options: Partial<PersistOptions<AuthStoreState, {
274
+ accessToken: string | null;
275
+ accessTokenUpdatedAt: string | null;
276
+ user: AutoGamesSDKUser | null;
277
+ isAuthenticated: boolean;
278
+ }, unknown>>) => void;
279
+ clearStorage: () => void;
280
+ rehydrate: () => Promise<void> | void;
281
+ hasHydrated: () => boolean;
282
+ onHydrate: (fn: (state: AuthStoreState) => void) => () => void;
283
+ onFinishHydration: (fn: (state: AuthStoreState) => void) => () => void;
284
+ getOptions: () => Partial<PersistOptions<AuthStoreState, {
285
+ accessToken: string | null;
286
+ accessTokenUpdatedAt: string | null;
287
+ user: AutoGamesSDKUser | null;
288
+ isAuthenticated: boolean;
289
+ }, unknown>>;
290
+ };
291
+ }, "subscribe"> & {
292
+ subscribe: {
293
+ (listener: (selectedState: AuthStoreState, previousSelectedState: AuthStoreState) => void): () => void;
294
+ <U>(selector: (state: AuthStoreState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
295
+ equalityFn?: ((a: U, b: U) => boolean) | undefined;
296
+ fireImmediately?: boolean;
297
+ } | undefined): () => void;
298
+ };
299
+ }>;
300
+
301
+ declare type UserAsset = {
302
+ token: Token;
303
+ user_token: UserToken;
304
+ };
305
+
306
+ export declare type UserAssetsParams = {
307
+ limit?: number;
308
+ prev_user_token?: string;
309
+ next_user_token?: string;
310
+ };
311
+
312
+ export declare type UserAssetsResponse = {
313
+ assets: UserAsset[];
314
+ };
315
+
316
+ export declare type UserCreatedTokensParams = {
317
+ limit?: number;
318
+ prev_token?: string;
319
+ next_token?: string;
320
+ };
321
+
322
+ export declare type UserCreatedTokensResponse = {
323
+ created_tokens: CreatedToken[];
324
+ };
325
+
326
+ declare type UserToken = BaseEntity & {
327
+ Amount: number;
328
+ LastUpdatedAt: string;
329
+ TokenID: number;
330
+ UserID: number;
331
+ };
332
+
333
+ declare type VoteRequest = {
334
+ option_id: number;
335
+ votingID: number;
336
+ };
337
+
338
+ declare type VoteResponse = {
339
+ message: string;
340
+ };
341
+
342
+ export { }
@@ -0,0 +1,131 @@
1
+ import { K as b, bP as y, bD as w, a3 as x, bR as p, cd as z, ca as M, d6 as k, cc as f, d7 as P, X as T, d8 as $, a2 as E, d9 as N, bs as S, c6 as B, da as L } from "./bridge-mount-Bhf05oeO.js";
2
+ function _(t, e) {
3
+ if (t.length !== e.length)
4
+ throw new b({
5
+ expectedLength: t.length,
6
+ givenLength: e.length
7
+ });
8
+ const i = [];
9
+ for (let n = 0; n < t.length; n++) {
10
+ const u = t[n], o = e[n];
11
+ i.push(m(u, o));
12
+ }
13
+ return y(i);
14
+ }
15
+ function m(t, e, i = !1) {
16
+ if (t === "address") {
17
+ const r = e;
18
+ if (!w(r))
19
+ throw new x({ address: r });
20
+ return p(r.toLowerCase(), {
21
+ size: i ? 32 : null
22
+ });
23
+ }
24
+ if (t === "string")
25
+ return z(e);
26
+ if (t === "bytes")
27
+ return e;
28
+ if (t === "bool")
29
+ return p(M(e), { size: i ? 32 : 1 });
30
+ const n = t.match(k);
31
+ if (n) {
32
+ const [r, s, a = "256"] = n, c = Number.parseInt(a, 10) / 8;
33
+ return f(e, {
34
+ size: i ? 32 : c,
35
+ signed: s === "int"
36
+ });
37
+ }
38
+ const u = t.match(P);
39
+ if (u) {
40
+ const [r, s] = u;
41
+ if (Number.parseInt(s, 10) !== (e.length - 2) / 2)
42
+ throw new T({
43
+ expectedSize: Number.parseInt(s, 10),
44
+ givenSize: (e.length - 2) / 2
45
+ });
46
+ return p(e, { dir: "right", size: i ? 32 : null });
47
+ }
48
+ const o = t.match($);
49
+ if (o && Array.isArray(e)) {
50
+ const [r, s] = o, a = [];
51
+ for (let c = 0; c < e.length; c++)
52
+ a.push(m(s, e[c], !0));
53
+ return a.length === 0 ? "0x" : y(a);
54
+ }
55
+ throw new E(t);
56
+ }
57
+ function C(t) {
58
+ return {
59
+ formatters: void 0,
60
+ fees: void 0,
61
+ serializers: void 0,
62
+ ...t
63
+ };
64
+ }
65
+ function H(t) {
66
+ const { source: e } = t, i = /* @__PURE__ */ new Map(), n = new N(8192), u = /* @__PURE__ */ new Map(), o = ({ address: r, chainId: s }) => `${r}.${s}`;
67
+ return {
68
+ async consume({ address: r, chainId: s, client: a }) {
69
+ const c = o({ address: r, chainId: s }), d = this.get({ address: r, chainId: s, client: a });
70
+ this.increment({ address: r, chainId: s });
71
+ const g = await d;
72
+ return await e.set({ address: r, chainId: s }, g), n.set(c, g), g;
73
+ },
74
+ async increment({ address: r, chainId: s }) {
75
+ const a = o({ address: r, chainId: s }), c = i.get(a) ?? 0;
76
+ i.set(a, c + 1);
77
+ },
78
+ async get({ address: r, chainId: s, client: a }) {
79
+ const c = o({ address: r, chainId: s });
80
+ let d = u.get(c);
81
+ return d || (d = (async () => {
82
+ try {
83
+ const l = await e.get({ address: r, chainId: s, client: a }), h = n.get(c) ?? 0;
84
+ return h > 0 && l <= h ? h + 1 : (n.delete(c), l);
85
+ } finally {
86
+ this.reset({ address: r, chainId: s });
87
+ }
88
+ })(), u.set(c, d)), (i.get(c) ?? 0) + await d;
89
+ },
90
+ reset({ address: r, chainId: s }) {
91
+ const a = o({ address: r, chainId: s });
92
+ i.delete(a), u.delete(a);
93
+ }
94
+ };
95
+ }
96
+ const A = "0x6492649264926492649264926492649264926492649264926492649264926492";
97
+ function I(t) {
98
+ const { address: e, data: i, signature: n, to: u = "hex" } = t, o = y([
99
+ S([{ type: "address" }, { type: "bytes" }, { type: "bytes" }], [e, i, n]),
100
+ A
101
+ ]);
102
+ return u === "hex" ? o : B(o);
103
+ }
104
+ function K(t) {
105
+ const { r: e, s: i } = L.Signature.fromCompact(t.slice(2, 130)), n = +`0x${t.slice(130)}`, [u, o] = (() => {
106
+ if (n === 0 || n === 1)
107
+ return [void 0, n];
108
+ if (n === 27)
109
+ return [BigInt(n), 0];
110
+ if (n === 28)
111
+ return [BigInt(n), 1];
112
+ throw new Error("Invalid yParityOrV value");
113
+ })();
114
+ return typeof u < "u" ? {
115
+ r: f(e, { size: 32 }),
116
+ s: f(i, { size: 32 }),
117
+ v: u,
118
+ yParity: o
119
+ } : {
120
+ r: f(e, { size: 32 }),
121
+ s: f(i, { size: 32 }),
122
+ yParity: o
123
+ };
124
+ }
125
+ export {
126
+ H as c,
127
+ C as d,
128
+ _ as e,
129
+ K as p,
130
+ I as s
131
+ };