@dynamic-labs/cosmos 4.9.10 → 4.9.12
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 +17 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +6 -6
- package/src/connectors/CosmosWalletConnector.cjs +8 -3
- package/src/connectors/CosmosWalletConnector.d.ts +3 -2
- package/src/connectors/CosmosWalletConnector.js +8 -3
- package/src/connectors/KeplrWalletConnector.cjs +34 -0
- package/src/connectors/KeplrWalletConnector.d.ts +1 -0
- package/src/connectors/KeplrWalletConnector.js +34 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.9.12](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.11...v4.9.12) (2025-03-28)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* prevent event subscription from throwing a page error ([#8393](https://github.com/dynamic-labs/dynamic-auth/issues/8393)) ([eda85cd](https://github.com/dynamic-labs/dynamic-auth/commit/eda85cdeed4cc208e20618882cf3e5a54b176356))
|
|
8
|
+
* global wallet popup in rainbowkit reopening ([#8395](https://github.com/dynamic-labs/dynamic-auth/issues/8395)) ([5473e87](https://github.com/dynamic-labs/dynamic-auth/commit/5473e87834c5a2102f7d87fc649590726bc390c7))
|
|
9
|
+
* notify user when sei is not enable in keplr ([#8396](https://github.com/dynamic-labs/dynamic-auth/issues/8396)) ([79aea59](https://github.com/dynamic-labs/dynamic-auth/commit/79aea59bde82dabbe070a1f0fc5ac484a696e7ac))
|
|
10
|
+
* respect tokenBalance order from backend for SendBalance view ([#8398](https://github.com/dynamic-labs/dynamic-auth/issues/8398)) ([fdb0e1c](https://github.com/dynamic-labs/dynamic-auth/commit/fdb0e1cc2f1614326f506dfdb1726f4c5baf9c0c))
|
|
11
|
+
|
|
12
|
+
### [4.9.11](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.10...v4.9.11) (2025-03-26)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* ensure global wallet users can disconnect from dapp ([#8389](https://github.com/dynamic-labs/dynamic-auth/issues/8389)) ([79e5892](https://github.com/dynamic-labs/dynamic-auth/commit/79e58921de673757dc0662977ed4eb391aaaf632))
|
|
18
|
+
|
|
2
19
|
### [4.9.10](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.9...v4.9.10) (2025-03-26)
|
|
3
20
|
|
|
4
21
|
|
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.9.
|
|
3
|
+
"version": "4.9.12",
|
|
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.9.
|
|
23
|
-
"@dynamic-labs/types": "4.9.
|
|
24
|
-
"@dynamic-labs/utils": "4.9.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.9.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.9.
|
|
22
|
+
"@dynamic-labs/assert-package-version": "4.9.12",
|
|
23
|
+
"@dynamic-labs/types": "4.9.12",
|
|
24
|
+
"@dynamic-labs/utils": "4.9.12",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.9.12",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.9.12"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {}
|
|
29
29
|
}
|
|
@@ -15,14 +15,19 @@ class CosmosWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
15
15
|
this.ChainWallet = CosmosWallet.CosmosWallet;
|
|
16
16
|
this.connectedChain = 'COSMOS';
|
|
17
17
|
this.supportedChains = ['COSMOS'];
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
18
|
+
this.cosmosNetworks = opts.cosmosNetworks;
|
|
19
|
+
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
20
|
+
}
|
|
21
|
+
get evmNetworks() {
|
|
22
|
+
return utils.parseCosmosNetworks(this.cosmosNetworks);
|
|
23
|
+
}
|
|
24
|
+
get chainIdMapping() {
|
|
25
|
+
return this.evmNetworks.map((network) => ({
|
|
20
26
|
bech32Prefix: network.bech32Prefix,
|
|
21
27
|
cosmosNetwork: network,
|
|
22
28
|
cosmosNetworkId: network.name,
|
|
23
29
|
dynamicChainId: utils.parseChainId(network.networkId),
|
|
24
30
|
}));
|
|
25
|
-
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
26
31
|
}
|
|
27
32
|
getSelectedChain() {
|
|
28
33
|
const selectedNetwork = this.chainIdMapping.find((mapping) => mapping.cosmosNetworkId === this.getChainId());
|
|
@@ -28,13 +28,14 @@ type CosmosChainIDMapObject = {
|
|
|
28
28
|
};
|
|
29
29
|
export declare const DYNAMIC_COSMOS_NETWORK_ID = "dynamic_cosmos_network_id";
|
|
30
30
|
export declare abstract class CosmosWalletConnector extends WalletConnectorBase {
|
|
31
|
-
|
|
31
|
+
cosmosNetworks: GenericNetwork[];
|
|
32
32
|
ChainWallet: typeof CosmosWallet;
|
|
33
33
|
connectedChain: Chain;
|
|
34
34
|
supportedChains: Chain[];
|
|
35
|
-
chainIdMapping: CosmosChainIDMapObject[];
|
|
36
35
|
constructor(opts: CosmosWalletConnectorOpts);
|
|
37
36
|
protected abstract getWallet(): KeplrWallet | undefined;
|
|
37
|
+
get evmNetworks(): CosmosNetwork[];
|
|
38
|
+
get chainIdMapping(): CosmosChainIDMapObject[];
|
|
38
39
|
getSelectedChain(): CosmosNetwork | undefined;
|
|
39
40
|
getNetwork(): Promise<number | undefined>;
|
|
40
41
|
getLcdUrl(): string | undefined;
|
|
@@ -11,14 +11,19 @@ class CosmosWalletConnector extends WalletConnectorBase {
|
|
|
11
11
|
this.ChainWallet = CosmosWallet;
|
|
12
12
|
this.connectedChain = 'COSMOS';
|
|
13
13
|
this.supportedChains = ['COSMOS'];
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
14
|
+
this.cosmosNetworks = opts.cosmosNetworks;
|
|
15
|
+
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
16
|
+
}
|
|
17
|
+
get evmNetworks() {
|
|
18
|
+
return parseCosmosNetworks(this.cosmosNetworks);
|
|
19
|
+
}
|
|
20
|
+
get chainIdMapping() {
|
|
21
|
+
return this.evmNetworks.map((network) => ({
|
|
16
22
|
bech32Prefix: network.bech32Prefix,
|
|
17
23
|
cosmosNetwork: network,
|
|
18
24
|
cosmosNetworkId: network.name,
|
|
19
25
|
dynamicChainId: parseChainId(network.networkId),
|
|
20
26
|
}));
|
|
21
|
-
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
22
27
|
}
|
|
23
28
|
getSelectedChain() {
|
|
24
29
|
const selectedNetwork = this.chainIdMapping.find((mapping) => mapping.cosmosNetworkId === this.getChainId());
|
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
8
|
var CosmosWalletConnector = require('./CosmosWalletConnector.cjs');
|
|
8
9
|
|
|
10
|
+
const isSeiNotEnabledError = (error) => {
|
|
11
|
+
if (!error ||
|
|
12
|
+
!Object.prototype.hasOwnProperty.call(error, 'message') ||
|
|
13
|
+
typeof error.message !== 'string')
|
|
14
|
+
return false;
|
|
15
|
+
return error.message.includes('There is no modular chain info for pacific-1');
|
|
16
|
+
};
|
|
9
17
|
class KeplrWalletConnector extends CosmosWalletConnector.CosmosWalletConnector {
|
|
10
18
|
constructor() {
|
|
11
19
|
super(...arguments);
|
|
@@ -22,6 +30,32 @@ class KeplrWalletConnector extends CosmosWalletConnector.CosmosWalletConnector {
|
|
|
22
30
|
}
|
|
23
31
|
return window.keplr;
|
|
24
32
|
}
|
|
33
|
+
connect() {
|
|
34
|
+
const _super = Object.create(null, {
|
|
35
|
+
connect: { get: () => super.connect }
|
|
36
|
+
});
|
|
37
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
yield _super.connect.call(this);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (isSeiNotEnabledError(error)) {
|
|
43
|
+
/**
|
|
44
|
+
* If only Sei is enabled, throw the error
|
|
45
|
+
* to inform the user to enable Sei in Keplr
|
|
46
|
+
*/
|
|
47
|
+
if (this.cosmosNetworks.length === 1) {
|
|
48
|
+
throw new utils.SeiNotEnabledInKeplrWalletError();
|
|
49
|
+
}
|
|
50
|
+
this.cosmosNetworks = this.cosmosNetworks.filter((network) => network.name !== 'pacific-1');
|
|
51
|
+
yield _super.connect.call(this);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
25
59
|
setupEventListeners() {
|
|
26
60
|
window.addEventListener('keplr_keystorechange', this._handleAccountChange);
|
|
27
61
|
}
|
|
@@ -10,6 +10,7 @@ export declare class KeplrWalletConnector extends CosmosWalletConnector {
|
|
|
10
10
|
switchNetworkOnlyFromWallet: boolean;
|
|
11
11
|
supportsNetworkSwitching(): boolean;
|
|
12
12
|
getWallet(): KeplrWallet | undefined;
|
|
13
|
+
connect(): Promise<void>;
|
|
13
14
|
setupEventListeners(): void;
|
|
14
15
|
teardownEventListeners(): void;
|
|
15
16
|
switchNetwork({ networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { SeiNotEnabledInKeplrWalletError } from '@dynamic-labs/utils';
|
|
3
4
|
import { CosmosWalletConnector } from './CosmosWalletConnector.js';
|
|
4
5
|
|
|
6
|
+
const isSeiNotEnabledError = (error) => {
|
|
7
|
+
if (!error ||
|
|
8
|
+
!Object.prototype.hasOwnProperty.call(error, 'message') ||
|
|
9
|
+
typeof error.message !== 'string')
|
|
10
|
+
return false;
|
|
11
|
+
return error.message.includes('There is no modular chain info for pacific-1');
|
|
12
|
+
};
|
|
5
13
|
class KeplrWalletConnector extends CosmosWalletConnector {
|
|
6
14
|
constructor() {
|
|
7
15
|
super(...arguments);
|
|
@@ -18,6 +26,32 @@ class KeplrWalletConnector extends CosmosWalletConnector {
|
|
|
18
26
|
}
|
|
19
27
|
return window.keplr;
|
|
20
28
|
}
|
|
29
|
+
connect() {
|
|
30
|
+
const _super = Object.create(null, {
|
|
31
|
+
connect: { get: () => super.connect }
|
|
32
|
+
});
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
try {
|
|
35
|
+
yield _super.connect.call(this);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (isSeiNotEnabledError(error)) {
|
|
39
|
+
/**
|
|
40
|
+
* If only Sei is enabled, throw the error
|
|
41
|
+
* to inform the user to enable Sei in Keplr
|
|
42
|
+
*/
|
|
43
|
+
if (this.cosmosNetworks.length === 1) {
|
|
44
|
+
throw new SeiNotEnabledInKeplrWalletError();
|
|
45
|
+
}
|
|
46
|
+
this.cosmosNetworks = this.cosmosNetworks.filter((network) => network.name !== 'pacific-1');
|
|
47
|
+
yield _super.connect.call(this);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
21
55
|
setupEventListeners() {
|
|
22
56
|
window.addEventListener('keplr_keystorechange', this._handleAccountChange);
|
|
23
57
|
}
|