@idosgames/wallet 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bridge-BzZmMMxK.d.ts → bridge-8F45t4nD.d.cts} +1 -1
- package/dist/{bridge-BEEkIeZj.d.cts → bridge-BJnRn3NX.d.ts} +1 -1
- package/dist/chains-B_P3u8_S.d.cts +64 -0
- package/dist/chains-B_P3u8_S.d.ts +64 -0
- package/dist/{chunk-ACZSIOFR.js → chunk-44AGTUFV.js} +1 -1
- package/dist/{chunk-NDNNLWPS.js → chunk-DMMHCUIU.js} +1 -1
- package/dist/chunk-HQNS6ZWL.js +2 -0
- package/dist/chunk-K62NMX3A.js +1 -0
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +8 -3
- package/dist/react/index.d.ts +8 -3
- package/dist/react/index.js +1 -1
- package/dist/react/lazyIndex.cjs +2 -0
- package/dist/react/lazyIndex.d.cts +42 -0
- package/dist/react/lazyIndex.d.ts +42 -0
- package/dist/react/lazyIndex.js +1 -0
- package/dist/react/solanaIndex.cjs +2 -2
- package/dist/react/solanaIndex.d.cts +9 -3
- package/dist/react/solanaIndex.d.ts +9 -3
- package/dist/react/solanaIndex.js +1 -1
- package/dist/{chains-DMjdV7VV.d.cts → types-C11zAA05.d.cts} +1 -64
- package/dist/{chains-DMjdV7VV.d.ts → types-C11zAA05.d.ts} +1 -64
- package/dist/{withdraw-DTHssYc9.d.ts → withdraw-C-sFNUnQ.d.ts} +1 -1
- package/dist/{withdraw-DgTjKpSf.d.cts → withdraw-CwX4HY2X.d.cts} +1 -1
- package/package.json +6 -1
- package/dist/chunk-XFMDEOHO.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SolanaWithdrawalSignature, IDosGamesClient, BlockchainNetworkDefinition, DepositTokenResponse, TokenWithdrawalResponse } from '@idosgames/core';
|
|
2
|
-
import {
|
|
2
|
+
import { a as BridgeResult } from './types-C11zAA05.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The on-chain half of the Solana bridge, delegated to the title's own program integration.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SolanaWithdrawalSignature, IDosGamesClient, BlockchainNetworkDefinition, DepositTokenResponse, TokenWithdrawalResponse } from '@idosgames/core';
|
|
2
|
-
import {
|
|
2
|
+
import { a as BridgeResult } from './types-C11zAA05.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The on-chain half of the Solana bridge, delegated to the title's own program integration.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Chain } from 'viem';
|
|
2
|
+
|
|
3
|
+
declare const mainnet: Chain;
|
|
4
|
+
declare const bsc: Chain;
|
|
5
|
+
declare const polygon: Chain;
|
|
6
|
+
declare const base: Chain;
|
|
7
|
+
declare const arbitrum: Chain;
|
|
8
|
+
declare const optimism: Chain;
|
|
9
|
+
declare const sepolia: Chain;
|
|
10
|
+
declare const polygonAmoy: Chain;
|
|
11
|
+
/** Every chain declared here, keyed by NetworkID-style name — handy for a title-driven picker. */
|
|
12
|
+
declare const idosChains: {
|
|
13
|
+
readonly mainnet: Chain;
|
|
14
|
+
readonly bsc: Chain;
|
|
15
|
+
readonly polygon: Chain;
|
|
16
|
+
readonly base: Chain;
|
|
17
|
+
readonly arbitrum: Chain;
|
|
18
|
+
readonly optimism: Chain;
|
|
19
|
+
readonly sepolia: Chain;
|
|
20
|
+
readonly polygonAmoy: Chain;
|
|
21
|
+
};
|
|
22
|
+
/** Look up a declared chain by its EVM chain id (e.g. from the title's blockchain config). */
|
|
23
|
+
declare function chainById(id: number): Chain | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A chain in the CAIP shape Reown AppKit expects.
|
|
26
|
+
*
|
|
27
|
+
* AppKit ships its own network list at `@reown/appkit/networks`, but that module is
|
|
28
|
+
* `export * from "viem/chains"` — the very barrel this file exists to avoid. Converting our own
|
|
29
|
+
* chains keeps AppKit working without dragging `tempo`/`ox` (and its BigInt `**`) into the bundle.
|
|
30
|
+
*/
|
|
31
|
+
type AppKitEvmNetwork = Chain & {
|
|
32
|
+
chainNamespace: "eip155";
|
|
33
|
+
caipNetworkId: `eip155:${number}`;
|
|
34
|
+
};
|
|
35
|
+
/** Wraps a chain in the CAIP fields AppKit needs. */
|
|
36
|
+
declare function toAppKitNetwork(chain: Chain): AppKitEvmNetwork;
|
|
37
|
+
interface AppKitSolanaNetwork {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
network: string;
|
|
41
|
+
nativeCurrency: {
|
|
42
|
+
name: string;
|
|
43
|
+
symbol: string;
|
|
44
|
+
decimals: number;
|
|
45
|
+
};
|
|
46
|
+
rpcUrls: {
|
|
47
|
+
default: {
|
|
48
|
+
http: string[];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
blockExplorers?: {
|
|
52
|
+
default: {
|
|
53
|
+
name: string;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
testnet: boolean;
|
|
58
|
+
chainNamespace: "solana";
|
|
59
|
+
caipNetworkId: `solana:${string}`;
|
|
60
|
+
}
|
|
61
|
+
declare const solanaMainnet: AppKitSolanaNetwork;
|
|
62
|
+
declare const solanaDevnet: AppKitSolanaNetwork;
|
|
63
|
+
|
|
64
|
+
export { type AppKitEvmNetwork as A, type AppKitSolanaNetwork as a, arbitrum as b, base as c, bsc as d, chainById as e, polygonAmoy as f, solanaDevnet as g, solanaMainnet as h, idosChains as i, mainnet as m, optimism as o, polygon as p, sepolia as s, toAppKitNetwork as t };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Chain } from 'viem';
|
|
2
|
+
|
|
3
|
+
declare const mainnet: Chain;
|
|
4
|
+
declare const bsc: Chain;
|
|
5
|
+
declare const polygon: Chain;
|
|
6
|
+
declare const base: Chain;
|
|
7
|
+
declare const arbitrum: Chain;
|
|
8
|
+
declare const optimism: Chain;
|
|
9
|
+
declare const sepolia: Chain;
|
|
10
|
+
declare const polygonAmoy: Chain;
|
|
11
|
+
/** Every chain declared here, keyed by NetworkID-style name — handy for a title-driven picker. */
|
|
12
|
+
declare const idosChains: {
|
|
13
|
+
readonly mainnet: Chain;
|
|
14
|
+
readonly bsc: Chain;
|
|
15
|
+
readonly polygon: Chain;
|
|
16
|
+
readonly base: Chain;
|
|
17
|
+
readonly arbitrum: Chain;
|
|
18
|
+
readonly optimism: Chain;
|
|
19
|
+
readonly sepolia: Chain;
|
|
20
|
+
readonly polygonAmoy: Chain;
|
|
21
|
+
};
|
|
22
|
+
/** Look up a declared chain by its EVM chain id (e.g. from the title's blockchain config). */
|
|
23
|
+
declare function chainById(id: number): Chain | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A chain in the CAIP shape Reown AppKit expects.
|
|
26
|
+
*
|
|
27
|
+
* AppKit ships its own network list at `@reown/appkit/networks`, but that module is
|
|
28
|
+
* `export * from "viem/chains"` — the very barrel this file exists to avoid. Converting our own
|
|
29
|
+
* chains keeps AppKit working without dragging `tempo`/`ox` (and its BigInt `**`) into the bundle.
|
|
30
|
+
*/
|
|
31
|
+
type AppKitEvmNetwork = Chain & {
|
|
32
|
+
chainNamespace: "eip155";
|
|
33
|
+
caipNetworkId: `eip155:${number}`;
|
|
34
|
+
};
|
|
35
|
+
/** Wraps a chain in the CAIP fields AppKit needs. */
|
|
36
|
+
declare function toAppKitNetwork(chain: Chain): AppKitEvmNetwork;
|
|
37
|
+
interface AppKitSolanaNetwork {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
network: string;
|
|
41
|
+
nativeCurrency: {
|
|
42
|
+
name: string;
|
|
43
|
+
symbol: string;
|
|
44
|
+
decimals: number;
|
|
45
|
+
};
|
|
46
|
+
rpcUrls: {
|
|
47
|
+
default: {
|
|
48
|
+
http: string[];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
blockExplorers?: {
|
|
52
|
+
default: {
|
|
53
|
+
name: string;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
testnet: boolean;
|
|
58
|
+
chainNamespace: "solana";
|
|
59
|
+
caipNetworkId: `solana:${string}`;
|
|
60
|
+
}
|
|
61
|
+
declare const solanaMainnet: AppKitSolanaNetwork;
|
|
62
|
+
declare const solanaDevnet: AppKitSolanaNetwork;
|
|
63
|
+
|
|
64
|
+
export { type AppKitEvmNetwork as A, type AppKitSolanaNetwork as a, arbitrum as b, base as c, bsc as d, chainById as e, polygonAmoy as f, solanaDevnet as g, solanaMainnet as h, idosChains as i, mainnet as m, optimism as o, polygon as p, sepolia as s, toAppKitNetwork as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,a,c}from'./chunk-
|
|
1
|
+
import {b,a,c}from'./chunk-K62NMX3A.js';import {normalizeBlockchainCategory}from'@idosgames/core';async function f(i){let{client:e,adapter:n,network:g,mint:p,amountRaw:o,titleID:d,category:s}=i,t=e.auth.context?.userID;if(!t)return b("deposit-onchain","Not logged in.");if(o<=0n)return b("deposit-onchain","Amount must be positive.");let l;try{l=await n.depositSpl({mint:p,amountRaw:o,userID:t,titleID:d,category:normalizeBlockchainCategory(s)});}catch(c){return b("deposit-onchain",a(c))}let r=await e.blockchain.depositToken(g.NetworkID??"",l);return r.ok?{ok:true,onChainTxHash:l,data:r.data}:b("report",r.error,{onChainTxHash:l})}async function S(i){let{client:e,adapter:n,currencyID:g,networkID:p,walletAddress:o,amount:d,category:s}=i,t=await e.blockchain.requestTokenWithdrawal(g,p,o,d,s);if(!t.ok)return b("request",t.error);let l=t.data.SolanaSignature,r=t.data.TitleTransactionID??void 0;if(!l)return b("request","Withdrawal response carried no Solana signature.",{titleTransactionID:r});let c;try{c=await n.submitWithdrawal(l);}catch(w){return b("withdraw-onchain",a(w),{titleTransactionID:r})}if(!r)return b("confirm","Missing TitleTransactionID.",{onChainTxHash:c});let h=await e.blockchain.confirmWithdrawal(r,c);return h.ok?{ok:true,onChainTxHash:c,data:t.data}:b("confirm",h.error,{onChainTxHash:c,titleTransactionID:r})}async function y(i){let{client:e,networkID:n,walletAddress:g,signMessage:p}=i,o=await e.auth.requestWalletChallenge(g,n);if(!o.ok)return c("challenge",o.error);let d;try{let t=await p(new TextEncoder().encode(o.data.Message));d=T(t);}catch(t){return c("sign",a(t))}let s=await e.auth.loginWithWallet(g,n,d);return s.ok?{ok:true,data:s.data}:c("login",s.error)}function T(i){let e="0x";for(let n of i)e+=n.toString(16).padStart(2,"0");return e}export{f as a,S as b,y as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b as b$1,a,c}from'./chunk-
|
|
1
|
+
import {b as b$1,a,c}from'./chunk-K62NMX3A.js';import {encodeAbiParameters}from'viem';import {normalizeBlockchainCategory}from'@idosgames/core';var w=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],k=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],b=[{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"}]}],D=[{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"}]}],v=[{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 A(e,t,n){return encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[e,t,normalizeBlockchainCategory(n)])}async function f(e,t){let{walletClient:n,publicClient:r,account:m}=e,o=await n.writeContract({address:t.address,abi:t.abi,functionName:t.functionName,args:t.args,account:m,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 I(e){let t=e.RewardPoolAddress;return t||null}async function C(e,t,n,r){return await e.publicClient.readContract({address:t,abi:b,functionName:"allowance",args:[e.account,n]})>=r?null:f(e,{address:t,abi:b,functionName:"approve",args:[n,r]})}async function P(e){let{client:t,clients:n,network:r,tokenAddress:m,amount:o,titleID:u,category:l}=e,i=t.auth.context?.userID;if(!i)return b$1("approve","Not logged in.");let p=I(r);if(!p)return b$1("approve","Network has no RewardPoolAddress.");if(o<=0n)return b$1("approve","Amount must be positive.");try{await C(n,m,p,o);}catch(d){return b$1("approve",a(d))}let c;try{c=await f(n,{address:p,abi:w,functionName:"depositERC20",args:[m,o,i,u,l??""]});}catch(d){return b$1("deposit-onchain",a(d))}let s=await t.blockchain.depositToken(r.NetworkID??"",c);return s.ok?{ok:true,onChainTxHash:c,data:s.data}:b$1("report",s.error,{onChainTxHash:c})}async function R(e){let{client:t,clients:n,network:r,nftContractAddress:m,tokenId:o,amount:u,titleID:l,category:i}=e,p=t.auth.context?.userID;if(!p)return b$1("deposit-onchain","Not logged in.");let c=I(r);if(!c)return b$1("deposit-onchain","Network has no RewardPoolAddress.");if(u<=0n)return b$1("deposit-onchain","Amount must be positive.");let s=A(p,l,i),d;try{d=await f(n,{address:m,abi:D,functionName:"safeTransferFrom",args:[n.account,c,o,u,s]});}catch(T){return b$1("deposit-onchain",a(T))}let g=await t.blockchain.depositNFT(r.NetworkID??"",d);return g.ok?{ok:true,onChainTxHash:d,data:g.data}:b$1("report",g.error,{onChainTxHash:d})}async function H(e){let{client:t,clients:n,network:r,nftContractAddress:m,tokenId:o,titleID:u,category:l}=e,i=t.auth.context?.userID;if(!i)return b$1("deposit-onchain","Not logged in.");let p=I(r);if(!p)return b$1("deposit-onchain","Network has no RewardPoolAddress.");let c=A(i,u,l),s;try{s=await f(n,{address:m,abi:v,functionName:"safeTransferFrom",args:[n.account,p,o,c]});}catch(g){return b$1("deposit-onchain",a(g))}let d=await t.blockchain.depositNFT(r.NetworkID??"",s);return d.ok?{ok:true,onChainTxHash:s,data:d.data}:b$1("report",d.error,{onChainTxHash:s})}async function E(e,t){return f(e,{address:t.ContractAddress,abi:w,functionName:"withdrawERC20",args:[t.TokenAddress,t.WalletAddress,BigInt(t.Amount??"0"),BigInt(t.BurnAmount??"0"),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function x(e,t){return f(e,{address:t.ContractAddress,abi:k,functionName:"withdrawERC1155Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Amount??"0"),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function M(e,t){return f(e,{address:t.ContractAddress,abi:k,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 F(e){let{client:t,clients:n,currencyID:r,networkID:m,walletAddress:o,amount:u,category:l}=e,i=await t.blockchain.requestTokenWithdrawal(r,m,o,u,l);if(!i.ok)return b$1("request",i.error);let p=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!p)return b$1("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let s;try{s=await E(n,p);}catch(g){return b$1("withdraw-onchain",a(g),{titleTransactionID:c})}let d=await N(t,c,s);return d.ok?{ok:true,onChainTxHash:s,data:i.data}:d}async function S(e){let{client:t,clients:n,itemID:r,networkID:m,walletAddress:o,amount:u,category:l}=e,i=await t.blockchain.requestNFTWithdrawal(r,m,o,u,l);if(!i.ok)return b$1("request",i.error);let p=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!p)return b$1("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let s;try{s=await x(n,p);}catch(g){return b$1("withdraw-onchain",a(g),{titleTransactionID:c})}let d=await N(t,c,s);return d.ok?{ok:true,onChainTxHash:s,data:i.data}:d}async function N(e,t,n){if(!t)return b$1("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await e.blockchain.confirmWithdrawal(t,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:b$1("confirm",r.error,{onChainTxHash:n,titleTransactionID:t})}async function G(e){let{client:t,clients:n,networkID:r}=e,m=e.walletAddress??n.account,o=await t.auth.requestWalletChallenge(m,r);if(!o.ok)return c("challenge",o.error);let u;try{u=await n.walletClient.signMessage({account:n.account,message:o.data.Message});}catch(i){return c("sign",a(i))}let l=await t.auth.loginWithWallet(m,r,u);return l.ok?{ok:true,data:l.data}:c("login",l.error)}export{w as a,b,D as c,v as d,A as e,f,C as g,P as h,R as i,H as j,E as k,x as l,M as m,F as n,S as o,G as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var a={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"}}},n={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"}}},o={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"}}},r={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"}}},s={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"}}},l={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"}}},i={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"}}},p={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"}}},c={mainnet:a,bsc:n,polygon:o,base:r,arbitrum:s,optimism:l,sepolia:i,polygonAmoy:p};function m(e){return Object.values(c).find(t=>t.id===e)}function d(e){return {...e,chainNamespace:"eip155",caipNetworkId:`eip155:${e.id}`}}var h={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"},u={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"};
|
|
2
|
+
export{a,n as b,o as c,r as d,s as e,l as f,i as g,p as h,c as i,m as j,d as k,h as l,u as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {BaseError}from'viem';function a(e){return e instanceof BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function o(e,r,t){return {ok:false,stage:e,error:r,...t}}function g(e,r){return {ok:false,stage:e,error:r}}export{a,o as b,g as c};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { W as WalletLoginResult } from './
|
|
2
|
-
export {
|
|
1
|
+
import { W as WalletLoginResult } from './types-C11zAA05.cjs';
|
|
2
|
+
export { B as BridgeFailure, a as BridgeResult, 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-C11zAA05.cjs';
|
|
3
|
+
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';
|
|
3
4
|
import { Hex } from 'viem';
|
|
4
|
-
import { E as EvmBridgeClients } from './withdraw-
|
|
5
|
-
export { D as DepositNft721EvmParams, a as DepositNftEvmParams, b as DepositTokenEvmParams, W as WithdrawNftEvmParams, c as WithdrawTokenEvmParams, d as depositNftEvm, e as depositNftEvm721, f as depositTokenEvm, g as ensureErc20Allowance, s as submitEvmNftWithdrawal, h as submitEvmNftWithdrawal721, i as submitEvmTokenWithdrawal, w as withdrawNftEvm, j as withdrawTokenEvm, k as writeAndWait } from './withdraw-
|
|
5
|
+
import { E as EvmBridgeClients } from './withdraw-CwX4HY2X.cjs';
|
|
6
|
+
export { D as DepositNft721EvmParams, a as DepositNftEvmParams, b as DepositTokenEvmParams, W as WithdrawNftEvmParams, c as WithdrawTokenEvmParams, d as depositNftEvm, e as depositNftEvm721, f as depositTokenEvm, g as ensureErc20Allowance, s as submitEvmNftWithdrawal, h as submitEvmNftWithdrawal721, i as submitEvmTokenWithdrawal, w as withdrawNftEvm, j as withdrawTokenEvm, k as writeAndWait } from './withdraw-CwX4HY2X.cjs';
|
|
6
7
|
import { IDosGamesClient, ClientState } from '@idosgames/core';
|
|
7
|
-
export { D as DepositTokenSolanaParams, S as SolanaProgramAdapter, W as WithdrawTokenSolanaParams, d as depositTokenSolana, w as withdrawTokenSolana } from './bridge-
|
|
8
|
+
export { D as DepositTokenSolanaParams, S as SolanaProgramAdapter, W as WithdrawTokenSolanaParams, d as depositTokenSolana, w as withdrawTokenSolana } from './bridge-8F45t4nD.cjs';
|
|
8
9
|
|
|
9
10
|
declare const rewardPoolAbi: readonly [{
|
|
10
11
|
readonly type: "function";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { W as WalletLoginResult } from './
|
|
2
|
-
export {
|
|
1
|
+
import { W as WalletLoginResult } from './types-C11zAA05.js';
|
|
2
|
+
export { B as BridgeFailure, a as BridgeResult, 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-C11zAA05.js';
|
|
3
|
+
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';
|
|
3
4
|
import { Hex } from 'viem';
|
|
4
|
-
import { E as EvmBridgeClients } from './withdraw-
|
|
5
|
-
export { D as DepositNft721EvmParams, a as DepositNftEvmParams, b as DepositTokenEvmParams, W as WithdrawNftEvmParams, c as WithdrawTokenEvmParams, d as depositNftEvm, e as depositNftEvm721, f as depositTokenEvm, g as ensureErc20Allowance, s as submitEvmNftWithdrawal, h as submitEvmNftWithdrawal721, i as submitEvmTokenWithdrawal, w as withdrawNftEvm, j as withdrawTokenEvm, k as writeAndWait } from './withdraw-
|
|
5
|
+
import { E as EvmBridgeClients } from './withdraw-C-sFNUnQ.js';
|
|
6
|
+
export { D as DepositNft721EvmParams, a as DepositNftEvmParams, b as DepositTokenEvmParams, W as WithdrawNftEvmParams, c as WithdrawTokenEvmParams, d as depositNftEvm, e as depositNftEvm721, f as depositTokenEvm, g as ensureErc20Allowance, s as submitEvmNftWithdrawal, h as submitEvmNftWithdrawal721, i as submitEvmTokenWithdrawal, w as withdrawNftEvm, j as withdrawTokenEvm, k as writeAndWait } from './withdraw-C-sFNUnQ.js';
|
|
6
7
|
import { IDosGamesClient, ClientState } from '@idosgames/core';
|
|
7
|
-
export { D as DepositTokenSolanaParams, S as SolanaProgramAdapter, W as WithdrawTokenSolanaParams, d as depositTokenSolana, w as withdrawTokenSolana } from './bridge-
|
|
8
|
+
export { D as DepositTokenSolanaParams, S as SolanaProgramAdapter, W as WithdrawTokenSolanaParams, d as depositTokenSolana, w as withdrawTokenSolana } from './bridge-BJnRn3NX.js';
|
|
8
9
|
|
|
9
10
|
declare const rewardPoolAbi: readonly [{
|
|
10
11
|
readonly type: "function";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{i as depositNftEvm,j as depositNftEvm721,h as depositTokenEvm,e as encodeNftDepositData,g as ensureErc20Allowance,c as erc1155Abi,b as erc20Abi,d as erc721Abi,p as loginWithWalletEvm,a as rewardPoolAbi,l as submitEvmNftWithdrawal,m as submitEvmNftWithdrawal721,k as submitEvmTokenWithdrawal,o as withdrawNftEvm,n as withdrawTokenEvm,f as writeAndWait}from'./chunk-
|
|
1
|
+
export{i as depositNftEvm,j as depositNftEvm721,h as depositTokenEvm,e as encodeNftDepositData,g as ensureErc20Allowance,c as erc1155Abi,b as erc20Abi,d as erc721Abi,p as loginWithWalletEvm,a as rewardPoolAbi,l as submitEvmNftWithdrawal,m as submitEvmNftWithdrawal721,k as submitEvmTokenWithdrawal,o as withdrawNftEvm,n as withdrawTokenEvm,f as writeAndWait}from'./chunk-DMMHCUIU.js';export{a as depositTokenSolana,c as loginWithWalletSolana,b as withdrawTokenSolana}from'./chunk-44AGTUFV.js';export{b as bridgeFail,a as toErrorMessage,c as walletLoginFail}from'./chunk-K62NMX3A.js';export{e as arbitrum,d as base,b as bsc,j as chainById,i as idosChains,a as mainnet,f as optimism,c as polygon,h as polygonAmoy,g as sepolia,m as solanaDevnet,l as solanaMainnet,k as toAppKitNetwork}from'./chunk-HQNS6ZWL.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 U={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},q={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},j={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},Y={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},z={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},_={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},Q={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},V={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},Z={mainnet:U,bsc:q,polygon:j,base:Y,arbitrum:z,optimism:_,sepolia:Q,polygonAmoy:V};function fe(t){return Object.values(Z).find(e=>e.id===t)}function $(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}var J=null;function X(t){J=t;}function N(){return J}function ve(t){let{chains:e,walletConnectProjectId:n,appName:r,appUrl:o,appIcon:a,transports:d,connectors:l}=t,s={};for(let c of e)s[c.id]=d?.[c.id]??wagmi.http();let u=o??(typeof window<"u"?window.location.origin:""),p={name:r??"iDosGames",description:r??"iDosGames game",url:u,icons:a?[a]:[]};if(n&&!l){let c=e.map($),f=new appkitAdapterWagmi.WagmiAdapter({networks:c,projectId:n,transports:s});return X(react.createAppKit({adapters:[f],networks:c,projectId:n,metadata:p,features:{analytics:false,email:false,socials:false}})),f.wagmiConfig}let m=l??[connectors.injected(),connectors.coinbaseWallet({appName:r??"iDosGames"})];return wagmi.createConfig({chains:e,connectors:m,transports:s})}function D(t){let{wagmiConfig:e,queryClient:n,children:r}=t,[o]=react$1.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:o,children:r})})}var E=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],te=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],P=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],ne=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];function re(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}async function y(t,e){let{walletClient:n,publicClient:r,account:o}=t,a=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:o,chain:n.chain,value:e.value});if((await r.waitForTransactionReceipt({hash:a})).status==="reverted")throw new Error(`On-chain transaction reverted (${a}).`);return a}function g(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function i(t,e,n){return {ok:false,stage:t,error:e,...n}}function h(t,e){return {ok:false,stage:t,error:e}}function oe(t){let e=t.RewardPoolAddress;return e||null}async function ae(t,e,n,r){return await t.publicClient.readContract({address:e,abi:P,functionName:"allowance",args:[t.account,n]})>=r?null:y(t,{address:e,abi:P,functionName:"approve",args:[n,r]})}async function I(t){let{client:e,clients:n,network:r,tokenAddress:o,amount:a,titleID:d,category:l}=t,s=e.auth.context?.userID;if(!s)return i("approve","Not logged in.");let u=oe(r);if(!u)return i("approve","Network has no RewardPoolAddress.");if(a<=0n)return i("approve","Amount must be positive.");try{await ae(n,o,u,a);}catch(c){return i("approve",g(c))}let p;try{p=await y(n,{address:u,abi:E,functionName:"depositERC20",args:[o,a,s,d,l??""]});}catch(c){return i("deposit-onchain",g(c))}let m=await e.blockchain.depositToken(r.NetworkID??"",p);return m.ok?{ok:true,onChainTxHash:p,data:m.data}:i("report",m.error,{onChainTxHash:p})}async function B(t){let{client:e,clients:n,network:r,nftContractAddress:o,tokenId:a,amount:d,titleID:l,category:s}=t,u=e.auth.context?.userID;if(!u)return i("deposit-onchain","Not logged in.");let p=oe(r);if(!p)return i("deposit-onchain","Network has no RewardPoolAddress.");if(d<=0n)return i("deposit-onchain","Amount must be positive.");let m=re(u,l,s),c;try{c=await y(n,{address:o,abi:ne,functionName:"safeTransferFrom",args:[n.account,p,a,d,m]});}catch(k){return i("deposit-onchain",g(k))}let f=await e.blockchain.depositNFT(r.NetworkID??"",c);return f.ok?{ok:true,onChainTxHash:c,data:f.data}:i("report",f.error,{onChainTxHash:c})}async function ie(t,e){return y(t,{address:e.ContractAddress,abi:E,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function se(t,e){return y(t,{address:e.ContractAddress,abi:te,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function R(t){let{client:e,clients:n,currencyID:r,networkID:o,walletAddress:a,amount:d,category:l}=t,s=await e.blockchain.requestTokenWithdrawal(r,o,a,d,l);if(!s.ok)return i("request",s.error);let u=s.data.EvmSignature,p=s.data.TitleTransactionID??void 0;if(!u)return i("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let m;try{m=await ie(n,u);}catch(f){return i("withdraw-onchain",g(f),{titleTransactionID:p})}let c=await le(e,p,m);return c.ok?{ok:true,onChainTxHash:m,data:s.data}:c}async function S(t){let{client:e,clients:n,itemID:r,networkID:o,walletAddress:a,amount:d,category:l}=t,s=await e.blockchain.requestNFTWithdrawal(r,o,a,d,l);if(!s.ok)return i("request",s.error);let u=s.data.EvmSignature,p=s.data.TitleTransactionID??void 0;if(!u)return i("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let m;try{m=await se(n,u);}catch(f){return i("withdraw-onchain",g(f),{titleTransactionID:p})}let c=await le(e,p,m);return c.ok?{ok:true,onChainTxHash:m,data:s.data}:c}async function le(t,e,n){if(!e)return i("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let r=await t.blockchain.confirmWithdrawal(e,n);return r.ok?{ok:true,onChainTxHash:n,data:r.data}:i("confirm",r.error,{onChainTxHash:n,titleTransactionID:e})}async function b(t){let{client:e,clients:n,networkID:r}=t,o=t.walletAddress??n.account,a=await e.auth.requestWalletChallenge(o,r);if(!a.ok)return h("challenge",a.error);let d;try{d=await n.walletClient.signMessage({account:n.account,message:a.data.Message});}catch(s){return h("sign",g(s))}let l=await e.auth.loginWithWallet(o,r,d);return l.ok?{ok:true,data:l.data}:h("login",l.error)}function A(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}var v="Wallet not connected.";function Be(t,e){let n=A();return {connected:!!n,account:n?.account??null,loginWithWallet:(r,o)=>n?b({client:t,clients:n,networkID:r,walletAddress:o}):Promise.resolve(h("challenge",v)),depositToken:r=>n?I({client:t,clients:n,titleID:e,...r}):Promise.resolve(i("approve",v)),depositNft:r=>n?B({client:t,clients:n,titleID:e,...r}):Promise.resolve(i("deposit-onchain",v)),withdrawToken:r=>n?R({client:t,clients:n,...r}):Promise.resolve(i("withdraw-onchain",v)),withdrawNft:r=>n?S({client:t,clients:n,...r}):Promise.resolve(i("withdraw-onchain",v))}}function Ge(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(D,{wagmiConfig:e,children:jsxRuntime.jsx(pe,{...n})})}function Oe(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Ue(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function qe(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function je(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let r=false,o=l=>{r||(r=true,a(),clearTimeout(d),n(l));},a=actions.watchAccount(t,{onChange:l=>{l.isConnected&&o(true);}}),d=setTimeout(()=>o(false),e);})}function Ye(t){let e=o=>t.find(a=>a.id===o||a.type===o),n=e("injected"),r=typeof window<"u"&&window.ethereum!=null;return n&&r?n:e("walletConnect")??n??t[0]}var ze=9e4;async function _e(t){try{let r=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,o=r?.native||r?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function Qe(t,e){return new Promise((n,r)=>{let o=setTimeout(()=>r(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(o),n(a);},a=>{clearTimeout(o),r(a instanceof Error?a:new Error(String(a)));});})}function pe(t){let{client:e,networkID:n,onAuthenticated:r,disabled:o,label:a,style:d}=t,l=wagmi.useConfig(),{isConnected:s}=wagmi.useAccount(),{connectAsync:u,connectors:p}=wagmi.useConnect(),m=A(),[c,f]=react$1.useState(false),[k,w]=react$1.useState(null),[H,M]=react$1.useState(false),L=react$1.useRef(0),de=async()=>{let ue=++L.current,T=()=>L.current===ue;f(true),w(null);try{if(!s){let K=N();if(K){if(await K.open(),!await je(l)){w("No wallet was connected.");return}}else {let G=Ye(p);if(!G){w("No wallet connector is configured.");return}try{await u({connector:G});}catch(O){if(!Oe(O))throw O}}}let C=m??await qe(l);if(!C){w("Wallet client is not available.");return}M(!0);let W=await Qe(b({client:e,clients:C,networkID:n}),ze);if(!T())return;if(W.ok){r();return}w(W.stage==="sign"?"Signature declined.":W.error??"Wallet sign-in failed.");}catch(C){if(!T())return;console.error("[idosgames/wallet] wallet sign-in failed:",C),w(Ue(C));}finally{T()&&(f(false),M(false));}},me=async()=>{await _e(l)||await N()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{H?me():de();},disabled:o,style:{...Ve,...o?{opacity:.6,cursor:"default"}:null,...d},children:H?"Waiting for signature \u2014 tap to open wallet":c?"Check your wallet\u2026":s?a??"Sign in with wallet":"Connect wallet"}),k&&jsxRuntime.jsx("span",{role:"alert",style:Ze,children:k})]})}var Ve={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Ze={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};
|
|
2
|
-
exports.IDosGamesWalletProvider=D;exports.WalletLogin=
|
|
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"}}},z={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"}}},Q={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"}}},V={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"}}},$={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"}}},J={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"}}},X={mainnet:Y,bsc:z,polygon:_,base:Q,arbitrum:V,optimism:Z,sepolia:$,polygonAmoy:J};function we(t){return Object.values(X).find(e=>e.id===t)}function ee(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}var te=null;function ne(t){te=t;}function N(){return te}function Ae(t){let{chains:e,walletConnectProjectId:n,appName:r,appUrl:o,appIcon:a,transports:d,connectors:c}=t,i={};for(let l of e)i[l.id]=d?.[l.id]??wagmi.http();let m=o??(typeof window<"u"?window.location.origin:""),p={name:r??"iDosGames",description:r??"iDosGames game",url:m,icons:a?[a]:[]};if(n&&!c){let l=e.map(ee),f=new appkitAdapterWagmi.WagmiAdapter({networks:l,projectId:n,transports:i});return ne(react.createAppKit({adapters:[f],networks:l,projectId:n,metadata:p,features:{analytics:false,email:false,socials:false}})),f.wagmiConfig}let u=c??[connectors.injected(),connectors.coinbaseWallet({appName:r??"iDosGames"})];return wagmi.createConfig({chains:e,connectors:u,transports:i})}function D(t){let{wagmiConfig:e,queryClient:n,children:r}=t,[o]=react$1.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:o,children:r})})}var E=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],oe=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],P=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],ae=[{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 ie(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}async function y(t,e){let{walletClient:n,publicClient:r,account:o}=t,a=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:o,chain:n.chain,value:e.value});if((await r.waitForTransactionReceipt({hash:a})).status==="reverted")throw new Error(`On-chain transaction reverted (${a}).`);return a}function g(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function s(t,e,n){return {ok:false,stage:t,error:e,...n}}function h(t,e){return {ok:false,stage:t,error:e}}function se(t){let e=t.RewardPoolAddress;return e||null}async function le(t,e,n,r){return await t.publicClient.readContract({address:e,abi:P,functionName:"allowance",args:[t.account,n]})>=r?null:y(t,{address:e,abi:P,functionName:"approve",args:[n,r]})}async function I(t){let{client:e,clients:n,network:r,tokenAddress:o,amount:a,titleID:d,category:c}=t,i=e.auth.context?.userID;if(!i)return s("approve","Not logged in.");let m=se(r);if(!m)return s("approve","Network has no RewardPoolAddress.");if(a<=0n)return s("approve","Amount must be positive.");try{await le(n,o,m,a);}catch(l){return s("approve",g(l))}let p;try{p=await y(n,{address:m,abi:E,functionName:"depositERC20",args:[o,a,i,d,c??""]});}catch(l){return s("deposit-onchain",g(l))}let u=await e.blockchain.depositToken(r.NetworkID??"",p);return u.ok?{ok:true,onChainTxHash:p,data:u.data}:s("report",u.error,{onChainTxHash:p})}async function B(t){let{client:e,clients:n,network:r,nftContractAddress:o,tokenId:a,amount:d,titleID:c,category:i}=t,m=e.auth.context?.userID;if(!m)return s("deposit-onchain","Not logged in.");let p=se(r);if(!p)return s("deposit-onchain","Network has no RewardPoolAddress.");if(d<=0n)return s("deposit-onchain","Amount must be positive.");let u=ie(m,c,i),l;try{l=await y(n,{address:o,abi:ae,functionName:"safeTransferFrom",args:[n.account,p,a,d,u]});}catch(k){return s("deposit-onchain",g(k))}let f=await e.blockchain.depositNFT(r.NetworkID??"",l);return f.ok?{ok:true,onChainTxHash:l,data:f.data}:s("report",f.error,{onChainTxHash:l})}async function ce(t,e){return y(t,{address:e.ContractAddress,abi:E,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function pe(t,e){return y(t,{address:e.ContractAddress,abi:oe,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function R(t){let{client:e,clients:n,currencyID:r,networkID:o,walletAddress:a,amount:d,category:c}=t,i=await e.blockchain.requestTokenWithdrawal(r,o,a,d,c);if(!i.ok)return s("request",i.error);let m=i.data.EvmSignature,p=i.data.TitleTransactionID??void 0;if(!m)return s("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let u;try{u=await ce(n,m);}catch(f){return s("withdraw-onchain",g(f),{titleTransactionID:p})}let l=await de(e,p,u);return l.ok?{ok:true,onChainTxHash:u,data:i.data}:l}async function S(t){let{client:e,clients:n,itemID:r,networkID:o,walletAddress:a,amount:d,category:c}=t,i=await e.blockchain.requestNFTWithdrawal(r,o,a,d,c);if(!i.ok)return s("request",i.error);let m=i.data.EvmSignature,p=i.data.TitleTransactionID??void 0;if(!m)return s("request","Withdrawal response carried no EVM signature.",{titleTransactionID:p});let u;try{u=await pe(n,m);}catch(f){return s("withdraw-onchain",g(f),{titleTransactionID:p})}let l=await de(e,p,u);return l.ok?{ok:true,onChainTxHash:u,data:i.data}:l}async function de(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 b(t){let{client:e,clients:n,networkID:r}=t,o=t.walletAddress??n.account,a=await e.auth.requestWalletChallenge(o,r);if(!a.ok)return h("challenge",a.error);let d;try{d=await n.walletClient.signMessage({account:n.account,message:a.data.Message});}catch(i){return h("sign",g(i))}let c=await e.auth.loginWithWallet(o,r,d);return c.ok?{ok:true,data:c.data}:h("login",c.error)}function A(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}var v="Wallet not connected.";function Fe(t,e){let n=A();return {connected:!!n,account:n?.account??null,loginWithWallet:(r,o)=>n?b({client:t,clients:n,networkID:r,walletAddress:o}):Promise.resolve(h("challenge",v)),depositToken:r=>n?I({client:t,clients:n,titleID:e,...r}):Promise.resolve(s("approve",v)),depositNft:r=>n?B({client:t,clients:n,titleID:e,...r}):Promise.resolve(s("deposit-onchain",v)),withdrawToken:r=>n?R({client:t,clients:n,...r}):Promise.resolve(s("withdraw-onchain",v)),withdrawNft:r=>n?S({client:t,clients:n,...r}):Promise.resolve(s("withdraw-onchain",v))}}function qe(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(D,{wagmiConfig:e,children:jsxRuntime.jsx(fe,{...n})})}function je(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Ye(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function ze(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function _e(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let r=false,o=c=>{r||(r=true,a(),clearTimeout(d),n(c));},a=actions.watchAccount(t,{onChange:c=>{c.isConnected&&o(true);}}),d=setTimeout(()=>o(false),e);})}function Qe(t){let e=o=>t.find(a=>a.id===o||a.type===o),n=e("injected"),r=typeof window<"u"&&window.ethereum!=null;return n&&r?n:e("walletConnect")??n??t[0]}var Ve=9e4;async function Ze(t){try{let r=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,o=r?.native||r?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function $e(t,e){return new Promise((n,r)=>{let o=setTimeout(()=>r(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(o),n(a);},a=>{clearTimeout(o),r(a instanceof Error?a:new Error(String(a)));});})}function fe(t){let{client:e,networkID:n,onAuthenticated:r,disabled:o,label:a,style:d,autoStart:c}=t,i=wagmi.useConfig(),{isConnected:m}=wagmi.useAccount(),{connectAsync:p,connectors:u}=wagmi.useConnect(),l=A(),[f,k]=react$1.useState(false),[H,w]=react$1.useState(null),[M,L]=react$1.useState(false),K=react$1.useRef(0),G=react$1.useRef(false),O=async()=>{let ye=++K.current,T=()=>K.current===ye;k(true),w(null);try{if(!m){let U=N();if(U){if(await U.open(),!await _e(i)){w("No wallet was connected.");return}}else {let q=Qe(u);if(!q){w("No wallet connector is configured.");return}try{await p({connector:q});}catch(j){if(!je(j))throw j}}}let C=l??await ze(i);if(!C){w("Wallet client is not available.");return}L(!0);let W=await $e(b({client:e,clients:C,networkID:n}),Ve);if(!T())return;if(W.ok){r();return}w(W.stage==="sign"?"Signature declined.":W.error??"Wallet sign-in failed.");}catch(C){if(!T())return;console.error("[idosgames/wallet] wallet sign-in failed:",C),w(Ye(C));}finally{T()&&(k(false),L(false));}};react$1.useEffect(()=>{!c||G.current||(G.current=true,O());},[c]);let ge=async()=>{await Ze(i)||await N()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{M?ge():O();},disabled:o,style:{...Je,...o?{opacity:.6,cursor:"default"}:null,...d},children:M?"Waiting for signature \u2014 tap to open wallet":f?"Check your wallet\u2026":m?a??"Sign in with wallet":"Connect wallet"}),H&&jsxRuntime.jsx("span",{role:"alert",style:Xe,children:H})]})}var Je={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Xe={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};
|
|
2
|
+
exports.IDosGamesWalletProvider=D;exports.WalletLogin=qe;exports.WalletLoginButton=fe;exports.arbitrum=V;exports.base=Q;exports.bsc=z;exports.chainById=we;exports.createEvmWalletConfig=Ae;exports.idosChains=X;exports.mainnet=Y;exports.optimism=Z;exports.polygon=_;exports.polygonAmoy=J;exports.sepolia=$;exports.useEvmBridge=Fe;exports.useEvmBridgeClients=A;
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CreateConnectorFn, Config } from 'wagmi';
|
|
2
2
|
import { Chain, Transport } from 'viem';
|
|
3
|
-
|
|
4
|
-
export { h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia } from '../chains-DMjdV7VV.cjs';
|
|
3
|
+
export { b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia } from '../chains-B_P3u8_S.cjs';
|
|
5
4
|
import * as react from 'react';
|
|
6
5
|
import { ReactNode, CSSProperties } from 'react';
|
|
7
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
8
7
|
import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
|
|
9
|
-
import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-
|
|
8
|
+
import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-CwX4HY2X.cjs';
|
|
9
|
+
import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.cjs';
|
|
10
10
|
|
|
11
11
|
interface EvmWalletConfigOptions {
|
|
12
12
|
/** Chains the game supports, matching the EVM networks in the title's blockchain config. */
|
|
@@ -118,6 +118,11 @@ interface WalletLoginProps {
|
|
|
118
118
|
disabled?: boolean;
|
|
119
119
|
label?: string;
|
|
120
120
|
style?: CSSProperties;
|
|
121
|
+
/**
|
|
122
|
+
* Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
|
|
123
|
+
* which already consumed the player's click to load this module — a second tap would be a bug.
|
|
124
|
+
*/
|
|
125
|
+
autoStart?: boolean;
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* Ready-made "sign in with wallet" button: connect → sign the challenge → session.
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CreateConnectorFn, Config } from 'wagmi';
|
|
2
2
|
import { Chain, Transport } from 'viem';
|
|
3
|
-
|
|
4
|
-
export { h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia } from '../chains-DMjdV7VV.js';
|
|
3
|
+
export { b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia } from '../chains-B_P3u8_S.js';
|
|
5
4
|
import * as react from 'react';
|
|
6
5
|
import { ReactNode, CSSProperties } from 'react';
|
|
7
6
|
import { QueryClient } from '@tanstack/react-query';
|
|
8
7
|
import { ClientState, DepositTokenResponse, DepositNFTResponse, TokenWithdrawalResponse, NFTWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
|
|
9
|
-
import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-
|
|
8
|
+
import { b as DepositTokenEvmParams, a as DepositNftEvmParams, c as WithdrawTokenEvmParams, W as WithdrawNftEvmParams, E as EvmBridgeClients } from '../withdraw-C-sFNUnQ.js';
|
|
9
|
+
import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.js';
|
|
10
10
|
|
|
11
11
|
interface EvmWalletConfigOptions {
|
|
12
12
|
/** Chains the game supports, matching the EVM networks in the title's blockchain config. */
|
|
@@ -118,6 +118,11 @@ interface WalletLoginProps {
|
|
|
118
118
|
disabled?: boolean;
|
|
119
119
|
label?: string;
|
|
120
120
|
style?: CSSProperties;
|
|
121
|
+
/**
|
|
122
|
+
* Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
|
|
123
|
+
* which already consumed the player's click to load this module — a second tap would be a bug.
|
|
124
|
+
*/
|
|
125
|
+
autoStart?: boolean;
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* Ready-made "sign in with wallet" button: connect → sign the challenge → session.
|
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {o,n
|
|
1
|
+
import {o,n,i,h,p}from'../chunk-DMMHCUIU.js';import {a,b as b$1}from'../chunk-ZL42KPPC.js';import {b,c}from'../chunk-K62NMX3A.js';import {k}from'../chunk-HQNS6ZWL.js';export{e as arbitrum,d as base,b as bsc,j as chainById,i as idosChains,a as mainnet,f as optimism,c as polygon,h as polygonAmoy,g as sepolia}from'../chunk-HQNS6ZWL.js';import {http,createConfig,WagmiProvider,useAccount,usePublicClient,useWalletClient,useConfig,useConnect}from'wagmi';import {injected,coinbaseWallet}from'wagmi/connectors';import {WagmiAdapter}from'@reown/appkit-adapter-wagmi';import {createAppKit}from'@reown/appkit/react';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {useState,useRef,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getAccount,watchAccount,getWalletClient,getPublicClient}from'wagmi/actions';function me(e){let{chains:o,walletConnectProjectId:t,appName:n,appUrl:r,appIcon:i,transports:p,connectors:s}=e,a$1={};for(let l of o)a$1[l.id]=p?.[l.id]??http();let f=r??(typeof window<"u"?window.location.origin:""),v={name:n??"iDosGames",description:n??"iDosGames game",url:f,icons:i?[i]:[]};if(t&&!s){let l=o.map(k),g=new WagmiAdapter({networks:l,projectId:t,transports:a$1});return a(createAppKit({adapters:[g],networks:l,projectId:t,metadata:v,features:{analytics:false,email:false,socials:false}})),g.wagmiConfig}let h=s??[injected(),coinbaseWallet({appName:n??"iDosGames"})];return createConfig({chains:o,connectors:h,transports:a$1})}function T(e){let{wagmiConfig:o,queryClient:t,children:n}=e,[r]=useState(()=>t??new QueryClient);return jsx(WagmiProvider,{config:o,children:jsx(QueryClientProvider,{client:r,children:n})})}function C(){let{address:e}=useAccount(),o=usePublicClient(),{data:t}=useWalletClient();return !e||!o||!t?null:{account:e,publicClient:o,walletClient:t}}var u="Wallet not connected.";function ve(e,o$1){let t=C();return {connected:!!t,account:t?.account??null,loginWithWallet:(n,r)=>t?p({client:e,clients:t,networkID:n,walletAddress:r}):Promise.resolve(c("challenge",u)),depositToken:n=>t?h({client:e,clients:t,titleID:o$1,...n}):Promise.resolve(b("approve",u)),depositNft:n=>t?i({client:e,clients:t,titleID:o$1,...n}):Promise.resolve(b("deposit-onchain",u)),withdrawToken:n$1=>t?n({client:e,clients:t,...n$1}):Promise.resolve(b("withdraw-onchain",u)),withdrawNft:n=>t?o({client:e,clients:t,...n}):Promise.resolve(b("withdraw-onchain",u))}}function Ne(e){let{wagmiConfig:o,...t}=e;return jsx(T,{wagmiConfig:o,children:jsx(z,{...t})})}function De(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function Ae(e){let o="Wallet sign-in failed. Please try again.";return e instanceof Error?e.name==="ProviderNotFoundError"||/provider not found/i.test(e.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":e.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":o:o}async function Re(e){let o=await getWalletClient(e).catch(()=>null);if(!o)return null;let t=getPublicClient(e);return t?{account:o.account.address,publicClient:t,walletClient:o}:null}function Be(e,o=18e4){return getAccount(e).isConnected?Promise.resolve(true):new Promise(t=>{let n=false,r=s=>{n||(n=true,i(),clearTimeout(p),t(s));},i=watchAccount(e,{onChange:s=>{s.isConnected&&r(true);}}),p=setTimeout(()=>r(false),o);})}function Ie(e){let o=r=>e.find(i=>i.id===r||i.type===r),t=o("injected"),n=typeof window<"u"&&window.ethereum!=null;return t&&n?t:o("walletConnect")??t??e[0]}var Se=9e4;async function xe(e){try{let n=(await getAccount(e).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,r=n?.native||n?.universal;return !r||typeof window>"u"?!1:(window.location.href=r,!0)}catch{return false}}function Ge(e,o){return new Promise((t,n)=>{let r=setTimeout(()=>n(new Error("The wallet request timed out.")),o);e.then(i=>{clearTimeout(r),t(i);},i=>{clearTimeout(r),n(i instanceof Error?i:new Error(String(i)));});})}function z(e){let{client:o,networkID:t,onAuthenticated:n,disabled:r,label:i,style:p$1,autoStart:s}=e,a=useConfig(),{isConnected:f}=useAccount(),{connectAsync:v,connectors:h}=useConnect(),l=C(),[g,k]=useState(false),[N,c]=useState(null),[D,A]=useState(false),R=useRef(0),B=useRef(false),I=async()=>{let J=++R.current,P=()=>R.current===J;k(true),c(null);try{if(!f){let S=b$1();if(S){if(await S.open(),!await Be(a)){c("No wallet was connected.");return}}else {let x=Ie(h);if(!x){c("No wallet connector is configured.");return}try{await v({connector:x});}catch(G){if(!De(G))throw G}}}let m=l??await Re(a);if(!m){c("Wallet client is not available.");return}A(!0);let W=await Ge(p({client:o,clients:m,networkID:t}),Se);if(!P())return;if(W.ok){n();return}c(W.stage==="sign"?"Signature declined.":W.error??"Wallet sign-in failed.");}catch(m){if(!P())return;console.error("[idosgames/wallet] wallet sign-in failed:",m),c(Ae(m));}finally{P()&&(k(false),A(false));}};useEffect(()=>{!s||B.current||(B.current=true,I());},[s]);let H=async()=>{await xe(a)||await b$1()?.open();};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{D?H():I();},disabled:r,style:{...Le,...r?{opacity:.6,cursor:"default"}:null,...p$1},children:D?"Waiting for signature \u2014 tap to open wallet":g?"Check your wallet\u2026":f?i??"Sign in with wallet":"Connect wallet"}),N&&jsx("span",{role:"alert",style:Oe,children:N})]})}var Le={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Oe={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};export{T as IDosGamesWalletProvider,Ne as WalletLogin,z as WalletLoginButton,me as createEvmWalletConfig,ve as useEvmBridge,C as useEvmBridgeClients};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react$1=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),viem=require('viem'),core=require('@idosgames/core'),actions=require('wagmi/actions'),appkitAdapterSolana=require('@reown/appkit-adapter-solana');var pt=Object.defineProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pe=(t,e)=>{for(var n in e)pt(t,n,{get:e[n],enumerable:true});};function ie(t){return Object.values(exports.idosChains).find(e=>e.id===t)}function Se(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}exports.mainnet=void 0;exports.bsc=void 0;exports.polygon=void 0;exports.base=void 0;exports.arbitrum=void 0;exports.optimism=void 0;exports.sepolia=void 0;exports.polygonAmoy=void 0;exports.idosChains=void 0;exports.solanaMainnet=void 0;exports.solanaDevnet=void 0;var E=f(()=>{exports.mainnet={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},exports.bsc={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},exports.polygon={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},exports.base={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},exports.arbitrum={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},exports.optimism={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},exports.sepolia={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},exports.polygonAmoy={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},exports.idosChains={mainnet:exports.mainnet,bsc:exports.bsc,polygon:exports.polygon,base:exports.base,arbitrum:exports.arbitrum,optimism:exports.optimism,sepolia:exports.sepolia,polygonAmoy:exports.polygonAmoy};exports.solanaMainnet={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},exports.solanaDevnet={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};});function te(t){xe=t;}function D(){return xe}var xe,O=f(()=>{xe=null;});function Ee(t){let{chains:e,walletConnectProjectId:n,appName:o,appUrl:a,appIcon:r,transports:p,connectors:s}=t,i={};for(let u of e)i[u.id]=p?.[u.id]??wagmi.http();let c=a??(typeof window<"u"?window.location.origin:""),l={name:o??"iDosGames",description:o??"iDosGames game",url:c,icons:r?[r]:[]};if(n&&!s){let u=e.map(Se),g=new appkitAdapterWagmi.WagmiAdapter({networks:u,projectId:n,transports:i});return te(react$1.createAppKit({adapters:[g],networks:u,projectId:n,metadata:l,features:{analytics:false,email:false,socials:false}})),g.wagmiConfig}let m=s??[connectors.injected(),connectors.coinbaseWallet({appName:o??"iDosGames"})];return wagmi.createConfig({chains:e,connectors:m,transports:i})}var De=f(()=>{E();O();});function ne(t){let{wagmiConfig:e,queryClient:n,children:o}=t,[a]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:a,children:o})})}var le=f(()=>{});var oe,Ne,ce,Re,pe=f(()=>{oe=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],Ne=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],ce=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],Re=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];});function Be(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}var Le=f(()=>{});async function S(t,e){let{walletClient:n,publicClient:o,account:a}=t,r=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:a,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:r})).status==="reverted")throw new Error(`On-chain transaction reverted (${r}).`);return r}var de=f(()=>{});function w(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function d(t,e,n){return {ok:false,stage:t,error:e,...n}}function h(t,e){return {ok:false,stage:t,error:e}}var T=f(()=>{});function Me(t){let e=t.RewardPoolAddress;return e||null}async function Fe(t,e,n,o){return await t.publicClient.readContract({address:e,abi:ce,functionName:"allowance",args:[t.account,n]})>=o?null:S(t,{address:e,abi:ce,functionName:"approve",args:[n,o]})}async function ue(t){let{client:e,clients:n,network:o,tokenAddress:a,amount:r,titleID:p,category:s}=t,i=e.auth.context?.userID;if(!i)return d("approve","Not logged in.");let c=Me(o);if(!c)return d("approve","Network has no RewardPoolAddress.");if(r<=0n)return d("approve","Amount must be positive.");try{await Fe(n,a,c,r);}catch(u){return d("approve",w(u))}let l;try{l=await S(n,{address:c,abi:oe,functionName:"depositERC20",args:[a,r,i,p,s??""]});}catch(u){return d("deposit-onchain",w(u))}let m=await e.blockchain.depositToken(o.NetworkID??"",l);return m.ok?{ok:true,onChainTxHash:l,data:m.data}:d("report",m.error,{onChainTxHash:l})}async function me(t){let{client:e,clients:n,network:o,nftContractAddress:a,tokenId:r,amount:p,titleID:s,category:i}=t,c=e.auth.context?.userID;if(!c)return d("deposit-onchain","Not logged in.");let l=Me(o);if(!l)return d("deposit-onchain","Network has no RewardPoolAddress.");if(p<=0n)return d("deposit-onchain","Amount must be positive.");let m=Be(c,s,i),u;try{u=await S(n,{address:a,abi:Re,functionName:"safeTransferFrom",args:[n.account,l,r,p,m]});}catch(y){return d("deposit-onchain",w(y))}let g=await e.blockchain.depositNFT(o.NetworkID??"",u);return g.ok?{ok:true,onChainTxHash:u,data:g.data}:d("report",g.error,{onChainTxHash:u})}var Ke=f(()=>{pe();Le();de();T();});async function He(t,e){return S(t,{address:e.ContractAddress,abi:oe,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function Ge(t,e){return S(t,{address:e.ContractAddress,abi:Ne,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function ge(t){let{client:e,clients:n,currencyID:o,networkID:a,walletAddress:r,amount:p,category:s}=t,i=await e.blockchain.requestTokenWithdrawal(o,a,r,p,s);if(!i.ok)return d("request",i.error);let c=i.data.EvmSignature,l=i.data.TitleTransactionID??void 0;if(!c)return d("request","Withdrawal response carried no EVM signature.",{titleTransactionID:l});let m;try{m=await He(n,c);}catch(g){return d("withdraw-onchain",w(g),{titleTransactionID:l})}let u=await Oe(e,l,m);return u.ok?{ok:true,onChainTxHash:m,data:i.data}:u}async function fe(t){let{client:e,clients:n,itemID:o,networkID:a,walletAddress:r,amount:p,category:s}=t,i=await e.blockchain.requestNFTWithdrawal(o,a,r,p,s);if(!i.ok)return d("request",i.error);let c=i.data.EvmSignature,l=i.data.TitleTransactionID??void 0;if(!c)return d("request","Withdrawal response carried no EVM signature.",{titleTransactionID:l});let m;try{m=await Ge(n,c);}catch(g){return d("withdraw-onchain",w(g),{titleTransactionID:l})}let u=await Oe(e,l,m);return u.ok?{ok:true,onChainTxHash:m,data:i.data}:u}async function Oe(t,e,n){if(!e)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:d("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}var Ue=f(()=>{pe();de();T();});async function U(t){let{client:e,clients:n,networkID:o}=t,a=t.walletAddress??n.account,r=await e.auth.requestWalletChallenge(a,o);if(!r.ok)return h("challenge",r.error);let p;try{p=await n.walletClient.signMessage({account:n.account,message:r.data.Message});}catch(i){return h("sign",w(i))}let s=await e.auth.loginWithWallet(a,o,p);return s.ok?{ok:true,data:s.data}:h("login",s.error)}var qe=f(()=>{T();});var ye=f(()=>{Ke();Ue();qe();});function z(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}function ze(t,e){let n=z();return {connected:!!n,account:n?.account??null,loginWithWallet:(o,a)=>n?U({client:t,clients:n,networkID:o,walletAddress:a}):Promise.resolve(h("challenge",q)),depositToken:o=>n?ue({client:t,clients:n,titleID:e,...o}):Promise.resolve(d("approve",q)),depositNft:o=>n?me({client:t,clients:n,titleID:e,...o}):Promise.resolve(d("deposit-onchain",q)),withdrawToken:o=>n?ge({client:t,clients:n,...o}):Promise.resolve(d("withdraw-onchain",q)),withdrawNft:o=>n?fe({client:t,clients:n,...o}):Promise.resolve(d("withdraw-onchain",q))}}var q,we=f(()=>{ye();T();q="Wallet not connected.";});function Ye(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(ne,{wagmiConfig:e,children:jsxRuntime.jsx(Ce,{...n})})}function Bt(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Lt(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function Mt(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function Ft(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let o=false,a=s=>{o||(o=true,r(),clearTimeout(p),n(s));},r=actions.watchAccount(t,{onChange:s=>{s.isConnected&&a(true);}}),p=setTimeout(()=>a(false),e);})}function Kt(t){let e=a=>t.find(r=>r.id===a||r.type===a),n=e("injected"),o=typeof window<"u"&&window.ethereum!=null;return n&&o?n:e("walletConnect")??n??t[0]}async function Gt(t){try{let o=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,a=o?.native||o?.universal;return !a||typeof window>"u"?!1:(window.location.href=a,!0)}catch{return false}}function Ot(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function Ce(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:p,autoStart:s}=t,i=wagmi.useConfig(),{isConnected:c}=wagmi.useAccount(),{connectAsync:l,connectors:m}=wagmi.useConnect(),u=z(),[g,y]=react.useState(false),[C,b]=react.useState(null),[R,B]=react.useState(false),P=react.useRef(0),L=react.useRef(false),v=async()=>{let F=++P.current,K=()=>P.current===F;y(true),b(null);try{if(!c){let x=D();if(x){if(await x.open(),!await Ft(i)){b("No wallet was connected.");return}}else {let H=Kt(m);if(!H){b("No wallet connector is configured.");return}try{await l({connector:H});}catch(k){if(!Bt(k))throw k}}}let W=u??await Mt(i);if(!W){b("Wallet client is not available.");return}B(!0);let A=await Ot(U({client:e,clients:W,networkID:n}),Ht);if(!K())return;if(A.ok){o();return}b(A.stage==="sign"?"Signature declined.":A.error??"Wallet sign-in failed.");}catch(W){if(!K())return;console.error("[idosgames/wallet] wallet sign-in failed:",W),b(Lt(W));}finally{K()&&(y(false),B(false));}};react.useEffect(()=>{!s||L.current||(L.current=true,v());},[s]);let M=async()=>{await Gt(i)||await D()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{R?M():v();},disabled:a,style:{...Ut,...a?{opacity:.6,cursor:"default"}:null,...p},children:R?"Waiting for signature \u2014 tap to open wallet":g?"Check your wallet\u2026":c?r??"Sign in with wallet":"Connect wallet"}),C&&jsxRuntime.jsx("span",{role:"alert",style:qt,children:C})]})}var Ht,Ut,qt,Qe=f(()=>{O();ye();le();we();Ht=9e4;Ut={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},qt={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});var Ve={};Pe(Ve,{IDosGamesWalletProvider:()=>ne,WalletLogin:()=>Ye,WalletLoginButton:()=>Ce,arbitrum:()=>exports.arbitrum,base:()=>exports.base,bsc:()=>exports.bsc,chainById:()=>ie,createEvmWalletConfig:()=>Ee,idosChains:()=>exports.idosChains,mainnet:()=>exports.mainnet,optimism:()=>exports.optimism,polygon:()=>exports.polygon,polygonAmoy:()=>exports.polygonAmoy,sepolia:()=>exports.sepolia,useEvmBridge:()=>ze,useEvmBridgeClients:()=>z});var Ze=f(()=>{De();E();le();we();Qe();});function $e(t){let{walletConnectProjectId:e,appName:n,appUrl:o,appIcon:a,wallets:r}=t,p=t.networks??[exports.solanaMainnet],s=o??(typeof window<"u"?window.location.origin:""),i={name:n??"iDosGames",description:n??"iDosGames game",url:s,icons:a?[a]:[]},c=new appkitAdapterSolana.SolanaAdapter(r?{wallets:r}:{});return te(react$1.createAppKit({adapters:[c],networks:p,projectId:e,metadata:i,features:{analytics:false,email:false,socials:false}})),c}var Je=f(()=>{E();O();});async function be(t){let{client:e,adapter:n,network:o,mint:a,amountRaw:r,titleID:p,category:s}=t,i=e.auth.context?.userID;if(!i)return d("deposit-onchain","Not logged in.");if(r<=0n)return d("deposit-onchain","Amount must be positive.");let c;try{c=await n.depositSpl({mint:a,amountRaw:r,userID:i,titleID:p,category:core.normalizeBlockchainCategory(s)});}catch(m){return d("deposit-onchain",w(m))}let l=await e.blockchain.depositToken(o.NetworkID??"",c);return l.ok?{ok:true,onChainTxHash:c,data:l.data}:d("report",l.error,{onChainTxHash:c})}async function ke(t){let{client:e,adapter:n,currencyID:o,networkID:a,walletAddress:r,amount:p,category:s}=t,i=await e.blockchain.requestTokenWithdrawal(o,a,r,p,s);if(!i.ok)return d("request",i.error);let c=i.data.SolanaSignature,l=i.data.TitleTransactionID??void 0;if(!c)return d("request","Withdrawal response carried no Solana signature.",{titleTransactionID:l});let m;try{m=await n.submitWithdrawal(c);}catch(g){return d("withdraw-onchain",w(g),{titleTransactionID:l})}if(!l)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:m});let u=await e.blockchain.confirmWithdrawal(l,m);return u.ok?{ok:true,onChainTxHash:m,data:i.data}:d("confirm",u.error,{onChainTxHash:m,titleTransactionID:l})}var Xe=f(()=>{T();});async function j(t){let{client:e,networkID:n,walletAddress:o,signMessage:a}=t,r=await e.auth.requestWalletChallenge(o,n);if(!r.ok)return h("challenge",r.error);let p;try{let i=await a(new TextEncoder().encode(r.data.Message));p=Vt(i);}catch(i){return h("sign",w(i))}let s=await e.auth.loginWithWallet(o,n,p);return s.ok?{ok:true,data:s.data}:h("login",s.error)}function Vt(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var et=f(()=>{T();});var ve=f(()=>{Xe();et();});function nt(t,e,n){let{address:o}=react$1.useAppKitAccount(),{walletProvider:a}=react$1.useAppKitProvider("solana"),r=o??null,p=a?.signMessage?.bind(a);return {connected:!!r,account:r,loginWithWallet:(s,i)=>{let c=i??r;return c?p?j({client:t,networkID:s,walletAddress:c,signMessage:p}):Promise.resolve(h("sign","The connected wallet does not support message signing.")):Promise.resolve(h("challenge",tt))},depositToken:s=>be({client:t,adapter:n,titleID:e,...s}),withdrawToken:s=>{let i=s.walletAddress??r;return i?ke({client:t,adapter:n,...s,walletAddress:i}):Promise.resolve(d("request",tt))}}}var tt,ot=f(()=>{ve();T();tt="Wallet not connected.";});function nn(t){try{let n=t?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function on(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function rn(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}function at(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:p,autoStart:s}=t,{address:i,isConnected:c}=react$1.useAppKitAccount(),{walletProvider:l}=react$1.useAppKitProvider("solana"),[m,u]=react.useState(false),[g,y]=react.useState(null),[C,b]=react.useState(false),[R,B]=react.useState(false),P=react.useRef(null),L=react.useRef(0),v=react.useCallback(()=>{P.current&&clearTimeout(P.current),P.current=null;},[]);react.useEffect(()=>v,[v]);let M=react.useRef(false),F=react.useCallback(async()=>{let A=++L.current,x=()=>L.current===A,H=l?.signMessage?.bind(l);if(!i||!H){y("The connected wallet cannot sign messages."),u(false);return}u(true),y(null);try{B(!0);let k=await on(j({client:e,networkID:n,walletAddress:i,signMessage:H}),tn);if(!x())return;if(k.ok){o();return}y(k.stage==="sign"?"Signature declined.":k.error??"Wallet sign-in failed.");}catch(k){if(!x())return;console.error("[idosgames/wallet] solana sign-in failed:",k),y(rn(k));}finally{x()&&(u(false),B(false));}},[i,l,e,n,o]),K=react.useCallback(()=>{nn(l)||D()?.open();},[l]);react.useEffect(()=>{!C||!c||!i||!l||(b(false),v(),F());},[C,c,i,l,F,v]);let W=()=>{if(R){K();return}if(y(null),M.current=true,c&&i&&l){F();return}let A=D();if(!A){y("Wallet sign-in is not configured for this title.");return}u(true),b(true),v(),P.current=setTimeout(()=>{b(false),u(false),y("No wallet was connected.");},en),A.open();};return react.useEffect(()=>{!s||M.current||(M.current=true,W());},[s]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:W,disabled:a,style:{...an,...a?{opacity:.6,cursor:"default"}:null,...p},children:R?"Waiting for signature \u2014 tap to open wallet":m?"Check your wallet\u2026":c?r??"Sign in with wallet":"Connect wallet"}),g&&jsxRuntime.jsx("span",{role:"alert",style:sn,children:g})]})}var en,tn,an,sn,it=f(()=>{ve();O();en=18e4,tn=9e4;an={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},sn={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});var st={};Pe(st,{SolanaWalletLogin:()=>at,createSolanaWalletConfig:()=>$e,solanaDevnet:()=>exports.solanaDevnet,solanaMainnet:()=>exports.solanaMainnet,useSolanaBridge:()=>nt});var lt=f(()=>{Je();ot();it();E();});var pn={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},dn={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function ct(t){let{loading:e,disabled:n,label:o,style:a,error:r,onClick:p}=t;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:n||e,style:{...pn,...n||e?{opacity:.6,cursor:"default"}:null,...a},children:e?"Loading wallet\u2026":o??"Sign in with wallet"}),r&&jsxRuntime.jsx("span",{role:"alert",style:dn,children:r})]})}function un(t){let{chains:e,walletConnectProjectId:n,appName:o,disabled:a,label:r,style:p,...s}=t,[i,c]=react.useState(null),[l,m]=react.useState(false),[u,g]=react.useState(null),y=()=>{m(true),g(null),(async()=>{try{let C=await Promise.resolve().then(()=>(Ze(),Ve)),b=C.createEvmWalletConfig({chains:e,walletConnectProjectId:n,appName:o});c({mod:C,config:b});}catch(C){console.error("[idosgames/wallet] failed to load the wallet module:",C),g("Could not load the wallet. Please try again.");}finally{m(false);}})();};if(i){let{WalletLogin:C}=i.mod;return jsxRuntime.jsx(C,{...s,wagmiConfig:i.config,disabled:a,label:r,style:p,autoStart:true})}return jsxRuntime.jsx(ct,{loading:l,disabled:a,label:r,style:p,error:u,onClick:y})}function mn(t){let{walletConnectProjectId:e,appName:n,disabled:o,label:a,style:r,...p}=t,[s,i]=react.useState(null),[c,l]=react.useState(false),[m,u]=react.useState(null),g=()=>{l(true),u(null),(async()=>{try{let y=await Promise.resolve().then(()=>(lt(),st));e&&y.createSolanaWalletConfig({walletConnectProjectId:e,appName:n}),i(y);}catch(y){console.error("[idosgames/wallet] failed to load the wallet module:",y),u("Could not load the wallet. Please try again.");}finally{l(false);}})();};if(s){let{SolanaWalletLogin:y}=s;return jsxRuntime.jsx(y,{...p,disabled:o,label:a,style:r,autoStart:true})}return jsxRuntime.jsx(ct,{loading:c,disabled:o,label:a,style:r,error:m,onClick:g})}E();
|
|
2
|
+
exports.LazySolanaWalletLogin=mn;exports.LazyWalletLogin=un;exports.chainById=ie;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { Chain } from 'viem';
|
|
3
|
+
import { IDosGamesClient } from '@idosgames/core';
|
|
4
|
+
export { a as AppKitSolanaNetwork, b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia, g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.cjs';
|
|
5
|
+
|
|
6
|
+
interface LazyLoginCommonProps {
|
|
7
|
+
/** The (not yet authenticated) shared client. */
|
|
8
|
+
client: IDosGamesClient;
|
|
9
|
+
/** NetworkID the challenge is issued for — one of the title's configured networks. */
|
|
10
|
+
networkID: string;
|
|
11
|
+
/** Called once the wallet signature has been exchanged for a session. */
|
|
12
|
+
onAuthenticated: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* WalletConnect Cloud / Reown project id — what makes phone wallets reachable. Comes from the
|
|
15
|
+
* title's blockchain config; without it only browser-extension wallets are offered.
|
|
16
|
+
*/
|
|
17
|
+
walletConnectProjectId?: string;
|
|
18
|
+
/** App name shown in the wallet's connect prompt. */
|
|
19
|
+
appName?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
label?: string;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
interface LazyWalletLoginProps extends LazyLoginCommonProps {
|
|
25
|
+
/** Chains the title supports, e.g. `[bsc]` — import them from this same subpath. */
|
|
26
|
+
chains: readonly [Chain, ...Chain[]];
|
|
27
|
+
}
|
|
28
|
+
type LazySolanaWalletLoginProps = LazyLoginCommonProps;
|
|
29
|
+
/**
|
|
30
|
+
* "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
|
|
31
|
+
*
|
|
32
|
+
* The first tap fetches the wallet module, builds the wagmi/AppKit config and mounts the real
|
|
33
|
+
* button with `autoStart`, so the sign-in begins immediately — the player still taps once.
|
|
34
|
+
*/
|
|
35
|
+
declare function LazyWalletLogin(props: LazyWalletLoginProps): ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* "Sign in with wallet" for **Solana** titles that loads its machinery on demand. Same contract as
|
|
38
|
+
* {@link LazyWalletLogin}; Solana needs no chain list, only the WalletConnect project id.
|
|
39
|
+
*/
|
|
40
|
+
declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): ReactNode;
|
|
41
|
+
|
|
42
|
+
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { Chain } from 'viem';
|
|
3
|
+
import { IDosGamesClient } from '@idosgames/core';
|
|
4
|
+
export { a as AppKitSolanaNetwork, b as arbitrum, c as base, d as bsc, e as chainById, i as idosChains, m as mainnet, o as optimism, p as polygon, f as polygonAmoy, s as sepolia, g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.js';
|
|
5
|
+
|
|
6
|
+
interface LazyLoginCommonProps {
|
|
7
|
+
/** The (not yet authenticated) shared client. */
|
|
8
|
+
client: IDosGamesClient;
|
|
9
|
+
/** NetworkID the challenge is issued for — one of the title's configured networks. */
|
|
10
|
+
networkID: string;
|
|
11
|
+
/** Called once the wallet signature has been exchanged for a session. */
|
|
12
|
+
onAuthenticated: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* WalletConnect Cloud / Reown project id — what makes phone wallets reachable. Comes from the
|
|
15
|
+
* title's blockchain config; without it only browser-extension wallets are offered.
|
|
16
|
+
*/
|
|
17
|
+
walletConnectProjectId?: string;
|
|
18
|
+
/** App name shown in the wallet's connect prompt. */
|
|
19
|
+
appName?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
label?: string;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
interface LazyWalletLoginProps extends LazyLoginCommonProps {
|
|
25
|
+
/** Chains the title supports, e.g. `[bsc]` — import them from this same subpath. */
|
|
26
|
+
chains: readonly [Chain, ...Chain[]];
|
|
27
|
+
}
|
|
28
|
+
type LazySolanaWalletLoginProps = LazyLoginCommonProps;
|
|
29
|
+
/**
|
|
30
|
+
* "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
|
|
31
|
+
*
|
|
32
|
+
* The first tap fetches the wallet module, builds the wagmi/AppKit config and mounts the real
|
|
33
|
+
* button with `autoStart`, so the sign-in begins immediately — the player still taps once.
|
|
34
|
+
*/
|
|
35
|
+
declare function LazyWalletLogin(props: LazyWalletLoginProps): ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* "Sign in with wallet" for **Solana** titles that loads its machinery on demand. Same contract as
|
|
38
|
+
* {@link LazyWalletLogin}; Solana needs no chain list, only the WalletConnect project id.
|
|
39
|
+
*/
|
|
40
|
+
declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): ReactNode;
|
|
41
|
+
|
|
42
|
+
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{e as arbitrum,d as base,b as bsc,j as chainById,i as idosChains,a as mainnet,f as optimism,c as polygon,h as polygonAmoy,g as sepolia,m as solanaDevnet,l as solanaMainnet}from'../chunk-HQNS6ZWL.js';import {useState}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var E={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},R={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function L(c){let{loading:o,disabled:a,label:n,style:t,error:e,onClick:r}=c;return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:r,disabled:a||o,style:{...E,...a||o?{opacity:.6,cursor:"default"}:null,...t},children:o?"Loading wallet\u2026":n??"Sign in with wallet"}),e&&jsx("span",{role:"alert",style:R,children:e})]})}function A(c){let{chains:o,walletConnectProjectId:a,appName:n,disabled:t,label:e,style:r,...y}=c,[p,b]=useState(null),[g,u]=useState(false),[m,f]=useState(null),l=()=>{u(true),f(null),(async()=>{try{let i=await import('./index.js'),C=i.createEvmWalletConfig({chains:o,walletConnectProjectId:a,appName:n});b({mod:i,config:C});}catch(i){console.error("[idosgames/wallet] failed to load the wallet module:",i),f("Could not load the wallet. Please try again.");}finally{u(false);}})();};if(p){let{WalletLogin:i}=p.mod;return jsx(i,{...y,wagmiConfig:p.config,disabled:t,label:e,style:r,autoStart:true})}return jsx(L,{loading:g,disabled:t,label:e,style:r,error:m,onClick:l})}function D(c){let{walletConnectProjectId:o,appName:a,disabled:n,label:t,style:e,...r}=c,[y,p]=useState(null),[b,g]=useState(false),[u,m]=useState(null),f=()=>{g(true),m(null),(async()=>{try{let l=await import('./solanaIndex.js');o&&l.createSolanaWalletConfig({walletConnectProjectId:o,appName:a}),p(l);}catch(l){console.error("[idosgames/wallet] failed to load the wallet module:",l),m("Could not load the wallet. Please try again.");}finally{g(false);}})();};if(y){let{SolanaWalletLogin:l}=y;return jsx(l,{...r,disabled:n,label:t,style:e,autoStart:true})}return jsx(L,{loading:b,disabled:n,label:t,style:e,error:u,onClick:f})}export{D as LazySolanaWalletLogin,A as LazyWalletLogin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var appkitAdapterSolana=require('@reown/appkit-adapter-solana'),react=require('@reown/appkit/react'),core=require('@idosgames/core'),viem=require('viem'),react$1=require('react'),jsxRuntime=require('react/jsx-runtime');var
|
|
2
|
-
exports.SolanaWalletLogin=
|
|
1
|
+
'use strict';var appkitAdapterSolana=require('@reown/appkit-adapter-solana'),react=require('@reown/appkit/react'),core=require('@idosgames/core'),viem=require('viem'),react$1=require('react'),jsxRuntime=require('react/jsx-runtime');var v={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},z={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};var F=null;function H(e){F=e;}function E(){return F}function $(e){let{walletConnectProjectId:t,appName:n,appUrl:o,appIcon:p,wallets:r}=e,c=e.networks??[v],i=o??(typeof window<"u"?window.location.origin:""),a={name:n??"iDosGames",description:n??"iDosGames game",url:i,icons:p?[p]:[]},s=new appkitAdapterSolana.SolanaAdapter(r?{wallets:r}:{});return H(react.createAppKit({adapters:[s],networks:c,projectId:t,metadata:a,features:{analytics:false,email:false,socials:false}})),s}function y(e){return e instanceof viem.BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function d(e,t,n){return {ok:false,stage:e,error:t,...n}}function f(e,t){return {ok:false,stage:e,error:t}}async function D(e){let{client:t,adapter:n,network:o,mint:p,amountRaw:r,titleID:c,category:i}=e,a=t.auth.context?.userID;if(!a)return d("deposit-onchain","Not logged in.");if(r<=0n)return d("deposit-onchain","Amount must be positive.");let s;try{s=await n.depositSpl({mint:p,amountRaw:r,userID:a,titleID:c,category:core.normalizeBlockchainCategory(i)});}catch(u){return d("deposit-onchain",y(u))}let l=await t.blockchain.depositToken(o.NetworkID??"",s);return l.ok?{ok:true,onChainTxHash:s,data:l.data}:d("report",l.error,{onChainTxHash:s})}async function I(e){let{client:t,adapter:n,currencyID:o,networkID:p,walletAddress:r,amount:c,category:i}=e,a=await t.blockchain.requestTokenWithdrawal(o,p,r,c,i);if(!a.ok)return d("request",a.error);let s=a.data.SolanaSignature,l=a.data.TitleTransactionID??void 0;if(!s)return d("request","Withdrawal response carried no Solana signature.",{titleTransactionID:l});let u;try{u=await n.submitWithdrawal(s);}catch(k){return d("withdraw-onchain",y(k),{titleTransactionID:l})}if(!l)return d("confirm","Missing TitleTransactionID.",{onChainTxHash:u});let m=await t.blockchain.confirmWithdrawal(l,u);return m.ok?{ok:true,onChainTxHash:u,data:a.data}:d("confirm",m.error,{onChainTxHash:u,titleTransactionID:l})}async function S(e){let{client:t,networkID:n,walletAddress:o,signMessage:p}=e,r=await t.auth.requestWalletChallenge(o,n);if(!r.ok)return f("challenge",r.error);let c;try{let a=await p(new TextEncoder().encode(r.data.Message));c=Q(a);}catch(a){return f("sign",y(a))}let i=await t.auth.loginWithWallet(o,n,c);return i.ok?{ok:true,data:i.data}:f("login",i.error)}function Q(e){let t="0x";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}var G="Wallet not connected.";function te(e,t,n){let{address:o}=react.useAppKitAccount(),{walletProvider:p}=react.useAppKitProvider("solana"),r=o??null,c=p?.signMessage?.bind(p);return {connected:!!r,account:r,loginWithWallet:(i,a)=>{let s=a??r;return s?c?S({client:e,networkID:i,walletAddress:s,signMessage:c}):Promise.resolve(f("sign","The connected wallet does not support message signing.")):Promise.resolve(f("challenge",G))},depositToken:i=>D({client:e,adapter:n,titleID:t,...i}),withdrawToken:i=>{let a=i.walletAddress??r;return a?I({client:e,adapter:n,...i,walletAddress:a}):Promise.resolve(d("request",G))}}}var re=18e4,oe=9e4;function ie(e){try{let n=e?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function se(e,t){return new Promise((n,o)=>{let p=setTimeout(()=>o(new Error("The wallet request timed out.")),t);e.then(r=>{clearTimeout(p),n(r);},r=>{clearTimeout(p),o(r instanceof Error?r:new Error(String(r)));});})}function le(e){let t="Wallet sign-in failed. Please try again.";return e instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":t:t}function pe(e){let{client:t,networkID:n,onAuthenticated:o,disabled:p,label:r,style:c,autoStart:i}=e,{address:a,isConnected:s}=react.useAppKitAccount(),{walletProvider:l}=react.useAppKitProvider("solana"),[u,m]=react$1.useState(false),[k,g]=react$1.useState(null),[K,A]=react$1.useState(false),[L,M]=react$1.useState(false),T=react$1.useRef(null),U=react$1.useRef(0),w=react$1.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=null;},[]);react$1.useEffect(()=>w,[w]);let W=react$1.useRef(false),C=react$1.useCallback(async()=>{let x=++U.current,P=()=>U.current===x,q=l?.signMessage?.bind(l);if(!a||!q){g("The connected wallet cannot sign messages."),m(false);return}m(true),g(null);try{M(!0);let h=await se(S({client:t,networkID:n,walletAddress:a,signMessage:q}),oe);if(!P())return;if(h.ok){o();return}g(h.stage==="sign"?"Signature declined.":h.error??"Wallet sign-in failed.");}catch(h){if(!P())return;console.error("[idosgames/wallet] solana sign-in failed:",h),g(le(h));}finally{P()&&(m(false),M(false));}},[a,l,t,n,o]),Y=react$1.useCallback(()=>{ie(l)||E()?.open();},[l]);react$1.useEffect(()=>{!K||!s||!a||!l||(A(false),w(),C());},[K,s,a,l,C,w]);let O=()=>{if(L){Y();return}if(g(null),W.current=true,s&&a&&l){C();return}let x=E();if(!x){g("Wallet sign-in is not configured for this title.");return}m(true),A(true),w(),T.current=setTimeout(()=>{A(false),m(false),g("No wallet was connected.");},re),x.open();};return react$1.useEffect(()=>{!i||W.current||(W.current=true,O());},[i]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:O,disabled:p,style:{...ce,...p?{opacity:.6,cursor:"default"}:null,...c},children:L?"Waiting for signature \u2014 tap to open wallet":u?"Check your wallet\u2026":s?r??"Sign in with wallet":"Connect wallet"}),k&&jsxRuntime.jsx("span",{role:"alert",style:de,children:k})]})}var ce={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},de={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};
|
|
2
|
+
exports.SolanaWalletLogin=pe;exports.createSolanaWalletConfig=$;exports.solanaDevnet=z;exports.solanaMainnet=v;exports.useSolanaBridge=te;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SolanaAdapter } from '@reown/appkit-adapter-solana';
|
|
2
2
|
import { BaseWalletAdapter } from '@solana/wallet-adapter-base';
|
|
3
|
-
import { a as AppKitSolanaNetwork
|
|
4
|
-
export {
|
|
3
|
+
import { a as AppKitSolanaNetwork } from '../chains-B_P3u8_S.cjs';
|
|
4
|
+
export { g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.cjs';
|
|
5
5
|
import { ClientState, DepositTokenResponse, TokenWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
|
|
6
|
-
import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-
|
|
6
|
+
import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-8F45t4nD.cjs';
|
|
7
|
+
import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.cjs';
|
|
7
8
|
import { CSSProperties, ReactNode } from 'react';
|
|
8
9
|
import 'viem';
|
|
9
10
|
|
|
@@ -75,6 +76,11 @@ interface SolanaWalletLoginProps {
|
|
|
75
76
|
disabled?: boolean;
|
|
76
77
|
label?: string;
|
|
77
78
|
style?: CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
|
|
81
|
+
* which already consumed the player's click to load this module — a second tap would be a bug.
|
|
82
|
+
*/
|
|
83
|
+
autoStart?: boolean;
|
|
78
84
|
}
|
|
79
85
|
/**
|
|
80
86
|
* Ready-made "sign in with wallet" button for **Solana** titles: connect → sign the challenge →
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SolanaAdapter } from '@reown/appkit-adapter-solana';
|
|
2
2
|
import { BaseWalletAdapter } from '@solana/wallet-adapter-base';
|
|
3
|
-
import { a as AppKitSolanaNetwork
|
|
4
|
-
export {
|
|
3
|
+
import { a as AppKitSolanaNetwork } from '../chains-B_P3u8_S.js';
|
|
4
|
+
export { g as solanaDevnet, h as solanaMainnet } from '../chains-B_P3u8_S.js';
|
|
5
5
|
import { ClientState, DepositTokenResponse, TokenWithdrawalResponse, IDosGamesClient } from '@idosgames/core';
|
|
6
|
-
import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-
|
|
6
|
+
import { D as DepositTokenSolanaParams, W as WithdrawTokenSolanaParams, S as SolanaProgramAdapter } from '../bridge-BJnRn3NX.js';
|
|
7
|
+
import { W as WalletLoginResult, a as BridgeResult } from '../types-C11zAA05.js';
|
|
7
8
|
import { CSSProperties, ReactNode } from 'react';
|
|
8
9
|
import 'viem';
|
|
9
10
|
|
|
@@ -75,6 +76,11 @@ interface SolanaWalletLoginProps {
|
|
|
75
76
|
disabled?: boolean;
|
|
76
77
|
label?: string;
|
|
77
78
|
style?: CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* Fire the sign-in immediately on mount instead of waiting for a click. Used by the lazy wrapper,
|
|
81
|
+
* which already consumed the player's click to load this module — a second tap would be a bug.
|
|
82
|
+
*/
|
|
83
|
+
autoStart?: boolean;
|
|
78
84
|
}
|
|
79
85
|
/**
|
|
80
86
|
* Ready-made "sign in with wallet" button for **Solana** titles: connect → sign the challenge →
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,a as a$1,c}from'../chunk-
|
|
1
|
+
import {b,a as a$1,c}from'../chunk-44AGTUFV.js';import {a,b as b$2}from'../chunk-ZL42KPPC.js';import {b as b$1,c as c$1}from'../chunk-K62NMX3A.js';import {l}from'../chunk-HQNS6ZWL.js';export{m as solanaDevnet,l as solanaMainnet}from'../chunk-HQNS6ZWL.js';import {SolanaAdapter}from'@reown/appkit-adapter-solana';import {createAppKit,useAppKitAccount,useAppKitProvider}from'@reown/appkit/react';import {useState,useRef,useCallback,useEffect}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function J(e){let{walletConnectProjectId:r,appName:n,appUrl:a$1,appIcon:i,wallets:t}=e,c=e.networks??[l],s=a$1??(typeof window<"u"?window.location.origin:""),o={name:n??"iDosGames",description:n??"iDosGames game",url:s,icons:i?[i]:[]},l$1=new SolanaAdapter(t?{wallets:t}:{});return a(createAppKit({adapters:[l$1],networks:c,projectId:r,metadata:o,features:{analytics:false,email:false,socials:false}})),l$1}var _="Wallet not connected.";function X(e,r,n){let{address:a}=useAppKitAccount(),{walletProvider:i}=useAppKitProvider("solana"),t=a??null,c$2=i?.signMessage?.bind(i);return {connected:!!t,account:t,loginWithWallet:(s,o)=>{let l=o??t;return l?c$2?c({client:e,networkID:s,walletAddress:l,signMessage:c$2}):Promise.resolve(c$1("sign","The connected wallet does not support message signing.")):Promise.resolve(c$1("challenge",_))},depositToken:s=>a$1({client:e,adapter:n,titleID:r,...s}),withdrawToken:s=>{let o=s.walletAddress??t;return o?b({client:e,adapter:n,...s,walletAddress:o}):Promise.resolve(b$1("request",_))}}}var $=18e4,ee=9e4;function te(e){try{let n=e?.session?.peer?.metadata?.redirect,a=n?.native||n?.universal;return !a||typeof window>"u"?!1:(window.location.href=a,!0)}catch{return false}}function ne(e,r){return new Promise((n,a)=>{let i=setTimeout(()=>a(new Error("The wallet request timed out.")),r);e.then(t=>{clearTimeout(i),n(t);},t=>{clearTimeout(i),a(t instanceof Error?t:new Error(String(t)));});})}function oe(e){let r="Wallet sign-in failed. Please try again.";return e instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":r:r}function re(e){let{client:r,networkID:n,onAuthenticated:a,disabled:i,label:t,style:c$1,autoStart:s}=e,{address:o,isConnected:l}=useAppKitAccount(),{walletProvider:p}=useAppKitProvider("solana"),[q,f]=useState(false),[D,d]=useState(null),[I,y]=useState(false),[K,x]=useState(false),m=useRef(null),N=useRef(0),g=useCallback(()=>{m.current&&clearTimeout(m.current),m.current=null;},[]);useEffect(()=>g,[g]);let k=useRef(false),A=useCallback(async()=>{let w=++N.current,W=()=>N.current===w,B=p?.signMessage?.bind(p);if(!o||!B){d("The connected wallet cannot sign messages."),f(false);return}f(true),d(null);try{x(!0);let u=await ne(c({client:r,networkID:n,walletAddress:o,signMessage:B}),ee);if(!W())return;if(u.ok){a();return}d(u.stage==="sign"?"Signature declined.":u.error??"Wallet sign-in failed.");}catch(u){if(!W())return;console.error("[idosgames/wallet] solana sign-in failed:",u),d(oe(u));}finally{W()&&(f(false),x(false));}},[o,p,r,n,a]),j=useCallback(()=>{te(p)||b$2()?.open();},[p]);useEffect(()=>{!I||!l||!o||!p||(y(false),g(),A());},[I,l,o,p,A,g]);let E=()=>{if(K){j();return}if(d(null),k.current=true,l&&o&&p){A();return}let w=b$2();if(!w){d("Wallet sign-in is not configured for this title.");return}f(true),y(true),g(),m.current=setTimeout(()=>{y(false),f(false),d("No wallet was connected.");},$),w.open();};return useEffect(()=>{!s||k.current||(k.current=true,E());},[s]),jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:E,disabled:i,style:{...ae,...i?{opacity:.6,cursor:"default"}:null,...c$1},children:K?"Waiting for signature \u2014 tap to open wallet":q?"Check your wallet\u2026":l?t??"Sign in with wallet":"Connect wallet"}),D&&jsx("span",{role:"alert",style:ie,children:D})]})}var ae={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},ie={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};export{re as SolanaWalletLogin,J as createSolanaWalletConfig,X as useSolanaBridge};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Chain } from 'viem';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Where a multi-step bridge flow stopped. Deposits run approve → deposit-onchain → report;
|
|
5
3
|
* withdrawals run request → withdraw-onchain → confirm. Knowing the stage lets a UI recover
|
|
@@ -56,65 +54,4 @@ interface WalletLoginFailure {
|
|
|
56
54
|
type WalletLoginResult<T> = WalletLoginSuccess<T> | WalletLoginFailure;
|
|
57
55
|
declare function walletLoginFail(stage: WalletLoginStage, error: string): WalletLoginFailure;
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
declare const bsc: Chain;
|
|
61
|
-
declare const polygon: Chain;
|
|
62
|
-
declare const base: Chain;
|
|
63
|
-
declare const arbitrum: Chain;
|
|
64
|
-
declare const optimism: Chain;
|
|
65
|
-
declare const sepolia: Chain;
|
|
66
|
-
declare const polygonAmoy: Chain;
|
|
67
|
-
/** Every chain declared here, keyed by NetworkID-style name — handy for a title-driven picker. */
|
|
68
|
-
declare const idosChains: {
|
|
69
|
-
readonly mainnet: Chain;
|
|
70
|
-
readonly bsc: Chain;
|
|
71
|
-
readonly polygon: Chain;
|
|
72
|
-
readonly base: Chain;
|
|
73
|
-
readonly arbitrum: Chain;
|
|
74
|
-
readonly optimism: Chain;
|
|
75
|
-
readonly sepolia: Chain;
|
|
76
|
-
readonly polygonAmoy: Chain;
|
|
77
|
-
};
|
|
78
|
-
/** Look up a declared chain by its EVM chain id (e.g. from the title's blockchain config). */
|
|
79
|
-
declare function chainById(id: number): Chain | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* A chain in the CAIP shape Reown AppKit expects.
|
|
82
|
-
*
|
|
83
|
-
* AppKit ships its own network list at `@reown/appkit/networks`, but that module is
|
|
84
|
-
* `export * from "viem/chains"` — the very barrel this file exists to avoid. Converting our own
|
|
85
|
-
* chains keeps AppKit working without dragging `tempo`/`ox` (and its BigInt `**`) into the bundle.
|
|
86
|
-
*/
|
|
87
|
-
type AppKitEvmNetwork = Chain & {
|
|
88
|
-
chainNamespace: "eip155";
|
|
89
|
-
caipNetworkId: `eip155:${number}`;
|
|
90
|
-
};
|
|
91
|
-
/** Wraps a chain in the CAIP fields AppKit needs. */
|
|
92
|
-
declare function toAppKitNetwork(chain: Chain): AppKitEvmNetwork;
|
|
93
|
-
interface AppKitSolanaNetwork {
|
|
94
|
-
id: string;
|
|
95
|
-
name: string;
|
|
96
|
-
network: string;
|
|
97
|
-
nativeCurrency: {
|
|
98
|
-
name: string;
|
|
99
|
-
symbol: string;
|
|
100
|
-
decimals: number;
|
|
101
|
-
};
|
|
102
|
-
rpcUrls: {
|
|
103
|
-
default: {
|
|
104
|
-
http: string[];
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
blockExplorers?: {
|
|
108
|
-
default: {
|
|
109
|
-
name: string;
|
|
110
|
-
url: string;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
testnet: boolean;
|
|
114
|
-
chainNamespace: "solana";
|
|
115
|
-
caipNetworkId: `solana:${string}`;
|
|
116
|
-
}
|
|
117
|
-
declare const solanaMainnet: AppKitSolanaNetwork;
|
|
118
|
-
declare const solanaDevnet: AppKitSolanaNetwork;
|
|
119
|
-
|
|
120
|
-
export { type AppKitEvmNetwork as A, type BridgeFailure as B, type WalletLoginResult as W, type AppKitSolanaNetwork as a, type BridgeResult as b, type BridgeStage as c, type BridgeSuccess as d, type WalletLoginFailure as e, type WalletLoginStage as f, type WalletLoginSuccess as g, arbitrum as h, base as i, bridgeFail as j, bsc as k, chainById as l, idosChains as m, mainnet as n, optimism as o, polygon as p, polygonAmoy as q, solanaDevnet as r, sepolia as s, solanaMainnet as t, toAppKitNetwork as u, toErrorMessage as v, walletLoginFail as w };
|
|
57
|
+
export { type BridgeFailure as B, type WalletLoginResult as W, type BridgeResult as a, type BridgeStage as b, type BridgeSuccess as c, type WalletLoginFailure as d, type WalletLoginStage as e, type WalletLoginSuccess as f, bridgeFail as g, toErrorMessage as t, walletLoginFail as w };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Chain } from 'viem';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Where a multi-step bridge flow stopped. Deposits run approve → deposit-onchain → report;
|
|
5
3
|
* withdrawals run request → withdraw-onchain → confirm. Knowing the stage lets a UI recover
|
|
@@ -56,65 +54,4 @@ interface WalletLoginFailure {
|
|
|
56
54
|
type WalletLoginResult<T> = WalletLoginSuccess<T> | WalletLoginFailure;
|
|
57
55
|
declare function walletLoginFail(stage: WalletLoginStage, error: string): WalletLoginFailure;
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
declare const bsc: Chain;
|
|
61
|
-
declare const polygon: Chain;
|
|
62
|
-
declare const base: Chain;
|
|
63
|
-
declare const arbitrum: Chain;
|
|
64
|
-
declare const optimism: Chain;
|
|
65
|
-
declare const sepolia: Chain;
|
|
66
|
-
declare const polygonAmoy: Chain;
|
|
67
|
-
/** Every chain declared here, keyed by NetworkID-style name — handy for a title-driven picker. */
|
|
68
|
-
declare const idosChains: {
|
|
69
|
-
readonly mainnet: Chain;
|
|
70
|
-
readonly bsc: Chain;
|
|
71
|
-
readonly polygon: Chain;
|
|
72
|
-
readonly base: Chain;
|
|
73
|
-
readonly arbitrum: Chain;
|
|
74
|
-
readonly optimism: Chain;
|
|
75
|
-
readonly sepolia: Chain;
|
|
76
|
-
readonly polygonAmoy: Chain;
|
|
77
|
-
};
|
|
78
|
-
/** Look up a declared chain by its EVM chain id (e.g. from the title's blockchain config). */
|
|
79
|
-
declare function chainById(id: number): Chain | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* A chain in the CAIP shape Reown AppKit expects.
|
|
82
|
-
*
|
|
83
|
-
* AppKit ships its own network list at `@reown/appkit/networks`, but that module is
|
|
84
|
-
* `export * from "viem/chains"` — the very barrel this file exists to avoid. Converting our own
|
|
85
|
-
* chains keeps AppKit working without dragging `tempo`/`ox` (and its BigInt `**`) into the bundle.
|
|
86
|
-
*/
|
|
87
|
-
type AppKitEvmNetwork = Chain & {
|
|
88
|
-
chainNamespace: "eip155";
|
|
89
|
-
caipNetworkId: `eip155:${number}`;
|
|
90
|
-
};
|
|
91
|
-
/** Wraps a chain in the CAIP fields AppKit needs. */
|
|
92
|
-
declare function toAppKitNetwork(chain: Chain): AppKitEvmNetwork;
|
|
93
|
-
interface AppKitSolanaNetwork {
|
|
94
|
-
id: string;
|
|
95
|
-
name: string;
|
|
96
|
-
network: string;
|
|
97
|
-
nativeCurrency: {
|
|
98
|
-
name: string;
|
|
99
|
-
symbol: string;
|
|
100
|
-
decimals: number;
|
|
101
|
-
};
|
|
102
|
-
rpcUrls: {
|
|
103
|
-
default: {
|
|
104
|
-
http: string[];
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
blockExplorers?: {
|
|
108
|
-
default: {
|
|
109
|
-
name: string;
|
|
110
|
-
url: string;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
testnet: boolean;
|
|
114
|
-
chainNamespace: "solana";
|
|
115
|
-
caipNetworkId: `solana:${string}`;
|
|
116
|
-
}
|
|
117
|
-
declare const solanaMainnet: AppKitSolanaNetwork;
|
|
118
|
-
declare const solanaDevnet: AppKitSolanaNetwork;
|
|
119
|
-
|
|
120
|
-
export { type AppKitEvmNetwork as A, type BridgeFailure as B, type WalletLoginResult as W, type AppKitSolanaNetwork as a, type BridgeResult as b, type BridgeStage as c, type BridgeSuccess as d, type WalletLoginFailure as e, type WalletLoginStage as f, type WalletLoginSuccess as g, arbitrum as h, base as i, bridgeFail as j, bsc as k, chainById as l, idosChains as m, mainnet as n, optimism as o, polygon as p, polygonAmoy as q, solanaDevnet as r, sepolia as s, solanaMainnet as t, toAppKitNetwork as u, toErrorMessage as v, walletLoginFail as w };
|
|
57
|
+
export { type BridgeFailure as B, type WalletLoginResult as W, type BridgeResult as a, type BridgeStage as b, type BridgeSuccess as c, type WalletLoginFailure as d, type WalletLoginStage as e, type WalletLoginSuccess as f, bridgeFail as g, toErrorMessage as t, walletLoginFail as w };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicClient, WalletClient, Address, Abi, ContractFunctionName, ContractFunctionArgs, Hex } from 'viem';
|
|
2
2
|
import { IDosGamesClient, BlockchainNetworkDefinition, DepositNFTResponse, DepositTokenResponse, WithdrawalSignatureResponse, NFTWithdrawalResponse, TokenWithdrawalResponse } from '@idosgames/core';
|
|
3
|
-
import {
|
|
3
|
+
import { a as BridgeResult } from './types-C11zAA05.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The viem clients + signing account the EVM bridge needs. wagmi supplies all three:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicClient, WalletClient, Address, Abi, ContractFunctionName, ContractFunctionArgs, Hex } from 'viem';
|
|
2
2
|
import { IDosGamesClient, BlockchainNetworkDefinition, DepositNFTResponse, DepositTokenResponse, WithdrawalSignatureResponse, NFTWithdrawalResponse, TokenWithdrawalResponse } from '@idosgames/core';
|
|
3
|
-
import {
|
|
3
|
+
import { a as BridgeResult } from './types-C11zAA05.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The viem clients + signing account the EVM bridge needs. wagmi supplies all three:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idosgames/wallet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Wallet-bridge companion to @idosgames/core: connect browser & mobile wallets (EVM via wagmi/viem/WalletConnect, Solana via wallet-adapter) and move tokens/NFTs in and out of the game through client.blockchain.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"types": "./dist/react/solanaIndex.d.ts",
|
|
48
48
|
"import": "./dist/react/solanaIndex.js",
|
|
49
49
|
"require": "./dist/react/solanaIndex.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./react/lazy": {
|
|
52
|
+
"types": "./dist/react/lazyIndex.d.ts",
|
|
53
|
+
"import": "./dist/react/lazyIndex.js",
|
|
54
|
+
"require": "./dist/react/lazyIndex.cjs"
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
"files": [
|
package/dist/chunk-XFMDEOHO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {BaseError}from'viem';function h(e){return e instanceof BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function g(e,t,a){return {ok:false,stage:e,error:t,...a}}function f(e,t){return {ok:false,stage:e,error:t}}var r={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"}}},o={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"}}},s={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"}}},i={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"}}},l={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"}}},p={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"}}},c={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"}}},m={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"}}},u={mainnet:r,bsc:o,polygon:s,base:i,arbitrum:l,optimism:p,sepolia:c,polygonAmoy:m};function b(e){return Object.values(u).find(t=>t.id===e)}function x(e){return {...e,chainNamespace:"eip155",caipNetworkId:`eip155:${e.id}`}}var k={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"},E={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"};
|
|
2
|
-
export{h as a,g as b,f as c,r as d,o as e,s as f,i as g,l as h,p as i,c as j,m as k,u as l,b as m,x as n,k as o,E as p};
|