@wagmi/connectors 5.0.2 → 5.0.3

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.
@@ -1,2 +1,2 @@
1
- export const version = '5.0.2';
1
+ export const version = '5.0.3';
2
2
  //# sourceMappingURL=version.js.map
@@ -11,6 +11,13 @@ export type SafeParameters = Evaluate<Opts & {
11
11
  * @default false
12
12
  */
13
13
  shimDisconnect?: boolean | undefined;
14
+ /**
15
+ * Timeout in milliseconds for `getInfo` (from the Safe SDK) to resolve.
16
+ *
17
+ * `getInfo` does not resolve when not used in Safe App iFrame. This allows the connector to force a timeout.
18
+ * @default 10
19
+ */
20
+ unstable_getInfoTimeout?: number | undefined;
14
21
  }>;
15
22
  export declare function safe(parameters?: SafeParameters): import("@wagmi/core").CreateConnectorFn<SafeAppProvider | undefined, {}, {
16
23
  'safe.disconnected': true;
@@ -1 +1 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAMtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAGpD,MAAM,MAAM,cAAc,GAAG,QAAQ,CACnC,IAAI,GAAG;IACL;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACrC,CACF,CAAA;AAGD,wBAAgB,IAAI,CAAC,UAAU,GAAE,cAAmB;yBAKR,IAAI;GAwG/C;yBA7Ge,IAAI"}
1
+ {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAMtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAGpD,MAAM,MAAM,cAAc,GAAG,QAAQ,CACnC,IAAI,GAAG;IACL;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACpC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7C,CACF,CAAA;AAGD,wBAAgB,IAAI,CAAC,UAAU,GAAE,cAAmB;yBAKR,IAAI;GA4G/C;yBAjHe,IAAI"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.0.2";
1
+ export declare const version = "5.0.3";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wagmi/connectors",
3
3
  "description": "Collection of connectors for Wagmi",
4
- "version": "5.0.2",
4
+ "version": "5.0.3",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "peerDependencies": {
31
31
  "typescript": ">=5.0.4",
32
32
  "viem": "2.x",
33
- "@wagmi/core": "2.10.2"
33
+ "@wagmi/core": "2.10.3"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "typescript": {
package/src/safe.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  createConnector,
7
7
  } from '@wagmi/core'
8
8
  import type { Evaluate } from '@wagmi/core/internal'
9
- import { getAddress } from 'viem'
9
+ import { getAddress, withTimeout } from 'viem'
10
10
 
11
11
  export type SafeParameters = Evaluate<
12
12
  Opts & {
@@ -19,6 +19,13 @@ export type SafeParameters = Evaluate<
19
19
  * @default false
20
20
  */
21
21
  shimDisconnect?: boolean | undefined
22
+ /**
23
+ * Timeout in milliseconds for `getInfo` (from the Safe SDK) to resolve.
24
+ *
25
+ * `getInfo` does not resolve when not used in Safe App iFrame. This allows the connector to force a timeout.
26
+ * @default 10
27
+ */
28
+ unstable_getInfoTimeout?: number | undefined
22
29
  }
23
30
  >
24
31
 
@@ -94,7 +101,11 @@ export function safe(parameters: SafeParameters = {}) {
94
101
  else SDK = SafeAppsSDK as unknown as typeof SafeAppsSDK.default
95
102
  const sdk = new SDK(parameters)
96
103
 
97
- const safe = await sdk.safe.getInfo()
104
+ // `getInfo` hangs when not used in Safe App iFrame
105
+ // https://github.com/safe-global/safe-apps-sdk/issues/263#issuecomment-1029835840
106
+ const safe = await withTimeout(() => sdk.safe.getInfo(), {
107
+ timeout: parameters.unstable_getInfoTimeout ?? 10,
108
+ })
98
109
  if (!safe) throw new Error('Could not load Safe information')
99
110
  const { SafeAppProvider } = await import(
100
111
  '@safe-global/safe-apps-provider'
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '5.0.2'
1
+ export const version = '5.0.3'