Commit b9fc65ec authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

feat: lazy-load safe only if iframed (#7360)

parent d73c368e
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) { ...@@ -20,8 +20,14 @@ async function connect(connector: Connector, type: ConnectionType) {
} }
} }
connect(gnosisSafeConnection.connector, ConnectionType.GNOSIS_SAFE) // 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) connect(networkConnection.connector, ConnectionType.NETWORK)
const selectedWallet = toConnectionType(localStorage.getItem(selectedWalletKey) ?? undefined) const selectedWallet = toConnectionType(localStorage.getItem(selectedWalletKey) ?? undefined)
if (selectedWallet) { if (selectedWallet) {
const selectedConnection = getConnection(selectedWallet) const selectedConnection = getConnection(selectedWallet)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment