@nexus-cross/crossx-sdk-react 2.6.0 → 3.0.0-beta.10
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 +15 -3
- package/dist/CROSSxProvider.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +85 -85
- package/package.json +2 -2
package/dist/CROSSxProvider.d.ts
CHANGED
|
@@ -8,10 +8,22 @@ export interface CROSSxContextValue {
|
|
|
8
8
|
walletAddress: string | null;
|
|
9
9
|
}
|
|
10
10
|
export declare const CROSSxContext: React.Context<CROSSxContextValue>;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* `config` 로 SDK 를 만들거나, 이미 만든 `sdk` 를 넘긴다 (둘 중 하나).
|
|
13
|
+
*
|
|
14
|
+
* `config` 로 만든 SDK 는 화면이 없다(headless) — PIN · 서명 확인 요청은 `UI_NOT_PROVIDED` 로 실패한다.
|
|
15
|
+
* 화면이 필요하면 `@nexus-cross/crossx-sdk-core/internal` 의 `createCROSSxSDKWithOverrides(config, { ui })` 로
|
|
16
|
+
* 만든 SDK 를 `sdk` 로 넘긴다 (DEV2TF-2321). 이 패키지는 UI 패키지에 의존하지 않는다.
|
|
17
|
+
*/
|
|
18
|
+
export type CROSSxProviderProps = ({
|
|
12
19
|
config: SDKConfig;
|
|
20
|
+
sdk?: never;
|
|
21
|
+
} | {
|
|
22
|
+
sdk: CROSSxSDK;
|
|
23
|
+
config?: never;
|
|
24
|
+
}) & {
|
|
13
25
|
children: React.ReactNode;
|
|
14
|
-
}
|
|
26
|
+
};
|
|
15
27
|
/**
|
|
16
28
|
* CROSSx Provider 컴포넌트
|
|
17
29
|
* 앱 최상위에 배치하여 SDK 인스턴스를 제공
|
|
@@ -22,7 +34,7 @@ export interface CROSSxProviderProps {
|
|
|
22
34
|
* @deprecated ONEpocket 리브랜드 — {@link ONEpocketProvider}를 사용하세요. 동작은 동일하며,
|
|
23
35
|
* 이 이름은 향후 major 버전에서 제거될 예정입니다.
|
|
24
36
|
*/
|
|
25
|
-
export declare function CROSSxProvider({ config, children }: CROSSxProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function CROSSxProvider({ config, sdk: injectedSdk, children }: CROSSxProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
26
38
|
/**
|
|
27
39
|
* ONEpocket Provider 컴포넌트 (CROSSxProvider와 동일)
|
|
28
40
|
* 앱 최상위에 배치하여 SDK 인스턴스를 제공
|
|
@@ -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,
|
|
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;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAC9B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,GAClC;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,CACrC,GAAG;IACF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAwDF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CA6CzF;AAID;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,cAA+B,CAAC;AAEvE,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACzD,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,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 C=require("react/jsx-runtime"),a=require("react"),h=require("@nexus-cross/crossx-sdk-core"),w=a.createContext({sdk:null,isInitialized:!1,isAuthenticated:!1,walletAddress:null});function E(t){let c={isAuthenticated:t.isAuthenticated(),walletAddress:t.currentAddress};const i=new Set;function s(){i.forEach(o=>o())}const u=t.on("authChanged",o=>{c={isAuthenticated:o.isAuthenticated,walletAddress:o.address},s()}),r=t.on("addressChanged",o=>{c={...c,walletAddress:o.address},s()});return{subscribe:o=>(i.add(o),()=>{i.delete(o)}),getSnapshot:()=>c,destroy:()=>{u(),r(),i.clear()}}}function g({config:t,sdk:c,children:i}){const[s]=a.useState(()=>c??h.createCROSSxSDK(t)),[u,r]=a.useState(!1),o=a.useMemo(()=>E(s),[s]),{isAuthenticated:d,walletAddress:l}=a.useSyncExternalStore(o.subscribe,o.getSnapshot);a.useEffect(()=>{let n=!1;return(async()=>{try{await s.initialize(),n||r(!0)}catch(y){n||console.error("CROSSx SDK 초기화 실패:",y)}})(),()=>{n=!0}},[s]);const e=a.useMemo(()=>({sdk:s,isInitialized:u,isAuthenticated:d,walletAddress:l}),[s,u,d,l]);return C.jsx(w.Provider,{value:e,children:i})}const A=g;function S(){const t=a.useContext(w);if(!t)throw new Error("useCROSSx must be used within CROSSxProvider");return t}const x=S;function O(){const{sdk:t,isAuthenticated:c}=S(),[i,s]=a.useState(!1),[u,r]=a.useState(null),o=a.useCallback(async()=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");s(!0),r(null);try{const e=await t.signIn();return e.success||r(e.error||"로그인 실패"),e}catch(e){const n=e instanceof Error?e.message:"로그인 실패";throw r(n),e}finally{s(!1)}},[t]),d=a.useCallback(async()=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");s(!0),r(null);try{const e=await t.signInWithCreate();return e.success||r(e.error||"로그인 실패"),e}catch(e){const n=e instanceof Error?e.message:"로그인 실패";throw r(n),e}finally{s(!1)}},[t]),l=a.useCallback(async()=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");s(!0),r(null);try{await t.signOut()}catch(e){const n=e instanceof Error?e.message:"로그아웃 실패";throw r(n),e}finally{s(!1)}},[t]);return{isAuthenticated:c,isLoading:i,error:u,signIn:o,signInWithCreate:d,signOut:l}}function b(){const{sdk:t,walletAddress:c}=S(),[i,s]=a.useState(!1),[u,r]=a.useState(null),o=a.useCallback(async(l,e)=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");s(!0),r(null);try{return await t.signMessage(l,e)}catch(n){const f=n instanceof Error?n.message:"서명 실패";throw r(f),n}finally{s(!1)}},[t]),d=a.useCallback(async(l,e)=>{if(!t)throw new Error("SDK가 초기화되지 않았습니다");s(!0),r(null);try{return await t.sendTransaction(l,e)}catch(n){const f=n instanceof Error?n.message:"트랜잭션 전송 실패";throw r(f),n}finally{s(!1)}},[t]);return{address:c,isLoading:i,error:u,signMessage:o,sendTransaction:d}}Object.defineProperty(exports,"ChainId",{enumerable:!0,get:()=>h.ChainId});exports.CROSSxProvider=g;exports.ONEpocketProvider=A;exports.useAuth=O;exports.useCROSSx=S;exports.useONEpocket=x;exports.useWallet=b;
|
package/dist/index.js
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { createCROSSxSDK as
|
|
4
|
-
import { ChainId as
|
|
5
|
-
const g =
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as A, useState as d, useMemo as S, useSyncExternalStore as E, useEffect as x, useContext as C, useCallback as f } from "react";
|
|
3
|
+
import { createCROSSxSDK as I } from "@nexus-cross/crossx-sdk-core";
|
|
4
|
+
import { ChainId as M } from "@nexus-cross/crossx-sdk-core";
|
|
5
|
+
const g = A({
|
|
6
6
|
sdk: null,
|
|
7
7
|
isInitialized: !1,
|
|
8
8
|
isAuthenticated: !1,
|
|
9
9
|
walletAddress: null
|
|
10
10
|
});
|
|
11
|
-
function
|
|
12
|
-
let
|
|
11
|
+
function O(e) {
|
|
12
|
+
let a = {
|
|
13
13
|
isAuthenticated: e.isAuthenticated(),
|
|
14
14
|
walletAddress: e.currentAddress
|
|
15
15
|
};
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
|
|
16
|
+
const i = /* @__PURE__ */ new Set();
|
|
17
|
+
function r() {
|
|
18
|
+
i.forEach((o) => o());
|
|
19
19
|
}
|
|
20
|
-
const c = e.on("authChanged", (
|
|
21
|
-
|
|
22
|
-
isAuthenticated:
|
|
23
|
-
walletAddress:
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
|
|
20
|
+
const c = e.on("authChanged", (o) => {
|
|
21
|
+
a = {
|
|
22
|
+
isAuthenticated: o.isAuthenticated,
|
|
23
|
+
walletAddress: o.address
|
|
24
|
+
}, r();
|
|
25
|
+
}), s = e.on("addressChanged", (o) => {
|
|
26
|
+
a = { ...a, walletAddress: o.address }, r();
|
|
27
27
|
});
|
|
28
28
|
return {
|
|
29
|
-
subscribe: (
|
|
30
|
-
|
|
29
|
+
subscribe: (o) => (i.add(o), () => {
|
|
30
|
+
i.delete(o);
|
|
31
31
|
}),
|
|
32
|
-
getSnapshot: () =>
|
|
32
|
+
getSnapshot: () => a,
|
|
33
33
|
destroy: () => {
|
|
34
|
-
c(),
|
|
34
|
+
c(), s(), i.clear();
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
function p({ config: e, sdk: a, children: i }) {
|
|
39
|
+
const [r] = d(() => a ?? I(e)), [c, s] = d(!1), o = S(() => O(r), [r]), { isAuthenticated: l, walletAddress: u } = E(
|
|
40
|
+
o.subscribe,
|
|
41
|
+
o.getSnapshot
|
|
42
42
|
);
|
|
43
|
-
|
|
44
|
-
let
|
|
43
|
+
x(() => {
|
|
44
|
+
let n = !1;
|
|
45
45
|
return (async () => {
|
|
46
46
|
try {
|
|
47
|
-
await
|
|
48
|
-
} catch (
|
|
49
|
-
|
|
47
|
+
await r.initialize(), n || s(!0);
|
|
48
|
+
} catch (y) {
|
|
49
|
+
n || console.error("CROSSx SDK 초기화 실패:", y);
|
|
50
50
|
}
|
|
51
51
|
})(), () => {
|
|
52
|
-
|
|
52
|
+
n = !0;
|
|
53
53
|
};
|
|
54
|
-
}, [
|
|
55
|
-
const
|
|
54
|
+
}, [r]);
|
|
55
|
+
const t = S(
|
|
56
56
|
() => ({
|
|
57
|
-
sdk:
|
|
58
|
-
isInitialized:
|
|
59
|
-
isAuthenticated:
|
|
60
|
-
walletAddress:
|
|
57
|
+
sdk: r,
|
|
58
|
+
isInitialized: c,
|
|
59
|
+
isAuthenticated: l,
|
|
60
|
+
walletAddress: u
|
|
61
61
|
}),
|
|
62
|
-
[
|
|
62
|
+
[r, c, l, u]
|
|
63
63
|
);
|
|
64
|
-
return /* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ m(g.Provider, { value: t, children: i });
|
|
65
65
|
}
|
|
66
|
-
const
|
|
66
|
+
const R = p;
|
|
67
67
|
function w() {
|
|
68
|
-
const e =
|
|
68
|
+
const e = C(g);
|
|
69
69
|
if (!e)
|
|
70
70
|
throw new Error("useCROSSx must be used within CROSSxProvider");
|
|
71
71
|
return e;
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
function
|
|
75
|
-
const { sdk: e, isAuthenticated:
|
|
73
|
+
const k = w;
|
|
74
|
+
function v() {
|
|
75
|
+
const { sdk: e, isAuthenticated: a } = w(), [i, r] = d(!1), [c, s] = d(null), o = f(async () => {
|
|
76
76
|
if (!e)
|
|
77
77
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
78
|
-
|
|
78
|
+
r(!0), s(null);
|
|
79
79
|
try {
|
|
80
80
|
const t = await e.signIn();
|
|
81
|
-
return t.success ||
|
|
81
|
+
return t.success || s(t.error || "로그인 실패"), t;
|
|
82
82
|
} catch (t) {
|
|
83
|
-
const
|
|
84
|
-
throw
|
|
83
|
+
const n = t instanceof Error ? t.message : "로그인 실패";
|
|
84
|
+
throw s(n), t;
|
|
85
85
|
} finally {
|
|
86
|
-
|
|
86
|
+
r(!1);
|
|
87
87
|
}
|
|
88
|
-
}, [e]), l =
|
|
88
|
+
}, [e]), l = f(async () => {
|
|
89
89
|
if (!e)
|
|
90
90
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
91
|
-
|
|
91
|
+
r(!0), s(null);
|
|
92
92
|
try {
|
|
93
93
|
const t = await e.signInWithCreate();
|
|
94
|
-
return t.success ||
|
|
94
|
+
return t.success || s(t.error || "로그인 실패"), t;
|
|
95
95
|
} catch (t) {
|
|
96
|
-
const
|
|
97
|
-
throw
|
|
96
|
+
const n = t instanceof Error ? t.message : "로그인 실패";
|
|
97
|
+
throw s(n), t;
|
|
98
98
|
} finally {
|
|
99
|
-
|
|
99
|
+
r(!1);
|
|
100
100
|
}
|
|
101
|
-
}, [e]), u =
|
|
101
|
+
}, [e]), u = f(async () => {
|
|
102
102
|
if (!e)
|
|
103
103
|
throw new Error("SDK가 초기화되지 않았습니다");
|
|
104
|
-
|
|
104
|
+
r(!0), s(null);
|
|
105
105
|
try {
|
|
106
106
|
await e.signOut();
|
|
107
107
|
} catch (t) {
|
|
108
|
-
const
|
|
109
|
-
throw
|
|
108
|
+
const n = t instanceof Error ? t.message : "로그아웃 실패";
|
|
109
|
+
throw s(n), t;
|
|
110
110
|
} finally {
|
|
111
|
-
|
|
111
|
+
r(!1);
|
|
112
112
|
}
|
|
113
113
|
}, [e]);
|
|
114
114
|
return {
|
|
115
|
-
isAuthenticated:
|
|
116
|
-
isLoading:
|
|
115
|
+
isAuthenticated: a,
|
|
116
|
+
isLoading: i,
|
|
117
117
|
error: c,
|
|
118
|
-
signIn:
|
|
118
|
+
signIn: o,
|
|
119
119
|
signInWithCreate: l,
|
|
120
120
|
signOut: u
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
const { sdk: e, walletAddress:
|
|
123
|
+
function z() {
|
|
124
|
+
const { sdk: e, walletAddress: a } = w(), [i, r] = d(!1), [c, s] = d(null), o = f(
|
|
125
125
|
async (u, t) => {
|
|
126
126
|
if (!e) throw new Error("SDK가 초기화되지 않았습니다");
|
|
127
|
-
|
|
127
|
+
r(!0), s(null);
|
|
128
128
|
try {
|
|
129
129
|
return await e.signMessage(u, t);
|
|
130
|
-
} catch (
|
|
131
|
-
const
|
|
132
|
-
throw
|
|
130
|
+
} catch (n) {
|
|
131
|
+
const h = n instanceof Error ? n.message : "서명 실패";
|
|
132
|
+
throw s(h), n;
|
|
133
133
|
} finally {
|
|
134
|
-
|
|
134
|
+
r(!1);
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
[e]
|
|
138
|
-
), l =
|
|
138
|
+
), l = f(
|
|
139
139
|
async (u, t) => {
|
|
140
140
|
if (!e) throw new Error("SDK가 초기화되지 않았습니다");
|
|
141
|
-
|
|
141
|
+
r(!0), s(null);
|
|
142
142
|
try {
|
|
143
143
|
return await e.sendTransaction(u, t);
|
|
144
|
-
} catch (
|
|
145
|
-
const
|
|
146
|
-
throw
|
|
144
|
+
} catch (n) {
|
|
145
|
+
const h = n instanceof Error ? n.message : "트랜잭션 전송 실패";
|
|
146
|
+
throw s(h), n;
|
|
147
147
|
} finally {
|
|
148
|
-
|
|
148
|
+
r(!1);
|
|
149
149
|
}
|
|
150
150
|
},
|
|
151
151
|
[e]
|
|
152
152
|
);
|
|
153
153
|
return {
|
|
154
|
-
address:
|
|
155
|
-
isLoading:
|
|
154
|
+
address: a,
|
|
155
|
+
isLoading: i,
|
|
156
156
|
error: c,
|
|
157
|
-
signMessage:
|
|
157
|
+
signMessage: o,
|
|
158
158
|
sendTransaction: l
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
p as CROSSxProvider,
|
|
163
|
+
M as ChainId,
|
|
164
|
+
R as ONEpocketProvider,
|
|
165
|
+
v as useAuth,
|
|
166
166
|
w as useCROSSx,
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
k as useONEpocket,
|
|
168
|
+
z as useWallet
|
|
169
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/crossx-sdk-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
4
|
"description": "CROSSx React SDK - React Hooks and Components for Embedded Wallet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react": "^18.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nexus-cross/crossx-sdk-core": "
|
|
37
|
+
"@nexus-cross/crossx-sdk-core": "3.0.0-beta.10"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.2.48",
|