@reef-knot/wallet-adapter-safe 5.1.1 → 5.2.0-alpha.1
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.
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WalletAdapterType } from "@reef-knot/wallets-helpers";
|
|
2
|
+
//#region src/index.d.ts
|
|
2
3
|
export declare const id = "safe";
|
|
3
4
|
export declare const name = "Safe";
|
|
4
5
|
export declare const SAFE_DEFAULT_ALLOWED_DOMAINS: readonly RegExp[];
|
|
5
6
|
export declare const getSafeAllowedDomains: (allowedDomains?: readonly RegExp[]) => RegExp[];
|
|
6
7
|
export declare const Safe: WalletAdapterType;
|
|
8
|
+
//#endregion
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;qBAIa;qBACA;qBAMA,uCAAuC;qBAKvC,wBAAqB,0BACP,aACxB;qBAQU,MAAM"}
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,8 @@ const Safe = ({ safeAllowedDomains }) => ({
|
|
|
19
19
|
try {
|
|
20
20
|
const { default: SafeAppsSDK } = await import("@safe-global/safe-apps-sdk");
|
|
21
21
|
let SDK;
|
|
22
|
-
|
|
22
|
+
const wrappedSDK = SafeAppsSDK;
|
|
23
|
+
if (typeof SafeAppsSDK !== "function" && typeof wrappedSDK.default === "function") SDK = wrappedSDK.default;
|
|
23
24
|
else SDK = SafeAppsSDK;
|
|
24
25
|
const parameters = { allowedDomains: getSafeAllowedDomains(safeAllowedDomains) };
|
|
25
26
|
const sdk = new SDK(parameters);
|
|
@@ -35,3 +36,5 @@ const Safe = ({ safeAllowedDomains }) => ({
|
|
|
35
36
|
});
|
|
36
37
|
//#endregion
|
|
37
38
|
export { SAFE_DEFAULT_ALLOWED_DOMAINS, Safe, getSafeAllowedDomains, id, name };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { safe } from 'wagmi/connectors';\nimport { withTimeout } from 'viem';\nimport type { WalletAdapterType } from '@reef-knot/wallets-helpers';\n\nexport const id = 'safe';\nexport const name = 'Safe';\n\ntype GetSafeConnectorArgs = {\n allowedDomains?: RegExp[];\n};\n\nexport const SAFE_DEFAULT_ALLOWED_DOMAINS: readonly RegExp[] = [\n /^https:\\/\\/app\\.safe\\.global$/,\n /^https:\\/\\/app\\.safe\\.protofire\\.io$/,\n];\n\nexport const getSafeAllowedDomains = (\n allowedDomains: readonly RegExp[] = [],\n): RegExp[] => [...SAFE_DEFAULT_ALLOWED_DOMAINS, ...allowedDomains];\n\nconst getSafeConnector = ({ allowedDomains }: GetSafeConnectorArgs) =>\n safe({\n allowedDomains: getSafeAllowedDomains(allowedDomains),\n debug: false,\n });\n\nexport const Safe: WalletAdapterType = ({ safeAllowedDomains }) => ({\n walletName: name,\n walletId: id,\n type: safe.type,\n autoConnectOnly: true,\n detector: async (): Promise<boolean> => {\n // We cannot longer use `safeConnector.getProvider()` directly\n // because in the current wagmi version it must be initialized\n // with `wagmi/createConfig/setup` otherewise the `getProvider` method is not accessible.\n // https://github.com/wevm/wagmi/blob/fa5864bfb3ebfb0dc147b35003152a17a785ade6/packages/core/src/createConfig.ts#L96-L111\n //\n // We also do not use wagmi config here because we prefer to create a connection on flight\n // when the connect button is clicked. This approach helps us to avoid connector collisions\n // that appear in wagmi sometimes when it has multiple injected connectors in the config list\n // which leading to some bugs detected during manual ui tests.\n //\n // So, with that being said, as we do not have an access to `safeConnector.getProvider`\n // we forced to copy an implementation from its original source to implement a wallet detector:\n // https://github.com/wevm/wagmi/blob/fa5864bfb3ebfb0dc147b35003152a17a785ade6/packages/connectors/src/safe.ts#L85-L116\n\n const isIframe =\n globalThis.window && globalThis.window?.parent !== globalThis.window;\n\n if (!isIframe) return false;\n\n try {\n // It is a dependency of @wagmi/connectors\n\n const { default: SafeAppsSDK } =\n await import('@safe-global/safe-apps-sdk');\n\n let SDK: typeof SafeAppsSDK;\n // The package can expose a nested default export under CommonJS interop.\n const wrappedSDK = SafeAppsSDK as unknown as {\n default?: typeof SafeAppsSDK;\n };\n if (\n typeof SafeAppsSDK !== 'function' &&\n typeof wrappedSDK.default === 'function'\n ) {\n SDK = wrappedSDK.default;\n } else {\n SDK = SafeAppsSDK;\n }\n const parameters: ConstructorParameters<typeof SafeAppsSDK>[0] = {\n allowedDomains: getSafeAllowedDomains(safeAllowedDomains),\n };\n const sdk = new SDK(parameters);\n\n // `getInfo` hangs when not used in Safe App iFrame\n // https://github.com/safe-global/safe-apps-sdk/issues/263#issuecomment-1029835840\n const safeSdk = await withTimeout(() => sdk.safe.getInfo(), {\n timeout: 200,\n });\n if (!safeSdk) return false;\n\n // It is a dependency of @wagmi/connectors\n\n const { SafeAppProvider } =\n await import('@safe-global/safe-apps-provider');\n const provider = new SafeAppProvider(safeSdk, sdk);\n return !!provider;\n } catch {\n return false;\n }\n },\n createConnectorFn: getSafeConnector({\n allowedDomains: safeAllowedDomains,\n }),\n});\n"],"mappings":";;;AAIA,MAAa,KAAK;AAClB,MAAa,OAAO;AAMpB,MAAa,+BAAkD,CAC7D,iCACA,sCACF;AAEA,MAAa,yBACX,iBAAoC,CAAC,MACxB,CAAC,GAAG,8BAA8B,GAAG,cAAc;AAElE,MAAM,oBAAoB,EAAE,qBAC1B,KAAK;CACH,gBAAgB,sBAAsB,cAAc;CACpD,OAAO;AACT,CAAC;AAEH,MAAa,QAA2B,EAAE,0BAA0B;CAClE,YAAY;CACZ,UAAU;CACV,MAAM,KAAK;CACX,iBAAiB;CACjB,UAAU,YAA8B;EAkBtC,IAAI,EAFF,WAAW,UAAU,WAAW,QAAQ,WAAW,WAAW,SAEjD,OAAO;EAEtB,IAAI;GAGF,MAAM,EAAE,SAAS,gBACf,MAAM,OAAO;GAEf,IAAI;GAEJ,MAAM,aAAa;GAGnB,IACE,OAAO,gBAAgB,cACvB,OAAO,WAAW,YAAY,YAE9B,MAAM,WAAW;QAEjB,MAAM;GAER,MAAM,aAA2D,EAC/D,gBAAgB,sBAAsB,kBAAkB,EAC1D;GACA,MAAM,MAAM,IAAI,IAAI,UAAU;GAI9B,MAAM,UAAU,MAAM,kBAAkB,IAAI,KAAK,QAAQ,GAAG,EAC1D,SAAS,IACX,CAAC;GACD,IAAI,CAAC,SAAS,OAAO;GAIrB,MAAM,EAAE,oBACN,MAAM,OAAO;GAEf,OAAO,CAAC,CAAC,IADY,gBAAgB,SAAS,GAC9B;EAClB,QAAQ;GACN,OAAO;EACT;CACF;CACA,mBAAmB,iBAAiB,EAClC,gBAAgB,mBAClB,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/wallet-adapter-safe",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0-alpha.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,21 +34,20 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "yarn run -T tsdown",
|
|
36
36
|
"dev": "yarn run -T tsdown --watch",
|
|
37
|
-
"lint": "
|
|
37
|
+
"lint": "yarn run -T eslint .",
|
|
38
38
|
"test": "vitest run",
|
|
39
|
-
"typecheck": "tsc --noEmit"
|
|
39
|
+
"typecheck": "yarn run -T tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@reef-knot/
|
|
42
|
+
"@reef-knot/wallets-helpers": "3.2.0-alpha.1",
|
|
43
43
|
"@safe-global/safe-apps-provider": "^0.18.6",
|
|
44
44
|
"@safe-global/safe-apps-sdk": "^9.1.0",
|
|
45
45
|
"build-config": "*",
|
|
46
|
-
"eslint-config-custom": "*",
|
|
47
46
|
"happy-dom": "^20.0.0",
|
|
48
47
|
"vitest": "^4.1.11"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
|
-
"@reef-knot/
|
|
50
|
+
"@reef-knot/wallets-helpers": "3.2.0-alpha.1",
|
|
52
51
|
"@safe-global/safe-apps-provider": "^0.18.6",
|
|
53
52
|
"@safe-global/safe-apps-sdk": "^9.1.0",
|
|
54
53
|
"@tanstack/react-query": "^5.29.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allowedDomains.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/allowedDomains.test.ts"],"names":[],"mappings":""}
|