@dynamic-labs/midnight 4.77.3 → 4.77.4
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/CHANGELOG.md +16 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -4
- package/src/MidnightProviderHelper/MidnightProviderHelper.cjs +111 -0
- package/src/MidnightProviderHelper/MidnightProviderHelper.d.ts +37 -0
- package/src/MidnightProviderHelper/MidnightProviderHelper.js +107 -0
- package/src/MidnightProviderHelper/index.d.ts +1 -0
- package/src/connectors/MidnightWalletConnector.cjs +20 -0
- package/src/connectors/MidnightWalletConnector.d.ts +15 -0
- package/src/connectors/MidnightWalletConnector.js +16 -0
- package/src/connectors/index.d.ts +1 -0
- package/src/constants.cjs +2 -0
- package/src/constants.d.ts +1 -0
- package/src/constants.js +2 -1
- package/src/index.cjs +16 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +8 -1
- package/src/injected/InjectedWalletBase/InjectedWalletBase.cjs +67 -0
- package/src/injected/InjectedWalletBase/InjectedWalletBase.d.ts +17 -0
- package/src/injected/InjectedWalletBase/InjectedWalletBase.js +63 -0
- package/src/injected/InjectedWalletBase/index.d.ts +1 -0
- package/src/injected/Midnight1am/Midnight1am.cjs +16 -0
- package/src/injected/Midnight1am/Midnight1am.d.ts +5 -0
- package/src/injected/Midnight1am/Midnight1am.js +12 -0
- package/src/injected/Midnight1am/index.d.ts +1 -0
- package/src/injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.cjs +26 -0
- package/src/injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.d.ts +7 -0
- package/src/injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.js +21 -0
- package/src/injected/fetchInjectedWalletConnectors/index.d.ts +1 -0
- package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs +25 -0
- package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.d.ts +3 -0
- package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js +21 -0
- package/src/utils/getConnectorConstructorInjectedWallet/index.d.ts +1 -0
- package/src/wallet/MidnightWallet.cjs +18 -0
- package/src/wallet/MidnightWallet.d.ts +12 -0
- package/src/wallet/MidnightWallet.js +14 -0
- package/src/wallet/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.77.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.77.3...v4.77.4) (2026-04-21)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **sdk-react-core:** log ui.fallback_error_shown when generic error surfaces ([#10972](https://github.com/dynamic-labs/dynamic-auth/issues/10972)) ([7aee5d1](https://github.com/dynamic-labs/dynamic-auth/commit/7aee5d1a518121742a6ffcc3d3e1101d70b1cc29))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* Add SSR-safe defaults to CaptchaContext ([#10977](https://github.com/dynamic-labs/dynamic-auth/issues/10977)) ([bdf4e80](https://github.com/dynamic-labs/dynamic-auth/commit/bdf4e809c0fd6382961d7b079dbdde25678ecbb1))
|
|
13
|
+
* **DYNT-400:** update Trust Wallet flag from isTrustWallet to isTrust ([#10917](https://github.com/dynamic-labs/dynamic-auth/issues/10917)) ([1ca616a](https://github.com/dynamic-labs/dynamic-auth/commit/1ca616a926ce35d5a75e4611049ef0a05b96865d))
|
|
14
|
+
* lower retry count for viem calls ([#10984](https://github.com/dynamic-labs/dynamic-auth/issues/10984)) ([37843df](https://github.com/dynamic-labs/dynamic-auth/commit/37843dffb2bf31bdc0d7f3e91b65656e3af745f9))
|
|
15
|
+
* show correct loading view when new view is selected ([#10981](https://github.com/dynamic-labs/dynamic-auth/issues/10981)) ([eb650a4](https://github.com/dynamic-labs/dynamic-auth/commit/eb650a4ba62cf12c03f03bfa0866fdc3d30503a1))
|
|
16
|
+
* **wagmi-connector:** promote onAccountsChanged log to instrument for backend visibility DYNT-549 ([#10982](https://github.com/dynamic-labs/dynamic-auth/issues/10982)) ([5087227](https://github.com/dynamic-labs/dynamic-auth/commit/508722724a049737da49fd0320e97d19f6249fce))
|
|
17
|
+
|
|
2
18
|
### [4.77.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.77.2...v4.77.3) (2026-04-18)
|
|
3
19
|
|
|
4
20
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
+
var e = new Error(message);
|
|
33
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
28
|
+
var e = new Error(message);
|
|
29
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { __awaiter };
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/midnight",
|
|
3
|
-
"version": "4.77.
|
|
3
|
+
"version": "4.77.4",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.77.
|
|
22
|
-
"@midnight-ntwrk/dapp-connector-api": "4.0.1"
|
|
23
|
-
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.77.4",
|
|
22
|
+
"@midnight-ntwrk/dapp-connector-api": "4.0.1",
|
|
23
|
+
"@dynamic-labs/utils": "4.77.4",
|
|
24
|
+
"@dynamic-labs/wallet-book": "4.77.4",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "4.77.4"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {}
|
|
24
28
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
var constants = require('../constants.cjs');
|
|
11
|
+
|
|
12
|
+
class MidnightProviderHelper {
|
|
13
|
+
constructor(connector) {
|
|
14
|
+
this._connectionGeneration = 0;
|
|
15
|
+
this.walletBookWallet = walletBook.findWalletBookWallet(connector.walletBook, connector.key);
|
|
16
|
+
this.connector = connector;
|
|
17
|
+
}
|
|
18
|
+
getInjectedConfig() {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
return (_b = (_a = this.walletBookWallet) === null || _a === void 0 ? void 0 : _a.injectedConfig) === null || _b === void 0 ? void 0 : _b.find((c) => c.chain === constants.MIDNIGHT_CHAIN);
|
|
21
|
+
}
|
|
22
|
+
getInstalledProvider() {
|
|
23
|
+
var _a;
|
|
24
|
+
const config = this.getInjectedConfig();
|
|
25
|
+
if (!((_a = config === null || config === void 0 ? void 0 : config.windowLocations) === null || _a === void 0 ? void 0 : _a.length))
|
|
26
|
+
return undefined;
|
|
27
|
+
for (const windowLocation of config.windowLocations) {
|
|
28
|
+
const [provider] = utils.getProvidersFromWindow(windowLocation);
|
|
29
|
+
if (provider)
|
|
30
|
+
return provider;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
isInstalledHelper() {
|
|
35
|
+
return this.getInstalledProvider() !== undefined;
|
|
36
|
+
}
|
|
37
|
+
getConnectedAPI() {
|
|
38
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (this._connectedAPI)
|
|
40
|
+
return this._connectedAPI;
|
|
41
|
+
if (this._connectPromise)
|
|
42
|
+
return this._connectPromise;
|
|
43
|
+
const initialProvider = this.getInstalledProvider();
|
|
44
|
+
if (!initialProvider)
|
|
45
|
+
return undefined;
|
|
46
|
+
const generation = this._connectionGeneration;
|
|
47
|
+
this._connectPromise = initialProvider
|
|
48
|
+
.connect(this.connector.networkId)
|
|
49
|
+
.then((api) => {
|
|
50
|
+
if (this._connectionGeneration === generation) {
|
|
51
|
+
this._connectedAPI = api;
|
|
52
|
+
}
|
|
53
|
+
return this._connectedAPI;
|
|
54
|
+
})
|
|
55
|
+
.catch((err) => {
|
|
56
|
+
walletConnectorCore.logger.error('[MidnightProviderHelper] getConnectedAPI - Error connecting to wallet', err);
|
|
57
|
+
return undefined;
|
|
58
|
+
})
|
|
59
|
+
.finally(() => {
|
|
60
|
+
this._connectPromise = undefined;
|
|
61
|
+
});
|
|
62
|
+
return this._connectPromise;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
getAddress() {
|
|
66
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const api = yield this.getConnectedAPI();
|
|
68
|
+
if (!api)
|
|
69
|
+
return undefined;
|
|
70
|
+
const { unshieldedAddress } = yield api.getUnshieldedAddress();
|
|
71
|
+
return unshieldedAddress;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getAddressIfConnected() {
|
|
75
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (!this._connectedAPI)
|
|
77
|
+
return undefined;
|
|
78
|
+
const { unshieldedAddress } = yield this._connectedAPI.getUnshieldedAddress();
|
|
79
|
+
return unshieldedAddress;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
signMessage(messageToSign) {
|
|
83
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const api = yield this.getConnectedAPI();
|
|
85
|
+
if (!api)
|
|
86
|
+
return undefined;
|
|
87
|
+
const { signature } = yield api.signData(messageToSign, {
|
|
88
|
+
encoding: 'text',
|
|
89
|
+
keyType: 'unshielded',
|
|
90
|
+
});
|
|
91
|
+
return signature;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
disconnect() {
|
|
95
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
this._connectionGeneration++;
|
|
97
|
+
this._connectedAPI = undefined;
|
|
98
|
+
this._connectPromise = undefined;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// Midnight ConnectedAPI does not expose event listeners.
|
|
102
|
+
// Connection status can be checked via getConnectionStatus() if polling is needed.
|
|
103
|
+
_setupEventListeners() {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
_teardownEventListeners() {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
exports.MidnightProviderHelper = MidnightProviderHelper;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ConnectedAPI, InitialAPI } from '@midnight-ntwrk/dapp-connector-api';
|
|
2
|
+
import type { InjectedWalletBase } from '../injected/InjectedWalletBase/InjectedWalletBase';
|
|
3
|
+
export declare class MidnightProviderHelper {
|
|
4
|
+
private walletBookWallet;
|
|
5
|
+
private connector;
|
|
6
|
+
private _connectedAPI;
|
|
7
|
+
private _connectPromise;
|
|
8
|
+
private _connectionGeneration;
|
|
9
|
+
constructor(connector: InjectedWalletBase);
|
|
10
|
+
getInjectedConfig(): {
|
|
11
|
+
chain: string;
|
|
12
|
+
extensionLocators: {
|
|
13
|
+
flag: string;
|
|
14
|
+
value: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
providerInterface?: string | undefined;
|
|
17
|
+
walletStandard?: {
|
|
18
|
+
features: string[];
|
|
19
|
+
name: string;
|
|
20
|
+
providerId?: string | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
walletStandardLocators?: {
|
|
23
|
+
locator: string;
|
|
24
|
+
name: string;
|
|
25
|
+
}[] | undefined;
|
|
26
|
+
windowLocations?: string[] | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
getInstalledProvider(): InitialAPI | undefined;
|
|
29
|
+
isInstalledHelper(): boolean;
|
|
30
|
+
getConnectedAPI(): Promise<ConnectedAPI | undefined>;
|
|
31
|
+
getAddress(): Promise<string | undefined>;
|
|
32
|
+
getAddressIfConnected(): Promise<string | undefined>;
|
|
33
|
+
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
34
|
+
disconnect(): Promise<void>;
|
|
35
|
+
_setupEventListeners(): void;
|
|
36
|
+
_teardownEventListeners(): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { getProvidersFromWindow } from '@dynamic-labs/utils';
|
|
4
|
+
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import { MIDNIGHT_CHAIN } from '../constants.js';
|
|
7
|
+
|
|
8
|
+
class MidnightProviderHelper {
|
|
9
|
+
constructor(connector) {
|
|
10
|
+
this._connectionGeneration = 0;
|
|
11
|
+
this.walletBookWallet = findWalletBookWallet(connector.walletBook, connector.key);
|
|
12
|
+
this.connector = connector;
|
|
13
|
+
}
|
|
14
|
+
getInjectedConfig() {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
return (_b = (_a = this.walletBookWallet) === null || _a === void 0 ? void 0 : _a.injectedConfig) === null || _b === void 0 ? void 0 : _b.find((c) => c.chain === MIDNIGHT_CHAIN);
|
|
17
|
+
}
|
|
18
|
+
getInstalledProvider() {
|
|
19
|
+
var _a;
|
|
20
|
+
const config = this.getInjectedConfig();
|
|
21
|
+
if (!((_a = config === null || config === void 0 ? void 0 : config.windowLocations) === null || _a === void 0 ? void 0 : _a.length))
|
|
22
|
+
return undefined;
|
|
23
|
+
for (const windowLocation of config.windowLocations) {
|
|
24
|
+
const [provider] = getProvidersFromWindow(windowLocation);
|
|
25
|
+
if (provider)
|
|
26
|
+
return provider;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
isInstalledHelper() {
|
|
31
|
+
return this.getInstalledProvider() !== undefined;
|
|
32
|
+
}
|
|
33
|
+
getConnectedAPI() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (this._connectedAPI)
|
|
36
|
+
return this._connectedAPI;
|
|
37
|
+
if (this._connectPromise)
|
|
38
|
+
return this._connectPromise;
|
|
39
|
+
const initialProvider = this.getInstalledProvider();
|
|
40
|
+
if (!initialProvider)
|
|
41
|
+
return undefined;
|
|
42
|
+
const generation = this._connectionGeneration;
|
|
43
|
+
this._connectPromise = initialProvider
|
|
44
|
+
.connect(this.connector.networkId)
|
|
45
|
+
.then((api) => {
|
|
46
|
+
if (this._connectionGeneration === generation) {
|
|
47
|
+
this._connectedAPI = api;
|
|
48
|
+
}
|
|
49
|
+
return this._connectedAPI;
|
|
50
|
+
})
|
|
51
|
+
.catch((err) => {
|
|
52
|
+
logger.error('[MidnightProviderHelper] getConnectedAPI - Error connecting to wallet', err);
|
|
53
|
+
return undefined;
|
|
54
|
+
})
|
|
55
|
+
.finally(() => {
|
|
56
|
+
this._connectPromise = undefined;
|
|
57
|
+
});
|
|
58
|
+
return this._connectPromise;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
getAddress() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const api = yield this.getConnectedAPI();
|
|
64
|
+
if (!api)
|
|
65
|
+
return undefined;
|
|
66
|
+
const { unshieldedAddress } = yield api.getUnshieldedAddress();
|
|
67
|
+
return unshieldedAddress;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getAddressIfConnected() {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
if (!this._connectedAPI)
|
|
73
|
+
return undefined;
|
|
74
|
+
const { unshieldedAddress } = yield this._connectedAPI.getUnshieldedAddress();
|
|
75
|
+
return unshieldedAddress;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
signMessage(messageToSign) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const api = yield this.getConnectedAPI();
|
|
81
|
+
if (!api)
|
|
82
|
+
return undefined;
|
|
83
|
+
const { signature } = yield api.signData(messageToSign, {
|
|
84
|
+
encoding: 'text',
|
|
85
|
+
keyType: 'unshielded',
|
|
86
|
+
});
|
|
87
|
+
return signature;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
disconnect() {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
this._connectionGeneration++;
|
|
93
|
+
this._connectedAPI = undefined;
|
|
94
|
+
this._connectPromise = undefined;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Midnight ConnectedAPI does not expose event listeners.
|
|
98
|
+
// Connection status can be checked via getConnectionStatus() if polling is needed.
|
|
99
|
+
_setupEventListeners() {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
_teardownEventListeners() {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { MidnightProviderHelper };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MidnightProviderHelper';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
+
var MidnightWallet = require('../wallet/MidnightWallet.cjs');
|
|
8
|
+
|
|
9
|
+
class MidnightWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
var _a;
|
|
12
|
+
super(opts);
|
|
13
|
+
this.ChainWallet = MidnightWallet.MidnightWallet;
|
|
14
|
+
this.connectedChain = 'MIDNIGHT';
|
|
15
|
+
this.supportedChains = ['MIDNIGHT'];
|
|
16
|
+
this.networkId = (_a = opts.networkId) !== null && _a !== void 0 ? _a : 'mainnet';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.MidnightWalletConnector = MidnightWalletConnector;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Chain, WalletConnectorBase, WalletMetadata } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { MidnightWallet } from '../wallet/MidnightWallet';
|
|
4
|
+
export type MidnightWalletConnectorOpts = {
|
|
5
|
+
walletBook: WalletBookSchema;
|
|
6
|
+
metadata?: WalletMetadata;
|
|
7
|
+
networkId?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare abstract class MidnightWalletConnector extends WalletConnectorBase<typeof MidnightWallet> {
|
|
10
|
+
ChainWallet: typeof MidnightWallet;
|
|
11
|
+
connectedChain: Chain;
|
|
12
|
+
supportedChains: Chain[];
|
|
13
|
+
networkId: string;
|
|
14
|
+
constructor(opts: MidnightWalletConnectorOpts);
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { MidnightWallet } from '../wallet/MidnightWallet.js';
|
|
4
|
+
|
|
5
|
+
class MidnightWalletConnector extends WalletConnectorBase {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
var _a;
|
|
8
|
+
super(opts);
|
|
9
|
+
this.ChainWallet = MidnightWallet;
|
|
10
|
+
this.connectedChain = 'MIDNIGHT';
|
|
11
|
+
this.supportedChains = ['MIDNIGHT'];
|
|
12
|
+
this.networkId = (_a = opts.networkId) !== null && _a !== void 0 ? _a : 'mainnet';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { MidnightWalletConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MidnightWalletConnector';
|
package/src/constants.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
const MIDNIGHT_CHAIN = 'midnight';
|
|
6
7
|
/**
|
|
7
8
|
* Midnight blockchain network identifiers.
|
|
8
9
|
* mainnet = 0, testnet = 1 (mirrors the chainId mapping).
|
|
@@ -12,4 +13,5 @@ const MIDNIGHT_NETWORKS = {
|
|
|
12
13
|
TESTNET: 'midnight:testnet',
|
|
13
14
|
};
|
|
14
15
|
|
|
16
|
+
exports.MIDNIGHT_CHAIN = MIDNIGHT_CHAIN;
|
|
15
17
|
exports.MIDNIGHT_NETWORKS = MIDNIGHT_NETWORKS;
|
package/src/constants.d.ts
CHANGED
package/src/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
const MIDNIGHT_CHAIN = 'midnight';
|
|
2
3
|
/**
|
|
3
4
|
* Midnight blockchain network identifiers.
|
|
4
5
|
* mainnet = 0, testnet = 1 (mirrors the chainId mapping).
|
|
@@ -8,4 +9,4 @@ const MIDNIGHT_NETWORKS = {
|
|
|
8
9
|
TESTNET: 'midnight:testnet',
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
export { MIDNIGHT_NETWORKS };
|
|
12
|
+
export { MIDNIGHT_CHAIN, MIDNIGHT_NETWORKS };
|
package/src/index.cjs
CHANGED
|
@@ -5,8 +5,24 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
7
|
var _package = require('../package.cjs');
|
|
8
|
+
var MidnightWalletConnector = require('./connectors/MidnightWalletConnector.cjs');
|
|
9
|
+
var MidnightWallet = require('./wallet/MidnightWallet.cjs');
|
|
10
|
+
var MidnightProviderHelper = require('./MidnightProviderHelper/MidnightProviderHelper.cjs');
|
|
11
|
+
var InjectedWalletBase = require('./injected/InjectedWalletBase/InjectedWalletBase.cjs');
|
|
12
|
+
var Midnight1am = require('./injected/Midnight1am/Midnight1am.cjs');
|
|
13
|
+
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.cjs');
|
|
14
|
+
var getConnectorConstructorInjectedWallet = require('./utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs');
|
|
8
15
|
var constants = require('./constants.cjs');
|
|
9
16
|
|
|
10
17
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/midnight', _package.version);
|
|
11
18
|
|
|
19
|
+
exports.MidnightWalletConnector = MidnightWalletConnector.MidnightWalletConnector;
|
|
20
|
+
exports.MidnightWallet = MidnightWallet.MidnightWallet;
|
|
21
|
+
exports.MidnightProviderHelper = MidnightProviderHelper.MidnightProviderHelper;
|
|
22
|
+
exports.InjectedWalletBase = InjectedWalletBase.InjectedWalletBase;
|
|
23
|
+
exports.Midnight1am = Midnight1am.Midnight1am;
|
|
24
|
+
exports.fetchInjectedWalletConnectors = fetchInjectedWalletConnectors.fetchInjectedWalletConnectors;
|
|
25
|
+
exports.injectedWalletOverrides = fetchInjectedWalletConnectors.injectedWalletOverrides;
|
|
26
|
+
exports.getConnectorConstructorInjectedWallet = getConnectorConstructorInjectedWallet.getConnectorConstructorInjectedWallet;
|
|
27
|
+
exports.MIDNIGHT_CHAIN = constants.MIDNIGHT_CHAIN;
|
|
12
28
|
exports.MIDNIGHT_NETWORKS = constants.MIDNIGHT_NETWORKS;
|
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
export * from './connectors';
|
|
2
|
+
export * from './wallet';
|
|
3
|
+
export * from './MidnightProviderHelper';
|
|
4
|
+
export * from './injected/InjectedWalletBase';
|
|
5
|
+
export * from './injected/Midnight1am';
|
|
6
|
+
export * from './injected/fetchInjectedWalletConnectors';
|
|
7
|
+
export * from './utils/getConnectorConstructorInjectedWallet';
|
|
1
8
|
export * from './constants';
|
|
2
9
|
export * from './types';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
3
|
import { version } from '../package.js';
|
|
4
|
-
export {
|
|
4
|
+
export { MidnightWalletConnector } from './connectors/MidnightWalletConnector.js';
|
|
5
|
+
export { MidnightWallet } from './wallet/MidnightWallet.js';
|
|
6
|
+
export { MidnightProviderHelper } from './MidnightProviderHelper/MidnightProviderHelper.js';
|
|
7
|
+
export { InjectedWalletBase } from './injected/InjectedWalletBase/InjectedWalletBase.js';
|
|
8
|
+
export { Midnight1am } from './injected/Midnight1am/Midnight1am.js';
|
|
9
|
+
export { fetchInjectedWalletConnectors, injectedWalletOverrides } from './injected/fetchInjectedWalletConnectors/fetchInjectedWalletConnectors.js';
|
|
10
|
+
export { getConnectorConstructorInjectedWallet } from './utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js';
|
|
11
|
+
export { MIDNIGHT_CHAIN, MIDNIGHT_NETWORKS } from './constants.js';
|
|
5
12
|
|
|
6
13
|
assertPackageVersion('@dynamic-labs/midnight', version);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var MidnightWalletConnector = require('../../connectors/MidnightWalletConnector.cjs');
|
|
8
|
+
var MidnightProviderHelper = require('../../MidnightProviderHelper/MidnightProviderHelper.cjs');
|
|
9
|
+
|
|
10
|
+
class InjectedWalletBase extends MidnightWalletConnector.MidnightWalletConnector {
|
|
11
|
+
get midnightProviderHelper() {
|
|
12
|
+
if (!this._midnightProviderHelper) {
|
|
13
|
+
this._midnightProviderHelper = new MidnightProviderHelper.MidnightProviderHelper(this);
|
|
14
|
+
}
|
|
15
|
+
return this._midnightProviderHelper;
|
|
16
|
+
}
|
|
17
|
+
findProvider() {
|
|
18
|
+
return this.midnightProviderHelper.getInstalledProvider();
|
|
19
|
+
}
|
|
20
|
+
isInstalledOnBrowser() {
|
|
21
|
+
return this.midnightProviderHelper.isInstalledHelper();
|
|
22
|
+
}
|
|
23
|
+
connect() {
|
|
24
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
yield this.midnightProviderHelper.getConnectedAPI();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getAddress() {
|
|
29
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
|
|
31
|
+
if (didOpenInAppBrowser)
|
|
32
|
+
return undefined;
|
|
33
|
+
return this.midnightProviderHelper.getAddress();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
signMessage(messageToSign) {
|
|
37
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
return this.midnightProviderHelper.signMessage(messageToSign);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
proveOwnership(address, messageToSign) {
|
|
42
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
yield this.validateActiveWallet(address);
|
|
44
|
+
return this.signMessage(messageToSign);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
setupEventListeners() {
|
|
48
|
+
this.midnightProviderHelper._setupEventListeners();
|
|
49
|
+
}
|
|
50
|
+
teardownEventListeners() {
|
|
51
|
+
this.midnightProviderHelper._teardownEventListeners();
|
|
52
|
+
}
|
|
53
|
+
endSession() {
|
|
54
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
yield this.midnightProviderHelper.disconnect();
|
|
56
|
+
this.teardownEventListeners();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getConnectedAccounts() {
|
|
60
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const address = yield this.midnightProviderHelper.getAddressIfConnected();
|
|
62
|
+
return address ? [address] : [];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
exports.InjectedWalletBase = InjectedWalletBase;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { InitialAPI } from '@midnight-ntwrk/dapp-connector-api';
|
|
2
|
+
import { MidnightWalletConnector } from '../../connectors/MidnightWalletConnector';
|
|
3
|
+
import { MidnightProviderHelper } from '../../MidnightProviderHelper/MidnightProviderHelper';
|
|
4
|
+
export declare abstract class InjectedWalletBase extends MidnightWalletConnector {
|
|
5
|
+
_midnightProviderHelper: MidnightProviderHelper | undefined;
|
|
6
|
+
get midnightProviderHelper(): MidnightProviderHelper;
|
|
7
|
+
findProvider(): InitialAPI | undefined;
|
|
8
|
+
isInstalledOnBrowser(): boolean;
|
|
9
|
+
connect(): Promise<void>;
|
|
10
|
+
getAddress(): Promise<string | undefined>;
|
|
11
|
+
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
12
|
+
proveOwnership(address: string, messageToSign: string): Promise<string | undefined>;
|
|
13
|
+
setupEventListeners(): void;
|
|
14
|
+
teardownEventListeners(): void;
|
|
15
|
+
endSession(): Promise<void>;
|
|
16
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { MidnightWalletConnector } from '../../connectors/MidnightWalletConnector.js';
|
|
4
|
+
import { MidnightProviderHelper } from '../../MidnightProviderHelper/MidnightProviderHelper.js';
|
|
5
|
+
|
|
6
|
+
class InjectedWalletBase extends MidnightWalletConnector {
|
|
7
|
+
get midnightProviderHelper() {
|
|
8
|
+
if (!this._midnightProviderHelper) {
|
|
9
|
+
this._midnightProviderHelper = new MidnightProviderHelper(this);
|
|
10
|
+
}
|
|
11
|
+
return this._midnightProviderHelper;
|
|
12
|
+
}
|
|
13
|
+
findProvider() {
|
|
14
|
+
return this.midnightProviderHelper.getInstalledProvider();
|
|
15
|
+
}
|
|
16
|
+
isInstalledOnBrowser() {
|
|
17
|
+
return this.midnightProviderHelper.isInstalledHelper();
|
|
18
|
+
}
|
|
19
|
+
connect() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield this.midnightProviderHelper.getConnectedAPI();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
getAddress() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
|
|
27
|
+
if (didOpenInAppBrowser)
|
|
28
|
+
return undefined;
|
|
29
|
+
return this.midnightProviderHelper.getAddress();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
signMessage(messageToSign) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return this.midnightProviderHelper.signMessage(messageToSign);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
proveOwnership(address, messageToSign) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
yield this.validateActiveWallet(address);
|
|
40
|
+
return this.signMessage(messageToSign);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
setupEventListeners() {
|
|
44
|
+
this.midnightProviderHelper._setupEventListeners();
|
|
45
|
+
}
|
|
46
|
+
teardownEventListeners() {
|
|
47
|
+
this.midnightProviderHelper._teardownEventListeners();
|
|
48
|
+
}
|
|
49
|
+
endSession() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
yield this.midnightProviderHelper.disconnect();
|
|
52
|
+
this.teardownEventListeners();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getConnectedAccounts() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const address = yield this.midnightProviderHelper.getAddressIfConnected();
|
|
58
|
+
return address ? [address] : [];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { InjectedWalletBase };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InjectedWalletBase';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var InjectedWalletBase = require('../InjectedWalletBase/InjectedWalletBase.cjs');
|
|
7
|
+
|
|
8
|
+
class Midnight1am extends InjectedWalletBase.InjectedWalletBase {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.name = '1am';
|
|
12
|
+
this.overrideKey = '1ammidnight';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.Midnight1am = Midnight1am;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { InjectedWalletBase } from '../InjectedWalletBase/InjectedWalletBase.js';
|
|
3
|
+
|
|
4
|
+
class Midnight1am extends InjectedWalletBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.name = '1am';
|
|
8
|
+
this.overrideKey = '1ammidnight';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { Midnight1am };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Midnight1am';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
+
var getConnectorConstructorInjectedWallet = require('../../utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs');
|
|
8
|
+
var constants = require('../../constants.cjs');
|
|
9
|
+
|
|
10
|
+
const injectedWalletOverrides = [];
|
|
11
|
+
const fetchInjectedWalletConnectors = ({ walletBook, walletsWithCustomConnectors, }) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
14
|
+
.filter(([key, wallet]) => {
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === constants.MIDNIGHT_CHAIN)) && !walletsWithCustomConnectors.includes(key);
|
|
17
|
+
})
|
|
18
|
+
.map(([key, wallet]) => {
|
|
19
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('[MIDNIGHT fetchInjectedWalletConnectors] creating connector from wallet-book', { key, name: wallet.name });
|
|
20
|
+
return getConnectorConstructorInjectedWallet.getConnectorConstructorInjectedWallet(key, wallet);
|
|
21
|
+
});
|
|
22
|
+
return walletBookConnectors;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.fetchInjectedWalletConnectors = fetchInjectedWalletConnectors;
|
|
26
|
+
exports.injectedWalletOverrides = injectedWalletOverrides;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
export declare const injectedWalletOverrides: WalletConnectorConstructor[];
|
|
4
|
+
export declare const fetchInjectedWalletConnectors: ({ walletBook, walletsWithCustomConnectors, }: {
|
|
5
|
+
walletBook: WalletBookSchema;
|
|
6
|
+
walletsWithCustomConnectors: string[];
|
|
7
|
+
}) => WalletConnectorConstructor[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { getConnectorConstructorInjectedWallet } from '../../utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js';
|
|
4
|
+
import { MIDNIGHT_CHAIN } from '../../constants.js';
|
|
5
|
+
|
|
6
|
+
const injectedWalletOverrides = [];
|
|
7
|
+
const fetchInjectedWalletConnectors = ({ walletBook, walletsWithCustomConnectors, }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
10
|
+
.filter(([key, wallet]) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return ((_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === MIDNIGHT_CHAIN)) && !walletsWithCustomConnectors.includes(key);
|
|
13
|
+
})
|
|
14
|
+
.map(([key, wallet]) => {
|
|
15
|
+
logger.logVerboseTroubleshootingMessage('[MIDNIGHT fetchInjectedWalletConnectors] creating connector from wallet-book', { key, name: wallet.name });
|
|
16
|
+
return getConnectorConstructorInjectedWallet(key, wallet);
|
|
17
|
+
});
|
|
18
|
+
return walletBookConnectors;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { fetchInjectedWalletConnectors, injectedWalletOverrides };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fetchInjectedWalletConnectors';
|
package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var InjectedWalletBase = require('../../injected/InjectedWalletBase/InjectedWalletBase.cjs');
|
|
7
|
+
|
|
8
|
+
const getConnectorConstructorInjectedWallet = (key, wallet) => {
|
|
9
|
+
const name = wallet.shortName || wallet.name;
|
|
10
|
+
const InjectedWalletConstructor = class extends InjectedWalletBase.InjectedWalletBase {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.overrideKey = key;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
// Add this key so we can later tell which wallet each constructor is for
|
|
18
|
+
Object.defineProperty(InjectedWalletConstructor, 'key', {
|
|
19
|
+
value: key,
|
|
20
|
+
writable: false,
|
|
21
|
+
});
|
|
22
|
+
return InjectedWalletConstructor;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.getConnectorConstructorInjectedWallet = getConnectorConstructorInjectedWallet;
|
package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { InjectedWalletBase } from '../../injected/InjectedWalletBase/InjectedWalletBase.js';
|
|
3
|
+
|
|
4
|
+
const getConnectorConstructorInjectedWallet = (key, wallet) => {
|
|
5
|
+
const name = wallet.shortName || wallet.name;
|
|
6
|
+
const InjectedWalletConstructor = class extends InjectedWalletBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.overrideKey = key;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
// Add this key so we can later tell which wallet each constructor is for
|
|
14
|
+
Object.defineProperty(InjectedWalletConstructor, 'key', {
|
|
15
|
+
value: key,
|
|
16
|
+
writable: false,
|
|
17
|
+
});
|
|
18
|
+
return InjectedWalletConstructor;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { getConnectorConstructorInjectedWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getConnectorConstructorInjectedWallet';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
|
|
9
|
+
class MidnightWallet extends walletConnectorCore.Wallet {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
sendBalance(_) {
|
|
12
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
throw new Error('sendBalance is not supported for Midnight wallets');
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.MidnightWallet = MidnightWallet;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { MidnightWalletConnector } from '../connectors/MidnightWalletConnector';
|
|
3
|
+
export declare class MidnightWallet extends Wallet<MidnightWalletConnector> {
|
|
4
|
+
sendBalance(_: {
|
|
5
|
+
amount: string;
|
|
6
|
+
toAddress: string;
|
|
7
|
+
token?: {
|
|
8
|
+
address: string;
|
|
9
|
+
decimals?: number;
|
|
10
|
+
};
|
|
11
|
+
}): Promise<string | undefined>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
|
|
5
|
+
class MidnightWallet extends Wallet {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
sendBalance(_) {
|
|
8
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
throw new Error('sendBalance is not supported for Midnight wallets');
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { MidnightWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MidnightWallet';
|