@nexus-cross/crossx-sdk-react 1.1.0 → 1.1.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/dist/CROSSxProvider.d.ts.map +1 -1
- package/dist/hooks/useAuth.d.ts +1 -3
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +102 -108
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CROSSxProvider.d.ts","sourceRoot":"","sources":["../src/CROSSxProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,mCAKxB,CAAC;AAEH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"CROSSxProvider.d.ts","sourceRoot":"","sources":["../src/CROSSxProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,mCAKxB,CAAC;AAEH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAwDD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CA6CvE"}
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { AuthResult } from '@nexus-cross/crossx-sdk-core';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* 인증 관련 기능을 제공하는 훅
|
|
5
3
|
*
|
|
@@ -9,7 +7,7 @@ export declare function useAuth(): {
|
|
|
9
7
|
isAuthenticated: boolean;
|
|
10
8
|
isLoading: boolean;
|
|
11
9
|
error: string | null;
|
|
12
|
-
signIn: () => Promise<AuthResult>;
|
|
10
|
+
signIn: () => Promise<import('@nexus-cross/crossx-sdk-core').AuthResult>;
|
|
13
11
|
signInWithCreate: () => Promise<import('@nexus-cross/crossx-sdk-core').SignInWithCreateResult>;
|
|
14
12
|
signOut: () => Promise<void>;
|
|
15
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,OAAO;;;;;;;EAoFtB"}
|
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 g=require("react/jsx-runtime"),n=require("react"),h=require("@nexus-cross/crossx-sdk-core"),w=n.createContext({sdk:null,isInitialized:!1,isAuthenticated:!1,walletAddress:null});function y(t){let c={isAuthenticated:t.isAuthenticated(),walletAddress:t.currentAddress};const o=new Set;function r(){o.forEach(a=>a())}const u=t.on("authChanged",a=>{c={isAuthenticated:a.isAuthenticated,walletAddress:a.address},r()}),s=t.on("addressChanged",a=>{c={...c,walletAddress:a.address},r()});return{subscribe:a=>(o.add(a),()=>{o.delete(a)}),getSnapshot:()=>c,destroy:()=>{u(),s(),o.clear()}}}function C({config:t,children:c}){const[o]=n.useState(()=>h.createCROSSxSDK(t)),[r,u]=n.useState(!1),s=n.useMemo(()=>y(o),[o]),{isAuthenticated:a,walletAddress:d}=n.useSyncExternalStore(s.subscribe,s.getSnapshot);n.useEffect(()=>{let e=!1;return(async()=>{try{await o.initialize(),e||u(!0)}catch(f){e||console.error("CROSSx SDK 초기화 실패:",f)}})(),()=>{e=!0}},[o]);const l=n.useMemo(()=>({sdk:o,isInitialized:r,isAuthenticated:a,walletAddress:d}),[o,r,a,d]);return g.jsx(w.Provider,{value:l,children:c})}function S(){const t=n.useContext(w);if(!t)throw new Error("useCROSSx must be used within CROSSxProvider");return t}function A(){const{sdk:t,isAuthenticated:c}=S(),[o,r]=n.useState(!1),[u,s]=n.useState(null),a=n.useCallback(async()=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");r(!0),s(null);try{const e=await t.signIn();return e.success||s(e.error||"로그인 실패"),e}catch(e){const i=e instanceof Error?e.message:"로그인 실패";throw s(i),e}finally{r(!1)}},[t]),d=n.useCallback(async()=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");r(!0),s(null);try{const e=await t.signInWithCreate();return e.success||s(e.error||"로그인 실패"),e}catch(e){const i=e instanceof Error?e.message:"로그인 실패";throw s(i),e}finally{r(!1)}},[t]),l=n.useCallback(async()=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");r(!0),s(null);try{await t.signOut()}catch(e){const i=e instanceof Error?e.message:"로그아웃 실패";throw s(i),e}finally{r(!1)}},[t]);return{isAuthenticated:c,isLoading:o,error:u,signIn:a,signInWithCreate:d,signOut:l}}function x(){const{sdk:t,walletAddress:c}=S(),[o,r]=n.useState(!1),[u,s]=n.useState(null),a=n.useCallback(async(l,e)=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");r(!0),s(null);try{return await t.signMessage(l,e)}catch(i){const f=i instanceof Error?i.message:"서명 실패";throw s(f),i}finally{r(!1)}},[t]),d=n.useCallback(async(l,e)=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");r(!0),s(null);try{return await t.sendTransaction(l,e)}catch(i){const f=i instanceof Error?i.message:"트랜잭션 전송 실패";throw s(f),i}finally{r(!1)}},[t]);return{address:c,isLoading:o,error:u,signMessage:a,sendTransaction:d}}Object.defineProperty(exports,"ChainId",{enumerable:!0,get:()=>h.ChainId});exports.CROSSxProvider=C;exports.useAuth=A;exports.useCROSSx=S;exports.useWallet=x;
|
package/dist/index.js
CHANGED
|
@@ -1,171 +1,165 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { createCROSSxSDK as
|
|
4
|
-
import { ChainId as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as m, useState as d, useMemo as w, useSyncExternalStore as A, useEffect as x, useContext as E, useCallback as h } from "react";
|
|
3
|
+
import { createCROSSxSDK as C } from "@nexus-cross/crossx-sdk-core";
|
|
4
|
+
import { ChainId as v } from "@nexus-cross/crossx-sdk-core";
|
|
5
|
+
const S = m({
|
|
6
6
|
sdk: null,
|
|
7
7
|
isInitialized: !1,
|
|
8
8
|
isAuthenticated: !1,
|
|
9
9
|
walletAddress: null
|
|
10
10
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
isAuthenticated: t.isAuthenticated(),
|
|
16
|
-
walletAddress: t.currentAddress
|
|
17
|
-
});
|
|
18
|
-
let o = {
|
|
19
|
-
isAuthenticated: t.isAuthenticated(),
|
|
20
|
-
walletAddress: t.currentAddress
|
|
11
|
+
function I(e) {
|
|
12
|
+
let i = {
|
|
13
|
+
isAuthenticated: e.isAuthenticated(),
|
|
14
|
+
walletAddress: e.currentAddress
|
|
21
15
|
};
|
|
22
|
-
const
|
|
23
|
-
function
|
|
24
|
-
|
|
16
|
+
const a = /* @__PURE__ */ new Set();
|
|
17
|
+
function s() {
|
|
18
|
+
a.forEach((n) => n());
|
|
25
19
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
isAuthenticated:
|
|
29
|
-
walletAddress:
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
|
|
20
|
+
const c = e.on("authChanged", (n) => {
|
|
21
|
+
i = {
|
|
22
|
+
isAuthenticated: n.isAuthenticated,
|
|
23
|
+
walletAddress: n.address
|
|
24
|
+
}, s();
|
|
25
|
+
}), r = e.on("addressChanged", (n) => {
|
|
26
|
+
i = { ...i, walletAddress: n.address }, s();
|
|
33
27
|
});
|
|
34
28
|
return {
|
|
35
|
-
subscribe: (
|
|
36
|
-
|
|
29
|
+
subscribe: (n) => (a.add(n), () => {
|
|
30
|
+
a.delete(n);
|
|
37
31
|
}),
|
|
38
|
-
getSnapshot: () =>
|
|
32
|
+
getSnapshot: () => i,
|
|
39
33
|
destroy: () => {
|
|
40
|
-
|
|
34
|
+
c(), r(), a.clear();
|
|
41
35
|
}
|
|
42
36
|
};
|
|
43
37
|
}
|
|
44
|
-
function
|
|
45
|
-
const [
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
function b({ config: e, children: i }) {
|
|
39
|
+
const [a] = d(() => C(e)), [s, c] = d(!1), r = w(() => I(a), [a]), { isAuthenticated: n, walletAddress: l } = A(
|
|
40
|
+
r.subscribe,
|
|
41
|
+
r.getSnapshot
|
|
48
42
|
);
|
|
49
|
-
|
|
50
|
-
let
|
|
51
|
-
return
|
|
43
|
+
x(() => {
|
|
44
|
+
let t = !1;
|
|
45
|
+
return (async () => {
|
|
52
46
|
try {
|
|
53
|
-
await
|
|
54
|
-
} catch (
|
|
55
|
-
|
|
47
|
+
await a.initialize(), t || c(!0);
|
|
48
|
+
} catch (f) {
|
|
49
|
+
t || console.error("CROSSx SDK 초기화 실패:", f);
|
|
56
50
|
}
|
|
57
51
|
})(), () => {
|
|
58
|
-
|
|
52
|
+
t = !0;
|
|
59
53
|
};
|
|
60
|
-
}, [
|
|
61
|
-
const u =
|
|
54
|
+
}, [a]);
|
|
55
|
+
const u = w(
|
|
62
56
|
() => ({
|
|
63
|
-
sdk:
|
|
57
|
+
sdk: a,
|
|
64
58
|
isInitialized: s,
|
|
65
|
-
isAuthenticated:
|
|
66
|
-
walletAddress:
|
|
59
|
+
isAuthenticated: n,
|
|
60
|
+
walletAddress: l
|
|
67
61
|
}),
|
|
68
|
-
[
|
|
62
|
+
[a, s, n, l]
|
|
69
63
|
);
|
|
70
|
-
return /* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ y(S.Provider, { value: u, children: i });
|
|
71
65
|
}
|
|
72
|
-
function
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
66
|
+
function g() {
|
|
67
|
+
const e = E(S);
|
|
68
|
+
if (!e)
|
|
75
69
|
throw new Error("useCROSSx must be used within CROSSxProvider");
|
|
76
|
-
return
|
|
70
|
+
return e;
|
|
77
71
|
}
|
|
78
|
-
function
|
|
79
|
-
const { sdk:
|
|
80
|
-
if (!
|
|
72
|
+
function p() {
|
|
73
|
+
const { sdk: e, isAuthenticated: i } = g(), [a, s] = d(!1), [c, r] = d(null), n = h(async () => {
|
|
74
|
+
if (!e)
|
|
81
75
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
82
|
-
s(!0),
|
|
76
|
+
s(!0), r(null);
|
|
83
77
|
try {
|
|
84
|
-
const
|
|
85
|
-
return
|
|
86
|
-
} catch (
|
|
87
|
-
const
|
|
88
|
-
throw
|
|
78
|
+
const t = await e.signIn();
|
|
79
|
+
return t.success || r(t.error || "로그인 실패"), t;
|
|
80
|
+
} catch (t) {
|
|
81
|
+
const o = t instanceof Error ? t.message : "로그인 실패";
|
|
82
|
+
throw r(o), t;
|
|
89
83
|
} finally {
|
|
90
84
|
s(!1);
|
|
91
85
|
}
|
|
92
|
-
}, [
|
|
93
|
-
if (!
|
|
86
|
+
}, [e]), l = h(async () => {
|
|
87
|
+
if (!e)
|
|
94
88
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
95
|
-
s(!0),
|
|
89
|
+
s(!0), r(null);
|
|
96
90
|
try {
|
|
97
|
-
const
|
|
98
|
-
return
|
|
99
|
-
} catch (
|
|
100
|
-
const
|
|
101
|
-
throw
|
|
91
|
+
const t = await e.signInWithCreate();
|
|
92
|
+
return t.success || r(t.error || "로그인 실패"), t;
|
|
93
|
+
} catch (t) {
|
|
94
|
+
const o = t instanceof Error ? t.message : "로그인 실패";
|
|
95
|
+
throw r(o), t;
|
|
102
96
|
} finally {
|
|
103
97
|
s(!1);
|
|
104
98
|
}
|
|
105
|
-
}, [
|
|
106
|
-
if (!
|
|
99
|
+
}, [e]), u = h(async () => {
|
|
100
|
+
if (!e)
|
|
107
101
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
108
|
-
s(!0),
|
|
102
|
+
s(!0), r(null);
|
|
109
103
|
try {
|
|
110
|
-
await
|
|
111
|
-
} catch (
|
|
112
|
-
const
|
|
113
|
-
throw
|
|
104
|
+
await e.signOut();
|
|
105
|
+
} catch (t) {
|
|
106
|
+
const o = t instanceof Error ? t.message : "로그아웃 실패";
|
|
107
|
+
throw r(o), t;
|
|
114
108
|
} finally {
|
|
115
109
|
s(!1);
|
|
116
110
|
}
|
|
117
|
-
}, [
|
|
111
|
+
}, [e]);
|
|
118
112
|
return {
|
|
119
113
|
isAuthenticated: i,
|
|
120
|
-
isLoading:
|
|
121
|
-
error:
|
|
122
|
-
signIn:
|
|
123
|
-
signInWithCreate:
|
|
114
|
+
isLoading: a,
|
|
115
|
+
error: c,
|
|
116
|
+
signIn: n,
|
|
117
|
+
signInWithCreate: l,
|
|
124
118
|
signOut: u
|
|
125
119
|
};
|
|
126
120
|
}
|
|
127
|
-
function
|
|
128
|
-
const { sdk:
|
|
129
|
-
async (u,
|
|
130
|
-
if (!
|
|
131
|
-
s(!0),
|
|
121
|
+
function R() {
|
|
122
|
+
const { sdk: e, walletAddress: i } = g(), [a, s] = d(!1), [c, r] = d(null), n = h(
|
|
123
|
+
async (u, t) => {
|
|
124
|
+
if (!e) throw new Error("SDK가 초기화되지 않았습니다");
|
|
125
|
+
s(!0), r(null);
|
|
132
126
|
try {
|
|
133
|
-
return await
|
|
134
|
-
} catch (
|
|
135
|
-
const
|
|
136
|
-
throw
|
|
127
|
+
return await e.signMessage(u, t);
|
|
128
|
+
} catch (o) {
|
|
129
|
+
const f = o instanceof Error ? o.message : "서명 실패";
|
|
130
|
+
throw r(f), o;
|
|
137
131
|
} finally {
|
|
138
132
|
s(!1);
|
|
139
133
|
}
|
|
140
134
|
},
|
|
141
|
-
[
|
|
142
|
-
),
|
|
143
|
-
async (u,
|
|
144
|
-
if (!
|
|
145
|
-
s(!0),
|
|
135
|
+
[e]
|
|
136
|
+
), l = h(
|
|
137
|
+
async (u, t) => {
|
|
138
|
+
if (!e) throw new Error("SDK가 초기화되지 않았습니다");
|
|
139
|
+
s(!0), r(null);
|
|
146
140
|
try {
|
|
147
|
-
return await
|
|
148
|
-
} catch (
|
|
149
|
-
const
|
|
150
|
-
throw
|
|
141
|
+
return await e.sendTransaction(u, t);
|
|
142
|
+
} catch (o) {
|
|
143
|
+
const f = o instanceof Error ? o.message : "트랜잭션 전송 실패";
|
|
144
|
+
throw r(f), o;
|
|
151
145
|
} finally {
|
|
152
146
|
s(!1);
|
|
153
147
|
}
|
|
154
148
|
},
|
|
155
|
-
[
|
|
149
|
+
[e]
|
|
156
150
|
);
|
|
157
151
|
return {
|
|
158
152
|
address: i,
|
|
159
|
-
isLoading:
|
|
160
|
-
error:
|
|
161
|
-
signMessage:
|
|
162
|
-
sendTransaction:
|
|
153
|
+
isLoading: a,
|
|
154
|
+
error: c,
|
|
155
|
+
signMessage: n,
|
|
156
|
+
sendTransaction: l
|
|
163
157
|
};
|
|
164
158
|
}
|
|
165
159
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
160
|
+
b as CROSSxProvider,
|
|
161
|
+
v as ChainId,
|
|
162
|
+
p as useAuth,
|
|
163
|
+
g as useCROSSx,
|
|
164
|
+
R as useWallet
|
|
171
165
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/crossx-sdk-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "CROSSx React SDK - React Hooks and Components for Embedded Wallet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"react": "^18.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nexus-cross/crossx-sdk-core": "1.1.
|
|
36
|
+
"@nexus-cross/crossx-sdk-core": "1.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/react": "^18.2.48",
|