@idosgames/wallet 0.1.5 → 0.1.7

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 +1,2 @@
1
- 'use strict';var wagmi=require('wagmi'),connectors=require('wagmi/connectors'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),viem=require('viem'),core=require('@idosgames/core'),actions=require('wagmi/actions'),walletAdapterReact=require('@solana/wallet-adapter-react');function re(t){let{chains:e,walletConnectProjectId:n,appName:r,appUrl:i,appIcon:o,transports:l,connectors:c}=t,a=r||i?{name:r??"iDosGames",description:r??"iDosGames game",url:i??"",icons:o?[o]:[]}:void 0,m=c??[connectors.injected(),connectors.coinbaseWallet({appName:r??"iDosGames"}),...n?[connectors.walletConnect({projectId:n,metadata:a,showQrModal:true})]:[]],d={};for(let p of e)d[p.id]=l?.[p.id]??wagmi.http();return wagmi.createConfig({chains:e,connectors:m,transports:d})}function P(t){let{wagmiConfig:e,queryClient:n,children:r}=t,[i]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:i,children:r})})}var D=[{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:[]}],G=[{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:[]}],x=[{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"}]}],O=[{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 q(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}async function w(t,e){let{walletClient:n,publicClient:r,account:i}=t,o=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:i,chain:n.chain,value:e.value});if((await r.waitForTransactionReceipt({hash:o})).status==="reverted")throw new Error(`On-chain transaction reverted (${o}).`);return o}function g(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function s(t,e,n){return {ok:false,stage:t,error:e,...n}}function f(t,e){return {ok:false,stage:t,error:e}}function U(t){let e=t.RewardPoolAddress;return e||null}async function j(t,e,n,r){return await t.publicClient.readContract({address:e,abi:x,functionName:"allowance",args:[t.account,n]})>=r?null:w(t,{address:e,abi:x,functionName:"approve",args:[n,r]})}async function I(t){let{client:e,clients:n,network:r,tokenAddress:i,amount:o,titleID:l,category:c}=t,a=e.auth.context?.userID;if(!a)return s("approve","Not logged in.");let m=U(r);if(!m)return s("approve","Network has no RewardPoolAddress.");if(o<=0n)return s("approve","Amount must be positive.");try{await j(n,i,m,o);}catch(u){return s("approve",g(u))}let d;try{d=await w(n,{address:m,abi:D,functionName:"depositERC20",args:[i,o,a,l,c??""]});}catch(u){return s("deposit-onchain",g(u))}let p=await e.blockchain.depositToken(r.NetworkID??"",d);return p.ok?{ok:true,onChainTxHash:d,data:p.data}:s("report",p.error,{onChainTxHash:d})}async function E(t){let{client:e,clients:n,network:r,nftContractAddress:i,tokenId:o,amount:l,titleID:c,category:a}=t,m=e.auth.context?.userID;if(!m)return s("deposit-onchain","Not logged in.");let d=U(r);if(!d)return s("deposit-onchain","Network has no RewardPoolAddress.");if(l<=0n)return s("deposit-onchain","Amount must be positive.");let p=q(m,c,a),u;try{u=await w(n,{address:i,abi:O,functionName:"safeTransferFrom",args:[n.account,d,o,l,p]});}catch(v){return s("deposit-onchain",g(v))}let y=await e.blockchain.depositNFT(r.NetworkID??"",u);return y.ok?{ok:true,onChainTxHash:u,data:y.data}:s("report",y.error,{onChainTxHash:u})}async function Q(t,e){return w(t,{address:e.ContractAddress,abi:D,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 z(t,e){return w(t,{address:e.ContractAddress,abi:G,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 N(t){let{client:e,clients:n,currencyID:r,networkID:i,walletAddress:o,amount:l,category:c}=t,a=await e.blockchain.requestTokenWithdrawal(r,i,o,l,c);if(!a.ok)return s("request",a.error);let m=a.data.EvmSignature,d=a.data.TitleTransactionID??void 0;if(!m)return s("request","Withdrawal response carried no EVM signature.",{titleTransactionID:d});let p;try{p=await Q(n,m);}catch(y){return s("withdraw-onchain",g(y),{titleTransactionID:d})}let u=await V(e,d,p);return u.ok?{ok:true,onChainTxHash:p,data:a.data}:u}async function B(t){let{client:e,clients:n,itemID:r,networkID:i,walletAddress:o,amount:l,category:c}=t,a=await e.blockchain.requestNFTWithdrawal(r,i,o,l,c);if(!a.ok)return s("request",a.error);let m=a.data.EvmSignature,d=a.data.TitleTransactionID??void 0;if(!m)return s("request","Withdrawal response carried no EVM signature.",{titleTransactionID:d});let p;try{p=await z(n,m);}catch(y){return s("withdraw-onchain",g(y),{titleTransactionID:d})}let u=await V(e,d,p);return u.ok?{ok:true,onChainTxHash:p,data:a.data}:u}async function V(t,e,n){if(!e)return s("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await t.blockchain.confirmWithdrawal(e,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:s("confirm",r.error,{onChainTxHash:n,titleTransactionID:e})}async function C(t){let{client:e,clients:n,networkID:r}=t,i=t.walletAddress??n.account,o=await e.auth.requestWalletChallenge(i,r);if(!o.ok)return f("challenge",o.error);let l;try{l=await n.walletClient.signMessage({account:n.account,message:o.data.Message});}catch(a){return f("sign",g(a))}let c=await e.auth.loginWithWallet(i,r,l);return c.ok?{ok:true,data:c.data}:f("login",c.error)}function b(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}var W="Wallet not connected.";function ge(t,e){let n=b();return {connected:!!n,account:n?.account??null,loginWithWallet:(r,i)=>n?C({client:t,clients:n,networkID:r,walletAddress:i}):Promise.resolve(f("challenge",W)),depositToken:r=>n?I({client:t,clients:n,titleID:e,...r}):Promise.resolve(s("approve",W)),depositNft:r=>n?E({client:t,clients:n,titleID:e,...r}):Promise.resolve(s("deposit-onchain",W)),withdrawToken:r=>n?N({client:t,clients:n,...r}):Promise.resolve(s("withdraw-onchain",W)),withdrawNft:r=>n?B({client:t,clients:n,...r}):Promise.resolve(s("withdraw-onchain",W))}}function Ce(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(P,{wagmiConfig:e,children:jsxRuntime.jsx(K,{...n})})}function We(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function ve(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 De(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 be(t){let e=i=>t.find(o=>o.id===i||o.type===i),n=e("injected"),r=typeof window<"u"&&window.ethereum!=null;return n&&r?n:e("walletConnect")??n??t[0]}function K(t){let{client:e,networkID:n,onAuthenticated:r,disabled:i,label:o,style:l}=t,c=wagmi.useConfig(),{isConnected:a}=wagmi.useAccount(),{connectAsync:m,connectors:d}=wagmi.useConnect(),p=b(),[u,y]=react.useState(false),[v,h]=react.useState(null),X=async()=>{y(true),h(null);try{if(!a){let M=be(d);if(!M){h("No wallet connector is configured.");return}try{await m({connector:M});}catch(L){if(!We(L))throw L}}let k=p??await De(c);if(!k){h("Wallet client is not available.");return}let A=await C({client:e,clients:k,networkID:n});if(A.ok){r();return}h(A.stage==="sign"?"Signature declined.":A.error??"Wallet sign-in failed.");}catch(k){console.error("[idosgames/wallet] wallet sign-in failed:",k),h(ve(k));}finally{y(false);}};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{X();},disabled:i||u,style:{...Te,...i||u?{opacity:.6,cursor:"default"}:null,...l},children:u?"Check your wallet\u2026":a?o??"Sign in with wallet":"Connect wallet"}),v&&jsxRuntime.jsx("span",{role:"alert",style:Ae,children:v})]})}var Te={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Ae={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function Ne(t){let{endpoint:e,wallets:n,autoConnect:r=true,children:i}=t;return jsxRuntime.jsx(walletAdapterReact.ConnectionProvider,{endpoint:e,children:jsxRuntime.jsx(walletAdapterReact.WalletProvider,{wallets:n,autoConnect:r,children:i})})}async function S(t){let{client:e,adapter:n,network:r,mint:i,amountRaw:o,titleID:l,category:c}=t,a=e.auth.context?.userID;if(!a)return s("deposit-onchain","Not logged in.");if(o<=0n)return s("deposit-onchain","Amount must be positive.");let m;try{m=await n.depositSpl({mint:i,amountRaw:o,userID:a,titleID:l,category:core.normalizeBlockchainCategory(c)});}catch(p){return s("deposit-onchain",g(p))}let d=await e.blockchain.depositToken(r.NetworkID??"",m);return d.ok?{ok:true,onChainTxHash:m,data:d.data}:s("report",d.error,{onChainTxHash:m})}async function R(t){let{client:e,adapter:n,currencyID:r,networkID:i,walletAddress:o,amount:l,category:c}=t,a=await e.blockchain.requestTokenWithdrawal(r,i,o,l,c);if(!a.ok)return s("request",a.error);let m=a.data.SolanaSignature,d=a.data.TitleTransactionID??void 0;if(!m)return s("request","Withdrawal response carried no Solana signature.",{titleTransactionID:d});let p;try{p=await n.submitWithdrawal(m);}catch(y){return s("withdraw-onchain",g(y),{titleTransactionID:d})}if(!d)return s("confirm","Missing TitleTransactionID.",{onChainTxHash:p});let u=await e.blockchain.confirmWithdrawal(d,p);return u.ok?{ok:true,onChainTxHash:p,data:a.data}:s("confirm",u.error,{onChainTxHash:p,titleTransactionID:d})}async function F(t){let{client:e,networkID:n,walletAddress:r,signMessage:i}=t,o=await e.auth.requestWalletChallenge(r,n);if(!o.ok)return f("challenge",o.error);let l;try{let a=await i(new TextEncoder().encode(o.data.Message));l=Se(a);}catch(a){return f("sign",g(a))}let c=await e.auth.loginWithWallet(r,n,l);return c.ok?{ok:true,data:c.data}:f("login",c.error)}function Se(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var J="Wallet not connected.";function Fe(t,e,n){let{publicKey:r,signMessage:i}=walletAdapterReact.useWallet(),o=r?.toBase58()??null;return {connected:!!o,account:o,loginWithWallet:(l,c)=>{let a=c??o;return a?i?F({client:t,networkID:l,walletAddress:a,signMessage:i}):Promise.resolve(f("sign","The connected wallet does not support message signing.")):Promise.resolve(f("challenge",J))},depositToken:l=>S({client:t,adapter:n,titleID:e,...l}),withdrawToken:l=>{let c=l.walletAddress??o;return c?R({client:t,adapter:n,...l,walletAddress:c}):Promise.resolve(s("request",J))}}}exports.IDosGamesWalletProvider=P;exports.SolanaWalletBridgeProvider=Ne;exports.WalletLogin=Ce;exports.WalletLoginButton=K;exports.createEvmWalletConfig=re;exports.useEvmBridge=ge;exports.useEvmBridgeClients=b;exports.useSolanaBridge=Fe;
1
+ 'use strict';var wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react$1=require('react'),jsxRuntime=require('react/jsx-runtime'),viem=require('viem'),core=require('@idosgames/core'),actions=require('wagmi/actions');var U={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"}}},q={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"}}},j={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"}}},Y={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"}}},z={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"}}},_={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"}}},Q={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"}}},V={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"}}},Z={mainnet:U,bsc:q,polygon:j,base:Y,arbitrum:z,optimism:_,sepolia:Q,polygonAmoy:V};function fe(t){return Object.values(Z).find(e=>e.id===t)}function $(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}var J=null;function X(t){J=t;}function N(){return J}function ve(t){let{chains:e,walletConnectProjectId:n,appName:r,appUrl:o,appIcon:a,transports:d,connectors:l}=t,s={};for(let c of e)s[c.id]=d?.[c.id]??wagmi.http();let u=o??(typeof window<"u"?window.location.origin:""),p={name:r??"iDosGames",description:r??"iDosGames game",url:u,icons:a?[a]:[]};if(n&&!l){let c=e.map($),f=new appkitAdapterWagmi.WagmiAdapter({networks:c,projectId:n,transports:s});return X(react.createAppKit({adapters:[f],networks:c,projectId:n,metadata:p,features:{analytics:false,email:false,socials:false}})),f.wagmiConfig}let m=l??[connectors.injected(),connectors.coinbaseWallet({appName:r??"iDosGames"})];return wagmi.createConfig({chains:e,connectors:m,transports:s})}function D(t){let{wagmiConfig:e,queryClient:n,children:r}=t,[o]=react$1.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:o,children:r})})}var E=[{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:[]}],te=[{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:[]}],P=[{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"}]}],ne=[{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 re(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}async function y(t,e){let{walletClient:n,publicClient:r,account:o}=t,a=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:o,chain:n.chain,value:e.value});if((await r.waitForTransactionReceipt({hash:a})).status==="reverted")throw new Error(`On-chain transaction reverted (${a}).`);return a}function g(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function i(t,e,n){return {ok:false,stage:t,error:e,...n}}function h(t,e){return {ok:false,stage:t,error:e}}function oe(t){let e=t.RewardPoolAddress;return e||null}async function ae(t,e,n,r){return await t.publicClient.readContract({address:e,abi:P,functionName:"allowance",args:[t.account,n]})>=r?null:y(t,{address:e,abi:P,functionName:"approve",args:[n,r]})}async function I(t){let{client:e,clients:n,network:r,tokenAddress:o,amount:a,titleID:d,category:l}=t,s=e.auth.context?.userID;if(!s)return i("approve","Not logged in.");let u=oe(r);if(!u)return i("approve","Network has no RewardPoolAddress.");if(a<=0n)return i("approve","Amount must be positive.");try{await ae(n,o,u,a);}catch(c){return i("approve",g(c))}let p;try{p=await y(n,{address:u,abi:E,functionName:"depositERC20",args:[o,a,s,d,l??""]});}catch(c){return i("deposit-onchain",g(c))}let m=await e.blockchain.depositToken(r.NetworkID??"",p);return m.ok?{ok:true,onChainTxHash:p,data:m.data}:i("report",m.error,{onChainTxHash:p})}async function B(t){let{client:e,clients:n,network:r,nftContractAddress:o,tokenId:a,amount:d,titleID:l,category:s}=t,u=e.auth.context?.userID;if(!u)return i("deposit-onchain","Not logged in.");let p=oe(r);if(!p)return i("deposit-onchain","Network has no RewardPoolAddress.");if(d<=0n)return i("deposit-onchain","Amount must be positive.");let m=re(u,l,s),c;try{c=await y(n,{address:o,abi:ne,functionName:"safeTransferFrom",args:[n.account,p,a,d,m]});}catch(k){return i("deposit-onchain",g(k))}let f=await e.blockchain.depositNFT(r.NetworkID??"",c);return f.ok?{ok:true,onChainTxHash:c,data:f.data}:i("report",f.error,{onChainTxHash:c})}async function ie(t,e){return y(t,{address:e.ContractAddress,abi:E,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 se(t,e){return y(t,{address:e.ContractAddress,abi:te,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 R(t){let{client:e,clients:n,currencyID:r,networkID:o,walletAddress:a,amount:d,category:l}=t,s=await e.blockchain.requestTokenWithdrawal(r,o,a,d,l);if(!s.ok)return i("request",s.error);let u=s.data.EvmSignature,p=s.data.TitleTransactionID??void 0;if(!u)return i("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let m;try{m=await ie(n,u);}catch(f){return i("withdraw-onchain",g(f),{titleTransactionID:p})}let c=await le(e,p,m);return c.ok?{ok:true,onChainTxHash:m,data:s.data}:c}async function S(t){let{client:e,clients:n,itemID:r,networkID:o,walletAddress:a,amount:d,category:l}=t,s=await e.blockchain.requestNFTWithdrawal(r,o,a,d,l);if(!s.ok)return i("request",s.error);let u=s.data.EvmSignature,p=s.data.TitleTransactionID??void 0;if(!u)return i("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let m;try{m=await se(n,u);}catch(f){return i("withdraw-onchain",g(f),{titleTransactionID:p})}let c=await le(e,p,m);return c.ok?{ok:true,onChainTxHash:m,data:s.data}:c}async function le(t,e,n){if(!e)return i("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await t.blockchain.confirmWithdrawal(e,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:i("confirm",r.error,{onChainTxHash:n,titleTransactionID:e})}async function b(t){let{client:e,clients:n,networkID:r}=t,o=t.walletAddress??n.account,a=await e.auth.requestWalletChallenge(o,r);if(!a.ok)return h("challenge",a.error);let d;try{d=await n.walletClient.signMessage({account:n.account,message:a.data.Message});}catch(s){return h("sign",g(s))}let l=await e.auth.loginWithWallet(o,r,d);return l.ok?{ok:true,data:l.data}:h("login",l.error)}function A(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}var v="Wallet not connected.";function Be(t,e){let n=A();return {connected:!!n,account:n?.account??null,loginWithWallet:(r,o)=>n?b({client:t,clients:n,networkID:r,walletAddress:o}):Promise.resolve(h("challenge",v)),depositToken:r=>n?I({client:t,clients:n,titleID:e,...r}):Promise.resolve(i("approve",v)),depositNft:r=>n?B({client:t,clients:n,titleID:e,...r}):Promise.resolve(i("deposit-onchain",v)),withdrawToken:r=>n?R({client:t,clients:n,...r}):Promise.resolve(i("withdraw-onchain",v)),withdrawNft:r=>n?S({client:t,clients:n,...r}):Promise.resolve(i("withdraw-onchain",v))}}function Ge(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(D,{wagmiConfig:e,children:jsxRuntime.jsx(pe,{...n})})}function Oe(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Ue(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 qe(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 je(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let r=false,o=l=>{r||(r=true,a(),clearTimeout(d),n(l));},a=actions.watchAccount(t,{onChange:l=>{l.isConnected&&o(true);}}),d=setTimeout(()=>o(false),e);})}function Ye(t){let e=o=>t.find(a=>a.id===o||a.type===o),n=e("injected"),r=typeof window<"u"&&window.ethereum!=null;return n&&r?n:e("walletConnect")??n??t[0]}var ze=9e4;async function _e(t){try{let r=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,o=r?.native||r?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function Qe(t,e){return new Promise((n,r)=>{let o=setTimeout(()=>r(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(o),n(a);},a=>{clearTimeout(o),r(a instanceof Error?a:new Error(String(a)));});})}function pe(t){let{client:e,networkID:n,onAuthenticated:r,disabled:o,label:a,style:d}=t,l=wagmi.useConfig(),{isConnected:s}=wagmi.useAccount(),{connectAsync:u,connectors:p}=wagmi.useConnect(),m=A(),[c,f]=react$1.useState(false),[k,w]=react$1.useState(null),[H,M]=react$1.useState(false),L=react$1.useRef(0),de=async()=>{let ue=++L.current,T=()=>L.current===ue;f(true),w(null);try{if(!s){let K=N();if(K){if(await K.open(),!await je(l)){w("No wallet was connected.");return}}else {let G=Ye(p);if(!G){w("No wallet connector is configured.");return}try{await u({connector:G});}catch(O){if(!Oe(O))throw O}}}let C=m??await qe(l);if(!C){w("Wallet client is not available.");return}M(!0);let W=await Qe(b({client:e,clients:C,networkID:n}),ze);if(!T())return;if(W.ok){r();return}w(W.stage==="sign"?"Signature declined.":W.error??"Wallet sign-in failed.");}catch(C){if(!T())return;console.error("[idosgames/wallet] wallet sign-in failed:",C),w(Ue(C));}finally{T()&&(f(false),M(false));}},me=async()=>{await _e(l)||await N()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{H?me():de();},disabled:o,style:{...Ve,...o?{opacity:.6,cursor:"default"}:null,...d},children:H?"Waiting for signature \u2014 tap to open wallet":c?"Check your wallet\u2026":s?a??"Sign in with wallet":"Connect wallet"}),k&&jsxRuntime.jsx("span",{role:"alert",style:Ze,children:k})]})}var Ve={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Ze={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};
2
+ exports.IDosGamesWalletProvider=D;exports.WalletLogin=Ge;exports.WalletLoginButton=pe;exports.arbitrum=z;exports.base=Y;exports.bsc=q;exports.chainById=fe;exports.createEvmWalletConfig=ve;exports.idosChains=Z;exports.mainnet=U;exports.optimism=_;exports.polygon=j;exports.polygonAmoy=V;exports.sepolia=Q;exports.useEvmBridge=Be;exports.useEvmBridgeClients=A;
@@ -1,19 +1,20 @@
1
- import * as wagmi from 'wagmi';
2
1
  import { CreateConnectorFn, Config } from 'wagmi';
3
2
  import { Chain, Transport } from 'viem';
3
+ import { W as WalletLoginResult, b as BridgeResult } from '../chains-DMjdV7VV.cjs';
4
+ export { h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia } from '../chains-DMjdV7VV.cjs';
4
5
  import * as react from 'react';
5
6
  import { ReactNode, CSSProperties } from 'react';
6
7
  import { QueryClient } from '@tanstack/react-query';
7
8
  import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
8
- 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-BCxf6AHE.cjs';
9
- import { Adapter } from '@solana/wallet-adapter-base';
9
+ import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-DgTjKpSf.cjs';
10
10
 
11
11
  interface EvmWalletConfigOptions {
12
12
  /** Chains the game supports, matching the EVM networks in the title's blockchain config. */
13
13
  chains: readonly [Chain, ...Chain[]];
14
14
  /**
15
- * WalletConnect Cloud project id — required to connect MOBILE wallets (and desktop wallets via
16
- * QR). Get one at https://cloud.walletconnect.com. Omit to support browser-extension wallets only.
15
+ * WalletConnect Cloud / Reown project id — required for MOBILE wallets. With it, the connect
16
+ * button opens the Reown AppKit modal (wallet list, QR on desktop, deep-link on phones). Omit it
17
+ * and the config degrades to browser-extension wallets only. Get one at dashboard.reown.com.
17
18
  */
18
19
  walletConnectProjectId?: string;
19
20
  /** App name/metadata shown in the wallet's connect prompt. */
@@ -26,9 +27,8 @@ interface EvmWalletConfigOptions {
26
27
  */
27
28
  transports?: Record<number, Transport>;
28
29
  /**
29
- * Override the connector list entirely. By default you get: `injected()` (MetaMask & other
30
- * browser extensions), `walletConnect()` (mobile + QR, when a projectId is given), and
31
- * `coinbaseWallet()`.
30
+ * Escape hatch: take over the connector list entirely. Supplying this opts OUT of AppKit and
31
+ * builds a plain wagmi config from exactly these connectors.
32
32
  */
33
33
  connectors?: CreateConnectorFn[];
34
34
  }
@@ -36,11 +36,15 @@ interface EvmWalletConfigOptions {
36
36
  * Builds a wagmi `Config` wired for both browser and mobile wallets, ready to hand to
37
37
  * {@link IDosGamesWalletProvider} (or a bare `WagmiProvider`).
38
38
  *
39
- * - Browser: `injected()` picks up MetaMask and any EIP-1193 extension.
40
- * - Mobile: `walletConnect()` opens the WalletConnect modal (QR on desktop, deep-link on mobile)
41
- * so phone wallets like MetaMask Mobile, Trust, Rainbow can connect. Needs a `walletConnectProjectId`.
39
+ * With a `walletConnectProjectId` this goes through **Reown AppKit** (the successor to
40
+ * WalletConnect's own modal): AppKit owns the wallet picker, the QR/deep-link handshake and — the
41
+ * part that matters on phones re-opening the wallet app for every signature request. The bare
42
+ * wagmi WalletConnect connector left that to the player, which is why signatures appeared to hang.
43
+ *
44
+ * Without a project id it falls back to a plain wagmi config with `injected()` + `coinbaseWallet()`:
45
+ * browser extensions keep working, mobile wallets are simply unavailable.
42
46
  */
43
- declare function createEvmWalletConfig(options: EvmWalletConfigOptions): wagmi.Config<readonly [Chain, ...Chain[]], Record<number, Transport>, CreateConnectorFn[]>;
47
+ declare function createEvmWalletConfig(options: EvmWalletConfigOptions): Config;
44
48
 
45
49
  interface IDosGamesWalletProviderProps {
46
50
  /** A wagmi config, typically from {@link createEvmWalletConfig}. */
@@ -69,9 +73,9 @@ declare function IDosGamesWalletProvider(props: IDosGamesWalletProviderProps): r
69
73
  * wallet is connected / the wallet client isn't ready yet.
70
74
  */
71
75
  declare function useEvmBridgeClients(): EvmBridgeClients | null;
72
- type DepositTokenArgs$1 = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
76
+ type DepositTokenArgs = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
73
77
  type DepositNftArgs = Omit<DepositNftEvmParams, "client" | "clients" | "titleID">;
74
- type WithdrawTokenArgs$1 = Omit<WithdrawTokenEvmParams, "client" | "clients">;
78
+ type WithdrawTokenArgs = Omit<WithdrawTokenEvmParams, "client" | "clients">;
75
79
  type WithdrawNftArgs = Omit<WithdrawNftEvmParams, "client" | "clients">;
76
80
  interface EvmBridge {
77
81
  /** Whether a wallet is connected and its client is ready. */
@@ -84,9 +88,9 @@ interface EvmBridge {
84
88
  * to the connected account. On success the core client is logged in and its ClientState returned.
85
89
  */
86
90
  loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
87
- depositToken(args: DepositTokenArgs$1): Promise<BridgeResult<DepositTokenResponse>>;
91
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
88
92
  depositNft(args: DepositNftArgs): Promise<BridgeResult<DepositNFTResponse>>;
89
- withdrawToken(args: WithdrawTokenArgs$1): Promise<BridgeResult<TokenWithdrawalResponse>>;
93
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
90
94
  withdrawNft(args: WithdrawNftArgs): Promise<BridgeResult<NFTWithdrawalResponse>>;
91
95
  }
92
96
  /**
@@ -131,49 +135,4 @@ type WalletLoginButtonProps = Omit<WalletLoginProps, "wagmiConfig">;
131
135
  /** The button itself. Must be rendered inside an {@link IDosGamesWalletProvider}. */
132
136
  declare function WalletLoginButton(props: WalletLoginButtonProps): ReactNode;
133
137
 
134
- interface SolanaWalletBridgeProviderProps {
135
- /** RPC endpoint for the Solana network the title uses (matches its blockchain config). */
136
- endpoint: string;
137
- /**
138
- * Wallet adapters to offer (e.g. `new PhantomWalletAdapter()` from
139
- * `@solana/wallet-adapter-wallets`). Mobile support comes from adapters that implement it
140
- * (Mobile Wallet Adapter on Android, or a WalletConnect adapter).
141
- */
142
- wallets: Adapter[];
143
- /** Auto-reconnect the last-used wallet on mount. */
144
- autoConnect?: boolean;
145
- children: ReactNode;
146
- }
147
- /**
148
- * Thin wrapper over wallet-adapter's `ConnectionProvider` + `WalletProvider` so the
149
- * {@link useSolanaBridge} hook has a connected wallet. Compose it alongside
150
- * {@link IDosGamesWalletProvider} when a title supports both EVM and Solana networks.
151
- */
152
- declare function SolanaWalletBridgeProvider(props: SolanaWalletBridgeProviderProps): react.JSX.Element;
153
-
154
- type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
155
- /** `walletAddress` defaults to the connected wallet if omitted. */
156
- type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
157
- walletAddress?: string;
158
- };
159
- interface SolanaBridge {
160
- connected: boolean;
161
- account: string | null;
162
- /**
163
- * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
164
- * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
165
- * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
166
- */
167
- loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
168
- depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
169
- withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
170
- }
171
- /**
172
- * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
173
- * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
174
- * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
175
- * just wires the connected address and threads the request → submit → confirm lifecycle.
176
- */
177
- declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
178
-
179
- export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, type SolanaBridge, SolanaWalletBridgeProvider, type SolanaWalletBridgeProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients, useSolanaBridge };
138
+ export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients };
@@ -1,19 +1,20 @@
1
- import * as wagmi from 'wagmi';
2
1
  import { CreateConnectorFn, Config } from 'wagmi';
3
2
  import { Chain, Transport } from 'viem';
3
+ import { W as WalletLoginResult, b as BridgeResult } from '../chains-DMjdV7VV.js';
4
+ export { h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia } from '../chains-DMjdV7VV.js';
4
5
  import * as react from 'react';
5
6
  import { ReactNode, CSSProperties } from 'react';
6
7
  import { QueryClient } from '@tanstack/react-query';
7
8
  import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
8
- 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-BCxf6AHE.js';
9
- import { Adapter } from '@solana/wallet-adapter-base';
9
+ import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-DTHssYc9.js';
10
10
 
11
11
  interface EvmWalletConfigOptions {
12
12
  /** Chains the game supports, matching the EVM networks in the title's blockchain config. */
13
13
  chains: readonly [Chain, ...Chain[]];
14
14
  /**
15
- * WalletConnect Cloud project id — required to connect MOBILE wallets (and desktop wallets via
16
- * QR). Get one at https://cloud.walletconnect.com. Omit to support browser-extension wallets only.
15
+ * WalletConnect Cloud / Reown project id — required for MOBILE wallets. With it, the connect
16
+ * button opens the Reown AppKit modal (wallet list, QR on desktop, deep-link on phones). Omit it
17
+ * and the config degrades to browser-extension wallets only. Get one at dashboard.reown.com.
17
18
  */
18
19
  walletConnectProjectId?: string;
19
20
  /** App name/metadata shown in the wallet's connect prompt. */
@@ -26,9 +27,8 @@ interface EvmWalletConfigOptions {
26
27
  */
27
28
  transports?: Record<number, Transport>;
28
29
  /**
29
- * Override the connector list entirely. By default you get: `injected()` (MetaMask & other
30
- * browser extensions), `walletConnect()` (mobile + QR, when a projectId is given), and
31
- * `coinbaseWallet()`.
30
+ * Escape hatch: take over the connector list entirely. Supplying this opts OUT of AppKit and
31
+ * builds a plain wagmi config from exactly these connectors.
32
32
  */
33
33
  connectors?: CreateConnectorFn[];
34
34
  }
@@ -36,11 +36,15 @@ interface EvmWalletConfigOptions {
36
36
  * Builds a wagmi `Config` wired for both browser and mobile wallets, ready to hand to
37
37
  * {@link IDosGamesWalletProvider} (or a bare `WagmiProvider`).
38
38
  *
39
- * - Browser: `injected()` picks up MetaMask and any EIP-1193 extension.
40
- * - Mobile: `walletConnect()` opens the WalletConnect modal (QR on desktop, deep-link on mobile)
41
- * so phone wallets like MetaMask Mobile, Trust, Rainbow can connect. Needs a `walletConnectProjectId`.
39
+ * With a `walletConnectProjectId` this goes through **Reown AppKit** (the successor to
40
+ * WalletConnect's own modal): AppKit owns the wallet picker, the QR/deep-link handshake and — the
41
+ * part that matters on phones re-opening the wallet app for every signature request. The bare
42
+ * wagmi WalletConnect connector left that to the player, which is why signatures appeared to hang.
43
+ *
44
+ * Without a project id it falls back to a plain wagmi config with `injected()` + `coinbaseWallet()`:
45
+ * browser extensions keep working, mobile wallets are simply unavailable.
42
46
  */
43
- declare function createEvmWalletConfig(options: EvmWalletConfigOptions): wagmi.Config<readonly [Chain, ...Chain[]], Record<number, Transport>, CreateConnectorFn[]>;
47
+ declare function createEvmWalletConfig(options: EvmWalletConfigOptions): Config;
44
48
 
45
49
  interface IDosGamesWalletProviderProps {
46
50
  /** A wagmi config, typically from {@link createEvmWalletConfig}. */
@@ -69,9 +73,9 @@ declare function IDosGamesWalletProvider(props: IDosGamesWalletProviderProps): r
69
73
  * wallet is connected / the wallet client isn't ready yet.
70
74
  */
71
75
  declare function useEvmBridgeClients(): EvmBridgeClients | null;
72
- type DepositTokenArgs$1 = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
76
+ type DepositTokenArgs = Omit<DepositTokenEvmParams, "client" | "clients" | "titleID">;
73
77
  type DepositNftArgs = Omit<DepositNftEvmParams, "client" | "clients" | "titleID">;
74
- type WithdrawTokenArgs$1 = Omit<WithdrawTokenEvmParams, "client" | "clients">;
78
+ type WithdrawTokenArgs = Omit<WithdrawTokenEvmParams, "client" | "clients">;
75
79
  type WithdrawNftArgs = Omit<WithdrawNftEvmParams, "client" | "clients">;
76
80
  interface EvmBridge {
77
81
  /** Whether a wallet is connected and its client is ready. */
@@ -84,9 +88,9 @@ interface EvmBridge {
84
88
  * to the connected account. On success the core client is logged in and its ClientState returned.
85
89
  */
86
90
  loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
87
- depositToken(args: DepositTokenArgs$1): Promise<BridgeResult<DepositTokenResponse>>;
91
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
88
92
  depositNft(args: DepositNftArgs): Promise<BridgeResult<DepositNFTResponse>>;
89
- withdrawToken(args: WithdrawTokenArgs$1): Promise<BridgeResult<TokenWithdrawalResponse>>;
93
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
90
94
  withdrawNft(args: WithdrawNftArgs): Promise<BridgeResult<NFTWithdrawalResponse>>;
91
95
  }
92
96
  /**
@@ -131,49 +135,4 @@ type WalletLoginButtonProps = Omit<WalletLoginProps, "wagmiConfig">;
131
135
  /** The button itself. Must be rendered inside an {@link IDosGamesWalletProvider}. */
132
136
  declare function WalletLoginButton(props: WalletLoginButtonProps): ReactNode;
133
137
 
134
- interface SolanaWalletBridgeProviderProps {
135
- /** RPC endpoint for the Solana network the title uses (matches its blockchain config). */
136
- endpoint: string;
137
- /**
138
- * Wallet adapters to offer (e.g. `new PhantomWalletAdapter()` from
139
- * `@solana/wallet-adapter-wallets`). Mobile support comes from adapters that implement it
140
- * (Mobile Wallet Adapter on Android, or a WalletConnect adapter).
141
- */
142
- wallets: Adapter[];
143
- /** Auto-reconnect the last-used wallet on mount. */
144
- autoConnect?: boolean;
145
- children: ReactNode;
146
- }
147
- /**
148
- * Thin wrapper over wallet-adapter's `ConnectionProvider` + `WalletProvider` so the
149
- * {@link useSolanaBridge} hook has a connected wallet. Compose it alongside
150
- * {@link IDosGamesWalletProvider} when a title supports both EVM and Solana networks.
151
- */
152
- declare function SolanaWalletBridgeProvider(props: SolanaWalletBridgeProviderProps): react.JSX.Element;
153
-
154
- type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
155
- /** `walletAddress` defaults to the connected wallet if omitted. */
156
- type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
157
- walletAddress?: string;
158
- };
159
- interface SolanaBridge {
160
- connected: boolean;
161
- account: string | null;
162
- /**
163
- * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
164
- * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
165
- * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
166
- */
167
- loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
168
- depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
169
- withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
170
- }
171
- /**
172
- * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
173
- * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
174
- * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
175
- * just wires the connected address and threads the request → submit → confirm lifecycle.
176
- */
177
- declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
178
-
179
- export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, type SolanaBridge, SolanaWalletBridgeProvider, type SolanaWalletBridgeProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients, useSolanaBridge };
138
+ export { type EvmBridge, type EvmWalletConfigOptions, IDosGamesWalletProvider, type IDosGamesWalletProviderProps, WalletLogin, WalletLoginButton, type WalletLoginButtonProps, type WalletLoginProps, createEvmWalletConfig, useEvmBridge, useEvmBridgeClients };
@@ -1 +1 @@
1
- import {r,b,q,l,k,s,c,u,t,v}from'../chunk-YV6AQWSH.js';import {http,createConfig,WagmiProvider,useAccount,usePublicClient,useWalletClient,useConfig,useConnect}from'wagmi';import {injected,coinbaseWallet,walletConnect}from'wagmi/connectors';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {useState}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getWalletClient,getPublicClient}from'wagmi/actions';import {ConnectionProvider,WalletProvider,useWallet}from'@solana/wallet-adapter-react';function _(e){let{chains:o,walletConnectProjectId:t,appName:n,appUrl:r,appIcon:i,transports:a,connectors:s}=e,l=n||r?{name:n??"iDosGames",description:n??"iDosGames game",url:r??"",icons:i?[i]:[]}:void 0,y=s??[injected(),coinbaseWallet({appName:n??"iDosGames"}),...t?[walletConnect({projectId:t,metadata:l,showQrModal:true})]:[]],u={};for(let f of o)u[f.id]=a?.[f.id]??http();return createConfig({chains:o,connectors:y,transports:u})}function h(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 g="Wallet not connected.";function $(e,o){let t=C();return {connected:!!t,account:t?.account??null,loginWithWallet:(n,r)=>t?s({client:e,clients:t,networkID:n,walletAddress:r}):Promise.resolve(c("challenge",g)),depositToken:n=>t?k({client:e,clients:t,titleID:o,...n}):Promise.resolve(b("approve",g)),depositNft:n=>t?l({client:e,clients:t,titleID:o,...n}):Promise.resolve(b("deposit-onchain",g)),withdrawToken:n=>t?q({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",g)),withdrawNft:n=>t?r({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",g))}}function ie(e){let{wagmiConfig:o,...t}=e;return jsx(h,{wagmiConfig:o,children:jsx(G,{...t})})}function ae(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function se(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 le(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 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 G(e){let{client:o,networkID:t,onAuthenticated:n,disabled:r,label:i,style:a}=e,s$1=useConfig(),{isConnected:l}=useAccount(),{connectAsync:y,connectors:u}=useConnect(),f=C(),[P,k]=useState(false),[T,c]=useState(null),j=async()=>{k(true),c(null);try{if(!l){let E=de(u);if(!E){c("No wallet connector is configured.");return}try{await y({connector:E});}catch(D){if(!ae(D))throw D}}let p=f??await le(s$1);if(!p){c("Wallet client is not available.");return}let v=await s({client:o,clients:p,networkID:t});if(v.ok){n();return}c(v.stage==="sign"?"Signature declined.":v.error??"Wallet sign-in failed.");}catch(p){console.error("[idosgames/wallet] wallet sign-in failed:",p),c(se(p));}finally{k(false);}};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{j();},disabled:r||P,style:{...ce,...r||P?{opacity:.6,cursor:"default"}:null,...a},children:P?"Check your wallet\u2026":l?i??"Sign in with wallet":"Connect wallet"}),T&&jsx("span",{role:"alert",style:pe,children:T})]})}var ce={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},pe={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function we(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 F="Wallet not connected.";function We(e,o,t$1){let{publicKey:n,signMessage:r}=useWallet(),i=n?.toBase58()??null;return {connected:!!i,account:i,loginWithWallet:(a,s)=>{let l=s??i;return l?r?v({client:e,networkID:a,walletAddress:l,signMessage:r}):Promise.resolve(c("sign","The connected wallet does not support message signing.")):Promise.resolve(c("challenge",F))},depositToken:a=>t({client:e,adapter:t$1,titleID:o,...a}),withdrawToken:a=>{let s=a.walletAddress??i;return s?u({client:e,adapter:t$1,...a,walletAddress:s}):Promise.resolve(b("request",F))}}}export{h as IDosGamesWalletProvider,we as SolanaWalletBridgeProvider,ie as WalletLogin,G as WalletLoginButton,_ as createEvmWalletConfig,$ as useEvmBridge,C as useEvmBridgeClients,We as useSolanaBridge};
1
+ import {o,n as n$1,i,h,p}from'../chunk-NDNNLWPS.js';import {a,b as b$1}from'../chunk-ZL42KPPC.js';import {n,b,c}from'../chunk-XFMDEOHO.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-XFMDEOHO.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}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getAccount,watchAccount,getWalletClient,getPublicClient}from'wagmi/actions';function le(e){let{chains:o,walletConnectProjectId:t,appName:n$1,appUrl:r,appIcon:i,transports:p,connectors:s}=e,l={};for(let a of o)l[a.id]=p?.[a.id]??http();let y=r??(typeof window<"u"?window.location.origin:""),v={name:n$1??"iDosGames",description:n$1??"iDosGames game",url:y,icons:i?[i]:[]};if(t&&!s){let a$1=o.map(n),m=new WagmiAdapter({networks:a$1,projectId:t,transports:l});return a(createAppKit({adapters:[m],networks:a$1,projectId:t,metadata:v,features:{analytics:false,email:false,socials:false}})),m.wagmiConfig}let h=s??[injected(),coinbaseWallet({appName:n$1??"iDosGames"})];return createConfig({chains:o,connectors:h,transports:l})}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 w(){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 we(e,o$1){let t=w();return {connected:!!t,account:t?.account??null,loginWithWallet:(n,r)=>t?p({client:e,clients:t,networkID:n,walletAddress:r}):Promise.resolve(c("challenge",f)),depositToken:n=>t?h({client:e,clients:t,titleID:o$1,...n}):Promise.resolve(b("approve",f)),depositNft:n=>t?i({client:e,clients:t,titleID:o$1,...n}):Promise.resolve(b("deposit-onchain",f)),withdrawToken:n=>t?n$1({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",f)),withdrawNft:n=>t?o({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",f))}}function Te(e){let{wagmiConfig:o,...t}=e;return jsx(T,{wagmiConfig:o,children:jsx(U,{...t})})}function be(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function ke(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 Ne(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 De(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 Ae(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 Re=9e4;async function Be(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 Ie(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 U(e){let{client:o,networkID:t,onAuthenticated:n,disabled:r,label:i,style:p$1}=e,s=useConfig(),{isConnected:l}=useAccount(),{connectAsync:y,connectors:v}=useConnect(),h=w(),[a,m]=useState(false),[k,c]=useState(null),[N,D]=useState(false),A=useRef(0),_=async()=>{let Q=++A.current,P=()=>A.current===Q;m(true),c(null);try{if(!l){let R=b$1();if(R){if(await R.open(),!await De(s)){c("No wallet was connected.");return}}else {let B=Ae(v);if(!B){c("No wallet connector is configured.");return}try{await y({connector:B});}catch(I){if(!be(I))throw I}}}let d=h??await Ne(s);if(!d){c("Wallet client is not available.");return}D(!0);let W=await Ie(p({client:o,clients:d,networkID:t}),Re);if(!P())return;if(W.ok){n();return}c(W.stage==="sign"?"Signature declined.":W.error??"Wallet sign-in failed.");}catch(d){if(!P())return;console.error("[idosgames/wallet] wallet sign-in failed:",d),c(ke(d));}finally{P()&&(m(false),D(false));}},M=async()=>{await Be(s)||await b$1()?.open();};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{N?M():_();},disabled:r,style:{...Se,...r?{opacity:.6,cursor:"default"}:null,...p$1},children:N?"Waiting for signature \u2014 tap to open wallet":a?"Check your wallet\u2026":l?i??"Sign in with wallet":"Connect wallet"}),k&&jsx("span",{role:"alert",style:xe,children:k})]})}var Se={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},xe={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};export{T as IDosGamesWalletProvider,Te as WalletLogin,U as WalletLoginButton,le as createEvmWalletConfig,we as useEvmBridge,w as useEvmBridgeClients};
@@ -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 C={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"},G={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 L=null;function M(e){L=e;}function P(){return L}function z(e){let{walletConnectProjectId:t,appName:a,appUrl:s,appIcon:l,wallets:n}=e,p=e.networks??[C],o=s??(typeof window<"u"?window.location.origin:""),r={name:a??"iDosGames",description:a??"iDosGames game",url:o,icons:l?[l]:[]},i=new appkitAdapterSolana.SolanaAdapter(n?{wallets:n}:{});return M(react.createAppKit({adapters:[i],networks:p,projectId:t,metadata:r,features:{analytics:false,email:false,socials:false}})),i}function y(e){return e instanceof viem.BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function d(e,t,a){return {ok:false,stage:e,error:t,...a}}function g(e,t){return {ok:false,stage:e,error:t}}async function v(e){let{client:t,adapter:a,network:s,mint:l,amountRaw:n,titleID:p,category:o}=e,r=t.auth.context?.userID;if(!r)return d("deposit-onchain","Not logged in.");if(n<=0n)return d("deposit-onchain","Amount must be positive.");let i;try{i=await a.depositSpl({mint:l,amountRaw:n,userID:r,titleID:p,category:core.normalizeBlockchainCategory(o)});}catch(c){return d("deposit-onchain",y(c))}let u=await t.blockchain.depositToken(s.NetworkID??"",i);return u.ok?{ok:true,onChainTxHash:i,data:u.data}:d("report",u.error,{onChainTxHash:i})}async function E(e){let{client:t,adapter:a,currencyID:s,networkID:l,walletAddress:n,amount:p,category:o}=e,r=await t.blockchain.requestTokenWithdrawal(s,l,n,p,o);if(!r.ok)return d("request",r.error);let i=r.data.SolanaSignature,u=r.data.TitleTransactionID??void 0;if(!i)return d("request","Withdrawal response carried no Solana signature.",{titleTransactionID:u});let c;try{c=await a.submitWithdrawal(i);}catch(m){return d("withdraw-onchain",y(m),{titleTransactionID:u})}if(!u)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:c});let h=await t.blockchain.confirmWithdrawal(u,c);return h.ok?{ok:true,onChainTxHash:c,data:r.data}:d("confirm",h.error,{onChainTxHash:c,titleTransactionID:u})}async function S(e){let{client:t,networkID:a,walletAddress:s,signMessage:l}=e,n=await t.auth.requestWalletChallenge(s,a);if(!n.ok)return g("challenge",n.error);let p;try{let r=await l(new TextEncoder().encode(n.data.Message));p=$(r);}catch(r){return g("sign",y(r))}let o=await t.auth.loginWithWallet(s,a,p);return o.ok?{ok:true,data:o.data}:g("login",o.error)}function $(e){let t="0x";for(let a of e)t+=a.toString(16).padStart(2,"0");return t}var U="Wallet not connected.";function Q(e,t,a){let{address:s}=react.useAppKitAccount(),{walletProvider:l}=react.useAppKitProvider("solana"),n=s??null,p=l?.signMessage?.bind(l);return {connected:!!n,account:n,loginWithWallet:(o,r)=>{let i=r??n;return i?p?S({client:e,networkID:o,walletAddress:i,signMessage:p}):Promise.resolve(g("sign","The connected wallet does not support message signing.")):Promise.resolve(g("challenge",U))},depositToken:o=>v({client:e,adapter:a,titleID:t,...o}),withdrawToken:o=>{let r=o.walletAddress??n;return r?E({client:e,adapter:a,...o,walletAddress:r}):Promise.resolve(d("request",U))}}}var te=18e4,ae=9e4;function ne(e){try{let a=e?.session?.peer?.metadata?.redirect,s=a?.native||a?.universal;return !s||typeof window>"u"?!1:(window.location.href=s,!0)}catch{return false}}function re(e,t){return new Promise((a,s)=>{let l=setTimeout(()=>s(new Error("The wallet request timed out.")),t);e.then(n=>{clearTimeout(l),a(n);},n=>{clearTimeout(l),s(n instanceof Error?n:new Error(String(n)));});})}function oe(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 ie(e){let{client:t,networkID:a,onAuthenticated:s,disabled:l,label:n,style:p}=e,{address:o,isConnected:r}=react.useAppKitAccount(),{walletProvider:i}=react.useAppKitProvider("solana"),[u,c]=react$1.useState(false),[h,m]=react$1.useState(null),[I,b]=react$1.useState(false),[B,N]=react$1.useState(false),k=react$1.useRef(null),R=react$1.useRef(0),w=react$1.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=null;},[]);react$1.useEffect(()=>w,[w]);let A=react$1.useCallback(async()=>{let T=++R.current,W=()=>R.current===T,K=i?.signMessage?.bind(i);if(!o||!K){m("The connected wallet cannot sign messages."),c(false);return}c(true),m(null);try{N(!0);let f=await re(S({client:t,networkID:a,walletAddress:o,signMessage:K}),ae);if(!W())return;if(f.ok){s();return}m(f.stage==="sign"?"Signature declined.":f.error??"Wallet sign-in failed.");}catch(f){if(!W())return;console.error("[idosgames/wallet] solana sign-in failed:",f),m(oe(f));}finally{W()&&(c(false),N(false));}},[o,i,t,a,s]),H=react$1.useCallback(()=>{ne(i)||P()?.open();},[i]);return react$1.useEffect(()=>{!I||!r||!o||!i||(b(false),w(),A());},[I,r,o,i,A,w]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(B){H();return}if(m(null),r&&o&&i){A();return}let T=P();if(!T){m("Wallet sign-in is not configured for this title.");return}c(true),b(true),w(),k.current=setTimeout(()=>{b(false),c(false),m("No wallet was connected.");},te),T.open();},disabled:l,style:{...se,...l?{opacity:.6,cursor:"default"}:null,...p},children:B?"Waiting for signature \u2014 tap to open wallet":u?"Check your wallet\u2026":r?n??"Sign in with wallet":"Connect wallet"}),h&&jsxRuntime.jsx("span",{role:"alert",style:le,children:h})]})}var se={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},le={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};
2
+ exports.SolanaWalletLogin=ie;exports.createSolanaWalletConfig=z;exports.solanaDevnet=G;exports.solanaMainnet=C;exports.useSolanaBridge=Q;
@@ -0,0 +1,93 @@
1
+ import { SolanaAdapter } from '@reown/appkit-adapter-solana';
2
+ import { BaseWalletAdapter } from '@solana/wallet-adapter-base';
3
+ import { a as AppKitSolanaNetwork, W as WalletLoginResult, b as BridgeResult } from '../chains-DMjdV7VV.cjs';
4
+ export { r as solanaDevnet, t as solanaMainnet } from '../chains-DMjdV7VV.cjs';
5
+ import { ClientState, DepositTokenResponse, TokenWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
6
+ import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-BEEkIeZj.cjs';
7
+ import { CSSProperties, ReactNode } from 'react';
8
+ import 'viem';
9
+
10
+ interface SolanaWalletConfigOptions {
11
+ /**
12
+ * WalletConnect Cloud / Reown project id. Required: it is what gives phones a working wallet at
13
+ * all. Solana's own Mobile Wallet Adapter is Android-only — on iOS a plain web page cannot reach
14
+ * a wallet app except through WalletConnect deep-links (or the wallet's in-app browser).
15
+ */
16
+ walletConnectProjectId: string;
17
+ /** Networks the title supports. Defaults to Solana mainnet. */
18
+ networks?: [AppKitSolanaNetwork, ...AppKitSolanaNetwork[]];
19
+ /** App name/metadata shown in the wallet's connect prompt. */
20
+ appName?: string;
21
+ appUrl?: string;
22
+ appIcon?: string;
23
+ /**
24
+ * Extra standard Solana wallet adapters (Phantom, Solflare, Mobile Wallet Adapter…).
25
+ *
26
+ * These do NOT replace the WalletConnect path — AppKit runs both: adapters cover browser
27
+ * extensions, wallet in-app browsers and Android's MWA, while WalletConnect covers iOS and any
28
+ * wallet the player has not installed as an extension. Wallet Standard already auto-detects most
29
+ * installed wallets, so this is only needed for ones that do not announce themselves.
30
+ */
31
+ wallets?: BaseWalletAdapter[];
32
+ }
33
+ /**
34
+ * Builds the Solana wallet stack for a title, on **Reown AppKit** — the same modal, session and
35
+ * deep-link machinery the EVM side uses, so both chains behave identically on a phone.
36
+ *
37
+ * A title is EVM or Solana, so exactly one of {@link createEvmWalletConfig} /
38
+ * `createSolanaWalletConfig` runs per game; both register the shared AppKit instance the sign-in
39
+ * button opens.
40
+ */
41
+ declare function createSolanaWalletConfig(options: SolanaWalletConfigOptions): SolanaAdapter;
42
+
43
+ type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
44
+ /** `walletAddress` defaults to the connected wallet if omitted. */
45
+ type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
46
+ walletAddress?: string;
47
+ };
48
+ interface SolanaBridge {
49
+ connected: boolean;
50
+ account: string | null;
51
+ /**
52
+ * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
53
+ * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
54
+ * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
55
+ */
56
+ loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
57
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
58
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
59
+ }
60
+ /**
61
+ * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
62
+ * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
63
+ * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
64
+ * just wires the connected address and threads the request → submit → confirm lifecycle.
65
+ */
66
+ declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
67
+
68
+ interface SolanaWalletLoginProps {
69
+ /** The (not yet authenticated) shared client. */
70
+ client: IDosGamesClient;
71
+ /** NetworkID the challenge is issued for — one of the title's configured networks. */
72
+ networkID: string;
73
+ /** Called once the wallet signature has been exchanged for a session. */
74
+ onAuthenticated: () => void;
75
+ disabled?: boolean;
76
+ label?: string;
77
+ style?: CSSProperties;
78
+ }
79
+ /**
80
+ * Ready-made "sign in with wallet" button for **Solana** titles: connect → sign the challenge →
81
+ * session. The EVM twin is {@link WalletLogin}; a title is one or the other.
82
+ *
83
+ * Unlike the EVM button this needs no provider wrapper — AppKit is a global instance created by
84
+ * `createSolanaWalletConfig`, and the wallet is read through its hooks.
85
+ *
86
+ * Connecting and signing are one action for the player, but on a phone they are separated by an app
87
+ * switch: `appKit.open()` returns as soon as the modal is on screen, long before a wallet is picked
88
+ * and the deep-link round trip completes. So the click only *arms* the flow, and an effect fires the
89
+ * signature once the account actually appears — no polling, no second tap.
90
+ */
91
+ declare function SolanaWalletLogin(props: SolanaWalletLoginProps): ReactNode;
92
+
93
+ export { AppKitSolanaNetwork, type SolanaBridge, type SolanaWalletConfigOptions, SolanaWalletLogin, type SolanaWalletLoginProps, createSolanaWalletConfig, useSolanaBridge };
@@ -0,0 +1,93 @@
1
+ import { SolanaAdapter } from '@reown/appkit-adapter-solana';
2
+ import { BaseWalletAdapter } from '@solana/wallet-adapter-base';
3
+ import { a as AppKitSolanaNetwork, W as WalletLoginResult, b as BridgeResult } from '../chains-DMjdV7VV.js';
4
+ export { r as solanaDevnet, t as solanaMainnet } from '../chains-DMjdV7VV.js';
5
+ import { ClientState, DepositTokenResponse, TokenWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
6
+ import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-BzZmMMxK.js';
7
+ import { CSSProperties, ReactNode } from 'react';
8
+ import 'viem';
9
+
10
+ interface SolanaWalletConfigOptions {
11
+ /**
12
+ * WalletConnect Cloud / Reown project id. Required: it is what gives phones a working wallet at
13
+ * all. Solana's own Mobile Wallet Adapter is Android-only — on iOS a plain web page cannot reach
14
+ * a wallet app except through WalletConnect deep-links (or the wallet's in-app browser).
15
+ */
16
+ walletConnectProjectId: string;
17
+ /** Networks the title supports. Defaults to Solana mainnet. */
18
+ networks?: [AppKitSolanaNetwork, ...AppKitSolanaNetwork[]];
19
+ /** App name/metadata shown in the wallet's connect prompt. */
20
+ appName?: string;
21
+ appUrl?: string;
22
+ appIcon?: string;
23
+ /**
24
+ * Extra standard Solana wallet adapters (Phantom, Solflare, Mobile Wallet Adapter…).
25
+ *
26
+ * These do NOT replace the WalletConnect path — AppKit runs both: adapters cover browser
27
+ * extensions, wallet in-app browsers and Android's MWA, while WalletConnect covers iOS and any
28
+ * wallet the player has not installed as an extension. Wallet Standard already auto-detects most
29
+ * installed wallets, so this is only needed for ones that do not announce themselves.
30
+ */
31
+ wallets?: BaseWalletAdapter[];
32
+ }
33
+ /**
34
+ * Builds the Solana wallet stack for a title, on **Reown AppKit** — the same modal, session and
35
+ * deep-link machinery the EVM side uses, so both chains behave identically on a phone.
36
+ *
37
+ * A title is EVM or Solana, so exactly one of {@link createEvmWalletConfig} /
38
+ * `createSolanaWalletConfig` runs per game; both register the shared AppKit instance the sign-in
39
+ * button opens.
40
+ */
41
+ declare function createSolanaWalletConfig(options: SolanaWalletConfigOptions): SolanaAdapter;
42
+
43
+ type DepositTokenArgs = Omit<DepositTokenSolanaParams, "client" | "adapter" | "titleID">;
44
+ /** `walletAddress` defaults to the connected wallet if omitted. */
45
+ type WithdrawTokenArgs = Omit<WithdrawTokenSolanaParams, "client" | "adapter" | "walletAddress"> & {
46
+ walletAddress?: string;
47
+ };
48
+ interface SolanaBridge {
49
+ connected: boolean;
50
+ account: string | null;
51
+ /**
52
+ * Logs into the game with the connected Solana wallet by signing a server challenge (no tx, no
53
+ * fee). `networkID` is the cfg.Blockchain.Networks key; `walletAddress` defaults to the connected
54
+ * account. Requires a wallet that supports `signMessage`. Returns the fresh ClientState.
55
+ */
56
+ loginWithWallet(networkID: string, walletAddress?: string): Promise<WalletLoginResult<ClientState>>;
57
+ depositToken(args: DepositTokenArgs): Promise<BridgeResult<DepositTokenResponse>>;
58
+ withdrawToken(args: WithdrawTokenArgs): Promise<BridgeResult<TokenWithdrawalResponse>>;
59
+ }
60
+ /**
61
+ * The ergonomic Solana bridge hook: binds the connected wallet-adapter wallet + your
62
+ * {@link SolanaProgramAdapter} to the deposit/withdraw flows against a core client + title.
63
+ * The on-chain instruction building lives in the adapter (it owns the program IDL); this hook
64
+ * just wires the connected address and threads the request → submit → confirm lifecycle.
65
+ */
66
+ declare function useSolanaBridge(client: IDosGamesClient, titleID: string, adapter: SolanaProgramAdapter): SolanaBridge;
67
+
68
+ interface SolanaWalletLoginProps {
69
+ /** The (not yet authenticated) shared client. */
70
+ client: IDosGamesClient;
71
+ /** NetworkID the challenge is issued for — one of the title's configured networks. */
72
+ networkID: string;
73
+ /** Called once the wallet signature has been exchanged for a session. */
74
+ onAuthenticated: () => void;
75
+ disabled?: boolean;
76
+ label?: string;
77
+ style?: CSSProperties;
78
+ }
79
+ /**
80
+ * Ready-made "sign in with wallet" button for **Solana** titles: connect → sign the challenge →
81
+ * session. The EVM twin is {@link WalletLogin}; a title is one or the other.
82
+ *
83
+ * Unlike the EVM button this needs no provider wrapper — AppKit is a global instance created by
84
+ * `createSolanaWalletConfig`, and the wallet is read through its hooks.
85
+ *
86
+ * Connecting and signing are one action for the player, but on a phone they are separated by an app
87
+ * switch: `appKit.open()` returns as soon as the modal is on screen, long before a wallet is picked
88
+ * and the deep-link round trip completes. So the click only *arms* the flow, and an effect fires the
89
+ * signature once the account actually appears — no polling, no second tap.
90
+ */
91
+ declare function SolanaWalletLogin(props: SolanaWalletLoginProps): ReactNode;
92
+
93
+ export { AppKitSolanaNetwork, type SolanaBridge, type SolanaWalletConfigOptions, SolanaWalletLogin, type SolanaWalletLoginProps, createSolanaWalletConfig, useSolanaBridge };
@@ -0,0 +1 @@
1
+ import {b,a as a$1,c}from'../chunk-ACZSIOFR.js';import {a,b as b$2}from'../chunk-ZL42KPPC.js';import {o,b as b$1,c as c$1}from'../chunk-XFMDEOHO.js';export{p as solanaDevnet,o as solanaMainnet}from'../chunk-XFMDEOHO.js';import {SolanaAdapter}from'@reown/appkit-adapter-solana';import {createAppKit,useAppKitAccount,useAppKitProvider}from'@reown/appkit/react';import {useState,useRef,useCallback,useEffect}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function z(e){let{walletConnectProjectId:a$1,appName:r,appUrl:i,appIcon:s,wallets:t}=e,d=e.networks??[o],n=i??(typeof window<"u"?window.location.origin:""),l={name:r??"iDosGames",description:r??"iDosGames game",url:n,icons:s?[s]:[]},o$1=new SolanaAdapter(t?{wallets:t}:{});return a(createAppKit({adapters:[o$1],networks:d,projectId:a$1,metadata:l,features:{analytics:false,email:false,socials:false}})),o$1}var B="Wallet not connected.";function J(e,a,r){let{address:i}=useAppKitAccount(),{walletProvider:s}=useAppKitProvider("solana"),t=i??null,d=s?.signMessage?.bind(s);return {connected:!!t,account:t,loginWithWallet:(n,l)=>{let o=l??t;return o?d?c({client:e,networkID:n,walletAddress:o,signMessage:d}):Promise.resolve(c$1("sign","The connected wallet does not support message signing.")):Promise.resolve(c$1("challenge",B))},depositToken:n=>a$1({client:e,adapter:r,titleID:a,...n}),withdrawToken:n=>{let l=n.walletAddress??t;return l?b({client:e,adapter:r,...n,walletAddress:l}):Promise.resolve(b$1("request",B))}}}var X=18e4,Y=9e4;function Z(e){try{let r=e?.session?.peer?.metadata?.redirect,i=r?.native||r?.universal;return !i||typeof window>"u"?!1:(window.location.href=i,!0)}catch{return false}}function $(e,a){return new Promise((r,i)=>{let s=setTimeout(()=>i(new Error("The wallet request timed out.")),a);e.then(t=>{clearTimeout(s),r(t);},t=>{clearTimeout(s),i(t instanceof Error?t:new Error(String(t)));});})}function ee(e){let a="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.":a:a}function te(e){let{client:a,networkID:r,onAuthenticated:i,disabled:s,label:t,style:d}=e,{address:n,isConnected:l}=useAppKitAccount(),{walletProvider:o}=useAppKitProvider("solana"),[G,u]=useState(false),[C,p]=useState(null),[b,T]=useState(false),[v,D]=useState(false),g=useRef(null),R=useRef(0),f=useCallback(()=>{g.current&&clearTimeout(g.current),g.current=null;},[]);useEffect(()=>f,[f]);let y=useCallback(async()=>{let m=++R.current,k=()=>R.current===m,I=o?.signMessage?.bind(o);if(!n||!I){p("The connected wallet cannot sign messages."),u(false);return}u(true),p(null);try{D(!0);let c$1=await $(c({client:a,networkID:r,walletAddress:n,signMessage:I}),Y);if(!k())return;if(c$1.ok){i();return}p(c$1.stage==="sign"?"Signature declined.":c$1.error??"Wallet sign-in failed.");}catch(c){if(!k())return;console.error("[idosgames/wallet] solana sign-in failed:",c),p(ee(c));}finally{k()&&(u(false),D(false));}},[n,o,a,r,i]),_=useCallback(()=>{Z(o)||b$2()?.open();},[o]);return useEffect(()=>{!b||!l||!n||!o||(T(false),f(),y());},[b,l,n,o,y,f]),jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{if(v){_();return}if(p(null),l&&n&&o){y();return}let m=b$2();if(!m){p("Wallet sign-in is not configured for this title.");return}u(true),T(true),f(),g.current=setTimeout(()=>{T(false),u(false),p("No wallet was connected.");},X),m.open();},disabled:s,style:{...ne,...s?{opacity:.6,cursor:"default"}:null,...d},children:v?"Waiting for signature \u2014 tap to open wallet":G?"Check your wallet\u2026":l?t??"Sign in with wallet":"Connect wallet"}),C&&jsx("span",{role:"alert",style:oe,children:C})]})}var ne={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{te as SolanaWalletLogin,z as createSolanaWalletConfig,J as useSolanaBridge};