@iamgame/wallet-sdk 0.1.3 → 0.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/dist/index.cjs +40 -0
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +36 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -249,6 +249,9 @@ function getTelegram() {
|
|
|
249
249
|
if (typeof window === "undefined") return void 0;
|
|
250
250
|
return window.Telegram;
|
|
251
251
|
}
|
|
252
|
+
function getTelegramWebApp() {
|
|
253
|
+
return getTelegram()?.WebApp ?? null;
|
|
254
|
+
}
|
|
252
255
|
function getTelegramInitData() {
|
|
253
256
|
const data = getTelegram()?.WebApp?.initData;
|
|
254
257
|
if (!data || typeof data !== "string" || data.length === 0) return null;
|
|
@@ -472,6 +475,13 @@ function useSolvenTransferIn() {
|
|
|
472
475
|
const wallet = useSolvenWallet();
|
|
473
476
|
return { destinationAddress: wallet?.address ?? null };
|
|
474
477
|
}
|
|
478
|
+
function useIsTelegram() {
|
|
479
|
+
const [inTelegram, setInTelegram] = react.useState(false);
|
|
480
|
+
react.useEffect(() => {
|
|
481
|
+
setInTelegram(isTelegramMiniApp());
|
|
482
|
+
}, []);
|
|
483
|
+
return inTelegram;
|
|
484
|
+
}
|
|
475
485
|
|
|
476
486
|
// ../../solven/sdk-client/src/wallet-adapter.ts
|
|
477
487
|
function phantomAdapter() {
|
|
@@ -2186,6 +2196,31 @@ async function buildSplTransferIn(deps, opts) {
|
|
|
2186
2196
|
tx.serialize({ requireAllSignatures: false, verifySignatures: false })
|
|
2187
2197
|
).toString("base64");
|
|
2188
2198
|
}
|
|
2199
|
+
var detectors = [
|
|
2200
|
+
{ platform: "telegram", detect: () => isTelegramMiniApp() }
|
|
2201
|
+
// Future hosts drop in here (or via registerPlatform), e.g.:
|
|
2202
|
+
// { platform: "mewe", detect: () => typeof window !== "undefined" && !!(window as { MeWe?: unknown }).MeWe },
|
|
2203
|
+
];
|
|
2204
|
+
function registerPlatform(detector) {
|
|
2205
|
+
detectors.unshift(detector);
|
|
2206
|
+
}
|
|
2207
|
+
function detectPlatform() {
|
|
2208
|
+
if (typeof window === "undefined") return "web";
|
|
2209
|
+
for (const d of detectors) {
|
|
2210
|
+
try {
|
|
2211
|
+
if (d.detect()) return d.platform;
|
|
2212
|
+
} catch {
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return "web";
|
|
2216
|
+
}
|
|
2217
|
+
function usePlatform() {
|
|
2218
|
+
const [platform, setPlatform] = react.useState("web");
|
|
2219
|
+
react.useEffect(() => {
|
|
2220
|
+
setPlatform(detectPlatform());
|
|
2221
|
+
}, []);
|
|
2222
|
+
return platform;
|
|
2223
|
+
}
|
|
2189
2224
|
|
|
2190
2225
|
// src/provider.tsx
|
|
2191
2226
|
var IAMGameWalletProvider = SolvenProvider;
|
|
@@ -2202,14 +2237,19 @@ exports.WalletWithdraw = SolvenWithdraw;
|
|
|
2202
2237
|
exports.backpackAdapter = backpackAdapter;
|
|
2203
2238
|
exports.buildSolTransferIn = buildSolTransferIn;
|
|
2204
2239
|
exports.buildSplTransferIn = buildSplTransferIn;
|
|
2240
|
+
exports.detectPlatform = detectPlatform;
|
|
2205
2241
|
exports.getTelegramInitData = getTelegramInitData;
|
|
2242
|
+
exports.getTelegramWebApp = getTelegramWebApp;
|
|
2206
2243
|
exports.inMemorySession = inMemorySession;
|
|
2207
2244
|
exports.isTelegramMiniApp = isTelegramMiniApp;
|
|
2208
2245
|
exports.listSupportedWallets = listSupportedWallets;
|
|
2209
2246
|
exports.localStorageSession = localStorageSession;
|
|
2210
2247
|
exports.notifyTelegramReady = notifyTelegramReady;
|
|
2211
2248
|
exports.phantomAdapter = phantomAdapter;
|
|
2249
|
+
exports.registerPlatform = registerPlatform;
|
|
2212
2250
|
exports.solflareAdapter = solflareAdapter;
|
|
2251
|
+
exports.useIsTelegram = useIsTelegram;
|
|
2252
|
+
exports.usePlatform = usePlatform;
|
|
2213
2253
|
exports.useWallet = useSolvenWallet;
|
|
2214
2254
|
exports.useWalletAuth = useSolvenAuth;
|
|
2215
2255
|
exports.useWalletBalance = useSolvenBalance;
|
package/dist/index.d.cts
CHANGED
|
@@ -302,6 +302,13 @@ interface IUseIAMGameTransferIn {
|
|
|
302
302
|
destinationAddress: string | null;
|
|
303
303
|
}
|
|
304
304
|
declare function useIAMGameTransferIn(): IUseIAMGameTransferIn;
|
|
305
|
+
/**
|
|
306
|
+
* True when the app is running inside a Telegram Mini App. SSR-safe: returns false
|
|
307
|
+
* on the server and during the first client render, then the real value after mount —
|
|
308
|
+
* so it never causes a hydration mismatch. For imperative checks use isTelegramMiniApp();
|
|
309
|
+
* for the WebApp object (haptics etc.) use getTelegramWebApp().
|
|
310
|
+
*/
|
|
311
|
+
declare function useIsTelegram(): boolean;
|
|
305
312
|
|
|
306
313
|
interface IAMGameLoginTheme {
|
|
307
314
|
primary?: string;
|
|
@@ -497,13 +504,54 @@ declare function buildSolTransferIn(deps: TransferInDeps, opts: BuildSolTransfer
|
|
|
497
504
|
*/
|
|
498
505
|
declare function buildSplTransferIn(deps: TransferInDeps, opts: BuildSplTransferOpts): Promise<string>;
|
|
499
506
|
|
|
507
|
+
/** Minimal shape of the Telegram WebApp object — enough for detection + common UI
|
|
508
|
+
* affordances (haptics, theme, buttons). It is the live Telegram object, so other
|
|
509
|
+
* fields exist at runtime; cast if you need them. */
|
|
510
|
+
interface TelegramWebApp {
|
|
511
|
+
initData?: string;
|
|
512
|
+
version?: string;
|
|
513
|
+
platform?: string;
|
|
514
|
+
colorScheme?: "light" | "dark";
|
|
515
|
+
ready?: () => void;
|
|
516
|
+
expand?: () => void;
|
|
517
|
+
close?: () => void;
|
|
518
|
+
HapticFeedback?: {
|
|
519
|
+
impactOccurred?: (style: "light" | "medium" | "heavy" | "rigid" | "soft") => void;
|
|
520
|
+
notificationOccurred?: (type: "error" | "success" | "warning") => void;
|
|
521
|
+
selectionChanged?: () => void;
|
|
522
|
+
};
|
|
523
|
+
[key: string]: unknown;
|
|
524
|
+
}
|
|
525
|
+
/** The live Telegram WebApp object when running inside Telegram, else null.
|
|
526
|
+
* Use it for haptics etc.: getTelegramWebApp()?.HapticFeedback?.impactOccurred("medium"). */
|
|
527
|
+
declare function getTelegramWebApp(): TelegramWebApp | null;
|
|
500
528
|
declare function getTelegramInitData(): string | null;
|
|
501
529
|
declare function isTelegramMiniApp(): boolean;
|
|
502
530
|
declare function notifyTelegramReady(): void;
|
|
503
531
|
|
|
532
|
+
/** Known hosts. Kept an open string so a new platform (e.g. "mewe") works before a
|
|
533
|
+
* release — register a detector for it and it just flows through everywhere. */
|
|
534
|
+
type Platform = "web" | "telegram" | "mewe" | (string & {});
|
|
535
|
+
interface PlatformDetector {
|
|
536
|
+
platform: Platform;
|
|
537
|
+
/** True when the app is running inside this host. Runs only in the browser. */
|
|
538
|
+
detect: () => boolean;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Register a host detector the SDK doesn't know yet (checked before the built-ins).
|
|
542
|
+
* Call once at app start. This is the seam for launching on a new platform — no SDK
|
|
543
|
+
* release required.
|
|
544
|
+
*/
|
|
545
|
+
declare function registerPlatform(detector: PlatformDetector): void;
|
|
546
|
+
/** The current host platform. "web" on the server and as the default. */
|
|
547
|
+
declare function detectPlatform(): Platform;
|
|
548
|
+
/** SSR-safe reactive platform: "web" on the server + first client render, then the
|
|
549
|
+
* real value after mount — so it never causes a hydration mismatch. */
|
|
550
|
+
declare function usePlatform(): Platform;
|
|
551
|
+
|
|
504
552
|
interface IAMGameWalletProviderProps extends IAMGameClientOptions {
|
|
505
553
|
children: React.ReactNode;
|
|
506
554
|
}
|
|
507
555
|
declare const IAMGameWalletProvider: React.FC<IAMGameWalletProviderProps>;
|
|
508
556
|
|
|
509
|
-
export { type AuthMethod, type BuildSolTransferOpts, type BuildSplTransferOpts, type ComplianceModuleType, type ComplianceStatus, IAMGameClient as IAMGameWalletClient, type IAMGameClientOptions as IAMGameWalletClientOptions, IAMGameWalletProvider, type IAMGameWalletProviderProps, type IComplianceState, type IExportInitiateRequest, type IExportInitiateResponse, type IExportPreflightResponse, type IExternalWalletAdapter, type ISession, type ISessionStorage, type ISignActionRequest, type ISignActionResponse, type ISiwsChallenge, type ISiwsVerifyRequest, type ITelegramVerifyRequest, type ITokenBalance, type IUseIAMGameAuth as IUseWalletAuth, type IUseIAMGameExport as IUseWalletExport, type IUseIAMGameSign as IUseWalletSign, type IUseIAMGameTransferIn as IUseWalletTransferIn, type IUser, type IUserIdentity, type IWallet, type IWalletBalance, type IIAMGameErrorEnvelope as IWalletErrorEnvelope, type IWebhookEnvelope, type IWebhookSignatureHeader, type IWithdrawRequest, type IWithdrawResponse, type TransferInDeps, IAMGameAddress as WalletAddress, type IAMGameAddressProps as WalletAddressProps, type IAMGameAddressTheme as WalletAddressTheme, IAMGameBalance as WalletBalance, type IAMGameBalanceProps as WalletBalanceProps, type IAMGameBalanceTheme as WalletBalanceTheme, type WalletCustody, type WalletDescriptor, type IAMGameErrorCode as WalletErrorCode, IAMGameExport as WalletExport, type IAMGameExportProps as WalletExportProps, type IAMGameExportTheme as WalletExportTheme, type WalletId, IAMGameLogin as WalletLogin, IAMGameLoginModal as WalletLoginModal, type IAMGameLoginModalProps as WalletLoginModalProps, type IAMGameLoginProps as WalletLoginProps, type IAMGameLoginTheme as WalletLoginTheme, IAMGameSdkError as WalletSdkError, type WalletStatus, IAMGameWithdraw as WalletWithdraw, type IAMGameWithdrawProps as WalletWithdrawProps, type IAMGameWithdrawTheme as WalletWithdrawTheme, type WebhookEventType, backpackAdapter, buildSolTransferIn, buildSplTransferIn, getTelegramInitData, inMemorySession, isTelegramMiniApp, listSupportedWallets, localStorageSession, notifyTelegramReady, phantomAdapter, solflareAdapter, useIAMGameWallet as useWallet, useIAMGameAuth as useWalletAuth, useIAMGameBalance as useWalletBalance, useIAMGameExport as useWalletExport, useIAMGameSign as useWalletSign, useIAMGameTransferIn as useWalletTransferIn };
|
|
557
|
+
export { type AuthMethod, type BuildSolTransferOpts, type BuildSplTransferOpts, type ComplianceModuleType, type ComplianceStatus, IAMGameClient as IAMGameWalletClient, type IAMGameClientOptions as IAMGameWalletClientOptions, IAMGameWalletProvider, type IAMGameWalletProviderProps, type IComplianceState, type IExportInitiateRequest, type IExportInitiateResponse, type IExportPreflightResponse, type IExternalWalletAdapter, type ISession, type ISessionStorage, type ISignActionRequest, type ISignActionResponse, type ISiwsChallenge, type ISiwsVerifyRequest, type ITelegramVerifyRequest, type ITokenBalance, type IUseIAMGameAuth as IUseWalletAuth, type IUseIAMGameExport as IUseWalletExport, type IUseIAMGameSign as IUseWalletSign, type IUseIAMGameTransferIn as IUseWalletTransferIn, type IUser, type IUserIdentity, type IWallet, type IWalletBalance, type IIAMGameErrorEnvelope as IWalletErrorEnvelope, type IWebhookEnvelope, type IWebhookSignatureHeader, type IWithdrawRequest, type IWithdrawResponse, type Platform, type PlatformDetector, type TelegramWebApp, type TransferInDeps, IAMGameAddress as WalletAddress, type IAMGameAddressProps as WalletAddressProps, type IAMGameAddressTheme as WalletAddressTheme, IAMGameBalance as WalletBalance, type IAMGameBalanceProps as WalletBalanceProps, type IAMGameBalanceTheme as WalletBalanceTheme, type WalletCustody, type WalletDescriptor, type IAMGameErrorCode as WalletErrorCode, IAMGameExport as WalletExport, type IAMGameExportProps as WalletExportProps, type IAMGameExportTheme as WalletExportTheme, type WalletId, IAMGameLogin as WalletLogin, IAMGameLoginModal as WalletLoginModal, type IAMGameLoginModalProps as WalletLoginModalProps, type IAMGameLoginProps as WalletLoginProps, type IAMGameLoginTheme as WalletLoginTheme, IAMGameSdkError as WalletSdkError, type WalletStatus, IAMGameWithdraw as WalletWithdraw, type IAMGameWithdrawProps as WalletWithdrawProps, type IAMGameWithdrawTheme as WalletWithdrawTheme, type WebhookEventType, backpackAdapter, buildSolTransferIn, buildSplTransferIn, detectPlatform, getTelegramInitData, getTelegramWebApp, inMemorySession, isTelegramMiniApp, listSupportedWallets, localStorageSession, notifyTelegramReady, phantomAdapter, registerPlatform, solflareAdapter, useIsTelegram, usePlatform, useIAMGameWallet as useWallet, useIAMGameAuth as useWalletAuth, useIAMGameBalance as useWalletBalance, useIAMGameExport as useWalletExport, useIAMGameSign as useWalletSign, useIAMGameTransferIn as useWalletTransferIn };
|
package/dist/index.d.ts
CHANGED
|
@@ -302,6 +302,13 @@ interface IUseIAMGameTransferIn {
|
|
|
302
302
|
destinationAddress: string | null;
|
|
303
303
|
}
|
|
304
304
|
declare function useIAMGameTransferIn(): IUseIAMGameTransferIn;
|
|
305
|
+
/**
|
|
306
|
+
* True when the app is running inside a Telegram Mini App. SSR-safe: returns false
|
|
307
|
+
* on the server and during the first client render, then the real value after mount —
|
|
308
|
+
* so it never causes a hydration mismatch. For imperative checks use isTelegramMiniApp();
|
|
309
|
+
* for the WebApp object (haptics etc.) use getTelegramWebApp().
|
|
310
|
+
*/
|
|
311
|
+
declare function useIsTelegram(): boolean;
|
|
305
312
|
|
|
306
313
|
interface IAMGameLoginTheme {
|
|
307
314
|
primary?: string;
|
|
@@ -497,13 +504,54 @@ declare function buildSolTransferIn(deps: TransferInDeps, opts: BuildSolTransfer
|
|
|
497
504
|
*/
|
|
498
505
|
declare function buildSplTransferIn(deps: TransferInDeps, opts: BuildSplTransferOpts): Promise<string>;
|
|
499
506
|
|
|
507
|
+
/** Minimal shape of the Telegram WebApp object — enough for detection + common UI
|
|
508
|
+
* affordances (haptics, theme, buttons). It is the live Telegram object, so other
|
|
509
|
+
* fields exist at runtime; cast if you need them. */
|
|
510
|
+
interface TelegramWebApp {
|
|
511
|
+
initData?: string;
|
|
512
|
+
version?: string;
|
|
513
|
+
platform?: string;
|
|
514
|
+
colorScheme?: "light" | "dark";
|
|
515
|
+
ready?: () => void;
|
|
516
|
+
expand?: () => void;
|
|
517
|
+
close?: () => void;
|
|
518
|
+
HapticFeedback?: {
|
|
519
|
+
impactOccurred?: (style: "light" | "medium" | "heavy" | "rigid" | "soft") => void;
|
|
520
|
+
notificationOccurred?: (type: "error" | "success" | "warning") => void;
|
|
521
|
+
selectionChanged?: () => void;
|
|
522
|
+
};
|
|
523
|
+
[key: string]: unknown;
|
|
524
|
+
}
|
|
525
|
+
/** The live Telegram WebApp object when running inside Telegram, else null.
|
|
526
|
+
* Use it for haptics etc.: getTelegramWebApp()?.HapticFeedback?.impactOccurred("medium"). */
|
|
527
|
+
declare function getTelegramWebApp(): TelegramWebApp | null;
|
|
500
528
|
declare function getTelegramInitData(): string | null;
|
|
501
529
|
declare function isTelegramMiniApp(): boolean;
|
|
502
530
|
declare function notifyTelegramReady(): void;
|
|
503
531
|
|
|
532
|
+
/** Known hosts. Kept an open string so a new platform (e.g. "mewe") works before a
|
|
533
|
+
* release — register a detector for it and it just flows through everywhere. */
|
|
534
|
+
type Platform = "web" | "telegram" | "mewe" | (string & {});
|
|
535
|
+
interface PlatformDetector {
|
|
536
|
+
platform: Platform;
|
|
537
|
+
/** True when the app is running inside this host. Runs only in the browser. */
|
|
538
|
+
detect: () => boolean;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Register a host detector the SDK doesn't know yet (checked before the built-ins).
|
|
542
|
+
* Call once at app start. This is the seam for launching on a new platform — no SDK
|
|
543
|
+
* release required.
|
|
544
|
+
*/
|
|
545
|
+
declare function registerPlatform(detector: PlatformDetector): void;
|
|
546
|
+
/** The current host platform. "web" on the server and as the default. */
|
|
547
|
+
declare function detectPlatform(): Platform;
|
|
548
|
+
/** SSR-safe reactive platform: "web" on the server + first client render, then the
|
|
549
|
+
* real value after mount — so it never causes a hydration mismatch. */
|
|
550
|
+
declare function usePlatform(): Platform;
|
|
551
|
+
|
|
504
552
|
interface IAMGameWalletProviderProps extends IAMGameClientOptions {
|
|
505
553
|
children: React.ReactNode;
|
|
506
554
|
}
|
|
507
555
|
declare const IAMGameWalletProvider: React.FC<IAMGameWalletProviderProps>;
|
|
508
556
|
|
|
509
|
-
export { type AuthMethod, type BuildSolTransferOpts, type BuildSplTransferOpts, type ComplianceModuleType, type ComplianceStatus, IAMGameClient as IAMGameWalletClient, type IAMGameClientOptions as IAMGameWalletClientOptions, IAMGameWalletProvider, type IAMGameWalletProviderProps, type IComplianceState, type IExportInitiateRequest, type IExportInitiateResponse, type IExportPreflightResponse, type IExternalWalletAdapter, type ISession, type ISessionStorage, type ISignActionRequest, type ISignActionResponse, type ISiwsChallenge, type ISiwsVerifyRequest, type ITelegramVerifyRequest, type ITokenBalance, type IUseIAMGameAuth as IUseWalletAuth, type IUseIAMGameExport as IUseWalletExport, type IUseIAMGameSign as IUseWalletSign, type IUseIAMGameTransferIn as IUseWalletTransferIn, type IUser, type IUserIdentity, type IWallet, type IWalletBalance, type IIAMGameErrorEnvelope as IWalletErrorEnvelope, type IWebhookEnvelope, type IWebhookSignatureHeader, type IWithdrawRequest, type IWithdrawResponse, type TransferInDeps, IAMGameAddress as WalletAddress, type IAMGameAddressProps as WalletAddressProps, type IAMGameAddressTheme as WalletAddressTheme, IAMGameBalance as WalletBalance, type IAMGameBalanceProps as WalletBalanceProps, type IAMGameBalanceTheme as WalletBalanceTheme, type WalletCustody, type WalletDescriptor, type IAMGameErrorCode as WalletErrorCode, IAMGameExport as WalletExport, type IAMGameExportProps as WalletExportProps, type IAMGameExportTheme as WalletExportTheme, type WalletId, IAMGameLogin as WalletLogin, IAMGameLoginModal as WalletLoginModal, type IAMGameLoginModalProps as WalletLoginModalProps, type IAMGameLoginProps as WalletLoginProps, type IAMGameLoginTheme as WalletLoginTheme, IAMGameSdkError as WalletSdkError, type WalletStatus, IAMGameWithdraw as WalletWithdraw, type IAMGameWithdrawProps as WalletWithdrawProps, type IAMGameWithdrawTheme as WalletWithdrawTheme, type WebhookEventType, backpackAdapter, buildSolTransferIn, buildSplTransferIn, getTelegramInitData, inMemorySession, isTelegramMiniApp, listSupportedWallets, localStorageSession, notifyTelegramReady, phantomAdapter, solflareAdapter, useIAMGameWallet as useWallet, useIAMGameAuth as useWalletAuth, useIAMGameBalance as useWalletBalance, useIAMGameExport as useWalletExport, useIAMGameSign as useWalletSign, useIAMGameTransferIn as useWalletTransferIn };
|
|
557
|
+
export { type AuthMethod, type BuildSolTransferOpts, type BuildSplTransferOpts, type ComplianceModuleType, type ComplianceStatus, IAMGameClient as IAMGameWalletClient, type IAMGameClientOptions as IAMGameWalletClientOptions, IAMGameWalletProvider, type IAMGameWalletProviderProps, type IComplianceState, type IExportInitiateRequest, type IExportInitiateResponse, type IExportPreflightResponse, type IExternalWalletAdapter, type ISession, type ISessionStorage, type ISignActionRequest, type ISignActionResponse, type ISiwsChallenge, type ISiwsVerifyRequest, type ITelegramVerifyRequest, type ITokenBalance, type IUseIAMGameAuth as IUseWalletAuth, type IUseIAMGameExport as IUseWalletExport, type IUseIAMGameSign as IUseWalletSign, type IUseIAMGameTransferIn as IUseWalletTransferIn, type IUser, type IUserIdentity, type IWallet, type IWalletBalance, type IIAMGameErrorEnvelope as IWalletErrorEnvelope, type IWebhookEnvelope, type IWebhookSignatureHeader, type IWithdrawRequest, type IWithdrawResponse, type Platform, type PlatformDetector, type TelegramWebApp, type TransferInDeps, IAMGameAddress as WalletAddress, type IAMGameAddressProps as WalletAddressProps, type IAMGameAddressTheme as WalletAddressTheme, IAMGameBalance as WalletBalance, type IAMGameBalanceProps as WalletBalanceProps, type IAMGameBalanceTheme as WalletBalanceTheme, type WalletCustody, type WalletDescriptor, type IAMGameErrorCode as WalletErrorCode, IAMGameExport as WalletExport, type IAMGameExportProps as WalletExportProps, type IAMGameExportTheme as WalletExportTheme, type WalletId, IAMGameLogin as WalletLogin, IAMGameLoginModal as WalletLoginModal, type IAMGameLoginModalProps as WalletLoginModalProps, type IAMGameLoginProps as WalletLoginProps, type IAMGameLoginTheme as WalletLoginTheme, IAMGameSdkError as WalletSdkError, type WalletStatus, IAMGameWithdraw as WalletWithdraw, type IAMGameWithdrawProps as WalletWithdrawProps, type IAMGameWithdrawTheme as WalletWithdrawTheme, type WebhookEventType, backpackAdapter, buildSolTransferIn, buildSplTransferIn, detectPlatform, getTelegramInitData, getTelegramWebApp, inMemorySession, isTelegramMiniApp, listSupportedWallets, localStorageSession, notifyTelegramReady, phantomAdapter, registerPlatform, solflareAdapter, useIsTelegram, usePlatform, useIAMGameWallet as useWallet, useIAMGameAuth as useWalletAuth, useIAMGameBalance as useWalletBalance, useIAMGameExport as useWalletExport, useIAMGameSign as useWalletSign, useIAMGameTransferIn as useWalletTransferIn };
|
package/dist/index.js
CHANGED
|
@@ -247,6 +247,9 @@ function getTelegram() {
|
|
|
247
247
|
if (typeof window === "undefined") return void 0;
|
|
248
248
|
return window.Telegram;
|
|
249
249
|
}
|
|
250
|
+
function getTelegramWebApp() {
|
|
251
|
+
return getTelegram()?.WebApp ?? null;
|
|
252
|
+
}
|
|
250
253
|
function getTelegramInitData() {
|
|
251
254
|
const data = getTelegram()?.WebApp?.initData;
|
|
252
255
|
if (!data || typeof data !== "string" || data.length === 0) return null;
|
|
@@ -470,6 +473,13 @@ function useSolvenTransferIn() {
|
|
|
470
473
|
const wallet = useSolvenWallet();
|
|
471
474
|
return { destinationAddress: wallet?.address ?? null };
|
|
472
475
|
}
|
|
476
|
+
function useIsTelegram() {
|
|
477
|
+
const [inTelegram, setInTelegram] = useState(false);
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
setInTelegram(isTelegramMiniApp());
|
|
480
|
+
}, []);
|
|
481
|
+
return inTelegram;
|
|
482
|
+
}
|
|
473
483
|
|
|
474
484
|
// ../../solven/sdk-client/src/wallet-adapter.ts
|
|
475
485
|
function phantomAdapter() {
|
|
@@ -2184,8 +2194,33 @@ async function buildSplTransferIn(deps, opts) {
|
|
|
2184
2194
|
tx.serialize({ requireAllSignatures: false, verifySignatures: false })
|
|
2185
2195
|
).toString("base64");
|
|
2186
2196
|
}
|
|
2197
|
+
var detectors = [
|
|
2198
|
+
{ platform: "telegram", detect: () => isTelegramMiniApp() }
|
|
2199
|
+
// Future hosts drop in here (or via registerPlatform), e.g.:
|
|
2200
|
+
// { platform: "mewe", detect: () => typeof window !== "undefined" && !!(window as { MeWe?: unknown }).MeWe },
|
|
2201
|
+
];
|
|
2202
|
+
function registerPlatform(detector) {
|
|
2203
|
+
detectors.unshift(detector);
|
|
2204
|
+
}
|
|
2205
|
+
function detectPlatform() {
|
|
2206
|
+
if (typeof window === "undefined") return "web";
|
|
2207
|
+
for (const d of detectors) {
|
|
2208
|
+
try {
|
|
2209
|
+
if (d.detect()) return d.platform;
|
|
2210
|
+
} catch {
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
return "web";
|
|
2214
|
+
}
|
|
2215
|
+
function usePlatform() {
|
|
2216
|
+
const [platform, setPlatform] = useState("web");
|
|
2217
|
+
useEffect(() => {
|
|
2218
|
+
setPlatform(detectPlatform());
|
|
2219
|
+
}, []);
|
|
2220
|
+
return platform;
|
|
2221
|
+
}
|
|
2187
2222
|
|
|
2188
2223
|
// src/provider.tsx
|
|
2189
2224
|
var IAMGameWalletProvider = SolvenProvider;
|
|
2190
2225
|
|
|
2191
|
-
export { SolvenClient as IAMGameWalletClient, IAMGameWalletProvider, SolvenAddress as WalletAddress, SolvenBalance as WalletBalance, SolvenExport as WalletExport, SolvenLogin as WalletLogin, SolvenLoginModal as WalletLoginModal, SolvenSdkError as WalletSdkError, SolvenWithdraw as WalletWithdraw, backpackAdapter, buildSolTransferIn, buildSplTransferIn, getTelegramInitData, inMemorySession, isTelegramMiniApp, listSupportedWallets, localStorageSession, notifyTelegramReady, phantomAdapter, solflareAdapter, useSolvenWallet as useWallet, useSolvenAuth as useWalletAuth, useSolvenBalance as useWalletBalance, useSolvenExport as useWalletExport, useSolvenSign as useWalletSign, useSolvenTransferIn as useWalletTransferIn };
|
|
2226
|
+
export { SolvenClient as IAMGameWalletClient, IAMGameWalletProvider, SolvenAddress as WalletAddress, SolvenBalance as WalletBalance, SolvenExport as WalletExport, SolvenLogin as WalletLogin, SolvenLoginModal as WalletLoginModal, SolvenSdkError as WalletSdkError, SolvenWithdraw as WalletWithdraw, backpackAdapter, buildSolTransferIn, buildSplTransferIn, detectPlatform, getTelegramInitData, getTelegramWebApp, inMemorySession, isTelegramMiniApp, listSupportedWallets, localStorageSession, notifyTelegramReady, phantomAdapter, registerPlatform, solflareAdapter, useIsTelegram, usePlatform, useSolvenWallet as useWallet, useSolvenAuth as useWalletAuth, useSolvenBalance as useWalletBalance, useSolvenExport as useWalletExport, useSolvenSign as useWalletSign, useSolvenTransferIn as useWalletTransferIn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamgame/wallet-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "IAMGame Wallet browser SDK — Telegram & Solana wallet auth, balances, server-side signing, and key export. Drop-in React provider for game frontends.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://wallet.iamgame.com",
|