@dynamic-labs/solana 2.1.2 → 2.1.3
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 +15 -0
- package/package.json +8 -8
- package/src/contants.cjs +8 -0
- package/src/contants.d.ts +1 -0
- package/src/contants.js +4 -0
- package/src/solWalletConnector.cjs +11 -6
- package/src/solWalletConnector.d.ts +1 -3
- package/src/solWalletConnector.js +11 -6
- package/src/utils/getGenesisHashLSKey.cjs +10 -0
- package/src/utils/getGenesisHashLSKey.d.ts +1 -0
- package/src/utils/getGenesisHashLSKey.js +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
### [2.1.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2...v2.1.3) (2024-06-14)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add in-app browser navigation support for sats-connect ([#5990](https://github.com/dynamic-labs/DynamicAuth/issues/5990)) ([7ea15b9](https://github.com/dynamic-labs/DynamicAuth/commit/7ea15b93d1864164acb82c1e73aae7f9130e1d44))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* cache getGenesisHash call to prevent over calling ([#5966](https://github.com/dynamic-labs/DynamicAuth/issues/5966)) ([#5970](https://github.com/dynamic-labs/DynamicAuth/issues/5970)) ([b624b2e](https://github.com/dynamic-labs/DynamicAuth/commit/b624b2ea5b398bf464d3098e7d81d83c7b5bf659))
|
|
13
|
+
* improvements to embedded solana wallet ([#6001](https://github.com/dynamic-labs/DynamicAuth/issues/6001)) ([a6437c9](https://github.com/dynamic-labs/DynamicAuth/commit/a6437c93e1946bca609d3d99d282123275022376)) ([#5815](https://github.com/dynamic-labs/DynamicAuth/issues/5815)) ([#5978](https://github.com/dynamic-labs/DynamicAuth/issues/5978)) ([dd92973](https://github.com/dynamic-labs/DynamicAuth/commit/dd9297365f0ccbee1217325328e173ae7ee9a922))
|
|
14
|
+
* show linked wallets with unavailable providers in user wallets list ([#6005](https://github.com/dynamic-labs/DynamicAuth/issues/6005)) ([79796d1](https://github.com/dynamic-labs/DynamicAuth/commit/79796d1b73670265ca9897314252b620afaa2e8a))
|
|
15
|
+
* close switch network modal after switching to a supported network ([#5987](https://github.com/dynamic-labs/DynamicAuth/issues/5987)) ([a7e762e](https://github.com/dynamic-labs/DynamicAuth/commit/a7e762ef63a72492d0c083a344111589a6fbc455))
|
|
16
|
+
|
|
2
17
|
### [2.1.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2-alpha.1...v2.1.2) (2024-06-10)
|
|
3
18
|
|
|
4
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"@wallet-standard/experimental-features": "0.1.1",
|
|
35
35
|
"bs58": "5.0.0",
|
|
36
36
|
"tweetnacl": "1.0.3",
|
|
37
|
-
"@dynamic-labs/rpc-provider-solana": "2.1.
|
|
38
|
-
"@dynamic-labs/rpc-providers": "2.1.
|
|
39
|
-
"@dynamic-labs/turnkey": "2.1.
|
|
40
|
-
"@dynamic-labs/types": "2.1.
|
|
41
|
-
"@dynamic-labs/utils": "2.1.
|
|
42
|
-
"@dynamic-labs/wallet-book": "2.1.
|
|
43
|
-
"@dynamic-labs/wallet-connector-core": "2.1.
|
|
37
|
+
"@dynamic-labs/rpc-provider-solana": "2.1.3",
|
|
38
|
+
"@dynamic-labs/rpc-providers": "2.1.3",
|
|
39
|
+
"@dynamic-labs/turnkey": "2.1.3",
|
|
40
|
+
"@dynamic-labs/types": "2.1.3",
|
|
41
|
+
"@dynamic-labs/utils": "2.1.3",
|
|
42
|
+
"@dynamic-labs/wallet-book": "2.1.3",
|
|
43
|
+
"@dynamic-labs/wallet-connector-core": "2.1.3",
|
|
44
44
|
"eventemitter3": "5.0.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {}
|
package/src/contants.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SOLANA_GENESIS_HASH = "genesis-hash";
|
package/src/contants.js
ADDED
|
@@ -9,6 +9,7 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
9
9
|
var utils = require('@dynamic-labs/utils');
|
|
10
10
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
11
11
|
var extractNonce = require('./utils/extractNonce.cjs');
|
|
12
|
+
var getGenesisHashLSKey = require('./utils/getGenesisHashLSKey.cjs');
|
|
12
13
|
|
|
13
14
|
const MEMO_PROGRAM_ID = new web3_js.PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
|
|
14
15
|
class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
@@ -16,7 +17,6 @@ class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
16
17
|
var _a;
|
|
17
18
|
super(opts);
|
|
18
19
|
this.isHardwareWalletEnabled = false;
|
|
19
|
-
this._network = undefined;
|
|
20
20
|
this.verifiedCredentials = [];
|
|
21
21
|
this.supportedChains = ['SOL'];
|
|
22
22
|
this.connectedChain = 'SOL';
|
|
@@ -26,11 +26,12 @@ class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
26
26
|
}
|
|
27
27
|
getNetwork() {
|
|
28
28
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
if (this._network) {
|
|
30
|
-
return this._network;
|
|
31
|
-
}
|
|
32
29
|
const provider = this.getWalletClient();
|
|
33
|
-
let genesisHash =
|
|
30
|
+
let genesisHash = localStorage.getItem(getGenesisHashLSKey.getGenesisHashLSKey(provider.rpcEndpoint));
|
|
31
|
+
if (!genesisHash) {
|
|
32
|
+
genesisHash = yield provider.getGenesisHash();
|
|
33
|
+
localStorage.setItem(getGenesisHashLSKey.getGenesisHashLSKey(provider.rpcEndpoint), genesisHash);
|
|
34
|
+
}
|
|
34
35
|
genesisHash = genesisHash.substring(0, 32);
|
|
35
36
|
// see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
|
|
36
37
|
let network;
|
|
@@ -43,10 +44,14 @@ class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
43
44
|
else {
|
|
44
45
|
network = 'testnet';
|
|
45
46
|
}
|
|
46
|
-
this._network = network;
|
|
47
47
|
return network;
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
+
endSession() {
|
|
51
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
localStorage.removeItem(getGenesisHashLSKey.getGenesisHashLSKey(this.getWalletClient().rpcEndpoint));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
50
55
|
getWalletClient() {
|
|
51
56
|
var _a;
|
|
52
57
|
const [network] = this.solNetworks;
|
|
@@ -10,16 +10,15 @@ export type SolWalletConnectorOpts = {
|
|
|
10
10
|
solNetworks: GenericNetwork[];
|
|
11
11
|
walletBook: WalletBookSchema;
|
|
12
12
|
};
|
|
13
|
-
type SolanaNetwork = 'mainnet' | 'devnet' | 'testnet';
|
|
14
13
|
export declare abstract class SolWalletConnector extends WalletConnectorBase implements IHardwareWalletConnector {
|
|
15
14
|
isHardwareWalletEnabled: boolean;
|
|
16
|
-
_network: SolanaNetwork | undefined;
|
|
17
15
|
verifiedCredentials: JwtVerifiedCredential[];
|
|
18
16
|
solNetworks: GenericNetwork[];
|
|
19
17
|
supportedChains: Chain[];
|
|
20
18
|
connectedChain: Chain;
|
|
21
19
|
constructor(opts: SolWalletConnectorOpts);
|
|
22
20
|
getNetwork(): Promise<string>;
|
|
21
|
+
endSession(): Promise<void>;
|
|
23
22
|
getWalletClient(): Connection;
|
|
24
23
|
getPublicClient(): Promise<Connection | undefined>;
|
|
25
24
|
abstract getSigner(): Promise<ISolana | undefined>;
|
|
@@ -34,4 +33,3 @@ export declare abstract class SolWalletConnector extends WalletConnectorBase imp
|
|
|
34
33
|
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
|
|
35
34
|
isLedgerAddress(address: string): boolean;
|
|
36
35
|
}
|
|
37
|
-
export {};
|
|
@@ -5,6 +5,7 @@ import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
|
5
5
|
import { DynamicError, NotSupportedError, isLedgerAddressViaVerifiedCredentials } from '@dynamic-labs/utils';
|
|
6
6
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
7
7
|
import { extractNonce } from './utils/extractNonce.js';
|
|
8
|
+
import { getGenesisHashLSKey } from './utils/getGenesisHashLSKey.js';
|
|
8
9
|
|
|
9
10
|
const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
|
|
10
11
|
class SolWalletConnector extends WalletConnectorBase {
|
|
@@ -12,7 +13,6 @@ class SolWalletConnector extends WalletConnectorBase {
|
|
|
12
13
|
var _a;
|
|
13
14
|
super(opts);
|
|
14
15
|
this.isHardwareWalletEnabled = false;
|
|
15
|
-
this._network = undefined;
|
|
16
16
|
this.verifiedCredentials = [];
|
|
17
17
|
this.supportedChains = ['SOL'];
|
|
18
18
|
this.connectedChain = 'SOL';
|
|
@@ -22,11 +22,12 @@ class SolWalletConnector extends WalletConnectorBase {
|
|
|
22
22
|
}
|
|
23
23
|
getNetwork() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
if (this._network) {
|
|
26
|
-
return this._network;
|
|
27
|
-
}
|
|
28
25
|
const provider = this.getWalletClient();
|
|
29
|
-
let genesisHash =
|
|
26
|
+
let genesisHash = localStorage.getItem(getGenesisHashLSKey(provider.rpcEndpoint));
|
|
27
|
+
if (!genesisHash) {
|
|
28
|
+
genesisHash = yield provider.getGenesisHash();
|
|
29
|
+
localStorage.setItem(getGenesisHashLSKey(provider.rpcEndpoint), genesisHash);
|
|
30
|
+
}
|
|
30
31
|
genesisHash = genesisHash.substring(0, 32);
|
|
31
32
|
// see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
|
|
32
33
|
let network;
|
|
@@ -39,10 +40,14 @@ class SolWalletConnector extends WalletConnectorBase {
|
|
|
39
40
|
else {
|
|
40
41
|
network = 'testnet';
|
|
41
42
|
}
|
|
42
|
-
this._network = network;
|
|
43
43
|
return network;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
endSession() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
localStorage.removeItem(getGenesisHashLSKey(this.getWalletClient().rpcEndpoint));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
46
51
|
getWalletClient() {
|
|
47
52
|
var _a;
|
|
48
53
|
const [network] = this.solNetworks;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var contants = require('../contants.cjs');
|
|
7
|
+
|
|
8
|
+
const getGenesisHashLSKey = (rpcEndpoint) => `${rpcEndpoint}_${contants.SOLANA_GENESIS_HASH}`;
|
|
9
|
+
|
|
10
|
+
exports.getGenesisHashLSKey = getGenesisHashLSKey;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGenesisHashLSKey: (rpcEndpoint: string) => string;
|