feat: lazy-load safe only if iframed (#7360)
This commit is contained in:
parent
d73c368ee4
commit
b9fc65ec9a
15
patches/@web3-react+gnosis-safe+8.2.3.patch
Normal file
15
patches/@web3-react+gnosis-safe+8.2.3.patch
Normal file
@ -0,0 +1,15 @@
|
||||
diff --git a/node_modules/@web3-react/gnosis-safe/dist/index.js b/node_modules/@web3-react/gnosis-safe/dist/index.js
|
||||
index 015a33c..4cd7cde 100644
|
||||
--- a/node_modules/@web3-react/gnosis-safe/dist/index.js
|
||||
+++ b/node_modules/@web3-react/gnosis-safe/dist/index.js
|
||||
@@ -68,8 +68,8 @@ class GnosisSafe extends types_1.Connector {
|
||||
if (this.eagerConnection)
|
||||
return;
|
||||
// kick off import early to minimize waterfalls
|
||||
- const SafeAppProviderPromise = Promise.resolve().then(() => __importStar(require('@safe-global/safe-apps-provider'))).then(({ SafeAppProvider }) => SafeAppProvider);
|
||||
- yield (this.eagerConnection = Promise.resolve().then(() => __importStar(require('@safe-global/safe-apps-sdk'))).then((m) => __awaiter(this, void 0, void 0, function* () {
|
||||
+ const SafeAppProviderPromise = Promise.resolve().then(async () => __importStar(await import('@safe-global/safe-apps-provider'))).then(({ SafeAppProvider }) => SafeAppProvider);
|
||||
+ yield (this.eagerConnection = Promise.resolve().then(async () => __importStar(await import('@safe-global/safe-apps-sdk'))).then((m) => __awaiter(this, void 0, void 0, function* () {
|
||||
this.sdk = new m.default(this.options);
|
||||
const safe = yield Promise.race([
|
||||
this.sdk.safe.getInfo(),
|
@ -20,8 +20,14 @@ async function connect(connector: Connector, type: ConnectionType) {
|
||||
}
|
||||
}
|
||||
|
||||
// The Safe connector will only work from safe.global, which iframes;
|
||||
// it is only necessary to try (and to load all the deps) if we are in an iframe.
|
||||
if (window !== window.parent) {
|
||||
connect(gnosisSafeConnection.connector, ConnectionType.GNOSIS_SAFE)
|
||||
}
|
||||
|
||||
connect(networkConnection.connector, ConnectionType.NETWORK)
|
||||
|
||||
const selectedWallet = toConnectionType(localStorage.getItem(selectedWalletKey) ?? undefined)
|
||||
if (selectedWallet) {
|
||||
const selectedConnection = getConnection(selectedWallet)
|
||||
|
Loading…
Reference in New Issue
Block a user