@reef-knot/wallet-adapter-safe 1.0.0 → 1.2.0
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/_virtual/_tslib.js +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -14
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
16
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
27
|
+
var e = new Error(message);
|
|
28
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { __awaiter };
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,eAAO,MAAM,EAAE,SAAS,CAAC;AACzB,eAAO,MAAM,IAAI,SAAS,CAAC;AAE3B,eAAO,MAAM,IAAI,EAAE,iBAoClB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
+
import { __awaiter } from './_virtual/_tslib.js';
|
|
1
2
|
import { SafeConnector } from 'wagmi/connectors/safe';
|
|
2
3
|
|
|
4
|
+
const id = 'safe';
|
|
5
|
+
const name = 'Safe';
|
|
3
6
|
const Safe = ({
|
|
4
7
|
chains
|
|
5
|
-
}) =>
|
|
6
|
-
|
|
7
|
-
walletId: 'safe',
|
|
8
|
-
autoConnectOnly: true,
|
|
9
|
-
detector: () => {
|
|
10
|
-
// iframe check
|
|
11
|
-
// A more precise check will occur during SafeConnector connection.
|
|
12
|
-
return globalThis.window && globalThis.window.parent !== globalThis.window;
|
|
13
|
-
},
|
|
14
|
-
connector: new SafeConnector({
|
|
8
|
+
}) => {
|
|
9
|
+
const safeConnector = new SafeConnector({
|
|
15
10
|
chains,
|
|
16
11
|
options: {
|
|
17
|
-
allowedDomains: [/
|
|
12
|
+
allowedDomains: [/app.safe.global$/, /holesky-safe.protofire.io$/],
|
|
18
13
|
debug: false
|
|
19
14
|
}
|
|
20
|
-
})
|
|
21
|
-
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
walletName: name,
|
|
18
|
+
walletId: id,
|
|
19
|
+
autoConnectOnly: true,
|
|
20
|
+
detector: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
// If opened in an iframe. This is an important check for Safe.
|
|
22
|
+
// The updated wagmi SafeConnector already has this check, but the currently used SafeConnector for wagmi 0.x hasn't.
|
|
23
|
+
if (globalThis.window && globalThis.window.parent !== globalThis.window) {
|
|
24
|
+
// The Promise.race is needed to handle regular iframes, not related to Safe,
|
|
25
|
+
// because in such iframes Safe SDK Promises can get stuck without resolving,
|
|
26
|
+
// so we are using a small timeout for them.
|
|
27
|
+
return Promise.race([new Promise(resolve => {
|
|
28
|
+
safeConnector.getProvider().then(() => resolve(true)).catch(() => resolve(false));
|
|
29
|
+
}), new Promise(resolve => {
|
|
30
|
+
setTimeout(() => resolve(false), 200);
|
|
31
|
+
})]);
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}),
|
|
35
|
+
connector: safeConnector
|
|
36
|
+
};
|
|
37
|
+
};
|
|
22
38
|
|
|
23
|
-
export { Safe };
|
|
39
|
+
export { Safe, id, name };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reef-knot/wallet-adapter-safe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"lint": "eslint --ext ts,tsx,js,mjs ."
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@reef-knot/types": "^1.
|
|
35
|
+
"@reef-knot/types": "^1.7.0",
|
|
36
36
|
"@svgr/rollup": "^6.5.1",
|
|
37
37
|
"eslint-config-custom": "*"
|
|
38
38
|
},
|