@idosgames/wallet 0.1.6 → 0.1.8

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.
@@ -1,12 +1,12 @@
1
1
  import { CreateConnectorFn, Config } from 'wagmi';
2
2
  import { Chain, Transport } from 'viem';
3
- import { W as WalletLoginResult, e as DepositTokenEvmParams, a as BridgeResult, d as DepositNftEvmParams, k as WithdrawTokenEvmParams, j as WithdrawNftEvmParams, E as EvmBridgeClients, f as DepositTokenSolanaParams, l as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-DvafuXl9.cjs';
4
- export { m as arbitrum, n as base, p as bsc, q as chainById, w as idosChains, x as mainnet, y as optimism, z as polygon, C as polygonAmoy, F as sepolia } from '../bridge-DvafuXl9.cjs';
3
+ export { b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia } from '../chains-B_P3u8_S.cjs';
5
4
  import * as react from 'react';
6
5
  import { ReactNode, CSSProperties } from 'react';
7
6
  import { QueryClient } from '@tanstack/react-query';
8
7
  import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
9
- import { Adapter } from '@solana/wallet-adapter-base';
8
+ import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-CwX4HY2X.cjs';
9
+ import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.cjs';
10
10
 
11
11
  interface EvmWalletConfigOptions {
12
12
  /** Chains the game supports, matching the EVM networks in the title's blockchain config. */
@@ -73,9 +73,9 @@ declare function IDosGamesWalletProvider(props: IDosGamesWalletProviderProps): r
73
73
  * wallet is connected / the wallet client isn't ready yet.
74
74
  */
75
75
  declare function useEvmBridgeClients(): EvmBridgeClients | null;
76
- type DepositTokenArgs$1 = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
76
+ type DepositTokenArgs = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
77
77
  type DepositNftArgs = Omit<DepositNftEvmParams, "client" | "clients" | "titleID">;
78
- type WithdrawTokenArgs$1 = Omit<WithdrawTokenEvmParams, "client" | "clients">;
78
+ type WithdrawTokenArgs = Omit<WithdrawTokenEvmParams, "client" | "clients">;
79
79
  type WithdrawNftArgs = Omit<WithdrawNftEvmParams, "client" | "clients">;
80
80
  interface EvmBridge {
81
81
  /** Whether a wallet is connected and its client is ready. */
@@ -88,9 +88,9 @@ interface EvmBridge {
88
88
  * to the connected account. On success the core client is logged in and its ClientState returned.
89
89
  */
90
90
  loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
91
- depositToken(args: DepositTokenArgs$1): Promise<BridgeResult<DepositTokenResponse>>;
91
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
92
92
  depositNft(args: DepositNftArgs): Promise<BridgeResult<DepositNFTResponse>>;
93
- withdrawToken(args: WithdrawTokenArgs$1): Promise<BridgeResult<TokenWithdrawalResponse>>;
93
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
94
94
  withdrawNft(args: WithdrawNftArgs): Promise<BridgeResult<NFTWithdrawalResponse>>;
95
95
  }
96
96
  /**
@@ -118,6 +118,11 @@ interface WalletLoginProps {
118
118
  disabled?: boolean;
119
119
  label?: string;
120
120
  style?: CSSProperties;
121
+ /**
122
+ * Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
123
+ * which already consumed the player's click to load this module — a second tap would be a bug.
124
+ */
125
+ autoStart?: boolean;
121
126
  }
122
127
  /**
123
128
  * Ready-made "sign in with wallet" button: connect → sign the challenge → session.
@@ -135,49 +140,4 @@ type WalletLoginButtonProps = Omit<WalletLoginProps, "wagmiConfig">;
135
140
  /** The button itself. Must be rendered inside an {@link IDosGamesWalletProvider}. */
136
141
  declare function WalletLoginButton(props: WalletLoginButtonProps): ReactNode;
137
142
 
138
- interface SolanaWalletBridgeProviderProps {
139
- /** RPC endpoint for the Solana network the title uses (matches its blockchain config). */
140
- endpoint: string;
141
- /**
142
- * Wallet adapters to offer (e.g. `new PhantomWalletAdapter()` from
143
- * `@solana/wallet-adapter-wallets`). Mobile support comes from adapters that implement it
144
- * (Mobile Wallet Adapter on Android, or a WalletConnect adapter).
145
- */
146
- wallets: Adapter[];
147
- /** Auto-reconnect the last-used wallet on mount. */
148
- autoConnect?: boolean;
149
- children: ReactNode;
150
- }
151
- /**
152
- * Thin wrapper over wallet-adapter's `ConnectionProvider` + `WalletProvider` so the
153
- * {@link useSolanaBridge} hook has a connected wallet. Compose it alongside
154
- * {@link IDosGamesWalletProvider} when a title supports both EVM and Solana networks.
155
- */
156
- declare function SolanaWalletBridgeProvider(props: SolanaWalletBridgeProviderProps): react.JSX.Element;
157
-
158
- type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
159
- /** `walletAddress` defaults to the connected wallet if omitted. */
160
- type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
161
- walletAddress?: string;
162
- };
163
- interface SolanaBridge {
164
- connected: boolean;
165
- account: string | null;
166
- /**
167
- * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
168
- * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
169
- * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
170
- */
171
- loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
172
- depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
173
- withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
174
- }
175
- /**
176
- * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
177
- * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
178
- * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
179
- * just wires the connected address and threads the request → submit → confirm lifecycle.
180
- */
181
- declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
182
-
183
- export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, type SolanaBridge, SolanaWalletBridgeProvider, type SolanaWalletBridgeProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients, useSolanaBridge };
143
+ export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients };
@@ -1,12 +1,12 @@
1
1
  import { CreateConnectorFn, Config } from 'wagmi';
2
2
  import { Chain, Transport } from 'viem';
3
- import { W as WalletLoginResult, e as DepositTokenEvmParams, a as BridgeResult, d as DepositNftEvmParams, k as WithdrawTokenEvmParams, j as WithdrawNftEvmParams, E as EvmBridgeClients, f as DepositTokenSolanaParams, l as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-DvafuXl9.js';
4
- export { m as arbitrum, n as base, p as bsc, q as chainById, w as idosChains, x as mainnet, y as optimism, z as polygon, C as polygonAmoy, F as sepolia } from '../bridge-DvafuXl9.js';
3
+ export { b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia } from '../chains-B_P3u8_S.js';
5
4
  import * as react from 'react';
6
5
  import { ReactNode, CSSProperties } from 'react';
7
6
  import { QueryClient } from '@tanstack/react-query';
8
7
  import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
9
- import { Adapter } from '@solana/wallet-adapter-base';
8
+ import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-C-sFNUnQ.js';
9
+ import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.js';
10
10
 
11
11
  interface EvmWalletConfigOptions {
12
12
  /** Chains the game supports, matching the EVM networks in the title's blockchain config. */
@@ -73,9 +73,9 @@ declare function IDosGamesWalletProvider(props: IDosGamesWalletProviderProps): r
73
73
  * wallet is connected / the wallet client isn't ready yet.
74
74
  */
75
75
  declare function useEvmBridgeClients(): EvmBridgeClients | null;
76
- type DepositTokenArgs$1 = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
76
+ type DepositTokenArgs = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
77
77
  type DepositNftArgs = Omit<DepositNftEvmParams, "client" | "clients" | "titleID">;
78
- type WithdrawTokenArgs$1 = Omit<WithdrawTokenEvmParams, "client" | "clients">;
78
+ type WithdrawTokenArgs = Omit<WithdrawTokenEvmParams, "client" | "clients">;
79
79
  type WithdrawNftArgs = Omit<WithdrawNftEvmParams, "client" | "clients">;
80
80
  interface EvmBridge {
81
81
  /** Whether a wallet is connected and its client is ready. */
@@ -88,9 +88,9 @@ interface EvmBridge {
88
88
  * to the connected account. On success the core client is logged in and its ClientState returned.
89
89
  */
90
90
  loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
91
- depositToken(args: DepositTokenArgs$1): Promise<BridgeResult<DepositTokenResponse>>;
91
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
92
92
  depositNft(args: DepositNftArgs): Promise<BridgeResult<DepositNFTResponse>>;
93
- withdrawToken(args: WithdrawTokenArgs$1): Promise<BridgeResult<TokenWithdrawalResponse>>;
93
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
94
94
  withdrawNft(args: WithdrawNftArgs): Promise<BridgeResult<NFTWithdrawalResponse>>;
95
95
  }
96
96
  /**
@@ -118,6 +118,11 @@ interface WalletLoginProps {
118
118
  disabled?: boolean;
119
119
  label?: string;
120
120
  style?: CSSProperties;
121
+ /**
122
+ * Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
123
+ * which already consumed the player's click to load this module — a second tap would be a bug.
124
+ */
125
+ autoStart?: boolean;
121
126
  }
122
127
  /**
123
128
  * Ready-made "sign in with wallet" button: connect → sign the challenge → session.
@@ -135,49 +140,4 @@ type WalletLoginButtonProps = Omit<WalletLoginProps, "wagmiConfig">;
135
140
  /** The button itself. Must be rendered inside an {@link IDosGamesWalletProvider}. */
136
141
  declare function WalletLoginButton(props: WalletLoginButtonProps): ReactNode;
137
142
 
138
- interface SolanaWalletBridgeProviderProps {
139
- /** RPC endpoint for the Solana network the title uses (matches its blockchain config). */
140
- endpoint: string;
141
- /**
142
- * Wallet adapters to offer (e.g. `new PhantomWalletAdapter()` from
143
- * `@solana/wallet-adapter-wallets`). Mobile support comes from adapters that implement it
144
- * (Mobile Wallet Adapter on Android, or a WalletConnect adapter).
145
- */
146
- wallets: Adapter[];
147
- /** Auto-reconnect the last-used wallet on mount. */
148
- autoConnect?: boolean;
149
- children: ReactNode;
150
- }
151
- /**
152
- * Thin wrapper over wallet-adapter's `ConnectionProvider` + `WalletProvider` so the
153
- * {@link useSolanaBridge} hook has a connected wallet. Compose it alongside
154
- * {@link IDosGamesWalletProvider} when a title supports both EVM and Solana networks.
155
- */
156
- declare function SolanaWalletBridgeProvider(props: SolanaWalletBridgeProviderProps): react.JSX.Element;
157
-
158
- type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
159
- /** `walletAddress` defaults to the connected wallet if omitted. */
160
- type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
161
- walletAddress?: string;
162
- };
163
- interface SolanaBridge {
164
- connected: boolean;
165
- account: string | null;
166
- /**
167
- * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
168
- * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
169
- * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
170
- */
171
- loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
172
- depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
173
- withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
174
- }
175
- /**
176
- * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
177
- * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
178
- * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
179
- * just wires the connected address and threads the request → submit → confirm lifecycle.
180
- */
181
- declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
182
-
183
- export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, type SolanaBridge, SolanaWalletBridgeProvider, type SolanaWalletBridgeProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients, useSolanaBridge };
143
+ export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients };
@@ -1 +1 @@
1
- import {n,C as C$1,b,B,w,v,D,c,F,E,G as G$1}from'../chunk-ZPNBMRUO.js';export{h as arbitrum,g as base,e as bsc,m as chainById,l as idosChains,d as mainnet,i as optimism,f as polygon,k as polygonAmoy,j as sepolia}from'../chunk-ZPNBMRUO.js';import {http,createConfig,WagmiProvider,useAccount,usePublicClient,useWalletClient,useConfig,useConnect}from'wagmi';import {injected,coinbaseWallet}from'wagmi/connectors';import {WagmiAdapter}from'@reown/appkit-adapter-wagmi';import {createAppKit}from'@reown/appkit/react';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {useState}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getAccount,watchAccount,getWalletClient,getPublicClient}from'wagmi/actions';import {ConnectionProvider,WalletProvider,useWallet}from'@solana/wallet-adapter-react';var G=null;function O(){return G}function ae(e){let{chains:o,walletConnectProjectId:t,appName:n$1,appUrl:r,appIcon:i,transports:s,connectors:a}=e,l={};for(let p of o)l[p.id]=s?.[p.id]??http();let W=r??(typeof window<"u"?window.location.origin:""),v={name:n$1??"iDosGames",description:n$1??"iDosGames game",url:W,icons:i?[i]:[]};if(t&&!a){let p=o.map(n),m=new WagmiAdapter({networks:p,projectId:t,transports:l});return G=createAppKit({adapters:[m],networks:p,projectId:t,metadata:v,features:{analytics:false,email:false,socials:false}}),m.wagmiConfig}let P=a??[injected(),coinbaseWallet({appName:n$1??"iDosGames"})];return createConfig({chains:o,connectors:P,transports:l})}function k(e){let{wagmiConfig:o,queryClient:t,children:n}=e,[r]=useState(()=>t??new QueryClient);return jsx(WagmiProvider,{config:o,children:jsx(QueryClientProvider,{client:r,children:n})})}function C(){let{address:e}=useAccount(),o=usePublicClient(),{data:t}=useWalletClient();return !e||!o||!t?null:{account:e,publicClient:o,walletClient:t}}var f="Wallet not connected.";function ge(e,o){let t=C();return {connected:!!t,account:t?.account??null,loginWithWallet:(n,r)=>t?D({client:e,clients:t,networkID:n,walletAddress:r}):Promise.resolve(c("challenge",f)),depositToken:n=>t?v({client:e,clients:t,titleID:o,...n}):Promise.resolve(b("approve",f)),depositNft:n=>t?w({client:e,clients:t,titleID:o,...n}):Promise.resolve(b("deposit-onchain",f)),withdrawToken:n=>t?B({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",f)),withdrawNft:n=>t?C$1({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",f))}}function he(e){let{wagmiConfig:o,...t}=e;return jsx(k,{wagmiConfig:o,children:jsx(j,{...t})})}function ke(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function Te(e){let o="Wallet sign-in failed. Please try again.";return e instanceof Error?e.name==="ProviderNotFoundError"||/provider not found/i.test(e.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":e.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":o:o}async function Ee(e){let o=await getWalletClient(e).catch(()=>null);if(!o)return null;let t=getPublicClient(e);return t?{account:o.account.address,publicClient:t,walletClient:o}:null}function Ae(e,o=18e4){return getAccount(e).isConnected?Promise.resolve(true):new Promise(t=>{let n=false,r=a=>{n||(n=true,i(),clearTimeout(s),t(a));},i=watchAccount(e,{onChange:a=>{a.isConnected&&r(true);}}),s=setTimeout(()=>r(false),o);})}function De(e){let o=r=>e.find(i=>i.id===r||i.type===r),t=o("injected"),n=typeof window<"u"&&window.ethereum!=null;return t&&n?t:o("walletConnect")??t??e[0]}function j(e){let{client:o,networkID:t,onAuthenticated:n,disabled:r,label:i,style:s}=e,a=useConfig(),{isConnected:l}=useAccount(),{connectAsync:W,connectors:v}=useConnect(),P=C(),[p,m]=useState(false),[T,d]=useState(null),M=async()=>{m(true),d(null);try{if(!l){let E=O();if(E){if(await E.open(),!await Ae(a)){d("No wallet was connected.");return}}else {let A=De(v);if(!A){d("No wallet connector is configured.");return}try{await W({connector:A});}catch(D){if(!ke(D))throw D}}}let u=P??await Ee(a);if(!u){d("Wallet client is not available.");return}let h=await D({client:o,clients:u,networkID:t});if(h.ok){n();return}d(h.stage==="sign"?"Signature declined.":h.error??"Wallet sign-in failed.");}catch(u){console.error("[idosgames/wallet] wallet sign-in failed:",u),d(Te(u));}finally{m(false);}};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{M();},disabled:r||p,style:{...Ne,...r||p?{opacity:.6,cursor:"default"}:null,...s},children:p?"Check your wallet\u2026":l?i??"Sign in with wallet":"Connect wallet"}),T&&jsx("span",{role:"alert",style:Be,children:T})]})}var Ne={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Be={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function xe(e){let{endpoint:o,wallets:t,autoConnect:n=true,children:r}=e;return jsx(ConnectionProvider,{endpoint:o,children:jsx(WalletProvider,{wallets:t,autoConnect:n,children:r})})}var Q="Wallet not connected.";function Ge(e,o,t){let{publicKey:n,signMessage:r}=useWallet(),i=n?.toBase58()??null;return {connected:!!i,account:i,loginWithWallet:(s,a)=>{let l=a??i;return l?r?G$1({client:e,networkID:s,walletAddress:l,signMessage:r}):Promise.resolve(c("sign","The connected wallet does not support message signing.")):Promise.resolve(c("challenge",Q))},depositToken:s=>E({client:e,adapter:t,titleID:o,...s}),withdrawToken:s=>{let a=s.walletAddress??i;return a?F({client:e,adapter:t,...s,walletAddress:a}):Promise.resolve(b("request",Q))}}}export{k as IDosGamesWalletProvider,xe as SolanaWalletBridgeProvider,he as WalletLogin,j as WalletLoginButton,ae as createEvmWalletConfig,ge as useEvmBridge,C as useEvmBridgeClients,Ge as useSolanaBridge};
1
+ import {o,n,i,h,p}from'../chunk-DMMHCUIU.js';import {a,b as b$1}from'../chunk-ZL42KPPC.js';import {b,c}from'../chunk-K62NMX3A.js';import {k}from'../chunk-HQNS6ZWL.js';export{e as arbitrum,d as base,b as bsc,j as chainById,i as idosChains,a as mainnet,f as optimism,c as polygon,h as polygonAmoy,g as sepolia}from'../chunk-HQNS6ZWL.js';import {http,createConfig,WagmiProvider,useAccount,usePublicClient,useWalletClient,useConfig,useConnect}from'wagmi';import {injected,coinbaseWallet}from'wagmi/connectors';import {WagmiAdapter}from'@reown/appkit-adapter-wagmi';import {createAppKit}from'@reown/appkit/react';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {useState,useRef,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getAccount,watchAccount,getWalletClient,getPublicClient}from'wagmi/actions';function me(e){let{chains:o,walletConnectProjectId:t,appName:n,appUrl:r,appIcon:i,transports:p,connectors:s}=e,a$1={};for(let l of o)a$1[l.id]=p?.[l.id]??http();let f=r??(typeof window<"u"?window.location.origin:""),v={name:n??"iDosGames",description:n??"iDosGames game",url:f,icons:i?[i]:[]};if(t&&!s){let l=o.map(k),g=new WagmiAdapter({networks:l,projectId:t,transports:a$1});return a(createAppKit({adapters:[g],networks:l,projectId:t,metadata:v,features:{analytics:false,email:false,socials:false}})),g.wagmiConfig}let h=s??[injected(),coinbaseWallet({appName:n??"iDosGames"})];return createConfig({chains:o,connectors:h,transports:a$1})}function T(e){let{wagmiConfig:o,queryClient:t,children:n}=e,[r]=useState(()=>t??new QueryClient);return jsx(WagmiProvider,{config:o,children:jsx(QueryClientProvider,{client:r,children:n})})}function C(){let{address:e}=useAccount(),o=usePublicClient(),{data:t}=useWalletClient();return !e||!o||!t?null:{account:e,publicClient:o,walletClient:t}}var u="Wallet not connected.";function ve(e,o$1){let t=C();return {connected:!!t,account:t?.account??null,loginWithWallet:(n,r)=>t?p({client:e,clients:t,networkID:n,walletAddress:r}):Promise.resolve(c("challenge",u)),depositToken:n=>t?h({client:e,clients:t,titleID:o$1,...n}):Promise.resolve(b("approve",u)),depositNft:n=>t?i({client:e,clients:t,titleID:o$1,...n}):Promise.resolve(b("deposit-onchain",u)),withdrawToken:n$1=>t?n({client:e,clients:t,...n$1}):Promise.resolve(b("withdraw-onchain",u)),withdrawNft:n=>t?o({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",u))}}function Ne(e){let{wagmiConfig:o,...t}=e;return jsx(T,{wagmiConfig:o,children:jsx(z,{...t})})}function De(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function Ae(e){let o="Wallet sign-in failed. Please try again.";return e instanceof Error?e.name==="ProviderNotFoundError"||/provider not found/i.test(e.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":e.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":o:o}async function Re(e){let o=await getWalletClient(e).catch(()=>null);if(!o)return null;let t=getPublicClient(e);return t?{account:o.account.address,publicClient:t,walletClient:o}:null}function Be(e,o=18e4){return getAccount(e).isConnected?Promise.resolve(true):new Promise(t=>{let n=false,r=s=>{n||(n=true,i(),clearTimeout(p),t(s));},i=watchAccount(e,{onChange:s=>{s.isConnected&&r(true);}}),p=setTimeout(()=>r(false),o);})}function Ie(e){let o=r=>e.find(i=>i.id===r||i.type===r),t=o("injected"),n=typeof window<"u"&&window.ethereum!=null;return t&&n?t:o("walletConnect")??t??e[0]}var Se=9e4;async function xe(e){try{let n=(await getAccount(e).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,r=n?.native||n?.universal;return !r||typeof window>"u"?!1:(window.location.href=r,!0)}catch{return false}}function Ge(e,o){return new Promise((t,n)=>{let r=setTimeout(()=>n(new Error("The wallet request timed out.")),o);e.then(i=>{clearTimeout(r),t(i);},i=>{clearTimeout(r),n(i instanceof Error?i:new Error(String(i)));});})}function z(e){let{client:o,networkID:t,onAuthenticated:n,disabled:r,label:i,style:p$1,autoStart:s}=e,a=useConfig(),{isConnected:f}=useAccount(),{connectAsync:v,connectors:h}=useConnect(),l=C(),[g,k]=useState(false),[N,c]=useState(null),[D,A]=useState(false),R=useRef(0),B=useRef(false),I=async()=>{let J=++R.current,P=()=>R.current===J;k(true),c(null);try{if(!f){let S=b$1();if(S){if(await S.open(),!await Be(a)){c("No wallet was connected.");return}}else {let x=Ie(h);if(!x){c("No wallet connector is configured.");return}try{await v({connector:x});}catch(G){if(!De(G))throw G}}}let m=l??await Re(a);if(!m){c("Wallet client is not available.");return}A(!0);let W=await Ge(p({client:o,clients:m,networkID:t}),Se);if(!P())return;if(W.ok){n();return}c(W.stage==="sign"?"Signature declined.":W.error??"Wallet sign-in failed.");}catch(m){if(!P())return;console.error("[idosgames/wallet] wallet sign-in failed:",m),c(Ae(m));}finally{P()&&(k(false),A(false));}};useEffect(()=>{!s||B.current||(B.current=true,I());},[s]);let H=async()=>{await xe(a)||await b$1()?.open();};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{D?H():I();},disabled:r,style:{...Le,...r?{opacity:.6,cursor:"default"}:null,...p$1},children:D?"Waiting for signature \u2014 tap to open wallet":g?"Check your wallet\u2026":f?i??"Sign in with wallet":"Connect wallet"}),N&&jsx("span",{role:"alert",style:Oe,children:N})]})}var Le={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Oe={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};export{T as IDosGamesWalletProvider,Ne as WalletLogin,z as WalletLoginButton,me as createEvmWalletConfig,ve as useEvmBridge,C as useEvmBridgeClients};
@@ -0,0 +1,2 @@
1
+ 'use strict';var wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react$1=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),viem=require('viem'),core=require('@idosgames/core'),actions=require('wagmi/actions'),appkitAdapterSolana=require('@reown/appkit-adapter-solana');var pt=Object.defineProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pe=(t,e)=>{for(var n in e)pt(t,n,{get:e[n],enumerable:true});};function ie(t){return Object.values(exports.idosChains).find(e=>e.id===t)}function Se(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}exports.mainnet=void 0;exports.bsc=void 0;exports.polygon=void 0;exports.base=void 0;exports.arbitrum=void 0;exports.optimism=void 0;exports.sepolia=void 0;exports.polygonAmoy=void 0;exports.idosChains=void 0;exports.solanaMainnet=void 0;exports.solanaDevnet=void 0;var E=f(()=>{exports.mainnet={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},exports.bsc={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},exports.polygon={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},exports.base={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},exports.arbitrum={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},exports.optimism={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},exports.sepolia={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},exports.polygonAmoy={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},exports.idosChains={mainnet:exports.mainnet,bsc:exports.bsc,polygon:exports.polygon,base:exports.base,arbitrum:exports.arbitrum,optimism:exports.optimism,sepolia:exports.sepolia,polygonAmoy:exports.polygonAmoy};exports.solanaMainnet={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},exports.solanaDevnet={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};});function te(t){xe=t;}function D(){return xe}var xe,O=f(()=>{xe=null;});function Ee(t){let{chains:e,walletConnectProjectId:n,appName:o,appUrl:a,appIcon:r,transports:p,connectors:s}=t,i={};for(let u of e)i[u.id]=p?.[u.id]??wagmi.http();let c=a??(typeof window<"u"?window.location.origin:""),l={name:o??"iDosGames",description:o??"iDosGames game",url:c,icons:r?[r]:[]};if(n&&!s){let u=e.map(Se),g=new appkitAdapterWagmi.WagmiAdapter({networks:u,projectId:n,transports:i});return te(react$1.createAppKit({adapters:[g],networks:u,projectId:n,metadata:l,features:{analytics:false,email:false,socials:false}})),g.wagmiConfig}let m=s??[connectors.injected(),connectors.coinbaseWallet({appName:o??"iDosGames"})];return wagmi.createConfig({chains:e,connectors:m,transports:i})}var De=f(()=>{E();O();});function ne(t){let{wagmiConfig:e,queryClient:n,children:o}=t,[a]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:a,children:o})})}var le=f(()=>{});var oe,Ne,ce,Re,pe=f(()=>{oe=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],Ne=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],ce=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],Re=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];});function Be(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}var Le=f(()=>{});async function S(t,e){let{walletClient:n,publicClient:o,account:a}=t,r=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:a,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:r})).status==="reverted")throw new Error(`On-chain transaction reverted (${r}).`);return r}var de=f(()=>{});function w(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function d(t,e,n){return {ok:false,stage:t,error:e,...n}}function h(t,e){return {ok:false,stage:t,error:e}}var T=f(()=>{});function Me(t){let e=t.RewardPoolAddress;return e||null}async function Fe(t,e,n,o){return await t.publicClient.readContract({address:e,abi:ce,functionName:"allowance",args:[t.account,n]})>=o?null:S(t,{address:e,abi:ce,functionName:"approve",args:[n,o]})}async function ue(t){let{client:e,clients:n,network:o,tokenAddress:a,amount:r,titleID:p,category:s}=t,i=e.auth.context?.userID;if(!i)return d("approve","Not logged in.");let c=Me(o);if(!c)return d("approve","Network has no RewardPoolAddress.");if(r<=0n)return d("approve","Amount must be positive.");try{await Fe(n,a,c,r);}catch(u){return d("approve",w(u))}let l;try{l=await S(n,{address:c,abi:oe,functionName:"depositERC20",args:[a,r,i,p,s??""]});}catch(u){return d("deposit-onchain",w(u))}let m=await e.blockchain.depositToken(o.NetworkID??"",l);return m.ok?{ok:true,onChainTxHash:l,data:m.data}:d("report",m.error,{onChainTxHash:l})}async function me(t){let{client:e,clients:n,network:o,nftContractAddress:a,tokenId:r,amount:p,titleID:s,category:i}=t,c=e.auth.context?.userID;if(!c)return d("deposit-onchain","Not logged in.");let l=Me(o);if(!l)return d("deposit-onchain","Network has no RewardPoolAddress.");if(p<=0n)return d("deposit-onchain","Amount must be positive.");let m=Be(c,s,i),u;try{u=await S(n,{address:a,abi:Re,functionName:"safeTransferFrom",args:[n.account,l,r,p,m]});}catch(y){return d("deposit-onchain",w(y))}let g=await e.blockchain.depositNFT(o.NetworkID??"",u);return g.ok?{ok:true,onChainTxHash:u,data:g.data}:d("report",g.error,{onChainTxHash:u})}var Ke=f(()=>{pe();Le();de();T();});async function He(t,e){return S(t,{address:e.ContractAddress,abi:oe,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function Ge(t,e){return S(t,{address:e.ContractAddress,abi:Ne,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function ge(t){let{client:e,clients:n,currencyID:o,networkID:a,walletAddress:r,amount:p,category:s}=t,i=await e.blockchain.requestTokenWithdrawal(o,a,r,p,s);if(!i.ok)return d("request",i.error);let c=i.data.EvmSignature,l=i.data.TitleTransactionID??void 0;if(!c)return d("request","Withdrawal response carried no EVM signature.",{titleTransactionID:l});let m;try{m=await He(n,c);}catch(g){return d("withdraw-onchain",w(g),{titleTransactionID:l})}let u=await Oe(e,l,m);return u.ok?{ok:true,onChainTxHash:m,data:i.data}:u}async function fe(t){let{client:e,clients:n,itemID:o,networkID:a,walletAddress:r,amount:p,category:s}=t,i=await e.blockchain.requestNFTWithdrawal(o,a,r,p,s);if(!i.ok)return d("request",i.error);let c=i.data.EvmSignature,l=i.data.TitleTransactionID??void 0;if(!c)return d("request","Withdrawal response carried no EVM signature.",{titleTransactionID:l});let m;try{m=await Ge(n,c);}catch(g){return d("withdraw-onchain",w(g),{titleTransactionID:l})}let u=await Oe(e,l,m);return u.ok?{ok:true,onChainTxHash:m,data:i.data}:u}async function Oe(t,e,n){if(!e)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:d("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}var Ue=f(()=>{pe();de();T();});async function U(t){let{client:e,clients:n,networkID:o}=t,a=t.walletAddress??n.account,r=await e.auth.requestWalletChallenge(a,o);if(!r.ok)return h("challenge",r.error);let p;try{p=await n.walletClient.signMessage({account:n.account,message:r.data.Message});}catch(i){return h("sign",w(i))}let s=await e.auth.loginWithWallet(a,o,p);return s.ok?{ok:true,data:s.data}:h("login",s.error)}var qe=f(()=>{T();});var ye=f(()=>{Ke();Ue();qe();});function z(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}function ze(t,e){let n=z();return {connected:!!n,account:n?.account??null,loginWithWallet:(o,a)=>n?U({client:t,clients:n,networkID:o,walletAddress:a}):Promise.resolve(h("challenge",q)),depositToken:o=>n?ue({client:t,clients:n,titleID:e,...o}):Promise.resolve(d("approve",q)),depositNft:o=>n?me({client:t,clients:n,titleID:e,...o}):Promise.resolve(d("deposit-onchain",q)),withdrawToken:o=>n?ge({client:t,clients:n,...o}):Promise.resolve(d("withdraw-onchain",q)),withdrawNft:o=>n?fe({client:t,clients:n,...o}):Promise.resolve(d("withdraw-onchain",q))}}var q,we=f(()=>{ye();T();q="Wallet not connected.";});function Ye(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(ne,{wagmiConfig:e,children:jsxRuntime.jsx(Ce,{...n})})}function Bt(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Lt(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function Mt(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function Ft(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let o=false,a=s=>{o||(o=true,r(),clearTimeout(p),n(s));},r=actions.watchAccount(t,{onChange:s=>{s.isConnected&&a(true);}}),p=setTimeout(()=>a(false),e);})}function Kt(t){let e=a=>t.find(r=>r.id===a||r.type===a),n=e("injected"),o=typeof window<"u"&&window.ethereum!=null;return n&&o?n:e("walletConnect")??n??t[0]}async function Gt(t){try{let o=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,a=o?.native||o?.universal;return !a||typeof window>"u"?!1:(window.location.href=a,!0)}catch{return false}}function Ot(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function Ce(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:p,autoStart:s}=t,i=wagmi.useConfig(),{isConnected:c}=wagmi.useAccount(),{connectAsync:l,connectors:m}=wagmi.useConnect(),u=z(),[g,y]=react.useState(false),[C,b]=react.useState(null),[R,B]=react.useState(false),P=react.useRef(0),L=react.useRef(false),v=async()=>{let F=++P.current,K=()=>P.current===F;y(true),b(null);try{if(!c){let x=D();if(x){if(await x.open(),!await Ft(i)){b("No wallet was connected.");return}}else {let H=Kt(m);if(!H){b("No wallet connector is configured.");return}try{await l({connector:H});}catch(k){if(!Bt(k))throw k}}}let W=u??await Mt(i);if(!W){b("Wallet client is not available.");return}B(!0);let A=await Ot(U({client:e,clients:W,networkID:n}),Ht);if(!K())return;if(A.ok){o();return}b(A.stage==="sign"?"Signature declined.":A.error??"Wallet sign-in failed.");}catch(W){if(!K())return;console.error("[idosgames/wallet] wallet sign-in failed:",W),b(Lt(W));}finally{K()&&(y(false),B(false));}};react.useEffect(()=>{!s||L.current||(L.current=true,v());},[s]);let M=async()=>{await Gt(i)||await D()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{R?M():v();},disabled:a,style:{...Ut,...a?{opacity:.6,cursor:"default"}:null,...p},children:R?"Waiting for signature \u2014 tap to open wallet":g?"Check your wallet\u2026":c?r??"Sign in with wallet":"Connect wallet"}),C&&jsxRuntime.jsx("span",{role:"alert",style:qt,children:C})]})}var Ht,Ut,qt,Qe=f(()=>{O();ye();le();we();Ht=9e4;Ut={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},qt={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});var Ve={};Pe(Ve,{IDosGamesWalletProvider:()=>ne,WalletLogin:()=>Ye,WalletLoginButton:()=>Ce,arbitrum:()=>exports.arbitrum,base:()=>exports.base,bsc:()=>exports.bsc,chainById:()=>ie,createEvmWalletConfig:()=>Ee,idosChains:()=>exports.idosChains,mainnet:()=>exports.mainnet,optimism:()=>exports.optimism,polygon:()=>exports.polygon,polygonAmoy:()=>exports.polygonAmoy,sepolia:()=>exports.sepolia,useEvmBridge:()=>ze,useEvmBridgeClients:()=>z});var Ze=f(()=>{De();E();le();we();Qe();});function $e(t){let{walletConnectProjectId:e,appName:n,appUrl:o,appIcon:a,wallets:r}=t,p=t.networks??[exports.solanaMainnet],s=o??(typeof window<"u"?window.location.origin:""),i={name:n??"iDosGames",description:n??"iDosGames game",url:s,icons:a?[a]:[]},c=new appkitAdapterSolana.SolanaAdapter(r?{wallets:r}:{});return te(react$1.createAppKit({adapters:[c],networks:p,projectId:e,metadata:i,features:{analytics:false,email:false,socials:false}})),c}var Je=f(()=>{E();O();});async function be(t){let{client:e,adapter:n,network:o,mint:a,amountRaw:r,titleID:p,category:s}=t,i=e.auth.context?.userID;if(!i)return d("deposit-onchain","Not logged in.");if(r<=0n)return d("deposit-onchain","Amount must be positive.");let c;try{c=await n.depositSpl({mint:a,amountRaw:r,userID:i,titleID:p,category:core.normalizeBlockchainCategory(s)});}catch(m){return d("deposit-onchain",w(m))}let l=await e.blockchain.depositToken(o.NetworkID??"",c);return l.ok?{ok:true,onChainTxHash:c,data:l.data}:d("report",l.error,{onChainTxHash:c})}async function ke(t){let{client:e,adapter:n,currencyID:o,networkID:a,walletAddress:r,amount:p,category:s}=t,i=await e.blockchain.requestTokenWithdrawal(o,a,r,p,s);if(!i.ok)return d("request",i.error);let c=i.data.SolanaSignature,l=i.data.TitleTransactionID??void 0;if(!c)return d("request","Withdrawal response carried no Solana signature.",{titleTransactionID:l});let m;try{m=await n.submitWithdrawal(c);}catch(g){return d("withdraw-onchain",w(g),{titleTransactionID:l})}if(!l)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:m});let u=await e.blockchain.confirmWithdrawal(l,m);return u.ok?{ok:true,onChainTxHash:m,data:i.data}:d("confirm",u.error,{onChainTxHash:m,titleTransactionID:l})}var Xe=f(()=>{T();});async function j(t){let{client:e,networkID:n,walletAddress:o,signMessage:a}=t,r=await e.auth.requestWalletChallenge(o,n);if(!r.ok)return h("challenge",r.error);let p;try{let i=await a(new TextEncoder().encode(r.data.Message));p=Vt(i);}catch(i){return h("sign",w(i))}let s=await e.auth.loginWithWallet(o,n,p);return s.ok?{ok:true,data:s.data}:h("login",s.error)}function Vt(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var et=f(()=>{T();});var ve=f(()=>{Xe();et();});function nt(t,e,n){let{address:o}=react$1.useAppKitAccount(),{walletProvider:a}=react$1.useAppKitProvider("solana"),r=o??null,p=a?.signMessage?.bind(a);return {connected:!!r,account:r,loginWithWallet:(s,i)=>{let c=i??r;return c?p?j({client:t,networkID:s,walletAddress:c,signMessage:p}):Promise.resolve(h("sign","The connected wallet does not support message signing.")):Promise.resolve(h("challenge",tt))},depositToken:s=>be({client:t,adapter:n,titleID:e,...s}),withdrawToken:s=>{let i=s.walletAddress??r;return i?ke({client:t,adapter:n,...s,walletAddress:i}):Promise.resolve(d("request",tt))}}}var tt,ot=f(()=>{ve();T();tt="Wallet not connected.";});function nn(t){try{let n=t?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function on(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function rn(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}function at(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:p,autoStart:s}=t,{address:i,isConnected:c}=react$1.useAppKitAccount(),{walletProvider:l}=react$1.useAppKitProvider("solana"),[m,u]=react.useState(false),[g,y]=react.useState(null),[C,b]=react.useState(false),[R,B]=react.useState(false),P=react.useRef(null),L=react.useRef(0),v=react.useCallback(()=>{P.current&&clearTimeout(P.current),P.current=null;},[]);react.useEffect(()=>v,[v]);let M=react.useRef(false),F=react.useCallback(async()=>{let A=++L.current,x=()=>L.current===A,H=l?.signMessage?.bind(l);if(!i||!H){y("The connected wallet cannot sign messages."),u(false);return}u(true),y(null);try{B(!0);let k=await on(j({client:e,networkID:n,walletAddress:i,signMessage:H}),tn);if(!x())return;if(k.ok){o();return}y(k.stage==="sign"?"Signature declined.":k.error??"Wallet sign-in failed.");}catch(k){if(!x())return;console.error("[idosgames/wallet] solana sign-in failed:",k),y(rn(k));}finally{x()&&(u(false),B(false));}},[i,l,e,n,o]),K=react.useCallback(()=>{nn(l)||D()?.open();},[l]);react.useEffect(()=>{!C||!c||!i||!l||(b(false),v(),F());},[C,c,i,l,F,v]);let W=()=>{if(R){K();return}if(y(null),M.current=true,c&&i&&l){F();return}let A=D();if(!A){y("Wallet sign-in is not configured for this title.");return}u(true),b(true),v(),P.current=setTimeout(()=>{b(false),u(false),y("No wallet was connected.");},en),A.open();};return react.useEffect(()=>{!s||M.current||(M.current=true,W());},[s]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:W,disabled:a,style:{...an,...a?{opacity:.6,cursor:"default"}:null,...p},children:R?"Waiting for signature \u2014 tap to open wallet":m?"Check your wallet\u2026":c?r??"Sign in with wallet":"Connect wallet"}),g&&jsxRuntime.jsx("span",{role:"alert",style:sn,children:g})]})}var en,tn,an,sn,it=f(()=>{ve();O();en=18e4,tn=9e4;an={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},sn={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});var st={};Pe(st,{SolanaWalletLogin:()=>at,createSolanaWalletConfig:()=>$e,solanaDevnet:()=>exports.solanaDevnet,solanaMainnet:()=>exports.solanaMainnet,useSolanaBridge:()=>nt});var lt=f(()=>{Je();ot();it();E();});var pn={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},dn={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function ct(t){let{loading:e,disabled:n,label:o,style:a,error:r,onClick:p}=t;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:n||e,style:{...pn,...n||e?{opacity:.6,cursor:"default"}:null,...a},children:e?"Loading wallet\u2026":o??"Sign in with wallet"}),r&&jsxRuntime.jsx("span",{role:"alert",style:dn,children:r})]})}function un(t){let{chains:e,walletConnectProjectId:n,appName:o,disabled:a,label:r,style:p,...s}=t,[i,c]=react.useState(null),[l,m]=react.useState(false),[u,g]=react.useState(null),y=()=>{m(true),g(null),(async()=>{try{let C=await Promise.resolve().then(()=>(Ze(),Ve)),b=C.createEvmWalletConfig({chains:e,walletConnectProjectId:n,appName:o});c({mod:C,config:b});}catch(C){console.error("[idosgames/wallet] failed to load the wallet module:",C),g("Could not load the wallet. Please try again.");}finally{m(false);}})();};if(i){let{WalletLogin:C}=i.mod;return jsxRuntime.jsx(C,{...s,wagmiConfig:i.config,disabled:a,label:r,style:p,autoStart:true})}return jsxRuntime.jsx(ct,{loading:l,disabled:a,label:r,style:p,error:u,onClick:y})}function mn(t){let{walletConnectProjectId:e,appName:n,disabled:o,label:a,style:r,...p}=t,[s,i]=react.useState(null),[c,l]=react.useState(false),[m,u]=react.useState(null),g=()=>{l(true),u(null),(async()=>{try{let y=await Promise.resolve().then(()=>(lt(),st));e&&y.createSolanaWalletConfig({walletConnectProjectId:e,appName:n}),i(y);}catch(y){console.error("[idosgames/wallet] failed to load the wallet module:",y),u("Could not load the wallet. Please try again.");}finally{l(false);}})();};if(s){let{SolanaWalletLogin:y}=s;return jsxRuntime.jsx(y,{...p,disabled:o,label:a,style:r,autoStart:true})}return jsxRuntime.jsx(ct,{loading:c,disabled:o,label:a,style:r,error:m,onClick:g})}E();
2
+ exports.LazySolanaWalletLogin=mn;exports.LazyWalletLogin=un;exports.chainById=ie;
@@ -0,0 +1,42 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { Chain } from 'viem';
3
+ import { IDosGamesClient } from '@idosgames/core';
4
+ export { a as AppKitSolanaNetwork, b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia, g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.cjs';
5
+
6
+ interface LazyLoginCommonProps {
7
+ /** The (not yet authenticated) shared client. */
8
+ client: IDosGamesClient;
9
+ /** NetworkID the challenge is issued for — one of the title's configured networks. */
10
+ networkID: string;
11
+ /** Called once the wallet signature has been exchanged for a session. */
12
+ onAuthenticated: () => void;
13
+ /**
14
+ * WalletConnect Cloud / Reown project id — what makes phone wallets reachable. Comes from the
15
+ * title's blockchain config; without it only browser-extension wallets are offered.
16
+ */
17
+ walletConnectProjectId?: string;
18
+ /** App name shown in the wallet's connect prompt. */
19
+ appName?: string;
20
+ disabled?: boolean;
21
+ label?: string;
22
+ style?: CSSProperties;
23
+ }
24
+ interface LazyWalletLoginProps extends LazyLoginCommonProps {
25
+ /** Chains the title supports, e.g. `[bsc]` — import them from this same subpath. */
26
+ chains: readonly [Chain, ...Chain[]];
27
+ }
28
+ type LazySolanaWalletLoginProps = LazyLoginCommonProps;
29
+ /**
30
+ * "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
31
+ *
32
+ * The first tap fetches the wallet module, builds the wagmi/AppKit config and mounts the real
33
+ * button with `autoStart`, so the sign-in begins immediately — the player still taps once.
34
+ */
35
+ declare function LazyWalletLogin(props: LazyWalletLoginProps): ReactNode;
36
+ /**
37
+ * "Sign in with wallet" for **Solana** titles that loads its machinery on demand. Same contract as
38
+ * {@link LazyWalletLogin}; Solana needs no chain list, only the WalletConnect project id.
39
+ */
40
+ declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): ReactNode;
41
+
42
+ export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps };
@@ -0,0 +1,42 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { Chain } from 'viem';
3
+ import { IDosGamesClient } from '@idosgames/core';
4
+ export { a as AppKitSolanaNetwork, b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia, g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.js';
5
+
6
+ interface LazyLoginCommonProps {
7
+ /** The (not yet authenticated) shared client. */
8
+ client: IDosGamesClient;
9
+ /** NetworkID the challenge is issued for — one of the title's configured networks. */
10
+ networkID: string;
11
+ /** Called once the wallet signature has been exchanged for a session. */
12
+ onAuthenticated: () => void;
13
+ /**
14
+ * WalletConnect Cloud / Reown project id — what makes phone wallets reachable. Comes from the
15
+ * title's blockchain config; without it only browser-extension wallets are offered.
16
+ */
17
+ walletConnectProjectId?: string;
18
+ /** App name shown in the wallet's connect prompt. */
19
+ appName?: string;
20
+ disabled?: boolean;
21
+ label?: string;
22
+ style?: CSSProperties;
23
+ }
24
+ interface LazyWalletLoginProps extends LazyLoginCommonProps {
25
+ /** Chains the title supports, e.g. `[bsc]` — import them from this same subpath. */
26
+ chains: readonly [Chain, ...Chain[]];
27
+ }
28
+ type LazySolanaWalletLoginProps = LazyLoginCommonProps;
29
+ /**
30
+ * "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
31
+ *
32
+ * The first tap fetches the wallet module, builds the wagmi/AppKit config and mounts the real
33
+ * button with `autoStart`, so the sign-in begins immediately — the player still taps once.
34
+ */
35
+ declare function LazyWalletLogin(props: LazyWalletLoginProps): ReactNode;
36
+ /**
37
+ * "Sign in with wallet" for **Solana** titles that loads its machinery on demand. Same contract as
38
+ * {@link LazyWalletLogin}; Solana needs no chain list, only the WalletConnect project id.
39
+ */
40
+ declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): ReactNode;
41
+
42
+ export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps };
@@ -0,0 +1 @@
1
+ export{e as arbitrum,d as base,b as bsc,j as chainById,i as idosChains,a as mainnet,f as optimism,c as polygon,h as polygonAmoy,g as sepolia,m as solanaDevnet,l as solanaMainnet}from'../chunk-HQNS6ZWL.js';import {useState}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var E={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},R={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function L(c){let{loading:o,disabled:a,label:n,style:t,error:e,onClick:r}=c;return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:r,disabled:a||o,style:{...E,...a||o?{opacity:.6,cursor:"default"}:null,...t},children:o?"Loading wallet\u2026":n??"Sign in with wallet"}),e&&jsx("span",{role:"alert",style:R,children:e})]})}function A(c){let{chains:o,walletConnectProjectId:a,appName:n,disabled:t,label:e,style:r,...y}=c,[p,b]=useState(null),[g,u]=useState(false),[m,f]=useState(null),l=()=>{u(true),f(null),(async()=>{try{let i=await import('./index.js'),C=i.createEvmWalletConfig({chains:o,walletConnectProjectId:a,appName:n});b({mod:i,config:C});}catch(i){console.error("[idosgames/wallet] failed to load the wallet module:",i),f("Could not load the wallet. Please try again.");}finally{u(false);}})();};if(p){let{WalletLogin:i}=p.mod;return jsx(i,{...y,wagmiConfig:p.config,disabled:t,label:e,style:r,autoStart:true})}return jsx(L,{loading:g,disabled:t,label:e,style:r,error:m,onClick:l})}function D(c){let{walletConnectProjectId:o,appName:a,disabled:n,label:t,style:e,...r}=c,[y,p]=useState(null),[b,g]=useState(false),[u,m]=useState(null),f=()=>{g(true),m(null),(async()=>{try{let l=await import('./solanaIndex.js');o&&l.createSolanaWalletConfig({walletConnectProjectId:o,appName:a}),p(l);}catch(l){console.error("[idosgames/wallet] failed to load the wallet module:",l),m("Could not load the wallet. Please try again.");}finally{g(false);}})();};if(y){let{SolanaWalletLogin:l}=y;return jsx(l,{...r,disabled:n,label:t,style:e,autoStart:true})}return jsx(L,{loading:b,disabled:n,label:t,style:e,error:u,onClick:f})}export{D as LazySolanaWalletLogin,A as LazyWalletLogin};
@@ -0,0 +1,2 @@
1
+ 'use strict';var appkitAdapterSolana=require('@reown/appkit-adapter-solana'),react=require('@reown/appkit/react'),core=require('@idosgames/core'),viem=require('viem'),react$1=require('react'),jsxRuntime=require('react/jsx-runtime');var v={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},z={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};var F=null;function H(e){F=e;}function E(){return F}function $(e){let{walletConnectProjectId:t,appName:n,appUrl:o,appIcon:p,wallets:r}=e,c=e.networks??[v],i=o??(typeof window<"u"?window.location.origin:""),a={name:n??"iDosGames",description:n??"iDosGames game",url:i,icons:p?[p]:[]},s=new appkitAdapterSolana.SolanaAdapter(r?{wallets:r}:{});return H(react.createAppKit({adapters:[s],networks:c,projectId:t,metadata:a,features:{analytics:false,email:false,socials:false}})),s}function y(e){return e instanceof viem.BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function d(e,t,n){return {ok:false,stage:e,error:t,...n}}function f(e,t){return {ok:false,stage:e,error:t}}async function D(e){let{client:t,adapter:n,network:o,mint:p,amountRaw:r,titleID:c,category:i}=e,a=t.auth.context?.userID;if(!a)return d("deposit-onchain","Not logged in.");if(r<=0n)return d("deposit-onchain","Amount must be positive.");let s;try{s=await n.depositSpl({mint:p,amountRaw:r,userID:a,titleID:c,category:core.normalizeBlockchainCategory(i)});}catch(u){return d("deposit-onchain",y(u))}let l=await t.blockchain.depositToken(o.NetworkID??"",s);return l.ok?{ok:true,onChainTxHash:s,data:l.data}:d("report",l.error,{onChainTxHash:s})}async function I(e){let{client:t,adapter:n,currencyID:o,networkID:p,walletAddress:r,amount:c,category:i}=e,a=await t.blockchain.requestTokenWithdrawal(o,p,r,c,i);if(!a.ok)return d("request",a.error);let s=a.data.SolanaSignature,l=a.data.TitleTransactionID??void 0;if(!s)return d("request","Withdrawal response carried no Solana signature.",{titleTransactionID:l});let u;try{u=await n.submitWithdrawal(s);}catch(k){return d("withdraw-onchain",y(k),{titleTransactionID:l})}if(!l)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:u});let m=await t.blockchain.confirmWithdrawal(l,u);return m.ok?{ok:true,onChainTxHash:u,data:a.data}:d("confirm",m.error,{onChainTxHash:u,titleTransactionID:l})}async function S(e){let{client:t,networkID:n,walletAddress:o,signMessage:p}=e,r=await t.auth.requestWalletChallenge(o,n);if(!r.ok)return f("challenge",r.error);let c;try{let a=await p(new TextEncoder().encode(r.data.Message));c=Q(a);}catch(a){return f("sign",y(a))}let i=await t.auth.loginWithWallet(o,n,c);return i.ok?{ok:true,data:i.data}:f("login",i.error)}function Q(e){let t="0x";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}var G="Wallet not connected.";function te(e,t,n){let{address:o}=react.useAppKitAccount(),{walletProvider:p}=react.useAppKitProvider("solana"),r=o??null,c=p?.signMessage?.bind(p);return {connected:!!r,account:r,loginWithWallet:(i,a)=>{let s=a??r;return s?c?S({client:e,networkID:i,walletAddress:s,signMessage:c}):Promise.resolve(f("sign","The connected wallet does not support message signing.")):Promise.resolve(f("challenge",G))},depositToken:i=>D({client:e,adapter:n,titleID:t,...i}),withdrawToken:i=>{let a=i.walletAddress??r;return a?I({client:e,adapter:n,...i,walletAddress:a}):Promise.resolve(d("request",G))}}}var re=18e4,oe=9e4;function ie(e){try{let n=e?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function se(e,t){return new Promise((n,o)=>{let p=setTimeout(()=>o(new Error("The wallet request timed out.")),t);e.then(r=>{clearTimeout(p),n(r);},r=>{clearTimeout(p),o(r instanceof Error?r:new Error(String(r)));});})}function le(e){let t="Wallet sign-in failed. Please try again.";return e instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":t:t}function pe(e){let{client:t,networkID:n,onAuthenticated:o,disabled:p,label:r,style:c,autoStart:i}=e,{address:a,isConnected:s}=react.useAppKitAccount(),{walletProvider:l}=react.useAppKitProvider("solana"),[u,m]=react$1.useState(false),[k,g]=react$1.useState(null),[K,A]=react$1.useState(false),[L,M]=react$1.useState(false),T=react$1.useRef(null),U=react$1.useRef(0),w=react$1.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=null;},[]);react$1.useEffect(()=>w,[w]);let W=react$1.useRef(false),C=react$1.useCallback(async()=>{let x=++U.current,P=()=>U.current===x,q=l?.signMessage?.bind(l);if(!a||!q){g("The connected wallet cannot sign messages."),m(false);return}m(true),g(null);try{M(!0);let h=await se(S({client:t,networkID:n,walletAddress:a,signMessage:q}),oe);if(!P())return;if(h.ok){o();return}g(h.stage==="sign"?"Signature declined.":h.error??"Wallet sign-in failed.");}catch(h){if(!P())return;console.error("[idosgames/wallet] solana sign-in failed:",h),g(le(h));}finally{P()&&(m(false),M(false));}},[a,l,t,n,o]),Y=react$1.useCallback(()=>{ie(l)||E()?.open();},[l]);react$1.useEffect(()=>{!K||!s||!a||!l||(A(false),w(),C());},[K,s,a,l,C,w]);let O=()=>{if(L){Y();return}if(g(null),W.current=true,s&&a&&l){C();return}let x=E();if(!x){g("Wallet sign-in is not configured for this title.");return}m(true),A(true),w(),T.current=setTimeout(()=>{A(false),m(false),g("No wallet was connected.");},re),x.open();};return react$1.useEffect(()=>{!i||W.current||(W.current=true,O());},[i]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:O,disabled:p,style:{...ce,...p?{opacity:.6,cursor:"default"}:null,...c},children:L?"Waiting for signature \u2014 tap to open wallet":u?"Check your wallet\u2026":s?r??"Sign in with wallet":"Connect wallet"}),k&&jsxRuntime.jsx("span",{role:"alert",style:de,children:k})]})}var ce={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},de={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};
2
+ exports.SolanaWalletLogin=pe;exports.createSolanaWalletConfig=$;exports.solanaDevnet=z;exports.solanaMainnet=v;exports.useSolanaBridge=te;
@@ -0,0 +1,99 @@
1
+ import { SolanaAdapter } from '@reown/appkit-adapter-solana';
2
+ import { BaseWalletAdapter } from '@solana/wallet-adapter-base';
3
+ import { a as AppKitSolanaNetwork } from '../chains-B_P3u8_S.cjs';
4
+ export { g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.cjs';
5
+ import { ClientState, DepositTokenResponse, TokenWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
6
+ import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-8F45t4nD.cjs';
7
+ import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.cjs';
8
+ import { CSSProperties, ReactNode } from 'react';
9
+ import 'viem';
10
+
11
+ interface SolanaWalletConfigOptions {
12
+ /**
13
+ * WalletConnect Cloud / Reown project id. Required: it is what gives phones a working wallet at
14
+ * all. Solana's own Mobile Wallet Adapter is Android-only — on iOS a plain web page cannot reach
15
+ * a wallet app except through WalletConnect deep-links (or the wallet's in-app browser).
16
+ */
17
+ walletConnectProjectId: string;
18
+ /** Networks the title supports. Defaults to Solana mainnet. */
19
+ networks?: [AppKitSolanaNetwork, ...AppKitSolanaNetwork[]];
20
+ /** App name/metadata shown in the wallet's connect prompt. */
21
+ appName?: string;
22
+ appUrl?: string;
23
+ appIcon?: string;
24
+ /**
25
+ * Extra standard Solana wallet adapters (Phantom, Solflare, Mobile Wallet Adapter…).
26
+ *
27
+ * These do NOT replace the WalletConnect path — AppKit runs both: adapters cover browser
28
+ * extensions, wallet in-app browsers and Android's MWA, while WalletConnect covers iOS and any
29
+ * wallet the player has not installed as an extension. Wallet Standard already auto-detects most
30
+ * installed wallets, so this is only needed for ones that do not announce themselves.
31
+ */
32
+ wallets?: BaseWalletAdapter[];
33
+ }
34
+ /**
35
+ * Builds the Solana wallet stack for a title, on **Reown AppKit** — the same modal, session and
36
+ * deep-link machinery the EVM side uses, so both chains behave identically on a phone.
37
+ *
38
+ * A title is EVM or Solana, so exactly one of {@link createEvmWalletConfig} /
39
+ * `createSolanaWalletConfig` runs per game; both register the shared AppKit instance the sign-in
40
+ * button opens.
41
+ */
42
+ declare function createSolanaWalletConfig(options: SolanaWalletConfigOptions): SolanaAdapter;
43
+
44
+ type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
45
+ /** `walletAddress` defaults to the connected wallet if omitted. */
46
+ type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
47
+ walletAddress?: string;
48
+ };
49
+ interface SolanaBridge {
50
+ connected: boolean;
51
+ account: string | null;
52
+ /**
53
+ * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
54
+ * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
55
+ * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
56
+ */
57
+ loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
58
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
59
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
60
+ }
61
+ /**
62
+ * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
63
+ * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
64
+ * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
65
+ * just wires the connected address and threads the request → submit → confirm lifecycle.
66
+ */
67
+ declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
68
+
69
+ interface SolanaWalletLoginProps {
70
+ /** The (not yet authenticated) shared client. */
71
+ client: IDosGamesClient;
72
+ /** NetworkID the challenge is issued for — one of the title's configured networks. */
73
+ networkID: string;
74
+ /** Called once the wallet signature has been exchanged for a session. */
75
+ onAuthenticated: () => void;
76
+ disabled?: boolean;
77
+ label?: string;
78
+ style?: CSSProperties;
79
+ /**
80
+ * Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
81
+ * which already consumed the player's click to load this module — a second tap would be a bug.
82
+ */
83
+ autoStart?: boolean;
84
+ }
85
+ /**
86
+ * Ready-made "sign in with wallet" button for **Solana** titles: connect → sign the challenge →
87
+ * session. The EVM twin is {@link WalletLogin}; a title is one or the other.
88
+ *
89
+ * Unlike the EVM button this needs no provider wrapper — AppKit is a global instance created by
90
+ * `createSolanaWalletConfig`, and the wallet is read through its hooks.
91
+ *
92
+ * Connecting and signing are one action for the player, but on a phone they are separated by an app
93
+ * switch: `appKit.open()` returns as soon as the modal is on screen, long before a wallet is picked
94
+ * and the deep-link round trip completes. So the click only *arms* the flow, and an effect fires the
95
+ * signature once the account actually appears — no polling, no second tap.
96
+ */
97
+ declare function SolanaWalletLogin(props: SolanaWalletLoginProps): ReactNode;
98
+
99
+ export { AppKitSolanaNetwork, type SolanaBridge, type SolanaWalletConfigOptions, SolanaWalletLogin, type SolanaWalletLoginProps, createSolanaWalletConfig, useSolanaBridge };