@web3-react/gnosis-safe
Advanced tools
Comparing version 8.0.4-beta.0 to 8.0.5-beta.0
@@ -9,5 +9,12 @@ import type { SafeAppProvider } from '@gnosis.pm/safe-apps-provider'; | ||
} | ||
/** | ||
* @param options - Options to pass to `@gnosis.pm/safe-apps-sdk`. | ||
*/ | ||
export interface GnosisSafeConstructorArgs { | ||
actions: Actions; | ||
options?: Opts; | ||
} | ||
export declare class GnosisSafe extends Connector { | ||
/** {@inheritdoc Connector.provider} */ | ||
provider: SafeAppProvider | undefined; | ||
provider?: SafeAppProvider; | ||
private readonly options?; | ||
@@ -19,11 +26,10 @@ private eagerConnection?; | ||
sdk: SafeAppsSDK | undefined; | ||
constructor({ actions, options }: GnosisSafeConstructorArgs); | ||
/** | ||
* @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed. | ||
* @param options - Options to pass to `@gnosis.pm/safe-apps-sdk`. | ||
* A function to determine whether or not this code is executing on a server. | ||
*/ | ||
constructor({ actions, connectEagerly, options, }: { | ||
actions: Actions; | ||
connectEagerly?: boolean; | ||
options?: Opts; | ||
}); | ||
private get serverSide(); | ||
/** | ||
* A function to determine whether or not this code is executing in an iframe. | ||
*/ | ||
private get inIframe(); | ||
@@ -30,0 +36,0 @@ private isomorphicInitialize; |
@@ -46,16 +46,15 @@ "use strict"; | ||
class GnosisSafe extends types_1.Connector { | ||
/** | ||
* @param connectEagerly - A flag indicating whether connection should be initiated when the class is constructed. | ||
* @param options - Options to pass to `@gnosis.pm/safe-apps-sdk`. | ||
*/ | ||
constructor({ actions, connectEagerly = false, options, }) { | ||
constructor({ actions, options }) { | ||
super(actions); | ||
if (connectEagerly && this.serverSide) { | ||
throw new Error('connectEagerly = true is invalid for SSR, instead use the connectEagerly method in a useEffect'); | ||
} | ||
this.options = options; | ||
if (connectEagerly) | ||
void this.connectEagerly(); | ||
} | ||
// check if we're in an iframe | ||
/** | ||
* A function to determine whether or not this code is executing on a server. | ||
*/ | ||
get serverSide() { | ||
return typeof window === 'undefined'; | ||
} | ||
/** | ||
* A function to determine whether or not this code is executing in an iframe. | ||
*/ | ||
get inIframe() { | ||
@@ -71,3 +70,3 @@ if (this.serverSide) | ||
if (this.eagerConnection) | ||
return this.eagerConnection; | ||
return; | ||
// kick off import early to minimize waterfalls | ||
@@ -94,6 +93,6 @@ const SafeAppProviderPromise = Promise.resolve().then(() => __importStar(require('@gnosis.pm/safe-apps-provider'))).then(({ SafeAppProvider }) => SafeAppProvider); | ||
const cancelActivation = this.actions.startActivation(); | ||
yield this.isomorphicInitialize(); | ||
if (!this.provider) | ||
return cancelActivation(); | ||
try { | ||
yield this.isomorphicInitialize(); | ||
if (!this.provider) | ||
throw new NoSafeContext(); | ||
this.actions.update({ | ||
@@ -106,4 +105,4 @@ chainId: this.provider.chainId, | ||
catch (error) { | ||
console.debug('Could not connect eagerly', error); | ||
cancelActivation(); | ||
throw error; | ||
} | ||
@@ -114,13 +113,12 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.inIframe) { | ||
if (!this.inIframe) | ||
throw new NoSafeContext(); | ||
} | ||
// only show activation if this is a first-time connection | ||
let cancelActivation; | ||
if (!this.sdk) | ||
this.actions.startActivation(); | ||
yield this.isomorphicInitialize(); | ||
if (!this.provider) { | ||
throw new NoSafeContext(); | ||
} | ||
try { | ||
cancelActivation = this.actions.startActivation(); | ||
return this.isomorphicInitialize() | ||
.then(() => __awaiter(this, void 0, void 0, function* () { | ||
if (!this.provider) | ||
throw new NoSafeContext(); | ||
this.actions.update({ | ||
@@ -131,7 +129,7 @@ chainId: this.provider.chainId, | ||
}); | ||
} | ||
catch (error) { | ||
this.actions.resetState(); | ||
})) | ||
.catch((error) => { | ||
cancelActivation === null || cancelActivation === void 0 ? void 0 : cancelActivation(); | ||
throw error; | ||
} | ||
}); | ||
}); | ||
@@ -138,0 +136,0 @@ } |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "8.0.4-beta.0", | ||
"version": "8.0.5-beta.0", | ||
"files": [ | ||
@@ -30,5 +30,5 @@ "dist/*" | ||
"@gnosis.pm/safe-apps-sdk": "^7.3.0", | ||
"@web3-react/types": "^8.0.18-beta.0" | ||
"@web3-react/types": "^8.0.19-beta.0" | ||
}, | ||
"gitHead": "b497295f7f4aeecf86845551e8fd0ee53d27d202" | ||
"gitHead": "9a5d6207c54457de7081755d5d69e5bd7c9fda31" | ||
} |
170
42944