@reef-knot/wallet-adapter-safe 4.2.1 → 5.0.0-alpha.2
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.js +36 -71
- package/package.json +15 -10
- package/dist/_virtual/_tslib.js +0 -33
package/dist/index.js
CHANGED
|
@@ -1,75 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { withTimeout } from 'viem';
|
|
1
|
+
import { safe } from "wagmi/connectors";
|
|
2
|
+
import { withTimeout } from "viem";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const id = "safe";
|
|
6
|
+
const name = "Safe";
|
|
7
|
+
const getSafeConnector = ({ allowedDomains = [] }) => safe({
|
|
8
|
+
allowedDomains: [
|
|
9
|
+
/app.safe.global$/,
|
|
10
|
+
/app.safe.protofire.io$/,
|
|
11
|
+
...allowedDomains
|
|
12
|
+
],
|
|
13
|
+
debug: false
|
|
12
14
|
});
|
|
13
|
-
const Safe = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const isIframe = globalThis.window && ((_a = globalThis.window) === null || _a === void 0 ? void 0 : _a.parent) !== globalThis.window;
|
|
36
|
-
if (!isIframe) return false;
|
|
37
|
-
try {
|
|
38
|
-
// It is a dependency of @wagmi/connectors
|
|
39
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
40
|
-
const {
|
|
41
|
-
default: SafeAppsSDK
|
|
42
|
-
} = yield import('@safe-global/safe-apps-sdk');
|
|
43
|
-
let SDK;
|
|
44
|
-
if (typeof SafeAppsSDK !== 'function' && typeof SafeAppsSDK.default === 'function') {
|
|
45
|
-
SDK = SafeAppsSDK.default;
|
|
46
|
-
} else {
|
|
47
|
-
SDK = SafeAppsSDK;
|
|
48
|
-
}
|
|
49
|
-
const parameters = {
|
|
50
|
-
allowedDomains: safeAllowedDomains
|
|
51
|
-
};
|
|
52
|
-
const sdk = new SDK(parameters);
|
|
53
|
-
// `getInfo` hangs when not used in Safe App iFrame
|
|
54
|
-
// https://github.com/safe-global/safe-apps-sdk/issues/263#issuecomment-1029835840
|
|
55
|
-
const safeSdk = yield withTimeout(() => sdk.safe.getInfo(), {
|
|
56
|
-
timeout: 200
|
|
57
|
-
});
|
|
58
|
-
if (!safeSdk) return false;
|
|
59
|
-
// It is a dependency of @wagmi/connectors
|
|
60
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
61
|
-
const {
|
|
62
|
-
SafeAppProvider
|
|
63
|
-
} = yield import('@safe-global/safe-apps-provider');
|
|
64
|
-
const provider = new SafeAppProvider(safeSdk, sdk);
|
|
65
|
-
return !!provider;
|
|
66
|
-
} catch (_b) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
createConnectorFn: getSafeConnector({
|
|
71
|
-
allowedDomains: safeAllowedDomains
|
|
72
|
-
})
|
|
15
|
+
const Safe = ({ safeAllowedDomains }) => ({
|
|
16
|
+
walletName: name,
|
|
17
|
+
walletId: id,
|
|
18
|
+
type: safe.type,
|
|
19
|
+
autoConnectOnly: true,
|
|
20
|
+
detector: async () => {
|
|
21
|
+
if (!(globalThis.window && globalThis.window?.parent !== globalThis.window)) return false;
|
|
22
|
+
try {
|
|
23
|
+
const { default: SafeAppsSDK } = await import("@safe-global/safe-apps-sdk");
|
|
24
|
+
let SDK;
|
|
25
|
+
if (typeof SafeAppsSDK !== "function" && typeof SafeAppsSDK.default === "function") SDK = SafeAppsSDK.default;
|
|
26
|
+
else SDK = SafeAppsSDK;
|
|
27
|
+
const sdk = new SDK({ allowedDomains: safeAllowedDomains });
|
|
28
|
+
const safeSdk = await withTimeout(() => sdk.safe.getInfo(), { timeout: 200 });
|
|
29
|
+
if (!safeSdk) return false;
|
|
30
|
+
const { SafeAppProvider } = await import("@safe-global/safe-apps-provider");
|
|
31
|
+
return !!new SafeAppProvider(safeSdk, sdk);
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
createConnectorFn: getSafeConnector({ allowedDomains: safeAllowedDomains })
|
|
73
37
|
});
|
|
74
38
|
|
|
75
|
-
|
|
39
|
+
//#endregion
|
|
40
|
+
export { Safe, id, name };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/wallet-adapter-safe",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/lidofinance/reef-knot.git",
|
|
27
|
+
"url": "git+https://github.com/lidofinance/reef-knot.git",
|
|
28
28
|
"directory": "packages/wallets/safe"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
@@ -32,19 +32,24 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"dev": "
|
|
37
|
-
"lint": "eslint --ext ts,tsx,js,mjs ."
|
|
35
|
+
"build": "yarn run -T tsdown",
|
|
36
|
+
"dev": "yarn run -T tsdown --watch",
|
|
37
|
+
"lint": "eslint --ext ts,tsx,js,mjs .",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@reef-knot/types": "
|
|
41
|
-
"@
|
|
41
|
+
"@reef-knot/types": "5.0.0-alpha.2",
|
|
42
|
+
"@safe-global/safe-apps-provider": "^0.18.6",
|
|
43
|
+
"@safe-global/safe-apps-sdk": "^9.1.0",
|
|
44
|
+
"build-config": "*",
|
|
42
45
|
"eslint-config-custom": "*"
|
|
43
46
|
},
|
|
44
47
|
"peerDependencies": {
|
|
45
|
-
"@reef-knot/types": "
|
|
48
|
+
"@reef-knot/types": "5.0.0-alpha.2",
|
|
49
|
+
"@safe-global/safe-apps-provider": "^0.18.6",
|
|
50
|
+
"@safe-global/safe-apps-sdk": "^9.1.0",
|
|
46
51
|
"@tanstack/react-query": "^5.29.0",
|
|
47
|
-
"viem": ">=2.
|
|
48
|
-
"wagmi": ">=
|
|
52
|
+
"viem": ">=2.44",
|
|
53
|
+
"wagmi": ">=3.3"
|
|
49
54
|
}
|
|
50
55
|
}
|
package/dist/_virtual/_tslib.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
19
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
21
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
23
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
29
|
-
var e = new Error(message);
|
|
30
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { __awaiter };
|