miniwallet 0.1.4 → 0.1.6

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 +8 -10
  2. package/package.json +1 -1
@@ -79,11 +79,11 @@ function m({ children: e, chains: n = [] }) {
79
79
  alert("请安装钱包");
80
80
  return;
81
81
  }
82
- h(t), x(e), console.log("provider: ", n);
82
+ x(e), console.log("provider: ", n);
83
83
  let r = await n.request({ method: "eth_requestAccounts" });
84
84
  console.log("accounts: ", r), console.log("provider.chainId: ", n.chainId);
85
85
  let i = parseInt(n.chainId, 16);
86
- l(r[0]), _(i), localStorage.setItem("miniwallet:lastWalletId", t), x(null);
86
+ l(r[0]), h(t), _(i), localStorage.setItem("miniwallet:lastWalletId", t), x(null);
87
87
  } catch (e) {
88
88
  console.log("error: ", e);
89
89
  let t = e, n = t?.code ?? "", r = t?.message ?? "";
@@ -91,17 +91,15 @@ function m({ children: e, chains: n = [] }) {
91
91
  alert("连接已发起,请在扩展中确认连接");
92
92
  return;
93
93
  }
94
- alert(`Connect failed${n && `\n${n}`}${r && `\n${r}`}`);
95
- } finally {
96
- x(null);
94
+ alert(`Connect failed${n && `\n${n}`}${r && `\n${r}`}`), x(null);
97
95
  }
98
96
  }, [S]), j = t(async () => {
99
97
  try {
100
- if (!T) {
98
+ if (!T || !m) {
101
99
  alert("请安装钱包");
102
100
  return;
103
101
  }
104
- await T.request({
102
+ m !== "okx" && await T.request({
105
103
  method: "wallet_revokePermissions",
106
104
  params: [{ eth_accounts: {} }]
107
105
  });
@@ -110,7 +108,7 @@ function m({ children: e, chains: n = [] }) {
110
108
  } finally {
111
109
  l(""), h(""), _(0), localStorage.removeItem("miniwallet:lastWalletId");
112
110
  }
113
- }, [T]), M = t(async (e) => {
111
+ }, [T, m]), M = t(async (e) => {
114
112
  if (!T) {
115
113
  alert("钱包不存在");
116
114
  return;
@@ -173,7 +171,7 @@ function m({ children: e, chains: n = [] }) {
173
171
  }, []), r(() => {
174
172
  g && N();
175
173
  }, [N, g]), r(() => {
176
- if (!T?.on) return;
174
+ if (!D || !T?.on) return;
177
175
  let e = (e) => {
178
176
  console.log("ChainChanged chainId: ", e), _(parseInt(e, 16));
179
177
  }, t = (e) => {
@@ -182,7 +180,7 @@ function m({ children: e, chains: n = [] }) {
182
180
  return console.log("Listen chainChanged and accountsChanged"), T.on("chainChanged", e), T.on("accountsChanged", t), () => {
183
181
  console.log("RemoveListener chainChanged and accountsChanged"), T.removeListener("chainChanged", e), T.removeListener("accountsChanged", t);
184
182
  };
185
- }, [T]), r(() => {
183
+ }, [T, D]), r(() => {
186
184
  if (!s) return;
187
185
  let e = setInterval(N, 1e4);
188
186
  return () => clearInterval(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miniwallet",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "React wallet connect button with multi-wallet support via EIP-6963",
5
5
  "type": "module",
6
6
  "main": "./dist/miniwallet.js",