Fixed browser provider
This commit is contained in:
parent
b9f891644d
commit
901281a59d
18
dist/index.js
vendored
18
dist/index.js
vendored
@ -477,19 +477,19 @@ class TornadoBrowserProvider extends ethers.BrowserProvider {
|
||||
}
|
||||
getSigner(address) {
|
||||
return __async$g(this, null, function* () {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
||||
const signerAddress = (yield __superGet$2(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
||||
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$2(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
||||
yield this.options.connectWallet();
|
||||
if (((_a = this.options) == null ? void 0 : _a.netId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$2(TornadoBrowserProvider.prototype, this, "send").call(this, "net_version", [])) !== ((_c = this.options) == null ? void 0 : _c.netId)) {
|
||||
yield this.options.connectWallet((_d = this.options) == null ? void 0 : _d.netId);
|
||||
}
|
||||
if ((_d = this.options) == null ? void 0 : _d.handleNetworkChanges) {
|
||||
(_e = window == null ? void 0 : window.ethereum) == null ? void 0 : _e.on("chainChanged", this.options.handleNetworkChanges);
|
||||
if ((_e = this.options) == null ? void 0 : _e.handleNetworkChanges) {
|
||||
(_f = window == null ? void 0 : window.ethereum) == null ? void 0 : _f.on("chainChanged", this.options.handleNetworkChanges);
|
||||
}
|
||||
if ((_f = this.options) == null ? void 0 : _f.handleAccountChanges) {
|
||||
(_g = window == null ? void 0 : window.ethereum) == null ? void 0 : _g.on("accountsChanged", this.options.handleAccountChanges);
|
||||
if ((_g = this.options) == null ? void 0 : _g.handleAccountChanges) {
|
||||
(_h = window == null ? void 0 : window.ethereum) == null ? void 0 : _h.on("accountsChanged", this.options.handleAccountChanges);
|
||||
}
|
||||
if ((_h = this.options) == null ? void 0 : _h.handleAccountDisconnect) {
|
||||
(_i = window == null ? void 0 : window.ethereum) == null ? void 0 : _i.on("disconnect", this.options.handleAccountDisconnect);
|
||||
if ((_i = this.options) == null ? void 0 : _i.handleAccountDisconnect) {
|
||||
(_j = window == null ? void 0 : window.ethereum) == null ? void 0 : _j.on("disconnect", this.options.handleAccountDisconnect);
|
||||
}
|
||||
return new TornadoRpcSigner(this, signerAddress, this.options);
|
||||
});
|
||||
|
18
dist/index.mjs
vendored
18
dist/index.mjs
vendored
@ -456,19 +456,19 @@ class TornadoBrowserProvider extends BrowserProvider {
|
||||
}
|
||||
getSigner(address) {
|
||||
return __async$g(this, null, function* () {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
||||
const signerAddress = (yield __superGet$2(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
||||
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$2(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
||||
yield this.options.connectWallet();
|
||||
if (((_a = this.options) == null ? void 0 : _a.netId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$2(TornadoBrowserProvider.prototype, this, "send").call(this, "net_version", [])) !== ((_c = this.options) == null ? void 0 : _c.netId)) {
|
||||
yield this.options.connectWallet((_d = this.options) == null ? void 0 : _d.netId);
|
||||
}
|
||||
if ((_d = this.options) == null ? void 0 : _d.handleNetworkChanges) {
|
||||
(_e = window == null ? void 0 : window.ethereum) == null ? void 0 : _e.on("chainChanged", this.options.handleNetworkChanges);
|
||||
if ((_e = this.options) == null ? void 0 : _e.handleNetworkChanges) {
|
||||
(_f = window == null ? void 0 : window.ethereum) == null ? void 0 : _f.on("chainChanged", this.options.handleNetworkChanges);
|
||||
}
|
||||
if ((_f = this.options) == null ? void 0 : _f.handleAccountChanges) {
|
||||
(_g = window == null ? void 0 : window.ethereum) == null ? void 0 : _g.on("accountsChanged", this.options.handleAccountChanges);
|
||||
if ((_g = this.options) == null ? void 0 : _g.handleAccountChanges) {
|
||||
(_h = window == null ? void 0 : window.ethereum) == null ? void 0 : _h.on("accountsChanged", this.options.handleAccountChanges);
|
||||
}
|
||||
if ((_h = this.options) == null ? void 0 : _h.handleAccountDisconnect) {
|
||||
(_i = window == null ? void 0 : window.ethereum) == null ? void 0 : _i.on("disconnect", this.options.handleAccountDisconnect);
|
||||
if ((_i = this.options) == null ? void 0 : _i.handleAccountDisconnect) {
|
||||
(_j = window == null ? void 0 : window.ethereum) == null ? void 0 : _j.on("disconnect", this.options.handleAccountDisconnect);
|
||||
}
|
||||
return new TornadoRpcSigner(this, signerAddress, this.options);
|
||||
});
|
||||
|
2
dist/providers.d.ts
vendored
2
dist/providers.d.ts
vendored
@ -75,7 +75,7 @@ export declare class TornadoRpcSigner extends JsonRpcSigner {
|
||||
export type connectWalletFunc = (...args: any[]) => Promise<void>;
|
||||
export type handleWalletFunc = (...args: any[]) => void;
|
||||
export type TornadoBrowserProviderOptions = TornadoWalletOptions & {
|
||||
webChainId?: NetIdType;
|
||||
netId?: NetIdType;
|
||||
connectWallet?: connectWalletFunc;
|
||||
handleNetworkChanges?: handleWalletFunc;
|
||||
handleAccountChanges?: handleWalletFunc;
|
||||
|
18
dist/tornado.umd.js
vendored
18
dist/tornado.umd.js
vendored
@ -72330,19 +72330,19 @@ class TornadoBrowserProvider extends BrowserProvider {
|
||||
}
|
||||
getSigner(address) {
|
||||
return __async(this, null, function* () {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
||||
const signerAddress = (yield __superGet(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
||||
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
||||
yield this.options.connectWallet();
|
||||
if (((_a = this.options) == null ? void 0 : _a.netId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet(TornadoBrowserProvider.prototype, this, "send").call(this, "net_version", [])) !== ((_c = this.options) == null ? void 0 : _c.netId)) {
|
||||
yield this.options.connectWallet((_d = this.options) == null ? void 0 : _d.netId);
|
||||
}
|
||||
if ((_d = this.options) == null ? void 0 : _d.handleNetworkChanges) {
|
||||
(_e = window == null ? void 0 : window.ethereum) == null ? void 0 : _e.on("chainChanged", this.options.handleNetworkChanges);
|
||||
if ((_e = this.options) == null ? void 0 : _e.handleNetworkChanges) {
|
||||
(_f = window == null ? void 0 : window.ethereum) == null ? void 0 : _f.on("chainChanged", this.options.handleNetworkChanges);
|
||||
}
|
||||
if ((_f = this.options) == null ? void 0 : _f.handleAccountChanges) {
|
||||
(_g = window == null ? void 0 : window.ethereum) == null ? void 0 : _g.on("accountsChanged", this.options.handleAccountChanges);
|
||||
if ((_g = this.options) == null ? void 0 : _g.handleAccountChanges) {
|
||||
(_h = window == null ? void 0 : window.ethereum) == null ? void 0 : _h.on("accountsChanged", this.options.handleAccountChanges);
|
||||
}
|
||||
if ((_h = this.options) == null ? void 0 : _h.handleAccountDisconnect) {
|
||||
(_i = window == null ? void 0 : window.ethereum) == null ? void 0 : _i.on("disconnect", this.options.handleAccountDisconnect);
|
||||
if ((_i = this.options) == null ? void 0 : _i.handleAccountDisconnect) {
|
||||
(_j = window == null ? void 0 : window.ethereum) == null ? void 0 : _j.on("disconnect", this.options.handleAccountDisconnect);
|
||||
}
|
||||
return new TornadoRpcSigner(this, signerAddress, this.options);
|
||||
});
|
||||
|
2
dist/tornado.umd.min.js
vendored
2
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -475,7 +475,7 @@ export type handleWalletFunc = (...args: any[]) => void;
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
|
||||
export type TornadoBrowserProviderOptions = TornadoWalletOptions & {
|
||||
webChainId?: NetIdType;
|
||||
netId?: NetIdType;
|
||||
connectWallet?: connectWalletFunc;
|
||||
handleNetworkChanges?: handleWalletFunc;
|
||||
handleAccountChanges?: handleWalletFunc;
|
||||
@ -493,11 +493,11 @@ export class TornadoBrowserProvider extends BrowserProvider {
|
||||
const signerAddress = (await super.getSigner(address)).address;
|
||||
|
||||
if (
|
||||
this.options?.webChainId &&
|
||||
this.options?.netId &&
|
||||
this.options?.connectWallet &&
|
||||
Number(await super.send('eth_chainId', [])) !== Number(this.options?.webChainId)
|
||||
Number(await super.send('net_version', [])) !== this.options?.netId
|
||||
) {
|
||||
await this.options.connectWallet();
|
||||
await this.options.connectWallet(this.options?.netId);
|
||||
}
|
||||
|
||||
if (this.options?.handleNetworkChanges) {
|
||||
|
Loading…
Reference in New Issue
Block a user