@nexus-cross/crossx-sdk-wagmi 3.0.0-beta.7 → 3.0.0-beta.8
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 +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +18 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ const proxy = createProxySDK({ frameUrl: 'https://onepocket.onechain.nexus/' });
|
|
|
54
54
|
const connector = createONEpocketConnector({ proxy, projectId: 'your-project-id', appName: 'My DApp' });
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
The connector calls `proxy.init(...)` once. If you already called it, the connector keeps using that session.
|
|
57
|
+
The connector calls `proxy.init(...)` once. If you already called it, the connector keeps using that session — the connector's `appName` · `theme` · `locale` · `primaryColor` options are then ignored, so pass them to your own `proxy.init(...)` instead.
|
|
58
58
|
|
|
59
59
|
## Options
|
|
60
60
|
|
|
@@ -65,6 +65,7 @@ The connector calls `proxy.init(...)` once. If you already called it, the connec
|
|
|
65
65
|
| `proxy` | advanced | Existing proxy SDK (required) |
|
|
66
66
|
| `projectId` | both | Required |
|
|
67
67
|
| `appName` · `theme` · `locale` | both | Passed to the wallet SDK in the iframe |
|
|
68
|
+
| `primaryColor` | both | Button · check · focus color of the secure frame screens. Default navy `#1F1C52`. Must be `#RGB` · `#RRGGBB` with at least 4.5:1 contrast against white, otherwise `connect()` fails with `INVALID_PARAMS` |
|
|
68
69
|
| `defaultChainId` | both | Number or CAIP-2 (`'eip155:612044'`). Default: the first of your wagmi `chains` |
|
|
69
70
|
|
|
70
71
|
## Connector behavior
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("wagmi"),m=require("viem"),_=require("@nexus-cross/crossx-sdk-proxy"),R=612055,P="ONEpocket";function k(n){var c;const t=typeof n=="number"?n:Number((c=/^eip155:(\d+)$/.exec(n))==null?void 0:c[1]);if(!Number.isSafeInteger(t)||t<=0)throw new Error(`invalid defaultChainId: ${String(n)}`);return t}function b(n){const{projectId:t,appName:c,theme:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("wagmi"),m=require("viem"),_=require("@nexus-cross/crossx-sdk-proxy"),R=612055,P="ONEpocket";function k(n){var c;const t=typeof n=="number"?n:Number((c=/^eip155:(\d+)$/.exec(n))==null?void 0:c[1]);if(!Number.isSafeInteger(t)||t<=0)throw new Error(`invalid defaultChainId: ${String(n)}`);return t}function b(n){const{projectId:t,appName:c,theme:s,locale:a,primaryColor:i}=n;return{projectId:t,appName:c,theme:s,locale:a,primaryColor:i}}function q(n){const{frameUrl:t,readyTimeoutMs:c,requestTimeoutMs:s,defaultChainId:a}=n;return O(()=>_.createProxySDK({frameUrl:t,readyTimeoutMs:c,requestTimeoutMs:s}),b(n),a)}function D(n){return O(()=>n.proxy,b(n),n.defaultChainId)}const E=n=>n.map(t=>m.getAddress(t));function L(n){const t=n==null?void 0:n.code;return t===4001?new m.UserRejectedRequestError(n):t===4902?new m.SwitchChainError(n):n}function O(n,t,c){const s=c===void 0?void 0:k(c);let a,i=null,g=null,h=null,r=null;function u(){return g||(i=n(),g=_.createEthereumProvider(i,{chainId:s??a??R}),i.onFrameReloaded(()=>{h=null})),g}function y(){return u(),h??(h=i.init(t).then(()=>{},o=>{if((o==null?void 0:o.code)!=="ALREADY_INITIALIZED")throw h=null,o})),h}async function d(o,l){await y();try{return await u().request({method:o,params:l})}catch(C){throw L(C)}}async function p(){return Number(await u().request({method:"eth_chainId"}))}return N.createConnector(o=>{var C;a??(a=(C=o.chains[0])==null?void 0:C.id);async function l(e){const w=o.chains.find(f=>f.id===e);if(!w)throw new m.SwitchChainError(new N.ChainNotConfiguredError);return await d("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}]),w}return{id:"crossx",name:P,type:"crossx",async setup(){if(!(typeof window>"u"||typeof document>"u"))try{await y()}catch{}},async connect({chainId:e,isReconnecting:w}={}){const f=E(await d(w?"eth_accounts":"eth_requestAccounts"));if(f.length===0)throw new Error("CROSSx: no wallet session to restore");r==null||r();const x=u(),A=I=>this.onAccountsChanged(I),S=I=>this.onChainChanged(I),v=()=>this.onDisconnect();return x.on("accountsChanged",A).on("chainChanged",S).on("disconnect",v),r=()=>{x.removeListener("accountsChanged",A).removeListener("chainChanged",S).removeListener("disconnect",v),r=null},e!==void 0&&e!==await p()&&await l(e),{accounts:f,chainId:await p()}},async disconnect(){r==null||r(),await y(),await i.signOut()},async getAccounts(){return E(await d("eth_accounts"))},async getChainId(){return p()},async getProvider(){return u()},async isAuthorized(){try{return(await d("eth_accounts")).length>0}catch{return!1}},async switchChain({chainId:e}){return l(e)},onAccountsChanged(e){e.length!==0&&o.emitter.emit("change",{accounts:E(e)})},onChainChanged(e){o.emitter.emit("change",{chainId:Number(e)})},onDisconnect(){r==null||r(),o.emitter.emit("disconnect")}}})}const T=q,M=D;exports.createCROSSxConnector=D;exports.createONEpocketConnector=M;exports.crossxConnector=q;exports.onepocketConnector=T;
|
package/dist/index.js
CHANGED
|
@@ -9,12 +9,12 @@ function k(n) {
|
|
|
9
9
|
return t;
|
|
10
10
|
}
|
|
11
11
|
function _(n) {
|
|
12
|
-
const { projectId: t, appName: c, theme:
|
|
13
|
-
return { projectId: t, appName: c, theme:
|
|
12
|
+
const { projectId: t, appName: c, theme: s, locale: a, primaryColor: i } = n;
|
|
13
|
+
return { projectId: t, appName: c, theme: s, locale: a, primaryColor: i };
|
|
14
14
|
}
|
|
15
15
|
function M(n) {
|
|
16
|
-
const { frameUrl: t, readyTimeoutMs: c, requestTimeoutMs:
|
|
17
|
-
return D(() => L({ frameUrl: t, readyTimeoutMs: c, requestTimeoutMs:
|
|
16
|
+
const { frameUrl: t, readyTimeoutMs: c, requestTimeoutMs: s, defaultChainId: a } = n;
|
|
17
|
+
return D(() => L({ frameUrl: t, readyTimeoutMs: c, requestTimeoutMs: s }), _(n), a);
|
|
18
18
|
}
|
|
19
19
|
function U(n) {
|
|
20
20
|
return D(() => n.proxy, _(n), n.defaultChainId);
|
|
@@ -25,15 +25,15 @@ function $(n) {
|
|
|
25
25
|
return t === 4001 ? new q(n) : t === 4902 ? new x(n) : n;
|
|
26
26
|
}
|
|
27
27
|
function D(n, t, c) {
|
|
28
|
-
const
|
|
29
|
-
let
|
|
28
|
+
const s = c === void 0 ? void 0 : k(c);
|
|
29
|
+
let a, i = null, w = null, h = null, r = null;
|
|
30
30
|
function u() {
|
|
31
|
-
return w || (
|
|
31
|
+
return w || (i = n(), w = O(i, { chainId: s ?? a ?? P }), i.onFrameReloaded(() => {
|
|
32
32
|
h = null;
|
|
33
33
|
})), w;
|
|
34
34
|
}
|
|
35
35
|
function g() {
|
|
36
|
-
return u(), h ?? (h =
|
|
36
|
+
return u(), h ?? (h = i.init(t).then(
|
|
37
37
|
() => {
|
|
38
38
|
},
|
|
39
39
|
(o) => {
|
|
@@ -46,20 +46,20 @@ function D(n, t, c) {
|
|
|
46
46
|
await g();
|
|
47
47
|
try {
|
|
48
48
|
return await u().request({ method: o, params: l });
|
|
49
|
-
} catch (
|
|
50
|
-
throw $(
|
|
49
|
+
} catch (m) {
|
|
50
|
+
throw $(m);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
async function y() {
|
|
54
54
|
return Number(await u().request({ method: "eth_chainId" }));
|
|
55
55
|
}
|
|
56
56
|
return S((o) => {
|
|
57
|
-
var
|
|
58
|
-
|
|
57
|
+
var m;
|
|
58
|
+
a ?? (a = (m = o.chains[0]) == null ? void 0 : m.id);
|
|
59
59
|
async function l(e) {
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
return await d("wallet_switchEthereumChain", [{ chainId: `0x${e.toString(16)}` }]),
|
|
60
|
+
const f = o.chains.find((C) => C.id === e);
|
|
61
|
+
if (!f) throw new x(new b());
|
|
62
|
+
return await d("wallet_switchEthereumChain", [{ chainId: `0x${e.toString(16)}` }]), f;
|
|
63
63
|
}
|
|
64
64
|
return {
|
|
65
65
|
id: "crossx",
|
|
@@ -72,8 +72,8 @@ function D(n, t, c) {
|
|
|
72
72
|
} catch {
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
async connect({ chainId: e, isReconnecting:
|
|
76
|
-
const C = I(await d(
|
|
75
|
+
async connect({ chainId: e, isReconnecting: f } = {}) {
|
|
76
|
+
const C = I(await d(f ? "eth_accounts" : "eth_requestAccounts"));
|
|
77
77
|
if (C.length === 0) throw new Error("CROSSx: no wallet session to restore");
|
|
78
78
|
r == null || r();
|
|
79
79
|
const A = u(), E = (p) => this.onAccountsChanged(p), N = (p) => this.onChainChanged(p), v = () => this.onDisconnect();
|
|
@@ -82,7 +82,7 @@ function D(n, t, c) {
|
|
|
82
82
|
}, e !== void 0 && e !== await y() && await l(e), { accounts: C, chainId: await y() };
|
|
83
83
|
},
|
|
84
84
|
async disconnect() {
|
|
85
|
-
r == null || r(), await g(), await
|
|
85
|
+
r == null || r(), await g(), await i.signOut();
|
|
86
86
|
},
|
|
87
87
|
async getAccounts() {
|
|
88
88
|
return I(await d("eth_accounts"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/crossx-sdk-wagmi",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.8",
|
|
4
4
|
"description": "CROSSx SDK wagmi Connector — 보안 화면 앱(iframe) 지갑을 대리 SDK 로 wagmi 에 통합",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"vite-plugin-dts": "^3.7.1",
|
|
30
30
|
"vitest": "^3.2.0",
|
|
31
31
|
"wagmi": "^3.5.0",
|
|
32
|
-
"@nexus-cross/crossx-sdk-proxy": "^3.0.0-beta.
|
|
32
|
+
"@nexus-cross/crossx-sdk-proxy": "^3.0.0-beta.8"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"crossx",
|