@keplr-wallet/stores 0.13.37 → 0.13.39

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.
Files changed (57) hide show
  1. package/build/common/query/query.d.ts +1 -0
  2. package/build/common/query/query.js +23 -16
  3. package/build/common/query/query.js.map +1 -1
  4. package/build/query/cosmos/staking/delegations.d.ts +4 -0
  5. package/build/query/cosmos/staking/delegations.js +35 -3
  6. package/build/query/cosmos/staking/delegations.js.map +1 -1
  7. package/build/query/cosmos/staking/initia-delegations.d.ts +4 -0
  8. package/build/query/cosmos/staking/initia-delegations.js +42 -4
  9. package/build/query/cosmos/staking/initia-delegations.js.map +1 -1
  10. package/build/query/cosmos/staking/initia-unbonding-delegations.d.ts +4 -0
  11. package/build/query/cosmos/staking/initia-unbonding-delegations.js +31 -3
  12. package/build/query/cosmos/staking/initia-unbonding-delegations.js.map +1 -1
  13. package/build/query/cosmos/staking/response-guards.spec.d.ts +1 -0
  14. package/build/query/cosmos/staking/response-guards.spec.js +318 -0
  15. package/build/query/cosmos/staking/response-guards.spec.js.map +1 -0
  16. package/build/query/cosmos/staking/rewards.d.ts +4 -0
  17. package/build/query/cosmos/staking/rewards.js +48 -10
  18. package/build/query/cosmos/staking/rewards.js.map +1 -1
  19. package/build/query/cosmos/staking/types.d.ts +13 -2
  20. package/build/query/cosmos/staking/types.js +162 -1
  21. package/build/query/cosmos/staking/types.js.map +1 -1
  22. package/build/query/cosmos/staking/unbonding-delegations.d.ts +4 -0
  23. package/build/query/cosmos/staking/unbonding-delegations.js +30 -2
  24. package/build/query/cosmos/staking/unbonding-delegations.js.map +1 -1
  25. package/build/query/cosmwasm/index.d.ts +0 -4
  26. package/build/query/cosmwasm/index.js +0 -4
  27. package/build/query/cosmwasm/index.js.map +1 -1
  28. package/build/query/cosmwasm/queries.d.ts +0 -8
  29. package/build/query/cosmwasm/queries.js +0 -9
  30. package/build/query/cosmwasm/queries.js.map +1 -1
  31. package/package.json +12 -11
  32. package/src/common/query/query.ts +32 -21
  33. package/src/query/cosmos/staking/delegations.ts +35 -4
  34. package/src/query/cosmos/staking/initia-delegations.ts +51 -4
  35. package/src/query/cosmos/staking/initia-unbonding-delegations.ts +30 -3
  36. package/src/query/cosmos/staking/response-guards.spec.ts +414 -0
  37. package/src/query/cosmos/staking/rewards.ts +45 -10
  38. package/src/query/cosmos/staking/types.ts +210 -4
  39. package/src/query/cosmos/staking/unbonding-delegations.ts +29 -3
  40. package/src/query/cosmwasm/index.ts +0 -4
  41. package/src/query/cosmwasm/queries.ts +0 -33
  42. package/build/query/cosmwasm/neutron/governance-proposals.d.ts +0 -64
  43. package/build/query/cosmwasm/neutron/governance-proposals.js +0 -83
  44. package/build/query/cosmwasm/neutron/governance-proposals.js.map +0 -1
  45. package/build/query/cosmwasm/neutron/governance-vote.d.ts +0 -27
  46. package/build/query/cosmwasm/neutron/governance-vote.js +0 -73
  47. package/build/query/cosmwasm/neutron/governance-vote.js.map +0 -1
  48. package/build/query/cosmwasm/neutron/staking-rewards-config.d.ts +0 -18
  49. package/build/query/cosmwasm/neutron/staking-rewards-config.js +0 -42
  50. package/build/query/cosmwasm/neutron/staking-rewards-config.js.map +0 -1
  51. package/build/query/cosmwasm/neutron/staking-rewards.d.ts +0 -25
  52. package/build/query/cosmwasm/neutron/staking-rewards.js +0 -75
  53. package/build/query/cosmwasm/neutron/staking-rewards.js.map +0 -1
  54. package/src/query/cosmwasm/neutron/governance-proposals.ts +0 -150
  55. package/src/query/cosmwasm/neutron/governance-vote.ts +0 -109
  56. package/src/query/cosmwasm/neutron/staking-rewards-config.ts +0 -54
  57. package/src/query/cosmwasm/neutron/staking-rewards.ts +0 -104
@@ -1,42 +0,0 @@
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.ObservableQueryNeutronStakingRewardsConfig = void 0;
10
- const mobx_1 = require("mobx");
11
- const contract_query_1 = require("../contract-query");
12
- class ObservableQueryNeutronStakingRewardsConfig extends contract_query_1.ObservableCosmwasmContractChainQuery {
13
- constructor(sharedContext, chainId, chainGetter) {
14
- super(sharedContext, chainId, chainGetter, ObservableQueryNeutronStakingRewardsConfig.NEUTRON_REWARDS_CONTRACT_ADDRESS, {
15
- config: {},
16
- });
17
- (0, mobx_1.makeObservable)(this);
18
- }
19
- canFetch() {
20
- return super.canFetch();
21
- }
22
- get config() {
23
- var _a, _b;
24
- if (!((_a = this.response) === null || _a === void 0 ? void 0 : _a.data)) {
25
- return {
26
- owner: "",
27
- dao_address: "",
28
- staking_info_proxy: "",
29
- annual_reward_rate_bps: 0,
30
- blocks_per_year: 0,
31
- staking_denom: "",
32
- };
33
- }
34
- return (_b = this.response) === null || _b === void 0 ? void 0 : _b.data;
35
- }
36
- }
37
- ObservableQueryNeutronStakingRewardsConfig.NEUTRON_REWARDS_CONTRACT_ADDRESS = "neutron1gqq3c735pj6ese3yru5xr6ud0fvxgltxesygvyyzpsrt74v6yg4sgkrgwq";
38
- __decorate([
39
- mobx_1.computed
40
- ], ObservableQueryNeutronStakingRewardsConfig.prototype, "config", null);
41
- exports.ObservableQueryNeutronStakingRewardsConfig = ObservableQueryNeutronStakingRewardsConfig;
42
- //# sourceMappingURL=staking-rewards-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"staking-rewards-config.js","sourceRoot":"","sources":["../../../../src/query/cosmwasm/neutron/staking-rewards-config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+BAAgD;AAEhD,sDAAyE;AAYzE,MAAa,0CAA2C,SAAQ,qDAAyE;IAIvI,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB;QAExB,KAAK,CACH,aAAa,EACb,OAAO,EACP,WAAW,EACX,0CAA0C,CAAC,gCAAgC,EAC3E;YACE,MAAM,EAAE,EAAE;SACX,CACF,CAAC;QACF,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAEkB,QAAQ;QACzB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAGD,IAAI,MAAM;;QACR,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,CAAA,EAAE;YACxB,OAAO;gBACL,KAAK,EAAE,EAAE;gBACT,WAAW,EAAE,EAAE;gBACf,kBAAkB,EAAE,EAAE;gBACtB,sBAAsB,EAAE,CAAC;gBACzB,eAAe,EAAE,CAAC;gBAClB,aAAa,EAAE,EAAE;aAClB,CAAC;SACH;QACD,OAAO,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,CAAC;IAC7B,CAAC;;AArCsB,2EAAgC,GACrD,oEAAoE,CAAC;AAwBvE;IADC,eAAQ;wEAaR;AAtCU,gGAA0C"}
@@ -1,25 +0,0 @@
1
- import { ChainGetter } from "../../../chain";
2
- import { CoinPretty } from "@keplr-wallet/unit";
3
- import { ObservableCosmwasmContractChainQuery } from "../contract-query";
4
- import { QuerySharedContext } from "../../../common";
5
- import { AppCurrency } from "@keplr-wallet/types";
6
- import { ObservableChainQueryMap } from "../../chain-query";
7
- interface NeutronStakingRewardsResponse {
8
- pending_rewards?: {
9
- denom?: string;
10
- amount?: string;
11
- };
12
- }
13
- declare class ObservableQueryNeutronStakingRewardsInner extends ObservableCosmwasmContractChainQuery<NeutronStakingRewardsResponse> {
14
- protected readonly bech32Address: string;
15
- static readonly NEUTRON_REWARDS_CONTRACT_ADDRESS = "neutron1gqq3c735pj6ese3yru5xr6ud0fvxgltxesygvyyzpsrt74v6yg4sgkrgwq";
16
- constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, bech32Address: string);
17
- protected canFetch(): boolean;
18
- get pendingReward(): CoinPretty;
19
- get rewardCurrency(): AppCurrency | undefined;
20
- }
21
- export declare class ObservableQueryNeutronStakingRewards extends ObservableChainQueryMap<NeutronStakingRewardsResponse> {
22
- constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
23
- getRewardFor(bech32Address: string): ObservableQueryNeutronStakingRewardsInner;
24
- }
25
- export {};
@@ -1,75 +0,0 @@
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.ObservableQueryNeutronStakingRewards = void 0;
10
- const chain_1 = require("../../../chain");
11
- const unit_1 = require("@keplr-wallet/unit");
12
- const contract_query_1 = require("../contract-query");
13
- const chain_query_1 = require("../../chain-query");
14
- const mobx_1 = require("mobx");
15
- class ObservableQueryNeutronStakingRewardsInner extends contract_query_1.ObservableCosmwasmContractChainQuery {
16
- constructor(sharedContext, chainId, chainGetter, bech32Address) {
17
- super(sharedContext, chainId, chainGetter, ObservableQueryNeutronStakingRewardsInner.NEUTRON_REWARDS_CONTRACT_ADDRESS, {
18
- rewards: { user: bech32Address },
19
- });
20
- this.bech32Address = bech32Address;
21
- }
22
- canFetch() {
23
- return super.canFetch() && this.bech32Address !== "";
24
- }
25
- get pendingReward() {
26
- var _a, _b;
27
- if (!((_b = (_a = this.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.pending_rewards)) {
28
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
29
- const cosmosInfo = (0, chain_1.requireCosmosInfo)(mcInfo2);
30
- const defaultCurrency = cosmosInfo.stakeCurrency || cosmosInfo.currencies[0];
31
- return new unit_1.CoinPretty(defaultCurrency, new unit_1.Int(0)).ready(false);
32
- }
33
- const reward = this.response.data.pending_rewards;
34
- if (!reward.denom || !reward.amount) {
35
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
36
- const cosmosInfo = (0, chain_1.requireCosmosInfo)(mcInfo2);
37
- const defaultCurrency = cosmosInfo.stakeCurrency || cosmosInfo.currencies[0];
38
- return new unit_1.CoinPretty(defaultCurrency, new unit_1.Int(0)).ready(false);
39
- }
40
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
41
- const currency = mcInfo2.forceFindCurrency(reward.denom);
42
- return new unit_1.CoinPretty(currency, new unit_1.Int(reward.amount)).ready(!this.isFetching);
43
- }
44
- get rewardCurrency() {
45
- var _a, _b;
46
- if (!((_b = (_a = this.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.pending_rewards)) {
47
- return undefined;
48
- }
49
- const reward = this.response.data.pending_rewards;
50
- if (!reward.denom || !reward.amount) {
51
- return undefined;
52
- }
53
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
54
- return mcInfo2.findCurrency(reward.denom);
55
- }
56
- }
57
- ObservableQueryNeutronStakingRewardsInner.NEUTRON_REWARDS_CONTRACT_ADDRESS = "neutron1gqq3c735pj6ese3yru5xr6ud0fvxgltxesygvyyzpsrt74v6yg4sgkrgwq";
58
- __decorate([
59
- mobx_1.computed
60
- ], ObservableQueryNeutronStakingRewardsInner.prototype, "pendingReward", null);
61
- __decorate([
62
- mobx_1.computed
63
- ], ObservableQueryNeutronStakingRewardsInner.prototype, "rewardCurrency", null);
64
- class ObservableQueryNeutronStakingRewards extends chain_query_1.ObservableChainQueryMap {
65
- constructor(sharedContext, chainId, chainGetter) {
66
- super(sharedContext, chainId, chainGetter, (contractAddress) => {
67
- return new ObservableQueryNeutronStakingRewardsInner(this.sharedContext, this.chainId, this.chainGetter, contractAddress);
68
- });
69
- }
70
- getRewardFor(bech32Address) {
71
- return this.get(bech32Address);
72
- }
73
- }
74
- exports.ObservableQueryNeutronStakingRewards = ObservableQueryNeutronStakingRewards;
75
- //# sourceMappingURL=staking-rewards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"staking-rewards.js","sourceRoot":"","sources":["../../../../src/query/cosmwasm/neutron/staking-rewards.ts"],"names":[],"mappings":"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"}
@@ -1,150 +0,0 @@
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
- }
@@ -1,109 +0,0 @@
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
- }
@@ -1,54 +0,0 @@
1
- import { computed, makeObservable } from "mobx";
2
- import { ChainGetter } from "../../../chain";
3
- import { ObservableCosmwasmContractChainQuery } from "../contract-query";
4
- import { QuerySharedContext } from "../../../common";
5
-
6
- interface NeutronStakingRewardsConfigResponse {
7
- owner?: string;
8
- dao_address?: string;
9
- staking_info_proxy?: string;
10
- annual_reward_rate_bps?: number; // APR in basis points (e.g., 500 = 5%)
11
- blocks_per_year?: number;
12
- staking_denom?: string;
13
- }
14
-
15
- export class ObservableQueryNeutronStakingRewardsConfig extends ObservableCosmwasmContractChainQuery<NeutronStakingRewardsConfigResponse> {
16
- public static readonly NEUTRON_REWARDS_CONTRACT_ADDRESS =
17
- "neutron1gqq3c735pj6ese3yru5xr6ud0fvxgltxesygvyyzpsrt74v6yg4sgkrgwq";
18
-
19
- constructor(
20
- sharedContext: QuerySharedContext,
21
- chainId: string,
22
- chainGetter: ChainGetter
23
- ) {
24
- super(
25
- sharedContext,
26
- chainId,
27
- chainGetter,
28
- ObservableQueryNeutronStakingRewardsConfig.NEUTRON_REWARDS_CONTRACT_ADDRESS,
29
- {
30
- config: {},
31
- }
32
- );
33
- makeObservable(this);
34
- }
35
-
36
- protected override canFetch(): boolean {
37
- return super.canFetch();
38
- }
39
-
40
- @computed
41
- get config(): NeutronStakingRewardsConfigResponse {
42
- if (!this.response?.data) {
43
- return {
44
- owner: "",
45
- dao_address: "",
46
- staking_info_proxy: "",
47
- annual_reward_rate_bps: 0,
48
- blocks_per_year: 0,
49
- staking_denom: "",
50
- };
51
- }
52
- return this.response?.data;
53
- }
54
- }
@@ -1,104 +0,0 @@
1
- import { ChainGetter, requireCosmosInfo } from "../../../chain";
2
- import { CoinPretty, Int } from "@keplr-wallet/unit";
3
- import { ObservableCosmwasmContractChainQuery } from "../contract-query";
4
- import { QuerySharedContext } from "../../../common";
5
- import { AppCurrency } from "@keplr-wallet/types";
6
- import { ObservableChainQueryMap } from "../../chain-query";
7
- import { computed } from "mobx";
8
-
9
- interface NeutronStakingRewardsResponse {
10
- pending_rewards?: {
11
- denom?: string;
12
- amount?: string;
13
- };
14
- }
15
-
16
- class ObservableQueryNeutronStakingRewardsInner extends ObservableCosmwasmContractChainQuery<NeutronStakingRewardsResponse> {
17
- public static readonly NEUTRON_REWARDS_CONTRACT_ADDRESS =
18
- "neutron1gqq3c735pj6ese3yru5xr6ud0fvxgltxesygvyyzpsrt74v6yg4sgkrgwq";
19
-
20
- constructor(
21
- sharedContext: QuerySharedContext,
22
- chainId: string,
23
- chainGetter: ChainGetter,
24
- protected readonly bech32Address: string
25
- ) {
26
- super(
27
- sharedContext,
28
- chainId,
29
- chainGetter,
30
- ObservableQueryNeutronStakingRewardsInner.NEUTRON_REWARDS_CONTRACT_ADDRESS,
31
- {
32
- rewards: { user: bech32Address },
33
- }
34
- );
35
- }
36
-
37
- protected override canFetch(): boolean {
38
- return super.canFetch() && this.bech32Address !== "";
39
- }
40
-
41
- @computed
42
- get pendingReward(): CoinPretty {
43
- if (!this.response?.data?.pending_rewards) {
44
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
45
- const cosmosInfo = requireCosmosInfo(mcInfo2);
46
- const defaultCurrency =
47
- cosmosInfo.stakeCurrency || cosmosInfo.currencies[0];
48
-
49
- return new CoinPretty(defaultCurrency, new Int(0)).ready(false);
50
- }
51
-
52
- const reward = this.response.data.pending_rewards;
53
- if (!reward.denom || !reward.amount) {
54
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
55
- const cosmosInfo = requireCosmosInfo(mcInfo2);
56
- const defaultCurrency =
57
- cosmosInfo.stakeCurrency || cosmosInfo.currencies[0];
58
-
59
- return new CoinPretty(defaultCurrency, new Int(0)).ready(false);
60
- }
61
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
62
- const currency = mcInfo2.forceFindCurrency(reward.denom);
63
-
64
- return new CoinPretty(currency, new Int(reward.amount)).ready(
65
- !this.isFetching
66
- );
67
- }
68
-
69
- @computed
70
- get rewardCurrency(): AppCurrency | undefined {
71
- if (!this.response?.data?.pending_rewards) {
72
- return undefined;
73
- }
74
- const reward = this.response.data.pending_rewards;
75
- if (!reward.denom || !reward.amount) {
76
- return undefined;
77
- }
78
- const mcInfo2 = this.chainGetter.getModularChain(this.chainId);
79
- return mcInfo2.findCurrency(reward.denom);
80
- }
81
- }
82
-
83
- export class ObservableQueryNeutronStakingRewards extends ObservableChainQueryMap<NeutronStakingRewardsResponse> {
84
- constructor(
85
- sharedContext: QuerySharedContext,
86
- chainId: string,
87
- chainGetter: ChainGetter
88
- ) {
89
- super(sharedContext, chainId, chainGetter, (contractAddress: string) => {
90
- return new ObservableQueryNeutronStakingRewardsInner(
91
- this.sharedContext,
92
- this.chainId,
93
- this.chainGetter,
94
- contractAddress
95
- );
96
- });
97
- }
98
-
99
- getRewardFor(
100
- bech32Address: string
101
- ): ObservableQueryNeutronStakingRewardsInner {
102
- return this.get(bech32Address) as ObservableQueryNeutronStakingRewardsInner;
103
- }
104
- }