@nexus-cross/crossx-sdk-wagmi 2.3.10-beta.3 → 2.3.10-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,SAAS,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,qDAAqD;IACrD,oBAAoB,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC7C,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,yEAAyE;IACzE,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAED,uCAAuC;AACvC,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG;IACtE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,qDAAqD;IACrD,oBAAoB,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC7C,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,yEAAyE;IACzE,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC;;;;;;;;;;;;;OAaG;IACH,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC,CAAC;AAoDF,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,8GAc9D;AAID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,8GAgWpE"}
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,SAAS,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,qDAAqD;IACrD,oBAAoB,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC7C,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,yEAAyE;IACzE,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAED,uCAAuC;AACvC,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG;IACtE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,qDAAqD;IACrD,oBAAoB,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC7C,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,yEAAyE;IACzE,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC;;;;;;;;;;;;;OAaG;IACH,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC,CAAC;AAoDF,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,8GAc9D;AAID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,8GA4dpE"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("wagmi"),F=require("viem"),x=require("@nexus-cross/crossx-sdk-core");function K(r){return parseInt(r.split(":")[1]??"1",10)}function A(r){return`eip155:${r}`}function b(r){return"0x"+r.toString(16)}function q(r){const e=r.startsWith("0x")?r.slice(2):r,i=new Uint8Array(e.length/2);for(let n=0;n<i.length;n++)i[n]=parseInt(e.substring(n*2,n*2+2),16);return new TextDecoder().decode(i)}class M{constructor(e,i=x.ChainId.CROSS_MAINNET){this.sdk=e,this.listeners=new Map,this.walletIndex=0,this.currentAccounts=[],this.off=this.removeListener.bind(this),this.chainId=typeof i=="number"?i:K(i),this.sdk.on("addressChanged",({address:n,index:l})=>{this.setWalletIndex(l),this.notifyAccountsChanged([n])})}_setWalletIndexChangeCallback(e){this.walletIndexChangeCallback=e}async request({method:e,params:i}){try{return await this._handleRequest(e,i)}catch(n){throw n instanceof x.CROSSxError&&n.code===x.ErrorCode.USER_REJECTED?Object.assign(new Error("User rejected the request"),{code:4001,data:n.details}):n}}async _handleRequest(e,i){var l;const n=i??[];switch(e){case"eth_requestAccounts":case"eth_accounts":{if(this.currentAccounts.length>0)return[...this.currentAccounts];const t=await this.sdk.getAddress();return t?[t.address]:[]}case"eth_chainId":return b(this.chainId);case"net_version":return String(this.chainId);case"personal_sign":{const[t]=n,c=t.startsWith("0x")?q(t):t;return(await this.sdk.signMessage(A(this.chainId),c,{index:this.walletIndex})).signature}case"eth_sign":{const[,t]=n,c=t.startsWith("0x")?q(t):t;return(await this.sdk.signMessage(A(this.chainId),c,{index:this.walletIndex})).signature}case"eth_signTypedData":case"eth_signTypedData_v3":case"eth_signTypedData_v4":{const[,t]=n,c=typeof t=="string"?JSON.parse(t):t,h=(l=c==null?void 0:c.domain)==null?void 0:l.chainId,f=h==null||h===0,m=f?0:Number(h),g={index:this.walletIndex};return(f?await this.sdk.signTypedDataOffchain(c,g):await this.sdk.signTypedData(A(m),c,g)).signature}case"eth_sendTransaction":{const[t]=n,c=A(this.chainId);return(await this.sdk.sendTransaction(c,{from:t.from,to:t.to,value:t.value,data:t.data,gasLimit:t.gasLimit??t.gas,gasPrice:t.gasPrice,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas,nonce:t.nonce!==void 0?parseInt(String(t.nonce),16):void 0,chainId:this.chainId},{index:this.walletIndex})).txHash}case"wallet_switchEthereumChain":{const[{chainId:t}]=n,c=parseInt(t,16);return c!==this.chainId&&(this.chainId=c,this.emit("chainChanged",b(c))),null}case"wallet_addEthereumChain":return null;default:return this.sdk.walletRpc(e,n,A(this.chainId))}}on(e,i){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(i),this}removeListener(e,i){var n;return(n=this.listeners.get(e))==null||n.delete(i),this}emit(e,...i){var n;(n=this.listeners.get(e))==null||n.forEach(l=>l(...i))}notifyAccountsChanged(e){this.currentAccounts=e,this.emit("accountsChanged",e)}notifyDisconnect(e){this.currentAccounts=[],this.walletIndex=0,this.emit("disconnect",e)}getCurrentChainId(){return this.chainId}setChainId(e){e!==this.chainId&&(this.chainId=e,this.emit("chainChanged",b(e)))}setWalletIndex(e){var i;this.walletIndex=e,(i=this.walletIndexChangeCallback)==null||i.call(this,e)}getWalletIndex(){return this.walletIndex}getCurrentAccounts(){return[...this.currentAccounts]}}function H(r){return typeof r=="number"?r:parseInt(r.split(":")[1]??"1",10)}const k="crossx-wallet-index";function J(){try{const r=typeof window<"u"?localStorage.getItem(k):null;return r&&Number(r)||0}catch{return 0}}function Y(r){try{typeof window<"u"&&localStorage.setItem(k,String(r))}catch{}}function G(){try{typeof window<"u"&&localStorage.removeItem(k)}catch{}}const T="crossx-wallet-address";function $(){try{return typeof window<"u"?localStorage.getItem(T):null}catch{return null}}function B(r){try{typeof window<"u"&&localStorage.setItem(T,r)}catch{}}function Q(){try{typeof window<"u"&&localStorage.removeItem(T)}catch{}}function X(r){const{defaultChainId:e,getStoredWalletIndex:i,onWalletIndexChanged:n,getStoredWalletAddress:l,onWalletAddressChanged:t,clearStoredWalletAddress:c,openConnectOtherWallet:h,...f}=r;if(h){const g=f.connectOtherWallets,S=Array.isArray(g)&&g.length>0,y=f.showConnectOtherWallets===!0;!S&&!y&&(f.showConnectOtherWallets=!0)}const m=x.createCROSSxSDK(f);return U({sdk:m,defaultChainId:e,getStoredWalletIndex:i,onWalletIndexChanged:n,getStoredWalletAddress:l,onWalletAddressChanged:t,clearStoredWalletAddress:c,openConnectOtherWallet:h})}function U(r){const{sdk:e,defaultChainId:i=x.ChainId.CROSS_MAINNET,getStoredWalletIndex:n=J,onWalletIndexChanged:l=Y,getStoredWalletAddress:t=$,onWalletAddressChanged:c=B,clearStoredWalletAddress:h=Q,openConnectOtherWallet:f}=r,m=H(i);let g=null,S=!1,y=null,P=!1,E=!1,O=!1;function C(){return g||(g=new M(e,m),g._setWalletIndexChangeCallback(l)),g}return z.createConnector(I=>{function L(s){if(P)return;const o=C();o.on("accountsChanged",s.onAccountsChanged.bind(s)),o.on("chainChanged",s.onChainChanged.bind(s)),o.on("disconnect",s.onDisconnect.bind(s)),P=!0}function _(s){const o=C();o.notifyAccountsChanged([s]),I.emitter.emit("connect",{accounts:[s],chainId:o.getCurrentChainId()})}async function v(){if(!S)return y||(y=(async()=>{const s=n(),o=t()??void 0;await e.initialize({preferredWalletIndex:s,preferredWalletAddress:o}),e.on("addressChanged",({address:a,index:u})=>{if(E)return;const W=C();W.setWalletIndex(u),a&&(c(a),e.isAuthenticated()?_(a):W.notifyAccountsChanged([a]))}),e.on("authChanged",a=>{if(!(E||O)){if(a.isAuthenticated){if(a.address){_(a.address);return}e.getAddress().then(u=>{u!=null&&u.address&&e.isAuthenticated()&&_(u.address)}).catch(()=>{});return}C().notifyDisconnect(),G(),h(),l(0),I.emitter.emit("disconnect")}}),f&&e.on("connectExternalWallet",f),S=!0})().finally(()=>{y=null}),y)}return{id:"crossx",name:x.WALLET_BRAND_NAME,type:"crossx",async setup(){await v(),L(this)},async connect({chainId:s,isReconnecting:o}={}){await v(),L(this);const a=C(),u=s??m;E=!0;try{if(e.isAuthenticated()){const d=await e.getAddress();if(d)return a.setWalletIndex(d.index),a.notifyAccountsChanged([d.address]),{accounts:[d.address],chainId:u};if(o)throw new Error("CROSSx reconnect: authenticated session has no active wallet address");await e.signOut().catch(()=>{}),a.notifyDisconnect()}if(o)throw new Error("CROSSx reconnect: no authenticated session to restore");const W=t();let p;try{p=await e.signInWithCreate({preferredWalletAddress:W??void 0})}catch(d){throw d instanceof x.CROSSxError&&d.code===x.ErrorCode.EXTERNAL_WALLET_REQUESTED?(a.notifyDisconnect(),new F.UserRejectedRequestError(d)):(e.isAuthenticated()||(a.notifyDisconnect(),I.emitter.emit("disconnect")),d)}if(!p.success)throw new Error(p.error??"CROSSx sign-in failed");const w=p.address,N=p.addresses.map(d=>d.address).filter(d=>!w||d.toLowerCase()!==w.toLowerCase()),R=w?[w,...N]:N;if(R.length===0)throw new Error("No address found after sign-in");const D=p.addresses.find(d=>w&&d.address.toLowerCase()===w.toLowerCase()),j=(D==null?void 0:D.index)??0;return a.setWalletIndex(j),a.notifyAccountsChanged(R),w&&c(w),{accounts:R,chainId:u}}finally{E=!1}},async disconnect(){O=!0;try{const s=C();await e.signOut(),s.notifyDisconnect(),G(),h(),l(0),I.emitter.emit("disconnect")}finally{O=!1}},async getAccounts(){const o=C().getCurrentAccounts();if(o.length>0)return o;const a=await e.getAddress();return a?[a.address]:[]},async getChainId(){return C().getCurrentChainId()},async getProvider({chainId:s}={}){return C()},async isAuthorized(){return await v(),e.isAuthenticated()},async switchChain({chainId:s}){C().setChainId(s),I.emitter.emit("change",{chainId:s});const a=I.chains.find(u=>u.id===s);if(!a)throw new Error(`Chain ${s} is not configured`);return a},onAccountsChanged(s){s.length===0?I.emitter.emit("disconnect"):I.emitter.emit("change",{accounts:s})},onChainChanged(s){I.emitter.emit("change",{chainId:Number(s)})},onDisconnect(){I.emitter.emit("disconnect")}}})}exports.CROSSxEIP1193Provider=M;exports.createCROSSxConnector=U;exports.crossxConnector=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("wagmi"),B=require("viem"),y=require("@nexus-cross/crossx-sdk-core");function Q(r){return parseInt(r.split(":")[1]??"1",10)}function k(r){return`eip155:${r}`}function M(r){return"0x"+r.toString(16)}function F(r){const t=r.startsWith("0x")?r.slice(2):r,i=new Uint8Array(t.length/2);for(let n=0;n<i.length;n++)i[n]=parseInt(t.substring(n*2,n*2+2),16);return new TextDecoder().decode(i)}class H{constructor(t,i=y.ChainId.CROSS_MAINNET){this.sdk=t,this.listeners=new Map,this.walletIndex=0,this.currentAccounts=[],this.off=this.removeListener.bind(this),this.chainId=typeof i=="number"?i:Q(i),this.sdk.on("addressChanged",({address:n,index:u})=>{this.setWalletIndex(u),this.notifyAccountsChanged([n])})}_setWalletIndexChangeCallback(t){this.walletIndexChangeCallback=t}async request({method:t,params:i}){try{return await this._handleRequest(t,i)}catch(n){throw n instanceof y.CROSSxError&&n.code===y.ErrorCode.USER_REJECTED?Object.assign(new Error("User rejected the request"),{code:4001,data:n.details}):n}}async _handleRequest(t,i){var u;const n=i??[];switch(t){case"eth_requestAccounts":case"eth_accounts":{if(this.currentAccounts.length>0)return[...this.currentAccounts];const e=await this.sdk.getAddress();return e?[e.address]:[]}case"eth_chainId":return M(this.chainId);case"net_version":return String(this.chainId);case"personal_sign":{const[e]=n,o=e.startsWith("0x")?F(e):e;return(await this.sdk.signMessage(k(this.chainId),o,{index:this.walletIndex})).signature}case"eth_sign":{const[,e]=n,o=e.startsWith("0x")?F(e):e;return(await this.sdk.signMessage(k(this.chainId),o,{index:this.walletIndex})).signature}case"eth_signTypedData":case"eth_signTypedData_v3":case"eth_signTypedData_v4":{const[,e]=n,o=typeof e=="string"?JSON.parse(e):e,f=(u=o==null?void 0:o.domain)==null?void 0:u.chainId,x=f==null||f===0,p=x?0:Number(f),m={index:this.walletIndex};return(x?await this.sdk.signTypedDataOffchain(o,m):await this.sdk.signTypedData(k(p),o,m)).signature}case"eth_sendTransaction":{const[e]=n,o=k(this.chainId);return(await this.sdk.sendTransaction(o,{from:e.from,to:e.to,value:e.value,data:e.data,gasLimit:e.gasLimit??e.gas,gasPrice:e.gasPrice,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,nonce:e.nonce!==void 0?parseInt(String(e.nonce),16):void 0,chainId:this.chainId},{index:this.walletIndex})).txHash}case"wallet_switchEthereumChain":{const[{chainId:e}]=n,o=parseInt(e,16);return o!==this.chainId&&(this.chainId=o,this.emit("chainChanged",M(o))),null}case"wallet_addEthereumChain":return null;default:return this.sdk.walletRpc(t,n,k(this.chainId))}}on(t,i){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(i),this}removeListener(t,i){var n;return(n=this.listeners.get(t))==null||n.delete(i),this}emit(t,...i){var n;(n=this.listeners.get(t))==null||n.forEach(u=>u(...i))}notifyAccountsChanged(t){this.currentAccounts=t,this.emit("accountsChanged",t)}notifyDisconnect(t){this.currentAccounts=[],this.walletIndex=0,this.emit("disconnect",t)}getCurrentChainId(){return this.chainId}setChainId(t){t!==this.chainId&&(this.chainId=t,this.emit("chainChanged",M(t)))}setWalletIndex(t){var i;this.walletIndex=t,(i=this.walletIndexChangeCallback)==null||i.call(this,t)}getWalletIndex(){return this.walletIndex}getCurrentAccounts(){return[...this.currentAccounts]}}function X(r){return typeof r=="number"?r:parseInt(r.split(":")[1]??"1",10)}const U="crossx-wallet-index";function V(){try{const r=typeof window<"u"?localStorage.getItem(U):null;return r&&Number(r)||0}catch{return 0}}function Z(r){try{typeof window<"u"&&localStorage.setItem(U,String(r))}catch{}}function K(){try{typeof window<"u"&&localStorage.removeItem(U)}catch{}}const j="crossx-wallet-address";function tt(){try{return typeof window<"u"?localStorage.getItem(j):null}catch{return null}}function et(r){try{typeof window<"u"&&localStorage.setItem(j,r)}catch{}}function nt(){try{typeof window<"u"&&localStorage.removeItem(j)}catch{}}function st(r){const{defaultChainId:t,getStoredWalletIndex:i,onWalletIndexChanged:n,getStoredWalletAddress:u,onWalletAddressChanged:e,clearStoredWalletAddress:o,openConnectOtherWallet:f,...x}=r;if(f){const m=x.connectOtherWallets,W=Array.isArray(m)&&m.length>0,A=x.showConnectOtherWallets===!0;!W&&!A&&(x.showConnectOtherWallets=!0)}const p=y.createCROSSxSDK(x);return J({sdk:p,defaultChainId:t,getStoredWalletIndex:i,onWalletIndexChanged:n,getStoredWalletAddress:u,onWalletAddressChanged:e,clearStoredWalletAddress:o,openConnectOtherWallet:f})}function J(r){const{sdk:t,defaultChainId:i=y.ChainId.CROSS_MAINNET,getStoredWalletIndex:n=V,onWalletIndexChanged:u=Z,getStoredWalletAddress:e=tt,onWalletAddressChanged:o=et,clearStoredWalletAddress:f=nt,openConnectOtherWallet:x}=r,p=X(i);let m=null,W=!1,A=null,z=!1,v=!1,L=!1,S=null,D=!1;function N(I){const O=S;return O?(S=null,D=!1,O(I),!0):!1}function C(){return m||(m=new H(t,p),m._setWalletIndexChangeCallback(u)),m}return $.createConnector(I=>{function O(s){if(z)return;const l=C();l.on("accountsChanged",s.onAccountsChanged.bind(s)),l.on("chainChanged",s.onChainChanged.bind(s)),l.on("disconnect",s.onDisconnect.bind(s)),z=!0}function q(s){const l=C();l.notifyAccountsChanged([s]),I.emitter.emit("connect",{accounts:[s],chainId:l.getCurrentChainId()})}async function G(){if(!W)return A||(A=(async()=>{const s=n(),l=e()??void 0;await t.initialize({preferredWalletIndex:s,preferredWalletAddress:l}),t.on("addressChanged",({address:a,index:d})=>{if(v){D&&a&&t.isAuthenticated()&&S&&(C().setWalletIndex(d),o(a),N(a));return}const b=C();b.setWalletIndex(d),a&&(o(a),t.isAuthenticated()?q(a):b.notifyAccountsChanged([a]))}),t.on("authChanged",a=>{if(a.isAuthenticated&&a.source==="external"&&S){if(a.address){N(a.address);return}D=!0,t.getAddress().then(d=>{d!=null&&d.address&&t.isAuthenticated()&&N(d.address)}).catch(()=>{});return}if(!(v||L)){if(a.isAuthenticated){if(a.address){q(a.address);return}t.getAddress().then(d=>{d!=null&&d.address&&t.isAuthenticated()&&q(d.address)}).catch(()=>{});return}C().notifyDisconnect(),K(),f(),u(0),I.emitter.emit("disconnect")}}),x&&t.on("connectExternalWallet",x),W=!0})().finally(()=>{A=null}),A)}return{id:"crossx",name:y.WALLET_BRAND_NAME,type:"crossx",async setup(){await G(),O(this)},async connect({chainId:s,isReconnecting:l}={}){const a=s??p;v=!0;const d=new Promise(w=>{S=w}),b=this,Y=async()=>{await G(),O(b);const w=C();if(t.isAuthenticated()){const c=await t.getAddress();if(c)return w.setWalletIndex(c.index),w.notifyAccountsChanged([c.address]),{accounts:[c.address],chainId:a};if(l)throw new Error("CROSSx reconnect: authenticated session has no active wallet address");await t.signOut().catch(()=>{}),w.notifyDisconnect()}if(l)throw new Error("CROSSx reconnect: no authenticated session to restore");const _=e();let g;try{g=await t.signInWithCreate({preferredWalletAddress:_??void 0})}catch(c){throw c instanceof y.CROSSxError&&c.code===y.ErrorCode.EXTERNAL_WALLET_REQUESTED?(w.notifyDisconnect(),new B.UserRejectedRequestError(c)):(t.isAuthenticated()||(w.notifyDisconnect(),I.emitter.emit("disconnect")),c)}if(!g.success)throw new Error(g.error??"CROSSx sign-in failed");const h=g.address,E=g.addresses.map(c=>c.address).filter(c=>!h||c.toLowerCase()!==h.toLowerCase()),T=h?[h,...E]:E;if(T.length===0)throw new Error("No address found after sign-in");const R=g.addresses.find(c=>h&&c.address.toLowerCase()===h.toLowerCase()),P=(R==null?void 0:R.index)??0;return w.setWalletIndex(P),w.notifyAccountsChanged(T),h&&o(h),{accounts:T,chainId:a}};try{const w=Y();w.catch(()=>{});const _=await Promise.race([w.then(g=>({kind:"inner",value:g})),d.then(g=>({kind:"external",address:g}))]);if(_.kind==="external"){const g=C(),h=await t.getAddress().catch(()=>null),E=(h==null?void 0:h.address)??_.address,R=(await t.getAddresses().catch(()=>[])).map(c=>c.address).filter(c=>c.toLowerCase()!==E.toLowerCase()),P=[E,...R];return g.setWalletIndex((h==null?void 0:h.index)??0),g.notifyAccountsChanged(P),o(E),{accounts:P,chainId:a}}return _.value}finally{v=!1,S=null,D=!1}},async disconnect(){L=!0;try{const s=C();await t.signOut(),s.notifyDisconnect(),K(),f(),u(0),I.emitter.emit("disconnect")}finally{L=!1}},async getAccounts(){const l=C().getCurrentAccounts();if(l.length>0)return l;const a=await t.getAddress();return a?[a.address]:[]},async getChainId(){return C().getCurrentChainId()},async getProvider({chainId:s}={}){return C()},async isAuthorized(){return await G(),t.isAuthenticated()},async switchChain({chainId:s}){C().setChainId(s),I.emitter.emit("change",{chainId:s});const a=I.chains.find(d=>d.id===s);if(!a)throw new Error(`Chain ${s} is not configured`);return a},onAccountsChanged(s){s.length===0?I.emitter.emit("disconnect"):I.emitter.emit("change",{accounts:s})},onChainChanged(s){I.emitter.emit("change",{chainId:Number(s)})},onDisconnect(){I.emitter.emit("disconnect")}}})}exports.CROSSxEIP1193Provider=H;exports.createCROSSxConnector=J;exports.crossxConnector=st;
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- import { createConnector as F } from "wagmi";
2
- import { UserRejectedRequestError as j } from "viem";
3
- import { ChainId as q, CROSSxError as M, ErrorCode as U, WALLET_BRAND_NAME as K, createCROSSxSDK as H } from "@nexus-cross/crossx-sdk-core";
4
- function J(r) {
1
+ import { createConnector as $ } from "wagmi";
2
+ import { UserRejectedRequestError as B } from "viem";
3
+ import { ChainId as K, CROSSxError as H, ErrorCode as J, WALLET_BRAND_NAME as Q, createCROSSxSDK as X } from "@nexus-cross/crossx-sdk-core";
4
+ function V(r) {
5
5
  return parseInt(r.split(":")[1] ?? "1", 10);
6
6
  }
7
- function A(r) {
7
+ function k(r) {
8
8
  return `eip155:${r}`;
9
9
  }
10
- function R(r) {
10
+ function q(r) {
11
11
  return "0x" + r.toString(16);
12
12
  }
13
- function N(r) {
13
+ function F(r) {
14
14
  const t = r.startsWith("0x") ? r.slice(2) : r, i = new Uint8Array(t.length / 2);
15
15
  for (let n = 0; n < i.length; n++)
16
16
  i[n] = parseInt(t.substring(n * 2, n * 2 + 2), 16);
17
17
  return new TextDecoder().decode(i);
18
18
  }
19
- class Y {
20
- constructor(t, i = q.CROSS_MAINNET) {
21
- this.sdk = t, this.listeners = /* @__PURE__ */ new Map(), this.walletIndex = 0, this.currentAccounts = [], this.off = this.removeListener.bind(this), this.chainId = typeof i == "number" ? i : J(i), this.sdk.on("addressChanged", ({ address: n, index: l }) => {
22
- this.setWalletIndex(l), this.notifyAccountsChanged([n]);
19
+ class Z {
20
+ constructor(t, i = K.CROSS_MAINNET) {
21
+ this.sdk = t, this.listeners = /* @__PURE__ */ new Map(), this.walletIndex = 0, this.currentAccounts = [], this.off = this.removeListener.bind(this), this.chainId = typeof i == "number" ? i : V(i), this.sdk.on("addressChanged", ({ address: n, index: u }) => {
22
+ this.setWalletIndex(u), this.notifyAccountsChanged([n]);
23
23
  });
24
24
  }
25
25
  /** connector가 내부적으로 호출. 외부에서 사용하지 않습니다. */
@@ -31,14 +31,14 @@ class Y {
31
31
  try {
32
32
  return await this._handleRequest(t, i);
33
33
  } catch (n) {
34
- throw n instanceof M && n.code === U.USER_REJECTED ? Object.assign(
34
+ throw n instanceof H && n.code === J.USER_REJECTED ? Object.assign(
35
35
  new Error("User rejected the request"),
36
36
  { code: 4001, data: n.details }
37
37
  ) : n;
38
38
  }
39
39
  }
40
40
  async _handleRequest(t, i) {
41
- var l;
41
+ var u;
42
42
  const n = i ?? [];
43
43
  switch (t) {
44
44
  case "eth_requestAccounts":
@@ -49,21 +49,21 @@ class Y {
49
49
  return e ? [e.address] : [];
50
50
  }
51
51
  case "eth_chainId":
52
- return R(this.chainId);
52
+ return q(this.chainId);
53
53
  case "net_version":
54
54
  return String(this.chainId);
55
55
  case "personal_sign": {
56
- const [e] = n, c = e.startsWith("0x") ? N(e) : e;
56
+ const [e] = n, c = e.startsWith("0x") ? F(e) : e;
57
57
  return (await this.sdk.signMessage(
58
- A(this.chainId),
58
+ k(this.chainId),
59
59
  c,
60
60
  { index: this.walletIndex }
61
61
  )).signature;
62
62
  }
63
63
  case "eth_sign": {
64
- const [, e] = n, c = e.startsWith("0x") ? N(e) : e;
64
+ const [, e] = n, c = e.startsWith("0x") ? F(e) : e;
65
65
  return (await this.sdk.signMessage(
66
- A(this.chainId),
66
+ k(this.chainId),
67
67
  c,
68
68
  { index: this.walletIndex }
69
69
  )).signature;
@@ -71,11 +71,11 @@ class Y {
71
71
  case "eth_signTypedData":
72
72
  case "eth_signTypedData_v3":
73
73
  case "eth_signTypedData_v4": {
74
- const [, e] = n, c = typeof e == "string" ? JSON.parse(e) : e, h = (l = c == null ? void 0 : c.domain) == null ? void 0 : l.chainId, f = h == null || h === 0, p = f ? 0 : Number(h), g = { index: this.walletIndex };
75
- return (f ? await this.sdk.signTypedDataOffchain(c, g) : await this.sdk.signTypedData(A(p), c, g)).signature;
74
+ const [, e] = n, c = typeof e == "string" ? JSON.parse(e) : e, f = (u = c == null ? void 0 : c.domain) == null ? void 0 : u.chainId, m = f == null || f === 0, A = m ? 0 : Number(f), x = { index: this.walletIndex };
75
+ return (m ? await this.sdk.signTypedDataOffchain(c, x) : await this.sdk.signTypedData(k(A), c, x)).signature;
76
76
  }
77
77
  case "eth_sendTransaction": {
78
- const [e] = n, c = A(this.chainId);
78
+ const [e] = n, c = k(this.chainId);
79
79
  return (await this.sdk.sendTransaction(c, {
80
80
  from: e.from,
81
81
  to: e.to,
@@ -91,12 +91,12 @@ class Y {
91
91
  }
92
92
  case "wallet_switchEthereumChain": {
93
93
  const [{ chainId: e }] = n, c = parseInt(e, 16);
94
- return c !== this.chainId && (this.chainId = c, this.emit("chainChanged", R(c))), null;
94
+ return c !== this.chainId && (this.chainId = c, this.emit("chainChanged", q(c))), null;
95
95
  }
96
96
  case "wallet_addEthereumChain":
97
97
  return null;
98
98
  default:
99
- return this.sdk.walletRpc(t, n, A(this.chainId));
99
+ return this.sdk.walletRpc(t, n, k(this.chainId));
100
100
  }
101
101
  }
102
102
  // ── EIP-1193 이벤트 ───────────────────────────────────────────────────────
@@ -109,7 +109,7 @@ class Y {
109
109
  }
110
110
  emit(t, ...i) {
111
111
  var n;
112
- (n = this.listeners.get(t)) == null || n.forEach((l) => l(...i));
112
+ (n = this.listeners.get(t)) == null || n.forEach((u) => u(...i));
113
113
  }
114
114
  // ── Connector 전용 헬퍼 ───────────────────────────────────────────────────
115
115
  notifyAccountsChanged(t) {
@@ -122,7 +122,7 @@ class Y {
122
122
  return this.chainId;
123
123
  }
124
124
  setChainId(t) {
125
- t !== this.chainId && (this.chainId = t, this.emit("chainChanged", R(t)));
125
+ t !== this.chainId && (this.chainId = t, this.emit("chainChanged", q(t)));
126
126
  }
127
127
  /**
128
128
  * 활성 지갑 인덱스 설정.
@@ -139,185 +139,224 @@ class Y {
139
139
  return [...this.currentAccounts];
140
140
  }
141
141
  }
142
- function $(r) {
142
+ function tt(r) {
143
143
  return typeof r == "number" ? r : parseInt(r.split(":")[1] ?? "1", 10);
144
144
  }
145
- const k = "crossx-wallet-index";
146
- function B() {
145
+ const M = "crossx-wallet-index";
146
+ function et() {
147
147
  try {
148
- const r = typeof window < "u" ? localStorage.getItem(k) : null;
148
+ const r = typeof window < "u" ? localStorage.getItem(M) : null;
149
149
  return r && Number(r) || 0;
150
150
  } catch {
151
151
  return 0;
152
152
  }
153
153
  }
154
- function Q(r) {
154
+ function nt(r) {
155
155
  try {
156
- typeof window < "u" && localStorage.setItem(k, String(r));
156
+ typeof window < "u" && localStorage.setItem(M, String(r));
157
157
  } catch {
158
158
  }
159
159
  }
160
- function G() {
160
+ function j() {
161
161
  try {
162
- typeof window < "u" && localStorage.removeItem(k);
162
+ typeof window < "u" && localStorage.removeItem(M);
163
163
  } catch {
164
164
  }
165
165
  }
166
- const T = "crossx-wallet-address";
167
- function X() {
166
+ const U = "crossx-wallet-address";
167
+ function st() {
168
168
  try {
169
- return typeof window < "u" ? localStorage.getItem(T) : null;
169
+ return typeof window < "u" ? localStorage.getItem(U) : null;
170
170
  } catch {
171
171
  return null;
172
172
  }
173
173
  }
174
- function V(r) {
174
+ function rt(r) {
175
175
  try {
176
- typeof window < "u" && localStorage.setItem(T, r);
176
+ typeof window < "u" && localStorage.setItem(U, r);
177
177
  } catch {
178
178
  }
179
179
  }
180
- function Z() {
180
+ function at() {
181
181
  try {
182
- typeof window < "u" && localStorage.removeItem(T);
182
+ typeof window < "u" && localStorage.removeItem(U);
183
183
  } catch {
184
184
  }
185
185
  }
186
- function rt(r) {
187
- const { defaultChainId: t, getStoredWalletIndex: i, onWalletIndexChanged: n, getStoredWalletAddress: l, onWalletAddressChanged: e, clearStoredWalletAddress: c, openConnectOtherWallet: h, ...f } = r;
188
- if (h) {
189
- const g = f.connectOtherWallets, x = Array.isArray(g) && g.length > 0, m = f.showConnectOtherWallets === !0;
190
- !x && !m && (f.showConnectOtherWallets = !0);
186
+ function lt(r) {
187
+ const { defaultChainId: t, getStoredWalletIndex: i, onWalletIndexChanged: n, getStoredWalletAddress: u, onWalletAddressChanged: e, clearStoredWalletAddress: c, openConnectOtherWallet: f, ...m } = r;
188
+ if (f) {
189
+ const x = m.connectOtherWallets, W = Array.isArray(x) && x.length > 0, p = m.showConnectOtherWallets === !0;
190
+ !W && !p && (m.showConnectOtherWallets = !0);
191
191
  }
192
- const p = H(f);
193
- return tt({ sdk: p, defaultChainId: t, getStoredWalletIndex: i, onWalletIndexChanged: n, getStoredWalletAddress: l, onWalletAddressChanged: e, clearStoredWalletAddress: c, openConnectOtherWallet: h });
192
+ const A = X(m);
193
+ return it({ sdk: A, defaultChainId: t, getStoredWalletIndex: i, onWalletIndexChanged: n, getStoredWalletAddress: u, onWalletAddressChanged: e, clearStoredWalletAddress: c, openConnectOtherWallet: f });
194
194
  }
195
- function tt(r) {
195
+ function it(r) {
196
196
  const {
197
197
  sdk: t,
198
- defaultChainId: i = q.CROSS_MAINNET,
199
- getStoredWalletIndex: n = B,
200
- onWalletIndexChanged: l = Q,
201
- getStoredWalletAddress: e = X,
202
- onWalletAddressChanged: c = V,
203
- clearStoredWalletAddress: h = Z,
204
- openConnectOtherWallet: f
205
- } = r, p = $(i);
206
- let g = null, x = !1, m = null, b = !1, S = !1, E = !1;
198
+ defaultChainId: i = K.CROSS_MAINNET,
199
+ getStoredWalletIndex: n = et,
200
+ onWalletIndexChanged: u = nt,
201
+ getStoredWalletAddress: e = st,
202
+ onWalletAddressChanged: c = rt,
203
+ clearStoredWalletAddress: f = at,
204
+ openConnectOtherWallet: m
205
+ } = r, A = tt(i);
206
+ let x = null, W = !1, p = null, z = !1, D = !1, P = !1, y = null, R = !1;
207
+ function L(I) {
208
+ const E = y;
209
+ return E ? (y = null, R = !1, E(I), !0) : !1;
210
+ }
207
211
  function C() {
208
- return g || (g = new Y(t, p), g._setWalletIndexChangeCallback(l)), g;
212
+ return x || (x = new Z(t, A), x._setWalletIndexChangeCallback(u)), x;
209
213
  }
210
- return F((I) => {
211
- function P(s) {
212
- if (b) return;
213
- const o = C();
214
- o.on("accountsChanged", s.onAccountsChanged.bind(s)), o.on("chainChanged", s.onChainChanged.bind(s)), o.on("disconnect", s.onDisconnect.bind(s)), b = !0;
214
+ return $((I) => {
215
+ function E(s) {
216
+ if (z) return;
217
+ const l = C();
218
+ l.on("accountsChanged", s.onAccountsChanged.bind(s)), l.on("chainChanged", s.onChainChanged.bind(s)), l.on("disconnect", s.onDisconnect.bind(s)), z = !0;
215
219
  }
216
- function _(s) {
217
- const o = C();
218
- o.notifyAccountsChanged([s]), I.emitter.emit("connect", {
220
+ function N(s) {
221
+ const l = C();
222
+ l.notifyAccountsChanged([s]), I.emitter.emit("connect", {
219
223
  accounts: [s],
220
- chainId: o.getCurrentChainId()
224
+ chainId: l.getCurrentChainId()
221
225
  });
222
226
  }
223
- async function O() {
224
- if (!x)
225
- return m || (m = (async () => {
226
- const s = n(), o = e() ?? void 0;
227
- await t.initialize({ preferredWalletIndex: s, preferredWalletAddress: o }), t.on("addressChanged", ({ address: a, index: u }) => {
228
- if (S) return;
229
- const W = C();
230
- W.setWalletIndex(u), a && (c(a), t.isAuthenticated() ? _(a) : W.notifyAccountsChanged([a]));
227
+ async function G() {
228
+ if (!W)
229
+ return p || (p = (async () => {
230
+ const s = n(), l = e() ?? void 0;
231
+ await t.initialize({ preferredWalletIndex: s, preferredWalletAddress: l }), t.on("addressChanged", ({ address: a, index: d }) => {
232
+ if (D) {
233
+ R && a && t.isAuthenticated() && y && (C().setWalletIndex(d), c(a), L(a));
234
+ return;
235
+ }
236
+ const T = C();
237
+ T.setWalletIndex(d), a && (c(a), t.isAuthenticated() ? N(a) : T.notifyAccountsChanged([a]));
231
238
  }), t.on("authChanged", (a) => {
232
- if (!(S || E)) {
239
+ if (a.isAuthenticated && a.source === "external" && y) {
240
+ if (a.address) {
241
+ L(a.address);
242
+ return;
243
+ }
244
+ R = !0, t.getAddress().then((d) => {
245
+ d != null && d.address && t.isAuthenticated() && L(d.address);
246
+ }).catch(() => {
247
+ });
248
+ return;
249
+ }
250
+ if (!(D || P)) {
233
251
  if (a.isAuthenticated) {
234
252
  if (a.address) {
235
- _(a.address);
253
+ N(a.address);
236
254
  return;
237
255
  }
238
- t.getAddress().then((u) => {
239
- u != null && u.address && t.isAuthenticated() && _(u.address);
256
+ t.getAddress().then((d) => {
257
+ d != null && d.address && t.isAuthenticated() && N(d.address);
240
258
  }).catch(() => {
241
259
  });
242
260
  return;
243
261
  }
244
- C().notifyDisconnect(), G(), h(), l(0), I.emitter.emit("disconnect");
262
+ C().notifyDisconnect(), j(), f(), u(0), I.emitter.emit("disconnect");
245
263
  }
246
- }), f && t.on("connectExternalWallet", f), x = !0;
264
+ }), m && t.on("connectExternalWallet", m), W = !0;
247
265
  })().finally(() => {
248
- m = null;
249
- }), m);
266
+ p = null;
267
+ }), p);
250
268
  }
251
269
  return {
252
270
  id: "crossx",
253
- name: K,
271
+ name: Q,
254
272
  type: "crossx",
255
273
  async setup() {
256
- await O(), P(this);
274
+ await G(), E(this);
257
275
  },
258
276
  // ── connect ─────────────────────────────────────────────────────────────
259
- async connect({ chainId: s, isReconnecting: o } = {}) {
260
- await O(), P(this);
261
- const a = C(), u = s ?? p;
262
- S = !0;
263
- try {
277
+ async connect({ chainId: s, isReconnecting: l } = {}) {
278
+ const a = s ?? A;
279
+ D = !0;
280
+ const d = new Promise((w) => {
281
+ y = w;
282
+ }), T = this, Y = async () => {
283
+ await G(), E(T);
284
+ const w = C();
264
285
  if (t.isAuthenticated()) {
265
- const d = await t.getAddress();
266
- if (d)
267
- return a.setWalletIndex(d.index), a.notifyAccountsChanged([d.address]), {
268
- accounts: [d.address],
269
- chainId: u
286
+ const o = await t.getAddress();
287
+ if (o)
288
+ return w.setWalletIndex(o.index), w.notifyAccountsChanged([o.address]), {
289
+ accounts: [o.address],
290
+ chainId: a
270
291
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
271
292
  };
272
- if (o)
293
+ if (l)
273
294
  throw new Error(
274
295
  "CROSSx reconnect: authenticated session has no active wallet address"
275
296
  );
276
297
  await t.signOut().catch(() => {
277
- }), a.notifyDisconnect();
298
+ }), w.notifyDisconnect();
278
299
  }
279
- if (o)
300
+ if (l)
280
301
  throw new Error("CROSSx reconnect: no authenticated session to restore");
281
- const W = e();
282
- let y;
302
+ const _ = e();
303
+ let g;
283
304
  try {
284
- y = await t.signInWithCreate({
285
- preferredWalletAddress: W ?? void 0
305
+ g = await t.signInWithCreate({
306
+ preferredWalletAddress: _ ?? void 0
286
307
  });
287
- } catch (d) {
288
- throw d instanceof M && d.code === U.EXTERNAL_WALLET_REQUESTED ? (a.notifyDisconnect(), new j(d)) : (t.isAuthenticated() || (a.notifyDisconnect(), I.emitter.emit("disconnect")), d);
308
+ } catch (o) {
309
+ throw o instanceof H && o.code === J.EXTERNAL_WALLET_REQUESTED ? (w.notifyDisconnect(), new B(o)) : (t.isAuthenticated() || (w.notifyDisconnect(), I.emitter.emit("disconnect")), o);
289
310
  }
290
- if (!y.success)
291
- throw new Error(y.error ?? "CROSSx sign-in failed");
292
- const w = y.address, L = y.addresses.map((d) => d.address).filter((d) => !w || d.toLowerCase() !== w.toLowerCase()), v = w ? [w, ...L] : L;
293
- if (v.length === 0)
311
+ if (!g.success)
312
+ throw new Error(g.error ?? "CROSSx sign-in failed");
313
+ const h = g.address, S = g.addresses.map((o) => o.address).filter((o) => !h || o.toLowerCase() !== h.toLowerCase()), b = h ? [h, ...S] : S;
314
+ if (b.length === 0)
294
315
  throw new Error("No address found after sign-in");
295
- const D = y.addresses.find(
296
- (d) => w && d.address.toLowerCase() === w.toLowerCase()
297
- ), z = (D == null ? void 0 : D.index) ?? 0;
298
- return a.setWalletIndex(z), a.notifyAccountsChanged(v), w && c(w), {
299
- accounts: v,
300
- chainId: u
316
+ const O = g.addresses.find(
317
+ (o) => h && o.address.toLowerCase() === h.toLowerCase()
318
+ ), v = (O == null ? void 0 : O.index) ?? 0;
319
+ return w.setWalletIndex(v), w.notifyAccountsChanged(b), h && c(h), {
320
+ accounts: b,
321
+ chainId: a
301
322
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
302
323
  };
324
+ };
325
+ try {
326
+ const w = Y();
327
+ w.catch(() => {
328
+ });
329
+ const _ = await Promise.race([
330
+ w.then((g) => ({ kind: "inner", value: g })),
331
+ d.then((g) => ({ kind: "external", address: g }))
332
+ ]);
333
+ if (_.kind === "external") {
334
+ const g = C(), h = await t.getAddress().catch(() => null), S = (h == null ? void 0 : h.address) ?? _.address, O = (await t.getAddresses().catch(() => [])).map((o) => o.address).filter((o) => o.toLowerCase() !== S.toLowerCase()), v = [S, ...O];
335
+ return g.setWalletIndex((h == null ? void 0 : h.index) ?? 0), g.notifyAccountsChanged(v), c(S), {
336
+ accounts: v,
337
+ chainId: a
338
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
339
+ };
340
+ }
341
+ return _.value;
303
342
  } finally {
304
- S = !1;
343
+ D = !1, y = null, R = !1;
305
344
  }
306
345
  },
307
346
  // ── disconnect ──────────────────────────────────────────────────────────
308
347
  async disconnect() {
309
- E = !0;
348
+ P = !0;
310
349
  try {
311
350
  const s = C();
312
- await t.signOut(), s.notifyDisconnect(), G(), h(), l(0), I.emitter.emit("disconnect");
351
+ await t.signOut(), s.notifyDisconnect(), j(), f(), u(0), I.emitter.emit("disconnect");
313
352
  } finally {
314
- E = !1;
353
+ P = !1;
315
354
  }
316
355
  },
317
356
  // ── getAccounts ─────────────────────────────────────────────────────────
318
357
  async getAccounts() {
319
- const o = C().getCurrentAccounts();
320
- if (o.length > 0) return o;
358
+ const l = C().getCurrentAccounts();
359
+ if (l.length > 0) return l;
321
360
  const a = await t.getAddress();
322
361
  return a ? [a.address] : [];
323
362
  },
@@ -331,12 +370,12 @@ function tt(r) {
331
370
  },
332
371
  // ── isAuthorized ────────────────────────────────────────────────────────
333
372
  async isAuthorized() {
334
- return await O(), t.isAuthenticated();
373
+ return await G(), t.isAuthenticated();
335
374
  },
336
375
  // ── switchChain ─────────────────────────────────────────────────────────
337
376
  async switchChain({ chainId: s }) {
338
377
  C().setChainId(s), I.emitter.emit("change", { chainId: s });
339
- const a = I.chains.find((u) => u.id === s);
378
+ const a = I.chains.find((d) => d.id === s);
340
379
  if (!a)
341
380
  throw new Error(`Chain ${s} is not configured`);
342
381
  return a;
@@ -359,7 +398,7 @@ function tt(r) {
359
398
  });
360
399
  }
361
400
  export {
362
- Y as CROSSxEIP1193Provider,
363
- tt as createCROSSxConnector,
364
- rt as crossxConnector
401
+ Z as CROSSxEIP1193Provider,
402
+ it as createCROSSxConnector,
403
+ lt as crossxConnector
365
404
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cross/crossx-sdk-wagmi",
3
- "version": "2.3.10-beta.3",
3
+ "version": "2.3.10-beta.5",
4
4
  "description": "CROSSx SDK wagmi Connector — OAuth 임베디드 지갑을 wagmi에 통합",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "sideEffects": false,
20
20
  "dependencies": {
21
- "@nexus-cross/crossx-sdk-core": "^2.3.10-beta.3"
21
+ "@nexus-cross/crossx-sdk-core": "^2.3.10-beta.5"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@nexus-cross/crossx-sdk-core": "^2.0.0",