miniwallet 0.1.17 → 0.1.19
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/miniwallet.js +25 -22
- package/package.json +3 -1
package/dist/miniwallet.js
CHANGED
|
@@ -78,8 +78,8 @@ function h({ children: e, chains: n = [] }) {
|
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
S(e);
|
|
81
|
-
let r = await n.request({ method: "eth_requestAccounts" }), i = parseInt(String(
|
|
82
|
-
u(r[0]), g(t), v(
|
|
81
|
+
let r = await n.request({ method: "eth_requestAccounts" }), i = await n.request({ method: "eth_chainId" }), a = parseInt(String(i || "0x0"), 16);
|
|
82
|
+
u(r[0]), g(t), v(a), localStorage.setItem("miniwallet:lastWalletId", t);
|
|
83
83
|
} catch (e) {
|
|
84
84
|
console.log("error: ", e);
|
|
85
85
|
let t = e, n = t?.code ?? "", r = t?.message ?? "";
|
|
@@ -111,7 +111,7 @@ function h({ children: e, chains: n = [] }) {
|
|
|
111
111
|
try {
|
|
112
112
|
let t = C.current[h];
|
|
113
113
|
if (!t) {
|
|
114
|
-
alert("
|
|
114
|
+
alert("请安装钱包");
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
await t.request({
|
|
@@ -198,13 +198,13 @@ function h({ children: e, chains: n = [] }) {
|
|
|
198
198
|
let n = !1;
|
|
199
199
|
return (async () => {
|
|
200
200
|
let r = await t.request({ method: "eth_accounts" });
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
u(r[0]), g(e), v(parseInt(t.chainId, 16));
|
|
201
|
+
if (n) return;
|
|
202
|
+
if (!r?.length) {
|
|
203
|
+
localStorage.removeItem("miniwallet:lastWalletId");
|
|
204
|
+
return;
|
|
207
205
|
}
|
|
206
|
+
let i = await t.request({ method: "eth_chainId" });
|
|
207
|
+
u(r[0]), g(e), v(parseInt(String(i || "0x0"), 16));
|
|
208
208
|
})(), () => {
|
|
209
209
|
n = !0;
|
|
210
210
|
};
|
|
@@ -226,11 +226,11 @@ var _ = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOC
|
|
|
226
226
|
//#endregion
|
|
227
227
|
//#region src/MiniWalletButton.tsx
|
|
228
228
|
function v({ label: e = "Connect Wallet" }) {
|
|
229
|
-
let { account: n, balance: a, isConnected: l, connectingWallet: u, selectedChain: d, wallet: p, switchChain: m, chains: h, connect: v, disconnect: y } = g(), [b, x] = o(!1), [S, C] = o(!1), [w, T] = o(!1), [E, D] = o("复制地址"), O = i(() => n ? `${n.slice(0, 6)}...${n.slice(-4)}` : "", [n]), k = t(() => {
|
|
229
|
+
let { account: n, balance: a, isConnected: l, connectingWallet: u, selectedChain: d, wallet: p, switchChain: m, chains: h, connect: v, disconnect: y } = g(), [b, x] = o(!1), [S, C] = o(!1), [w, T] = o(!1), [E, D] = o("复制地址"), O = i(() => n ? `${n.slice(0, 6)}...${n.slice(-4)}` : "", [n]), k = i(() => l && !d, [l, d]), A = t(() => {
|
|
230
230
|
x(!0);
|
|
231
|
-
}, []),
|
|
232
|
-
x(!1), C(!1);
|
|
233
|
-
}, []),
|
|
231
|
+
}, []), j = t(() => {
|
|
232
|
+
x(!1), C(!1), T(!1);
|
|
233
|
+
}, []), M = t(async () => {
|
|
234
234
|
try {
|
|
235
235
|
await navigator.clipboard.writeText(n), D("已复制!"), setTimeout(() => {
|
|
236
236
|
D("复制地址");
|
|
@@ -240,18 +240,21 @@ function v({ label: e = "Connect Wallet" }) {
|
|
|
240
240
|
}
|
|
241
241
|
}, [n]);
|
|
242
242
|
return r(() => {
|
|
243
|
-
l &&
|
|
244
|
-
}, [
|
|
243
|
+
l && j();
|
|
244
|
+
}, [j, l]), l ? /* @__PURE__ */ c("section", {
|
|
245
245
|
className: "inline-flex items-center justify-center text-center",
|
|
246
246
|
children: [
|
|
247
|
-
/* @__PURE__ */
|
|
248
|
-
value: d?.id,
|
|
247
|
+
/* @__PURE__ */ c("select", {
|
|
248
|
+
value: k ? "unknow" : d?.id,
|
|
249
249
|
onChange: (e) => m(h.find((t) => t.id === Number(e.target.value))),
|
|
250
250
|
className: "bg-transparent1 mr-4 cursor-pointer rounded-sm border-none p-1 text-gray-600 outline-none hover:bg-gray-100",
|
|
251
|
-
children: h.map((e) => /* @__PURE__ */ s("option", {
|
|
251
|
+
children: [h.map((e) => /* @__PURE__ */ s("option", {
|
|
252
252
|
value: e.id,
|
|
253
253
|
children: e.name
|
|
254
|
-
}, e.id))
|
|
254
|
+
}, e.id)), k && /* @__PURE__ */ s("option", {
|
|
255
|
+
value: "unknow",
|
|
256
|
+
children: "未知的网络"
|
|
257
|
+
}, "unknow")]
|
|
255
258
|
}),
|
|
256
259
|
/* @__PURE__ */ c("div", {
|
|
257
260
|
className: "flex items-center justify-center rounded-2xl bg-white pr-3 shadow-lg inset-ring-1 shadow-gray-200 inset-ring-gray-100",
|
|
@@ -323,7 +326,7 @@ function v({ label: e = "Connect Wallet" }) {
|
|
|
323
326
|
/* @__PURE__ */ c("div", {
|
|
324
327
|
className: "mt-2 w-full space-x-10",
|
|
325
328
|
children: [/* @__PURE__ */ s("button", {
|
|
326
|
-
onClick:
|
|
329
|
+
onClick: M,
|
|
327
330
|
className: "w-[112px] cursor-pointer rounded-xl bg-gray-700 py-2 text-white shadow-md shadow-gray-500/50 outline-none",
|
|
328
331
|
children: E
|
|
329
332
|
}), /* @__PURE__ */ s("button", {
|
|
@@ -339,7 +342,7 @@ function v({ label: e = "Connect Wallet" }) {
|
|
|
339
342
|
]
|
|
340
343
|
}) : /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("button", {
|
|
341
344
|
type: "button",
|
|
342
|
-
onClick:
|
|
345
|
+
onClick: A,
|
|
343
346
|
className: "cursor-pointer rounded-xl bg-blue-500 px-4 py-2 text-white shadow-lg shadow-blue-500/50",
|
|
344
347
|
children: e
|
|
345
348
|
}), b && /* @__PURE__ */ s("div", {
|
|
@@ -355,7 +358,7 @@ function v({ label: e = "Connect Wallet" }) {
|
|
|
355
358
|
type: "button",
|
|
356
359
|
"aria-label": "Close",
|
|
357
360
|
className: "cursor-pointer rounded-full p-1 hover:bg-gray-100",
|
|
358
|
-
onClick:
|
|
361
|
+
onClick: j,
|
|
359
362
|
children: /* @__PURE__ */ c("svg", {
|
|
360
363
|
xmlns: "http://www.w3.org/2000/svg",
|
|
361
364
|
viewBox: "0 0 24 24",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miniwallet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "React wallet connect button with multi-wallet support via EIP-6963",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/miniwallet.js",
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"dev": "vite",
|
|
24
24
|
"build": "tsc -b && vite build",
|
|
25
|
+
"build:demo": "tsc -b && vite build --mode demo",
|
|
25
26
|
"lint": "eslint .",
|
|
26
27
|
"preview": "vite preview",
|
|
28
|
+
"preview:demo": "vite preview --outDir dist-demo",
|
|
27
29
|
"prepublishOnly": "pnpm build"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|