@keplr-wallet/stores 0.13.40 → 0.13.41
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/build/query/cosmos/account/index.d.ts +1 -0
- package/build/query/cosmos/account/index.js +15 -0
- package/build/query/cosmos/account/index.js.map +1 -1
- package/build/query/cosmos/account/module-account.d.ts +15 -0
- package/build/query/cosmos/account/module-account.js +50 -0
- package/build/query/cosmos/account/module-account.js.map +1 -0
- package/build/query/cosmos/account/module-account.spec.d.ts +1 -0
- package/build/query/cosmos/account/module-account.spec.js +22 -0
- package/build/query/cosmos/account/module-account.spec.js.map +1 -0
- package/build/query/cosmos/account/types.d.ts +10 -0
- package/build/query/cosmos/queries.d.ts +2 -1
- package/build/query/cosmos/queries.js +1 -0
- package/build/query/cosmos/queries.js.map +1 -1
- package/package.json +11 -11
- package/src/query/cosmos/account/index.ts +2 -0
- package/src/query/cosmos/account/module-account.spec.ts +24 -0
- package/src/query/cosmos/account/module-account.ts +68 -0
- package/src/query/cosmos/account/types.ts +11 -0
- package/src/query/cosmos/queries.ts +10 -1
|
@@ -2,6 +2,7 @@ import { ObservableChainQuery, ObservableChainQueryMap } from "../../chain-query
|
|
|
2
2
|
import { ChainGetter } from "../../../chain";
|
|
3
3
|
import { AuthAccount } from "./types";
|
|
4
4
|
import { QuerySharedContext } from "../../../common";
|
|
5
|
+
export * from "./module-account";
|
|
5
6
|
export declare class ObservableQueryAccountInner extends ObservableChainQuery<AuthAccount> {
|
|
6
7
|
protected readonly bech32Address: string;
|
|
7
8
|
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, bech32Address: string);
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
2
13
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
14
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
15
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
16
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
17
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
18
|
};
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
8
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
23
|
exports.ObservableQueryAccount = exports.ObservableQueryAccountInner = void 0;
|
|
10
24
|
const chain_query_1 = require("../../chain-query");
|
|
11
25
|
const mobx_1 = require("mobx");
|
|
12
26
|
const cosmos_1 = require("@keplr-wallet/cosmos");
|
|
27
|
+
__exportStar(require("./module-account"), exports);
|
|
13
28
|
class ObservableQueryAccountInner extends chain_query_1.ObservableChainQuery {
|
|
14
29
|
constructor(sharedContext, chainId, chainGetter, bech32Address) {
|
|
15
30
|
super(sharedContext, chainId, chainGetter, `/cosmos/auth/v1beta1/accounts/${bech32Address}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/query/cosmos/account/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/query/cosmos/account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAG2B;AAG3B,+BAAgD;AAChD,iDAAmD;AAGnD,mDAAiC;AAEjC,MAAa,2BAA4B,SAAQ,kCAAiC;IAChF,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB,EACL,aAAqB;QAExC,KAAK,CACH,aAAa,EACb,OAAO,EACP,WAAW,EACX,iCAAiC,aAAa,EAAE,CACjD,CAAC;QAPiB,kBAAa,GAAb,aAAa,CAAQ;QASxC,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAEkB,QAAQ;QACzB,8EAA8E;QAC9E,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IAGD,IAAI,QAAQ;QACV,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,GAAG,CAAC;SACZ;QAED,uEAAuE;QACvE,gFAAgF;QAChF,8CAA8C;QAC9C,+GAA+G;QAE/G,IAAI;YACF,MAAM,OAAO,GAAG,oBAAW,CAAC,aAAa,CACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB,IAAI,CAAC,aAAa,CACnB,CAAC;YACF,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC;SACzC;QAAC,WAAM;YACN,OAAO,GAAG,CAAC;SACZ;IACH,CAAC;IAGD,IAAI,gBAAgB;;QAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,0CAAE,OAAO,CAAC,oBAAoB,CAAA,CAAC;IAC5D,CAAC;CACF;AA7BC;IADC,eAAQ;2DAoBR;AAGD;IADC,eAAQ;mEAOR;AAnDH,kEAoDC;AAED,MAAa,sBAAuB,SAAQ,qCAAoC;IAC9E,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB;QAExB,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,aAAa,EAAE,EAAE;YAC3D,OAAO,IAAI,2BAA2B,CACpC,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,WAAW,EAChB,aAAa,CACd,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB,CAAC,aAAqB;QACzC,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAgC,CAAC;IAChE,CAAC;CACF;AAnBD,wDAmBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ObservableChainQuery, ObservableChainQueryMap } from "../../chain-query";
|
|
2
|
+
import { ChainGetter } from "../../../chain";
|
|
3
|
+
import { QuerySharedContext } from "../../../common";
|
|
4
|
+
import { ModuleAccountResponse } from "./types";
|
|
5
|
+
export declare function getModuleAccountAddress(response: ModuleAccountResponse | undefined, moduleName: string): string | undefined;
|
|
6
|
+
export declare class ObservableQueryModuleAccountInner extends ObservableChainQuery<ModuleAccountResponse> {
|
|
7
|
+
protected readonly moduleName: string;
|
|
8
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, moduleName: string);
|
|
9
|
+
protected canFetch(): boolean;
|
|
10
|
+
get moduleAccountAddress(): string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class ObservableQueryModuleAccount extends ObservableChainQueryMap<ModuleAccountResponse> {
|
|
13
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
14
|
+
getQueryModuleName(moduleName: string): ObservableQueryModuleAccountInner;
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ObservableQueryModuleAccount = exports.ObservableQueryModuleAccountInner = exports.getModuleAccountAddress = void 0;
|
|
10
|
+
const chain_query_1 = require("../../chain-query");
|
|
11
|
+
const mobx_1 = require("mobx");
|
|
12
|
+
function getModuleAccountAddress(response, moduleName) {
|
|
13
|
+
var _a;
|
|
14
|
+
const account = response === null || response === void 0 ? void 0 : response.account;
|
|
15
|
+
if ((account === null || account === void 0 ? void 0 : account.name) !== moduleName) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return (_a = account.base_account) === null || _a === void 0 ? void 0 : _a.address;
|
|
19
|
+
}
|
|
20
|
+
exports.getModuleAccountAddress = getModuleAccountAddress;
|
|
21
|
+
class ObservableQueryModuleAccountInner extends chain_query_1.ObservableChainQuery {
|
|
22
|
+
constructor(sharedContext, chainId, chainGetter, moduleName) {
|
|
23
|
+
super(sharedContext, chainId, chainGetter, `/cosmos/auth/v1beta1/module_accounts/${encodeURIComponent(moduleName)}`);
|
|
24
|
+
this.moduleName = moduleName;
|
|
25
|
+
(0, mobx_1.makeObservable)(this);
|
|
26
|
+
}
|
|
27
|
+
canFetch() {
|
|
28
|
+
return super.canFetch() && this.moduleName.length > 0;
|
|
29
|
+
}
|
|
30
|
+
get moduleAccountAddress() {
|
|
31
|
+
var _a;
|
|
32
|
+
return getModuleAccountAddress((_a = this.response) === null || _a === void 0 ? void 0 : _a.data, this.moduleName);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
mobx_1.computed
|
|
37
|
+
], ObservableQueryModuleAccountInner.prototype, "moduleAccountAddress", null);
|
|
38
|
+
exports.ObservableQueryModuleAccountInner = ObservableQueryModuleAccountInner;
|
|
39
|
+
class ObservableQueryModuleAccount extends chain_query_1.ObservableChainQueryMap {
|
|
40
|
+
constructor(sharedContext, chainId, chainGetter) {
|
|
41
|
+
super(sharedContext, chainId, chainGetter, (moduleName) => {
|
|
42
|
+
return new ObservableQueryModuleAccountInner(this.sharedContext, this.chainId, this.chainGetter, moduleName);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getQueryModuleName(moduleName) {
|
|
46
|
+
return this.get(moduleName);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ObservableQueryModuleAccount = ObservableQueryModuleAccount;
|
|
50
|
+
//# sourceMappingURL=module-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-account.js","sourceRoot":"","sources":["../../../../src/query/cosmos/account/module-account.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAG2B;AAG3B,+BAAgD;AAGhD,SAAgB,uBAAuB,CACrC,QAA2C,EAC3C,UAAkB;;IAElB,MAAM,OAAO,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC;IAClC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,UAAU,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,MAAA,OAAO,CAAC,YAAY,0CAAE,OAAO,CAAC;AACvC,CAAC;AAVD,0DAUC;AAED,MAAa,iCAAkC,SAAQ,kCAA2C;IAChG,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB,EACL,UAAkB;QAErC,KAAK,CACH,aAAa,EACb,OAAO,EACP,WAAW,EACX,wCAAwC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CACzE,CAAC;QAPiB,eAAU,GAAV,UAAU,CAAQ;QASrC,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAEkB,QAAQ;QACzB,OAAO,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACxD,CAAC;IAGD,IAAI,oBAAoB;;QACtB,OAAO,uBAAuB,CAAC,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;CACF;AAHC;IADC,eAAQ;6EAGR;AAxBH,8EAyBC;AAED,MAAa,4BAA6B,SAAQ,qCAA8C;IAC9F,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB;QAExB,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE;YACxD,OAAO,IAAI,iCAAiC,CAC1C,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,WAAW,EAChB,UAAU,CACX,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB,CAAC,UAAkB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAsC,CAAC;IACnE,CAAC;CACF;AAnBD,oEAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const module_account_1 = require("./module-account");
|
|
4
|
+
describe("getModuleAccountAddress", () => {
|
|
5
|
+
test("returns the address only for the requested module", () => {
|
|
6
|
+
const response = {
|
|
7
|
+
account: {
|
|
8
|
+
base_account: {
|
|
9
|
+
address: "thor1module",
|
|
10
|
+
},
|
|
11
|
+
name: "thorchain",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
expect((0, module_account_1.getModuleAccountAddress)(response, "thorchain")).toBe("thor1module");
|
|
15
|
+
expect((0, module_account_1.getModuleAccountAddress)(response, "other")).toBeUndefined();
|
|
16
|
+
});
|
|
17
|
+
test("returns undefined for an incomplete response", () => {
|
|
18
|
+
expect((0, module_account_1.getModuleAccountAddress)(undefined, "thorchain")).toBeUndefined();
|
|
19
|
+
expect((0, module_account_1.getModuleAccountAddress)({ account: { name: "thorchain" } }, "thorchain")).toBeUndefined();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=module-account.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-account.spec.js","sourceRoot":"","sources":["../../../../src/query/cosmos/account/module-account.spec.ts"],"names":[],"mappings":";;AAAA,qDAA2D;AAE3D,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC7D,MAAM,QAAQ,GAAG;YACf,OAAO,EAAE;gBACP,YAAY,EAAE;oBACZ,OAAO,EAAE,aAAa;iBACvB;gBACD,IAAI,EAAE,WAAW;aAClB;SACF,CAAC;QAEF,MAAM,CAAC,IAAA,wCAAuB,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3E,MAAM,CAAC,IAAA,wCAAuB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,IAAA,wCAAuB,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACxE,MAAM,CACJ,IAAA,wCAAuB,EAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,CAAC,CACzE,CAAC,aAAa,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueriesSetBase } from "../queries";
|
|
2
2
|
import { ChainGetter } from "../../chain";
|
|
3
|
-
import { ObservableQueryAccount } from "./account";
|
|
3
|
+
import { ObservableQueryAccount, ObservableQueryModuleAccount } from "./account";
|
|
4
4
|
import { ObservableQueryBabylonBtcDelegationReward, ObservableQueryDelegations, ObservableQueryRewards, ObservableQueryStakingParams, ObservableQueryStakingPool, ObservableQueryUnbondingDelegations, ObservableQueryValidators } from "./staking";
|
|
5
5
|
import { ObservableQueryDenomTrace, ObservableQueryIBCChannel, ObservableQueryIBCClientState } from "./ibc";
|
|
6
6
|
import { ObservableQuerySpendableBalances } from "./balance";
|
|
@@ -24,6 +24,7 @@ export declare const CosmosQueries: {
|
|
|
24
24
|
export declare class CosmosQueriesImpl {
|
|
25
25
|
readonly queryRPCStatus: DeepReadonly<ObservableQueryRPCStatus>;
|
|
26
26
|
readonly queryAccount: DeepReadonly<ObservableQueryAccount>;
|
|
27
|
+
readonly queryModuleAccount: DeepReadonly<ObservableQueryModuleAccount>;
|
|
27
28
|
readonly querySpendableBalances: DeepReadonly<ObservableQuerySpendableBalances>;
|
|
28
29
|
readonly queryPool: DeepReadonly<ObservableQueryStakingPool>;
|
|
29
30
|
readonly queryStakingParams: DeepReadonly<ObservableQueryStakingParams>;
|
|
@@ -28,6 +28,7 @@ class CosmosQueriesImpl {
|
|
|
28
28
|
this.queryRPCStatus = new status_1.ObservableQueryRPCStatus(sharedContext, chainId, chainGetter);
|
|
29
29
|
base.queryBalances.addBalanceRegistry(new balance_1.ObservableQueryCosmosBalanceRegistry(sharedContext));
|
|
30
30
|
this.queryAccount = new account_1.ObservableQueryAccount(sharedContext, chainId, chainGetter);
|
|
31
|
+
this.queryModuleAccount = new account_1.ObservableQueryModuleAccount(sharedContext, chainId, chainGetter);
|
|
31
32
|
this.querySpendableBalances = new balance_1.ObservableQuerySpendableBalances(sharedContext, chainId, chainGetter);
|
|
32
33
|
this.queryPool = new staking_1.ObservableQueryStakingPool(sharedContext, chainId, chainGetter);
|
|
33
34
|
this.queryStakingParams = new staking_1.ObservableQueryStakingParams(sharedContext, chainId, chainGetter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/query/cosmos/queries.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/query/cosmos/queries.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/stores",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.41",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"typecheck": "npx tsc -p tsconfig.check.json"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@keplr-wallet/provider-mock": "0.13.
|
|
24
|
+
"@keplr-wallet/provider-mock": "0.13.41"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@ethersproject/address": "^5.7.0",
|
|
28
|
-
"@keplr-wallet/common": "0.13.
|
|
29
|
-
"@keplr-wallet/cosmos": "0.13.
|
|
30
|
-
"@keplr-wallet/crypto": "0.13.
|
|
31
|
-
"@keplr-wallet/mobx-utils": "0.13.
|
|
32
|
-
"@keplr-wallet/proto-types": "0.13.
|
|
33
|
-
"@keplr-wallet/simple-fetch": "0.13.
|
|
34
|
-
"@keplr-wallet/types": "0.13.
|
|
35
|
-
"@keplr-wallet/unit": "0.13.
|
|
28
|
+
"@keplr-wallet/common": "0.13.41",
|
|
29
|
+
"@keplr-wallet/cosmos": "0.13.41",
|
|
30
|
+
"@keplr-wallet/crypto": "0.13.41",
|
|
31
|
+
"@keplr-wallet/mobx-utils": "0.13.41",
|
|
32
|
+
"@keplr-wallet/proto-types": "0.13.41",
|
|
33
|
+
"@keplr-wallet/simple-fetch": "0.13.41",
|
|
34
|
+
"@keplr-wallet/types": "0.13.41",
|
|
35
|
+
"@keplr-wallet/unit": "0.13.41",
|
|
36
36
|
"buffer": "^6.0.3",
|
|
37
37
|
"deepmerge": "^4.2.2",
|
|
38
38
|
"eventemitter3": "^4.0.7",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"mobx": "^6",
|
|
46
46
|
"mobx-utils": "^6"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "82e381a28cac67229da0e0aeb55d477cb72aac9d"
|
|
49
49
|
}
|
|
@@ -8,6 +8,8 @@ import { computed, makeObservable } from "mobx";
|
|
|
8
8
|
import { BaseAccount } from "@keplr-wallet/cosmos";
|
|
9
9
|
import { QuerySharedContext } from "../../../common";
|
|
10
10
|
|
|
11
|
+
export * from "./module-account";
|
|
12
|
+
|
|
11
13
|
export class ObservableQueryAccountInner extends ObservableChainQuery<AuthAccount> {
|
|
12
14
|
constructor(
|
|
13
15
|
sharedContext: QuerySharedContext,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getModuleAccountAddress } from "./module-account";
|
|
2
|
+
|
|
3
|
+
describe("getModuleAccountAddress", () => {
|
|
4
|
+
test("returns the address only for the requested module", () => {
|
|
5
|
+
const response = {
|
|
6
|
+
account: {
|
|
7
|
+
base_account: {
|
|
8
|
+
address: "thor1module",
|
|
9
|
+
},
|
|
10
|
+
name: "thorchain",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
expect(getModuleAccountAddress(response, "thorchain")).toBe("thor1module");
|
|
15
|
+
expect(getModuleAccountAddress(response, "other")).toBeUndefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("returns undefined for an incomplete response", () => {
|
|
19
|
+
expect(getModuleAccountAddress(undefined, "thorchain")).toBeUndefined();
|
|
20
|
+
expect(
|
|
21
|
+
getModuleAccountAddress({ account: { name: "thorchain" } }, "thorchain")
|
|
22
|
+
).toBeUndefined();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObservableChainQuery,
|
|
3
|
+
ObservableChainQueryMap,
|
|
4
|
+
} from "../../chain-query";
|
|
5
|
+
import { ChainGetter } from "../../../chain";
|
|
6
|
+
import { QuerySharedContext } from "../../../common";
|
|
7
|
+
import { computed, makeObservable } from "mobx";
|
|
8
|
+
import { ModuleAccountResponse } from "./types";
|
|
9
|
+
|
|
10
|
+
export function getModuleAccountAddress(
|
|
11
|
+
response: ModuleAccountResponse | undefined,
|
|
12
|
+
moduleName: string
|
|
13
|
+
): string | undefined {
|
|
14
|
+
const account = response?.account;
|
|
15
|
+
if (account?.name !== moduleName) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return account.base_account?.address;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class ObservableQueryModuleAccountInner extends ObservableChainQuery<ModuleAccountResponse> {
|
|
23
|
+
constructor(
|
|
24
|
+
sharedContext: QuerySharedContext,
|
|
25
|
+
chainId: string,
|
|
26
|
+
chainGetter: ChainGetter,
|
|
27
|
+
protected readonly moduleName: string
|
|
28
|
+
) {
|
|
29
|
+
super(
|
|
30
|
+
sharedContext,
|
|
31
|
+
chainId,
|
|
32
|
+
chainGetter,
|
|
33
|
+
`/cosmos/auth/v1beta1/module_accounts/${encodeURIComponent(moduleName)}`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
makeObservable(this);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected override canFetch(): boolean {
|
|
40
|
+
return super.canFetch() && this.moduleName.length > 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@computed
|
|
44
|
+
get moduleAccountAddress(): string | undefined {
|
|
45
|
+
return getModuleAccountAddress(this.response?.data, this.moduleName);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class ObservableQueryModuleAccount extends ObservableChainQueryMap<ModuleAccountResponse> {
|
|
50
|
+
constructor(
|
|
51
|
+
sharedContext: QuerySharedContext,
|
|
52
|
+
chainId: string,
|
|
53
|
+
chainGetter: ChainGetter
|
|
54
|
+
) {
|
|
55
|
+
super(sharedContext, chainId, chainGetter, (moduleName) => {
|
|
56
|
+
return new ObservableQueryModuleAccountInner(
|
|
57
|
+
this.sharedContext,
|
|
58
|
+
this.chainId,
|
|
59
|
+
this.chainGetter,
|
|
60
|
+
moduleName
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
getQueryModuleName(moduleName: string): ObservableQueryModuleAccountInner {
|
|
66
|
+
return this.get(moduleName) as ObservableQueryModuleAccountInner;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { QueriesSetBase } from "../queries";
|
|
2
2
|
import { ChainGetter } from "../../chain";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ObservableQueryAccount,
|
|
5
|
+
ObservableQueryModuleAccount,
|
|
6
|
+
} from "./account";
|
|
4
7
|
import {
|
|
5
8
|
ObservableQueryBabylonBtcDelegationReward,
|
|
6
9
|
ObservableQueryDelegations,
|
|
@@ -64,6 +67,7 @@ export class CosmosQueriesImpl {
|
|
|
64
67
|
public readonly queryRPCStatus: DeepReadonly<ObservableQueryRPCStatus>;
|
|
65
68
|
|
|
66
69
|
public readonly queryAccount: DeepReadonly<ObservableQueryAccount>;
|
|
70
|
+
public readonly queryModuleAccount: DeepReadonly<ObservableQueryModuleAccount>;
|
|
67
71
|
public readonly querySpendableBalances: DeepReadonly<ObservableQuerySpendableBalances>;
|
|
68
72
|
public readonly queryPool: DeepReadonly<ObservableQueryStakingPool>;
|
|
69
73
|
public readonly queryStakingParams: DeepReadonly<ObservableQueryStakingParams>;
|
|
@@ -108,6 +112,11 @@ export class CosmosQueriesImpl {
|
|
|
108
112
|
chainId,
|
|
109
113
|
chainGetter
|
|
110
114
|
);
|
|
115
|
+
this.queryModuleAccount = new ObservableQueryModuleAccount(
|
|
116
|
+
sharedContext,
|
|
117
|
+
chainId,
|
|
118
|
+
chainGetter
|
|
119
|
+
);
|
|
111
120
|
this.querySpendableBalances = new ObservableQuerySpendableBalances(
|
|
112
121
|
sharedContext,
|
|
113
122
|
chainId,
|