@nexus-cross/crossx-sdk-react 2.4.0 → 2.5.0-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/dist/CROSSxProvider.d.ts +10 -0
- package/dist/CROSSxProvider.d.ts.map +1 -1
- package/dist/hooks/useCROSSx.d.ts +7 -0
- package/dist/hooks/useCROSSx.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -42
- package/package.json +3 -3
package/dist/CROSSxProvider.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ export interface CROSSxProviderProps {
|
|
|
18
18
|
*
|
|
19
19
|
* wallet preference 영속화는 SDK 내부(StoragePort)에서 자동 처리되므로
|
|
20
20
|
* Provider에서 별도 localStorage 관리가 불필요합니다.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated ONEpocket 리브랜드 — {@link ONEpocketProvider}를 사용하세요. 동작은 동일하며,
|
|
23
|
+
* 이 이름은 향후 major 버전에서 제거될 예정입니다.
|
|
21
24
|
*/
|
|
22
25
|
export declare function CROSSxProvider({ config, children }: CROSSxProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* ONEpocket Provider 컴포넌트 (CROSSxProvider와 동일)
|
|
28
|
+
* 앱 최상위에 배치하여 SDK 인스턴스를 제공
|
|
29
|
+
*/
|
|
30
|
+
export declare const ONEpocketProvider: typeof CROSSxProvider;
|
|
31
|
+
export type ONEpocketProviderProps = CROSSxProviderProps;
|
|
32
|
+
export type ONEpocketContextValue = CROSSxContextValue;
|
|
23
33
|
//# sourceMappingURL=CROSSxProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CROSSxProvider.d.ts","sourceRoot":"","sources":["../src/CROSSxProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AAEjG,OAAO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Sx SDK 인스턴스에 접근하는 훅
|
|
3
|
+
*
|
|
4
|
+
* @deprecated ONEpocket 리브랜드 — {@link useONEpocket}을 사용하세요. 동작은 동일하며,
|
|
5
|
+
* 이 이름은 향후 major 버전에서 제거될 예정입니다.
|
|
3
6
|
*/
|
|
4
7
|
export declare function useCROSSx(): import('..').CROSSxContextValue;
|
|
8
|
+
/**
|
|
9
|
+
* SDK 인스턴스에 접근하는 훅 (ONEpocket 리브랜드 이름 — useCROSSx와 동일)
|
|
10
|
+
*/
|
|
11
|
+
export declare const useONEpocket: typeof useCROSSx;
|
|
5
12
|
//# sourceMappingURL=useCROSSx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCROSSx.d.ts","sourceRoot":"","sources":["../../src/hooks/useCROSSx.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"useCROSSx.d.ts","sourceRoot":"","sources":["../../src/hooks/useCROSSx.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,SAAS,oCAQxB;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,SAAqB,CAAC"}
|
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 y=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 C(t){let i={isAuthenticated:t.isAuthenticated(),walletAddress:t.currentAddress};const o=new Set;function r(){o.forEach(a=>a())}const u=t.on("authChanged",a=>{i={isAuthenticated:a.isAuthenticated,walletAddress:a.address},r()}),s=t.on("addressChanged",a=>{i={...i,walletAddress:a.address},r()});return{subscribe:a=>(o.add(a),()=>{o.delete(a)}),getSnapshot:()=>i,destroy:()=>{u(),s(),o.clear()}}}function g({config:t,children:i}){const[o]=n.useState(()=>h.createCROSSxSDK(t)),[r,u]=n.useState(!1),s=n.useMemo(()=>C(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 y.jsx(w.Provider,{value:l,children:i})}const E=g;function S(){const t=n.useContext(w);if(!t)throw new Error("useCROSSx must be used within CROSSxProvider");return t}const A=S;function x(){const{sdk:t,isAuthenticated:i}=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 c=e instanceof Error?e.message:"로그인 실패";throw s(c),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 c=e instanceof Error?e.message:"로그인 실패";throw s(c),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 c=e instanceof Error?e.message:"로그아웃 실패";throw s(c),e}finally{r(!1)}},[t]);return{isAuthenticated:i,isLoading:o,error:u,signIn:a,signInWithCreate:d,signOut:l}}function O(){const{sdk:t,walletAddress:i}=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(c){const f=c instanceof Error?c.message:"서명 실패";throw s(f),c}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(c){const f=c instanceof Error?c.message:"트랜잭션 전송 실패";throw s(f),c}finally{r(!1)}},[t]);return{address:i,isLoading:o,error:u,signMessage:a,sendTransaction:d}}Object.defineProperty(exports,"ChainId",{enumerable:!0,get:()=>h.ChainId});exports.CROSSxProvider=g;exports.ONEpocketProvider=E;exports.useAuth=x;exports.useCROSSx=S;exports.useONEpocket=A;exports.useWallet=O;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { useCROSSx } from './hooks/useCROSSx';
|
|
|
3
3
|
export { useAuth } from './hooks/useAuth';
|
|
4
4
|
export { useWallet } from './hooks/useWallet';
|
|
5
5
|
export type { CROSSxProviderProps, CROSSxContextValue } from './CROSSxProvider';
|
|
6
|
+
export { ONEpocketProvider } from './CROSSxProvider';
|
|
7
|
+
export { useONEpocket } from './hooks/useCROSSx';
|
|
8
|
+
export type { ONEpocketProviderProps, ONEpocketContextValue } from './CROSSxProvider';
|
|
6
9
|
export type { SDKConfig, AuthResult, SignMessageResp, SendTxResp, SignInOptions, EvmTransactionRequest, ChainIdValue, } from '@nexus-cross/crossx-sdk-core';
|
|
7
10
|
export { ChainId } from '@nexus-cross/crossx-sdk-core';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,YAAY,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,YAAY,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGtF,YAAY,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,YAAY,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as m, useState as d, useMemo as
|
|
2
|
+
import { createContext as m, useState as d, useMemo as S, useSyncExternalStore as A, useEffect as E, useContext as x, useCallback as h } from "react";
|
|
3
3
|
import { createCROSSxSDK as C } from "@nexus-cross/crossx-sdk-core";
|
|
4
|
-
import { ChainId as
|
|
5
|
-
const
|
|
4
|
+
import { ChainId as P } from "@nexus-cross/crossx-sdk-core";
|
|
5
|
+
const g = m({
|
|
6
6
|
sdk: null,
|
|
7
7
|
isInitialized: !1,
|
|
8
8
|
isAuthenticated: !1,
|
|
@@ -13,9 +13,9 @@ function I(e) {
|
|
|
13
13
|
isAuthenticated: e.isAuthenticated(),
|
|
14
14
|
walletAddress: e.currentAddress
|
|
15
15
|
};
|
|
16
|
-
const
|
|
16
|
+
const o = /* @__PURE__ */ new Set();
|
|
17
17
|
function s() {
|
|
18
|
-
|
|
18
|
+
o.forEach((n) => n());
|
|
19
19
|
}
|
|
20
20
|
const c = e.on("authChanged", (n) => {
|
|
21
21
|
i = {
|
|
@@ -26,51 +26,53 @@ function I(e) {
|
|
|
26
26
|
i = { ...i, walletAddress: n.address }, s();
|
|
27
27
|
});
|
|
28
28
|
return {
|
|
29
|
-
subscribe: (n) => (
|
|
30
|
-
|
|
29
|
+
subscribe: (n) => (o.add(n), () => {
|
|
30
|
+
o.delete(n);
|
|
31
31
|
}),
|
|
32
32
|
getSnapshot: () => i,
|
|
33
33
|
destroy: () => {
|
|
34
|
-
c(), r(),
|
|
34
|
+
c(), r(), o.clear();
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
const [
|
|
38
|
+
function O({ config: e, children: i }) {
|
|
39
|
+
const [o] = d(() => C(e)), [s, c] = d(!1), r = S(() => I(o), [o]), { isAuthenticated: n, walletAddress: l } = A(
|
|
40
40
|
r.subscribe,
|
|
41
41
|
r.getSnapshot
|
|
42
42
|
);
|
|
43
|
-
|
|
43
|
+
E(() => {
|
|
44
44
|
let t = !1;
|
|
45
45
|
return (async () => {
|
|
46
46
|
try {
|
|
47
|
-
await
|
|
47
|
+
await o.initialize(), t || c(!0);
|
|
48
48
|
} catch (f) {
|
|
49
49
|
t || console.error("CROSSx SDK 초기화 실패:", f);
|
|
50
50
|
}
|
|
51
51
|
})(), () => {
|
|
52
52
|
t = !0;
|
|
53
53
|
};
|
|
54
|
-
}, [
|
|
55
|
-
const u =
|
|
54
|
+
}, [o]);
|
|
55
|
+
const u = S(
|
|
56
56
|
() => ({
|
|
57
|
-
sdk:
|
|
57
|
+
sdk: o,
|
|
58
58
|
isInitialized: s,
|
|
59
59
|
isAuthenticated: n,
|
|
60
60
|
walletAddress: l
|
|
61
61
|
}),
|
|
62
|
-
[
|
|
62
|
+
[o, s, n, l]
|
|
63
63
|
);
|
|
64
|
-
return /* @__PURE__ */ y(
|
|
64
|
+
return /* @__PURE__ */ y(g.Provider, { value: u, children: i });
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const b = O;
|
|
67
|
+
function w() {
|
|
68
|
+
const e = x(g);
|
|
68
69
|
if (!e)
|
|
69
70
|
throw new Error("useCROSSx must be used within CROSSxProvider");
|
|
70
71
|
return e;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
const R = w;
|
|
74
|
+
function k() {
|
|
75
|
+
const { sdk: e, isAuthenticated: i } = w(), [o, s] = d(!1), [c, r] = d(null), n = h(async () => {
|
|
74
76
|
if (!e)
|
|
75
77
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
76
78
|
s(!0), r(null);
|
|
@@ -78,8 +80,8 @@ function p() {
|
|
|
78
80
|
const t = await e.signIn();
|
|
79
81
|
return t.success || r(t.error || "로그인 실패"), t;
|
|
80
82
|
} catch (t) {
|
|
81
|
-
const
|
|
82
|
-
throw r(
|
|
83
|
+
const a = t instanceof Error ? t.message : "로그인 실패";
|
|
84
|
+
throw r(a), t;
|
|
83
85
|
} finally {
|
|
84
86
|
s(!1);
|
|
85
87
|
}
|
|
@@ -91,8 +93,8 @@ function p() {
|
|
|
91
93
|
const t = await e.signInWithCreate();
|
|
92
94
|
return t.success || r(t.error || "로그인 실패"), t;
|
|
93
95
|
} catch (t) {
|
|
94
|
-
const
|
|
95
|
-
throw r(
|
|
96
|
+
const a = t instanceof Error ? t.message : "로그인 실패";
|
|
97
|
+
throw r(a), t;
|
|
96
98
|
} finally {
|
|
97
99
|
s(!1);
|
|
98
100
|
}
|
|
@@ -103,31 +105,31 @@ function p() {
|
|
|
103
105
|
try {
|
|
104
106
|
await e.signOut();
|
|
105
107
|
} catch (t) {
|
|
106
|
-
const
|
|
107
|
-
throw r(
|
|
108
|
+
const a = t instanceof Error ? t.message : "로그아웃 실패";
|
|
109
|
+
throw r(a), t;
|
|
108
110
|
} finally {
|
|
109
111
|
s(!1);
|
|
110
112
|
}
|
|
111
113
|
}, [e]);
|
|
112
114
|
return {
|
|
113
115
|
isAuthenticated: i,
|
|
114
|
-
isLoading:
|
|
116
|
+
isLoading: o,
|
|
115
117
|
error: c,
|
|
116
118
|
signIn: n,
|
|
117
119
|
signInWithCreate: l,
|
|
118
120
|
signOut: u
|
|
119
121
|
};
|
|
120
122
|
}
|
|
121
|
-
function
|
|
122
|
-
const { sdk: e, walletAddress: i } =
|
|
123
|
+
function v() {
|
|
124
|
+
const { sdk: e, walletAddress: i } = w(), [o, s] = d(!1), [c, r] = d(null), n = h(
|
|
123
125
|
async (u, t) => {
|
|
124
126
|
if (!e) throw new Error("SDK가 초기화되지 않았습니다");
|
|
125
127
|
s(!0), r(null);
|
|
126
128
|
try {
|
|
127
129
|
return await e.signMessage(u, t);
|
|
128
|
-
} catch (
|
|
129
|
-
const f =
|
|
130
|
-
throw r(f),
|
|
130
|
+
} catch (a) {
|
|
131
|
+
const f = a instanceof Error ? a.message : "서명 실패";
|
|
132
|
+
throw r(f), a;
|
|
131
133
|
} finally {
|
|
132
134
|
s(!1);
|
|
133
135
|
}
|
|
@@ -139,9 +141,9 @@ function R() {
|
|
|
139
141
|
s(!0), r(null);
|
|
140
142
|
try {
|
|
141
143
|
return await e.sendTransaction(u, t);
|
|
142
|
-
} catch (
|
|
143
|
-
const f =
|
|
144
|
-
throw r(f),
|
|
144
|
+
} catch (a) {
|
|
145
|
+
const f = a instanceof Error ? a.message : "트랜잭션 전송 실패";
|
|
146
|
+
throw r(f), a;
|
|
145
147
|
} finally {
|
|
146
148
|
s(!1);
|
|
147
149
|
}
|
|
@@ -150,16 +152,18 @@ function R() {
|
|
|
150
152
|
);
|
|
151
153
|
return {
|
|
152
154
|
address: i,
|
|
153
|
-
isLoading:
|
|
155
|
+
isLoading: o,
|
|
154
156
|
error: c,
|
|
155
157
|
signMessage: n,
|
|
156
158
|
sendTransaction: l
|
|
157
159
|
};
|
|
158
160
|
}
|
|
159
161
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
O as CROSSxProvider,
|
|
163
|
+
P as ChainId,
|
|
164
|
+
b as ONEpocketProvider,
|
|
165
|
+
k as useAuth,
|
|
166
|
+
w as useCROSSx,
|
|
167
|
+
R as useONEpocket,
|
|
168
|
+
v as useWallet
|
|
165
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/crossx-sdk-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-beta.1",
|
|
4
4
|
"description": "CROSSx React SDK - React Hooks and Components for Embedded Wallet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"react": "^18.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nexus-cross/crossx-sdk-core": "2.
|
|
37
|
+
"@nexus-cross/crossx-sdk-core": "2.5.0-beta.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.2.48",
|
|
41
41
|
"react": "^18.2.0",
|
|
42
42
|
"typescript": "^5.3.3",
|
|
43
|
-
"vite": "^
|
|
43
|
+
"vite": "^6.4.3",
|
|
44
44
|
"vite-plugin-dts": "^3.7.1"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|