@injectivelabs/wallet-cosmos 1.17.2-alpha.0 → 1.17.2-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/dist/cjs/index.cjs +49 -11
- package/dist/cjs/index.d.cts +1 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +48 -10
- package/package.json +10 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,10 +3,17 @@ let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
|
|
|
3
3
|
let __injectivelabs_sdk_ts_core_accounts = require("@injectivelabs/sdk-ts/core/accounts");
|
|
4
4
|
let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
|
|
5
5
|
let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
|
|
6
|
-
let __cosmjs_stargate = require("@cosmjs/stargate");
|
|
7
6
|
let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
|
|
8
7
|
let __injectivelabs_sdk_ts_core_tx = require("@injectivelabs/sdk-ts/core/tx");
|
|
9
8
|
|
|
9
|
+
//#region src/lib.ts
|
|
10
|
+
let cachedSigningStargateClient = null;
|
|
11
|
+
const loadSigningStargateClient = async () => {
|
|
12
|
+
if (!cachedSigningStargateClient) cachedSigningStargateClient = (await import("@cosmjs/stargate")).SigningStargateClient;
|
|
13
|
+
return cachedSigningStargateClient;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
10
17
|
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
11
18
|
function _typeof(o) {
|
|
12
19
|
"@babel/helpers - typeof";
|
|
@@ -50,7 +57,7 @@ function _defineProperty(e, r, t) {
|
|
|
50
57
|
|
|
51
58
|
//#endregion
|
|
52
59
|
//#region src/wallet.ts
|
|
53
|
-
const
|
|
60
|
+
const getWindow = () => typeof window !== "undefined" ? window : {};
|
|
54
61
|
var CosmosWallet = class CosmosWallet {
|
|
55
62
|
constructor({ wallet, chainId }) {
|
|
56
63
|
_defineProperty(this, "wallet", void 0);
|
|
@@ -167,14 +174,15 @@ var CosmosWallet = class CosmosWallet {
|
|
|
167
174
|
const cosmosWallet = await this.getCosmosWallet();
|
|
168
175
|
if (![__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.OWallet].includes(wallet)) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`signAndBroadcastAminoUsingCosmjs is not support on ${(0, __injectivelabs_utils.capitalize)(wallet)}`));
|
|
169
176
|
if (!endpoints.rpc) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error(`Please provide rpc endpoint`));
|
|
177
|
+
const SigningStargateClient = await loadSigningStargateClient();
|
|
170
178
|
const offlineSigner = cosmosWallet.getOfflineSignerOnlyAmino(chainId);
|
|
171
179
|
const [account] = await offlineSigner.getAccounts();
|
|
172
|
-
return await (await
|
|
180
|
+
return await (await SigningStargateClient.connectWithSigner(endpoints.rpc, offlineSigner)).signAndBroadcast(account.address, messages, stdFee);
|
|
173
181
|
}
|
|
174
182
|
async signArbitrary({ data, signer }) {
|
|
175
183
|
const { chainId, wallet } = this;
|
|
176
184
|
const cosmosWallet = await this.getCosmosWallet();
|
|
177
|
-
if (
|
|
185
|
+
if (![__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.Cosmostation].includes(wallet)) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`signArbitrary is not supported on ${(0, __injectivelabs_utils.capitalize)(wallet)}`));
|
|
178
186
|
try {
|
|
179
187
|
return (await cosmosWallet.signArbitrary(chainId, signer, data)).signature;
|
|
180
188
|
} catch (e) {
|
|
@@ -199,16 +207,36 @@ var CosmosWallet = class CosmosWallet {
|
|
|
199
207
|
}
|
|
200
208
|
async checkChainIdSupport() {
|
|
201
209
|
const { chainId, wallet } = this;
|
|
202
|
-
const cosmos = this.getCosmos();
|
|
203
210
|
const chainName = chainId.split("-");
|
|
211
|
+
if (wallet === __injectivelabs_wallet_base.Wallet.Cosmostation) return this.checkCosmostationChainSupport();
|
|
212
|
+
const cosmos = this.getCosmos();
|
|
204
213
|
try {
|
|
205
214
|
return !!await cosmos.getKey(chainId);
|
|
206
215
|
} catch (_unused) {
|
|
207
216
|
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`${(0, __injectivelabs_utils.capitalize)(wallet)} doesn't support ${chainName[0] || chainId} network. Please use another Cosmos wallet`));
|
|
208
217
|
}
|
|
209
218
|
}
|
|
219
|
+
async checkCosmostationChainSupport() {
|
|
220
|
+
var _$window$cosmostation;
|
|
221
|
+
const { chainId } = this;
|
|
222
|
+
const $window = getWindow();
|
|
223
|
+
const chainName = chainId.split("-");
|
|
224
|
+
if (!((_$window$cosmostation = $window.cosmostation) === null || _$window$cosmostation === void 0 ? void 0 : _$window$cosmostation.cosmos)) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("Please install the Cosmostation extension"), {
|
|
225
|
+
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
226
|
+
type: __injectivelabs_exceptions.ErrorType.WalletNotInstalledError,
|
|
227
|
+
contextModule: __injectivelabs_wallet_base.Wallet.Cosmostation
|
|
228
|
+
});
|
|
229
|
+
try {
|
|
230
|
+
if (!(await $window.cosmostation.cosmos.request({ method: "cos_supportedChainIds" })).official.includes(chainId)) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`Cosmostation doesn't support ${chainName[0] || chainId} network. Please use another Cosmos wallet`));
|
|
231
|
+
return true;
|
|
232
|
+
} catch (e) {
|
|
233
|
+
if (e instanceof __injectivelabs_exceptions.CosmosWalletException) throw e;
|
|
234
|
+
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
210
237
|
getCosmos() {
|
|
211
238
|
const { wallet } = this;
|
|
239
|
+
const $window = getWindow();
|
|
212
240
|
if (!$window) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`Please install ${(0, __injectivelabs_utils.capitalize)(wallet)} extension`), {
|
|
213
241
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
214
242
|
type: __injectivelabs_exceptions.ErrorType.WalletNotInstalledError,
|
|
@@ -219,6 +247,10 @@ var CosmosWallet = class CosmosWallet {
|
|
|
219
247
|
if (wallet === __injectivelabs_wallet_base.Wallet.Keplr) cosmos = $window.keplr;
|
|
220
248
|
if (wallet === __injectivelabs_wallet_base.Wallet.Ninji) cosmos = $window.ninji;
|
|
221
249
|
if (wallet === __injectivelabs_wallet_base.Wallet.Leap) cosmos = $window.leap;
|
|
250
|
+
if (wallet === __injectivelabs_wallet_base.Wallet.Cosmostation) {
|
|
251
|
+
var _$window$cosmostation2;
|
|
252
|
+
cosmos = (_$window$cosmostation2 = $window.cosmostation) === null || _$window$cosmostation2 === void 0 || (_$window$cosmostation2 = _$window$cosmostation2.providers) === null || _$window$cosmostation2 === void 0 ? void 0 : _$window$cosmostation2.keplr;
|
|
253
|
+
}
|
|
222
254
|
if (!cosmos) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`Please install ${(0, __injectivelabs_utils.capitalize)(wallet)} extension`), {
|
|
223
255
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
224
256
|
type: __injectivelabs_exceptions.ErrorType.WalletNotInstalledError,
|
|
@@ -258,18 +290,22 @@ const cosmosWallets$1 = [
|
|
|
258
290
|
__injectivelabs_wallet_base.Wallet.Leap,
|
|
259
291
|
__injectivelabs_wallet_base.Wallet.Ninji,
|
|
260
292
|
__injectivelabs_wallet_base.Wallet.Keplr,
|
|
261
|
-
__injectivelabs_wallet_base.Wallet.OWallet
|
|
293
|
+
__injectivelabs_wallet_base.Wallet.OWallet,
|
|
294
|
+
__injectivelabs_wallet_base.Wallet.Cosmostation
|
|
262
295
|
];
|
|
263
296
|
|
|
264
297
|
//#endregion
|
|
265
298
|
//#region src/utils/index.ts
|
|
266
299
|
const isCosmosWalletInstalled = (wallet) => {
|
|
267
|
-
const $window
|
|
300
|
+
const $window = typeof window !== "undefined" ? window : {};
|
|
268
301
|
switch (wallet) {
|
|
269
|
-
case __injectivelabs_wallet_base.Wallet.Keplr: return $window
|
|
270
|
-
case __injectivelabs_wallet_base.Wallet.Ninji: return $window
|
|
271
|
-
case __injectivelabs_wallet_base.Wallet.Leap: return $window
|
|
272
|
-
case __injectivelabs_wallet_base.Wallet.OWallet: return $window
|
|
302
|
+
case __injectivelabs_wallet_base.Wallet.Keplr: return $window.keplr !== void 0;
|
|
303
|
+
case __injectivelabs_wallet_base.Wallet.Ninji: return $window.ninji !== void 0;
|
|
304
|
+
case __injectivelabs_wallet_base.Wallet.Leap: return $window.leap !== void 0;
|
|
305
|
+
case __injectivelabs_wallet_base.Wallet.OWallet: return $window.oWallet !== void 0;
|
|
306
|
+
case __injectivelabs_wallet_base.Wallet.Cosmostation:
|
|
307
|
+
var _$window$cosmostation;
|
|
308
|
+
return ((_$window$cosmostation = $window.cosmostation) === null || _$window$cosmostation === void 0 || (_$window$cosmostation = _$window$cosmostation.providers) === null || _$window$cosmostation === void 0 ? void 0 : _$window$cosmostation.keplr) !== void 0;
|
|
273
309
|
default: return false;
|
|
274
310
|
}
|
|
275
311
|
};
|
|
@@ -319,6 +355,7 @@ var CosmosWalletStrategy = class extends __injectivelabs_wallet_base.BaseConcret
|
|
|
319
355
|
if (wallet === __injectivelabs_wallet_base.Wallet.Ninji) window.ninji.off("accountsChanged", this.listeners[__injectivelabs_wallet_base.WalletEventListener.AccountChange]);
|
|
320
356
|
if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.OWallet].includes(wallet)) window.removeEventListener("keplr_keystorechange", this.listeners[__injectivelabs_wallet_base.WalletEventListener.AccountChange]);
|
|
321
357
|
if (wallet === __injectivelabs_wallet_base.Wallet.Leap) window.removeEventListener("leap_keystorechange", this.listeners[__injectivelabs_wallet_base.WalletEventListener.AccountChange]);
|
|
358
|
+
if (wallet === __injectivelabs_wallet_base.Wallet.Cosmostation) window.removeEventListener("cosmostation_keystorechange", this.listeners[__injectivelabs_wallet_base.WalletEventListener.AccountChange]);
|
|
322
359
|
}
|
|
323
360
|
this.listeners = {};
|
|
324
361
|
}
|
|
@@ -437,6 +474,7 @@ var CosmosWalletStrategy = class extends __injectivelabs_wallet_base.BaseConcret
|
|
|
437
474
|
if (wallet === __injectivelabs_wallet_base.Wallet.Ninji) window.ninji.on("accountsChanged", listener);
|
|
438
475
|
if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.OWallet].includes(wallet)) window.addEventListener("keplr_keystorechange", listener);
|
|
439
476
|
if (wallet === __injectivelabs_wallet_base.Wallet.Leap) window.addEventListener("leap_keystorechange", listener);
|
|
477
|
+
if (wallet === __injectivelabs_wallet_base.Wallet.Cosmostation) window.addEventListener("cosmostation_keystorechange", listener);
|
|
440
478
|
}
|
|
441
479
|
getCosmosWallet(chainId) {
|
|
442
480
|
const { wallet, cosmosWallet } = this;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -82,6 +82,7 @@ declare class CosmosWallet {
|
|
|
82
82
|
signDoc: StdSignDoc$1;
|
|
83
83
|
}): Promise<AminoSignResponse>;
|
|
84
84
|
checkChainIdSupport(): Promise<boolean>;
|
|
85
|
+
private checkCosmostationChainSupport;
|
|
85
86
|
private getCosmos;
|
|
86
87
|
disableGasCheck(): Promise<void>;
|
|
87
88
|
enableGasCheck(): Promise<void>;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, StdSignDoc, Wallet, WalletDeviceType } from "@injectivelabs/wallet-base";
|
|
2
|
-
import * as _cosmjs_stargate0 from "@cosmjs/stargate";
|
|
3
|
-
import { StdFee } from "@cosmjs/stargate";
|
|
4
2
|
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
5
3
|
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
4
|
+
import * as _cosmjs_stargate0 from "@cosmjs/stargate";
|
|
5
|
+
import { StdFee } from "@cosmjs/stargate";
|
|
6
6
|
import { AccountAddress, ChainId, CosmosChainId, EvmChainId, TestnetCosmosChainId } from "@injectivelabs/ts-types";
|
|
7
7
|
import * as _keplr_wallet_types0 from "@keplr-wallet/types";
|
|
8
8
|
import { AminoSignResponse, Keplr, OfflineAminoSigner, StdSignDoc as StdSignDoc$1 } from "@keplr-wallet/types";
|
|
@@ -82,6 +82,7 @@ declare class CosmosWallet {
|
|
|
82
82
|
signDoc: StdSignDoc$1;
|
|
83
83
|
}): Promise<AminoSignResponse>;
|
|
84
84
|
checkChainIdSupport(): Promise<boolean>;
|
|
85
|
+
private checkCosmostationChainSupport;
|
|
85
86
|
private getCosmos;
|
|
86
87
|
disableGasCheck(): Promise<void>;
|
|
87
88
|
enableGasCheck(): Promise<void>;
|
package/dist/esm/index.js
CHANGED
|
@@ -3,10 +3,17 @@ import { BaseConcreteStrategy, BroadcastMode, Wallet, WalletAction, WalletDevice
|
|
|
3
3
|
import { PublicKey } from "@injectivelabs/sdk-ts/core/accounts";
|
|
4
4
|
import { stringToUint8Array, uint8ArrayToBase64, uint8ArrayToHex } from "@injectivelabs/sdk-ts/utils";
|
|
5
5
|
import { CosmosWalletException, ErrorType, GeneralException, TransactionException, UnspecifiedErrorCode, WalletErrorActionModule } from "@injectivelabs/exceptions";
|
|
6
|
-
import { SigningStargateClient } from "@cosmjs/stargate";
|
|
7
6
|
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
8
7
|
import { createSignDocFromTransaction, createTxRawFromSigResponse, waitTxBroadcasted } from "@injectivelabs/sdk-ts/core/tx";
|
|
9
8
|
|
|
9
|
+
//#region src/lib.ts
|
|
10
|
+
let cachedSigningStargateClient = null;
|
|
11
|
+
const loadSigningStargateClient = async () => {
|
|
12
|
+
if (!cachedSigningStargateClient) cachedSigningStargateClient = (await import("@cosmjs/stargate")).SigningStargateClient;
|
|
13
|
+
return cachedSigningStargateClient;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
10
17
|
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
11
18
|
function _typeof(o) {
|
|
12
19
|
"@babel/helpers - typeof";
|
|
@@ -50,7 +57,7 @@ function _defineProperty(e, r, t) {
|
|
|
50
57
|
|
|
51
58
|
//#endregion
|
|
52
59
|
//#region src/wallet.ts
|
|
53
|
-
const
|
|
60
|
+
const getWindow = () => typeof window !== "undefined" ? window : {};
|
|
54
61
|
var CosmosWallet = class CosmosWallet {
|
|
55
62
|
constructor({ wallet, chainId }) {
|
|
56
63
|
_defineProperty(this, "wallet", void 0);
|
|
@@ -167,6 +174,7 @@ var CosmosWallet = class CosmosWallet {
|
|
|
167
174
|
const cosmosWallet = await this.getCosmosWallet();
|
|
168
175
|
if (![Wallet.Keplr, Wallet.OWallet].includes(wallet)) throw new CosmosWalletException(/* @__PURE__ */ new Error(`signAndBroadcastAminoUsingCosmjs is not support on ${capitalize(wallet)}`));
|
|
169
176
|
if (!endpoints.rpc) throw new GeneralException(/* @__PURE__ */ new Error(`Please provide rpc endpoint`));
|
|
177
|
+
const SigningStargateClient = await loadSigningStargateClient();
|
|
170
178
|
const offlineSigner = cosmosWallet.getOfflineSignerOnlyAmino(chainId);
|
|
171
179
|
const [account] = await offlineSigner.getAccounts();
|
|
172
180
|
return await (await SigningStargateClient.connectWithSigner(endpoints.rpc, offlineSigner)).signAndBroadcast(account.address, messages, stdFee);
|
|
@@ -174,7 +182,7 @@ var CosmosWallet = class CosmosWallet {
|
|
|
174
182
|
async signArbitrary({ data, signer }) {
|
|
175
183
|
const { chainId, wallet } = this;
|
|
176
184
|
const cosmosWallet = await this.getCosmosWallet();
|
|
177
|
-
if (
|
|
185
|
+
if (![Wallet.Keplr, Wallet.Cosmostation].includes(wallet)) throw new CosmosWalletException(/* @__PURE__ */ new Error(`signArbitrary is not supported on ${capitalize(wallet)}`));
|
|
178
186
|
try {
|
|
179
187
|
return (await cosmosWallet.signArbitrary(chainId, signer, data)).signature;
|
|
180
188
|
} catch (e) {
|
|
@@ -199,16 +207,36 @@ var CosmosWallet = class CosmosWallet {
|
|
|
199
207
|
}
|
|
200
208
|
async checkChainIdSupport() {
|
|
201
209
|
const { chainId, wallet } = this;
|
|
202
|
-
const cosmos = this.getCosmos();
|
|
203
210
|
const chainName = chainId.split("-");
|
|
211
|
+
if (wallet === Wallet.Cosmostation) return this.checkCosmostationChainSupport();
|
|
212
|
+
const cosmos = this.getCosmos();
|
|
204
213
|
try {
|
|
205
214
|
return !!await cosmos.getKey(chainId);
|
|
206
215
|
} catch (_unused) {
|
|
207
216
|
throw new CosmosWalletException(/* @__PURE__ */ new Error(`${capitalize(wallet)} doesn't support ${chainName[0] || chainId} network. Please use another Cosmos wallet`));
|
|
208
217
|
}
|
|
209
218
|
}
|
|
219
|
+
async checkCosmostationChainSupport() {
|
|
220
|
+
var _$window$cosmostation;
|
|
221
|
+
const { chainId } = this;
|
|
222
|
+
const $window = getWindow();
|
|
223
|
+
const chainName = chainId.split("-");
|
|
224
|
+
if (!((_$window$cosmostation = $window.cosmostation) === null || _$window$cosmostation === void 0 ? void 0 : _$window$cosmostation.cosmos)) throw new CosmosWalletException(/* @__PURE__ */ new Error("Please install the Cosmostation extension"), {
|
|
225
|
+
code: UnspecifiedErrorCode,
|
|
226
|
+
type: ErrorType.WalletNotInstalledError,
|
|
227
|
+
contextModule: Wallet.Cosmostation
|
|
228
|
+
});
|
|
229
|
+
try {
|
|
230
|
+
if (!(await $window.cosmostation.cosmos.request({ method: "cos_supportedChainIds" })).official.includes(chainId)) throw new CosmosWalletException(/* @__PURE__ */ new Error(`Cosmostation doesn't support ${chainName[0] || chainId} network. Please use another Cosmos wallet`));
|
|
231
|
+
return true;
|
|
232
|
+
} catch (e) {
|
|
233
|
+
if (e instanceof CosmosWalletException) throw e;
|
|
234
|
+
throw new CosmosWalletException(new Error(e.message));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
210
237
|
getCosmos() {
|
|
211
238
|
const { wallet } = this;
|
|
239
|
+
const $window = getWindow();
|
|
212
240
|
if (!$window) throw new CosmosWalletException(/* @__PURE__ */ new Error(`Please install ${capitalize(wallet)} extension`), {
|
|
213
241
|
code: UnspecifiedErrorCode,
|
|
214
242
|
type: ErrorType.WalletNotInstalledError,
|
|
@@ -219,6 +247,10 @@ var CosmosWallet = class CosmosWallet {
|
|
|
219
247
|
if (wallet === Wallet.Keplr) cosmos = $window.keplr;
|
|
220
248
|
if (wallet === Wallet.Ninji) cosmos = $window.ninji;
|
|
221
249
|
if (wallet === Wallet.Leap) cosmos = $window.leap;
|
|
250
|
+
if (wallet === Wallet.Cosmostation) {
|
|
251
|
+
var _$window$cosmostation2;
|
|
252
|
+
cosmos = (_$window$cosmostation2 = $window.cosmostation) === null || _$window$cosmostation2 === void 0 || (_$window$cosmostation2 = _$window$cosmostation2.providers) === null || _$window$cosmostation2 === void 0 ? void 0 : _$window$cosmostation2.keplr;
|
|
253
|
+
}
|
|
222
254
|
if (!cosmos) throw new CosmosWalletException(/* @__PURE__ */ new Error(`Please install ${capitalize(wallet)} extension`), {
|
|
223
255
|
code: UnspecifiedErrorCode,
|
|
224
256
|
type: ErrorType.WalletNotInstalledError,
|
|
@@ -258,18 +290,22 @@ const cosmosWallets$1 = [
|
|
|
258
290
|
Wallet.Leap,
|
|
259
291
|
Wallet.Ninji,
|
|
260
292
|
Wallet.Keplr,
|
|
261
|
-
Wallet.OWallet
|
|
293
|
+
Wallet.OWallet,
|
|
294
|
+
Wallet.Cosmostation
|
|
262
295
|
];
|
|
263
296
|
|
|
264
297
|
//#endregion
|
|
265
298
|
//#region src/utils/index.ts
|
|
266
299
|
const isCosmosWalletInstalled = (wallet) => {
|
|
267
|
-
const $window
|
|
300
|
+
const $window = typeof window !== "undefined" ? window : {};
|
|
268
301
|
switch (wallet) {
|
|
269
|
-
case Wallet.Keplr: return $window
|
|
270
|
-
case Wallet.Ninji: return $window
|
|
271
|
-
case Wallet.Leap: return $window
|
|
272
|
-
case Wallet.OWallet: return $window
|
|
302
|
+
case Wallet.Keplr: return $window.keplr !== void 0;
|
|
303
|
+
case Wallet.Ninji: return $window.ninji !== void 0;
|
|
304
|
+
case Wallet.Leap: return $window.leap !== void 0;
|
|
305
|
+
case Wallet.OWallet: return $window.oWallet !== void 0;
|
|
306
|
+
case Wallet.Cosmostation:
|
|
307
|
+
var _$window$cosmostation;
|
|
308
|
+
return ((_$window$cosmostation = $window.cosmostation) === null || _$window$cosmostation === void 0 || (_$window$cosmostation = _$window$cosmostation.providers) === null || _$window$cosmostation === void 0 ? void 0 : _$window$cosmostation.keplr) !== void 0;
|
|
273
309
|
default: return false;
|
|
274
310
|
}
|
|
275
311
|
};
|
|
@@ -319,6 +355,7 @@ var CosmosWalletStrategy = class extends BaseConcreteStrategy {
|
|
|
319
355
|
if (wallet === Wallet.Ninji) window.ninji.off("accountsChanged", this.listeners[WalletEventListener.AccountChange]);
|
|
320
356
|
if ([Wallet.Keplr, Wallet.OWallet].includes(wallet)) window.removeEventListener("keplr_keystorechange", this.listeners[WalletEventListener.AccountChange]);
|
|
321
357
|
if (wallet === Wallet.Leap) window.removeEventListener("leap_keystorechange", this.listeners[WalletEventListener.AccountChange]);
|
|
358
|
+
if (wallet === Wallet.Cosmostation) window.removeEventListener("cosmostation_keystorechange", this.listeners[WalletEventListener.AccountChange]);
|
|
322
359
|
}
|
|
323
360
|
this.listeners = {};
|
|
324
361
|
}
|
|
@@ -437,6 +474,7 @@ var CosmosWalletStrategy = class extends BaseConcreteStrategy {
|
|
|
437
474
|
if (wallet === Wallet.Ninji) window.ninji.on("accountsChanged", listener);
|
|
438
475
|
if ([Wallet.Keplr, Wallet.OWallet].includes(wallet)) window.addEventListener("keplr_keystorechange", listener);
|
|
439
476
|
if (wallet === Wallet.Leap) window.addEventListener("leap_keystorechange", listener);
|
|
477
|
+
if (wallet === Wallet.Cosmostation) window.addEventListener("cosmostation_keystorechange", listener);
|
|
440
478
|
}
|
|
441
479
|
getCosmosWallet(chainId) {
|
|
442
480
|
const { wallet, cosmosWallet } = this;
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-cosmos",
|
|
3
|
-
"version": "1.17.2-alpha.
|
|
3
|
+
"version": "1.17.2-alpha.10",
|
|
4
4
|
"description": "Cosmos wallet strategies for use with @injectivelabs/wallet-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "InjectiveLabs",
|
|
8
8
|
"email": "admin@injectivelabs.org"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/InjectiveLabs/injective-ts"
|
|
13
|
+
},
|
|
10
14
|
"type": "module",
|
|
11
15
|
"sideEffects": false,
|
|
12
16
|
"exports": {
|
|
@@ -41,11 +45,11 @@
|
|
|
41
45
|
"@cosmjs/proto-signing": "0.33.0",
|
|
42
46
|
"@cosmjs/stargate": "0.33.0",
|
|
43
47
|
"@keplr-wallet/types": "^0.12.296",
|
|
44
|
-
"@injectivelabs/exceptions": "1.17.2-alpha.
|
|
45
|
-
"@injectivelabs/ts-types": "1.17.2-alpha.
|
|
46
|
-
"@injectivelabs/
|
|
47
|
-
"@injectivelabs/
|
|
48
|
-
"@injectivelabs/
|
|
48
|
+
"@injectivelabs/exceptions": "1.17.2-alpha.10",
|
|
49
|
+
"@injectivelabs/ts-types": "1.17.2-alpha.10",
|
|
50
|
+
"@injectivelabs/utils": "1.17.2-alpha.10",
|
|
51
|
+
"@injectivelabs/sdk-ts": "1.17.2-alpha.10",
|
|
52
|
+
"@injectivelabs/wallet-base": "1.17.2-alpha.10"
|
|
49
53
|
},
|
|
50
54
|
"publishConfig": {
|
|
51
55
|
"access": "public"
|