@nexus-cross/crossx-sdk-wagmi 1.3.0 → 1.3.2
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/connector.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +80 -73
- package/dist/provider.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/connector.d.ts.map
CHANGED
|
@@ -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;CAChD;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;CAChD,CAAC;AAgCF,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,8GAI9D;AAID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,
|
|
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;CAChD;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;CAChD,CAAC;AAgCF,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,8GAI9D;AAID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,8GAoNpE"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("wagmi"),D=require("viem"),f=require("@nexus-cross/crossx-sdk-core");function P(i){return parseInt(i.split(":")[1]??"1",10)}function y(i){return`eip155:${i}`}function E(i){return"0x"+i.toString(16)}function R(i){const t=i.startsWith("0x")?i.slice(2):i,s=new Uint8Array(t.length/2);for(let n=0;n<s.length;n++)s[n]=parseInt(t.substring(n*2,n*2+2),16);return new TextDecoder().decode(s)}class W{constructor(t,s=f.ChainId.CROSS_MAINNET){this.sdk=t,this.listeners=new Map,this.walletIndex=0,this.currentAccounts=[],this.off=this.removeListener.bind(this),this.chainId=typeof s=="number"?s:P(s),this.sdk.on("addressChanged",({address:n,index:o})=>{this.setWalletIndex(o),this.notifyAccountsChanged([n])})}_setWalletIndexChangeCallback(t){this.walletIndexChangeCallback=t}async request({method:t,params:s}){try{return await this._handleRequest(t,s)}catch(n){throw n instanceof f.CROSSxError&&n.code===f.ErrorCode.USER_REJECTED?Object.assign(new Error("User rejected the request"),{code:4001,data:n.details}):n}}async _handleRequest(t,s){var o;const n=s??[];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 E(this.chainId);case"net_version":return String(this.chainId);case"personal_sign":{const[e]=n,r=e.startsWith("0x")?R(e):e;return(await this.sdk.signMessage(y(this.chainId),r,{index:this.walletIndex})).signature}case"eth_sign":{const[,e]=n,r=e.startsWith("0x")?R(e):e;return(await this.sdk.signMessage(y(this.chainId),r,{index:this.walletIndex})).signature}case"eth_signTypedData":case"eth_signTypedData_v3":case"eth_signTypedData_v4":{const[,e]=n,r=typeof e=="string"?JSON.parse(e):e,l=(o=r==null?void 0:r.domain)==null?void 0:o.chainId,I=l==null||l===0,u=I?0:Number(l),h={index:this.walletIndex};return(I?await this.sdk.signTypedDataOffchain(r,h):await this.sdk.signTypedData(y(u),r,h)).signature}case"eth_sendTransaction":{const[e]=n,r=y(this.chainId);return(await this.sdk.sendTransaction(r,{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,r=parseInt(e,16);return r!==this.chainId&&(this.chainId=r,this.emit("chainChanged",E(r))),null}case"wallet_addEthereumChain":return null;default:return this.sdk.walletRpc(t,n,y(this.chainId))}}on(t,s){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(s),this}removeListener(t,s){var n;return(n=this.listeners.get(t))==null||n.delete(s),this}emit(t,...s){var n;(n=this.listeners.get(t))==null||n.forEach(o=>o(...s))}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",E(t)))}setWalletIndex(t){var s;this.walletIndex=t,(s=this.walletIndexChangeCallback)==null||s.call(this,t)}getWalletIndex(){return this.walletIndex}getCurrentAccounts(){return[...this.currentAccounts]}}function N(i){return typeof i=="number"?i:parseInt(i.split(":")[1]??"1",10)}const _="crossx-wallet-index";function L(){try{const i=typeof window<"u"?localStorage.getItem(_):null;return i&&Number(i)||0}catch{return 0}}function q(i){try{typeof window<"u"&&localStorage.setItem(_,String(i))}catch{}}function G(){try{typeof window<"u"&&localStorage.removeItem(_)}catch{}}function M(i){const{defaultChainId:t,getStoredWalletIndex:s,onWalletIndexChanged:n,...o}=i,e=f.createCROSSxSDK(o);return b({sdk:e,defaultChainId:t,getStoredWalletIndex:s,onWalletIndexChanged:n})}function b(i){const{sdk:t,defaultChainId:s=f.ChainId.CROSS_MAINNET,getStoredWalletIndex:n=L,onWalletIndexChanged:o=q}=i,e=N(s);let r=null,l=!1,I=!1;function u(){return r||(r=new W(t,e),r._setWalletIndexChangeCallback(o)),r}return v.createConnector(h=>({id:"crossx",name:"CROSSx Wallet",type:"crossx",async setup(){if(!l){const g=n();await t.initialize({preferredWalletIndex:g}),l=!0,t.on("addressChanged",({address:c,index:C})=>{if(I)return;const m=u();m.setWalletIndex(C),c&&m.notifyAccountsChanged([c])})}const a=u();a.on("accountsChanged",this.onAccountsChanged.bind(this)),a.on("chainChanged",this.onChainChanged.bind(this)),a.on("disconnect",this.onDisconnect.bind(this))},async connect({chainId:a,isReconnecting:g}={}){var m;const c=u(),C=a??e;I=!0;try{if(g||t.isAuthenticated()){const d=n();if(t.isAuthenticated()){try{const S=await t.getAddresses();if(S.length>0){const A=S.find(T=>T.index===d)??S[0];return c.setWalletIndex(A.index),c.notifyAccountsChanged([A.address]),{accounts:[A.address],chainId:C}}}catch{}await t.signOut().catch(()=>{}),c.notifyDisconnect()}}let x;try{x=await t.signInWithCreate()}catch(d){throw d instanceof f.CROSSxError&&d.code===f.ErrorCode.EXTERNAL_WALLET_REQUESTED?(c.notifyDisconnect(),new D.UserRejectedRequestError(d)):(t.isAuthenticated()||(c.notifyDisconnect(),h.emitter.emit("disconnect")),d)}if(!x.success)throw new Error(x.error??"CROSSx sign-in failed");const w=x.address,O=x.addresses.map(d=>d.address).filter(d=>!w||d.toLowerCase()!==w.toLowerCase()),p=w?[w,...O]:O;if(p.length===0)throw new Error("No address found after sign-in");const k=((m=x.addresses.find(d=>w&&d.address.toLowerCase()===w.toLowerCase()))==null?void 0:m.index)??0;return c.setWalletIndex(k),c.notifyAccountsChanged(p),{accounts:p,chainId:C}}finally{I=!1}},async disconnect(){const a=u();await t.signOut(),a.notifyDisconnect(),G(),o(0),h.emitter.emit("disconnect")},async getAccounts(){const g=u().getCurrentAccounts();if(g.length>0)return g;const c=await t.getAddress();return c?[c.address]:[]},async getChainId(){return u().getCurrentChainId()},async getProvider({chainId:a}={}){return u()},async isAuthorized(){return await t.whenReady(),t.isAuthenticated()},async switchChain({chainId:a}){u().setChainId(a),h.emitter.emit("change",{chainId:a});const c=h.chains.find(C=>C.id===a);if(!c)throw new Error(`Chain ${a} is not configured`);return c},onAccountsChanged(a){a.length===0?h.emitter.emit("disconnect"):h.emitter.emit("change",{accounts:a})},onChainChanged(a){h.emitter.emit("change",{chainId:Number(a)})},onDisconnect(){h.emitter.emit("disconnect")}}))}exports.CROSSxEIP1193Provider=W;exports.createCROSSxConnector=b;exports.crossxConnector=M;
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import { createConnector as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createConnector as D } from "wagmi";
|
|
2
|
+
import { UserRejectedRequestError as v } from "viem";
|
|
3
|
+
import { ChainId as b, CROSSxError as R, ErrorCode as k, createCROSSxSDK as P } from "@nexus-cross/crossx-sdk-core";
|
|
4
|
+
function N(i) {
|
|
5
|
+
return parseInt(i.split(":")[1] ?? "1", 10);
|
|
5
6
|
}
|
|
6
|
-
function m(
|
|
7
|
-
return `eip155:${
|
|
7
|
+
function m(i) {
|
|
8
|
+
return `eip155:${i}`;
|
|
8
9
|
}
|
|
9
|
-
function A(
|
|
10
|
-
return "0x" +
|
|
10
|
+
function A(i) {
|
|
11
|
+
return "0x" + i.toString(16);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
function W(i) {
|
|
14
|
+
const t = i.startsWith("0x") ? i.slice(2) : i, s = new Uint8Array(t.length / 2);
|
|
15
|
+
for (let n = 0; n < s.length; n++)
|
|
16
|
+
s[n] = parseInt(t.substring(n * 2, n * 2 + 2), 16);
|
|
17
|
+
return new TextDecoder().decode(s);
|
|
18
|
+
}
|
|
19
|
+
class L {
|
|
20
|
+
constructor(t, s = b.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 s == "number" ? s : N(s), this.sdk.on("addressChanged", ({ address: n, index: o }) => {
|
|
15
22
|
this.setWalletIndex(o), this.notifyAccountsChanged([n]);
|
|
16
23
|
});
|
|
17
24
|
}
|
|
@@ -24,7 +31,7 @@ class T {
|
|
|
24
31
|
try {
|
|
25
32
|
return await this._handleRequest(t, s);
|
|
26
33
|
} catch (n) {
|
|
27
|
-
throw n instanceof
|
|
34
|
+
throw n instanceof R && n.code === k.USER_REJECTED ? Object.assign(
|
|
28
35
|
new Error("User rejected the request"),
|
|
29
36
|
{ code: 4001, data: n.details }
|
|
30
37
|
) : n;
|
|
@@ -46,26 +53,26 @@ class T {
|
|
|
46
53
|
case "net_version":
|
|
47
54
|
return String(this.chainId);
|
|
48
55
|
case "personal_sign": {
|
|
49
|
-
const [e] = n;
|
|
56
|
+
const [e] = n, r = e.startsWith("0x") ? W(e) : e;
|
|
50
57
|
return (await this.sdk.signMessage(
|
|
51
58
|
m(this.chainId),
|
|
52
|
-
|
|
59
|
+
r,
|
|
53
60
|
{ index: this.walletIndex }
|
|
54
61
|
)).signature;
|
|
55
62
|
}
|
|
56
63
|
case "eth_sign": {
|
|
57
|
-
const [, e] = n;
|
|
64
|
+
const [, e] = n, r = e.startsWith("0x") ? W(e) : e;
|
|
58
65
|
return (await this.sdk.signMessage(
|
|
59
66
|
m(this.chainId),
|
|
60
|
-
|
|
67
|
+
r,
|
|
61
68
|
{ index: this.walletIndex }
|
|
62
69
|
)).signature;
|
|
63
70
|
}
|
|
64
71
|
case "eth_signTypedData":
|
|
65
72
|
case "eth_signTypedData_v3":
|
|
66
73
|
case "eth_signTypedData_v4": {
|
|
67
|
-
const [, e] = n, r = typeof e == "string" ? JSON.parse(e) : e,
|
|
68
|
-
return (f ? await this.sdk.signTypedDataOffchain(r,
|
|
74
|
+
const [, e] = n, r = typeof e == "string" ? JSON.parse(e) : e, l = (o = r == null ? void 0 : r.domain) == null ? void 0 : o.chainId, f = l == null || l === 0, u = f ? 0 : Number(l), h = { index: this.walletIndex };
|
|
75
|
+
return (f ? await this.sdk.signTypedDataOffchain(r, h) : await this.sdk.signTypedData(m(u), r, h)).signature;
|
|
69
76
|
}
|
|
70
77
|
case "eth_sendTransaction": {
|
|
71
78
|
const [e] = n, r = m(this.chainId);
|
|
@@ -132,74 +139,74 @@ class T {
|
|
|
132
139
|
return [...this.currentAccounts];
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
|
-
function
|
|
136
|
-
return typeof
|
|
142
|
+
function q(i) {
|
|
143
|
+
return typeof i == "number" ? i : parseInt(i.split(":")[1] ?? "1", 10);
|
|
137
144
|
}
|
|
138
|
-
const
|
|
139
|
-
function
|
|
145
|
+
const E = "crossx-wallet-index";
|
|
146
|
+
function G() {
|
|
140
147
|
try {
|
|
141
|
-
const
|
|
142
|
-
return
|
|
148
|
+
const i = typeof window < "u" ? localStorage.getItem(E) : null;
|
|
149
|
+
return i && Number(i) || 0;
|
|
143
150
|
} catch {
|
|
144
151
|
return 0;
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
|
-
function
|
|
154
|
+
function U(i) {
|
|
148
155
|
try {
|
|
149
|
-
typeof window < "u" && localStorage.setItem(
|
|
156
|
+
typeof window < "u" && localStorage.setItem(E, String(i));
|
|
150
157
|
} catch {
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
|
-
function
|
|
160
|
+
function M() {
|
|
154
161
|
try {
|
|
155
|
-
typeof window < "u" && localStorage.removeItem(
|
|
162
|
+
typeof window < "u" && localStorage.removeItem(E);
|
|
156
163
|
} catch {
|
|
157
164
|
}
|
|
158
165
|
}
|
|
159
|
-
function
|
|
160
|
-
const { defaultChainId: t, getStoredWalletIndex: s, onWalletIndexChanged: n, ...o } =
|
|
161
|
-
return
|
|
166
|
+
function J(i) {
|
|
167
|
+
const { defaultChainId: t, getStoredWalletIndex: s, onWalletIndexChanged: n, ...o } = i, e = P(o);
|
|
168
|
+
return F({ sdk: e, defaultChainId: t, getStoredWalletIndex: s, onWalletIndexChanged: n });
|
|
162
169
|
}
|
|
163
|
-
function
|
|
170
|
+
function F(i) {
|
|
164
171
|
const {
|
|
165
172
|
sdk: t,
|
|
166
|
-
defaultChainId: s =
|
|
167
|
-
getStoredWalletIndex: n =
|
|
168
|
-
onWalletIndexChanged: o =
|
|
169
|
-
} =
|
|
170
|
-
let r = null,
|
|
171
|
-
function
|
|
172
|
-
return r || (r = new
|
|
173
|
+
defaultChainId: s = b.CROSS_MAINNET,
|
|
174
|
+
getStoredWalletIndex: n = G,
|
|
175
|
+
onWalletIndexChanged: o = U
|
|
176
|
+
} = i, e = q(s);
|
|
177
|
+
let r = null, l = !1, f = !1;
|
|
178
|
+
function u() {
|
|
179
|
+
return r || (r = new L(t, e), r._setWalletIndexChangeCallback(o)), r;
|
|
173
180
|
}
|
|
174
|
-
return
|
|
181
|
+
return D((h) => ({
|
|
175
182
|
id: "crossx",
|
|
176
183
|
name: "CROSSx Wallet",
|
|
177
184
|
type: "crossx",
|
|
178
185
|
async setup() {
|
|
179
|
-
if (!
|
|
186
|
+
if (!l) {
|
|
180
187
|
const g = n();
|
|
181
|
-
await t.initialize({ preferredWalletIndex: g }),
|
|
188
|
+
await t.initialize({ preferredWalletIndex: g }), l = !0, t.on("addressChanged", ({ address: c, index: I }) => {
|
|
182
189
|
if (f) return;
|
|
183
|
-
const w =
|
|
190
|
+
const w = u();
|
|
184
191
|
w.setWalletIndex(I), c && w.notifyAccountsChanged([c]);
|
|
185
192
|
});
|
|
186
193
|
}
|
|
187
|
-
const
|
|
188
|
-
|
|
194
|
+
const a = u();
|
|
195
|
+
a.on("accountsChanged", this.onAccountsChanged.bind(this)), a.on("chainChanged", this.onChainChanged.bind(this)), a.on("disconnect", this.onDisconnect.bind(this));
|
|
189
196
|
},
|
|
190
197
|
// ── connect ─────────────────────────────────────────────────────────────
|
|
191
|
-
async connect({ chainId:
|
|
198
|
+
async connect({ chainId: a, isReconnecting: g } = {}) {
|
|
192
199
|
var w;
|
|
193
|
-
const c =
|
|
200
|
+
const c = u(), I = a ?? e;
|
|
194
201
|
f = !0;
|
|
195
202
|
try {
|
|
196
203
|
if (g || t.isAuthenticated()) {
|
|
197
|
-
const
|
|
204
|
+
const d = n();
|
|
198
205
|
if (t.isAuthenticated()) {
|
|
199
206
|
try {
|
|
200
207
|
const y = await t.getAddresses();
|
|
201
208
|
if (y.length > 0) {
|
|
202
|
-
const S = y.find((
|
|
209
|
+
const S = y.find((T) => T.index === d) ?? y[0];
|
|
203
210
|
return c.setWalletIndex(S.index), c.notifyAccountsChanged([S.address]), {
|
|
204
211
|
accounts: [S.address],
|
|
205
212
|
chainId: I
|
|
@@ -215,16 +222,16 @@ function M(a) {
|
|
|
215
222
|
let C;
|
|
216
223
|
try {
|
|
217
224
|
C = await t.signInWithCreate();
|
|
218
|
-
} catch (
|
|
219
|
-
throw t.isAuthenticated() || (c.notifyDisconnect(),
|
|
225
|
+
} catch (d) {
|
|
226
|
+
throw d instanceof R && d.code === k.EXTERNAL_WALLET_REQUESTED ? (c.notifyDisconnect(), new v(d)) : (t.isAuthenticated() || (c.notifyDisconnect(), h.emitter.emit("disconnect")), d);
|
|
220
227
|
}
|
|
221
228
|
if (!C.success)
|
|
222
229
|
throw new Error(C.error ?? "CROSSx sign-in failed");
|
|
223
|
-
const x = C.address,
|
|
230
|
+
const x = C.address, _ = C.addresses.map((d) => d.address).filter((d) => !x || d.toLowerCase() !== x.toLowerCase()), p = x ? [x, ..._] : _;
|
|
224
231
|
if (p.length === 0)
|
|
225
232
|
throw new Error("No address found after sign-in");
|
|
226
233
|
const O = ((w = C.addresses.find(
|
|
227
|
-
(
|
|
234
|
+
(d) => x && d.address.toLowerCase() === x.toLowerCase()
|
|
228
235
|
)) == null ? void 0 : w.index) ?? 0;
|
|
229
236
|
return c.setWalletIndex(O), c.notifyAccountsChanged(p), {
|
|
230
237
|
accounts: p,
|
|
@@ -237,54 +244,54 @@ function M(a) {
|
|
|
237
244
|
},
|
|
238
245
|
// ── disconnect ──────────────────────────────────────────────────────────
|
|
239
246
|
async disconnect() {
|
|
240
|
-
const
|
|
241
|
-
await t.signOut(),
|
|
247
|
+
const a = u();
|
|
248
|
+
await t.signOut(), a.notifyDisconnect(), M(), o(0), h.emitter.emit("disconnect");
|
|
242
249
|
},
|
|
243
250
|
// ── getAccounts ─────────────────────────────────────────────────────────
|
|
244
251
|
async getAccounts() {
|
|
245
|
-
const g =
|
|
252
|
+
const g = u().getCurrentAccounts();
|
|
246
253
|
if (g.length > 0) return g;
|
|
247
254
|
const c = await t.getAddress();
|
|
248
255
|
return c ? [c.address] : [];
|
|
249
256
|
},
|
|
250
257
|
// ── getChainId ──────────────────────────────────────────────────────────
|
|
251
258
|
async getChainId() {
|
|
252
|
-
return
|
|
259
|
+
return u().getCurrentChainId();
|
|
253
260
|
},
|
|
254
261
|
// ── getProvider ─────────────────────────────────────────────────────────
|
|
255
|
-
async getProvider({ chainId:
|
|
256
|
-
return
|
|
262
|
+
async getProvider({ chainId: a } = {}) {
|
|
263
|
+
return u();
|
|
257
264
|
},
|
|
258
265
|
// ── isAuthorized ────────────────────────────────────────────────────────
|
|
259
266
|
async isAuthorized() {
|
|
260
267
|
return await t.whenReady(), t.isAuthenticated();
|
|
261
268
|
},
|
|
262
269
|
// ── switchChain ─────────────────────────────────────────────────────────
|
|
263
|
-
async switchChain({ chainId:
|
|
264
|
-
|
|
265
|
-
const c =
|
|
270
|
+
async switchChain({ chainId: a }) {
|
|
271
|
+
u().setChainId(a), h.emitter.emit("change", { chainId: a });
|
|
272
|
+
const c = h.chains.find((I) => I.id === a);
|
|
266
273
|
if (!c)
|
|
267
|
-
throw new Error(`Chain ${
|
|
274
|
+
throw new Error(`Chain ${a} is not configured`);
|
|
268
275
|
return c;
|
|
269
276
|
},
|
|
270
277
|
// ── 이벤트 핸들러 ───────────────────────────────────────────────────────
|
|
271
|
-
onAccountsChanged(
|
|
272
|
-
|
|
273
|
-
accounts:
|
|
278
|
+
onAccountsChanged(a) {
|
|
279
|
+
a.length === 0 ? h.emitter.emit("disconnect") : h.emitter.emit("change", {
|
|
280
|
+
accounts: a
|
|
274
281
|
});
|
|
275
282
|
},
|
|
276
|
-
onChainChanged(
|
|
277
|
-
|
|
278
|
-
chainId: Number(
|
|
283
|
+
onChainChanged(a) {
|
|
284
|
+
h.emitter.emit("change", {
|
|
285
|
+
chainId: Number(a)
|
|
279
286
|
});
|
|
280
287
|
},
|
|
281
288
|
onDisconnect() {
|
|
282
|
-
|
|
289
|
+
h.emitter.emit("disconnect");
|
|
283
290
|
}
|
|
284
291
|
}));
|
|
285
292
|
}
|
|
286
293
|
export {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
L as CROSSxEIP1193Provider,
|
|
295
|
+
F as createCROSSxConnector,
|
|
296
|
+
J as crossxConnector
|
|
290
297
|
};
|
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;
|
|
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": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "CROSSx SDK wagmi Connector — OAuth 임베디드 지갑을 wagmi에 통합",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@nexus-cross/crossx-sdk-core": "1.3.
|
|
20
|
+
"@nexus-cross/crossx-sdk-core": "1.3.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"viem": ">=2.0.0",
|