@nexus-cross/crossx-sdk-wagmi 2.3.8 → 2.3.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +48 -48
- package/dist/provider.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ import { createConfig, http } from 'wagmi';
|
|
|
23
23
|
import { crossxConnector } from '@nexus-cross/crossx-sdk-wagmi';
|
|
24
24
|
import type { Chain } from 'viem';
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const crossMainnet = {
|
|
27
27
|
id: 612055,
|
|
28
28
|
name: 'CROSS Mainnet',
|
|
29
29
|
nativeCurrency: { name: 'CROSS', symbol: 'CROSS', decimals: 18 },
|
|
@@ -31,7 +31,7 @@ const oneMainnet = {
|
|
|
31
31
|
} as const satisfies Chain;
|
|
32
32
|
|
|
33
33
|
const config = createConfig({
|
|
34
|
-
chains: [
|
|
34
|
+
chains: [crossMainnet],
|
|
35
35
|
connectors: [
|
|
36
36
|
crossxConnector({
|
|
37
37
|
projectId: 'your-project-id',
|
|
@@ -39,7 +39,7 @@ const config = createConfig({
|
|
|
39
39
|
}),
|
|
40
40
|
],
|
|
41
41
|
transports: {
|
|
42
|
-
[
|
|
42
|
+
[crossMainnet.id]: http(),
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
```
|
|
@@ -60,15 +60,15 @@ const sdk = createCROSSxSDK({
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
const config = createConfig({
|
|
63
|
-
chains: [
|
|
63
|
+
chains: [crossMainnet],
|
|
64
64
|
connectors: [
|
|
65
65
|
createCROSSxConnector({
|
|
66
66
|
sdk,
|
|
67
|
-
defaultChainId: ChainId.
|
|
67
|
+
defaultChainId: ChainId.CROSS_MAINNET,
|
|
68
68
|
}),
|
|
69
69
|
],
|
|
70
70
|
transports: {
|
|
71
|
-
[
|
|
71
|
+
[crossMainnet.id]: http(),
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("wagmi"),z=require("viem"),x=require("@nexus-cross/crossx-sdk-core");function F(s){return parseInt(s.split(":")[1]??"1",10)}function A(s){return`eip155:${s}`}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("wagmi"),z=require("viem"),x=require("@nexus-cross/crossx-sdk-core");function F(s){return parseInt(s.split(":")[1]??"1",10)}function A(s){return`eip155:${s}`}function D(s){return"0x"+s.toString(16)}function N(s){const e=s.startsWith("0x")?s.slice(2):s,r=new Uint8Array(e.length/2);for(let n=0;n<r.length;n++)r[n]=parseInt(e.substring(n*2,n*2+2),16);return new TextDecoder().decode(r)}class G{constructor(e,r=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 r=="number"?r:F(r),this.sdk.on("addressChanged",({address:n,index:d})=>{this.setWalletIndex(d),this.notifyAccountsChanged([n])})}_setWalletIndexChangeCallback(e){this.walletIndexChangeCallback=e}async request({method:e,params:r}){try{return await this._handleRequest(e,r)}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,r){var d;const n=r??[];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 D(this.chainId);case"net_version":return String(this.chainId);case"personal_sign":{const[t]=n,c=t.startsWith("0x")?N(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")?N(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,l=(d=c==null?void 0:c.domain)==null?void 0:d.chainId,u=l==null||l===0,m=u?0:Number(l),f={index:this.walletIndex};return(u?await this.sdk.signTypedDataOffchain(c,f):await this.sdk.signTypedData(A(m),c,f)).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",D(c))),null}case"wallet_addEthereumChain":return null;default:return this.sdk.walletRpc(e,n,A(this.chainId))}}on(e,r){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),this}removeListener(e,r){var n;return(n=this.listeners.get(e))==null||n.delete(r),this}emit(e,...r){var n;(n=this.listeners.get(e))==null||n.forEach(d=>d(...r))}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",D(e)))}setWalletIndex(e){var r;this.walletIndex=e,(r=this.walletIndexChangeCallback)==null||r.call(this,e)}getWalletIndex(){return this.walletIndex}getCurrentAccounts(){return[...this.currentAccounts]}}function K(s){return typeof s=="number"?s:parseInt(s.split(":")[1]??"1",10)}const b="crossx-wallet-index";function H(){try{const s=typeof window<"u"?localStorage.getItem(b):null;return s&&Number(s)||0}catch{return 0}}function J(s){try{typeof window<"u"&&localStorage.setItem(b,String(s))}catch{}}function q(){try{typeof window<"u"&&localStorage.removeItem(b)}catch{}}const k="crossx-wallet-address";function Y(){try{return typeof window<"u"?localStorage.getItem(k):null}catch{return null}}function $(s){try{typeof window<"u"&&localStorage.setItem(k,s)}catch{}}function B(){try{typeof window<"u"&&localStorage.removeItem(k)}catch{}}function Q(s){const{defaultChainId:e,getStoredWalletIndex:r,onWalletIndexChanged:n,getStoredWalletAddress:d,onWalletAddressChanged:t,clearStoredWalletAddress:c,openConnectOtherWallet:l,...u}=s;if(l){const f=u.connectOtherWallets,S=Array.isArray(f)&&f.length>0,y=u.showConnectOtherWallets===!0;!S&&!y&&(u.showConnectOtherWallets=!0)}const m=x.createCROSSxSDK(u);return M({sdk:m,defaultChainId:e,getStoredWalletIndex:r,onWalletIndexChanged:n,getStoredWalletAddress:d,onWalletAddressChanged:t,clearStoredWalletAddress:c,openConnectOtherWallet:l})}function M(s){const{sdk:e,defaultChainId:r=x.ChainId.CROSS_MAINNET,getStoredWalletIndex:n=H,onWalletIndexChanged:d=J,getStoredWalletAddress:t=Y,onWalletAddressChanged:c=$,clearStoredWalletAddress:l=B,openConnectOtherWallet:u}=s,m=K(r);let f=null,S=!1,y=null,T=!1,E=!1,O=!1;function g(){return f||(f=new G(e,m),f._setWalletIndexChangeCallback(d)),f}return j.createConnector(C=>{function P(a){if(T)return;const h=g();h.on("accountsChanged",a.onAccountsChanged.bind(a)),h.on("chainChanged",a.onChainChanged.bind(a)),h.on("disconnect",a.onDisconnect.bind(a)),T=!0}async function _(){if(!S)return y||(y=(async()=>{const a=n(),h=t()??void 0;await e.initialize({preferredWalletIndex:a,preferredWalletAddress:h}),e.on("addressChanged",({address:i,index:I})=>{if(E)return;const W=g();W.setWalletIndex(I),i&&(W.notifyAccountsChanged([i]),c(i))}),e.on("authChanged",i=>{if(!(E||O))if(i.isAuthenticated&&i.address){const I=g();I.notifyAccountsChanged([i.address]),C.emitter.emit("connect",{accounts:[i.address],chainId:I.getCurrentChainId()})}else i.isAuthenticated||(g().notifyDisconnect(),q(),l(),d(0),C.emitter.emit("disconnect"))}),u&&e.on("connectExternalWallet",u),S=!0})().finally(()=>{y=null}),y)}return{id:"crossx",name:x.WALLET_BRAND_NAME,type:"crossx",async setup(){await _(),P(this)},async connect({chainId:a,isReconnecting:h}={}){await _(),P(this);const i=g(),I=a??m;E=!0;try{if(e.isAuthenticated()){const o=await e.getAddress();if(o)return i.setWalletIndex(o.index),i.notifyAccountsChanged([o.address]),{accounts:[o.address],chainId:I};if(h)throw new Error("CROSSx reconnect: authenticated session has no active wallet address");await e.signOut().catch(()=>{}),i.notifyDisconnect()}if(h)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(o){throw o instanceof x.CROSSxError&&o.code===x.ErrorCode.EXTERNAL_WALLET_REQUESTED?(i.notifyDisconnect(),new z.UserRejectedRequestError(o)):(e.isAuthenticated()||(i.notifyDisconnect(),C.emitter.emit("disconnect")),o)}if(!p.success)throw new Error(p.error??"CROSSx sign-in failed");const w=p.address,L=p.addresses.map(o=>o.address).filter(o=>!w||o.toLowerCase()!==w.toLowerCase()),R=w?[w,...L]:L;if(R.length===0)throw new Error("No address found after sign-in");const v=p.addresses.find(o=>w&&o.address.toLowerCase()===w.toLowerCase()),U=(v==null?void 0:v.index)??0;return i.setWalletIndex(U),i.notifyAccountsChanged(R),w&&c(w),{accounts:R,chainId:I}}finally{E=!1}},async disconnect(){O=!0;try{const a=g();await e.signOut(),a.notifyDisconnect(),q(),l(),d(0),C.emitter.emit("disconnect")}finally{O=!1}},async getAccounts(){const h=g().getCurrentAccounts();if(h.length>0)return h;const i=await e.getAddress();return i?[i.address]:[]},async getChainId(){return g().getCurrentChainId()},async getProvider({chainId:a}={}){return g()},async isAuthorized(){return await _(),e.isAuthenticated()},async switchChain({chainId:a}){g().setChainId(a),C.emitter.emit("change",{chainId:a});const i=C.chains.find(I=>I.id===a);if(!i)throw new Error(`Chain ${a} is not configured`);return i},onAccountsChanged(a){a.length===0?C.emitter.emit("disconnect"):C.emitter.emit("change",{accounts:a})},onChainChanged(a){C.emitter.emit("change",{chainId:Number(a)})},onDisconnect(){C.emitter.emit("disconnect")}}})}exports.CROSSxEIP1193Provider=G;exports.createCROSSxConnector=M;exports.crossxConnector=Q;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* 간편 모드:
|
|
7
7
|
* import { crossxConnector } from '@nexus-cross/crossx-sdk-wagmi';
|
|
8
8
|
* const config = createConfig({
|
|
9
|
-
* chains: [
|
|
9
|
+
* chains: [crossMainnet],
|
|
10
10
|
* connectors: [crossxConnector({ projectId: 'YOUR_ID' })],
|
|
11
|
-
* transports: { [
|
|
11
|
+
* transports: { [crossMainnet.id]: http() },
|
|
12
12
|
* });
|
|
13
13
|
*
|
|
14
14
|
* 고급 모드 (SDK 직접 주입):
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* import { createCROSSxSDK } from '@nexus-cross/crossx-sdk-core';
|
|
17
17
|
* const sdk = createCROSSxSDK({ projectId: 'YOUR_ID' });
|
|
18
18
|
* const config = createConfig({
|
|
19
|
-
* chains: [
|
|
19
|
+
* chains: [crossMainnet],
|
|
20
20
|
* connectors: [createCROSSxConnector({ sdk })],
|
|
21
|
-
* transports: { [
|
|
21
|
+
* transports: { [crossMainnet.id]: http() },
|
|
22
22
|
* });
|
|
23
23
|
*/
|
|
24
24
|
export { crossxConnector, createCROSSxConnector } from './connector';
|
package/dist/index.js
CHANGED
|
@@ -7,17 +7,17 @@ function H(s) {
|
|
|
7
7
|
function A(s) {
|
|
8
8
|
return `eip155:${s}`;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function R(s) {
|
|
11
11
|
return "0x" + s.toString(16);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function L(s) {
|
|
14
14
|
const t = s.startsWith("0x") ? s.slice(2) : s, r = new Uint8Array(t.length / 2);
|
|
15
15
|
for (let n = 0; n < r.length; n++)
|
|
16
16
|
r[n] = parseInt(t.substring(n * 2, n * 2 + 2), 16);
|
|
17
17
|
return new TextDecoder().decode(r);
|
|
18
18
|
}
|
|
19
19
|
class J {
|
|
20
|
-
constructor(t, r = G.
|
|
20
|
+
constructor(t, r = G.CROSS_MAINNET) {
|
|
21
21
|
this.sdk = t, this.listeners = /* @__PURE__ */ new Map(), this.walletIndex = 0, this.currentAccounts = [], this.off = this.removeListener.bind(this), this.chainId = typeof r == "number" ? r : H(r), this.sdk.on("addressChanged", ({ address: n, index: d }) => {
|
|
22
22
|
this.setWalletIndex(d), this.notifyAccountsChanged([n]);
|
|
23
23
|
});
|
|
@@ -49,11 +49,11 @@ class J {
|
|
|
49
49
|
return e ? [e.address] : [];
|
|
50
50
|
}
|
|
51
51
|
case "eth_chainId":
|
|
52
|
-
return
|
|
52
|
+
return R(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") ?
|
|
56
|
+
const [e] = n, c = e.startsWith("0x") ? L(e) : e;
|
|
57
57
|
return (await this.sdk.signMessage(
|
|
58
58
|
A(this.chainId),
|
|
59
59
|
c,
|
|
@@ -61,7 +61,7 @@ class J {
|
|
|
61
61
|
)).signature;
|
|
62
62
|
}
|
|
63
63
|
case "eth_sign": {
|
|
64
|
-
const [, e] = n, c = e.startsWith("0x") ?
|
|
64
|
+
const [, e] = n, c = e.startsWith("0x") ? L(e) : e;
|
|
65
65
|
return (await this.sdk.signMessage(
|
|
66
66
|
A(this.chainId),
|
|
67
67
|
c,
|
|
@@ -91,7 +91,7 @@ class J {
|
|
|
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",
|
|
94
|
+
return c !== this.chainId && (this.chainId = c, this.emit("chainChanged", R(c))), null;
|
|
95
95
|
}
|
|
96
96
|
case "wallet_addEthereumChain":
|
|
97
97
|
return null;
|
|
@@ -122,7 +122,7 @@ class J {
|
|
|
122
122
|
return this.chainId;
|
|
123
123
|
}
|
|
124
124
|
setChainId(t) {
|
|
125
|
-
t !== this.chainId && (this.chainId = t, this.emit("chainChanged",
|
|
125
|
+
t !== this.chainId && (this.chainId = t, this.emit("chainChanged", R(t)));
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* 활성 지갑 인덱스 설정.
|
|
@@ -142,10 +142,10 @@ class J {
|
|
|
142
142
|
function Y(s) {
|
|
143
143
|
return typeof s == "number" ? s : parseInt(s.split(":")[1] ?? "1", 10);
|
|
144
144
|
}
|
|
145
|
-
const
|
|
145
|
+
const k = "crossx-wallet-index";
|
|
146
146
|
function $() {
|
|
147
147
|
try {
|
|
148
|
-
const s = typeof window < "u" ? localStorage.getItem(
|
|
148
|
+
const s = typeof window < "u" ? localStorage.getItem(k) : null;
|
|
149
149
|
return s && Number(s) || 0;
|
|
150
150
|
} catch {
|
|
151
151
|
return 0;
|
|
@@ -153,33 +153,33 @@ function $() {
|
|
|
153
153
|
}
|
|
154
154
|
function B(s) {
|
|
155
155
|
try {
|
|
156
|
-
typeof window < "u" && localStorage.setItem(
|
|
156
|
+
typeof window < "u" && localStorage.setItem(k, String(s));
|
|
157
157
|
} catch {
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function N() {
|
|
161
161
|
try {
|
|
162
|
-
typeof window < "u" && localStorage.removeItem(
|
|
162
|
+
typeof window < "u" && localStorage.removeItem(k);
|
|
163
163
|
} catch {
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
const
|
|
166
|
+
const T = "crossx-wallet-address";
|
|
167
167
|
function Q() {
|
|
168
168
|
try {
|
|
169
|
-
return typeof window < "u" ? localStorage.getItem(
|
|
169
|
+
return typeof window < "u" ? localStorage.getItem(T) : null;
|
|
170
170
|
} catch {
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
function X(s) {
|
|
175
175
|
try {
|
|
176
|
-
typeof window < "u" && localStorage.setItem(
|
|
176
|
+
typeof window < "u" && localStorage.setItem(T, s);
|
|
177
177
|
} catch {
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
function V() {
|
|
181
181
|
try {
|
|
182
|
-
typeof window < "u" && localStorage.removeItem(
|
|
182
|
+
typeof window < "u" && localStorage.removeItem(T);
|
|
183
183
|
} catch {
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -195,7 +195,7 @@ function st(s) {
|
|
|
195
195
|
function Z(s) {
|
|
196
196
|
const {
|
|
197
197
|
sdk: t,
|
|
198
|
-
defaultChainId: r = G.
|
|
198
|
+
defaultChainId: r = G.CROSS_MAINNET,
|
|
199
199
|
getStoredWalletIndex: n = $,
|
|
200
200
|
onWalletIndexChanged: d = B,
|
|
201
201
|
getStoredWalletAddress: e = Q,
|
|
@@ -203,33 +203,33 @@ function Z(s) {
|
|
|
203
203
|
clearStoredWalletAddress: l = V,
|
|
204
204
|
openConnectOtherWallet: u
|
|
205
205
|
} = s, p = Y(r);
|
|
206
|
-
let f = null, x = !1, m = null,
|
|
206
|
+
let f = null, x = !1, m = null, b = !1, S = !1, E = !1;
|
|
207
207
|
function g() {
|
|
208
208
|
return f || (f = new J(t, p), f._setWalletIndexChangeCallback(d)), f;
|
|
209
209
|
}
|
|
210
|
-
return z((
|
|
211
|
-
function
|
|
212
|
-
if (
|
|
210
|
+
return z((C) => {
|
|
211
|
+
function v(a) {
|
|
212
|
+
if (b) return;
|
|
213
213
|
const h = g();
|
|
214
|
-
h.on("accountsChanged", a.onAccountsChanged.bind(a)), h.on("chainChanged", a.onChainChanged.bind(a)), h.on("disconnect", a.onDisconnect.bind(a)),
|
|
214
|
+
h.on("accountsChanged", a.onAccountsChanged.bind(a)), h.on("chainChanged", a.onChainChanged.bind(a)), h.on("disconnect", a.onDisconnect.bind(a)), b = !0;
|
|
215
215
|
}
|
|
216
216
|
async function _() {
|
|
217
217
|
if (!x)
|
|
218
218
|
return m || (m = (async () => {
|
|
219
219
|
const a = n(), h = e() ?? void 0;
|
|
220
|
-
await t.initialize({ preferredWalletIndex: a, preferredWalletAddress: h }), t.on("addressChanged", ({ address: i, index:
|
|
220
|
+
await t.initialize({ preferredWalletIndex: a, preferredWalletAddress: h }), t.on("addressChanged", ({ address: i, index: I }) => {
|
|
221
221
|
if (S) return;
|
|
222
|
-
const
|
|
223
|
-
|
|
222
|
+
const W = g();
|
|
223
|
+
W.setWalletIndex(I), i && (W.notifyAccountsChanged([i]), c(i));
|
|
224
224
|
}), t.on("authChanged", (i) => {
|
|
225
|
-
if (!(S ||
|
|
225
|
+
if (!(S || E))
|
|
226
226
|
if (i.isAuthenticated && i.address) {
|
|
227
|
-
const
|
|
228
|
-
|
|
227
|
+
const I = g();
|
|
228
|
+
I.notifyAccountsChanged([i.address]), C.emitter.emit("connect", {
|
|
229
229
|
accounts: [i.address],
|
|
230
|
-
chainId:
|
|
230
|
+
chainId: I.getCurrentChainId()
|
|
231
231
|
});
|
|
232
|
-
} else i.isAuthenticated || (g().notifyDisconnect(),
|
|
232
|
+
} else i.isAuthenticated || (g().notifyDisconnect(), N(), l(), d(0), C.emitter.emit("disconnect"));
|
|
233
233
|
}), u && t.on("connectExternalWallet", u), x = !0;
|
|
234
234
|
})().finally(() => {
|
|
235
235
|
m = null;
|
|
@@ -240,12 +240,12 @@ function Z(s) {
|
|
|
240
240
|
name: j,
|
|
241
241
|
type: "crossx",
|
|
242
242
|
async setup() {
|
|
243
|
-
await _(),
|
|
243
|
+
await _(), v(this);
|
|
244
244
|
},
|
|
245
245
|
// ── connect ─────────────────────────────────────────────────────────────
|
|
246
246
|
async connect({ chainId: a, isReconnecting: h } = {}) {
|
|
247
|
-
await _(),
|
|
248
|
-
const i = g(),
|
|
247
|
+
await _(), v(this);
|
|
248
|
+
const i = g(), I = a ?? p;
|
|
249
249
|
S = !0;
|
|
250
250
|
try {
|
|
251
251
|
if (t.isAuthenticated()) {
|
|
@@ -253,7 +253,7 @@ function Z(s) {
|
|
|
253
253
|
if (o)
|
|
254
254
|
return i.setWalletIndex(o.index), i.notifyAccountsChanged([o.address]), {
|
|
255
255
|
accounts: [o.address],
|
|
256
|
-
chainId:
|
|
256
|
+
chainId: I
|
|
257
257
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
258
|
};
|
|
259
259
|
if (h)
|
|
@@ -265,18 +265,18 @@ function Z(s) {
|
|
|
265
265
|
}
|
|
266
266
|
if (h)
|
|
267
267
|
throw new Error("CROSSx reconnect: no authenticated session to restore");
|
|
268
|
-
const
|
|
268
|
+
const W = e();
|
|
269
269
|
let y;
|
|
270
270
|
try {
|
|
271
271
|
y = await t.signInWithCreate({
|
|
272
|
-
preferredWalletAddress:
|
|
272
|
+
preferredWalletAddress: W ?? void 0
|
|
273
273
|
});
|
|
274
274
|
} catch (o) {
|
|
275
|
-
throw o instanceof q && o.code === M.EXTERNAL_WALLET_REQUESTED ? (i.notifyDisconnect(), new F(o)) : (t.isAuthenticated() || (i.notifyDisconnect(),
|
|
275
|
+
throw o instanceof q && o.code === M.EXTERNAL_WALLET_REQUESTED ? (i.notifyDisconnect(), new F(o)) : (t.isAuthenticated() || (i.notifyDisconnect(), C.emitter.emit("disconnect")), o);
|
|
276
276
|
}
|
|
277
277
|
if (!y.success)
|
|
278
278
|
throw new Error(y.error ?? "CROSSx sign-in failed");
|
|
279
|
-
const w = y.address,
|
|
279
|
+
const w = y.address, P = y.addresses.map((o) => o.address).filter((o) => !w || o.toLowerCase() !== w.toLowerCase()), O = w ? [w, ...P] : P;
|
|
280
280
|
if (O.length === 0)
|
|
281
281
|
throw new Error("No address found after sign-in");
|
|
282
282
|
const D = y.addresses.find(
|
|
@@ -284,7 +284,7 @@ function Z(s) {
|
|
|
284
284
|
), U = (D == null ? void 0 : D.index) ?? 0;
|
|
285
285
|
return i.setWalletIndex(U), i.notifyAccountsChanged(O), w && c(w), {
|
|
286
286
|
accounts: O,
|
|
287
|
-
chainId:
|
|
287
|
+
chainId: I
|
|
288
288
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
289
|
};
|
|
290
290
|
} finally {
|
|
@@ -293,12 +293,12 @@ function Z(s) {
|
|
|
293
293
|
},
|
|
294
294
|
// ── disconnect ──────────────────────────────────────────────────────────
|
|
295
295
|
async disconnect() {
|
|
296
|
-
|
|
296
|
+
E = !0;
|
|
297
297
|
try {
|
|
298
298
|
const a = g();
|
|
299
|
-
await t.signOut(), a.notifyDisconnect(),
|
|
299
|
+
await t.signOut(), a.notifyDisconnect(), N(), l(), d(0), C.emitter.emit("disconnect");
|
|
300
300
|
} finally {
|
|
301
|
-
|
|
301
|
+
E = !1;
|
|
302
302
|
}
|
|
303
303
|
},
|
|
304
304
|
// ── getAccounts ─────────────────────────────────────────────────────────
|
|
@@ -322,25 +322,25 @@ function Z(s) {
|
|
|
322
322
|
},
|
|
323
323
|
// ── switchChain ─────────────────────────────────────────────────────────
|
|
324
324
|
async switchChain({ chainId: a }) {
|
|
325
|
-
g().setChainId(a),
|
|
326
|
-
const i =
|
|
325
|
+
g().setChainId(a), C.emitter.emit("change", { chainId: a });
|
|
326
|
+
const i = C.chains.find((I) => I.id === a);
|
|
327
327
|
if (!i)
|
|
328
328
|
throw new Error(`Chain ${a} is not configured`);
|
|
329
329
|
return i;
|
|
330
330
|
},
|
|
331
331
|
// ── 이벤트 핸들러 ───────────────────────────────────────────────────────
|
|
332
332
|
onAccountsChanged(a) {
|
|
333
|
-
a.length === 0 ?
|
|
333
|
+
a.length === 0 ? C.emitter.emit("disconnect") : C.emitter.emit("change", {
|
|
334
334
|
accounts: a
|
|
335
335
|
});
|
|
336
336
|
},
|
|
337
337
|
onChainChanged(a) {
|
|
338
|
-
|
|
338
|
+
C.emitter.emit("change", {
|
|
339
339
|
chainId: Number(a)
|
|
340
340
|
});
|
|
341
341
|
},
|
|
342
342
|
onDisconnect() {
|
|
343
|
-
|
|
343
|
+
C.emitter.emit("disconnect");
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
346
|
});
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAO9C,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC;CACtC;AA2BD,qBAAa,qBAAqB;IAQ9B,QAAQ,CAAC,GAAG,EAAE,SAAS;IAPzB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,yBAAyB,CAAC,CAA0B;gBAGjD,GAAG,EAAE,SAAS,EACvB,cAAc,GAAE,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAO9C,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC;CACtC;AA2BD,qBAAa,qBAAqB;IAQ9B,QAAQ,CAAC,GAAG,EAAE,SAAS;IAPzB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,yBAAyB,CAAC,CAA0B;gBAGjD,GAAG,EAAE,SAAS,EACvB,cAAc,GAAE,MAAM,GAAG,MAA8B;IAazD,2CAA2C;IAC3C,6BAA6B,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAM1D,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC;YAe9D,cAAc;IAuG5B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAQhD,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAK5D,GAAG,UALmB,MAAM,YAAY,aAAa,KAAG,IAAI,CAKvB;IAErC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM7C,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAK/C,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAMrC,iBAAiB,IAAI,MAAM;IAI3B,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAO5B;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKnC,cAAc,IAAI,MAAM;IAIxB,kBAAkB,IAAI,MAAM,EAAE;CAG/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/crossx-sdk-wagmi",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.10-beta.1",
|
|
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.
|
|
21
|
+
"@nexus-cross/crossx-sdk-core": "^2.3.10-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@nexus-cross/crossx-sdk-core": "^2.0.0",
|