decentralcardgame-cardchain-client-ts 0.0.3 → 0.0.4
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/DecentralCardGame.cardchain.cardchain/module.js +1044 -0
- package/DecentralCardGame.cardchain.cardchain/registry.js +72 -70
- package/DecentralCardGame.cardchain.cardchain/rest.js +1 -1
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.js +30 -6
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/council.js +11 -17
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.js +1 -217
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.js +166 -8
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.js +7 -65
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/params.js +30 -10
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/tx.js +4137 -0
- package/DecentralCardGame.cardchain.cardchain/types.js +22 -21
- package/client.js +2 -1
- package/cosmos.authz.v1beta1/module.js +19 -19
- package/cosmos.authz.v1beta1/registry.js +2 -2
- package/cosmos.distribution.v1beta1/module.js +24 -24
- package/cosmos.distribution.v1beta1/registry.js +4 -4
- package/cosmos.gov.v1/module.js +31 -31
- package/cosmos.gov.v1/registry.js +4 -4
- package/cosmos.gov.v1beta1/module.js +22 -22
- package/cosmos.gov.v1beta1/registry.js +2 -2
- package/cosmos.group.v1/module.js +102 -102
- package/cosmos.group.v1/registry.js +14 -14
- package/cosmos.group.v1/rest.js +15 -0
- package/cosmos.group.v1/types/cosmos/group/v1/query.js +110 -0
- package/cosmos.staking.v1beta1/module.js +40 -40
- package/cosmos.staking.v1beta1/registry.js +8 -8
- package/cosmos.vesting.v1beta1/module.js +16 -16
- package/cosmos.vesting.v1beta1/registry.js +2 -2
- package/ibc.applications.interchain_accounts.controller.v1/rest.js +9 -0
- package/ibc.applications.interchain_accounts.controller.v1/types/google/protobuf/any.js +99 -0
- package/ibc.applications.interchain_accounts.controller.v1/types/ibc/applications/interchain_accounts/controller/v1/tx.js +266 -0
- package/ibc.applications.interchain_accounts.controller.v1/types/ibc/applications/interchain_accounts/v1/packet.js +192 -0
- package/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/tx.js +24 -6
- package/ibc.core.client.v1/rest.js +14 -14
- package/ibc.core.connection.v1/rest.js +14 -0
- package/ibc.core.connection.v1/types/ibc/core/connection/v1/query.js +83 -1
- package/package.json +2 -2
- package/tsconfig.json +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { Card } from "./types/cardchain/card";
|
|
2
|
-
import { Collection } from "./types/cardchain/collection";
|
|
3
|
-
import { CollectionProposal } from "./types/cardchain/collection_proposal";
|
|
4
|
-
import { CopyrightProposal } from "./types/cardchain/copyright_proposal";
|
|
5
|
-
import { WrapClearResponse } from "./types/cardchain/council";
|
|
6
|
-
import { WrapHashResponse } from "./types/cardchain/council";
|
|
7
|
-
import { Image } from "./types/cardchain/image";
|
|
8
|
-
import { MatchPlayer } from "./types/cardchain/match";
|
|
9
|
-
import { MatchReporterProposal } from "./types/cardchain/match_reporter_proposal";
|
|
10
|
-
import { Num } from "./types/cardchain/num";
|
|
11
|
-
import { Params } from "./types/cardchain/params";
|
|
12
|
-
import { IgnoreMatches } from "./types/cardchain/query";
|
|
13
|
-
import { IgnoreSellOffers } from "./types/cardchain/query";
|
|
14
|
-
import { QueryQServerResponse } from "./types/cardchain/query";
|
|
15
|
-
import { RunningAverage } from "./types/cardchain/running_average";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
1
|
+
import { Card } from "./types/cardchain/cardchain/card";
|
|
2
|
+
import { Collection } from "./types/cardchain/cardchain/collection";
|
|
3
|
+
import { CollectionProposal } from "./types/cardchain/cardchain/collection_proposal";
|
|
4
|
+
import { CopyrightProposal } from "./types/cardchain/cardchain/copyright_proposal";
|
|
5
|
+
import { WrapClearResponse } from "./types/cardchain/cardchain/council";
|
|
6
|
+
import { WrapHashResponse } from "./types/cardchain/cardchain/council";
|
|
7
|
+
import { Image } from "./types/cardchain/cardchain/image";
|
|
8
|
+
import { MatchPlayer } from "./types/cardchain/cardchain/match";
|
|
9
|
+
import { MatchReporterProposal } from "./types/cardchain/cardchain/match_reporter_proposal";
|
|
10
|
+
import { Num } from "./types/cardchain/cardchain/num";
|
|
11
|
+
import { Params } from "./types/cardchain/cardchain/params";
|
|
12
|
+
import { IgnoreMatches } from "./types/cardchain/cardchain/query";
|
|
13
|
+
import { IgnoreSellOffers } from "./types/cardchain/cardchain/query";
|
|
14
|
+
import { QueryQServerResponse } from "./types/cardchain/cardchain/query";
|
|
15
|
+
import { RunningAverage } from "./types/cardchain/cardchain/running_average";
|
|
16
|
+
import { SingleVote } from "./types/cardchain/cardchain/tx";
|
|
17
|
+
import { BoosterPack } from "./types/cardchain/cardchain/user";
|
|
18
|
+
import { AirDrops } from "./types/cardchain/cardchain/user";
|
|
19
|
+
import { VoteRight } from "./types/cardchain/cardchain/vote_right";
|
|
20
|
+
import { VotingResult } from "./types/cardchain/cardchain/voting_result";
|
|
21
|
+
import { VotingResults } from "./types/cardchain/cardchain/voting_results";
|
|
22
|
+
export { Card, Collection, CollectionProposal, CopyrightProposal, WrapClearResponse, WrapHashResponse, Image, MatchPlayer, MatchReporterProposal, Num, Params, IgnoreMatches, IgnoreSellOffers, QueryQServerResponse, RunningAverage, SingleVote, BoosterPack, AirDrops, VoteRight, VotingResult, VotingResults, };
|
package/client.js
CHANGED
|
@@ -6,7 +6,7 @@ const defaultFee = {
|
|
|
6
6
|
amount: [],
|
|
7
7
|
gas: "200000",
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
class IgniteClient extends EventEmitter {
|
|
10
10
|
static plugin(plugin) {
|
|
11
11
|
const currentPlugins = this.plugins;
|
|
12
12
|
class AugmentedClient extends this {
|
|
@@ -133,3 +133,4 @@ export class IgniteClient extends EventEmitter {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
IgniteClient.plugins = [];
|
|
136
|
+
export { IgniteClient };
|
|
@@ -3,16 +3,16 @@ import { SigningStargateClient } from "@cosmjs/stargate";
|
|
|
3
3
|
import { Registry } from "@cosmjs/proto-signing";
|
|
4
4
|
import { msgTypes } from './registry';
|
|
5
5
|
import { Api } from "./rest";
|
|
6
|
-
import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx";
|
|
7
6
|
import { MsgExec } from "./types/cosmos/authz/v1beta1/tx";
|
|
8
7
|
import { MsgRevoke } from "./types/cosmos/authz/v1beta1/tx";
|
|
8
|
+
import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx";
|
|
9
9
|
import { GenericAuthorization as typeGenericAuthorization } from "./types";
|
|
10
10
|
import { Grant as typeGrant } from "./types";
|
|
11
11
|
import { GrantAuthorization as typeGrantAuthorization } from "./types";
|
|
12
12
|
import { GrantQueueItem as typeGrantQueueItem } from "./types";
|
|
13
13
|
import { EventGrant as typeEventGrant } from "./types";
|
|
14
14
|
import { EventRevoke as typeEventRevoke } from "./types";
|
|
15
|
-
export {
|
|
15
|
+
export { MsgExec, MsgRevoke, MsgGrant };
|
|
16
16
|
export const registry = new Registry(msgTypes);
|
|
17
17
|
function getStructure(template) {
|
|
18
18
|
const structure = { fields: [] };
|
|
@@ -28,20 +28,6 @@ const defaultFee = {
|
|
|
28
28
|
};
|
|
29
29
|
export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26657", prefix: "cosmos" }) => {
|
|
30
30
|
return {
|
|
31
|
-
async sendMsgGrant({ value, fee, memo }) {
|
|
32
|
-
if (!signer) {
|
|
33
|
-
throw new Error('TxClient:sendMsgGrant: Unable to sign Tx. Signer is not present.');
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const { address } = (await signer.getAccounts())[0];
|
|
37
|
-
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
38
|
-
let msg = this.msgGrant({ value: MsgGrant.fromPartial(value) });
|
|
39
|
-
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
throw new Error('TxClient:sendMsgGrant: Could not broadcast Tx: ' + e.message);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
31
|
async sendMsgExec({ value, fee, memo }) {
|
|
46
32
|
if (!signer) {
|
|
47
33
|
throw new Error('TxClient:sendMsgExec: Unable to sign Tx. Signer is not present.');
|
|
@@ -70,12 +56,18 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
70
56
|
throw new Error('TxClient:sendMsgRevoke: Could not broadcast Tx: ' + e.message);
|
|
71
57
|
}
|
|
72
58
|
},
|
|
73
|
-
|
|
59
|
+
async sendMsgGrant({ value, fee, memo }) {
|
|
60
|
+
if (!signer) {
|
|
61
|
+
throw new Error('TxClient:sendMsgGrant: Unable to sign Tx. Signer is not present.');
|
|
62
|
+
}
|
|
74
63
|
try {
|
|
75
|
-
|
|
64
|
+
const { address } = (await signer.getAccounts())[0];
|
|
65
|
+
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
66
|
+
let msg = this.msgGrant({ value: MsgGrant.fromPartial(value) });
|
|
67
|
+
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
76
68
|
}
|
|
77
69
|
catch (e) {
|
|
78
|
-
throw new Error('TxClient:
|
|
70
|
+
throw new Error('TxClient:sendMsgGrant: Could not broadcast Tx: ' + e.message);
|
|
79
71
|
}
|
|
80
72
|
},
|
|
81
73
|
msgExec({ value }) {
|
|
@@ -94,6 +86,14 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
94
86
|
throw new Error('TxClient:MsgRevoke: Could not create message: ' + e.message);
|
|
95
87
|
}
|
|
96
88
|
},
|
|
89
|
+
msgGrant({ value }) {
|
|
90
|
+
try {
|
|
91
|
+
return { typeUrl: "/cosmos.authz.v1beta1.MsgGrant", value: MsgGrant.fromPartial(value) };
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
throw new Error('TxClient:MsgGrant: Could not create message: ' + e.message);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
export const queryClient = ({ addr: addr } = { addr: "http://localhost:1317" }) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx";
|
|
2
1
|
import { MsgExec } from "./types/cosmos/authz/v1beta1/tx";
|
|
3
2
|
import { MsgRevoke } from "./types/cosmos/authz/v1beta1/tx";
|
|
3
|
+
import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx";
|
|
4
4
|
const msgTypes = [
|
|
5
|
-
["/cosmos.authz.v1beta1.MsgGrant", MsgGrant],
|
|
6
5
|
["/cosmos.authz.v1beta1.MsgExec", MsgExec],
|
|
7
6
|
["/cosmos.authz.v1beta1.MsgRevoke", MsgRevoke],
|
|
7
|
+
["/cosmos.authz.v1beta1.MsgGrant", MsgGrant],
|
|
8
8
|
];
|
|
9
9
|
export { msgTypes };
|
|
@@ -3,10 +3,10 @@ import { SigningStargateClient } from "@cosmjs/stargate";
|
|
|
3
3
|
import { Registry } from "@cosmjs/proto-signing";
|
|
4
4
|
import { msgTypes } from './registry';
|
|
5
5
|
import { Api } from "./rest";
|
|
6
|
-
import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx";
|
|
7
|
-
import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx";
|
|
8
6
|
import { MsgFundCommunityPool } from "./types/cosmos/distribution/v1beta1/tx";
|
|
7
|
+
import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx";
|
|
9
8
|
import { MsgSetWithdrawAddress } from "./types/cosmos/distribution/v1beta1/tx";
|
|
9
|
+
import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx";
|
|
10
10
|
import { Params as typeParams } from "./types";
|
|
11
11
|
import { ValidatorHistoricalRewards as typeValidatorHistoricalRewards } from "./types";
|
|
12
12
|
import { ValidatorCurrentRewards as typeValidatorCurrentRewards } from "./types";
|
|
@@ -26,7 +26,7 @@ import { ValidatorHistoricalRewardsRecord as typeValidatorHistoricalRewardsRecor
|
|
|
26
26
|
import { ValidatorCurrentRewardsRecord as typeValidatorCurrentRewardsRecord } from "./types";
|
|
27
27
|
import { DelegatorStartingInfoRecord as typeDelegatorStartingInfoRecord } from "./types";
|
|
28
28
|
import { ValidatorSlashEventRecord as typeValidatorSlashEventRecord } from "./types";
|
|
29
|
-
export {
|
|
29
|
+
export { MsgFundCommunityPool, MsgWithdrawDelegatorReward, MsgSetWithdrawAddress, MsgWithdrawValidatorCommission };
|
|
30
30
|
export const registry = new Registry(msgTypes);
|
|
31
31
|
function getStructure(template) {
|
|
32
32
|
const structure = { fields: [] };
|
|
@@ -42,18 +42,18 @@ const defaultFee = {
|
|
|
42
42
|
};
|
|
43
43
|
export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26657", prefix: "cosmos" }) => {
|
|
44
44
|
return {
|
|
45
|
-
async
|
|
45
|
+
async sendMsgFundCommunityPool({ value, fee, memo }) {
|
|
46
46
|
if (!signer) {
|
|
47
|
-
throw new Error('TxClient:
|
|
47
|
+
throw new Error('TxClient:sendMsgFundCommunityPool: Unable to sign Tx. Signer is not present.');
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
50
|
const { address } = (await signer.getAccounts())[0];
|
|
51
51
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
52
|
-
let msg = this.
|
|
52
|
+
let msg = this.msgFundCommunityPool({ value: MsgFundCommunityPool.fromPartial(value) });
|
|
53
53
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
throw new Error('TxClient:
|
|
56
|
+
throw new Error('TxClient:sendMsgFundCommunityPool: Could not broadcast Tx: ' + e.message);
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
async sendMsgWithdrawDelegatorReward({ value, fee, memo }) {
|
|
@@ -70,40 +70,40 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
70
70
|
throw new Error('TxClient:sendMsgWithdrawDelegatorReward: Could not broadcast Tx: ' + e.message);
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
async
|
|
73
|
+
async sendMsgSetWithdrawAddress({ value, fee, memo }) {
|
|
74
74
|
if (!signer) {
|
|
75
|
-
throw new Error('TxClient:
|
|
75
|
+
throw new Error('TxClient:sendMsgSetWithdrawAddress: Unable to sign Tx. Signer is not present.');
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
78
|
const { address } = (await signer.getAccounts())[0];
|
|
79
79
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
80
|
-
let msg = this.
|
|
80
|
+
let msg = this.msgSetWithdrawAddress({ value: MsgSetWithdrawAddress.fromPartial(value) });
|
|
81
81
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
82
82
|
}
|
|
83
83
|
catch (e) {
|
|
84
|
-
throw new Error('TxClient:
|
|
84
|
+
throw new Error('TxClient:sendMsgSetWithdrawAddress: Could not broadcast Tx: ' + e.message);
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
async
|
|
87
|
+
async sendMsgWithdrawValidatorCommission({ value, fee, memo }) {
|
|
88
88
|
if (!signer) {
|
|
89
|
-
throw new Error('TxClient:
|
|
89
|
+
throw new Error('TxClient:sendMsgWithdrawValidatorCommission: Unable to sign Tx. Signer is not present.');
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
92
|
const { address } = (await signer.getAccounts())[0];
|
|
93
93
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
94
|
-
let msg = this.
|
|
94
|
+
let msg = this.msgWithdrawValidatorCommission({ value: MsgWithdrawValidatorCommission.fromPartial(value) });
|
|
95
95
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
96
96
|
}
|
|
97
97
|
catch (e) {
|
|
98
|
-
throw new Error('TxClient:
|
|
98
|
+
throw new Error('TxClient:sendMsgWithdrawValidatorCommission: Could not broadcast Tx: ' + e.message);
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
|
-
|
|
101
|
+
msgFundCommunityPool({ value }) {
|
|
102
102
|
try {
|
|
103
|
-
return { typeUrl: "/cosmos.distribution.v1beta1.
|
|
103
|
+
return { typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", value: MsgFundCommunityPool.fromPartial(value) };
|
|
104
104
|
}
|
|
105
105
|
catch (e) {
|
|
106
|
-
throw new Error('TxClient:
|
|
106
|
+
throw new Error('TxClient:MsgFundCommunityPool: Could not create message: ' + e.message);
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
109
|
msgWithdrawDelegatorReward({ value }) {
|
|
@@ -114,20 +114,20 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
114
114
|
throw new Error('TxClient:MsgWithdrawDelegatorReward: Could not create message: ' + e.message);
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
|
|
117
|
+
msgSetWithdrawAddress({ value }) {
|
|
118
118
|
try {
|
|
119
|
-
return { typeUrl: "/cosmos.distribution.v1beta1.
|
|
119
|
+
return { typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", value: MsgSetWithdrawAddress.fromPartial(value) };
|
|
120
120
|
}
|
|
121
121
|
catch (e) {
|
|
122
|
-
throw new Error('TxClient:
|
|
122
|
+
throw new Error('TxClient:MsgSetWithdrawAddress: Could not create message: ' + e.message);
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
|
-
|
|
125
|
+
msgWithdrawValidatorCommission({ value }) {
|
|
126
126
|
try {
|
|
127
|
-
return { typeUrl: "/cosmos.distribution.v1beta1.
|
|
127
|
+
return { typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", value: MsgWithdrawValidatorCommission.fromPartial(value) };
|
|
128
128
|
}
|
|
129
129
|
catch (e) {
|
|
130
|
-
throw new Error('TxClient:
|
|
130
|
+
throw new Error('TxClient:MsgWithdrawValidatorCommission: Could not create message: ' + e.message);
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx";
|
|
2
|
-
import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx";
|
|
3
1
|
import { MsgFundCommunityPool } from "./types/cosmos/distribution/v1beta1/tx";
|
|
2
|
+
import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx";
|
|
4
3
|
import { MsgSetWithdrawAddress } from "./types/cosmos/distribution/v1beta1/tx";
|
|
4
|
+
import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx";
|
|
5
5
|
const msgTypes = [
|
|
6
|
-
["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", MsgWithdrawValidatorCommission],
|
|
7
|
-
["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", MsgWithdrawDelegatorReward],
|
|
8
6
|
["/cosmos.distribution.v1beta1.MsgFundCommunityPool", MsgFundCommunityPool],
|
|
7
|
+
["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", MsgWithdrawDelegatorReward],
|
|
9
8
|
["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", MsgSetWithdrawAddress],
|
|
9
|
+
["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", MsgWithdrawValidatorCommission],
|
|
10
10
|
];
|
|
11
11
|
export { msgTypes };
|
package/cosmos.gov.v1/module.js
CHANGED
|
@@ -3,10 +3,10 @@ import { SigningStargateClient } from "@cosmjs/stargate";
|
|
|
3
3
|
import { Registry } from "@cosmjs/proto-signing";
|
|
4
4
|
import { msgTypes } from './registry';
|
|
5
5
|
import { Api } from "./rest";
|
|
6
|
+
import { MsgSubmitProposal } from "./types/cosmos/gov/v1/tx";
|
|
7
|
+
import { MsgDeposit } from "./types/cosmos/gov/v1/tx";
|
|
6
8
|
import { MsgVote } from "./types/cosmos/gov/v1/tx";
|
|
7
9
|
import { MsgVoteWeighted } from "./types/cosmos/gov/v1/tx";
|
|
8
|
-
import { MsgDeposit } from "./types/cosmos/gov/v1/tx";
|
|
9
|
-
import { MsgSubmitProposal } from "./types/cosmos/gov/v1/tx";
|
|
10
10
|
import { WeightedVoteOption as typeWeightedVoteOption } from "./types";
|
|
11
11
|
import { Deposit as typeDeposit } from "./types";
|
|
12
12
|
import { Proposal as typeProposal } from "./types";
|
|
@@ -15,7 +15,7 @@ import { Vote as typeVote } from "./types";
|
|
|
15
15
|
import { DepositParams as typeDepositParams } from "./types";
|
|
16
16
|
import { VotingParams as typeVotingParams } from "./types";
|
|
17
17
|
import { TallyParams as typeTallyParams } from "./types";
|
|
18
|
-
export {
|
|
18
|
+
export { MsgSubmitProposal, MsgDeposit, MsgVote, MsgVoteWeighted };
|
|
19
19
|
export const registry = new Registry(msgTypes);
|
|
20
20
|
function getStructure(template) {
|
|
21
21
|
const structure = { fields: [] };
|
|
@@ -31,92 +31,92 @@ const defaultFee = {
|
|
|
31
31
|
};
|
|
32
32
|
export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26657", prefix: "cosmos" }) => {
|
|
33
33
|
return {
|
|
34
|
-
async
|
|
34
|
+
async sendMsgSubmitProposal({ value, fee, memo }) {
|
|
35
35
|
if (!signer) {
|
|
36
|
-
throw new Error('TxClient:
|
|
36
|
+
throw new Error('TxClient:sendMsgSubmitProposal: Unable to sign Tx. Signer is not present.');
|
|
37
37
|
}
|
|
38
38
|
try {
|
|
39
39
|
const { address } = (await signer.getAccounts())[0];
|
|
40
40
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
41
|
-
let msg = this.
|
|
41
|
+
let msg = this.msgSubmitProposal({ value: MsgSubmitProposal.fromPartial(value) });
|
|
42
42
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
-
throw new Error('TxClient:
|
|
45
|
+
throw new Error('TxClient:sendMsgSubmitProposal: Could not broadcast Tx: ' + e.message);
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
async
|
|
48
|
+
async sendMsgDeposit({ value, fee, memo }) {
|
|
49
49
|
if (!signer) {
|
|
50
|
-
throw new Error('TxClient:
|
|
50
|
+
throw new Error('TxClient:sendMsgDeposit: Unable to sign Tx. Signer is not present.');
|
|
51
51
|
}
|
|
52
52
|
try {
|
|
53
53
|
const { address } = (await signer.getAccounts())[0];
|
|
54
54
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
55
|
-
let msg = this.
|
|
55
|
+
let msg = this.msgDeposit({ value: MsgDeposit.fromPartial(value) });
|
|
56
56
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
57
57
|
}
|
|
58
58
|
catch (e) {
|
|
59
|
-
throw new Error('TxClient:
|
|
59
|
+
throw new Error('TxClient:sendMsgDeposit: Could not broadcast Tx: ' + e.message);
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
async
|
|
62
|
+
async sendMsgVote({ value, fee, memo }) {
|
|
63
63
|
if (!signer) {
|
|
64
|
-
throw new Error('TxClient:
|
|
64
|
+
throw new Error('TxClient:sendMsgVote: Unable to sign Tx. Signer is not present.');
|
|
65
65
|
}
|
|
66
66
|
try {
|
|
67
67
|
const { address } = (await signer.getAccounts())[0];
|
|
68
68
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
69
|
-
let msg = this.
|
|
69
|
+
let msg = this.msgVote({ value: MsgVote.fromPartial(value) });
|
|
70
70
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
|
-
throw new Error('TxClient:
|
|
73
|
+
throw new Error('TxClient:sendMsgVote: Could not broadcast Tx: ' + e.message);
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
-
async
|
|
76
|
+
async sendMsgVoteWeighted({ value, fee, memo }) {
|
|
77
77
|
if (!signer) {
|
|
78
|
-
throw new Error('TxClient:
|
|
78
|
+
throw new Error('TxClient:sendMsgVoteWeighted: Unable to sign Tx. Signer is not present.');
|
|
79
79
|
}
|
|
80
80
|
try {
|
|
81
81
|
const { address } = (await signer.getAccounts())[0];
|
|
82
82
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
83
|
-
let msg = this.
|
|
83
|
+
let msg = this.msgVoteWeighted({ value: MsgVoteWeighted.fromPartial(value) });
|
|
84
84
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
85
85
|
}
|
|
86
86
|
catch (e) {
|
|
87
|
-
throw new Error('TxClient:
|
|
87
|
+
throw new Error('TxClient:sendMsgVoteWeighted: Could not broadcast Tx: ' + e.message);
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
|
|
90
|
+
msgSubmitProposal({ value }) {
|
|
91
91
|
try {
|
|
92
|
-
return { typeUrl: "/cosmos.gov.v1.
|
|
92
|
+
return { typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", value: MsgSubmitProposal.fromPartial(value) };
|
|
93
93
|
}
|
|
94
94
|
catch (e) {
|
|
95
|
-
throw new Error('TxClient:
|
|
95
|
+
throw new Error('TxClient:MsgSubmitProposal: Could not create message: ' + e.message);
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
|
-
|
|
98
|
+
msgDeposit({ value }) {
|
|
99
99
|
try {
|
|
100
|
-
return { typeUrl: "/cosmos.gov.v1.
|
|
100
|
+
return { typeUrl: "/cosmos.gov.v1.MsgDeposit", value: MsgDeposit.fromPartial(value) };
|
|
101
101
|
}
|
|
102
102
|
catch (e) {
|
|
103
|
-
throw new Error('TxClient:
|
|
103
|
+
throw new Error('TxClient:MsgDeposit: Could not create message: ' + e.message);
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
|
-
|
|
106
|
+
msgVote({ value }) {
|
|
107
107
|
try {
|
|
108
|
-
return { typeUrl: "/cosmos.gov.v1.
|
|
108
|
+
return { typeUrl: "/cosmos.gov.v1.MsgVote", value: MsgVote.fromPartial(value) };
|
|
109
109
|
}
|
|
110
110
|
catch (e) {
|
|
111
|
-
throw new Error('TxClient:
|
|
111
|
+
throw new Error('TxClient:MsgVote: Could not create message: ' + e.message);
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
|
-
|
|
114
|
+
msgVoteWeighted({ value }) {
|
|
115
115
|
try {
|
|
116
|
-
return { typeUrl: "/cosmos.gov.v1.
|
|
116
|
+
return { typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", value: MsgVoteWeighted.fromPartial(value) };
|
|
117
117
|
}
|
|
118
118
|
catch (e) {
|
|
119
|
-
throw new Error('TxClient:
|
|
119
|
+
throw new Error('TxClient:MsgVoteWeighted: Could not create message: ' + e.message);
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
122
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { MsgSubmitProposal } from "./types/cosmos/gov/v1/tx";
|
|
2
|
+
import { MsgDeposit } from "./types/cosmos/gov/v1/tx";
|
|
1
3
|
import { MsgVote } from "./types/cosmos/gov/v1/tx";
|
|
2
4
|
import { MsgVoteWeighted } from "./types/cosmos/gov/v1/tx";
|
|
3
|
-
import { MsgDeposit } from "./types/cosmos/gov/v1/tx";
|
|
4
|
-
import { MsgSubmitProposal } from "./types/cosmos/gov/v1/tx";
|
|
5
5
|
const msgTypes = [
|
|
6
|
+
["/cosmos.gov.v1.MsgSubmitProposal", MsgSubmitProposal],
|
|
7
|
+
["/cosmos.gov.v1.MsgDeposit", MsgDeposit],
|
|
6
8
|
["/cosmos.gov.v1.MsgVote", MsgVote],
|
|
7
9
|
["/cosmos.gov.v1.MsgVoteWeighted", MsgVoteWeighted],
|
|
8
|
-
["/cosmos.gov.v1.MsgDeposit", MsgDeposit],
|
|
9
|
-
["/cosmos.gov.v1.MsgSubmitProposal", MsgSubmitProposal],
|
|
10
10
|
];
|
|
11
11
|
export { msgTypes };
|
|
@@ -4,9 +4,9 @@ import { Registry } from "@cosmjs/proto-signing";
|
|
|
4
4
|
import { msgTypes } from './registry';
|
|
5
5
|
import { Api } from "./rest";
|
|
6
6
|
import { MsgVote } from "./types/cosmos/gov/v1beta1/tx";
|
|
7
|
-
import { MsgVoteWeighted } from "./types/cosmos/gov/v1beta1/tx";
|
|
8
7
|
import { MsgSubmitProposal } from "./types/cosmos/gov/v1beta1/tx";
|
|
9
8
|
import { MsgDeposit } from "./types/cosmos/gov/v1beta1/tx";
|
|
9
|
+
import { MsgVoteWeighted } from "./types/cosmos/gov/v1beta1/tx";
|
|
10
10
|
import { WeightedVoteOption as typeWeightedVoteOption } from "./types";
|
|
11
11
|
import { TextProposal as typeTextProposal } from "./types";
|
|
12
12
|
import { Deposit as typeDeposit } from "./types";
|
|
@@ -16,7 +16,7 @@ import { Vote as typeVote } from "./types";
|
|
|
16
16
|
import { DepositParams as typeDepositParams } from "./types";
|
|
17
17
|
import { VotingParams as typeVotingParams } from "./types";
|
|
18
18
|
import { TallyParams as typeTallyParams } from "./types";
|
|
19
|
-
export { MsgVote,
|
|
19
|
+
export { MsgVote, MsgSubmitProposal, MsgDeposit, MsgVoteWeighted };
|
|
20
20
|
export const registry = new Registry(msgTypes);
|
|
21
21
|
function getStructure(template) {
|
|
22
22
|
const structure = { fields: [] };
|
|
@@ -46,20 +46,6 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
46
46
|
throw new Error('TxClient:sendMsgVote: Could not broadcast Tx: ' + e.message);
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
-
async sendMsgVoteWeighted({ value, fee, memo }) {
|
|
50
|
-
if (!signer) {
|
|
51
|
-
throw new Error('TxClient:sendMsgVoteWeighted: Unable to sign Tx. Signer is not present.');
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const { address } = (await signer.getAccounts())[0];
|
|
55
|
-
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
56
|
-
let msg = this.msgVoteWeighted({ value: MsgVoteWeighted.fromPartial(value) });
|
|
57
|
-
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
throw new Error('TxClient:sendMsgVoteWeighted: Could not broadcast Tx: ' + e.message);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
49
|
async sendMsgSubmitProposal({ value, fee, memo }) {
|
|
64
50
|
if (!signer) {
|
|
65
51
|
throw new Error('TxClient:sendMsgSubmitProposal: Unable to sign Tx. Signer is not present.');
|
|
@@ -88,20 +74,26 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
88
74
|
throw new Error('TxClient:sendMsgDeposit: Could not broadcast Tx: ' + e.message);
|
|
89
75
|
}
|
|
90
76
|
},
|
|
91
|
-
|
|
77
|
+
async sendMsgVoteWeighted({ value, fee, memo }) {
|
|
78
|
+
if (!signer) {
|
|
79
|
+
throw new Error('TxClient:sendMsgVoteWeighted: Unable to sign Tx. Signer is not present.');
|
|
80
|
+
}
|
|
92
81
|
try {
|
|
93
|
-
|
|
82
|
+
const { address } = (await signer.getAccounts())[0];
|
|
83
|
+
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
84
|
+
let msg = this.msgVoteWeighted({ value: MsgVoteWeighted.fromPartial(value) });
|
|
85
|
+
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
94
86
|
}
|
|
95
87
|
catch (e) {
|
|
96
|
-
throw new Error('TxClient:
|
|
88
|
+
throw new Error('TxClient:sendMsgVoteWeighted: Could not broadcast Tx: ' + e.message);
|
|
97
89
|
}
|
|
98
90
|
},
|
|
99
|
-
|
|
91
|
+
msgVote({ value }) {
|
|
100
92
|
try {
|
|
101
|
-
return { typeUrl: "/cosmos.gov.v1beta1.
|
|
93
|
+
return { typeUrl: "/cosmos.gov.v1beta1.MsgVote", value: MsgVote.fromPartial(value) };
|
|
102
94
|
}
|
|
103
95
|
catch (e) {
|
|
104
|
-
throw new Error('TxClient:
|
|
96
|
+
throw new Error('TxClient:MsgVote: Could not create message: ' + e.message);
|
|
105
97
|
}
|
|
106
98
|
},
|
|
107
99
|
msgSubmitProposal({ value }) {
|
|
@@ -120,6 +112,14 @@ export const txClient = ({ signer, prefix, addr } = { addr: "http://localhost:26
|
|
|
120
112
|
throw new Error('TxClient:MsgDeposit: Could not create message: ' + e.message);
|
|
121
113
|
}
|
|
122
114
|
},
|
|
115
|
+
msgVoteWeighted({ value }) {
|
|
116
|
+
try {
|
|
117
|
+
return { typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", value: MsgVoteWeighted.fromPartial(value) };
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
throw new Error('TxClient:MsgVoteWeighted: Could not create message: ' + e.message);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
123
|
};
|
|
124
124
|
};
|
|
125
125
|
export const queryClient = ({ addr: addr } = { addr: "http://localhost:1317" }) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MsgVote } from "./types/cosmos/gov/v1beta1/tx";
|
|
2
|
-
import { MsgVoteWeighted } from "./types/cosmos/gov/v1beta1/tx";
|
|
3
2
|
import { MsgSubmitProposal } from "./types/cosmos/gov/v1beta1/tx";
|
|
4
3
|
import { MsgDeposit } from "./types/cosmos/gov/v1beta1/tx";
|
|
4
|
+
import { MsgVoteWeighted } from "./types/cosmos/gov/v1beta1/tx";
|
|
5
5
|
const msgTypes = [
|
|
6
6
|
["/cosmos.gov.v1beta1.MsgVote", MsgVote],
|
|
7
|
-
["/cosmos.gov.v1beta1.MsgVoteWeighted", MsgVoteWeighted],
|
|
8
7
|
["/cosmos.gov.v1beta1.MsgSubmitProposal", MsgSubmitProposal],
|
|
9
8
|
["/cosmos.gov.v1beta1.MsgDeposit", MsgDeposit],
|
|
9
|
+
["/cosmos.gov.v1beta1.MsgVoteWeighted", MsgVoteWeighted],
|
|
10
10
|
];
|
|
11
11
|
export { msgTypes };
|