@keplr-wallet/stores 0.12.287 → 0.12.289-rc.0
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/cosmwasm/index.d.ts +2 -0
- package/build/query/cosmwasm/index.js +2 -0
- package/build/query/cosmwasm/index.js.map +1 -1
- package/build/query/cosmwasm/neutron/governance-proposals.d.ts +64 -0
- package/build/query/cosmwasm/neutron/governance-proposals.js +83 -0
- package/build/query/cosmwasm/neutron/governance-proposals.js.map +1 -0
- package/build/query/cosmwasm/neutron/governance-vote.d.ts +27 -0
- package/build/query/cosmwasm/neutron/governance-vote.js +73 -0
- package/build/query/cosmwasm/neutron/governance-vote.js.map +1 -0
- package/build/query/cosmwasm/queries.d.ts +4 -0
- package/build/query/cosmwasm/queries.js +4 -0
- package/build/query/cosmwasm/queries.js.map +1 -1
- package/package.json +11 -11
- package/src/query/cosmwasm/index.ts +2 -0
- package/src/query/cosmwasm/neutron/governance-proposals.ts +150 -0
- package/src/query/cosmwasm/neutron/governance-vote.ts +109 -0
- package/src/query/cosmwasm/queries.ts +17 -0
|
@@ -32,4 +32,6 @@ exports.CosmWasm = __importStar(require("./types"));
|
|
|
32
32
|
__exportStar(require("./queries"), exports);
|
|
33
33
|
__exportStar(require("./neutron/staking-rewards"), exports);
|
|
34
34
|
__exportStar(require("./neutron/staking-rewards-config"), exports);
|
|
35
|
+
__exportStar(require("./neutron/governance-proposals"), exports);
|
|
36
|
+
__exportStar(require("./neutron/governance-vote"), exports);
|
|
35
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/query/cosmwasm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oDAAoC;AACpC,4CAA0B;AAC1B,4DAA0C;AAC1C,mEAAiD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/query/cosmwasm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oDAAoC;AACpC,4CAA0B;AAC1B,4DAA0C;AAC1C,mEAAiD;AACjD,iEAA+C;AAC/C,4DAA0C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ChainGetter } from "../../../chain";
|
|
2
|
+
import { QuerySharedContext } from "../../../common";
|
|
3
|
+
import { ObservableChainQueryMap } from "../../chain-query";
|
|
4
|
+
export declare enum NeutronGovProposalStatus {
|
|
5
|
+
OPEN = "open",
|
|
6
|
+
PASSED = "passed",
|
|
7
|
+
REJECTED = "rejected",
|
|
8
|
+
EXECUTED = "executed",
|
|
9
|
+
CLOSED = "closed",
|
|
10
|
+
EXECUTION_FAILED = "execution_failed"
|
|
11
|
+
}
|
|
12
|
+
interface NeutronGovThreshold {
|
|
13
|
+
threshold_quorum?: {
|
|
14
|
+
threshold: string;
|
|
15
|
+
quorum: string;
|
|
16
|
+
};
|
|
17
|
+
absolute_percentage?: {
|
|
18
|
+
percentage: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface NeutronGovProposal {
|
|
22
|
+
id: number;
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
proposer: string;
|
|
26
|
+
start_height: number;
|
|
27
|
+
min_voting_period: null;
|
|
28
|
+
expiration: {
|
|
29
|
+
at_time?: string;
|
|
30
|
+
at_height?: string;
|
|
31
|
+
};
|
|
32
|
+
threshold: NeutronGovThreshold;
|
|
33
|
+
total_power: string;
|
|
34
|
+
msgs: unknown[];
|
|
35
|
+
status: NeutronGovProposalStatus;
|
|
36
|
+
votes: {
|
|
37
|
+
yes: string;
|
|
38
|
+
no: string;
|
|
39
|
+
abstain: string;
|
|
40
|
+
};
|
|
41
|
+
allow_revoting: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface NeutronGovProposalsResponse {
|
|
44
|
+
proposals: {
|
|
45
|
+
id: number;
|
|
46
|
+
proposal: NeutronGovProposal;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
export declare class ObservableQueryNeutronGovernance extends ObservableChainQueryMap<NeutronGovProposalsResponse> {
|
|
50
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
51
|
+
getQueryGovernanceWithPage(params: {
|
|
52
|
+
page: number;
|
|
53
|
+
perPageNumber: number;
|
|
54
|
+
}): {
|
|
55
|
+
proposals: {
|
|
56
|
+
id: number;
|
|
57
|
+
proposal: NeutronGovProposal;
|
|
58
|
+
}[];
|
|
59
|
+
firstFetching: boolean;
|
|
60
|
+
nextKey: number | null;
|
|
61
|
+
isFetching: boolean;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
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.ObservableQueryNeutronGovernance = exports.NeutronGovProposalStatus = void 0;
|
|
10
|
+
const contract_query_1 = require("../contract-query");
|
|
11
|
+
const chain_query_1 = require("../../chain-query");
|
|
12
|
+
const mobx_1 = require("mobx");
|
|
13
|
+
var NeutronGovProposalStatus;
|
|
14
|
+
(function (NeutronGovProposalStatus) {
|
|
15
|
+
NeutronGovProposalStatus["OPEN"] = "open";
|
|
16
|
+
NeutronGovProposalStatus["PASSED"] = "passed";
|
|
17
|
+
NeutronGovProposalStatus["REJECTED"] = "rejected";
|
|
18
|
+
NeutronGovProposalStatus["EXECUTED"] = "executed";
|
|
19
|
+
NeutronGovProposalStatus["CLOSED"] = "closed";
|
|
20
|
+
NeutronGovProposalStatus["EXECUTION_FAILED"] = "execution_failed";
|
|
21
|
+
})(NeutronGovProposalStatus = exports.NeutronGovProposalStatus || (exports.NeutronGovProposalStatus = {}));
|
|
22
|
+
class ObservableQueryNeutronGovernanceInner extends contract_query_1.ObservableCosmwasmContractChainQuery {
|
|
23
|
+
constructor(sharedContext, chainId, chainGetter, params) {
|
|
24
|
+
const contractAddress = chainId === "neutron-1"
|
|
25
|
+
? ObservableQueryNeutronGovernanceInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET
|
|
26
|
+
: chainId === "pion-1"
|
|
27
|
+
? ObservableQueryNeutronGovernanceInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET
|
|
28
|
+
: "";
|
|
29
|
+
super(sharedContext, chainId, chainGetter, contractAddress, {
|
|
30
|
+
reverse_proposals: params || { limit: 20 },
|
|
31
|
+
});
|
|
32
|
+
this.params = params;
|
|
33
|
+
}
|
|
34
|
+
canFetch() {
|
|
35
|
+
return (super.canFetch() &&
|
|
36
|
+
(this.chainId === "neutron-1" || this.chainId === "pion-1"));
|
|
37
|
+
}
|
|
38
|
+
get proposals() {
|
|
39
|
+
var _a;
|
|
40
|
+
if (!((_a = this.response) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
return this.response.data.proposals || [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
ObservableQueryNeutronGovernanceInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET = "neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh";
|
|
47
|
+
ObservableQueryNeutronGovernanceInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET = "neutron19sf2y4dvgt02kczemvhktrwvt4aunrahw8qkjq6u3pehdujwssgqrs5e4h";
|
|
48
|
+
__decorate([
|
|
49
|
+
mobx_1.computed
|
|
50
|
+
], ObservableQueryNeutronGovernanceInner.prototype, "proposals", null);
|
|
51
|
+
class ObservableQueryNeutronGovernance extends chain_query_1.ObservableChainQueryMap {
|
|
52
|
+
constructor(sharedContext, chainId, chainGetter) {
|
|
53
|
+
super(sharedContext, chainId, chainGetter, (param) => {
|
|
54
|
+
const parsedParams = JSON.parse(param);
|
|
55
|
+
return new ObservableQueryNeutronGovernanceInner(this.sharedContext, this.chainId, this.chainGetter, parsedParams);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
getQueryGovernanceWithPage(params) {
|
|
59
|
+
var _a;
|
|
60
|
+
const list = Array.from({ length: params.page + 1 }, (_, i) => {
|
|
61
|
+
return JSON.stringify({
|
|
62
|
+
start_before: i === 0 ? undefined : i * params.perPageNumber,
|
|
63
|
+
limit: params.perPageNumber,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
const proposals = list.flatMap((param) => {
|
|
67
|
+
const query = this.get(param);
|
|
68
|
+
return query.proposals;
|
|
69
|
+
});
|
|
70
|
+
const lastQuery = this.get(list[list.length - 1]);
|
|
71
|
+
const nextKey = lastQuery.proposals.length === params.perPageNumber
|
|
72
|
+
? (_a = proposals[proposals.length - 1]) === null || _a === void 0 ? void 0 : _a.id
|
|
73
|
+
: null;
|
|
74
|
+
return {
|
|
75
|
+
proposals,
|
|
76
|
+
firstFetching: lastQuery.isFetching && proposals.length === 0,
|
|
77
|
+
nextKey,
|
|
78
|
+
isFetching: lastQuery.isFetching,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.ObservableQueryNeutronGovernance = ObservableQueryNeutronGovernance;
|
|
83
|
+
//# sourceMappingURL=governance-proposals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance-proposals.js","sourceRoot":"","sources":["../../../../src/query/cosmwasm/neutron/governance-proposals.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChainGetter } from "../../../chain";
|
|
2
|
+
import { ObservableCosmwasmContractChainQuery } from "../contract-query";
|
|
3
|
+
import { QuerySharedContext } from "../../../common";
|
|
4
|
+
import { ObservableChainQueryMap } from "../../chain-query";
|
|
5
|
+
interface NeutronGovVote {
|
|
6
|
+
voter: string;
|
|
7
|
+
vote: "yes" | "no" | "abstain";
|
|
8
|
+
power: string;
|
|
9
|
+
}
|
|
10
|
+
interface NeutronGovVoteResponse {
|
|
11
|
+
vote: NeutronGovVote | null;
|
|
12
|
+
}
|
|
13
|
+
declare class ObservableQueryNeutronProposalVoteInner extends ObservableCosmwasmContractChainQuery<NeutronGovVoteResponse> {
|
|
14
|
+
static readonly NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET = "neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh";
|
|
15
|
+
static readonly NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET = "neutron19sf2y4dvgt02kczemvhktrwvt4aunrahw8qkjq6u3pehdujwssgqrs5e4h";
|
|
16
|
+
protected proposalId: string;
|
|
17
|
+
protected bech32Address: string;
|
|
18
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, proposalId: string, bech32Address: string);
|
|
19
|
+
get vote(): "Yes" | "Abstain" | "No" | "NoWithVeto" | "Unspecified";
|
|
20
|
+
refetch(): void;
|
|
21
|
+
protected canFetch(): boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class ObservableQueryNeutronProposalVote extends ObservableChainQueryMap<NeutronGovVoteResponse> {
|
|
24
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
25
|
+
getVote(proposalId: string, voter: string): ObservableQueryNeutronProposalVoteInner;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
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.ObservableQueryNeutronProposalVote = void 0;
|
|
10
|
+
const contract_query_1 = require("../contract-query");
|
|
11
|
+
const chain_query_1 = require("../../chain-query");
|
|
12
|
+
const mobx_1 = require("mobx");
|
|
13
|
+
class ObservableQueryNeutronProposalVoteInner extends contract_query_1.ObservableCosmwasmContractChainQuery {
|
|
14
|
+
constructor(sharedContext, chainId, chainGetter, proposalId, bech32Address) {
|
|
15
|
+
const contractAddress = chainId === "neutron-1"
|
|
16
|
+
? ObservableQueryNeutronProposalVoteInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET
|
|
17
|
+
: chainId === "pion-1"
|
|
18
|
+
? ObservableQueryNeutronProposalVoteInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET
|
|
19
|
+
: "";
|
|
20
|
+
super(sharedContext, chainId, chainGetter, contractAddress, {
|
|
21
|
+
get_vote: { proposal_id: parseInt(proposalId), voter: bech32Address },
|
|
22
|
+
});
|
|
23
|
+
this.proposalId = proposalId;
|
|
24
|
+
this.bech32Address = bech32Address;
|
|
25
|
+
}
|
|
26
|
+
get vote() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (!((_b = (_a = this.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.vote)) {
|
|
29
|
+
return "Unspecified";
|
|
30
|
+
}
|
|
31
|
+
const voteOption = this.response.data.vote.vote;
|
|
32
|
+
switch (voteOption) {
|
|
33
|
+
case "yes":
|
|
34
|
+
return "Yes";
|
|
35
|
+
case "abstain":
|
|
36
|
+
return "Abstain";
|
|
37
|
+
case "no":
|
|
38
|
+
return "No";
|
|
39
|
+
default:
|
|
40
|
+
return "Unspecified";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
refetch() {
|
|
44
|
+
this.fetch();
|
|
45
|
+
}
|
|
46
|
+
canFetch() {
|
|
47
|
+
return (super.canFetch() &&
|
|
48
|
+
this.bech32Address.length > 0 &&
|
|
49
|
+
(this.chainId === "neutron-1" || this.chainId === "pion-1"));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
ObservableQueryNeutronProposalVoteInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET = "neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh";
|
|
53
|
+
ObservableQueryNeutronProposalVoteInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET = "neutron19sf2y4dvgt02kczemvhktrwvt4aunrahw8qkjq6u3pehdujwssgqrs5e4h";
|
|
54
|
+
__decorate([
|
|
55
|
+
mobx_1.computed
|
|
56
|
+
], ObservableQueryNeutronProposalVoteInner.prototype, "vote", null);
|
|
57
|
+
class ObservableQueryNeutronProposalVote extends chain_query_1.ObservableChainQueryMap {
|
|
58
|
+
constructor(sharedContext, chainId, chainGetter) {
|
|
59
|
+
super(sharedContext, chainId, chainGetter, (param) => {
|
|
60
|
+
const { proposalId, voter } = JSON.parse(param);
|
|
61
|
+
return new ObservableQueryNeutronProposalVoteInner(this.sharedContext, this.chainId, this.chainGetter, proposalId, voter);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getVote(proposalId, voter) {
|
|
65
|
+
const param = JSON.stringify({
|
|
66
|
+
proposalId,
|
|
67
|
+
voter,
|
|
68
|
+
});
|
|
69
|
+
return this.get(param);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.ObservableQueryNeutronProposalVote = ObservableQueryNeutronProposalVote;
|
|
73
|
+
//# sourceMappingURL=governance-vote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance-vote.js","sourceRoot":"","sources":["../../../../src/query/cosmwasm/neutron/governance-vote.ts"],"names":[],"mappings":";;;;;;;;;AACA,sDAAyE;AAEzE,mDAA4D;AAC5D,+BAAgC;AAYhC,MAAM,uCAAwC,SAAQ,qDAA4D;IAShH,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB,EACxB,UAAkB,EAClB,aAAqB;QAErB,MAAM,eAAe,GACnB,OAAO,KAAK,WAAW;YACrB,CAAC,CAAC,uCAAuC,CAAC,uCAAuC;YACjF,CAAC,CAAC,OAAO,KAAK,QAAQ;gBACtB,CAAC,CAAC,uCAAuC,CAAC,uCAAuC;gBACjF,CAAC,CAAC,EAAE,CAAC;QAET,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE;YAC1D,QAAQ,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE;SACtE,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAGD,IAAI,IAAI;;QACN,IAAI,CAAC,CAAA,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,0CAAE,IAAI,CAAA,EAAE;YAC9B,OAAO,aAAa,CAAC;SACtB;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,QAAQ,UAAU,EAAE;YAClB,KAAK,KAAK;gBACR,OAAO,KAAK,CAAC;YACf,KAAK,SAAS;gBACZ,OAAO,SAAS,CAAC;YACnB,KAAK,IAAI;gBACP,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,aAAa,CAAC;SACxB;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAEkB,QAAQ;QACzB,OAAO,CACL,KAAK,CAAC,QAAQ,EAAE;YAChB,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC;YAC7B,CAAC,IAAI,CAAC,OAAO,KAAK,WAAW,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAC5D,CAAC;IACJ,CAAC;;AA1DsB,+EAAuC,GAC5D,oEAAoE,CAAC;AAChD,+EAAuC,GAC5D,oEAAoE,CAAC;AA2BvE;IADC,eAAQ;mEAiBR;AAeH,MAAa,kCAAmC,SAAQ,qCAA+C;IACrG,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB;QAExB,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE;YAC3D,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAEhD,OAAO,IAAI,uCAAuC,CAChD,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,WAAW,EAChB,UAAU,EACV,KAAK,CACN,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CACL,UAAkB,EAClB,KAAa;QAEb,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;YAC3B,UAAU;YACV,KAAK;SACN,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAA4C,CAAC;IACpE,CAAC;CACF;AA9BD,gFA8BC"}
|
|
@@ -5,6 +5,8 @@ import { DeepReadonly } from "utility-types";
|
|
|
5
5
|
import { QuerySharedContext } from "../../common";
|
|
6
6
|
import { ObservableQueryNeutronStakingRewards } from "./neutron/staking-rewards";
|
|
7
7
|
import { ObservableQueryNeutronStakingRewardsConfig } from "./neutron/staking-rewards-config";
|
|
8
|
+
import { ObservableQueryNeutronGovernance } from "./neutron/governance-proposals";
|
|
9
|
+
import { ObservableQueryNeutronProposalVote } from "./neutron/governance-vote";
|
|
8
10
|
export interface CosmwasmQueries {
|
|
9
11
|
cosmwasm: CosmwasmQueriesImpl;
|
|
10
12
|
}
|
|
@@ -15,5 +17,7 @@ export declare class CosmwasmQueriesImpl {
|
|
|
15
17
|
readonly querycw20ContractInfo: DeepReadonly<ObservableQueryCw20ContractInfo>;
|
|
16
18
|
readonly queryNeutronStakingRewards: DeepReadonly<ObservableQueryNeutronStakingRewards>;
|
|
17
19
|
readonly queryNeutronStakingRewardsConfig: DeepReadonly<ObservableQueryNeutronStakingRewardsConfig>;
|
|
20
|
+
readonly queryNeutronGovernance: DeepReadonly<ObservableQueryNeutronGovernance>;
|
|
21
|
+
readonly queryNeutronVote: DeepReadonly<ObservableQueryNeutronProposalVote>;
|
|
18
22
|
constructor(base: QueriesSetBase, sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
19
23
|
}
|
|
@@ -5,6 +5,8 @@ const cw20_contract_info_1 = require("./cw20-contract-info");
|
|
|
5
5
|
const cw20_balance_1 = require("./cw20-balance");
|
|
6
6
|
const staking_rewards_1 = require("./neutron/staking-rewards");
|
|
7
7
|
const staking_rewards_config_1 = require("./neutron/staking-rewards-config");
|
|
8
|
+
const governance_proposals_1 = require("./neutron/governance-proposals");
|
|
9
|
+
const governance_vote_1 = require("./neutron/governance-vote");
|
|
8
10
|
exports.CosmwasmQueries = {
|
|
9
11
|
use() {
|
|
10
12
|
return (queriesSetBase, sharedContext, chainId, chainGetter) => {
|
|
@@ -21,6 +23,8 @@ class CosmwasmQueriesImpl {
|
|
|
21
23
|
this.queryNeutronStakingRewards = new staking_rewards_1.ObservableQueryNeutronStakingRewards(sharedContext, chainId, chainGetter);
|
|
22
24
|
this.queryNeutronStakingRewardsConfig =
|
|
23
25
|
new staking_rewards_config_1.ObservableQueryNeutronStakingRewardsConfig(sharedContext, chainId, chainGetter);
|
|
26
|
+
this.queryNeutronGovernance = new governance_proposals_1.ObservableQueryNeutronGovernance(sharedContext, chainId, chainGetter);
|
|
27
|
+
this.queryNeutronVote = new governance_vote_1.ObservableQueryNeutronProposalVote(sharedContext, chainId, chainGetter);
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
exports.CosmwasmQueriesImpl = CosmwasmQueriesImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/query/cosmwasm/queries.ts"],"names":[],"mappings":";;;AAEA,6DAAuE;AAEvE,iDAAoE;AAEpE,+DAAiF;AACjF,6EAA8F;
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/query/cosmwasm/queries.ts"],"names":[],"mappings":";;;AAEA,6DAAuE;AAEvE,iDAAoE;AAEpE,+DAAiF;AACjF,6EAA8F;AAC9F,yEAAkF;AAClF,+DAA+E;AAMlE,QAAA,eAAe,GAAG;IAC7B,GAAG;QAMD,OAAO,CACL,cAA8B,EAC9B,aAAiC,EACjC,OAAe,EACf,WAAwB,EACxB,EAAE;YACF,OAAO;gBACL,QAAQ,EAAE,IAAI,mBAAmB,CAC/B,cAAc,EACd,aAAa,EACb,OAAO,EACP,WAAW,CACZ;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAa,mBAAmB;IAO9B,YACE,IAAoB,EACpB,aAAiC,EACjC,OAAe,EACf,WAAwB;QAExB,IAAI,CAAC,aAAa,CAAC,kBAAkB,CACnC,IAAI,iDAAkC,CAAC,aAAa,CAAC,CACtD,CAAC;QAEF,IAAI,CAAC,qBAAqB,GAAG,IAAI,oDAA+B,CAC9D,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,0BAA0B,GAAG,IAAI,sDAAoC,CACxE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,gCAAgC;YACnC,IAAI,mEAA0C,CAC5C,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEJ,IAAI,CAAC,sBAAsB,GAAG,IAAI,uDAAgC,CAChE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,gBAAgB,GAAG,IAAI,oDAAkC,CAC5D,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC;CACF;AAhDD,kDAgDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/stores",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.289-rc.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"lint-fix": "npx eslint --fix \"src/**/*\" && npx prettier --write \"src/**/*\""
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@keplr-wallet/provider-mock": "0.12.
|
|
19
|
+
"@keplr-wallet/provider-mock": "0.12.289-rc.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@keplr-wallet/common": "0.12.
|
|
23
|
-
"@keplr-wallet/cosmos": "0.12.
|
|
24
|
-
"@keplr-wallet/crypto": "0.12.
|
|
25
|
-
"@keplr-wallet/mobx-utils": "0.12.
|
|
26
|
-
"@keplr-wallet/proto-types": "0.12.
|
|
27
|
-
"@keplr-wallet/simple-fetch": "0.12.
|
|
28
|
-
"@keplr-wallet/types": "0.12.
|
|
29
|
-
"@keplr-wallet/unit": "0.12.
|
|
22
|
+
"@keplr-wallet/common": "0.12.289-rc.0",
|
|
23
|
+
"@keplr-wallet/cosmos": "0.12.289-rc.0",
|
|
24
|
+
"@keplr-wallet/crypto": "0.12.289-rc.0",
|
|
25
|
+
"@keplr-wallet/mobx-utils": "0.12.289-rc.0",
|
|
26
|
+
"@keplr-wallet/proto-types": "0.12.289-rc.0",
|
|
27
|
+
"@keplr-wallet/simple-fetch": "0.12.289-rc.0",
|
|
28
|
+
"@keplr-wallet/types": "0.12.289-rc.0",
|
|
29
|
+
"@keplr-wallet/unit": "0.12.289-rc.0",
|
|
30
30
|
"buffer": "^6.0.3",
|
|
31
31
|
"deepmerge": "^4.2.2",
|
|
32
32
|
"eventemitter3": "^4.0.7",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"mobx": "^6",
|
|
39
39
|
"mobx-utils": "^6"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "10e230438baf4f1292d661d44de87f9939dc05b3"
|
|
42
42
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { ChainGetter } from "../../../chain";
|
|
2
|
+
import { ObservableCosmwasmContractChainQuery } from "../contract-query";
|
|
3
|
+
import { QuerySharedContext } from "../../../common";
|
|
4
|
+
import { ObservableChainQueryMap } from "../../chain-query";
|
|
5
|
+
import { computed } from "mobx";
|
|
6
|
+
|
|
7
|
+
export enum NeutronGovProposalStatus {
|
|
8
|
+
OPEN = "open",
|
|
9
|
+
PASSED = "passed",
|
|
10
|
+
REJECTED = "rejected",
|
|
11
|
+
EXECUTED = "executed",
|
|
12
|
+
CLOSED = "closed",
|
|
13
|
+
EXECUTION_FAILED = "execution_failed",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface NeutronGovThreshold {
|
|
17
|
+
threshold_quorum?: {
|
|
18
|
+
threshold: string;
|
|
19
|
+
quorum: string;
|
|
20
|
+
};
|
|
21
|
+
absolute_percentage?: {
|
|
22
|
+
percentage: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface NeutronGovProposal {
|
|
27
|
+
id: number;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
proposer: string;
|
|
31
|
+
start_height: number;
|
|
32
|
+
min_voting_period: null;
|
|
33
|
+
expiration: {
|
|
34
|
+
at_time?: string;
|
|
35
|
+
at_height?: string;
|
|
36
|
+
};
|
|
37
|
+
threshold: NeutronGovThreshold;
|
|
38
|
+
total_power: string;
|
|
39
|
+
msgs: unknown[];
|
|
40
|
+
status: NeutronGovProposalStatus;
|
|
41
|
+
votes: {
|
|
42
|
+
yes: string;
|
|
43
|
+
no: string;
|
|
44
|
+
abstain: string;
|
|
45
|
+
};
|
|
46
|
+
allow_revoting: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface NeutronGovProposalsResponse {
|
|
50
|
+
proposals: {
|
|
51
|
+
id: number;
|
|
52
|
+
proposal: NeutronGovProposal;
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class ObservableQueryNeutronGovernanceInner extends ObservableCosmwasmContractChainQuery<NeutronGovProposalsResponse> {
|
|
57
|
+
public static readonly NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET =
|
|
58
|
+
"neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh";
|
|
59
|
+
public static readonly NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET =
|
|
60
|
+
"neutron19sf2y4dvgt02kczemvhktrwvt4aunrahw8qkjq6u3pehdujwssgqrs5e4h";
|
|
61
|
+
|
|
62
|
+
constructor(
|
|
63
|
+
sharedContext: QuerySharedContext,
|
|
64
|
+
chainId: string,
|
|
65
|
+
chainGetter: ChainGetter,
|
|
66
|
+
protected readonly params: { start_before?: number; limit?: number }
|
|
67
|
+
) {
|
|
68
|
+
const contractAddress =
|
|
69
|
+
chainId === "neutron-1"
|
|
70
|
+
? ObservableQueryNeutronGovernanceInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET
|
|
71
|
+
: chainId === "pion-1"
|
|
72
|
+
? ObservableQueryNeutronGovernanceInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET
|
|
73
|
+
: "";
|
|
74
|
+
|
|
75
|
+
super(sharedContext, chainId, chainGetter, contractAddress, {
|
|
76
|
+
reverse_proposals: params || { limit: 20 },
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected override canFetch(): boolean {
|
|
81
|
+
return (
|
|
82
|
+
super.canFetch() &&
|
|
83
|
+
(this.chainId === "neutron-1" || this.chainId === "pion-1")
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@computed
|
|
88
|
+
get proposals(): {
|
|
89
|
+
id: number;
|
|
90
|
+
proposal: NeutronGovProposal;
|
|
91
|
+
}[] {
|
|
92
|
+
if (!this.response?.data) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
return this.response.data.proposals || [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class ObservableQueryNeutronGovernance extends ObservableChainQueryMap<NeutronGovProposalsResponse> {
|
|
100
|
+
constructor(
|
|
101
|
+
sharedContext: QuerySharedContext,
|
|
102
|
+
chainId: string,
|
|
103
|
+
chainGetter: ChainGetter
|
|
104
|
+
) {
|
|
105
|
+
super(sharedContext, chainId, chainGetter, (param: string) => {
|
|
106
|
+
const parsedParams = JSON.parse(param);
|
|
107
|
+
return new ObservableQueryNeutronGovernanceInner(
|
|
108
|
+
this.sharedContext,
|
|
109
|
+
this.chainId,
|
|
110
|
+
this.chainGetter,
|
|
111
|
+
parsedParams
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getQueryGovernanceWithPage(params: { page: number; perPageNumber: number }): {
|
|
117
|
+
proposals: { id: number; proposal: NeutronGovProposal }[];
|
|
118
|
+
firstFetching: boolean;
|
|
119
|
+
nextKey: number | null;
|
|
120
|
+
isFetching: boolean;
|
|
121
|
+
} {
|
|
122
|
+
const list = Array.from({ length: params.page + 1 }, (_, i) => {
|
|
123
|
+
return JSON.stringify({
|
|
124
|
+
start_before: i === 0 ? undefined : i * params.perPageNumber,
|
|
125
|
+
limit: params.perPageNumber,
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const proposals = list.flatMap((param) => {
|
|
130
|
+
const query = this.get(param) as ObservableQueryNeutronGovernanceInner;
|
|
131
|
+
return query.proposals;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const lastQuery = this.get(
|
|
135
|
+
list[list.length - 1]
|
|
136
|
+
) as ObservableQueryNeutronGovernanceInner;
|
|
137
|
+
|
|
138
|
+
const nextKey =
|
|
139
|
+
lastQuery.proposals.length === params.perPageNumber
|
|
140
|
+
? proposals[proposals.length - 1]?.id
|
|
141
|
+
: null;
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
proposals,
|
|
145
|
+
firstFetching: lastQuery.isFetching && proposals.length === 0,
|
|
146
|
+
nextKey,
|
|
147
|
+
isFetching: lastQuery.isFetching,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ChainGetter } from "../../../chain";
|
|
2
|
+
import { ObservableCosmwasmContractChainQuery } from "../contract-query";
|
|
3
|
+
import { QuerySharedContext } from "../../../common";
|
|
4
|
+
import { ObservableChainQueryMap } from "../../chain-query";
|
|
5
|
+
import { computed } from "mobx";
|
|
6
|
+
|
|
7
|
+
interface NeutronGovVote {
|
|
8
|
+
voter: string;
|
|
9
|
+
vote: "yes" | "no" | "abstain";
|
|
10
|
+
power: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface NeutronGovVoteResponse {
|
|
14
|
+
vote: NeutronGovVote | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class ObservableQueryNeutronProposalVoteInner extends ObservableCosmwasmContractChainQuery<NeutronGovVoteResponse> {
|
|
18
|
+
public static readonly NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET =
|
|
19
|
+
"neutron1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshlt6zh";
|
|
20
|
+
public static readonly NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET =
|
|
21
|
+
"neutron19sf2y4dvgt02kczemvhktrwvt4aunrahw8qkjq6u3pehdujwssgqrs5e4h";
|
|
22
|
+
|
|
23
|
+
protected proposalId: string;
|
|
24
|
+
protected bech32Address: string;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
sharedContext: QuerySharedContext,
|
|
28
|
+
chainId: string,
|
|
29
|
+
chainGetter: ChainGetter,
|
|
30
|
+
proposalId: string,
|
|
31
|
+
bech32Address: string
|
|
32
|
+
) {
|
|
33
|
+
const contractAddress =
|
|
34
|
+
chainId === "neutron-1"
|
|
35
|
+
? ObservableQueryNeutronProposalVoteInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_MAINNET
|
|
36
|
+
: chainId === "pion-1"
|
|
37
|
+
? ObservableQueryNeutronProposalVoteInner.NEUTRON_PROPOSAL_MODULE_ADDRESS_TESTNET
|
|
38
|
+
: "";
|
|
39
|
+
|
|
40
|
+
super(sharedContext, chainId, chainGetter, contractAddress, {
|
|
41
|
+
get_vote: { proposal_id: parseInt(proposalId), voter: bech32Address },
|
|
42
|
+
});
|
|
43
|
+
this.proposalId = proposalId;
|
|
44
|
+
this.bech32Address = bech32Address;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@computed
|
|
48
|
+
get vote(): "Yes" | "Abstain" | "No" | "NoWithVeto" | "Unspecified" {
|
|
49
|
+
if (!this.response?.data?.vote) {
|
|
50
|
+
return "Unspecified";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const voteOption = this.response.data.vote.vote;
|
|
54
|
+
switch (voteOption) {
|
|
55
|
+
case "yes":
|
|
56
|
+
return "Yes";
|
|
57
|
+
case "abstain":
|
|
58
|
+
return "Abstain";
|
|
59
|
+
case "no":
|
|
60
|
+
return "No";
|
|
61
|
+
default:
|
|
62
|
+
return "Unspecified";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
refetch() {
|
|
67
|
+
this.fetch();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected override canFetch(): boolean {
|
|
71
|
+
return (
|
|
72
|
+
super.canFetch() &&
|
|
73
|
+
this.bech32Address.length > 0 &&
|
|
74
|
+
(this.chainId === "neutron-1" || this.chainId === "pion-1")
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class ObservableQueryNeutronProposalVote extends ObservableChainQueryMap<NeutronGovVoteResponse> {
|
|
80
|
+
constructor(
|
|
81
|
+
sharedContext: QuerySharedContext,
|
|
82
|
+
chainId: string,
|
|
83
|
+
chainGetter: ChainGetter
|
|
84
|
+
) {
|
|
85
|
+
super(sharedContext, chainId, chainGetter, (param: string) => {
|
|
86
|
+
const { proposalId, voter } = JSON.parse(param);
|
|
87
|
+
|
|
88
|
+
return new ObservableQueryNeutronProposalVoteInner(
|
|
89
|
+
this.sharedContext,
|
|
90
|
+
this.chainId,
|
|
91
|
+
this.chainGetter,
|
|
92
|
+
proposalId,
|
|
93
|
+
voter
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getVote(
|
|
99
|
+
proposalId: string,
|
|
100
|
+
voter: string
|
|
101
|
+
): ObservableQueryNeutronProposalVoteInner {
|
|
102
|
+
const param = JSON.stringify({
|
|
103
|
+
proposalId,
|
|
104
|
+
voter,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return this.get(param) as ObservableQueryNeutronProposalVoteInner;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -6,6 +6,8 @@ import { ObservableQueryCw20BalanceRegistry } from "./cw20-balance";
|
|
|
6
6
|
import { QuerySharedContext } from "../../common";
|
|
7
7
|
import { ObservableQueryNeutronStakingRewards } from "./neutron/staking-rewards";
|
|
8
8
|
import { ObservableQueryNeutronStakingRewardsConfig } from "./neutron/staking-rewards-config";
|
|
9
|
+
import { ObservableQueryNeutronGovernance } from "./neutron/governance-proposals";
|
|
10
|
+
import { ObservableQueryNeutronProposalVote } from "./neutron/governance-vote";
|
|
9
11
|
|
|
10
12
|
export interface CosmwasmQueries {
|
|
11
13
|
cosmwasm: CosmwasmQueriesImpl;
|
|
@@ -40,6 +42,9 @@ export class CosmwasmQueriesImpl {
|
|
|
40
42
|
public readonly querycw20ContractInfo: DeepReadonly<ObservableQueryCw20ContractInfo>;
|
|
41
43
|
public readonly queryNeutronStakingRewards: DeepReadonly<ObservableQueryNeutronStakingRewards>;
|
|
42
44
|
public readonly queryNeutronStakingRewardsConfig: DeepReadonly<ObservableQueryNeutronStakingRewardsConfig>;
|
|
45
|
+
public readonly queryNeutronGovernance: DeepReadonly<ObservableQueryNeutronGovernance>;
|
|
46
|
+
public readonly queryNeutronVote: DeepReadonly<ObservableQueryNeutronProposalVote>;
|
|
47
|
+
|
|
43
48
|
constructor(
|
|
44
49
|
base: QueriesSetBase,
|
|
45
50
|
sharedContext: QuerySharedContext,
|
|
@@ -68,5 +73,17 @@ export class CosmwasmQueriesImpl {
|
|
|
68
73
|
chainId,
|
|
69
74
|
chainGetter
|
|
70
75
|
);
|
|
76
|
+
|
|
77
|
+
this.queryNeutronGovernance = new ObservableQueryNeutronGovernance(
|
|
78
|
+
sharedContext,
|
|
79
|
+
chainId,
|
|
80
|
+
chainGetter
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
this.queryNeutronVote = new ObservableQueryNeutronProposalVote(
|
|
84
|
+
sharedContext,
|
|
85
|
+
chainId,
|
|
86
|
+
chainGetter
|
|
87
|
+
);
|
|
71
88
|
}
|
|
72
89
|
}
|