@dynamic-labs/solana 1.1.0-alpha.0 → 1.1.0-alpha.10
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 +106 -0
- package/package.json +6 -6
- package/src/CoinbaseSolana.cjs +26 -8
- package/src/CoinbaseSolana.d.ts +2 -2
- package/src/CoinbaseSolana.js +26 -8
- package/src/Glow.cjs +8 -8
- package/src/Glow.js +8 -8
- package/src/Solflare.cjs +17 -17
- package/src/Solflare.js +18 -18
- package/src/index.d.ts +1 -1
- package/src/injected/BackpackSol.cjs +4 -4
- package/src/injected/BackpackSol.js +4 -4
- package/src/injected/BraveSol.cjs +1 -1
- package/src/injected/BraveSol.js +1 -1
- package/src/injected/InjectedWalletBase.cjs +8 -8
- package/src/injected/InjectedWalletBase.js +8 -8
- package/src/injected/Phantom.cjs +19 -0
- package/src/injected/Phantom.d.ts +1 -0
- package/src/injected/Phantom.js +19 -0
- package/src/solProviderHelper.cjs +19 -21
- package/src/solProviderHelper.d.ts +7 -7
- package/src/solProviderHelper.js +20 -22
- package/src/types.d.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,110 @@
|
|
|
1
1
|
|
|
2
|
+
## [1.1.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.9...v1.1.0-alpha.10) (2024-01-06)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* pass flow network to magic client ([#4322](https://github.com/dynamic-labs/DynamicAuth/issues/4322)) ([f3adccf](https://github.com/dynamic-labs/DynamicAuth/commit/f3adccf9f8d835f6b04e4767acd0fbd2ac238379))
|
|
8
|
+
* prevent error message when mobile wallet app is open ([#4301](https://github.com/dynamic-labs/DynamicAuth/issues/4301)) ([2a66dcf](https://github.com/dynamic-labs/DynamicAuth/commit/2a66dcfaf8100b3d910c559d35d8b731b1cb380e))
|
|
9
|
+
* turnkeyWalletConnector is not an email otp connector and uses dynamic otp ([#4313](https://github.com/dynamic-labs/DynamicAuth/issues/4313)) ([e4ea56f](https://github.com/dynamic-labs/DynamicAuth/commit/e4ea56f40fdf97b3f5440b016ebd95501089cebe))
|
|
10
|
+
|
|
11
|
+
## [1.1.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.8...v1.1.0-alpha.9) (2024-01-04)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* add solana magic support ([#4258](https://github.com/dynamic-labs/DynamicAuth/issues/4258)) ([da726aa](https://github.com/dynamic-labs/DynamicAuth/commit/da726aa78466c52ee3e1f18952e4351cde754cbc))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* edge case with unlinking wallet ([#4285](https://github.com/dynamic-labs/DynamicAuth/issues/4285)) ([1057fe4](https://github.com/dynamic-labs/DynamicAuth/commit/1057fe47599381f5d9dc39ce4cbeca2041c70319))
|
|
22
|
+
* remove normalizeWalletName from DynamicAuth ([5592817](https://github.com/dynamic-labs/DynamicAuth/commit/5592817b62e345319e04cca9a98276ffad87cfc2))
|
|
23
|
+
* **useFetchBalance:** ensure the latest wallet balance is fetched ([#4288](https://github.com/dynamic-labs/DynamicAuth/issues/4288)) ([25dd035](https://github.com/dynamic-labs/DynamicAuth/commit/25dd035cf8893b7cd28f550026134ba0eecda142))
|
|
24
|
+
|
|
25
|
+
## [1.1.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.7...v1.1.0-alpha.8) (2024-01-03)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* add new sdk view section for text ([#4280](https://github.com/dynamic-labs/DynamicAuth/issues/4280)) ([457ae38](https://github.com/dynamic-labs/DynamicAuth/commit/457ae38cd2be8dae078f40b54ffc4704299d4ed9))
|
|
31
|
+
* add new setShowLinkNewWalletModal method ([f46447a](https://github.com/dynamic-labs/DynamicAuth/commit/f46447ab606f4fdbf55e5fef21dd98f8f2650e90))
|
|
32
|
+
* add pk export for hd wallets ([#4266](https://github.com/dynamic-labs/DynamicAuth/issues/4266)) ([44aac69](https://github.com/dynamic-labs/DynamicAuth/commit/44aac69580ed44e66eab971f87cb6061a3fadc90))
|
|
33
|
+
* add starknet support for sopelia ([#4248](https://github.com/dynamic-labs/DynamicAuth/issues/4248)) ([f9a0980](https://github.com/dynamic-labs/DynamicAuth/commit/f9a0980c3cd2d6d95c5dd17b179fbd0931f08b1a))
|
|
34
|
+
* enable hardware wallet for solana wallets ([#4275](https://github.com/dynamic-labs/DynamicAuth/issues/4275)) ([704b380](https://github.com/dynamic-labs/DynamicAuth/commit/704b380186618a5a5793e88f36ccbe84b59a2e4a))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* phantom solana not connecting on mobile ([#4284](https://github.com/dynamic-labs/DynamicAuth/issues/4284)) ([6ad75f1](https://github.com/dynamic-labs/DynamicAuth/commit/6ad75f152896459f5cf658227f998c246b6a572b))
|
|
40
|
+
* use bitcoin payment address for onramp ([#4273](https://github.com/dynamic-labs/DynamicAuth/issues/4273)) ([a2f54e8](https://github.com/dynamic-labs/DynamicAuth/commit/a2f54e812a11a91ee488eca64f14b5eeea1a8874))
|
|
41
|
+
|
|
42
|
+
## [1.1.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.6...v1.1.0-alpha.7) (2023-12-28)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Features
|
|
46
|
+
|
|
47
|
+
* better coinbase deeplinking ux ([#4164](https://github.com/dynamic-labs/DynamicAuth/issues/4164)) ([5252608](https://github.com/dynamic-labs/DynamicAuth/commit/525260851900a33a52f129def338963400344205))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* don't prompt for connect when selecting bitcoin wallet if already connected ([#4265](https://github.com/dynamic-labs/DynamicAuth/issues/4265)) ([adef402](https://github.com/dynamic-labs/DynamicAuth/commit/adef402ef94270a17fab896a8585a7f2eacd3681))
|
|
53
|
+
|
|
54
|
+
## [1.1.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.5...v1.1.0-alpha.6) (2023-12-27)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Features
|
|
58
|
+
|
|
59
|
+
* add multi-wallet-prompts-widget ([#4166](https://github.com/dynamic-labs/DynamicAuth/issues/4166)) ([151e3d2](https://github.com/dynamic-labs/DynamicAuth/commit/151e3d2e7bebbf18448e4af8eecbf660f713cd3d))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
* coinbase solana signMessage ([#4254](https://github.com/dynamic-labs/DynamicAuth/issues/4254)) ([f0300a9](https://github.com/dynamic-labs/DynamicAuth/commit/f0300a93ed6c9ba9dfab613820d8cedbe72abb87))
|
|
65
|
+
* make useConnectWithEmailOtp work cross views ([#4252](https://github.com/dynamic-labs/DynamicAuth/issues/4252)) ([a097119](https://github.com/dynamic-labs/DynamicAuth/commit/a097119556c38a22f338a783f79d512b99203cf5))
|
|
66
|
+
|
|
67
|
+
## [1.1.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.4...v1.1.0-alpha.5) (2023-12-21)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Features
|
|
71
|
+
|
|
72
|
+
* add support for xverse wallet ([#4245](https://github.com/dynamic-labs/DynamicAuth/issues/4245)) ([7b68546](https://github.com/dynamic-labs/DynamicAuth/commit/7b6854684412007bcb33896555900936395176df))
|
|
73
|
+
* **gvty-526:** add embedded reveal ([#4233](https://github.com/dynamic-labs/DynamicAuth/issues/4233)) ([c2d0f90](https://github.com/dynamic-labs/DynamicAuth/commit/c2d0f903f4a4646f86c71834540fd49d51a4a7ae))
|
|
74
|
+
|
|
75
|
+
## [1.1.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.3...v1.1.0-alpha.4) (2023-12-21)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Features
|
|
79
|
+
|
|
80
|
+
* add bitcoin integration ([#4216](https://github.com/dynamic-labs/DynamicAuth/issues/4216)) ([9584f1c](https://github.com/dynamic-labs/DynamicAuth/commit/9584f1cc3133835049ad1c53da980192263b8f21))
|
|
81
|
+
* add default footer to wallet list when tos and pp not enabled ([#4224](https://github.com/dynamic-labs/DynamicAuth/issues/4224)) ([0ad81c4](https://github.com/dynamic-labs/DynamicAuth/commit/0ad81c409bcb4aafb0dc565685525d620a95efce))
|
|
82
|
+
* adds useConnectWithEmailOtp ([#4234](https://github.com/dynamic-labs/DynamicAuth/issues/4234)) ([4a4e50a](https://github.com/dynamic-labs/DynamicAuth/commit/4a4e50ac8651c2a249d5125ae6bcf49aaf49be8c))
|
|
83
|
+
|
|
84
|
+
## [1.1.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.2...v1.1.0-alpha.3) (2023-12-19)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Features
|
|
88
|
+
|
|
89
|
+
* add Flow support in magic wallet connector ([#4158](https://github.com/dynamic-labs/DynamicAuth/issues/4158)) ([fbbaea7](https://github.com/dynamic-labs/DynamicAuth/commit/fbbaea76b36ceb693f6bd4f2404dfa1204e61492))
|
|
90
|
+
* add showDynamicUserProfile to DynamicContext ([#4214](https://github.com/dynamic-labs/DynamicAuth/issues/4214)) ([2aeb8e3](https://github.com/dynamic-labs/DynamicAuth/commit/2aeb8e3c45a3d9f87bd9196ea9b46927e02eb633))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Bug Fixes
|
|
94
|
+
|
|
95
|
+
* add shortname to braveevm to allow for lookups by name as well as key ([#4213](https://github.com/dynamic-labs/DynamicAuth/issues/4213)) ([969b089](https://github.com/dynamic-labs/DynamicAuth/commit/969b089be516fb57fcdc941f908c078998eb4ec0))
|
|
96
|
+
* solflare connect ([#4215](https://github.com/dynamic-labs/DynamicAuth/issues/4215)) ([9a4164e](https://github.com/dynamic-labs/DynamicAuth/commit/9a4164e53198f33ef7201cd4e1eff745a09e9701))
|
|
97
|
+
* wagmi attempt to connect to primary wallet first ([#4206](https://github.com/dynamic-labs/DynamicAuth/issues/4206)) ([9e5fc8e](https://github.com/dynamic-labs/DynamicAuth/commit/9e5fc8ef026628935ac32d3bb0c22bda35057e5d))
|
|
98
|
+
|
|
99
|
+
## [1.1.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.1...v1.1.0-alpha.2) (2023-12-18)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Bug Fixes
|
|
103
|
+
|
|
104
|
+
* increase timeout when fetching wallet network ([#4197](https://github.com/dynamic-labs/DynamicAuth/issues/4197)) ([bd43d45](https://github.com/dynamic-labs/DynamicAuth/commit/bd43d452dccf36f68bd012e5737480599b93c3b5))
|
|
105
|
+
|
|
106
|
+
## [1.1.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.0...v1.1.0-alpha.1) (2023-12-15)
|
|
107
|
+
|
|
2
108
|
## [1.1.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.14...v1.1.0-alpha.0) (2023-12-12)
|
|
3
109
|
|
|
4
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@solana/web3.js": "1.70.1",
|
|
30
|
-
"@dynamic-labs/rpc-providers": "1.1.0-alpha.
|
|
31
|
-
"@dynamic-labs/types": "1.1.0-alpha.
|
|
32
|
-
"@dynamic-labs/utils": "1.1.0-alpha.
|
|
33
|
-
"@dynamic-labs/wallet-book": "1.1.0-alpha.
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "1.1.0-alpha.
|
|
30
|
+
"@dynamic-labs/rpc-providers": "1.1.0-alpha.10",
|
|
31
|
+
"@dynamic-labs/types": "1.1.0-alpha.10",
|
|
32
|
+
"@dynamic-labs/utils": "1.1.0-alpha.10",
|
|
33
|
+
"@dynamic-labs/wallet-book": "1.1.0-alpha.10",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "1.1.0-alpha.10",
|
|
35
35
|
"eventemitter3": "5.0.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {}
|
package/src/CoinbaseSolana.cjs
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
6
7
|
var solWalletConnector = require('./solWalletConnector.cjs');
|
|
7
8
|
var solProviderHelper = require('./solProviderHelper.cjs');
|
|
9
|
+
require('@solana/web3.js');
|
|
10
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
11
|
+
require('./injected/PhantomLedger.cjs');
|
|
12
|
+
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
8
13
|
|
|
9
14
|
class CoinbaseSolana extends solWalletConnector.SolWalletConnector {
|
|
10
15
|
constructor() {
|
|
@@ -12,40 +17,53 @@ class CoinbaseSolana extends solWalletConnector.SolWalletConnector {
|
|
|
12
17
|
this.name = 'CoinbaseSolana';
|
|
13
18
|
}
|
|
14
19
|
setupEventListeners() {
|
|
15
|
-
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.
|
|
20
|
+
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.key));
|
|
16
21
|
}
|
|
17
22
|
teardownEventListeners() {
|
|
18
|
-
solProviderHelper.SolProviderHelper._teardownEventListeners(this.
|
|
23
|
+
solProviderHelper.SolProviderHelper._teardownEventListeners(this.key);
|
|
19
24
|
}
|
|
20
25
|
connect() {
|
|
21
26
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
yield solProviderHelper.SolProviderHelper.
|
|
27
|
+
yield solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
23
28
|
});
|
|
24
29
|
}
|
|
25
30
|
getSigner() {
|
|
26
31
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return solProviderHelper.SolProviderHelper.
|
|
32
|
+
return solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
35
|
isInstalledOnBrowser() {
|
|
31
|
-
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.
|
|
36
|
+
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.key);
|
|
32
37
|
}
|
|
33
38
|
fetchPublicAddress() {
|
|
34
39
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
35
40
|
if (this.isInstalledOnBrowser()) {
|
|
36
|
-
return solProviderHelper.SolProviderHelper.
|
|
41
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
37
42
|
}
|
|
38
43
|
return;
|
|
39
44
|
});
|
|
40
45
|
}
|
|
41
46
|
signMessage(messageToSign) {
|
|
42
47
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
|
|
48
|
+
const walletAddress = yield this.fetchPublicAddress();
|
|
49
|
+
if (!walletAddress) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const provider = yield this.getSigner();
|
|
53
|
+
if (!provider) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const encodedMessage = new TextEncoder().encode(messageToSign);
|
|
57
|
+
const signedMessage = yield provider.signMessage(encodedMessage, walletAddress);
|
|
58
|
+
if (!signedMessage) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return utils.bufferToBase64(isSignedMessage.isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
|
|
44
62
|
});
|
|
45
63
|
}
|
|
46
64
|
getConnectedAccounts() {
|
|
47
65
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return solProviderHelper.SolProviderHelper.
|
|
66
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
49
67
|
});
|
|
50
68
|
}
|
|
51
69
|
}
|
package/src/CoinbaseSolana.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SolWalletConnector } from './solWalletConnector';
|
|
2
|
-
import {
|
|
2
|
+
import { ICoinbaseSolanaSigner } from './types';
|
|
3
3
|
export declare class CoinbaseSolana extends SolWalletConnector {
|
|
4
4
|
name: string;
|
|
5
5
|
setupEventListeners(): void;
|
|
6
6
|
teardownEventListeners(): void;
|
|
7
7
|
connect(): Promise<void>;
|
|
8
|
-
getSigner(): Promise<
|
|
8
|
+
getSigner(): Promise<ICoinbaseSolanaSigner | undefined>;
|
|
9
9
|
isInstalledOnBrowser(): boolean;
|
|
10
10
|
fetchPublicAddress(): Promise<string | undefined>;
|
|
11
11
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
package/src/CoinbaseSolana.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
import { bufferToBase64 } from '@dynamic-labs/utils';
|
|
2
3
|
import { SolWalletConnector } from './solWalletConnector.js';
|
|
3
4
|
import { SolProviderHelper } from './solProviderHelper.js';
|
|
5
|
+
import '@solana/web3.js';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import './injected/PhantomLedger.js';
|
|
8
|
+
import { isSignedMessage } from './utils/isSignedMessage.js';
|
|
4
9
|
|
|
5
10
|
class CoinbaseSolana extends SolWalletConnector {
|
|
6
11
|
constructor() {
|
|
@@ -8,40 +13,53 @@ class CoinbaseSolana extends SolWalletConnector {
|
|
|
8
13
|
this.name = 'CoinbaseSolana';
|
|
9
14
|
}
|
|
10
15
|
setupEventListeners() {
|
|
11
|
-
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.
|
|
16
|
+
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.key));
|
|
12
17
|
}
|
|
13
18
|
teardownEventListeners() {
|
|
14
|
-
SolProviderHelper._teardownEventListeners(this.
|
|
19
|
+
SolProviderHelper._teardownEventListeners(this.key);
|
|
15
20
|
}
|
|
16
21
|
connect() {
|
|
17
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
yield SolProviderHelper.
|
|
23
|
+
yield SolProviderHelper.connectWithKey(this.key);
|
|
19
24
|
});
|
|
20
25
|
}
|
|
21
26
|
getSigner() {
|
|
22
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return SolProviderHelper.
|
|
28
|
+
return SolProviderHelper.connectWithKey(this.key);
|
|
24
29
|
});
|
|
25
30
|
}
|
|
26
31
|
isInstalledOnBrowser() {
|
|
27
|
-
return SolProviderHelper.isInstalledHelper(this.
|
|
32
|
+
return SolProviderHelper.isInstalledHelper(this.key);
|
|
28
33
|
}
|
|
29
34
|
fetchPublicAddress() {
|
|
30
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
36
|
if (this.isInstalledOnBrowser()) {
|
|
32
|
-
return SolProviderHelper.
|
|
37
|
+
return SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
33
38
|
}
|
|
34
39
|
return;
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
42
|
signMessage(messageToSign) {
|
|
38
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
|
|
44
|
+
const walletAddress = yield this.fetchPublicAddress();
|
|
45
|
+
if (!walletAddress) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const provider = yield this.getSigner();
|
|
49
|
+
if (!provider) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const encodedMessage = new TextEncoder().encode(messageToSign);
|
|
53
|
+
const signedMessage = yield provider.signMessage(encodedMessage, walletAddress);
|
|
54
|
+
if (!signedMessage) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return bufferToBase64(isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
|
|
40
58
|
});
|
|
41
59
|
}
|
|
42
60
|
getConnectedAccounts() {
|
|
43
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return SolProviderHelper.
|
|
62
|
+
return SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
45
63
|
});
|
|
46
64
|
}
|
|
47
65
|
}
|
package/src/Glow.cjs
CHANGED
|
@@ -12,37 +12,37 @@ class Glow extends solWalletConnector.SolWalletConnector {
|
|
|
12
12
|
this.name = 'Glow';
|
|
13
13
|
}
|
|
14
14
|
setupEventListeners() {
|
|
15
|
-
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.
|
|
15
|
+
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.key));
|
|
16
16
|
}
|
|
17
17
|
teardownEventListeners() {
|
|
18
|
-
solProviderHelper.SolProviderHelper._teardownEventListeners(this.
|
|
18
|
+
solProviderHelper.SolProviderHelper._teardownEventListeners(this.key);
|
|
19
19
|
}
|
|
20
20
|
connect() {
|
|
21
21
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
yield solProviderHelper.SolProviderHelper.
|
|
22
|
+
yield solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
getSigner() {
|
|
26
26
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return solProviderHelper.SolProviderHelper.
|
|
27
|
+
return solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
isInstalledOnBrowser() {
|
|
31
|
-
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.
|
|
31
|
+
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.key);
|
|
32
32
|
}
|
|
33
33
|
fetchPublicAddress() {
|
|
34
34
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
return solProviderHelper.SolProviderHelper.
|
|
35
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
signMessage(messageToSign) {
|
|
39
39
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
return solProviderHelper.SolProviderHelper.
|
|
40
|
+
return solProviderHelper.SolProviderHelper.signMessageWithKey(messageToSign, this.key);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
getConnectedAccounts() {
|
|
44
44
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
return solProviderHelper.SolProviderHelper.
|
|
45
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/Glow.js
CHANGED
|
@@ -8,37 +8,37 @@ class Glow extends SolWalletConnector {
|
|
|
8
8
|
this.name = 'Glow';
|
|
9
9
|
}
|
|
10
10
|
setupEventListeners() {
|
|
11
|
-
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.
|
|
11
|
+
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.key));
|
|
12
12
|
}
|
|
13
13
|
teardownEventListeners() {
|
|
14
|
-
SolProviderHelper._teardownEventListeners(this.
|
|
14
|
+
SolProviderHelper._teardownEventListeners(this.key);
|
|
15
15
|
}
|
|
16
16
|
connect() {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
yield SolProviderHelper.
|
|
18
|
+
yield SolProviderHelper.connectWithKey(this.key);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
getSigner() {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return SolProviderHelper.
|
|
23
|
+
return SolProviderHelper.connectWithKey(this.key);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
isInstalledOnBrowser() {
|
|
27
|
-
return SolProviderHelper.isInstalledHelper(this.
|
|
27
|
+
return SolProviderHelper.isInstalledHelper(this.key);
|
|
28
28
|
}
|
|
29
29
|
fetchPublicAddress() {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
return SolProviderHelper.
|
|
31
|
+
return SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
signMessage(messageToSign) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
return SolProviderHelper.
|
|
36
|
+
return SolProviderHelper.signMessageWithKey(messageToSign, this.key);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
getConnectedAccounts() {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
return SolProviderHelper.
|
|
41
|
+
return SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/Solflare.cjs
CHANGED
|
@@ -13,32 +13,32 @@ class Solflare extends solWalletConnector.SolWalletConnector {
|
|
|
13
13
|
this.name = 'Solflare';
|
|
14
14
|
}
|
|
15
15
|
isInstalledOnBrowser() {
|
|
16
|
-
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.
|
|
16
|
+
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.key);
|
|
17
17
|
}
|
|
18
18
|
fetchPublicAddress() {
|
|
19
19
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* It should redirect to in-app browser if on mobile and if not in the in-app browser,
|
|
22
|
+
* this checks if it is not in the in-app browser by checking if the provider is not available.
|
|
23
|
+
*/
|
|
24
|
+
if (utils.isMobile() && !this.isInstalledOnBrowser()) {
|
|
25
|
+
utils.handleMobileWalletRedirect({
|
|
26
|
+
nativeLink: 'solflare://ul/v1/browse',
|
|
27
|
+
universalLink: 'https://solflare.com/ul/v1/browse',
|
|
28
|
+
});
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
return solProviderHelper.SolProviderHelper.
|
|
31
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
connect() {
|
|
35
35
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
yield solProviderHelper.SolProviderHelper.
|
|
36
|
+
yield solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
getSigner() {
|
|
40
40
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
return solProviderHelper.SolProviderHelper.
|
|
41
|
+
return solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
signMessage(messageToSign) {
|
|
@@ -47,7 +47,7 @@ class Solflare extends solWalletConnector.SolWalletConnector {
|
|
|
47
47
|
if (!walletAddress) {
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
|
-
const provider = solProviderHelper.SolProviderHelper.findProvider(this.
|
|
50
|
+
const provider = solProviderHelper.SolProviderHelper.findProvider(this.key);
|
|
51
51
|
if (!provider) {
|
|
52
52
|
return undefined;
|
|
53
53
|
}
|
|
@@ -69,14 +69,14 @@ class Solflare extends solWalletConnector.SolWalletConnector {
|
|
|
69
69
|
}
|
|
70
70
|
getConnectedAccounts() {
|
|
71
71
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return solProviderHelper.SolProviderHelper.
|
|
72
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
setupEventListeners() {
|
|
76
|
-
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.
|
|
76
|
+
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.key));
|
|
77
77
|
}
|
|
78
78
|
teardownEventListeners() {
|
|
79
|
-
solProviderHelper.SolProviderHelper._teardownEventListeners(this.
|
|
79
|
+
solProviderHelper.SolProviderHelper._teardownEventListeners(this.key);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
package/src/Solflare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
-
import { isMobile,
|
|
2
|
+
import { isMobile, handleMobileWalletRedirect, bufferToBase64 } from '@dynamic-labs/utils';
|
|
3
3
|
import { SolWalletConnector } from './solWalletConnector.js';
|
|
4
4
|
import { SolProviderHelper } from './solProviderHelper.js';
|
|
5
5
|
|
|
@@ -9,32 +9,32 @@ class Solflare extends SolWalletConnector {
|
|
|
9
9
|
this.name = 'Solflare';
|
|
10
10
|
}
|
|
11
11
|
isInstalledOnBrowser() {
|
|
12
|
-
return SolProviderHelper.isInstalledHelper(this.
|
|
12
|
+
return SolProviderHelper.isInstalledHelper(this.key);
|
|
13
13
|
}
|
|
14
14
|
fetchPublicAddress() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
16
|
+
/**
|
|
17
|
+
* It should redirect to in-app browser if on mobile and if not in the in-app browser,
|
|
18
|
+
* this checks if it is not in the in-app browser by checking if the provider is not available.
|
|
19
|
+
*/
|
|
20
|
+
if (isMobile() && !this.isInstalledOnBrowser()) {
|
|
21
|
+
handleMobileWalletRedirect({
|
|
22
|
+
nativeLink: 'solflare://ul/v1/browse',
|
|
23
|
+
universalLink: 'https://solflare.com/ul/v1/browse',
|
|
24
|
+
});
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
return SolProviderHelper.
|
|
27
|
+
return SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
connect() {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
yield SolProviderHelper.
|
|
32
|
+
yield SolProviderHelper.connectWithKey(this.key);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
getSigner() {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return SolProviderHelper.
|
|
37
|
+
return SolProviderHelper.connectWithKey(this.key);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
signMessage(messageToSign) {
|
|
@@ -43,7 +43,7 @@ class Solflare extends SolWalletConnector {
|
|
|
43
43
|
if (!walletAddress) {
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
|
-
const provider = SolProviderHelper.findProvider(this.
|
|
46
|
+
const provider = SolProviderHelper.findProvider(this.key);
|
|
47
47
|
if (!provider) {
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
@@ -65,14 +65,14 @@ class Solflare extends SolWalletConnector {
|
|
|
65
65
|
}
|
|
66
66
|
getConnectedAccounts() {
|
|
67
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return SolProviderHelper.
|
|
68
|
+
return SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
setupEventListeners() {
|
|
72
|
-
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.
|
|
72
|
+
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.key));
|
|
73
73
|
}
|
|
74
74
|
teardownEventListeners() {
|
|
75
|
-
SolProviderHelper._teardownEventListeners(this.
|
|
75
|
+
SolProviderHelper._teardownEventListeners(this.key);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
package/src/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export * from './Solflare';
|
|
|
4
4
|
export declare const SolanaWalletConnectors: (props: any) => typeof import("./injected/BraveSol").BraveSol[];
|
|
5
5
|
export { isSignedMessage } from './utils/isSignedMessage';
|
|
6
6
|
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
|
|
7
|
-
export type { ISolana, IBackpackSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
|
|
7
|
+
export type { ISolana, IBackpackSolanaSigner, ICoinbaseSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
|
|
@@ -13,7 +13,7 @@ class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
|
|
|
13
13
|
this.name = 'BackpackSol';
|
|
14
14
|
}
|
|
15
15
|
setupEventListeners() {
|
|
16
|
-
const web3Provider = solProviderHelper.SolProviderHelper.findProvider(this.
|
|
16
|
+
const web3Provider = solProviderHelper.SolProviderHelper.findProvider(this.key);
|
|
17
17
|
if (!web3Provider)
|
|
18
18
|
return;
|
|
19
19
|
web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.on('activeWalletDidChange', (publicKey) => solProviderHelper.SolProviderHelper.handleAccountChange(this, web3Provider, publicKey));
|
|
@@ -21,12 +21,12 @@ class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
|
|
|
21
21
|
}
|
|
22
22
|
fetchPublicAddress() {
|
|
23
23
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
return solProviderHelper.SolProviderHelper.
|
|
24
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
getSigner() {
|
|
28
28
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return solProviderHelper.SolProviderHelper.
|
|
29
|
+
return solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
signMessage(messageToSign) {
|
|
@@ -48,7 +48,7 @@ class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
|
|
|
48
48
|
}
|
|
49
49
|
getConnectedAccounts() {
|
|
50
50
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
return solProviderHelper.SolProviderHelper.
|
|
51
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -9,7 +9,7 @@ class BackpackSol extends InjectedWalletBase {
|
|
|
9
9
|
this.name = 'BackpackSol';
|
|
10
10
|
}
|
|
11
11
|
setupEventListeners() {
|
|
12
|
-
const web3Provider = SolProviderHelper.findProvider(this.
|
|
12
|
+
const web3Provider = SolProviderHelper.findProvider(this.key);
|
|
13
13
|
if (!web3Provider)
|
|
14
14
|
return;
|
|
15
15
|
web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.on('activeWalletDidChange', (publicKey) => SolProviderHelper.handleAccountChange(this, web3Provider, publicKey));
|
|
@@ -17,12 +17,12 @@ class BackpackSol extends InjectedWalletBase {
|
|
|
17
17
|
}
|
|
18
18
|
fetchPublicAddress() {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
return SolProviderHelper.
|
|
20
|
+
return SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
getSigner() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return SolProviderHelper.
|
|
25
|
+
return SolProviderHelper.connectWithKey(this.key);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
signMessage(messageToSign) {
|
|
@@ -44,7 +44,7 @@ class BackpackSol extends InjectedWalletBase {
|
|
|
44
44
|
}
|
|
45
45
|
getConnectedAccounts() {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return SolProviderHelper.
|
|
47
|
+
return SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -13,7 +13,7 @@ class BraveSol extends InjectedWalletBase.InjectedWalletBase {
|
|
|
13
13
|
}
|
|
14
14
|
fetchPublicAddress() {
|
|
15
15
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
return solProviderHelper.SolProviderHelper.
|
|
16
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
}
|
package/src/injected/BraveSol.js
CHANGED
|
@@ -9,7 +9,7 @@ class BraveSol extends InjectedWalletBase {
|
|
|
9
9
|
}
|
|
10
10
|
fetchPublicAddress() {
|
|
11
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
return SolProviderHelper.
|
|
12
|
+
return SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -8,19 +8,19 @@ var solProviderHelper = require('../solProviderHelper.cjs');
|
|
|
8
8
|
|
|
9
9
|
class InjectedWalletBase extends solWalletConnector.SolWalletConnector {
|
|
10
10
|
setupEventListeners() {
|
|
11
|
-
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.
|
|
11
|
+
solProviderHelper.SolProviderHelper._setupEventListeners(this, solProviderHelper.SolProviderHelper.findProvider(this.key));
|
|
12
12
|
}
|
|
13
13
|
teardownEventListeners() {
|
|
14
|
-
solProviderHelper.SolProviderHelper._teardownEventListeners(this.
|
|
14
|
+
solProviderHelper.SolProviderHelper._teardownEventListeners(this.key);
|
|
15
15
|
}
|
|
16
16
|
connect() {
|
|
17
17
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
yield solProviderHelper.SolProviderHelper.
|
|
18
|
+
yield solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
getSigner() {
|
|
22
22
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return solProviderHelper.SolProviderHelper.
|
|
23
|
+
return solProviderHelper.SolProviderHelper.connectWithKey(this.key);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
isInstalledOnBrowser() {
|
|
@@ -31,23 +31,23 @@ class InjectedWalletBase extends solWalletConnector.SolWalletConnector {
|
|
|
31
31
|
* It relies on the fact that if both Glow and Phantom are enabled,
|
|
32
32
|
* solana.isGlow will return false.
|
|
33
33
|
*/
|
|
34
|
-
return (solProviderHelper.SolProviderHelper.isInstalledHelper(this.
|
|
34
|
+
return (solProviderHelper.SolProviderHelper.isInstalledHelper(this.key) && !((_a = window.solana) === null || _a === void 0 ? void 0 : _a.isGlow));
|
|
35
35
|
}
|
|
36
36
|
fetchPublicAddress() {
|
|
37
37
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
if (!this.isInstalledOnBrowser())
|
|
39
39
|
return;
|
|
40
|
-
return solProviderHelper.SolProviderHelper.
|
|
40
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
signMessage(messageToSign) {
|
|
44
44
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
return solProviderHelper.SolProviderHelper.
|
|
45
|
+
return solProviderHelper.SolProviderHelper.signMessageWithKey(messageToSign, this.key);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
getConnectedAccounts() {
|
|
49
49
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
return solProviderHelper.SolProviderHelper.
|
|
50
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -4,19 +4,19 @@ import { SolProviderHelper } from '../solProviderHelper.js';
|
|
|
4
4
|
|
|
5
5
|
class InjectedWalletBase extends SolWalletConnector {
|
|
6
6
|
setupEventListeners() {
|
|
7
|
-
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.
|
|
7
|
+
SolProviderHelper._setupEventListeners(this, SolProviderHelper.findProvider(this.key));
|
|
8
8
|
}
|
|
9
9
|
teardownEventListeners() {
|
|
10
|
-
SolProviderHelper._teardownEventListeners(this.
|
|
10
|
+
SolProviderHelper._teardownEventListeners(this.key);
|
|
11
11
|
}
|
|
12
12
|
connect() {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
yield SolProviderHelper.
|
|
14
|
+
yield SolProviderHelper.connectWithKey(this.key);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
getSigner() {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
return SolProviderHelper.
|
|
19
|
+
return SolProviderHelper.connectWithKey(this.key);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
isInstalledOnBrowser() {
|
|
@@ -27,23 +27,23 @@ class InjectedWalletBase extends SolWalletConnector {
|
|
|
27
27
|
* It relies on the fact that if both Glow and Phantom are enabled,
|
|
28
28
|
* solana.isGlow will return false.
|
|
29
29
|
*/
|
|
30
|
-
return (SolProviderHelper.isInstalledHelper(this.
|
|
30
|
+
return (SolProviderHelper.isInstalledHelper(this.key) && !((_a = window.solana) === null || _a === void 0 ? void 0 : _a.isGlow));
|
|
31
31
|
}
|
|
32
32
|
fetchPublicAddress() {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
if (!this.isInstalledOnBrowser())
|
|
35
35
|
return;
|
|
36
|
-
return SolProviderHelper.
|
|
36
|
+
return SolProviderHelper.fetchPublicAddressWithKey(this.key);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
signMessage(messageToSign) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
return SolProviderHelper.
|
|
41
|
+
return SolProviderHelper.signMessageWithKey(messageToSign, this.key);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
getConnectedAccounts() {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
return SolProviderHelper.
|
|
46
|
+
return SolProviderHelper.getConnectedAccountsWithKey(this.key);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/injected/Phantom.cjs
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
5
7
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
6
8
|
|
|
7
9
|
class Phantom extends InjectedWalletBase.InjectedWalletBase {
|
|
@@ -9,6 +11,23 @@ class Phantom extends InjectedWalletBase.InjectedWalletBase {
|
|
|
9
11
|
super(...arguments);
|
|
10
12
|
this.name = 'Phantom';
|
|
11
13
|
}
|
|
14
|
+
fetchPublicAddress() {
|
|
15
|
+
const _super = Object.create(null, {
|
|
16
|
+
fetchPublicAddress: { get: () => super.fetchPublicAddress }
|
|
17
|
+
});
|
|
18
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
if (this.isInstalledOnBrowser()) {
|
|
20
|
+
return _super.fetchPublicAddress.call(this);
|
|
21
|
+
}
|
|
22
|
+
if (utils.isMobile()) {
|
|
23
|
+
utils.handleMobileWalletRedirect({
|
|
24
|
+
nativeLink: 'phantom://browse',
|
|
25
|
+
universalLink: 'https://phantom.app/ul/browse',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
12
31
|
}
|
|
13
32
|
|
|
14
33
|
exports.Phantom = Phantom;
|
package/src/injected/Phantom.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { isMobile, handleMobileWalletRedirect } from '@dynamic-labs/utils';
|
|
1
3
|
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
2
4
|
|
|
3
5
|
class Phantom extends InjectedWalletBase {
|
|
@@ -5,6 +7,23 @@ class Phantom extends InjectedWalletBase {
|
|
|
5
7
|
super(...arguments);
|
|
6
8
|
this.name = 'Phantom';
|
|
7
9
|
}
|
|
10
|
+
fetchPublicAddress() {
|
|
11
|
+
const _super = Object.create(null, {
|
|
12
|
+
fetchPublicAddress: { get: () => super.fetchPublicAddress }
|
|
13
|
+
});
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (this.isInstalledOnBrowser()) {
|
|
16
|
+
return _super.fetchPublicAddress.call(this);
|
|
17
|
+
}
|
|
18
|
+
if (isMobile()) {
|
|
19
|
+
handleMobileWalletRedirect({
|
|
20
|
+
nativeLink: 'phantom://browse',
|
|
21
|
+
universalLink: 'https://phantom.app/ul/browse',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
8
27
|
}
|
|
9
28
|
|
|
10
29
|
export { Phantom };
|
|
@@ -13,8 +13,8 @@ class SolProviderHelper {
|
|
|
13
13
|
return walletConnectorCore.ProviderLookup(this.allInstalledProviders(), providerFlags);
|
|
14
14
|
}
|
|
15
15
|
static allInstalledProviders() {
|
|
16
|
-
var _b;
|
|
17
|
-
return this.findSolanaProviders(window.solana).concat(this.findSolanaProviders(window.solflare), this.findSolanaProviders(window.glowSolana), this.findSolanaProviders(window.backpack), this.findSolanaProviders((_b = window.
|
|
16
|
+
var _b, _c;
|
|
17
|
+
return this.findSolanaProviders(window.solana).concat(this.findSolanaProviders(window.solflare), this.findSolanaProviders(window.glowSolana), this.findSolanaProviders(window.backpack), this.findSolanaProviders((_b = window.phantom) === null || _b === void 0 ? void 0 : _b.solana), this.findSolanaProviders((_c = window.magicEden) === null || _c === void 0 ? void 0 : _c.solana));
|
|
18
18
|
}
|
|
19
19
|
static findSolanaProviders(solana) {
|
|
20
20
|
const solanaProviders = [];
|
|
@@ -28,16 +28,16 @@ class SolProviderHelper {
|
|
|
28
28
|
}
|
|
29
29
|
return solanaProviders;
|
|
30
30
|
}
|
|
31
|
-
static isInstalledHelper(
|
|
32
|
-
return this.findProvider(
|
|
31
|
+
static isInstalledHelper(walletKey) {
|
|
32
|
+
return this.findProvider(walletKey) !== undefined;
|
|
33
33
|
}
|
|
34
|
-
static findProvider(
|
|
34
|
+
static findProvider(walletKey) {
|
|
35
35
|
var _b, _c;
|
|
36
|
-
return (_c = (_b = this.providers)[
|
|
36
|
+
return (_c = (_b = this.providers)[walletKey]) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
37
37
|
}
|
|
38
|
-
static
|
|
38
|
+
static fetchPublicAddressWithKey(key) {
|
|
39
39
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const provider = this.findProvider(
|
|
40
|
+
const provider = this.findProvider(key);
|
|
41
41
|
if (!provider) {
|
|
42
42
|
return Promise.resolve(undefined);
|
|
43
43
|
}
|
|
@@ -48,9 +48,9 @@ class SolProviderHelper {
|
|
|
48
48
|
return publicKey ? publicKey.toString() : Promise.resolve(undefined);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
static
|
|
51
|
+
static connectWithKey(key) {
|
|
52
52
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const provider = this.findProvider(
|
|
53
|
+
const provider = this.findProvider(key);
|
|
54
54
|
if (!provider) {
|
|
55
55
|
return Promise.resolve(undefined);
|
|
56
56
|
}
|
|
@@ -65,13 +65,13 @@ class SolProviderHelper {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
static
|
|
68
|
+
static signMessageWithKey(messageToSign, key) {
|
|
69
69
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const walletAddress = yield this.
|
|
70
|
+
const walletAddress = yield this.fetchPublicAddressWithKey(key);
|
|
71
71
|
if (!walletAddress) {
|
|
72
72
|
return Promise.resolve(undefined);
|
|
73
73
|
}
|
|
74
|
-
const provider = this.findProvider(
|
|
74
|
+
const provider = this.findProvider(key);
|
|
75
75
|
if (!provider) {
|
|
76
76
|
return Promise.resolve(undefined);
|
|
77
77
|
}
|
|
@@ -90,17 +90,17 @@ class SolProviderHelper {
|
|
|
90
90
|
web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.on('accountChanged', (publicKey) => this.handleAccountChange(walletConnector, web3Provider, publicKey));
|
|
91
91
|
web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.on('disconnect', () => walletConnector.emit('disconnect'));
|
|
92
92
|
}
|
|
93
|
-
static _teardownEventListeners(
|
|
94
|
-
const web3Provider = this.findProvider(
|
|
93
|
+
static _teardownEventListeners(key) {
|
|
94
|
+
const web3Provider = this.findProvider(key);
|
|
95
95
|
if (!web3Provider) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
web3Provider.removeAllListeners();
|
|
99
99
|
}
|
|
100
|
-
static
|
|
100
|
+
static getConnectedAccountsWithKey(key) {
|
|
101
101
|
var _b, _c;
|
|
102
102
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const provider = this.findProvider(
|
|
103
|
+
const provider = this.findProvider(key);
|
|
104
104
|
if (!provider) {
|
|
105
105
|
return [];
|
|
106
106
|
}
|
|
@@ -137,11 +137,9 @@ SolProviderHelper.PhantomProvider = () => _a.installedProviderLookup([
|
|
|
137
137
|
{ flag: 'isPhantom', value: true },
|
|
138
138
|
{ flag: 'isBraveWallet', value: false },
|
|
139
139
|
{ flag: 'isExodus', value: false },
|
|
140
|
+
{ flag: 'isMagicEden', value: false },
|
|
140
141
|
]);
|
|
141
|
-
SolProviderHelper.MagicEdenProvider = () => _a.installedProviderLookup([
|
|
142
|
-
{ flag: 'isMagicEden', value: true },
|
|
143
|
-
{ flag: 'isPhantom', value: false },
|
|
144
|
-
]);
|
|
142
|
+
SolProviderHelper.MagicEdenProvider = () => _a.installedProviderLookup([{ flag: 'isMagicEden', value: true }]);
|
|
145
143
|
SolProviderHelper.SolflareProvider = () => _a.installedProviderLookup([{ flag: 'isSolflare', value: true }]);
|
|
146
144
|
SolProviderHelper.BraveProvider = () => _a.installedProviderLookup([
|
|
147
145
|
{ flag: 'isPhantom', value: true },
|
|
@@ -20,14 +20,14 @@ export declare class SolProviderHelper {
|
|
|
20
20
|
static installedProviderLookup(providerFlags: Array<ProviderCondition<ProviderFlag>>): ISolana | undefined;
|
|
21
21
|
static allInstalledProviders(): ISolana[];
|
|
22
22
|
static findSolanaProviders(solana?: ISolana): ISolana[];
|
|
23
|
-
static isInstalledHelper(
|
|
24
|
-
static findProvider(
|
|
25
|
-
static
|
|
26
|
-
static
|
|
27
|
-
static
|
|
23
|
+
static isInstalledHelper(walletKey: string): boolean;
|
|
24
|
+
static findProvider(walletKey: string): ISolana | undefined;
|
|
25
|
+
static fetchPublicAddressWithKey(key: string): Promise<string | undefined>;
|
|
26
|
+
static connectWithKey(key: string): Promise<ISolana | undefined>;
|
|
27
|
+
static signMessageWithKey(messageToSign: string, key: string): Promise<string | undefined>;
|
|
28
28
|
static handleAccountChange: (walletConnector: WalletConnector, web3Provider: ISolana, address: string) => Promise<void>;
|
|
29
29
|
static _setupEventListeners(walletConnector: WalletConnector, web3Provider?: ISolana): void;
|
|
30
|
-
static _teardownEventListeners(
|
|
31
|
-
static
|
|
30
|
+
static _teardownEventListeners(key: string): void;
|
|
31
|
+
static getConnectedAccountsWithKey(key: string): Promise<string[]>;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
package/src/solProviderHelper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
-
import { ProviderLookup
|
|
2
|
+
import { ProviderLookup } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { bufferToBase64 } from '@dynamic-labs/utils';
|
|
4
4
|
import { isSignedMessage } from './utils/isSignedMessage.js';
|
|
5
5
|
|
|
@@ -9,8 +9,8 @@ class SolProviderHelper {
|
|
|
9
9
|
return ProviderLookup(this.allInstalledProviders(), providerFlags);
|
|
10
10
|
}
|
|
11
11
|
static allInstalledProviders() {
|
|
12
|
-
var _b;
|
|
13
|
-
return this.findSolanaProviders(window.solana).concat(this.findSolanaProviders(window.solflare), this.findSolanaProviders(window.glowSolana), this.findSolanaProviders(window.backpack), this.findSolanaProviders((_b = window.
|
|
12
|
+
var _b, _c;
|
|
13
|
+
return this.findSolanaProviders(window.solana).concat(this.findSolanaProviders(window.solflare), this.findSolanaProviders(window.glowSolana), this.findSolanaProviders(window.backpack), this.findSolanaProviders((_b = window.phantom) === null || _b === void 0 ? void 0 : _b.solana), this.findSolanaProviders((_c = window.magicEden) === null || _c === void 0 ? void 0 : _c.solana));
|
|
14
14
|
}
|
|
15
15
|
static findSolanaProviders(solana) {
|
|
16
16
|
const solanaProviders = [];
|
|
@@ -24,16 +24,16 @@ class SolProviderHelper {
|
|
|
24
24
|
}
|
|
25
25
|
return solanaProviders;
|
|
26
26
|
}
|
|
27
|
-
static isInstalledHelper(
|
|
28
|
-
return this.findProvider(
|
|
27
|
+
static isInstalledHelper(walletKey) {
|
|
28
|
+
return this.findProvider(walletKey) !== undefined;
|
|
29
29
|
}
|
|
30
|
-
static findProvider(
|
|
30
|
+
static findProvider(walletKey) {
|
|
31
31
|
var _b, _c;
|
|
32
|
-
return (_c = (_b = this.providers)[
|
|
32
|
+
return (_c = (_b = this.providers)[walletKey]) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
33
33
|
}
|
|
34
|
-
static
|
|
34
|
+
static fetchPublicAddressWithKey(key) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const provider = this.findProvider(
|
|
36
|
+
const provider = this.findProvider(key);
|
|
37
37
|
if (!provider) {
|
|
38
38
|
return Promise.resolve(undefined);
|
|
39
39
|
}
|
|
@@ -44,9 +44,9 @@ class SolProviderHelper {
|
|
|
44
44
|
return publicKey ? publicKey.toString() : Promise.resolve(undefined);
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
static
|
|
47
|
+
static connectWithKey(key) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const provider = this.findProvider(
|
|
49
|
+
const provider = this.findProvider(key);
|
|
50
50
|
if (!provider) {
|
|
51
51
|
return Promise.resolve(undefined);
|
|
52
52
|
}
|
|
@@ -61,13 +61,13 @@ class SolProviderHelper {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
static
|
|
64
|
+
static signMessageWithKey(messageToSign, key) {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const walletAddress = yield this.
|
|
66
|
+
const walletAddress = yield this.fetchPublicAddressWithKey(key);
|
|
67
67
|
if (!walletAddress) {
|
|
68
68
|
return Promise.resolve(undefined);
|
|
69
69
|
}
|
|
70
|
-
const provider = this.findProvider(
|
|
70
|
+
const provider = this.findProvider(key);
|
|
71
71
|
if (!provider) {
|
|
72
72
|
return Promise.resolve(undefined);
|
|
73
73
|
}
|
|
@@ -86,17 +86,17 @@ class SolProviderHelper {
|
|
|
86
86
|
web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.on('accountChanged', (publicKey) => this.handleAccountChange(walletConnector, web3Provider, publicKey));
|
|
87
87
|
web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.on('disconnect', () => walletConnector.emit('disconnect'));
|
|
88
88
|
}
|
|
89
|
-
static _teardownEventListeners(
|
|
90
|
-
const web3Provider = this.findProvider(
|
|
89
|
+
static _teardownEventListeners(key) {
|
|
90
|
+
const web3Provider = this.findProvider(key);
|
|
91
91
|
if (!web3Provider) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
web3Provider.removeAllListeners();
|
|
95
95
|
}
|
|
96
|
-
static
|
|
96
|
+
static getConnectedAccountsWithKey(key) {
|
|
97
97
|
var _b, _c;
|
|
98
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const provider = this.findProvider(
|
|
99
|
+
const provider = this.findProvider(key);
|
|
100
100
|
if (!provider) {
|
|
101
101
|
return [];
|
|
102
102
|
}
|
|
@@ -133,11 +133,9 @@ SolProviderHelper.PhantomProvider = () => _a.installedProviderLookup([
|
|
|
133
133
|
{ flag: 'isPhantom', value: true },
|
|
134
134
|
{ flag: 'isBraveWallet', value: false },
|
|
135
135
|
{ flag: 'isExodus', value: false },
|
|
136
|
+
{ flag: 'isMagicEden', value: false },
|
|
136
137
|
]);
|
|
137
|
-
SolProviderHelper.MagicEdenProvider = () => _a.installedProviderLookup([
|
|
138
|
-
{ flag: 'isMagicEden', value: true },
|
|
139
|
-
{ flag: 'isPhantom', value: false },
|
|
140
|
-
]);
|
|
138
|
+
SolProviderHelper.MagicEdenProvider = () => _a.installedProviderLookup([{ flag: 'isMagicEden', value: true }]);
|
|
141
139
|
SolProviderHelper.SolflareProvider = () => _a.installedProviderLookup([{ flag: 'isSolflare', value: true }]);
|
|
142
140
|
SolProviderHelper.BraveProvider = () => _a.installedProviderLookup([
|
|
143
141
|
{ flag: 'isPhantom', value: true },
|
package/src/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare global {
|
|
|
9
9
|
Slope?: {
|
|
10
10
|
new (): ISolana;
|
|
11
11
|
};
|
|
12
|
-
coinbaseSolana?:
|
|
12
|
+
coinbaseSolana?: ICoinbaseSolanaSigner;
|
|
13
13
|
glowSolana?: ISolana;
|
|
14
14
|
phantom?: IWindowPhantom;
|
|
15
15
|
solana?: ISolana;
|
|
@@ -59,7 +59,10 @@ export type IBackpackSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
|
|
|
59
59
|
signMessage: (message: Uint8Array, encoding?: string) => Promise<void | Uint8Array>;
|
|
60
60
|
send: (transaction: Transaction, signers?: Signer[], options?: SendOptions, connection?: Connection, publicKey?: PublicKey) => Promise<TransactionSignature>;
|
|
61
61
|
};
|
|
62
|
-
export type
|
|
62
|
+
export type ICoinbaseSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
|
|
63
|
+
signMessage: (message: Uint8Array, publicKey?: string) => Promise<void | Uint8Array>;
|
|
64
|
+
};
|
|
65
|
+
export type ISolana = ISolanaSigner | IBackpackSolanaSigner | ICoinbaseSolanaSigner;
|
|
63
66
|
export type ProviderFlag = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare' | 'isExodus' | 'isBackpack' | 'isMagicEden';
|
|
64
67
|
export type EthProviderCondition = ProviderCondition<ProviderFlag>;
|
|
65
68
|
export {};
|