miniwallet 0.1.12 → 0.1.13

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.
Files changed (2) hide show
  1. package/dist/miniwallet.js +111 -113
  2. package/package.json +1 -1
@@ -1,26 +1,26 @@
1
1
  import "./miniwallet.css";
2
- import { createContext as e, useCallback as t, useContext as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
3
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
2
+ import { createContext as e, useCallback as t, useContext as n, useEffect as r, useMemo as i, useState as a } from "react";
3
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
4
  //#region src/MiniWalletContext.tsx
5
- var l = e(null);
5
+ var c = e(null);
6
6
  //#endregion
7
7
  //#region src/utils/formatUnits.ts
8
- function u(e) {
8
+ function l(e) {
9
9
  if (typeof e == "bigint") return e;
10
10
  let t = e.trim();
11
11
  if (!t) throw Error("value must not be empty");
12
12
  return BigInt(t);
13
13
  }
14
- function d(e, t) {
14
+ function u(e, t) {
15
15
  if (!Number.isInteger(t) || t < 0) throw Error("decimals must be a non-negative integer");
16
- let n = u(e);
16
+ let n = l(e);
17
17
  if (t === 0) return n.toString();
18
18
  let r = 10n ** BigInt(t), i = n / r, a = n % r;
19
19
  return a === 0n ? i.toString() : `${i}.${a.toString().padStart(t, "0").replace(/0+$/, "")}`;
20
20
  }
21
21
  //#endregion
22
22
  //#region src/constants.ts
23
- var f = [
23
+ var d = [
24
24
  {
25
25
  id: "metamask",
26
26
  name: "MetaMask",
@@ -41,13 +41,13 @@ var f = [
41
41
  name: "Coinbase",
42
42
  icon: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1783439807758'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='13209'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%3e%3cpath%20d='M1024%20186.181818a186.181818%20186.181818%200%200%200-186.181818-186.181818H186.181818a186.181818%20186.181818%200%200%200-186.181818%20186.181818v651.636364a186.181818%20186.181818%200%200%200%20186.181818%20186.181818h651.636364a186.181818%20186.181818%200%200%200%20186.181818-186.181818V186.181818z'%20fill='%232C5FF6'%20p-id='13210'%3e%3c/path%3e%3cpath%20d='M512%20870.4a358.4%20358.4%200%201%200%200-716.8%20358.4%20358.4%200%200%200%200%20716.8zM422.4%20394.984727h179.2a27.461818%2027.461818%200%200%201%2027.461818%2027.415273v179.2a27.461818%2027.461818%200%200%201-27.461818%2027.461818h-179.2a27.461818%2027.461818%200%200%201-27.461818-27.461818v-179.2a27.461818%2027.461818%200%200%201%2027.461818-27.461818z'%20fill='%23FFFFFF'%20p-id='13211'%3e%3c/path%3e%3c/svg%3e"
43
43
  }
44
- ], p = {
44
+ ], f = {
45
45
  "io.metamask": "metamask",
46
46
  "com.okex.wallet": "okx",
47
47
  "com.okx.wallet": "okx",
48
48
  "app.phantom": "phantom",
49
49
  "com.coinbase.wallet": "coinbase"
50
- }, m = [
50
+ }, p = [
51
51
  {
52
52
  id: 1,
53
53
  name: "Ethereum",
@@ -69,12 +69,10 @@ var f = [
69
69
  ];
70
70
  //#endregion
71
71
  //#region src/MiniWalletProvider.tsx
72
- function h({ children: e, chains: n = [] }) {
73
- let [c, u] = o(""), [h, g] = o(""), [_, v] = o(0), [y, b] = o(""), [x] = o(null), S = a({}), [C, w] = o(0), T = i(() => n.length > 0 ? n : m, [n]), E = i(() => S.current[h] ?? null, [C, h]), D = i(() => f.find((e) => e.id === h), [h]), O = i(() => !!c, [c]), k = i(() => T.find((e) => e.id === _) || null, [T, _]), A = i(() => !k || !y || !k?.decimals ? "0" : Number(d(y, k.decimals)).toFixed(3), [y, k]), j = t(async (e) => {
74
- let { id: t } = e;
75
- console.log("eip6963Providers: ", S.current);
76
- let n = S.current[t];
77
- if (!n || typeof n.request != "function") {
72
+ function m({ children: e, chains: n = [] }) {
73
+ let [s, l] = a(""), [m, h] = a(""), [g, _] = a(0), [v, y] = a(""), [b] = a(null), [x, S] = a({}), C = i(() => n.length > 0 ? n : p, [n]), w = i(() => x[m] ?? null, [x, m]), T = i(() => d.find((e) => e.id === m), [m]), E = i(() => !!s, [s]), D = i(() => C.find((e) => e.id === g) || null, [C, g]), O = i(() => !D || !v || !D?.decimals ? "0" : Number(u(v, D.decimals)).toFixed(3), [v, D]), k = t(async (e) => {
74
+ let { id: t } = e, n = x[t];
75
+ if (!n) {
78
76
  alert("请安装钱包");
79
77
  return;
80
78
  }
@@ -83,7 +81,7 @@ function h({ children: e, chains: n = [] }) {
83
81
  let e = await n.request({ method: "eth_requestAccounts" });
84
82
  console.log("accounts: ", e), console.log("provider.chainId: ", n.chainId);
85
83
  let r = parseInt(String(n.chainId ?? "0x0"), 16);
86
- u(e[0]), g(t), v(r), localStorage.setItem("miniwallet:lastWalletId", t);
84
+ l(e[0]), h(t), _(r), localStorage.setItem("miniwallet:lastWalletId", t);
87
85
  } catch (e) {
88
86
  console.log("error: ", e);
89
87
  let t = e, n = t?.code ?? "", r = t?.message ?? "";
@@ -93,101 +91,101 @@ function h({ children: e, chains: n = [] }) {
93
91
  }
94
92
  alert(`Connect failed${n && `\n${n}`}${r && `\n${r}`}`);
95
93
  }
96
- }, []), M = t(async () => {
94
+ }, [x]), A = t(async () => {
97
95
  try {
98
- if (!E || !h) {
96
+ if (!w || !m) {
99
97
  alert("请安装钱包");
100
98
  return;
101
99
  }
102
- h !== "okx" && await E.request({
100
+ m !== "okx" && await w.request({
103
101
  method: "wallet_revokePermissions",
104
102
  params: [{ eth_accounts: {} }]
105
103
  });
106
104
  } catch (e) {
107
105
  console.error("disconnect error: ", e);
108
106
  } finally {
109
- u(""), g(""), v(0), localStorage.removeItem("miniwallet:lastWalletId");
107
+ l(""), h(""), _(0), localStorage.removeItem("miniwallet:lastWalletId");
110
108
  }
111
- }, [E, h]), N = t(async (e) => {
112
- if (!E) {
109
+ }, [w, m]), j = t(async (e) => {
110
+ if (!w) {
113
111
  alert("钱包不存在");
114
112
  return;
115
113
  }
116
114
  try {
117
- await E.request({
115
+ await w.request({
118
116
  method: "wallet_switchEthereumChain",
119
117
  params: [{ chainId: `0x${e.id.toString(16)}` }]
120
- }), v(e.id);
118
+ }), _(e.id);
121
119
  } catch (e) {
122
120
  console.log("switchError: ", e);
123
121
  let t = e, n = t?.code ?? "", r = t?.message ?? "";
124
122
  alert(`Switch failed${n && `\n${n}`}${r && `\n${r}`}`);
125
123
  }
126
- }, [E]), P = t(async () => {
124
+ }, [w]), M = t(async () => {
127
125
  try {
128
- if (!c || !E) return;
129
- let e = await E.request({
126
+ if (!s || !w) return;
127
+ let e = await w.request({
130
128
  method: "eth_getBalance",
131
- params: [c, "latest"]
129
+ params: [s, "latest"]
132
130
  });
133
- b(BigInt(e).toString());
131
+ y(BigInt(e).toString());
134
132
  } catch (e) {
135
133
  console.error("getBalance error: ", e);
136
134
  }
137
- }, [c, E]), F = i(() => ({
138
- account: c,
139
- balance: A,
140
- isConnected: O,
141
- connectingWallet: x,
142
- selectedChain: k,
143
- wallet: D,
144
- chains: T,
145
- connect: j,
146
- switchChain: N,
147
- disconnect: M
135
+ }, [s, w]), N = i(() => ({
136
+ account: s,
137
+ balance: O,
138
+ isConnected: E,
139
+ connectingWallet: b,
140
+ selectedChain: D,
141
+ wallet: T,
142
+ chains: C,
143
+ connect: k,
144
+ switchChain: j,
145
+ disconnect: A
148
146
  }), [
149
- c,
150
- A,
147
+ s,
151
148
  O,
152
- x,
153
- k,
149
+ E,
150
+ b,
154
151
  D,
155
152
  T,
153
+ C,
154
+ k,
156
155
  j,
157
- N,
158
- M
156
+ A
159
157
  ]);
160
158
  return r(() => {
161
159
  let e = ((e) => {
162
- let { info: t, provider: n } = e.detail ?? {}, r = p[t?.rdns];
163
- !r || typeof n?.request != "function" || S.current[r] !== n && (S.current = {
164
- ...S.current,
160
+ let { info: t, provider: n } = e.detail ?? {}, r = f[t?.rdns];
161
+ !r || !n?.request || S((e) => e[r] === n ? e : {
162
+ ...e,
165
163
  [r]: n
166
- }, w((e) => e + 1));
164
+ });
167
165
  });
168
166
  return window.addEventListener("eip6963:announceProvider", e), window.dispatchEvent(new Event("eip6963:requestProvider")), () => {
169
- window.removeEventListener("eip6963:announceProvider", e);
167
+ window.removeEventListener("eip6963:announceProvider", e), S({});
170
168
  };
171
169
  }, []), r(() => {
172
- _ && P();
173
- }, [P, _]), r(() => {
174
- if (!O || !E?.on) return;
170
+ g && M();
171
+ }, [M, g]), r(() => {
172
+ if (!E || !w?.on) return;
175
173
  let e = (e) => {
176
- console.log("ChainChanged chainId: ", e), v(parseInt(e, 16));
174
+ console.log("ChainChanged chainId: ", e), _(parseInt(e, 16));
177
175
  }, t = (e) => {
178
- console.log("AccountsChanged accounts: ", e), u(e[0] ?? "");
176
+ console.log("AccountsChanged accounts: ", e), l(e[0] ?? "");
179
177
  };
180
- return console.log("Listen chainChanged and accountsChanged"), E.on("chainChanged", e), E.on("accountsChanged", t), () => {
181
- console.log("RemoveListener chainChanged and accountsChanged"), E.removeListener?.("chainChanged", e), E.removeListener?.("accountsChanged", t);
178
+ return console.log("Listen chainChanged and accountsChanged"), w.on("chainChanged", e), w.on("accountsChanged", t), () => {
179
+ console.log("RemoveListener chainChanged and accountsChanged"), w.removeListener("chainChanged", e), w.removeListener("accountsChanged", t);
182
180
  };
183
- }, [E, O]), r(() => {
184
- if (!c) return;
185
- let e = setInterval(P, 1e4);
181
+ }, [E, w]), r(() => {
182
+ if (!s) return;
183
+ let e = setInterval(M, 1e4);
186
184
  return () => clearInterval(e);
187
- }, [c, P]), r(() => {
185
+ }, [s, M]), r(() => {
188
186
  let e = localStorage.getItem("miniwallet:lastWalletId");
189
187
  if (!e) return;
190
- let t = S.current[e];
188
+ let t = x[e];
191
189
  if (!t) return;
192
190
  let n = !1;
193
191
  return (async () => {
@@ -197,30 +195,30 @@ function h({ children: e, chains: n = [] }) {
197
195
  localStorage.removeItem("miniwallet:lastWalletId");
198
196
  return;
199
197
  }
200
- u(r[0]), g(e), v(parseInt(String(t.chainId ?? "0x0"), 16));
198
+ l(r[0]), h(e), _(parseInt(t.chainId, 16));
201
199
  }
202
200
  })(), () => {
203
201
  n = !0;
204
202
  };
205
- }, [C]), /* @__PURE__ */ s(l.Provider, {
206
- value: F,
203
+ }, [x]), /* @__PURE__ */ o(c.Provider, {
204
+ value: N,
207
205
  children: e
208
206
  });
209
207
  }
210
208
  //#endregion
211
209
  //#region src/useMiniWallet.ts
212
- function g() {
213
- let e = n(l);
210
+ function h() {
211
+ let e = n(c);
214
212
  if (!e) throw Error("useMiniWallet 必须在 MiniWalletProvider 内使用");
215
213
  return e;
216
214
  }
217
215
  //#endregion
218
216
  //#region src/icons/disconnect.svg
219
- var _ = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1783575961451'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5071'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%3e%3cpath%20d='M512.922%2063.583c248.335%200%20449.712%20201.384%20449.712%20449.71%200%20248.333-201.377%20449.702-449.712%20449.702-248.333%200-449.71-201.369-449.71-449.702%200-248.326%20201.377-449.71%20449.71-449.71z%20m148.683%20213.634l-35.351%2061.247a206.8%20206.8%200%200%201%2034.37%2027.739c37.359%2037.351%2060.475%2088.96%2060.475%20145.955%200%2057.004-23.117%20108.607-60.475%20145.965-37.344%2037.352-88.945%2060.469-145.949%2060.469-56.987%200-108.606-23.117-145.965-60.469-37.359-37.359-60.461-88.962-60.461-145.965%200-56.995%2023.117-108.605%2060.461-145.955a209.04%20209.04%200%200%201%2027.762-23.286l-35.43-61.359a278.69%20278.69%200%200%200-42.279%2034.69c-50.156%2050.148-81.18%20119.417-81.18%20195.91%200%2076.504%2031.041%20145.773%2081.18%20195.929%2050.139%2050.139%20119.408%2081.166%20195.912%2081.166%2076.502%200%20145.771-31.026%20195.91-81.166%2050.156-50.156%2081.182-119.425%2081.182-195.929%200-76.494-31.026-145.763-81.182-195.91a277.704%20277.704%200%200%200-48.98-39.031zM473.618%20128.865v337.849h75.458V128.865h-75.458z'%20fill='%23e6523f'%20p-id='5072'%3e%3c/path%3e%3c/svg%3e";
217
+ var g = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1783575961451'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5071'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%3e%3cpath%20d='M512.922%2063.583c248.335%200%20449.712%20201.384%20449.712%20449.71%200%20248.333-201.377%20449.702-449.712%20449.702-248.333%200-449.71-201.369-449.71-449.702%200-248.326%20201.377-449.71%20449.71-449.71z%20m148.683%20213.634l-35.351%2061.247a206.8%20206.8%200%200%201%2034.37%2027.739c37.359%2037.351%2060.475%2088.96%2060.475%20145.955%200%2057.004-23.117%20108.607-60.475%20145.965-37.344%2037.352-88.945%2060.469-145.949%2060.469-56.987%200-108.606-23.117-145.965-60.469-37.359-37.359-60.461-88.962-60.461-145.965%200-56.995%2023.117-108.605%2060.461-145.955a209.04%20209.04%200%200%201%2027.762-23.286l-35.43-61.359a278.69%20278.69%200%200%200-42.279%2034.69c-50.156%2050.148-81.18%20119.417-81.18%20195.91%200%2076.504%2031.041%20145.773%2081.18%20195.929%2050.139%2050.139%20119.408%2081.166%20195.912%2081.166%2076.502%200%20145.771-31.026%20195.91-81.166%2050.156-50.156%2081.182-119.425%2081.182-195.929%200-76.494-31.026-145.763-81.182-195.91a277.704%20277.704%200%200%200-48.98-39.031zM473.618%20128.865v337.849h75.458V128.865h-75.458z'%20fill='%23e6523f'%20p-id='5072'%3e%3c/path%3e%3c/svg%3e";
220
218
  //#endregion
221
219
  //#region src/MiniWalletButton.tsx
222
- function v({ label: e = "Connect Wallet" }) {
223
- let { account: n, balance: a, isConnected: l, selectedChain: u, wallet: d, switchChain: p, chains: m, connect: h, disconnect: v } = g(), [y, b] = o(!1), [x, S] = o(!1), [C, w] = o("复制地址"), T = i(() => n ? `${n.slice(0, 6)}...${n.slice(-4)}` : "", [n]), E = t(() => {
220
+ function _({ label: e = "Connect Wallet" }) {
221
+ let { account: n, balance: c, isConnected: l, selectedChain: u, wallet: f, switchChain: p, chains: m, connect: _, disconnect: v } = h(), [y, b] = a(!1), [x, S] = a(!1), [C, w] = a("复制地址"), T = i(() => n ? `${n.slice(0, 6)}...${n.slice(-4)}` : "", [n]), E = t(() => {
224
222
  b(!0);
225
223
  }, []), D = t(() => {
226
224
  b(!1);
@@ -235,92 +233,92 @@ function v({ label: e = "Connect Wallet" }) {
235
233
  }, [n]);
236
234
  return r(() => {
237
235
  l && b(!1);
238
- }, [l]), l ? /* @__PURE__ */ c("section", {
236
+ }, [l]), l ? /* @__PURE__ */ s("section", {
239
237
  className: "inline-flex items-center justify-center text-center",
240
238
  children: [
241
- /* @__PURE__ */ s("select", {
239
+ /* @__PURE__ */ o("select", {
242
240
  value: u?.id,
243
241
  onChange: (e) => p(m.find((t) => t.id === Number(e.target.value))),
244
242
  className: "bg-transparent1 mr-4 cursor-pointer rounded-sm border-none p-1 text-gray-600 outline-none hover:bg-gray-100",
245
- children: m.map((e) => /* @__PURE__ */ s("option", {
243
+ children: m.map((e) => /* @__PURE__ */ o("option", {
246
244
  value: e.id,
247
245
  children: e.name
248
246
  }, e.id))
249
247
  }),
250
- /* @__PURE__ */ c("div", {
248
+ /* @__PURE__ */ s("div", {
251
249
  className: "flex items-center justify-center rounded-2xl bg-white pr-3 shadow-lg inset-ring-1 shadow-gray-200 inset-ring-gray-100",
252
- children: [/* @__PURE__ */ c("div", {
250
+ children: [/* @__PURE__ */ s("div", {
253
251
  onClick: () => {
254
252
  S(!0);
255
253
  },
256
254
  className: "flex cursor-pointer items-center justify-center space-x-2 rounded-l-2xl py-2.5 pr-1 pl-3 hover:bg-gray-50",
257
255
  children: [
258
- d && /* @__PURE__ */ s("img", {
259
- src: d.icon,
260
- alt: d.name,
256
+ f && /* @__PURE__ */ o("img", {
257
+ src: f.icon,
258
+ alt: f.name,
261
259
  className: "h-6 w-6"
262
260
  }),
263
- /* @__PURE__ */ s("div", {
261
+ /* @__PURE__ */ o("div", {
264
262
  className: "mr-1",
265
263
  children: T
266
264
  }),
267
- /* @__PURE__ */ c("span", {
265
+ /* @__PURE__ */ s("span", {
268
266
  className: "text-sm text-gray-400",
269
267
  children: [
270
268
  "(",
271
- a,
269
+ c,
272
270
  " ",
273
271
  u?.symbol ?? "",
274
272
  ")"
275
273
  ]
276
274
  })
277
275
  ]
278
- }), /* @__PURE__ */ s("button", {
276
+ }), /* @__PURE__ */ o("button", {
279
277
  className: "ml-1 h-6 w-6 cursor-pointer rounded-full",
280
278
  onClick: v,
281
- children: /* @__PURE__ */ s("img", {
282
- src: _,
279
+ children: /* @__PURE__ */ o("img", {
280
+ src: g,
283
281
  alt: "disconnect",
284
282
  className: "h-[22px] w-6"
285
283
  })
286
284
  })]
287
285
  }),
288
- x && /* @__PURE__ */ s("div", {
286
+ x && /* @__PURE__ */ o("div", {
289
287
  className: "z-index-10 fixed top-0 right-0 bottom-0 left-0 bg-[rgba(0,0,0,0.5)]",
290
- children: /* @__PURE__ */ c("div", {
288
+ children: /* @__PURE__ */ s("div", {
291
289
  className: "absolute top-1/2 left-1/2 flex h-auto w-[380px] -translate-x-1/2 -translate-y-1/2 flex-col items-center gap-3 rounded-3xl bg-white p-10 pt-5 text-center",
292
290
  children: [
293
- /* @__PURE__ */ s("div", {
291
+ /* @__PURE__ */ o("div", {
294
292
  className: "mb-[-12px] w-full text-right",
295
- children: /* @__PURE__ */ s("button", {
293
+ children: /* @__PURE__ */ o("button", {
296
294
  className: "mr-[-20px] cursor-pointer rounded-full p-1 hover:bg-gray-100",
297
295
  onClick: () => {
298
296
  S(!1);
299
297
  },
300
- children: /* @__PURE__ */ c("svg", {
298
+ children: /* @__PURE__ */ s("svg", {
301
299
  xmlns: "http://www.w3.org/2000/svg",
302
300
  viewBox: "0 0 24 24",
303
301
  fill: "none",
304
302
  stroke: "currentColor",
305
303
  strokeWidth: "2",
306
304
  className: "h-8 w-8",
307
- children: [/* @__PURE__ */ s("path", { d: "M18 6 6 18" }), /* @__PURE__ */ s("path", { d: "m6 6 12 12" })]
305
+ children: [/* @__PURE__ */ o("path", { d: "M18 6 6 18" }), /* @__PURE__ */ o("path", { d: "m6 6 12 12" })]
308
306
  })
309
307
  })
310
308
  }),
311
- d && /* @__PURE__ */ s("img", {
312
- src: d.icon,
313
- alt: d.name,
309
+ f && /* @__PURE__ */ o("img", {
310
+ src: f.icon,
311
+ alt: f.name,
314
312
  className: "h-16 w-16"
315
313
  }),
316
- /* @__PURE__ */ s("p", { children: T }),
317
- /* @__PURE__ */ c("div", {
314
+ /* @__PURE__ */ o("p", { children: T }),
315
+ /* @__PURE__ */ s("div", {
318
316
  className: "mt-2 w-full space-x-10",
319
- children: [/* @__PURE__ */ s("button", {
317
+ children: [/* @__PURE__ */ o("button", {
320
318
  onClick: O,
321
319
  className: "w-[112px] cursor-pointer rounded-xl bg-gray-700 py-2 text-white shadow-md shadow-gray-500/50 outline-none",
322
320
  children: C
323
- }), /* @__PURE__ */ s("button", {
321
+ }), /* @__PURE__ */ o("button", {
324
322
  type: "button",
325
323
  onClick: v,
326
324
  className: "w-[112px] cursor-pointer rounded-xl bg-red-400 py-2 text-white shadow-md shadow-red-500/50 outline-none",
@@ -331,48 +329,48 @@ function v({ label: e = "Connect Wallet" }) {
331
329
  })
332
330
  })
333
331
  ]
334
- }) : /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("button", {
332
+ }) : /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("button", {
335
333
  type: "button",
336
334
  onClick: E,
337
335
  className: "cursor-pointer rounded-xl bg-blue-500 px-4 py-2 text-white shadow-lg shadow-blue-500/50",
338
336
  children: e
339
- }), y && /* @__PURE__ */ s("div", {
337
+ }), y && /* @__PURE__ */ o("div", {
340
338
  className: "z-index-10 fixed top-0 right-0 bottom-0 left-0 bg-[rgba(0,0,0,0.5)]",
341
- children: /* @__PURE__ */ c("div", {
339
+ children: /* @__PURE__ */ s("div", {
342
340
  className: "absolute top-1/2 left-1/2 flex h-auto w-[380px] -translate-x-1/2 -translate-y-1/2 flex-col gap-3 rounded-3xl bg-white p-6",
343
- children: [/* @__PURE__ */ c("div", {
341
+ children: [/* @__PURE__ */ s("div", {
344
342
  className: "mb-2 flex items-center justify-between",
345
- children: [/* @__PURE__ */ s("span", {
343
+ children: [/* @__PURE__ */ o("span", {
346
344
  className: "text-2xl font-bold",
347
345
  children: "Connect Wallet"
348
- }), /* @__PURE__ */ s("button", {
346
+ }), /* @__PURE__ */ o("button", {
349
347
  type: "button",
350
348
  "aria-label": "Close",
351
349
  className: "cursor-pointer rounded-full p-1 hover:bg-gray-100",
352
350
  onClick: D,
353
- children: /* @__PURE__ */ c("svg", {
351
+ children: /* @__PURE__ */ s("svg", {
354
352
  xmlns: "http://www.w3.org/2000/svg",
355
353
  viewBox: "0 0 24 24",
356
354
  fill: "none",
357
355
  stroke: "currentColor",
358
356
  strokeWidth: "2",
359
357
  className: "h-8 w-8",
360
- children: [/* @__PURE__ */ s("path", { d: "M18 6 6 18" }), /* @__PURE__ */ s("path", { d: "m6 6 12 12" })]
358
+ children: [/* @__PURE__ */ o("path", { d: "M18 6 6 18" }), /* @__PURE__ */ o("path", { d: "m6 6 12 12" })]
361
359
  })
362
360
  })]
363
- }), /* @__PURE__ */ s("div", {
361
+ }), /* @__PURE__ */ o("div", {
364
362
  className: "relative w-full space-y-4",
365
- children: f.map((e) => /* @__PURE__ */ c("button", {
363
+ children: d.map((e) => /* @__PURE__ */ s("button", {
366
364
  type: "button",
367
- onClick: () => h(e),
365
+ onClick: () => _(e),
368
366
  className: "flex w-full cursor-pointer items-center gap-2 rounded-xl border border-gray-300 px-4 py-2 hover:bg-gray-100",
369
- children: [/* @__PURE__ */ s("img", {
367
+ children: [/* @__PURE__ */ o("img", {
370
368
  src: e.icon,
371
369
  alt: e.name,
372
370
  className: "h-8 w-8"
373
- }), /* @__PURE__ */ c("div", {
371
+ }), /* @__PURE__ */ s("div", {
374
372
  className: "flex flex-col justify-between text-left",
375
- children: [/* @__PURE__ */ s("p", { children: e.name }), /* @__PURE__ */ c("span", {
373
+ children: [/* @__PURE__ */ o("p", { children: e.name }), /* @__PURE__ */ s("span", {
376
374
  className: "text-xs text-gray-500",
377
375
  children: [
378
376
  "Connect your ",
@@ -387,4 +385,4 @@ function v({ label: e = "Connect Wallet" }) {
387
385
  })] });
388
386
  }
389
387
  //#endregion
390
- export { v as MiniWalletButton, h as MiniWalletProvider, g as useMiniWallet };
388
+ export { _ as MiniWalletButton, m as MiniWalletProvider, h as useMiniWallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miniwallet",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "React wallet connect button with multi-wallet support via EIP-6963",
5
5
  "type": "module",
6
6
  "main": "./dist/miniwallet.js",