@idosgames/wallet 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -14
- package/dist/chunk-3VONNSCN.js +1 -0
- package/dist/chunk-FFBRTCQK.js +1 -0
- package/dist/chunk-QST6UVX7.js +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +56 -2
- package/dist/index.d.ts +56 -2
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +9 -1
- package/dist/react/index.d.ts +9 -1
- package/dist/react/index.js +1 -1
- package/dist/react/lazyIndex.cjs +2 -2
- package/dist/react/lazyIndex.d.cts +11 -3
- package/dist/react/lazyIndex.d.ts +11 -3
- package/dist/react/lazyIndex.js +1 -1
- package/dist/react/solanaIndex.cjs +2 -2
- package/dist/react/solanaIndex.d.cts +9 -1
- package/dist/react/solanaIndex.d.ts +9 -1
- package/dist/react/solanaIndex.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-2PEE5F3U.js +0 -1
- package/dist/chunk-RTP7IL25.js +0 -1
package/README.md
CHANGED
|
@@ -253,20 +253,30 @@ Recovery rules (the bridge never double-charges, but you drive the retry):
|
|
|
253
253
|
|
|
254
254
|
## Embedded in an idosgames.com iframe
|
|
255
255
|
|
|
256
|
-
A game embedded in an idosgames.com iframe cannot
|
|
257
|
-
its own — deposit/withdraw goes through the site's
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
256
|
+
A game embedded in an idosgames.com iframe cannot reach the player's wallet on
|
|
257
|
+
its own — deposit/withdraw goes through the buttons in the site's wallet card
|
|
258
|
+
next to the game. The `@idosgames/wallet/react/lazy` components handle this by
|
|
259
|
+
themselves:
|
|
260
|
+
|
|
261
|
+
- **`LazyWalletLogin` / `LazySolanaWalletLogin`** stay a normal "Sign in with
|
|
262
|
+
wallet" button. Inside the platform's frame the tap goes to
|
|
263
|
+
`loginWithWalletViaPlatform`: the SITE's already-connected wallet signs the
|
|
264
|
+
engine's login message (the site connects one first if needed), so the
|
|
265
|
+
wallet prompt comes from idosgames.com, and the game exchanges the signature
|
|
266
|
+
for a session as usual. The site signs nothing but the engine's login
|
|
267
|
+
template for its own page's title. (2026-09-23 — before that the button was
|
|
268
|
+
replaced by a notice and wallet sign-in inside the frame was simply gone.)
|
|
269
|
+
- **`LazyWalletPanel`** renders nothing in a frame — no notice either.
|
|
270
|
+
- Embedded on somebody else's site through `idosgames.com/embed/{id}` (two
|
|
271
|
+
frames deep, `isEmbeddedOnForeignSite()`) the sign-in button renders nothing
|
|
272
|
+
too: that page has no wallet of ours to sign with.
|
|
273
|
+
|
|
274
|
+
Every bridge and login flow that talks to the wallet directly
|
|
275
|
+
(`depositTokenEvm`, `withdrawTokenEvm`, `loginWithWalletEvm`, their Solana
|
|
276
|
+
equivalents, `payWithWalletEvm`) refuses with `error: WALLET_USE_SITE_PANEL` if
|
|
277
|
+
called inside a frame anyway, so a game that rolls its own UI can check
|
|
278
|
+
`isEmbeddedInPlatform()` up front — and call `loginWithWalletViaPlatform({
|
|
279
|
+
client, networkID, family: "evm" | "solana" })` for sign-in:
|
|
270
280
|
|
|
271
281
|
```ts
|
|
272
282
|
import {
|
|
@@ -287,6 +297,28 @@ const unsubscribe = onWalletBalanceChanged(() => {
|
|
|
287
297
|
A game opened by its own direct link (not embedded) is unaffected — every flow
|
|
288
298
|
works exactly as before there.
|
|
289
299
|
|
|
300
|
+
## Linking a wallet (play access by token balance)
|
|
301
|
+
|
|
302
|
+
When a title's login mode requires a token balance (`cfg.Blockchain.PlayAccess`,
|
|
303
|
+
`AnyWithLinkedWallet`), a player who signed in by e-mail or through the site
|
|
304
|
+
attaches a wallet to the account by signature — not a second login. Every
|
|
305
|
+
sign-in button has a link mode:
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
<LazyWalletLogin
|
|
309
|
+
mode="link"
|
|
310
|
+
client={client}
|
|
311
|
+
networkID="bsc"
|
|
312
|
+
onLinked={(pass) => (pass?.Granted ? enterGame() : showWhyNot(pass))}
|
|
313
|
+
/>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Framework-agnostic: `linkWalletEvm`, `linkWalletSolana`, and
|
|
317
|
+
`linkWalletViaPlatform` (inside the idosgames.com frame — the site's wallet
|
|
318
|
+
signs). The server checks the balance against exactly the linked wallet and
|
|
319
|
+
returns the pass as `data.PlayAccess`. The host template wires this into its
|
|
320
|
+
play-access screen already (`renderWalletLink` in `src/walletLogin.tsx`).
|
|
321
|
+
|
|
290
322
|
## Framework-agnostic core
|
|
291
323
|
|
|
292
324
|
Not on React? Import the same flows from `@idosgames/wallet` and pass viem
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c as c$1}from'./chunk-IEWZH6XD.js';import {isPlatformParentOrigin,PLATFORM_ORIGINS}from'@idosgames/core';var c={addressRequest:"IDOS_PLATFORM_WALLET_ADDRESS_REQUEST",addressResponse:"IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE",signRequest:"IDOS_PLATFORM_WALLET_SIGN_REQUEST",signResponse:"IDOS_PLATFORM_WALLET_SIGN_RESPONSE",ack:"IDOS_PLATFORM_WALLET_ACK"},m="PLATFORM_WALLET_UNAVAILABLE",P=5e3,S=18e4;function T(){let r=[...PLATFORM_ORIGINS],t=window.location.ancestorOrigins?.[0];return t&&!r.includes(t)&&isPlatformParentOrigin(t)&&r.push(t),r}function R(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function L(r,t,i){if(typeof window>"u"||window.self===window.top)return Promise.resolve({ok:false,error:m});let s=window.parent;if(!s)return Promise.resolve({ok:false,error:m});let e=R();return new Promise(f=>{let l=false,a,g=o=>{l||(l=true,window.removeEventListener("message",u),clearTimeout(a),f(o));},u=o=>{if(!isPlatformParentOrigin(o.origin))return;let n=o.data;if(!(!n||n.requestId!==e)){if(n.type===c.ack){clearTimeout(a),a=setTimeout(()=>g({ok:false,error:"TIMEOUT"}),S);return}n.type===t&&g({ok:n.ok===true,error:typeof n.error=="string"?n.error:void 0,address:typeof n.address=="string"?n.address:void 0,signature:typeof n.signature=="string"?n.signature:void 0});}};a=setTimeout(()=>g({ok:false,error:m}),P),window.addEventListener("message",u);for(let o of T())try{s.postMessage({type:r,requestId:e,...i},o);}catch{}})}async function p(r){let{client:t,networkID:i}=r;return k(r,async s=>{let e=await t.auth.requestWalletChallenge(s,i);return e.ok?{ok:true,message:e.data.Message}:{ok:false,error:e.error}},(s,e)=>t.auth.loginWithWallet(s,i,e))}async function E(r){let{client:t,networkID:i}=r;return k(r,async s=>{let e=await t.auth.linkWallet(s,i);return e.ok?e.data.Challenge?{ok:true,message:e.data.Challenge}:{ok:false,error:"No challenge was issued."}:{ok:false,error:e.error}},(s,e)=>t.auth.linkWallet(s,i,e))}async function k(r,t,i){let{client:s,family:e}=r,f=s.titleID,l=await L(c.addressRequest,c.addressResponse,{titleID:f,family:e});if(!l.ok||!l.address)return c$1("challenge",l.error??"NO_WALLET");let a=l.address,g=await t(a);if(!g.ok)return c$1("challenge",g.error);let u=await L(c.signRequest,c.signResponse,{titleID:f,family:e,address:a,message:g.message});if(!u.ok||!u.signature)return c$1("sign",u.error??"SIGN_FAILED");let o=await i(a,u.signature);return o.ok?{ok:true,data:o.data}:c$1("login",o.error)}export{c as a,m as b,p as c,E as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {e,g,b,a,h as h$1,c}from'./chunk-IEWZH6XD.js';import {encodeAbiParameters,parseUnits}from'viem';import {normalizeBlockchainCategory}from'@idosgames/core';var k=[{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:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],I=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],v=[{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"}]}],E=[{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"}]}],x=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]}];function D(e,t,n){return encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[e,t,normalizeBlockchainCategory(n)])}async function h(e,t){let{walletClient:n,publicClient:r,account:s}=e,o=await n.writeContract({address:t.address,abi:t.abi,functionName:t.functionName,args:t.args,account:s,chain:n.chain,value:t.value});if((await r.waitForTransactionReceipt({hash:o})).status==="reverted")throw new Error(`On-chain transaction reverted (${o}).`);return o}function T(e){let t=e.RewardPoolAddress;return t||null}async function W(e,t,n,r){return await e.publicClient.readContract({address:t,abi:v,functionName:"allowance",args:[e.account,n]})>=r?null:h(e,{address:t,abi:v,functionName:"approve",args:[n,r]})}async function N(e$1){let{client:t,clients:n,network:r,tokenAddress:s,amount:o,titleID:m,category:d}=e$1;if(e())return g("approve");let i=t.auth.context?.userID;if(!i)return b("approve","Not logged in.");let u=T(r);if(!u)return b("approve","Network has no RewardPoolAddress.");if(o<=0n)return b("approve","Amount must be positive.");try{await W(n,s,u,o);}catch(l){return b("approve",a(l))}let c;try{c=await h(n,{address:u,abi:k,functionName:"depositERC20",args:[s,o,i,m,d??""]});}catch(l){return b("deposit-onchain",a(l))}let p=await t.blockchain.depositToken(r.NetworkID??"",c);return p.ok?{ok:true,onChainTxHash:c,data:p.data}:b("report",p.error,{onChainTxHash:c})}async function S(e$1){let{clients:t,poolAddress:n,tokenAddress:r,amount:s,userID:o,titleID:m,category:d}=e$1;if(e())return g("approve");if(!o)return b("approve","userID is required.");if(s<=0n)return b("approve","Amount must be positive.");try{await W(t,r,n,s);}catch(i){return b("approve",a(i))}try{let i=await h(t,{address:n,abi:k,functionName:"depositERC20",args:[r,s,o,m,d??""]});return {ok:!0,onChainTxHash:i,data:{txHash:i}}}catch(i){return b("deposit-onchain",a(i))}}async function L(e$1){let{client:t,clients:n,network:r,nftContractAddress:s,tokenId:o,amount:m,titleID:d,category:i}=e$1;if(e())return g("deposit-onchain");let u=t.auth.context?.userID;if(!u)return b("deposit-onchain","Not logged in.");let c=T(r);if(!c)return b("deposit-onchain","Network has no RewardPoolAddress.");if(m<=0n)return b("deposit-onchain","Amount must be positive.");let p=D(u,d,i),l;try{l=await h(n,{address:s,abi:E,functionName:"safeTransferFrom",args:[n.account,c,o,m,p]});}catch(A){return b("deposit-onchain",a(A))}let f=await t.blockchain.depositNFT(r.NetworkID??"",l);return f.ok?{ok:true,onChainTxHash:l,data:f.data}:b("report",f.error,{onChainTxHash:l})}async function O(e$1){let{client:t,clients:n,network:r,nftContractAddress:s,tokenId:o,titleID:m,category:d}=e$1;if(e())return g("deposit-onchain");let i=t.auth.context?.userID;if(!i)return b("deposit-onchain","Not logged in.");let u=T(r);if(!u)return b("deposit-onchain","Network has no RewardPoolAddress.");let c=D(i,m,d),p;try{p=await h(n,{address:s,abi:x,functionName:"safeTransferFrom",args:[n.account,u,o,c]});}catch(f){return b("deposit-onchain",a(f))}let l=await t.blockchain.depositNFT(r.NetworkID??"",p);return l.ok?{ok:true,onChainTxHash:p,data:l.data}:b("report",l.error,{onChainTxHash:p})}function P(e){return (e.Splits??[]).map(t=>({to:t.To,amount:BigInt(t.Amount??"0")}))}async function B(e,t){return h(e,{address:t.ContractAddress,abi:k,functionName:"withdrawERC20",args:[t.TokenAddress,t.WalletAddress,BigInt(t.Amount??"0"),BigInt(t.BurnAmount??"0"),P(t),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function R(e,t){return h(e,{address:t.ContractAddress,abi:I,functionName:"withdrawERC1155Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Amount??"0"),P(t),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function q(e,t){return h(e,{address:t.ContractAddress,abi:I,functionName:"withdrawERC721Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function U(e$1){let{client:t,clients:n,currencyID:r,networkID:s,walletAddress:o,amount:m,category:d}=e$1;if(e())return g("request");let i=await t.blockchain.requestTokenWithdrawal(r,s,o,m,d);if(!i.ok)return b("request",i.error);let u=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!u)return b("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let p;try{p=await B(n,u);}catch(f){return b("withdraw-onchain",a(f),{titleTransactionID:c})}let l=await H(t,c,p);return l.ok?{ok:true,onChainTxHash:p,data:i.data}:l}async function $(e$1){let{client:t,clients:n,itemID:r,networkID:s,walletAddress:o,amount:m,category:d}=e$1;if(e())return g("request");let i=await t.blockchain.requestNFTWithdrawal(r,s,o,m,d);if(!i.ok)return b("request",i.error);let u=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!u)return b("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let p;try{p=await R(n,u);}catch(f){return b("withdraw-onchain",a(f),{titleTransactionID:c})}let l=await H(t,c,p);return l.ok?{ok:true,onChainTxHash:p,data:i.data}:l}async function H(e,t,n){if(!t)return b("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await e.blockchain.confirmWithdrawal(t,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:b("confirm",r.error,{onChainTxHash:n,titleTransactionID:t})}async function V(e$1){let{client:t,clients:n,networkID:r}=e$1;if(e())return h$1("challenge");let s=e$1.walletAddress??n.account,o=await t.auth.requestWalletChallenge(s,r);if(!o.ok)return c("challenge",o.error);let m;try{m=await n.walletClient.signMessage({account:n.account,message:o.data.Message});}catch(i){return c("sign",a(i))}let d=await t.auth.loginWithWallet(s,r,m);return d.ok?{ok:true,data:d.data}:c("login",d.error)}async function z(e$1){let{client:t,clients:n,networkID:r}=e$1;if(e())return h$1("challenge");let s=e$1.walletAddress??n.account,o=await t.auth.linkWallet(s,r);if(!o.ok)return c("challenge",o.error);if(!o.data.Challenge)return c("challenge","No challenge was issued.");let m;try{m=await n.walletClient.signMessage({account:n.account,message:o.data.Challenge});}catch(i){return c("sign",a(i))}let d=await t.auth.linkWallet(s,r,m);return d.ok?{ok:true,data:d.data}:c("login",d.error)}async function J(e$1){let{client:t,clients:n,network:r,tokenAddress:s,decimals:o,titleID:m,shortfall:d,completePurchase:i,bufferRatio:u=0,category:c}=e$1;if(e())return g("approve");if(d.missing<=0)return b("approve","Nothing to deposit.");let p=d.missing*(1+Math.max(0,u)),l;try{l=parseUnits(K(p,o),o);}catch(F){return b("approve",a(F))}let f=await N({client:t,clients:n,network:r,tokenAddress:s,amount:l,titleID:m,category:c});if(!f.ok)return f;let A=await i();return A.ok?{ok:true,onChainTxHash:f.onChainTxHash,data:A.data}:b("report",A.error,{onChainTxHash:f.onChainTxHash})}function K(e,t){return e.toFixed(Math.min(t,18)).replace(/0+$/,"").replace(/\.$/,"")||"0"}export{k as a,v as b,E as c,x as d,D as e,h as f,W as g,N as h,S as i,L as j,O as k,B as l,R as m,q as n,U as o,$ as p,V as q,z as r,J as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {e,g,b,a,h,c}from'./chunk-IEWZH6XD.js';import {normalizeBlockchainCategory}from'@idosgames/core';async function T(i){let{client:t,adapter:n,network:s,mint:d,amountRaw:a$1,titleID:l,category:r}=i;if(e())return g("deposit-onchain");let e$1=t.auth.context?.userID;if(!e$1)return b("deposit-onchain","Not logged in.");if(a$1<=0n)return b("deposit-onchain","Amount must be positive.");let u;try{u=await n.depositSpl({mint:d,amountRaw:a$1,userID:e$1,titleID:l,category:normalizeBlockchainCategory(r)});}catch(m){return b("deposit-onchain",a(m))}let c=await t.blockchain.depositToken(s.NetworkID??"",u);return c.ok?{ok:true,onChainTxHash:u,data:c.data}:b("report",c.error,{onChainTxHash:u})}async function D(i){let{client:t,adapter:n,currencyID:s,networkID:d,walletAddress:a$1,amount:l,category:r}=i;if(e())return g("request");let e$1=await t.blockchain.requestTokenWithdrawal(s,d,a$1,l,r);if(!e$1.ok)return b("request",e$1.error);let u=e$1.data.SolanaSignature,c=e$1.data.TitleTransactionID??void 0;if(!u)return b("request","Withdrawal response carried no Solana signature.",{titleTransactionID:c});let m;try{m=await n.submitWithdrawal(u);}catch(W){return b("withdraw-onchain",a(W),{titleTransactionID:c})}if(!c)return b("confirm","Missing TitleTransactionID.",{onChainTxHash:m});let w=await t.blockchain.confirmWithdrawal(c,m);return w.ok?{ok:true,onChainTxHash:m,data:e$1.data}:b("confirm",w.error,{onChainTxHash:m,titleTransactionID:c})}async function x(i){let{client:t,networkID:n,walletAddress:s,signMessage:d}=i;if(e())return h("challenge");let a$1=await t.auth.requestWalletChallenge(s,n);if(!a$1.ok)return c("challenge",a$1.error);let l;try{let e=await d(new TextEncoder().encode(a$1.data.Message));l=S(e);}catch(e){return c("sign",a(e))}let r=await t.auth.loginWithWallet(s,n,l);return r.ok?{ok:true,data:r.data}:c("login",r.error)}async function I(i){let{client:t,networkID:n,walletAddress:s,signMessage:d}=i;if(e())return h("challenge");let a$1=await t.auth.linkWallet(s,n);if(!a$1.ok)return c("challenge",a$1.error);if(!a$1.data.Challenge)return c("challenge","No challenge was issued.");let l;try{let e=await d(new TextEncoder().encode(a$1.data.Challenge));l=S(e);}catch(e){return c("sign",a(e))}let r=await t.auth.linkWallet(s,n,l);return r.ok?{ok:true,data:r.data}:c("login",r.error)}function S(i){let t="0x";for(let n of i)t+=n.toString(16).padStart(2,"0");return t}export{T as a,D as b,x as c,I as d};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var viem=require('viem'),core=require('@idosgames/core');function g(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function a(t,e,n){return {ok:false,stage:t,error:e,...n}}function w(t,e){return {ok:false,stage:t,error:e}}var D="WALLET_USE_SITE_PANEL";function f(){if(typeof window>"u")return false;try{return window.self!==window.top}catch{return true}}function G(){if(typeof window>"u")return false;try{return window.parent!==window.top}catch{return true}}function h(t){return a(t,D)}function E(t){return w(t,D)}var O=core.PLATFORM_ORIGINS;function U(t){if(typeof window>"u")return ()=>{};let e=n=>{O.includes(n.origin)&&n.data?.type==="IDOS_WALLET_BALANCE_CHANGED"&&t();};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}var q={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"}}},_={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"}}},K={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"}}},$={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"}}},z={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"}}},V={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"}}},Z={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"}}},J={mainnet:q,bsc:_,polygon:K,base:Y,arbitrum:$,optimism:z,sepolia:V,polygonAmoy:Z};function ke(t){return Object.values(J).find(e=>e.id===t)}function be(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}var xe={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"},Ee={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 b=[{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:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],T=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],A=[{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"}]}],v=[{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"}]}],I=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]}];function C(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}async function k(t,e){let{walletClient:n,publicClient:o,account:l}=t,i=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:l,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:i})).status==="reverted")throw new Error(`On-chain transaction reverted (${i}).`);return i}function W(t){let e=t.RewardPoolAddress;return e||null}async function N(t,e,n,o){return await t.publicClient.readContract({address:e,abi:A,functionName:"allowance",args:[t.account,n]})>=o?null:k(t,{address:e,abi:A,functionName:"approve",args:[n,o]})}async function B(t){let{client:e,clients:n,network:o,tokenAddress:l,amount:i,titleID:c,category:p}=t;if(f())return h("approve");let r=e.auth.context?.userID;if(!r)return a("approve","Not logged in.");let m=W(o);if(!m)return a("approve","Network has no RewardPoolAddress.");if(i<=0n)return a("approve","Amount must be positive.");try{await N(n,l,m,i);}catch(u){return a("approve",g(u))}let s;try{s=await k(n,{address:m,abi:b,functionName:"depositERC20",args:[l,i,r,c,p??""]});}catch(u){return a("deposit-onchain",g(u))}let d=await e.blockchain.depositToken(o.NetworkID??"",s);return d.ok?{ok:true,onChainTxHash:s,data:d.data}:a("report",d.error,{onChainTxHash:s})}async function X(t){let{clients:e,poolAddress:n,tokenAddress:o,amount:l,userID:i,titleID:c,category:p}=t;if(f())return h("approve");if(!i)return a("approve","userID is required.");if(l<=0n)return a("approve","Amount must be positive.");try{await N(e,o,n,l);}catch(r){return a("approve",g(r))}try{let r=await k(e,{address:n,abi:b,functionName:"depositERC20",args:[o,l,i,c,p??""]});return {ok:!0,onChainTxHash:r,data:{txHash:r}}}catch(r){return a("deposit-onchain",g(r))}}async function ee(t){let{client:e,clients:n,network:o,nftContractAddress:l,tokenId:i,amount:c,titleID:p,category:r}=t;if(f())return h("deposit-onchain");let m=e.auth.context?.userID;if(!m)return a("deposit-onchain","Not logged in.");let s=W(o);if(!s)return a("deposit-onchain","Network has no RewardPoolAddress.");if(c<=0n)return a("deposit-onchain","Amount must be positive.");let d=C(m,p,r),u;try{u=await k(n,{address:l,abi:v,functionName:"safeTransferFrom",args:[n.account,s,i,c,d]});}catch(x){return a("deposit-onchain",g(x))}let y=await e.blockchain.depositNFT(o.NetworkID??"",u);return y.ok?{ok:true,onChainTxHash:u,data:y.data}:a("report",y.error,{onChainTxHash:u})}async function te(t){let{client:e,clients:n,network:o,nftContractAddress:l,tokenId:i,titleID:c,category:p}=t;if(f())return h("deposit-onchain");let r=e.auth.context?.userID;if(!r)return a("deposit-onchain","Not logged in.");let m=W(o);if(!m)return a("deposit-onchain","Network has no RewardPoolAddress.");let s=C(r,c,p),d;try{d=await k(n,{address:l,abi:I,functionName:"safeTransferFrom",args:[n.account,m,i,s]});}catch(y){return a("deposit-onchain",g(y))}let u=await e.blockchain.depositNFT(o.NetworkID??"",d);return u.ok?{ok:true,onChainTxHash:d,data:u.data}:a("report",u.error,{onChainTxHash:d})}function P(t){return (t.Splits??[]).map(e=>({to:e.To,amount:BigInt(e.Amount??"0")}))}async function S(t,e){return k(t,{address:e.ContractAddress,abi:b,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),P(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function R(t,e){return k(t,{address:e.ContractAddress,abi:T,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),P(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function ne(t,e){return k(t,{address:e.ContractAddress,abi:T,functionName:"withdrawERC721Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function ae(t){let{client:e,clients:n,currencyID:o,networkID:l,walletAddress:i,amount:c,category:p}=t;if(f())return h("request");let r=await e.blockchain.requestTokenWithdrawal(o,l,i,c,p);if(!r.ok)return a("request",r.error);let m=r.data.EvmSignature,s=r.data.TitleTransactionID??void 0;if(!m)return a("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let d;try{d=await S(n,m);}catch(y){return a("withdraw-onchain",g(y),{titleTransactionID:s})}let u=await F(e,s,d);return u.ok?{ok:true,onChainTxHash:d,data:r.data}:u}async function re(t){let{client:e,clients:n,itemID:o,networkID:l,walletAddress:i,amount:c,category:p}=t;if(f())return h("request");let r=await e.blockchain.requestNFTWithdrawal(o,l,i,c,p);if(!r.ok)return a("request",r.error);let m=r.data.EvmSignature,s=r.data.TitleTransactionID??void 0;if(!m)return a("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let d;try{d=await R(n,m);}catch(y){return a("withdraw-onchain",g(y),{titleTransactionID:s})}let u=await F(e,s,d);return u.ok?{ok:true,onChainTxHash:d,data:r.data}:u}async function F(t,e,n){if(!e)return a("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:a("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}async function oe(t){let{client:e,clients:n,networkID:o}=t;if(f())return E("challenge");let l=t.walletAddress??n.account,i=await e.auth.requestWalletChallenge(l,o);if(!i.ok)return w("challenge",i.error);let c;try{c=await n.walletClient.signMessage({account:n.account,message:i.data.Message});}catch(r){return w("sign",g(r))}let p=await e.auth.loginWithWallet(l,o,c);return p.ok?{ok:true,data:p.data}:w("login",p.error)}async function se(t){let{client:e,clients:n,network:o,tokenAddress:l,decimals:i,titleID:c,shortfall:p,completePurchase:r,bufferRatio:m=0,category:s}=t;if(f())return h("approve");if(p.missing<=0)return a("approve","Nothing to deposit.");let d=p.missing*(1+Math.max(0,m)),u;try{u=viem.parseUnits(le(d,i),i);}catch(L){return a("approve",g(L))}let y=await B({client:e,clients:n,network:o,tokenAddress:l,amount:u,titleID:c,category:s});if(!y.ok)return y;let x=await r();return x.ok?{ok:true,onChainTxHash:y.onChainTxHash,data:x.data}:a("report",x.error,{onChainTxHash:y.onChainTxHash})}function le(t,e){return t.toFixed(Math.min(e,18)).replace(/0+$/,"").replace(/\.$/,"")||"0"}async function pe(t){let{client:e,adapter:n,network:o,mint:l,amountRaw:i,titleID:c,category:p}=t;if(f())return h("deposit-onchain");let r=e.auth.context?.userID;if(!r)return a("deposit-onchain","Not logged in.");if(i<=0n)return a("deposit-onchain","Amount must be positive.");let m;try{m=await n.depositSpl({mint:l,amountRaw:i,userID:r,titleID:c,category:core.normalizeBlockchainCategory(p)});}catch(d){return a("deposit-onchain",g(d))}let s=await e.blockchain.depositToken(o.NetworkID??"",m);return s.ok?{ok:true,onChainTxHash:m,data:s.data}:a("report",s.error,{onChainTxHash:m})}async function ce(t){let{client:e,adapter:n,currencyID:o,networkID:l,walletAddress:i,amount:c,category:p}=t;if(f())return h("request");let r=await e.blockchain.requestTokenWithdrawal(o,l,i,c,p);if(!r.ok)return a("request",r.error);let m=r.data.SolanaSignature,s=r.data.TitleTransactionID??void 0;if(!m)return a("request","Withdrawal response carried no Solana signature.",{titleTransactionID:s});let d;try{d=await n.submitWithdrawal(m);}catch(y){return a("withdraw-onchain",g(y),{titleTransactionID:s})}if(!s)return a("confirm","Missing TitleTransactionID.",{onChainTxHash:d});let u=await e.blockchain.confirmWithdrawal(s,d);return u.ok?{ok:true,onChainTxHash:d,data:r.data}:a("confirm",u.error,{onChainTxHash:d,titleTransactionID:s})}async function me(t){let{client:e,networkID:n,walletAddress:o,signMessage:l}=t;if(f())return E("challenge");let i=await e.auth.requestWalletChallenge(o,n);if(!i.ok)return w("challenge",i.error);let c;try{let r=await l(new TextEncoder().encode(i.data.Message));c=ue(r);}catch(r){return w("sign",g(r))}let p=await e.auth.loginWithWallet(o,n,c);return p.ok?{ok:true,data:p.data}:w("login",p.error)}function ue(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}
|
|
2
|
-
exports.WALLET_USE_SITE_PANEL=
|
|
1
|
+
'use strict';var viem=require('viem'),core=require('@idosgames/core');function f(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 g(t,e){return {ok:false,stage:t,error:e}}var C="WALLET_USE_SITE_PANEL";function y(){if(typeof window>"u")return false;try{return window.self!==window.top}catch{return true}}function K(){if(typeof window>"u")return false;try{return window.parent!==window.top}catch{return true}}function w(t){return s(t,C)}function A(t){return g(t,C)}var $=core.PLATFORM_ORIGINS;function Y(t){if(typeof window>"u")return ()=>{};let e=n=>{$.includes(n.origin)&&n.data?.type==="IDOS_WALLET_BALANCE_CHANGED"&&t();};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}var E={addressRequest:"IDOS_PLATFORM_WALLET_ADDRESS_REQUEST",addressResponse:"IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE",signRequest:"IDOS_PLATFORM_WALLET_SIGN_REQUEST",signResponse:"IDOS_PLATFORM_WALLET_SIGN_RESPONSE",ack:"IDOS_PLATFORM_WALLET_ACK"},T="PLATFORM_WALLET_UNAVAILABLE",Z=5e3,J=18e4;function Q(){let t=[...core.PLATFORM_ORIGINS],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&core.isPlatformParentOrigin(e)&&t.push(e),t}function j(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function R(t,e,n){if(typeof window>"u"||window.self===window.top)return Promise.resolve({ok:false,error:T});let r=window.parent;if(!r)return Promise.resolve({ok:false,error:T});let o=j();return new Promise(i=>{let p=false,l,a=d=>{p||(p=true,window.removeEventListener("message",u),clearTimeout(l),i(d));},u=d=>{if(!core.isPlatformParentOrigin(d.origin))return;let c=d.data;if(!(!c||c.requestId!==o)){if(c.type===E.ack){clearTimeout(l),l=setTimeout(()=>a({ok:false,error:"TIMEOUT"}),J);return}c.type===e&&a({ok:c.ok===true,error:typeof c.error=="string"?c.error:void 0,address:typeof c.address=="string"?c.address:void 0,signature:typeof c.signature=="string"?c.signature:void 0});}};l=setTimeout(()=>a({ok:false,error:T}),Z),window.addEventListener("message",u);for(let d of Q())try{r.postMessage({type:t,requestId:o,...n},d);}catch{}})}async function X(t){let{client:e,networkID:n}=t;return F(t,async r=>{let o=await e.auth.requestWalletChallenge(r,n);return o.ok?{ok:true,message:o.data.Message}:{ok:false,error:o.error}},(r,o)=>e.auth.loginWithWallet(r,n,o))}async function ee(t){let{client:e,networkID:n}=t;return F(t,async r=>{let o=await e.auth.linkWallet(r,n);return o.ok?o.data.Challenge?{ok:true,message:o.data.Challenge}:{ok:false,error:"No challenge was issued."}:{ok:false,error:o.error}},(r,o)=>e.auth.linkWallet(r,n,o))}async function F(t,e,n){let{client:r,family:o}=t,i=r.titleID,p=await R(E.addressRequest,E.addressResponse,{titleID:i,family:o});if(!p.ok||!p.address)return g("challenge",p.error??"NO_WALLET");let l=p.address,a=await e(l);if(!a.ok)return g("challenge",a.error);let u=await R(E.signRequest,E.signResponse,{titleID:i,family:o,address:l,message:a.message});if(!u.ok||!u.signature)return g("sign",u.error??"SIGN_FAILED");let d=await n(l,u.signature);return d.ok?{ok:true,data:d.data}:g("login",d.error)}var te={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"}}},ne={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"}}},ae={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"}}},re={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"}}},oe={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"}}},ie={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"}}},se={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"}}},le={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"}}},de={mainnet:te,bsc:ne,polygon:ae,base:re,arbitrum:oe,optimism:ie,sepolia:se,polygonAmoy:le};function Fe(t){return Object.values(de).find(e=>e.id===t)}function Me(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}var He={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"},Oe={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 b=[{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:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],D=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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"}]}],v=[{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"}]}],P=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]}];function I(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}async function k(t,e){let{walletClient:n,publicClient:r,account:o}=t,i=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:i})).status==="reverted")throw new Error(`On-chain transaction reverted (${i}).`);return i}function S(t){let e=t.RewardPoolAddress;return e||null}async function L(t,e,n,r){return await t.publicClient.readContract({address:e,abi:x,functionName:"allowance",args:[t.account,n]})>=r?null:k(t,{address:e,abi:x,functionName:"approve",args:[n,r]})}async function N(t){let{client:e,clients:n,network:r,tokenAddress:o,amount:i,titleID:p,category:l}=t;if(y())return w("approve");let a=e.auth.context?.userID;if(!a)return s("approve","Not logged in.");let u=S(r);if(!u)return s("approve","Network has no RewardPoolAddress.");if(i<=0n)return s("approve","Amount must be positive.");try{await L(n,o,u,i);}catch(m){return s("approve",f(m))}let d;try{d=await k(n,{address:u,abi:b,functionName:"depositERC20",args:[o,i,a,p,l??""]});}catch(m){return s("deposit-onchain",f(m))}let c=await e.blockchain.depositToken(r.NetworkID??"",d);return c.ok?{ok:true,onChainTxHash:d,data:c.data}:s("report",c.error,{onChainTxHash:d})}async function ue(t){let{clients:e,poolAddress:n,tokenAddress:r,amount:o,userID:i,titleID:p,category:l}=t;if(y())return w("approve");if(!i)return s("approve","userID is required.");if(o<=0n)return s("approve","Amount must be positive.");try{await L(e,r,n,o);}catch(a){return s("approve",f(a))}try{let a=await k(e,{address:n,abi:b,functionName:"depositERC20",args:[r,o,i,p,l??""]});return {ok:!0,onChainTxHash:a,data:{txHash:a}}}catch(a){return s("deposit-onchain",f(a))}}async function me(t){let{client:e,clients:n,network:r,nftContractAddress:o,tokenId:i,amount:p,titleID:l,category:a}=t;if(y())return w("deposit-onchain");let u=e.auth.context?.userID;if(!u)return s("deposit-onchain","Not logged in.");let d=S(r);if(!d)return s("deposit-onchain","Network has no RewardPoolAddress.");if(p<=0n)return s("deposit-onchain","Amount must be positive.");let c=I(u,l,a),m;try{m=await k(n,{address:o,abi:v,functionName:"safeTransferFrom",args:[n.account,d,i,p,c]});}catch(W){return s("deposit-onchain",f(W))}let h=await e.blockchain.depositNFT(r.NetworkID??"",m);return h.ok?{ok:true,onChainTxHash:m,data:h.data}:s("report",h.error,{onChainTxHash:m})}async function ge(t){let{client:e,clients:n,network:r,nftContractAddress:o,tokenId:i,titleID:p,category:l}=t;if(y())return w("deposit-onchain");let a=e.auth.context?.userID;if(!a)return s("deposit-onchain","Not logged in.");let u=S(r);if(!u)return s("deposit-onchain","Network has no RewardPoolAddress.");let d=I(a,p,l),c;try{c=await k(n,{address:o,abi:P,functionName:"safeTransferFrom",args:[n.account,u,i,d]});}catch(h){return s("deposit-onchain",f(h))}let m=await e.blockchain.depositNFT(r.NetworkID??"",c);return m.ok?{ok:true,onChainTxHash:c,data:m.data}:s("report",m.error,{onChainTxHash:c})}function M(t){return (t.Splits??[]).map(e=>({to:e.To,amount:BigInt(e.Amount??"0")}))}async function H(t,e){return k(t,{address:e.ContractAddress,abi:b,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),M(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function O(t,e){return k(t,{address:e.ContractAddress,abi:D,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),M(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function fe(t,e){return k(t,{address:e.ContractAddress,abi:D,functionName:"withdrawERC721Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function ye(t){let{client:e,clients:n,currencyID:r,networkID:o,walletAddress:i,amount:p,category:l}=t;if(y())return w("request");let a=await e.blockchain.requestTokenWithdrawal(r,o,i,p,l);if(!a.ok)return s("request",a.error);let u=a.data.EvmSignature,d=a.data.TitleTransactionID??void 0;if(!u)return s("request","Withdrawal response carried no EVM signature.",{titleTransactionID:d});let c;try{c=await H(n,u);}catch(h){return s("withdraw-onchain",f(h),{titleTransactionID:d})}let m=await _(e,d,c);return m.ok?{ok:true,onChainTxHash:c,data:a.data}:m}async function he(t){let{client:e,clients:n,itemID:r,networkID:o,walletAddress:i,amount:p,category:l}=t;if(y())return w("request");let a=await e.blockchain.requestNFTWithdrawal(r,o,i,p,l);if(!a.ok)return s("request",a.error);let u=a.data.EvmSignature,d=a.data.TitleTransactionID??void 0;if(!u)return s("request","Withdrawal response carried no EVM signature.",{titleTransactionID:d});let c;try{c=await O(n,u);}catch(h){return s("withdraw-onchain",f(h),{titleTransactionID:d})}let m=await _(e,d,c);return m.ok?{ok:true,onChainTxHash:c,data:a.data}:m}async function _(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 we(t){let{client:e,clients:n,networkID:r}=t;if(y())return A("challenge");let o=t.walletAddress??n.account,i=await e.auth.requestWalletChallenge(o,r);if(!i.ok)return g("challenge",i.error);let p;try{p=await n.walletClient.signMessage({account:n.account,message:i.data.Message});}catch(a){return g("sign",f(a))}let l=await e.auth.loginWithWallet(o,r,p);return l.ok?{ok:true,data:l.data}:g("login",l.error)}async function ke(t){let{client:e,clients:n,networkID:r}=t;if(y())return A("challenge");let o=t.walletAddress??n.account,i=await e.auth.linkWallet(o,r);if(!i.ok)return g("challenge",i.error);if(!i.data.Challenge)return g("challenge","No challenge was issued.");let p;try{p=await n.walletClient.signMessage({account:n.account,message:i.data.Challenge});}catch(a){return g("sign",f(a))}let l=await e.auth.linkWallet(o,r,p);return l.ok?{ok:true,data:l.data}:g("login",l.error)}async function Ee(t){let{client:e,clients:n,network:r,tokenAddress:o,decimals:i,titleID:p,shortfall:l,completePurchase:a,bufferRatio:u=0,category:d}=t;if(y())return w("approve");if(l.missing<=0)return s("approve","Nothing to deposit.");let c=l.missing*(1+Math.max(0,u)),m;try{m=viem.parseUnits(be(c,i),i);}catch(U){return s("approve",f(U))}let h=await N({client:e,clients:n,network:r,tokenAddress:o,amount:m,titleID:p,category:d});if(!h.ok)return h;let W=await a();return W.ok?{ok:true,onChainTxHash:h.onChainTxHash,data:W.data}:s("report",W.error,{onChainTxHash:h.onChainTxHash})}function be(t,e){return t.toFixed(Math.min(e,18)).replace(/0+$/,"").replace(/\.$/,"")||"0"}async function Te(t){let{client:e,adapter:n,network:r,mint:o,amountRaw:i,titleID:p,category:l}=t;if(y())return w("deposit-onchain");let a=e.auth.context?.userID;if(!a)return s("deposit-onchain","Not logged in.");if(i<=0n)return s("deposit-onchain","Amount must be positive.");let u;try{u=await n.depositSpl({mint:o,amountRaw:i,userID:a,titleID:p,category:core.normalizeBlockchainCategory(l)});}catch(c){return s("deposit-onchain",f(c))}let d=await e.blockchain.depositToken(r.NetworkID??"",u);return d.ok?{ok:true,onChainTxHash:u,data:d.data}:s("report",d.error,{onChainTxHash:u})}async function xe(t){let{client:e,adapter:n,currencyID:r,networkID:o,walletAddress:i,amount:p,category:l}=t;if(y())return w("request");let a=await e.blockchain.requestTokenWithdrawal(r,o,i,p,l);if(!a.ok)return s("request",a.error);let u=a.data.SolanaSignature,d=a.data.TitleTransactionID??void 0;if(!u)return s("request","Withdrawal response carried no Solana signature.",{titleTransactionID:d});let c;try{c=await n.submitWithdrawal(u);}catch(h){return s("withdraw-onchain",f(h),{titleTransactionID:d})}if(!d)return s("confirm","Missing TitleTransactionID.",{onChainTxHash:c});let m=await e.blockchain.confirmWithdrawal(d,c);return m.ok?{ok:true,onChainTxHash:c,data:a.data}:s("confirm",m.error,{onChainTxHash:c,titleTransactionID:d})}async function Ie(t){let{client:e,networkID:n,walletAddress:r,signMessage:o}=t;if(y())return A("challenge");let i=await e.auth.requestWalletChallenge(r,n);if(!i.ok)return g("challenge",i.error);let p;try{let a=await o(new TextEncoder().encode(i.data.Message));p=G(a);}catch(a){return g("sign",f(a))}let l=await e.auth.loginWithWallet(r,n,p);return l.ok?{ok:true,data:l.data}:g("login",l.error)}async function Ce(t){let{client:e,networkID:n,walletAddress:r,signMessage:o}=t;if(y())return A("challenge");let i=await e.auth.linkWallet(r,n);if(!i.ok)return g("challenge",i.error);if(!i.data.Challenge)return g("challenge","No challenge was issued.");let p;try{let a=await o(new TextEncoder().encode(i.data.Challenge));p=G(a);}catch(a){return g("sign",f(a))}let l=await e.auth.linkWallet(r,n,p);return l.ok?{ok:true,data:l.data}:g("login",l.error)}function G(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}
|
|
2
|
+
exports.PLATFORM_WALLET_MESSAGES=E;exports.PLATFORM_WALLET_UNAVAILABLE=T;exports.WALLET_USE_SITE_PANEL=C;exports.arbitrum=oe;exports.base=re;exports.bridgeFail=s;exports.bsc=ne;exports.chainById=Fe;exports.depositNftEvm=me;exports.depositNftEvm721=ge;exports.depositTokenEvm=N;exports.depositTokenOnChainEvm=ue;exports.depositTokenSolana=Te;exports.encodeNftDepositData=I;exports.ensureErc20Allowance=L;exports.erc1155Abi=v;exports.erc20Abi=x;exports.erc721Abi=P;exports.idosChains=de;exports.isEmbeddedInPlatform=y;exports.isEmbeddedOnForeignSite=K;exports.linkWalletEvm=ke;exports.linkWalletSolana=Ce;exports.linkWalletViaPlatform=ee;exports.loginWithWalletEvm=we;exports.loginWithWalletSolana=Ie;exports.loginWithWalletViaPlatform=X;exports.mainnet=te;exports.onWalletBalanceChanged=Y;exports.optimism=ie;exports.payWithWalletEvm=Ee;exports.polygon=ae;exports.polygonAmoy=le;exports.rewardPoolAbi=b;exports.sepolia=se;exports.solanaDevnet=Oe;exports.solanaMainnet=He;exports.submitEvmNftWithdrawal=O;exports.submitEvmNftWithdrawal721=fe;exports.submitEvmTokenWithdrawal=H;exports.toAppKitNetwork=Me;exports.toErrorMessage=f;exports.walletLoginFail=g;exports.withdrawNftEvm=he;exports.withdrawTokenEvm=ye;exports.withdrawTokenSolana=xe;exports.writeAndWait=k;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { W as WalletLoginResult, B as BridgeResult } from './types-CeUVf1tr.cjs';
|
|
2
2
|
export { a as BridgeFailure, b as BridgeStage, c as BridgeSuccess, d as WalletLoginFailure, e as WalletLoginStage, f as WalletLoginSuccess, g as bridgeFail, t as toErrorMessage, w as walletLoginFail } from './types-CeUVf1tr.cjs';
|
|
3
|
+
import { IDosGamesClient, WalletLinkResponse, ClientState, BlockchainNetworkDefinition, CryptoShortfall, OperationResult } from '@idosgames/core';
|
|
3
4
|
export { A as AppKitEvmNetwork, 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, t as toAppKitNetwork } from './chains-B_P3u8_S.cjs';
|
|
4
5
|
import { Hex, Address } from 'viem';
|
|
5
6
|
import { E as EvmBridgeClients } from './withdraw-C5y67V7i.cjs';
|
|
6
7
|
export { D as DepositNft721EvmParams, a as DepositNftEvmParams, b as DepositTokenEvmParams, c as DepositTokenOnChainParams, W as WithdrawNftEvmParams, d as WithdrawTokenEvmParams, e as depositNftEvm, f as depositNftEvm721, g as depositTokenEvm, h as depositTokenOnChainEvm, i as ensureErc20Allowance, s as submitEvmNftWithdrawal, j as submitEvmNftWithdrawal721, k as submitEvmTokenWithdrawal, w as withdrawNftEvm, l as withdrawTokenEvm, m as writeAndWait } from './withdraw-C5y67V7i.cjs';
|
|
7
|
-
import { IDosGamesClient, ClientState, BlockchainNetworkDefinition, CryptoShortfall, OperationResult } from '@idosgames/core';
|
|
8
8
|
export { D as DepositTokenSolanaParams, S as SolanaProgramAdapter, W as WithdrawTokenSolanaParams, d as depositTokenSolana, w as withdrawTokenSolana } from './bridge-f3pZbjqs.cjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -50,6 +50,45 @@ declare function isEmbeddedOnForeignSite(): boolean;
|
|
|
50
50
|
*/
|
|
51
51
|
declare function onWalletBalanceChanged(callback: () => void): () => void;
|
|
52
52
|
|
|
53
|
+
/** Message names. Shared with `GameWalletLoginBridge` on the website — keep both in step. */
|
|
54
|
+
declare const PLATFORM_WALLET_MESSAGES: {
|
|
55
|
+
readonly addressRequest: "IDOS_PLATFORM_WALLET_ADDRESS_REQUEST";
|
|
56
|
+
readonly addressResponse: "IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE";
|
|
57
|
+
readonly signRequest: "IDOS_PLATFORM_WALLET_SIGN_REQUEST";
|
|
58
|
+
readonly signResponse: "IDOS_PLATFORM_WALLET_SIGN_RESPONSE";
|
|
59
|
+
/** Sent by the site the moment it receives a request — "I am here, the player is choosing". */
|
|
60
|
+
readonly ack: "IDOS_PLATFORM_WALLET_ACK";
|
|
61
|
+
};
|
|
62
|
+
/** Which of the site's wallets signs: its EVM connection or its Solana adapter. */
|
|
63
|
+
type PlatformWalletFamily = "evm" | "solana";
|
|
64
|
+
/**
|
|
65
|
+
* The page around the game did not answer at all — an old site build without the bridge, or a
|
|
66
|
+
* parent that is not the platform. The button shows a plain "not available here" for it.
|
|
67
|
+
*/
|
|
68
|
+
declare const PLATFORM_WALLET_UNAVAILABLE = "PLATFORM_WALLET_UNAVAILABLE";
|
|
69
|
+
interface LoginWithWalletViaPlatformParams {
|
|
70
|
+
/** The (not yet authenticated) shared client. */
|
|
71
|
+
client: IDosGamesClient;
|
|
72
|
+
/** NetworkID (key of cfg.Blockchain.Networks) the wallet proves ownership on. */
|
|
73
|
+
networkID: string;
|
|
74
|
+
/** Which of the site's wallets to use. */
|
|
75
|
+
family: PlatformWalletFamily;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Full wallet sign-in for a game embedded on idosgames.com, signed by the site's own wallet
|
|
79
|
+
* connection. Same result shape and stages as `loginWithWalletEvm` / `loginWithWalletSolana`:
|
|
80
|
+
* `challenge` covers getting the address and the engine's message, `sign` the site's signature,
|
|
81
|
+
* `login` the exchange for a session.
|
|
82
|
+
*/
|
|
83
|
+
declare function loginWithWalletViaPlatform(params: LoginWithWalletViaPlatformParams): Promise<WalletLoginResult<ClientState>>;
|
|
84
|
+
/**
|
|
85
|
+
* Attach a wallet to the LOGGED-IN account inside the idosgames.com frame — the site's wallet signs
|
|
86
|
+
* the engine's link challenge (same message template as login, so the site's check accepts it). Used
|
|
87
|
+
* by the play-access screen of a gated title; `data.PlayAccess` is the pass checked against this
|
|
88
|
+
* wallet.
|
|
89
|
+
*/
|
|
90
|
+
declare function linkWalletViaPlatform(params: LoginWithWalletViaPlatformParams): Promise<WalletLoginResult<WalletLinkResponse>>;
|
|
91
|
+
|
|
53
92
|
declare const rewardPoolAbi: readonly [{
|
|
54
93
|
readonly type: "function";
|
|
55
94
|
readonly name: "depositERC20";
|
|
@@ -375,6 +414,16 @@ interface LoginWithWalletEvmParams {
|
|
|
375
414
|
* A user-rejected signature surfaces as a `{ ok: false, stage: "sign" }` failure, not a throw.
|
|
376
415
|
*/
|
|
377
416
|
declare function loginWithWalletEvm(params: LoginWithWalletEvmParams): Promise<WalletLoginResult<ClientState>>;
|
|
417
|
+
/**
|
|
418
|
+
* Attach a wallet to the LOGGED-IN account by signature — not a login, so no second account is
|
|
419
|
+
* created. Used by the play-access screen of a gated title (`cfg.Blockchain.PlayAccess`): the
|
|
420
|
+
* server then checks the pass against exactly this wallet (`data.PlayAccess`).
|
|
421
|
+
*
|
|
422
|
+
* `client.auth.linkWallet` (no signature) → `personal_sign` the returned challenge →
|
|
423
|
+
* `client.auth.linkWallet` with the signature. Refuses inside the platform iframe — there the
|
|
424
|
+
* site's wallet signs (`linkWalletViaPlatform`).
|
|
425
|
+
*/
|
|
426
|
+
declare function linkWalletEvm(params: LoginWithWalletEvmParams): Promise<WalletLoginResult<WalletLinkResponse>>;
|
|
378
427
|
|
|
379
428
|
interface PayWithWalletParams<T> {
|
|
380
429
|
client: IDosGamesClient;
|
|
@@ -434,5 +483,10 @@ interface LoginWithWalletSolanaParams {
|
|
|
434
483
|
* {@link ClientState} is returned. No on-chain transaction — off-chain proof of ownership only.
|
|
435
484
|
*/
|
|
436
485
|
declare function loginWithWalletSolana(params: LoginWithWalletSolanaParams): Promise<WalletLoginResult<ClientState>>;
|
|
486
|
+
/**
|
|
487
|
+
* Attach a Solana wallet to the LOGGED-IN account by signature (see `linkWalletEvm`): challenge →
|
|
488
|
+
* sign the message bytes → exchange. Refuses inside the platform iframe.
|
|
489
|
+
*/
|
|
490
|
+
declare function linkWalletSolana(params: LoginWithWalletSolanaParams): Promise<WalletLoginResult<WalletLinkResponse>>;
|
|
437
491
|
|
|
438
|
-
export { BridgeResult, EvmBridgeClients, type LoginWithWalletEvmParams, type LoginWithWalletSolanaParams, type PayWithWalletParams, type SolanaMessageSigner, WALLET_USE_SITE_PANEL, WalletLoginResult, encodeNftDepositData, erc1155Abi, erc20Abi, erc721Abi, isEmbeddedInPlatform, isEmbeddedOnForeignSite, loginWithWalletEvm, loginWithWalletSolana, onWalletBalanceChanged, payWithWalletEvm, rewardPoolAbi };
|
|
492
|
+
export { BridgeResult, EvmBridgeClients, type LoginWithWalletEvmParams, type LoginWithWalletSolanaParams, type LoginWithWalletViaPlatformParams, PLATFORM_WALLET_MESSAGES, PLATFORM_WALLET_UNAVAILABLE, type PayWithWalletParams, type PlatformWalletFamily, type SolanaMessageSigner, WALLET_USE_SITE_PANEL, WalletLoginResult, encodeNftDepositData, erc1155Abi, erc20Abi, erc721Abi, isEmbeddedInPlatform, isEmbeddedOnForeignSite, linkWalletEvm, linkWalletSolana, linkWalletViaPlatform, loginWithWalletEvm, loginWithWalletSolana, loginWithWalletViaPlatform, onWalletBalanceChanged, payWithWalletEvm, rewardPoolAbi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { W as WalletLoginResult, B as BridgeResult } from './types-CeUVf1tr.js';
|
|
2
2
|
export { a as BridgeFailure, b as BridgeStage, c as BridgeSuccess, d as WalletLoginFailure, e as WalletLoginStage, f as WalletLoginSuccess, g as bridgeFail, t as toErrorMessage, w as walletLoginFail } from './types-CeUVf1tr.js';
|
|
3
|
+
import { IDosGamesClient, WalletLinkResponse, ClientState, BlockchainNetworkDefinition, CryptoShortfall, OperationResult } from '@idosgames/core';
|
|
3
4
|
export { A as AppKitEvmNetwork, 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, t as toAppKitNetwork } from './chains-B_P3u8_S.js';
|
|
4
5
|
import { Hex, Address } from 'viem';
|
|
5
6
|
import { E as EvmBridgeClients } from './withdraw-BKVcklPB.js';
|
|
6
7
|
export { D as DepositNft721EvmParams, a as DepositNftEvmParams, b as DepositTokenEvmParams, c as DepositTokenOnChainParams, W as WithdrawNftEvmParams, d as WithdrawTokenEvmParams, e as depositNftEvm, f as depositNftEvm721, g as depositTokenEvm, h as depositTokenOnChainEvm, i as ensureErc20Allowance, s as submitEvmNftWithdrawal, j as submitEvmNftWithdrawal721, k as submitEvmTokenWithdrawal, w as withdrawNftEvm, l as withdrawTokenEvm, m as writeAndWait } from './withdraw-BKVcklPB.js';
|
|
7
|
-
import { IDosGamesClient, ClientState, BlockchainNetworkDefinition, CryptoShortfall, OperationResult } from '@idosgames/core';
|
|
8
8
|
export { D as DepositTokenSolanaParams, S as SolanaProgramAdapter, W as WithdrawTokenSolanaParams, d as depositTokenSolana, w as withdrawTokenSolana } from './bridge-BSTHFExV.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -50,6 +50,45 @@ declare function isEmbeddedOnForeignSite(): boolean;
|
|
|
50
50
|
*/
|
|
51
51
|
declare function onWalletBalanceChanged(callback: () => void): () => void;
|
|
52
52
|
|
|
53
|
+
/** Message names. Shared with `GameWalletLoginBridge` on the website — keep both in step. */
|
|
54
|
+
declare const PLATFORM_WALLET_MESSAGES: {
|
|
55
|
+
readonly addressRequest: "IDOS_PLATFORM_WALLET_ADDRESS_REQUEST";
|
|
56
|
+
readonly addressResponse: "IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE";
|
|
57
|
+
readonly signRequest: "IDOS_PLATFORM_WALLET_SIGN_REQUEST";
|
|
58
|
+
readonly signResponse: "IDOS_PLATFORM_WALLET_SIGN_RESPONSE";
|
|
59
|
+
/** Sent by the site the moment it receives a request — "I am here, the player is choosing". */
|
|
60
|
+
readonly ack: "IDOS_PLATFORM_WALLET_ACK";
|
|
61
|
+
};
|
|
62
|
+
/** Which of the site's wallets signs: its EVM connection or its Solana adapter. */
|
|
63
|
+
type PlatformWalletFamily = "evm" | "solana";
|
|
64
|
+
/**
|
|
65
|
+
* The page around the game did not answer at all — an old site build without the bridge, or a
|
|
66
|
+
* parent that is not the platform. The button shows a plain "not available here" for it.
|
|
67
|
+
*/
|
|
68
|
+
declare const PLATFORM_WALLET_UNAVAILABLE = "PLATFORM_WALLET_UNAVAILABLE";
|
|
69
|
+
interface LoginWithWalletViaPlatformParams {
|
|
70
|
+
/** The (not yet authenticated) shared client. */
|
|
71
|
+
client: IDosGamesClient;
|
|
72
|
+
/** NetworkID (key of cfg.Blockchain.Networks) the wallet proves ownership on. */
|
|
73
|
+
networkID: string;
|
|
74
|
+
/** Which of the site's wallets to use. */
|
|
75
|
+
family: PlatformWalletFamily;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Full wallet sign-in for a game embedded on idosgames.com, signed by the site's own wallet
|
|
79
|
+
* connection. Same result shape and stages as `loginWithWalletEvm` / `loginWithWalletSolana`:
|
|
80
|
+
* `challenge` covers getting the address and the engine's message, `sign` the site's signature,
|
|
81
|
+
* `login` the exchange for a session.
|
|
82
|
+
*/
|
|
83
|
+
declare function loginWithWalletViaPlatform(params: LoginWithWalletViaPlatformParams): Promise<WalletLoginResult<ClientState>>;
|
|
84
|
+
/**
|
|
85
|
+
* Attach a wallet to the LOGGED-IN account inside the idosgames.com frame — the site's wallet signs
|
|
86
|
+
* the engine's link challenge (same message template as login, so the site's check accepts it). Used
|
|
87
|
+
* by the play-access screen of a gated title; `data.PlayAccess` is the pass checked against this
|
|
88
|
+
* wallet.
|
|
89
|
+
*/
|
|
90
|
+
declare function linkWalletViaPlatform(params: LoginWithWalletViaPlatformParams): Promise<WalletLoginResult<WalletLinkResponse>>;
|
|
91
|
+
|
|
53
92
|
declare const rewardPoolAbi: readonly [{
|
|
54
93
|
readonly type: "function";
|
|
55
94
|
readonly name: "depositERC20";
|
|
@@ -375,6 +414,16 @@ interface LoginWithWalletEvmParams {
|
|
|
375
414
|
* A user-rejected signature surfaces as a `{ ok: false, stage: "sign" }` failure, not a throw.
|
|
376
415
|
*/
|
|
377
416
|
declare function loginWithWalletEvm(params: LoginWithWalletEvmParams): Promise<WalletLoginResult<ClientState>>;
|
|
417
|
+
/**
|
|
418
|
+
* Attach a wallet to the LOGGED-IN account by signature — not a login, so no second account is
|
|
419
|
+
* created. Used by the play-access screen of a gated title (`cfg.Blockchain.PlayAccess`): the
|
|
420
|
+
* server then checks the pass against exactly this wallet (`data.PlayAccess`).
|
|
421
|
+
*
|
|
422
|
+
* `client.auth.linkWallet` (no signature) → `personal_sign` the returned challenge →
|
|
423
|
+
* `client.auth.linkWallet` with the signature. Refuses inside the platform iframe — there the
|
|
424
|
+
* site's wallet signs (`linkWalletViaPlatform`).
|
|
425
|
+
*/
|
|
426
|
+
declare function linkWalletEvm(params: LoginWithWalletEvmParams): Promise<WalletLoginResult<WalletLinkResponse>>;
|
|
378
427
|
|
|
379
428
|
interface PayWithWalletParams<T> {
|
|
380
429
|
client: IDosGamesClient;
|
|
@@ -434,5 +483,10 @@ interface LoginWithWalletSolanaParams {
|
|
|
434
483
|
* {@link ClientState} is returned. No on-chain transaction — off-chain proof of ownership only.
|
|
435
484
|
*/
|
|
436
485
|
declare function loginWithWalletSolana(params: LoginWithWalletSolanaParams): Promise<WalletLoginResult<ClientState>>;
|
|
486
|
+
/**
|
|
487
|
+
* Attach a Solana wallet to the LOGGED-IN account by signature (see `linkWalletEvm`): challenge →
|
|
488
|
+
* sign the message bytes → exchange. Refuses inside the platform iframe.
|
|
489
|
+
*/
|
|
490
|
+
declare function linkWalletSolana(params: LoginWithWalletSolanaParams): Promise<WalletLoginResult<WalletLinkResponse>>;
|
|
437
491
|
|
|
438
|
-
export { BridgeResult, EvmBridgeClients, type LoginWithWalletEvmParams, type LoginWithWalletSolanaParams, type PayWithWalletParams, type SolanaMessageSigner, WALLET_USE_SITE_PANEL, WalletLoginResult, encodeNftDepositData, erc1155Abi, erc20Abi, erc721Abi, isEmbeddedInPlatform, isEmbeddedOnForeignSite, loginWithWalletEvm, loginWithWalletSolana, onWalletBalanceChanged, payWithWalletEvm, rewardPoolAbi };
|
|
492
|
+
export { BridgeResult, EvmBridgeClients, type LoginWithWalletEvmParams, type LoginWithWalletSolanaParams, type LoginWithWalletViaPlatformParams, PLATFORM_WALLET_MESSAGES, PLATFORM_WALLET_UNAVAILABLE, type PayWithWalletParams, type PlatformWalletFamily, type SolanaMessageSigner, WALLET_USE_SITE_PANEL, WalletLoginResult, encodeNftDepositData, erc1155Abi, erc20Abi, erc721Abi, isEmbeddedInPlatform, isEmbeddedOnForeignSite, linkWalletEvm, linkWalletSolana, linkWalletViaPlatform, loginWithWalletEvm, loginWithWalletSolana, loginWithWalletViaPlatform, onWalletBalanceChanged, payWithWalletEvm, rewardPoolAbi };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{j as depositNftEvm,k as depositNftEvm721,h as depositTokenEvm,i as depositTokenOnChainEvm,e as encodeNftDepositData,g as ensureErc20Allowance,c as erc1155Abi,b as erc20Abi,d as erc721Abi,q as loginWithWalletEvm,
|
|
1
|
+
export{j as depositNftEvm,k as depositNftEvm721,h as depositTokenEvm,i as depositTokenOnChainEvm,e as encodeNftDepositData,g as ensureErc20Allowance,c as erc1155Abi,b as erc20Abi,d as erc721Abi,r as linkWalletEvm,q as loginWithWalletEvm,s as payWithWalletEvm,a as rewardPoolAbi,m as submitEvmNftWithdrawal,n as submitEvmNftWithdrawal721,l as submitEvmTokenWithdrawal,p as withdrawNftEvm,o as withdrawTokenEvm,f as writeAndWait}from'./chunk-FFBRTCQK.js';export{a as PLATFORM_WALLET_MESSAGES,b as PLATFORM_WALLET_UNAVAILABLE,d as linkWalletViaPlatform,c as loginWithWalletViaPlatform}from'./chunk-3VONNSCN.js';export{a as depositTokenSolana,d as linkWalletSolana,c as loginWithWalletSolana,b as withdrawTokenSolana}from'./chunk-QST6UVX7.js';export{d as WALLET_USE_SITE_PANEL,n as arbitrum,m as base,b as bridgeFail,k as bsc,s as chainById,r as idosChains,e as isEmbeddedInPlatform,f as isEmbeddedOnForeignSite,j as mainnet,i as onWalletBalanceChanged,o as optimism,l as polygon,q as polygonAmoy,p as sepolia,v as solanaDevnet,u as solanaMainnet,t as toAppKitNetwork,a as toErrorMessage,c as walletLoginFail}from'./chunk-IEWZH6XD.js';
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 z={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"}}},V={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"}}},$={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"}}},Q={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"}}},Z={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"}}},J={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"}}},X={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"}}},ve={mainnet:z,bsc:V,polygon:$,base:Y,arbitrum:Q,optimism:Z,sepolia:J,polygonAmoy:X};function $e(e){return Object.values(ve).find(t=>t.id===e)}function ke(e){return {...e,chainNamespace:"eip155",caipNetworkId:`eip155:${e.id}`}}var Ee=null;function Ae(e){Ee=e;}function se(){return Ee}var xe=[z,V,$,Y,Q,Z,J,X],le=new Map;function ce(e){let{chains:t=xe,walletConnectProjectId:n,appName:r,appUrl:o,appIcon:i,transports:d,connectors:l}=e,a=n??"__extension_only__";if(!l){let y=le.get(a);if(y)return y}let u={};for(let y of t)u[y.id]=d?.[y.id]??wagmi.http();let p=o??(typeof window<"u"?window.location.origin:""),m={name:r??"iDosGames",description:r??"iDosGames game",url:p,icons:i?[i]:[]};if(n&&!l){let y=t.map(ke),D=new appkitAdapterWagmi.WagmiAdapter({networks:y,projectId:n,transports:u});return Ae(react.createAppKit({adapters:[D],networks:y,projectId:n,metadata:m,features:{analytics:false,email:false,socials:false}})),le.set(a,D.wagmiConfig),D.wagmiConfig}let f=l??[connectors.injected(),connectors.coinbaseWallet({appName:r??"iDosGames"})],h=wagmi.createConfig({chains:t,connectors:f,transports:u});return l||le.set(a,h),h}function U(e){let{wagmiConfig:t,queryClient:n,children:r}=e,[o]=react$1.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:t,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:o,children:r})})}var ee=[{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:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],Pe=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],de=[{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"}]}],Ie=[{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 Ne(e,t,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[e,t,core.normalizeBlockchainCategory(n)])}async function S(e,t){let{walletClient:n,publicClient:r,account:o}=e,i=await n.writeContract({address:t.address,abi:t.abi,functionName:t.functionName,args:t.args,account:o,chain:n.chain,value:t.value});if((await r.waitForTransactionReceipt({hash:i})).status==="reverted")throw new Error(`On-chain transaction reverted (${i}).`);return i}function x(e){return e instanceof viem.BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function c(e,t,n){return {ok:false,stage:e,error:t,...n}}function I(e,t){return {ok:false,stage:e,error:t}}var We="WALLET_USE_SITE_PANEL";function N(){if(typeof window>"u")return false;try{return window.self!==window.top}catch{return true}}function M(e){return c(e,We)}function Te(e){return I(e,We)}function Be(e){let t=e.RewardPoolAddress;return t||null}async function Se(e,t,n,r){return await e.publicClient.readContract({address:t,abi:de,functionName:"allowance",args:[e.account,n]})>=r?null:S(e,{address:t,abi:de,functionName:"approve",args:[n,r]})}async function pe(e){let{client:t,clients:n,network:r,tokenAddress:o,amount:i,titleID:d,category:l}=e;if(N())return M("approve");let a=t.auth.context?.userID;if(!a)return c("approve","Not logged in.");let u=Be(r);if(!u)return c("approve","Network has no RewardPoolAddress.");if(i<=0n)return c("approve","Amount must be positive.");try{await Se(n,o,u,i);}catch(f){return c("approve",x(f))}let p;try{p=await S(n,{address:u,abi:ee,functionName:"depositERC20",args:[o,i,a,d,l??""]});}catch(f){return c("deposit-onchain",x(f))}let m=await t.blockchain.depositToken(r.NetworkID??"",p);return m.ok?{ok:true,onChainTxHash:p,data:m.data}:c("report",m.error,{onChainTxHash:p})}async function ue(e){let{client:t,clients:n,network:r,nftContractAddress:o,tokenId:i,amount:d,titleID:l,category:a}=e;if(N())return M("deposit-onchain");let u=t.auth.context?.userID;if(!u)return c("deposit-onchain","Not logged in.");let p=Be(r);if(!p)return c("deposit-onchain","Network has no RewardPoolAddress.");if(d<=0n)return c("deposit-onchain","Amount must be positive.");let m=Ne(u,l,a),f;try{f=await S(n,{address:o,abi:Ie,functionName:"safeTransferFrom",args:[n.account,p,i,d,m]});}catch(y){return c("deposit-onchain",x(y))}let h=await t.blockchain.depositNFT(r.NetworkID??"",f);return h.ok?{ok:true,onChainTxHash:f,data:h.data}:c("report",h.error,{onChainTxHash:f})}function Re(e){return (e.Splits??[]).map(t=>({to:t.To,amount:BigInt(t.Amount??"0")}))}async function Fe(e,t){return S(e,{address:t.ContractAddress,abi:ee,functionName:"withdrawERC20",args:[t.TokenAddress,t.WalletAddress,BigInt(t.Amount??"0"),BigInt(t.BurnAmount??"0"),Re(t),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function Le(e,t){return S(e,{address:t.ContractAddress,abi:Pe,functionName:"withdrawERC1155Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Amount??"0"),Re(t),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function me(e){let{client:t,clients:n,currencyID:r,networkID:o,walletAddress:i,amount:d,category:l}=e;if(N())return M("request");let a=await t.blockchain.requestTokenWithdrawal(r,o,i,d,l);if(!a.ok)return c("request",a.error);let u=a.data.EvmSignature,p=a.data.TitleTransactionID??void 0;if(!u)return c("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let m;try{m=await Fe(n,u);}catch(h){return c("withdraw-onchain",x(h),{titleTransactionID:p})}let f=await He(t,p,m);return f.ok?{ok:true,onChainTxHash:m,data:a.data}:f}async function fe(e){let{client:t,clients:n,itemID:r,networkID:o,walletAddress:i,amount:d,category:l}=e;if(N())return M("request");let a=await t.blockchain.requestNFTWithdrawal(r,o,i,d,l);if(!a.ok)return c("request",a.error);let u=a.data.EvmSignature,p=a.data.TitleTransactionID??void 0;if(!u)return c("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let m;try{m=await Le(n,u);}catch(h){return c("withdraw-onchain",x(h),{titleTransactionID:p})}let f=await He(t,p,m);return f.ok?{ok:true,onChainTxHash:m,data:a.data}:f}async function He(e,t,n){if(!t)return c("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await e.blockchain.confirmWithdrawal(t,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:c("confirm",r.error,{onChainTxHash:n,titleTransactionID:t})}async function K(e){let{client:t,clients:n,networkID:r}=e;if(N())return Te("challenge");let o=e.walletAddress??n.account,i=await t.auth.requestWalletChallenge(o,r);if(!i.ok)return I("challenge",i.error);let d;try{d=await n.walletClient.signMessage({account:n.account,message:i.data.Message});}catch(a){return I("sign",x(a))}let l=await t.auth.loginWithWallet(o,r,d);return l.ok?{ok:true,data:l.data}:I("login",l.error)}function te(){let{address:e}=wagmi.useAccount(),t=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !e||!t||!n?null:{account:e,publicClient:t,walletClient:n}}var _="Wallet not connected.";function ge(e,t){let n=te();return {connected:!!n,account:n?.account??null,loginWithWallet:(r,o)=>n?K({client:e,clients:n,networkID:r,walletAddress:o}):Promise.resolve(I("challenge",_)),depositToken:r=>n?pe({client:e,clients:n,titleID:t,...r}):Promise.resolve(c("approve",_)),depositNft:r=>n?ue({client:e,clients:n,titleID:t,...r}):Promise.resolve(c("deposit-onchain",_)),withdrawToken:r=>n?me({client:e,clients:n,...r}):Promise.resolve(c("withdraw-onchain",_)),withdrawNft:r=>n?fe({client:e,clients:n,...r}):Promise.resolve(c("withdraw-onchain",_))}}function wt(e){let{wagmiConfig:t,...n}=e;return jsxRuntime.jsx(U,{wagmiConfig:t,children:jsxRuntime.jsx(Ue,{...n})})}function ht(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function Ct(e){let t="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.":t:t}async function Oe(e){let t=await actions.getWalletClient(e).catch(()=>null);if(!t)return null;let n=actions.getPublicClient(e);return n?{account:t.account.address,publicClient:n,walletClient:t}:null}function bt(e,t=18e4){return actions.getAccount(e).isConnected?Promise.resolve(true):new Promise(n=>{let r=false,o=l=>{r||(r=true,i(),clearTimeout(d),n(l));},i=actions.watchAccount(e,{onChange:l=>{l.isConnected&&o(true);}}),d=setTimeout(()=>o(false),t);})}function vt(e,t=8e3){let n=r=>r==="reconnecting"||r==="connecting";return n(actions.getAccount(e).status)?new Promise(r=>{let o=false,i=()=>{o||(o=true,d(),clearTimeout(l),r());},d=actions.watchAccount(e,{onChange:a=>{n(a.status)||i();}}),l=setTimeout(i,t);}):Promise.resolve()}function kt(e){let t=o=>e.find(i=>i.id===o||i.type===o),n=t("injected"),r=typeof window<"u"&&window.ethereum!=null;return n&&r?n:t("walletConnect")??n??e[0]}var Et=9e4;async function At(e){try{let r=(await actions.getAccount(e).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 xt(e,t){return new Promise((n,r)=>{let o=setTimeout(()=>r(new Error("The wallet request timed out.")),t);e.then(i=>{clearTimeout(o),n(i);},i=>{clearTimeout(o),r(i instanceof Error?i:new Error(String(i)));});})}function Ue(e){let{client:t,networkID:n,onAuthenticated:r,disabled:o,label:i,style:d,autoStart:l}=e,a=wagmi.useConfig(),{isConnected:u}=wagmi.useAccount(),{connectAsync:p,connectors:m}=wagmi.useConnect(),f=te(),[h,y]=react$1.useState(false),[D,C]=react$1.useState(null),[O,E]=react$1.useState(false),G=react$1.useRef(0),F=react$1.useRef(false),j=async()=>{let T=++G.current,P=()=>G.current===T;y(true),C(null);try{if(await vt(a),!P())return;if(!actions.getAccount(a).isConnected){let k=se();if(k){if(await k.open(),!await bt(a)){C("No wallet was connected.");return}}else {let ie=kt(m);if(!ie){C("No wallet connector is configured.");return}try{await p({connector:ie});}catch(B){if(!ht(B))throw B}}}let b=f??await Oe(a);if(!b&&actions.getAccount(a).isConnected&&(await new Promise(k=>setTimeout(k,300)),b=await Oe(a),!P()))return;if(!b){C("Wallet client is not available.");return}E(!0);let A=await xt(K({client:t,clients:b,networkID:n}),Et);if(!P())return;if(A.ok){r();return}C(A.stage==="sign"?"Signature declined.":A.error??"Wallet sign-in failed.");}catch(b){if(!P())return;console.error("[idosgames/wallet] wallet sign-in failed:",b),C(Ct(b));}finally{P()&&(y(false),E(false));}};react$1.useEffect(()=>{!l||F.current||(F.current=true,j());},[l]);let L=async()=>{await At(a)||await se()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{O?L():j();},disabled:o,style:{...Dt,...o?{opacity:.6,cursor:"default"}:null,...d},children:O?"Waiting for signature \u2014 tap to open wallet":h?"Check your wallet\u2026":u?i??"Sign in with wallet":"Connect wallet"}),D&&jsxRuntime.jsx("span",{role:"alert",style:Pt,children:D})]})}var Dt={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Pt={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};var Lt={pointerEvents:"auto",background:"#04276bf5",border:"1px solid #1e59c8",borderRadius:12,padding:16,color:"#fff",width:320,boxSizing:"border-box",fontFamily:"system-ui, sans-serif",display:"flex",flexDirection:"column",gap:10,maxHeight:"80vh",overflow:"auto"},Ht={fontWeight:700,fontSize:16},R={fontSize:12,opacity:.7},we={background:"#052e7e",border:"1px solid #1e59c8",borderRadius:8,color:"#fff",padding:"8px 10px",width:"100%",boxSizing:"border-box"},Mt={background:"#0d66fe",color:"#fff",border:"none",borderRadius:8,padding:"9px 14px",fontWeight:700,cursor:"pointer"},re={background:"#1e59c8",color:"#fff",border:"none",borderRadius:8,padding:"7px 12px",fontWeight:600,cursor:"pointer"},he={display:"flex",gap:8};function Ot(e){let{client:t,walletConnectProjectId:n,appName:r,onClose:o,style:i}=e,[d,l]=react$1.useState(n??"");react$1.useEffect(()=>{if(n)return;let u=true;return (async()=>{let p=await t.blockchain.getDefinitions();if(!u||!p.ok)return;let m=p.data.Blockchain?.WalletLogin?.WalletConnectProjectId;m&&l(m);})(),()=>{u=false;}},[t,n]);let a=react$1.useMemo(()=>ce({walletConnectProjectId:d||void 0,appName:r}),[d,r]);return jsxRuntime.jsx(U,{wagmiConfig:a,children:jsxRuntime.jsx(Gt,{client:t,appName:r,onClose:o,style:i})})}function Gt({client:e,onClose:t,style:n}){let r=ge(e,e.titleID),{address:o,isConnected:i,chainId:d}=wagmi.useAccount(),{connect:l,connectors:a}=wagmi.useConnect(),{disconnect:u}=wagmi.useDisconnect(),{switchChainAsync:p}=wagmi.useSwitchChain(),[,m]=react$1.useReducer(s=>s+1,0),[f,h]=react$1.useState({}),[y,D]=react$1.useState({}),[C,O]=react$1.useState(""),[E,G]=react$1.useState(""),[F,j]=react$1.useState(""),[L,T]=react$1.useState(false),[P,b]=react$1.useState(null);react$1.useEffect(()=>{let s=true;return (async()=>{let w=await e.blockchain.getDefinitions();if(await e.blockchain.getUserState(),!s||!w.ok)return;let H=w.data.Blockchain?.Networks??{},ae={};for(let[Ve,be]of Object.entries(H))be.Type==="EVM"&&(ae[Ve]=be);h(ae),D(w.data.CryptoCurrencies??{});let ze=Object.keys(ae)[0]??"";O(ze);})(),()=>{s=false;}},[e]),react$1.useEffect(()=>e.on("user:anyUpdated",m),[e]);let A=react$1.useMemo(()=>Object.entries(y).filter(([,s])=>s.Networks?.some(w=>w.NetworkID===C&&!!w.ContractAddress)),[y,C]);react$1.useEffect(()=>{let s=A[0]?.[0]??"";G(w=>A.some(([H])=>H===w)?w:s);},[A]);let k=C?f[C]:void 0,B=(E?y[E]:void 0)?.Networks?.find(s=>s.NetworkID===C),_e=E?e.data.user.getCryptoCurrencyAmount(E):"0";async function Ce(){if(!k?.ChainID||d===k.ChainID)return true;try{return await p({chainId:k.ChainID}),!0}catch{return b({ok:false,stage:"approve",error:`Switch your wallet to chain ${k.ChainID} to continue.`}),false}}async function qe(){if(!(!k||!B?.ContractAddress)){if(T(true),b(null),await Ce()){let s=B.Decimals??18,w;try{w=viem.parseUnits(F||"0",s);}catch{b({ok:false,stage:"approve",error:"Invalid amount."}),T(false);return}let H=await r.depositToken({network:k,tokenAddress:B.ContractAddress,amount:w});b(H),H.ok&&await e.blockchain.getUserState();}T(false);}}async function je(){if(!(!k||!r.account)){if(T(true),b(null),await Ce()){let s=await r.withdrawToken({currencyID:E,networkID:C,walletAddress:r.account,amount:F||"0"});b(s),s.ok&&await e.blockchain.getUserState();}T(false);}}return jsxRuntime.jsxs("div",{style:{...Lt,...n},children:[jsxRuntime.jsxs("div",{style:{...he,justifyContent:"space-between"},children:[jsxRuntime.jsx("span",{style:Ht,children:"Crypto wallet"}),t&&jsxRuntime.jsx("button",{type:"button",style:re,onClick:t,children:"\u2715"})]}),i?jsxRuntime.jsxs("div",{style:he,children:[jsxRuntime.jsxs("span",{style:{...R,flex:1,alignSelf:"center"},children:[o?.slice(0,6),"\u2026",o?.slice(-4)]}),jsxRuntime.jsx("button",{type:"button",style:re,onClick:()=>u(),children:"Disconnect"})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("span",{style:R,children:"Connect a browser or mobile wallet"}),a.map(s=>jsxRuntime.jsx("button",{type:"button",style:re,onClick:()=>l({connector:s}),children:s.name},s.uid))]}),Object.keys(f).length===0?jsxRuntime.jsx("span",{style:R,children:"No EVM networks configured for this title."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:R,children:"Network"}),jsxRuntime.jsx("select",{style:we,value:C,onChange:s=>O(s.target.value),children:Object.entries(f).map(([s,w])=>jsxRuntime.jsx("option",{value:s,children:w.DisplayName??s},s))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:R,children:"Token"}),jsxRuntime.jsxs("select",{style:we,value:E,onChange:s=>G(s.target.value),children:[A.length===0&&jsxRuntime.jsx("option",{value:"",children:"\u2014 no depositable tokens \u2014"}),A.map(([s,w])=>jsxRuntime.jsx("option",{value:s,children:w.DisplayName??s},s))]})]}),jsxRuntime.jsxs("div",{style:R,children:["In-game balance: ",jsxRuntime.jsx("b",{children:_e})," ",E]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:R,children:"Amount"}),jsxRuntime.jsx("input",{style:we,inputMode:"decimal",placeholder:"0.0",value:F,onChange:s=>j(s.target.value)})]}),jsxRuntime.jsxs("div",{style:he,children:[jsxRuntime.jsx("button",{type:"button",style:{...Mt,flex:1,opacity:L?.6:1},disabled:L||!i||!B?.ContractAddress,onClick:()=>{qe();},children:"Deposit"}),jsxRuntime.jsx("button",{type:"button",style:{...re,flex:1,opacity:L?.6:1},disabled:L||!i||!E,onClick:()=>{je();},children:"Withdraw"})]})]}),P&&jsxRuntime.jsx(Ut,{result:P})]})}function Ut({result:e}){let t={fontSize:12,borderRadius:8,padding:"8px 10px",background:e.ok?"#1e3a2a":"#3a1e28",color:e.ok?"#8ef0b0":"#f2a0b4",wordBreak:"break-all"};return e.ok?jsxRuntime.jsxs("div",{style:t,children:["\u2713 Done \xB7 tx ",e.onChainTxHash]}):jsxRuntime.jsxs("div",{style:t,children:["\u2715 [",e.stage,"] ",e.error,e.titleTransactionID?` \xB7 already debited (tx ${e.titleTransactionID}) \u2014 retry/confirm, don't re-request`:""]})}
|
|
2
|
-
exports.DEFAULT_EVM_CHAINS=
|
|
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 Y={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"}}},Z={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"}}},J={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"}}},X={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"}}},ee={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"}}},te={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"}}},ne={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"}}},Ae={mainnet:Y,bsc:Q,polygon:Z,base:J,arbitrum:X,optimism:ee,sepolia:te,polygonAmoy:ne};function Ze(e){return Object.values(Ae).find(t=>t.id===e)}function xe(e){return {...e,chainNamespace:"eip155",caipNetworkId:`eip155:${e.id}`}}var De=null;function Pe(e){De=e;}function ce(){return De}var We=[Y,Q,Z,J,X,ee,te,ne],de=new Map;function pe(e){let{chains:t=We,walletConnectProjectId:n,appName:r,appUrl:i,appIcon:o,transports:d,connectors:a}=e,s=n??"__extension_only__";if(!a){let y=de.get(s);if(y)return y}let u={};for(let y of t)u[y.id]=d?.[y.id]??wagmi.http();let c=i??(typeof window<"u"?window.location.origin:""),m={name:r??"iDosGames",description:r??"iDosGames game",url:c,icons:o?[o]:[]};if(n&&!a){let y=t.map(xe),T=new appkitAdapterWagmi.WagmiAdapter({networks:y,projectId:n,transports:u});return Pe(react.createAppKit({adapters:[T],networks:y,projectId:n,metadata:m,features:{analytics:false,email:false,socials:false}})),de.set(s,T.wagmiConfig),T.wagmiConfig}let f=a??[connectors.injected(),connectors.coinbaseWallet({appName:r??"iDosGames"})],b=wagmi.createConfig({chains:t,connectors:f,transports:u});return a||de.set(s,b),b}function U(e){let{wagmiConfig:t,queryClient:n,children:r}=e,[i]=react$1.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:t,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:i,children:r})})}var re=[{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:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{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:[]}],ue=[{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"}]}],Te=[{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 Se(e,t,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[e,t,core.normalizeBlockchainCategory(n)])}async function B(e,t){let{walletClient:n,publicClient:r,account:i}=e,o=await n.writeContract({address:t.address,abi:t.abi,functionName:t.functionName,args:t.args,account:i,chain:n.chain,value:t.value});if((await r.waitForTransactionReceipt({hash:o})).status==="reverted")throw new Error(`On-chain transaction reverted (${o}).`);return o}function D(e){return e instanceof viem.BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function p(e,t,n){return {ok:false,stage:e,error:t,...n}}function A(e,t){return {ok:false,stage:e,error:t}}var Be="WALLET_USE_SITE_PANEL";function P(){if(typeof window>"u")return false;try{return window.self!==window.top}catch{return true}}function H(e){return p(e,Be)}function me(e){return A(e,Be)}function Re(e){let t=e.RewardPoolAddress;return t||null}async function Le(e,t,n,r){return await e.publicClient.readContract({address:t,abi:ue,functionName:"allowance",args:[e.account,n]})>=r?null:B(e,{address:t,abi:ue,functionName:"approve",args:[n,r]})}async function fe(e){let{client:t,clients:n,network:r,tokenAddress:i,amount:o,titleID:d,category:a}=e;if(P())return H("approve");let s=t.auth.context?.userID;if(!s)return p("approve","Not logged in.");let u=Re(r);if(!u)return p("approve","Network has no RewardPoolAddress.");if(o<=0n)return p("approve","Amount must be positive.");try{await Le(n,i,u,o);}catch(f){return p("approve",D(f))}let c;try{c=await B(n,{address:u,abi:re,functionName:"depositERC20",args:[i,o,s,d,a??""]});}catch(f){return p("deposit-onchain",D(f))}let m=await t.blockchain.depositToken(r.NetworkID??"",c);return m.ok?{ok:true,onChainTxHash:c,data:m.data}:p("report",m.error,{onChainTxHash:c})}async function ge(e){let{client:t,clients:n,network:r,nftContractAddress:i,tokenId:o,amount:d,titleID:a,category:s}=e;if(P())return H("deposit-onchain");let u=t.auth.context?.userID;if(!u)return p("deposit-onchain","Not logged in.");let c=Re(r);if(!c)return p("deposit-onchain","Network has no RewardPoolAddress.");if(d<=0n)return p("deposit-onchain","Amount must be positive.");let m=Se(u,a,s),f;try{f=await B(n,{address:i,abi:Te,functionName:"safeTransferFrom",args:[n.account,c,o,d,m]});}catch(y){return p("deposit-onchain",D(y))}let b=await t.blockchain.depositNFT(r.NetworkID??"",f);return b.ok?{ok:true,onChainTxHash:f,data:b.data}:p("report",b.error,{onChainTxHash:f})}function Fe(e){return (e.Splits??[]).map(t=>({to:t.To,amount:BigInt(t.Amount??"0")}))}async function He(e,t){return B(e,{address:t.ContractAddress,abi:re,functionName:"withdrawERC20",args:[t.TokenAddress,t.WalletAddress,BigInt(t.Amount??"0"),BigInt(t.BurnAmount??"0"),Fe(t),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function Me(e,t){return B(e,{address:t.ContractAddress,abi:Ne,functionName:"withdrawERC1155Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Amount??"0"),Fe(t),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function ye(e){let{client:t,clients:n,currencyID:r,networkID:i,walletAddress:o,amount:d,category:a}=e;if(P())return H("request");let s=await t.blockchain.requestTokenWithdrawal(r,i,o,d,a);if(!s.ok)return p("request",s.error);let u=s.data.EvmSignature,c=s.data.TitleTransactionID??void 0;if(!u)return p("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let m;try{m=await He(n,u);}catch(b){return p("withdraw-onchain",D(b),{titleTransactionID:c})}let f=await Oe(t,c,m);return f.ok?{ok:true,onChainTxHash:m,data:s.data}:f}async function we(e){let{client:t,clients:n,itemID:r,networkID:i,walletAddress:o,amount:d,category:a}=e;if(P())return H("request");let s=await t.blockchain.requestNFTWithdrawal(r,i,o,d,a);if(!s.ok)return p("request",s.error);let u=s.data.EvmSignature,c=s.data.TitleTransactionID??void 0;if(!u)return p("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let m;try{m=await Me(n,u);}catch(b){return p("withdraw-onchain",D(b),{titleTransactionID:c})}let f=await Oe(t,c,m);return f.ok?{ok:true,onChainTxHash:m,data:s.data}:f}async function Oe(e,t,n){if(!t)return p("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await e.blockchain.confirmWithdrawal(t,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:p("confirm",r.error,{onChainTxHash:n,titleTransactionID:t})}async function K(e){let{client:t,clients:n,networkID:r}=e;if(P())return me("challenge");let i=e.walletAddress??n.account,o=await t.auth.requestWalletChallenge(i,r);if(!o.ok)return A("challenge",o.error);let d;try{d=await n.walletClient.signMessage({account:n.account,message:o.data.Message});}catch(s){return A("sign",D(s))}let a=await t.auth.loginWithWallet(i,r,d);return a.ok?{ok:true,data:a.data}:A("login",a.error)}async function he(e){let{client:t,clients:n,networkID:r}=e;if(P())return me("challenge");let i=e.walletAddress??n.account,o=await t.auth.linkWallet(i,r);if(!o.ok)return A("challenge",o.error);if(!o.data.Challenge)return A("challenge","No challenge was issued.");let d;try{d=await n.walletClient.signMessage({account:n.account,message:o.data.Challenge});}catch(s){return A("sign",D(s))}let a=await t.auth.linkWallet(i,r,d);return a.ok?{ok:true,data:a.data}:A("login",a.error)}function oe(){let{address:e}=wagmi.useAccount(),t=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !e||!t||!n?null:{account:e,publicClient:t,walletClient:n}}var _="Wallet not connected.";function Ce(e,t){let n=oe();return {connected:!!n,account:n?.account??null,loginWithWallet:(r,i)=>n?K({client:e,clients:n,networkID:r,walletAddress:i}):Promise.resolve(A("challenge",_)),depositToken:r=>n?fe({client:e,clients:n,titleID:t,...r}):Promise.resolve(p("approve",_)),depositNft:r=>n?ge({client:e,clients:n,titleID:t,...r}):Promise.resolve(p("deposit-onchain",_)),withdrawToken:r=>n?ye({client:e,clients:n,...r}):Promise.resolve(p("withdraw-onchain",_)),withdrawNft:r=>n?we({client:e,clients:n,...r}):Promise.resolve(p("withdraw-onchain",_))}}function bt(e){let{wagmiConfig:t,...n}=e;return jsxRuntime.jsx(U,{wagmiConfig:t,children:jsxRuntime.jsx(je,{...n})})}function vt(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function kt(e){let t="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.":t:t}async function Ue(e){let t=await actions.getWalletClient(e).catch(()=>null);if(!t)return null;let n=actions.getPublicClient(e);return n?{account:t.account.address,publicClient:n,walletClient:t}:null}function Et(e,t=18e4){return actions.getAccount(e).isConnected?Promise.resolve(true):new Promise(n=>{let r=false,i=a=>{r||(r=true,o(),clearTimeout(d),n(a));},o=actions.watchAccount(e,{onChange:a=>{a.isConnected&&i(true);}}),d=setTimeout(()=>i(false),t);})}function At(e,t=8e3){let n=r=>r==="reconnecting"||r==="connecting";return n(actions.getAccount(e).status)?new Promise(r=>{let i=false,o=()=>{i||(i=true,d(),clearTimeout(a),r());},d=actions.watchAccount(e,{onChange:s=>{n(s.status)||o();}}),a=setTimeout(o,t);}):Promise.resolve()}function xt(e){let t=i=>e.find(o=>o.id===i||o.type===i),n=t("injected"),r=typeof window<"u"&&window.ethereum!=null;return n&&r?n:t("walletConnect")??n??e[0]}var Ke=9e4;async function Dt(e){try{let r=(await actions.getAccount(e).connector?.getProvider?.())?.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(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>r(new Error("The wallet request timed out.")),t);e.then(o=>{clearTimeout(i),n(o);},o=>{clearTimeout(i),r(o instanceof Error?o:new Error(String(o)));});})}function je(e){let{client:t,networkID:n,onAuthenticated:r,disabled:i,label:o,style:d,autoStart:a,mode:s="login",onLinked:u}=e,c=wagmi.useConfig(),{isConnected:m}=wagmi.useAccount(),{connectAsync:f,connectors:b}=wagmi.useConnect(),y=oe(),[T,x]=react$1.useState(false),[M,w]=react$1.useState(null),[O,L]=react$1.useState(false),j=react$1.useRef(0),S=react$1.useRef(false),W=async()=>{let I=++j.current,E=()=>j.current===I;x(true),w(null);try{if(await At(c),!E())return;if(!actions.getAccount(c).isConnected){let v=ce();if(v){if(await v.open(),!await Et(c)){w("No wallet was connected.");return}}else {let $=xt(b);if(!$){w("No wallet connector is configured.");return}try{await f({connector:$});}catch(G){if(!vt(G))throw G}}}let h=y??await Ue(c);if(!h&&actions.getAccount(c).isConnected&&(await new Promise(v=>setTimeout(v,300)),h=await Ue(c),!E()))return;if(!h){w("Wallet client is not available.");return}if(L(!0),s==="link"){let v=await _e(he({client:t,clients:h,networkID:n}),Ke);if(!E())return;if(v.ok){u?.(v.data.PlayAccess??null);return}w(v.stage==="sign"?"Signature declined.":v.error??"Could not link the wallet.");return}let V=await _e(K({client:t,clients:h,networkID:n}),Ke);if(!E())return;if(V.ok){r();return}w(V.stage==="sign"?"Signature declined.":V.error??"Wallet sign-in failed.");}catch(h){if(!E())return;console.error("[idosgames/wallet] wallet sign-in failed:",h),w(kt(h));}finally{E()&&(x(false),L(false));}};react$1.useEffect(()=>{!a||S.current||(S.current=true,W());},[a]);let z=async()=>{await Dt(c)||await ce()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{O?z():W();},disabled:i,style:{...Pt,...i?{opacity:.6,cursor:"default"}:null,...d},children:O?"Waiting for signature \u2014 tap to open wallet":T?"Check your wallet\u2026":m?o??(s==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),M&&jsxRuntime.jsx("span",{role:"alert",style:Wt,children:M})]})}var Pt={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Wt={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};var Ht={pointerEvents:"auto",background:"#04276bf5",border:"1px solid #1e59c8",borderRadius:12,padding:16,color:"#fff",width:320,boxSizing:"border-box",fontFamily:"system-ui, sans-serif",display:"flex",flexDirection:"column",gap:10,maxHeight:"80vh",overflow:"auto"},Mt={fontWeight:700,fontSize:16},R={fontSize:12,opacity:.7},ve={background:"#052e7e",border:"1px solid #1e59c8",borderRadius:8,color:"#fff",padding:"8px 10px",width:"100%",boxSizing:"border-box"},Ot={background:"#0d66fe",color:"#fff",border:"none",borderRadius:8,padding:"9px 14px",fontWeight:700,cursor:"pointer"},ae={background:"#1e59c8",color:"#fff",border:"none",borderRadius:8,padding:"7px 12px",fontWeight:600,cursor:"pointer"},ke={display:"flex",gap:8};function Gt(e){let{client:t,walletConnectProjectId:n,appName:r,onClose:i,style:o}=e,[d,a]=react$1.useState(n??"");react$1.useEffect(()=>{if(n)return;let u=true;return (async()=>{let c=await t.blockchain.getDefinitions();if(!u||!c.ok)return;let m=c.data.Blockchain?.WalletLogin?.WalletConnectProjectId;m&&a(m);})(),()=>{u=false;}},[t,n]);let s=react$1.useMemo(()=>pe({walletConnectProjectId:d||void 0,appName:r}),[d,r]);return jsxRuntime.jsx(U,{wagmiConfig:s,children:jsxRuntime.jsx(Ut,{client:t,appName:r,onClose:i,style:o})})}function Ut({client:e,onClose:t,style:n}){let r=Ce(e,e.titleID),{address:i,isConnected:o,chainId:d}=wagmi.useAccount(),{connect:a,connectors:s}=wagmi.useConnect(),{disconnect:u}=wagmi.useDisconnect(),{switchChainAsync:c}=wagmi.useSwitchChain(),[,m]=react$1.useReducer(l=>l+1,0),[f,b]=react$1.useState({}),[y,T]=react$1.useState({}),[x,M]=react$1.useState(""),[w,O]=react$1.useState(""),[L,j]=react$1.useState(""),[S,W]=react$1.useState(false),[z,I]=react$1.useState(null);react$1.useEffect(()=>{let l=true;return (async()=>{let C=await e.blockchain.getDefinitions();if(await e.blockchain.getUserState(),!l||!C.ok)return;let F=C.data.Blockchain?.Networks??{},le={};for(let[Qe,Ee]of Object.entries(F))Ee.Type==="EVM"&&(le[Qe]=Ee);b(le),T(C.data.CryptoCurrencies??{});let Ye=Object.keys(le)[0]??"";M(Ye);})(),()=>{l=false;}},[e]),react$1.useEffect(()=>e.on("user:anyUpdated",m),[e]);let E=react$1.useMemo(()=>Object.entries(y).filter(([,l])=>l.Networks?.some(C=>C.NetworkID===x&&!!C.ContractAddress)),[y,x]);react$1.useEffect(()=>{let l=E[0]?.[0]??"";O(C=>E.some(([F])=>F===C)?C:l);},[E]);let h=x?f[x]:void 0,v=(w?y[w]:void 0)?.Networks?.find(l=>l.NetworkID===x),$=w?e.data.user.getCryptoCurrencyAmount(w):"0";async function G(){if(!h?.ChainID||d===h.ChainID)return true;try{return await c({chainId:h.ChainID}),!0}catch{return I({ok:false,stage:"approve",error:`Switch your wallet to chain ${h.ChainID} to continue.`}),false}}async function Ve(){if(!(!h||!v?.ContractAddress)){if(W(true),I(null),await G()){let l=v.Decimals??18,C;try{C=viem.parseUnits(L||"0",l);}catch{I({ok:false,stage:"approve",error:"Invalid amount."}),W(false);return}let F=await r.depositToken({network:h,tokenAddress:v.ContractAddress,amount:C});I(F),F.ok&&await e.blockchain.getUserState();}W(false);}}async function $e(){if(!(!h||!r.account)){if(W(true),I(null),await G()){let l=await r.withdrawToken({currencyID:w,networkID:x,walletAddress:r.account,amount:L||"0"});I(l),l.ok&&await e.blockchain.getUserState();}W(false);}}return jsxRuntime.jsxs("div",{style:{...Ht,...n},children:[jsxRuntime.jsxs("div",{style:{...ke,justifyContent:"space-between"},children:[jsxRuntime.jsx("span",{style:Mt,children:"Crypto wallet"}),t&&jsxRuntime.jsx("button",{type:"button",style:ae,onClick:t,children:"\u2715"})]}),o?jsxRuntime.jsxs("div",{style:ke,children:[jsxRuntime.jsxs("span",{style:{...R,flex:1,alignSelf:"center"},children:[i?.slice(0,6),"\u2026",i?.slice(-4)]}),jsxRuntime.jsx("button",{type:"button",style:ae,onClick:()=>u(),children:"Disconnect"})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("span",{style:R,children:"Connect a browser or mobile wallet"}),s.map(l=>jsxRuntime.jsx("button",{type:"button",style:ae,onClick:()=>a({connector:l}),children:l.name},l.uid))]}),Object.keys(f).length===0?jsxRuntime.jsx("span",{style:R,children:"No EVM networks configured for this title."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:R,children:"Network"}),jsxRuntime.jsx("select",{style:ve,value:x,onChange:l=>M(l.target.value),children:Object.entries(f).map(([l,C])=>jsxRuntime.jsx("option",{value:l,children:C.DisplayName??l},l))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:R,children:"Token"}),jsxRuntime.jsxs("select",{style:ve,value:w,onChange:l=>O(l.target.value),children:[E.length===0&&jsxRuntime.jsx("option",{value:"",children:"\u2014 no depositable tokens \u2014"}),E.map(([l,C])=>jsxRuntime.jsx("option",{value:l,children:C.DisplayName??l},l))]})]}),jsxRuntime.jsxs("div",{style:R,children:["In-game balance: ",jsxRuntime.jsx("b",{children:$})," ",w]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:R,children:"Amount"}),jsxRuntime.jsx("input",{style:ve,inputMode:"decimal",placeholder:"0.0",value:L,onChange:l=>j(l.target.value)})]}),jsxRuntime.jsxs("div",{style:ke,children:[jsxRuntime.jsx("button",{type:"button",style:{...Ot,flex:1,opacity:S?.6:1},disabled:S||!o||!v?.ContractAddress,onClick:()=>{Ve();},children:"Deposit"}),jsxRuntime.jsx("button",{type:"button",style:{...ae,flex:1,opacity:S?.6:1},disabled:S||!o||!w,onClick:()=>{$e();},children:"Withdraw"})]})]}),z&&jsxRuntime.jsx(Kt,{result:z})]})}function Kt({result:e}){let t={fontSize:12,borderRadius:8,padding:"8px 10px",background:e.ok?"#1e3a2a":"#3a1e28",color:e.ok?"#8ef0b0":"#f2a0b4",wordBreak:"break-all"};return e.ok?jsxRuntime.jsxs("div",{style:t,children:["\u2713 Done \xB7 tx ",e.onChainTxHash]}):jsxRuntime.jsxs("div",{style:t,children:["\u2715 [",e.stage,"] ",e.error,e.titleTransactionID?` \xB7 already debited (tx ${e.titleTransactionID}) \u2014 retry/confirm, don't re-request`:""]})}
|
|
2
|
+
exports.DEFAULT_EVM_CHAINS=We;exports.IDosGamesWalletProvider=U;exports.WalletLogin=bt;exports.WalletLoginButton=je;exports.WalletPanel=Gt;exports.arbitrum=X;exports.base=J;exports.bsc=Q;exports.chainById=Ze;exports.createEvmWalletConfig=pe;exports.idosChains=Ae;exports.mainnet=Y;exports.optimism=ee;exports.polygon=Z;exports.polygonAmoy=ne;exports.sepolia=te;exports.useEvmBridge=Ce;exports.useEvmBridgeClients=oe;
|
package/dist/react/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export { b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m
|
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, CSSProperties } from 'react';
|
|
6
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
|
|
7
|
+
import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient, PlayAccessStatus } from '@idosgames/core';
|
|
8
8
|
import { b as DepositTokenEvmParams, a as DepositNftEvmParams, d as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-C5y67V7i.cjs';
|
|
9
9
|
import { W as WalletLoginResult, B as BridgeResult } from '../types-CeUVf1tr.cjs';
|
|
10
10
|
|
|
@@ -126,6 +126,14 @@ interface WalletLoginProps {
|
|
|
126
126
|
* which already consumed the player's click to load this module — a second tap would be a bug.
|
|
127
127
|
*/
|
|
128
128
|
autoStart?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* `"login"` (default) — sign in. `"link"` — attach the wallet to the LOGGED-IN account by
|
|
131
|
+
* signature (play-access screen of a gated title); `onLinked` then receives the pass checked
|
|
132
|
+
* against this wallet, and `onAuthenticated` is not called.
|
|
133
|
+
*/
|
|
134
|
+
mode?: "login" | "link";
|
|
135
|
+
/** Link mode: the pass checked against the linked wallet (null on an Open title). */
|
|
136
|
+
onLinked?: (playAccess: PlayAccessStatus | null) => void;
|
|
129
137
|
}
|
|
130
138
|
/**
|
|
131
139
|
* Ready-made "sign in with wallet" button: connect → sign the challenge → session.
|