@dynamic-labs/cosmos 4.19.2 → 4.19.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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +6 -6
- package/src/CosmosWalletConnectorsWithConfig.cjs +23 -0
- package/src/CosmosWalletConnectorsWithConfig.d.ts +6 -0
- package/src/CosmosWalletConnectorsWithConfig.js +19 -0
- package/src/connectors/CosmosWalletConnector.cjs +58 -1
- package/src/connectors/CosmosWalletConnector.d.ts +10 -1
- package/src/connectors/CosmosWalletConnector.js +58 -1
- package/src/connectors/KeplrWalletConnector.cjs +6 -13
- package/src/connectors/KeplrWalletConnector.d.ts +0 -2
- package/src/connectors/KeplrWalletConnector.js +6 -13
- package/src/index.cjs +2 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.19.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.2...v4.19.3) (2025-05-28)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* rerender issue with Slush wallet pop up appearing multiple times ([#8817](https://github.com/dynamic-labs/dynamic-auth/issues/8817)) ([bea0da6](https://github.com/dynamic-labs/dynamic-auth/commit/bea0da647bab983610ebbf18a6ca66ba0ac569bf))
|
|
8
|
+
|
|
2
9
|
### [4.19.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.1...v4.19.2) (2025-05-27)
|
|
3
10
|
|
|
4
11
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/cosmos",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.3",
|
|
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",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@keplr-wallet/types": "0.12.121",
|
|
22
|
-
"@dynamic-labs/assert-package-version": "4.19.
|
|
23
|
-
"@dynamic-labs/types": "4.19.
|
|
24
|
-
"@dynamic-labs/utils": "4.19.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.19.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.19.
|
|
22
|
+
"@dynamic-labs/assert-package-version": "4.19.3",
|
|
23
|
+
"@dynamic-labs/types": "4.19.3",
|
|
24
|
+
"@dynamic-labs/utils": "4.19.3",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.19.3",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.19.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {}
|
|
29
29
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var index = require('./index.cjs');
|
|
7
|
+
|
|
8
|
+
const CosmosWalletConnectorsWithConfig = (connectionConfig) => {
|
|
9
|
+
// Idea here is to ensure that all wallet connectors are constructed with
|
|
10
|
+
// the client-provided connection configuration, so we "wrap" the constructors with it.
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
const classWithConfig = (className) => class extends className {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
const [opts] = args;
|
|
16
|
+
super(Object.assign(Object.assign({}, opts), { connectionConfig }));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
return () => index.CosmosWalletConnectors().map(classWithConfig);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.CosmosWalletConnectorsWithConfig = CosmosWalletConnectorsWithConfig;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChainInfo } from '@keplr-wallet/types';
|
|
2
|
+
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
export type CosmosConnectorConfig = {
|
|
4
|
+
experimentalChainInfo: ChainInfo[] | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const CosmosWalletConnectorsWithConfig: (connectionConfig: CosmosConnectorConfig) => () => WalletConnectorConstructor[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { CosmosWalletConnectors } from './index.js';
|
|
3
|
+
|
|
4
|
+
const CosmosWalletConnectorsWithConfig = (connectionConfig) => {
|
|
5
|
+
// Idea here is to ensure that all wallet connectors are constructed with
|
|
6
|
+
// the client-provided connection configuration, so we "wrap" the constructors with it.
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
const classWithConfig = (className) => class extends className {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
constructor(...args) {
|
|
11
|
+
const [opts] = args;
|
|
12
|
+
super(Object.assign(Object.assign({}, opts), { connectionConfig }));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
return () => CosmosWalletConnectors().map(classWithConfig);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { CosmosWalletConnectorsWithConfig };
|
|
@@ -11,12 +11,50 @@ var CosmosWallet = require('../wallet/CosmosWallet.cjs');
|
|
|
11
11
|
const DYNAMIC_COSMOS_NETWORK_ID = 'dynamic_cosmos_network_id';
|
|
12
12
|
class CosmosWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
13
13
|
constructor(opts) {
|
|
14
|
+
var _a;
|
|
14
15
|
super(opts);
|
|
16
|
+
this.switchNetworkOnlyFromWallet = true;
|
|
15
17
|
this.ChainWallet = CosmosWallet.CosmosWallet;
|
|
16
18
|
this.connectedChain = 'COSMOS';
|
|
17
19
|
this.supportedChains = ['COSMOS'];
|
|
18
20
|
this.cosmosNetworks = opts.cosmosNetworks;
|
|
19
21
|
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
22
|
+
this.experimentalChainsInfo = (_a = opts.connectionConfig) === null || _a === void 0 ? void 0 : _a.experimentalChainInfo;
|
|
23
|
+
if (this.experimentalChainsInfo) {
|
|
24
|
+
this.addExperimentalChains();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
addExperimentalChains() {
|
|
28
|
+
var _a;
|
|
29
|
+
if (!this.experimentalChainsInfo) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (const experimentalChain of this.experimentalChainsInfo) {
|
|
33
|
+
const randomChainId = Math.random() * 10000;
|
|
34
|
+
const chainToNetwork = {
|
|
35
|
+
bech32Prefix: (_a = experimentalChain.bech32Config) === null || _a === void 0 ? void 0 : _a.bech32PrefixAccAddr,
|
|
36
|
+
blockExplorerUrls: [],
|
|
37
|
+
chainId: randomChainId,
|
|
38
|
+
iconUrls: [experimentalChain.chainSymbolImageUrl],
|
|
39
|
+
name: experimentalChain.chainId,
|
|
40
|
+
nativeCurrency: {
|
|
41
|
+
decimals: experimentalChain.currencies[0].coinDecimals,
|
|
42
|
+
name: experimentalChain.currencies[0].coinDenom,
|
|
43
|
+
symbol: experimentalChain.currencies[0].coinDenom,
|
|
44
|
+
},
|
|
45
|
+
networkId: randomChainId,
|
|
46
|
+
rpcUrls: [experimentalChain.rpc],
|
|
47
|
+
shortName: experimentalChain.chainName,
|
|
48
|
+
supportedChainIds: [experimentalChain.chainId],
|
|
49
|
+
supportedFeatures: [],
|
|
50
|
+
supportedMethods: [],
|
|
51
|
+
supportedSignMethods: [],
|
|
52
|
+
vanityName: experimentalChain.chainName,
|
|
53
|
+
};
|
|
54
|
+
if (!this.cosmosNetworks.find((network) => network.vanityName === chainToNetwork.vanityName)) {
|
|
55
|
+
this.cosmosNetworks.push(chainToNetwork);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
20
58
|
}
|
|
21
59
|
get evmNetworks() {
|
|
22
60
|
return utils.parseCosmosNetworks(this.cosmosNetworks);
|
|
@@ -27,8 +65,13 @@ class CosmosWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
27
65
|
cosmosNetwork: network,
|
|
28
66
|
cosmosNetworkId: network.name,
|
|
29
67
|
dynamicChainId: utils.parseChainId(network.networkId),
|
|
68
|
+
experimental: this.isExperimentalChain(network),
|
|
30
69
|
}));
|
|
31
70
|
}
|
|
71
|
+
isExperimentalChain(cosmosNetwork) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return ((_b = (_a = this.experimentalChainsInfo) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.chainId === cosmosNetwork.name)) !== null && _b !== void 0 ? _b : false);
|
|
74
|
+
}
|
|
32
75
|
getSelectedChain() {
|
|
33
76
|
const selectedNetwork = this.chainIdMapping.find((mapping) => mapping.cosmosNetworkId === this.getChainId());
|
|
34
77
|
return selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.cosmosNetwork;
|
|
@@ -121,7 +164,9 @@ class CosmosWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
121
164
|
connect() {
|
|
122
165
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
123
166
|
var _a;
|
|
124
|
-
yield ((_a = this.getWallet()) === null || _a === void 0 ? void 0 : _a.enable(this.chainIdMapping
|
|
167
|
+
yield ((_a = this.getWallet()) === null || _a === void 0 ? void 0 : _a.enable(this.chainIdMapping
|
|
168
|
+
.filter((mapping) => !mapping.experimental)
|
|
169
|
+
.map((mapping) => mapping.cosmosNetworkId)));
|
|
125
170
|
});
|
|
126
171
|
}
|
|
127
172
|
getAddress() {
|
|
@@ -189,6 +234,18 @@ class CosmosWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
189
234
|
return;
|
|
190
235
|
});
|
|
191
236
|
}
|
|
237
|
+
switchNetwork(_a) {
|
|
238
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
239
|
+
if (!networkChainId)
|
|
240
|
+
return;
|
|
241
|
+
this.chainIdMapping.forEach((mapping) => {
|
|
242
|
+
if (mapping.dynamicChainId === networkChainId) {
|
|
243
|
+
this.setChainId(mapping.cosmosNetworkId);
|
|
244
|
+
this.emit('chainChange', { chain: networkChainId.toString() });
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
}
|
|
192
249
|
}
|
|
193
250
|
|
|
194
251
|
exports.CosmosWalletConnector = CosmosWalletConnector;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Keplr as KeplrWallet, OfflineAminoSigner, OfflineDirectSigner } from '@keplr-wallet/types';
|
|
1
|
+
import { ChainInfo, Keplr as KeplrWallet, OfflineAminoSigner, OfflineDirectSigner } from '@keplr-wallet/types';
|
|
2
2
|
import { CosmosNetwork, GenericNetwork } from '@dynamic-labs/types';
|
|
3
3
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
4
4
|
import { Chain, WalletConnectorBase, WalletMetadata } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { CosmosWallet } from '../wallet';
|
|
6
|
+
import { CosmosConnectorConfig } from '../CosmosWalletConnectorsWithConfig';
|
|
7
|
+
import { SwitchNetworkOps } from './KeplrWalletConnector';
|
|
6
8
|
export interface IFetchBalanceResponse {
|
|
7
9
|
balances: IFetchBalanceBalance[];
|
|
8
10
|
pagination: IFetchBalancePagination;
|
|
@@ -19,23 +21,29 @@ export type CosmosWalletConnectorOpts = {
|
|
|
19
21
|
cosmosNetworks: GenericNetwork[];
|
|
20
22
|
walletBook: WalletBookSchema;
|
|
21
23
|
metadata?: WalletMetadata;
|
|
24
|
+
connectionConfig?: CosmosConnectorConfig;
|
|
22
25
|
};
|
|
23
26
|
type CosmosChainIDMapObject = {
|
|
24
27
|
dynamicChainId: number;
|
|
25
28
|
cosmosNetworkId: string;
|
|
26
29
|
bech32Prefix: string | undefined;
|
|
27
30
|
cosmosNetwork: CosmosNetwork;
|
|
31
|
+
experimental: boolean;
|
|
28
32
|
};
|
|
29
33
|
export declare const DYNAMIC_COSMOS_NETWORK_ID = "dynamic_cosmos_network_id";
|
|
30
34
|
export declare abstract class CosmosWalletConnector extends WalletConnectorBase {
|
|
31
35
|
cosmosNetworks: GenericNetwork[];
|
|
36
|
+
switchNetworkOnlyFromWallet: boolean;
|
|
32
37
|
ChainWallet: typeof CosmosWallet;
|
|
33
38
|
connectedChain: Chain;
|
|
34
39
|
supportedChains: Chain[];
|
|
40
|
+
experimentalChainsInfo: ChainInfo[] | undefined;
|
|
35
41
|
constructor(opts: CosmosWalletConnectorOpts);
|
|
42
|
+
private addExperimentalChains;
|
|
36
43
|
protected abstract getWallet(): KeplrWallet | undefined;
|
|
37
44
|
get evmNetworks(): CosmosNetwork[];
|
|
38
45
|
get chainIdMapping(): CosmosChainIDMapObject[];
|
|
46
|
+
isExperimentalChain(cosmosNetwork: CosmosNetwork): boolean;
|
|
39
47
|
getSelectedChain(): CosmosNetwork | undefined;
|
|
40
48
|
getNetwork(): Promise<number | undefined>;
|
|
41
49
|
getLcdUrl(): string | undefined;
|
|
@@ -58,5 +66,6 @@ export declare abstract class CosmosWalletConnector extends WalletConnectorBase
|
|
|
58
66
|
getEnabledNetworks(): GenericNetwork[];
|
|
59
67
|
supportsNetworkSwitching(): boolean;
|
|
60
68
|
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
69
|
+
switchNetwork({ networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
61
70
|
}
|
|
62
71
|
export {};
|
|
@@ -7,12 +7,50 @@ import { CosmosWallet } from '../wallet/CosmosWallet.js';
|
|
|
7
7
|
const DYNAMIC_COSMOS_NETWORK_ID = 'dynamic_cosmos_network_id';
|
|
8
8
|
class CosmosWalletConnector extends WalletConnectorBase {
|
|
9
9
|
constructor(opts) {
|
|
10
|
+
var _a;
|
|
10
11
|
super(opts);
|
|
12
|
+
this.switchNetworkOnlyFromWallet = true;
|
|
11
13
|
this.ChainWallet = CosmosWallet;
|
|
12
14
|
this.connectedChain = 'COSMOS';
|
|
13
15
|
this.supportedChains = ['COSMOS'];
|
|
14
16
|
this.cosmosNetworks = opts.cosmosNetworks;
|
|
15
17
|
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
18
|
+
this.experimentalChainsInfo = (_a = opts.connectionConfig) === null || _a === void 0 ? void 0 : _a.experimentalChainInfo;
|
|
19
|
+
if (this.experimentalChainsInfo) {
|
|
20
|
+
this.addExperimentalChains();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
addExperimentalChains() {
|
|
24
|
+
var _a;
|
|
25
|
+
if (!this.experimentalChainsInfo) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const experimentalChain of this.experimentalChainsInfo) {
|
|
29
|
+
const randomChainId = Math.random() * 10000;
|
|
30
|
+
const chainToNetwork = {
|
|
31
|
+
bech32Prefix: (_a = experimentalChain.bech32Config) === null || _a === void 0 ? void 0 : _a.bech32PrefixAccAddr,
|
|
32
|
+
blockExplorerUrls: [],
|
|
33
|
+
chainId: randomChainId,
|
|
34
|
+
iconUrls: [experimentalChain.chainSymbolImageUrl],
|
|
35
|
+
name: experimentalChain.chainId,
|
|
36
|
+
nativeCurrency: {
|
|
37
|
+
decimals: experimentalChain.currencies[0].coinDecimals,
|
|
38
|
+
name: experimentalChain.currencies[0].coinDenom,
|
|
39
|
+
symbol: experimentalChain.currencies[0].coinDenom,
|
|
40
|
+
},
|
|
41
|
+
networkId: randomChainId,
|
|
42
|
+
rpcUrls: [experimentalChain.rpc],
|
|
43
|
+
shortName: experimentalChain.chainName,
|
|
44
|
+
supportedChainIds: [experimentalChain.chainId],
|
|
45
|
+
supportedFeatures: [],
|
|
46
|
+
supportedMethods: [],
|
|
47
|
+
supportedSignMethods: [],
|
|
48
|
+
vanityName: experimentalChain.chainName,
|
|
49
|
+
};
|
|
50
|
+
if (!this.cosmosNetworks.find((network) => network.vanityName === chainToNetwork.vanityName)) {
|
|
51
|
+
this.cosmosNetworks.push(chainToNetwork);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
16
54
|
}
|
|
17
55
|
get evmNetworks() {
|
|
18
56
|
return parseCosmosNetworks(this.cosmosNetworks);
|
|
@@ -23,8 +61,13 @@ class CosmosWalletConnector extends WalletConnectorBase {
|
|
|
23
61
|
cosmosNetwork: network,
|
|
24
62
|
cosmosNetworkId: network.name,
|
|
25
63
|
dynamicChainId: parseChainId(network.networkId),
|
|
64
|
+
experimental: this.isExperimentalChain(network),
|
|
26
65
|
}));
|
|
27
66
|
}
|
|
67
|
+
isExperimentalChain(cosmosNetwork) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
return ((_b = (_a = this.experimentalChainsInfo) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.chainId === cosmosNetwork.name)) !== null && _b !== void 0 ? _b : false);
|
|
70
|
+
}
|
|
28
71
|
getSelectedChain() {
|
|
29
72
|
const selectedNetwork = this.chainIdMapping.find((mapping) => mapping.cosmosNetworkId === this.getChainId());
|
|
30
73
|
return selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.cosmosNetwork;
|
|
@@ -117,7 +160,9 @@ class CosmosWalletConnector extends WalletConnectorBase {
|
|
|
117
160
|
connect() {
|
|
118
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
162
|
var _a;
|
|
120
|
-
yield ((_a = this.getWallet()) === null || _a === void 0 ? void 0 : _a.enable(this.chainIdMapping
|
|
163
|
+
yield ((_a = this.getWallet()) === null || _a === void 0 ? void 0 : _a.enable(this.chainIdMapping
|
|
164
|
+
.filter((mapping) => !mapping.experimental)
|
|
165
|
+
.map((mapping) => mapping.cosmosNetworkId)));
|
|
121
166
|
});
|
|
122
167
|
}
|
|
123
168
|
getAddress() {
|
|
@@ -185,6 +230,18 @@ class CosmosWalletConnector extends WalletConnectorBase {
|
|
|
185
230
|
return;
|
|
186
231
|
});
|
|
187
232
|
}
|
|
233
|
+
switchNetwork(_a) {
|
|
234
|
+
return __awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
235
|
+
if (!networkChainId)
|
|
236
|
+
return;
|
|
237
|
+
this.chainIdMapping.forEach((mapping) => {
|
|
238
|
+
if (mapping.dynamicChainId === networkChainId) {
|
|
239
|
+
this.setChainId(mapping.cosmosNetworkId);
|
|
240
|
+
this.emit('chainChange', { chain: networkChainId.toString() });
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
188
245
|
}
|
|
189
246
|
|
|
190
247
|
export { CosmosWalletConnector, DYNAMIC_COSMOS_NETWORK_ID };
|
|
@@ -19,7 +19,6 @@ class KeplrWalletConnector extends CosmosWalletConnector.CosmosWalletConnector {
|
|
|
19
19
|
super(...arguments);
|
|
20
20
|
this.name = 'Keplr';
|
|
21
21
|
this.overrideKey = 'keplr';
|
|
22
|
-
this.switchNetworkOnlyFromWallet = true;
|
|
23
22
|
}
|
|
24
23
|
supportsNetworkSwitching() {
|
|
25
24
|
return true;
|
|
@@ -35,8 +34,14 @@ class KeplrWalletConnector extends CosmosWalletConnector.CosmosWalletConnector {
|
|
|
35
34
|
connect: { get: () => super.connect }
|
|
36
35
|
});
|
|
37
36
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
var _a;
|
|
38
38
|
try {
|
|
39
39
|
yield _super.connect.call(this);
|
|
40
|
+
if (this.experimentalChainsInfo) {
|
|
41
|
+
for (const chain of this.experimentalChainsInfo) {
|
|
42
|
+
yield ((_a = this.getWallet()) === null || _a === void 0 ? void 0 : _a.experimentalSuggestChain(chain));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
catch (error) {
|
|
42
47
|
if (isSeiNotEnabledError(error)) {
|
|
@@ -63,18 +68,6 @@ class KeplrWalletConnector extends CosmosWalletConnector.CosmosWalletConnector {
|
|
|
63
68
|
window.removeEventListener('keplr_keystorechange', this._handleAccountChange);
|
|
64
69
|
this.setChainId(null);
|
|
65
70
|
}
|
|
66
|
-
switchNetwork(_a) {
|
|
67
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
68
|
-
if (!networkChainId)
|
|
69
|
-
return;
|
|
70
|
-
this.chainIdMapping.forEach((mapping) => {
|
|
71
|
-
if (mapping.dynamicChainId === networkChainId) {
|
|
72
|
-
this.setChainId(mapping.cosmosNetworkId);
|
|
73
|
-
this.emit('chainChange', { chain: networkChainId.toString() });
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
exports.KeplrWalletConnector = KeplrWalletConnector;
|
|
@@ -7,11 +7,9 @@ export type SwitchNetworkOps = {
|
|
|
7
7
|
export declare class KeplrWalletConnector extends CosmosWalletConnector {
|
|
8
8
|
name: string;
|
|
9
9
|
overrideKey: string;
|
|
10
|
-
switchNetworkOnlyFromWallet: boolean;
|
|
11
10
|
supportsNetworkSwitching(): boolean;
|
|
12
11
|
getWallet(): KeplrWallet | undefined;
|
|
13
12
|
connect(): Promise<void>;
|
|
14
13
|
setupEventListeners(): void;
|
|
15
14
|
teardownEventListeners(): void;
|
|
16
|
-
switchNetwork({ networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
17
15
|
}
|
|
@@ -15,7 +15,6 @@ class KeplrWalletConnector extends CosmosWalletConnector {
|
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this.name = 'Keplr';
|
|
17
17
|
this.overrideKey = 'keplr';
|
|
18
|
-
this.switchNetworkOnlyFromWallet = true;
|
|
19
18
|
}
|
|
20
19
|
supportsNetworkSwitching() {
|
|
21
20
|
return true;
|
|
@@ -31,8 +30,14 @@ class KeplrWalletConnector extends CosmosWalletConnector {
|
|
|
31
30
|
connect: { get: () => super.connect }
|
|
32
31
|
});
|
|
33
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a;
|
|
34
34
|
try {
|
|
35
35
|
yield _super.connect.call(this);
|
|
36
|
+
if (this.experimentalChainsInfo) {
|
|
37
|
+
for (const chain of this.experimentalChainsInfo) {
|
|
38
|
+
yield ((_a = this.getWallet()) === null || _a === void 0 ? void 0 : _a.experimentalSuggestChain(chain));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
catch (error) {
|
|
38
43
|
if (isSeiNotEnabledError(error)) {
|
|
@@ -59,18 +64,6 @@ class KeplrWalletConnector extends CosmosWalletConnector {
|
|
|
59
64
|
window.removeEventListener('keplr_keystorechange', this._handleAccountChange);
|
|
60
65
|
this.setChainId(null);
|
|
61
66
|
}
|
|
62
|
-
switchNetwork(_a) {
|
|
63
|
-
return __awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
|
|
64
|
-
if (!networkChainId)
|
|
65
|
-
return;
|
|
66
|
-
this.chainIdMapping.forEach((mapping) => {
|
|
67
|
-
if (mapping.dynamicChainId === networkChainId) {
|
|
68
|
-
this.setChainId(mapping.cosmosNetworkId);
|
|
69
|
-
this.emit('chainChange', { chain: networkChainId.toString() });
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
export { KeplrWalletConnector };
|
package/src/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ var CosmosWallet = require('./wallet/CosmosWallet.cjs');
|
|
|
13
13
|
var isCosmosWallet = require('./wallet/isCosmosWallet/isCosmosWallet.cjs');
|
|
14
14
|
var LeapWalletConnector = require('./connectors/LeapWalletConnector.cjs');
|
|
15
15
|
var CompassWalletConnector = require('./connectors/CompassWalletConnector.cjs');
|
|
16
|
+
var CosmosWalletConnectorsWithConfig = require('./CosmosWalletConnectorsWithConfig.cjs');
|
|
16
17
|
|
|
17
18
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/cosmos', _package.version);
|
|
18
19
|
const CosmosWalletConnectors = () => [
|
|
@@ -23,4 +24,5 @@ const CosmosWalletConnectors = () => [
|
|
|
23
24
|
|
|
24
25
|
exports.CosmosWallet = CosmosWallet.CosmosWallet;
|
|
25
26
|
exports.isCosmosWallet = isCosmosWallet.isCosmosWallet;
|
|
27
|
+
exports.CosmosWalletConnectorsWithConfig = CosmosWalletConnectorsWithConfig.CosmosWalletConnectorsWithConfig;
|
|
26
28
|
exports.CosmosWalletConnectors = CosmosWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ import { LeapWalletConnector } from './connectors/LeapWalletConnector';
|
|
|
3
3
|
export * from './wallet';
|
|
4
4
|
export { type ICosmosOfflineSigner, type ICosmosProvider } from './types';
|
|
5
5
|
export { type CosmosWalletConnector } from './connectors/CosmosWalletConnector';
|
|
6
|
+
export { type ChainInfo } from '@keplr-wallet/types';
|
|
7
|
+
export { CosmosWalletConnectorsWithConfig } from './CosmosWalletConnectorsWithConfig';
|
|
6
8
|
export declare const CosmosWalletConnectors: () => (typeof KeplrWalletConnector | typeof LeapWalletConnector | typeof CompassWalletConnector)[];
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { CosmosWallet } from './wallet/CosmosWallet.js';
|
|
|
9
9
|
export { isCosmosWallet } from './wallet/isCosmosWallet/isCosmosWallet.js';
|
|
10
10
|
import { LeapWalletConnector } from './connectors/LeapWalletConnector.js';
|
|
11
11
|
import { CompassWalletConnector } from './connectors/CompassWalletConnector.js';
|
|
12
|
+
export { CosmosWalletConnectorsWithConfig } from './CosmosWalletConnectorsWithConfig.js';
|
|
12
13
|
|
|
13
14
|
assertPackageVersion('@dynamic-labs/cosmos', version);
|
|
14
15
|
const CosmosWalletConnectors = () => [
|