decentralcardgame-cardchain-client-ts 0.0.29 → 0.0.30
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 +420 -452
- package/DecentralCardGame.cardchain.cardchain/module.ts +1495 -1570
- package/DecentralCardGame.cardchain.cardchain/registry.js +78 -70
- package/DecentralCardGame.cardchain.cardchain/registry.ts +78 -70
- package/DecentralCardGame.cardchain.cardchain/rest.js +71 -0
- package/DecentralCardGame.cardchain.cardchain/rest.ts +132 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.js +6 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/card.ts +6 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/early_access_proposal.js +81 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/early_access_proposal.ts +106 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/encounters.js +295 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/encounters.ts +354 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/genesis.js +16 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/genesis.ts +19 -1
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.js +447 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/query.ts +570 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.js +504 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/tx.ts +613 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.js +50 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/user.ts +48 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/zealy.js +58 -0
- package/DecentralCardGame.cardchain.cardchain/types/cardchain/cardchain/zealy.ts +82 -0
- package/DecentralCardGame.cardchain.cardchain/types.js +5 -1
- package/DecentralCardGame.cardchain.cardchain/types.ts +8 -0
- package/DecentralCardGame.cardchain.featureflag/module.js +9 -7
- package/DecentralCardGame.cardchain.featureflag/module.ts +69 -65
- package/client.js +2 -5
- package/client.ts +164 -162
- package/cosmos.authz.v1beta1/module.js +33 -22
- package/cosmos.authz.v1beta1/module.ts +220 -148
- package/cosmos.distribution.v1beta1/module.js +65 -35
- package/cosmos.distribution.v1beta1/module.ts +354 -200
- package/cosmos.evidence.v1beta1/module.js +21 -13
- package/cosmos.evidence.v1beta1/module.ts +115 -86
- package/cosmos.gov.v1/module.js +48 -29
- package/cosmos.gov.v1/module.ts +275 -178
- package/cosmos.mint.v1beta1/module.js +9 -7
- package/cosmos.mint.v1beta1/module.ts +67 -63
- package/cosmos.nft.v1beta1/module.js +9 -7
- package/cosmos.nft.v1beta1/module.ts +75 -71
- package/cosmos.tx.v1beta1/module.js +9 -7
- package/cosmos.tx.v1beta1/module.ts +89 -85
- package/cosmos.vesting.v1beta1/module.js +52 -29
- package/cosmos.vesting.v1beta1/module.ts +249 -149
- package/ibc.applications.interchain_accounts.controller.v1/module.js +9 -7
- package/ibc.applications.interchain_accounts.controller.v1/module.ts +65 -61
- package/ibc.applications.transfer.v1/module.js +17 -12
- package/ibc.applications.transfer.v1/module.ts +114 -88
- package/ibc.core.channel.v1/module.js +1 -4
- package/ibc.core.channel.v1/module.ts +79 -81
- package/ibc.core.client.v1/module.js +1 -4
- package/ibc.core.client.v1/module.ts +81 -83
- package/ibc.core.connection.v1/module.js +6 -7
- package/ibc.core.connection.v1/module.ts +88 -84
- package/package.json +1 -1
- package/tsconfig.json +1 -1
|
@@ -2,69 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
import { StdFee } from "@cosmjs/amino";
|
|
4
4
|
import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
EncodeObject,
|
|
7
|
+
GeneratedType,
|
|
8
|
+
OfflineSigner,
|
|
9
|
+
Registry,
|
|
10
|
+
} from "@cosmjs/proto-signing";
|
|
11
|
+
import { msgTypes } from "./registry";
|
|
12
|
+
import { IgniteClient } from "../client";
|
|
13
|
+
import { MissingWalletError } from "../helpers";
|
|
9
14
|
import { Api } from "./rest";
|
|
10
15
|
import { MsgRevoke } from "./types/cosmos/authz/v1beta1/tx";
|
|
11
16
|
import { MsgExec } from "./types/cosmos/authz/v1beta1/tx";
|
|
12
17
|
import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx";
|
|
13
18
|
|
|
14
|
-
import { GenericAuthorization as typeGenericAuthorization} from "./types"
|
|
15
|
-
import { Grant as typeGrant} from "./types"
|
|
16
|
-
import { GrantAuthorization as typeGrantAuthorization} from "./types"
|
|
17
|
-
import { GrantQueueItem as typeGrantQueueItem} from "./types"
|
|
18
|
-
import { EventGrant as typeEventGrant} from "./types"
|
|
19
|
-
import { EventRevoke as typeEventRevoke} from "./types"
|
|
19
|
+
import { GenericAuthorization as typeGenericAuthorization } from "./types";
|
|
20
|
+
import { Grant as typeGrant } from "./types";
|
|
21
|
+
import { GrantAuthorization as typeGrantAuthorization } from "./types";
|
|
22
|
+
import { GrantQueueItem as typeGrantQueueItem } from "./types";
|
|
23
|
+
import { EventGrant as typeEventGrant } from "./types";
|
|
24
|
+
import { EventRevoke as typeEventRevoke } from "./types";
|
|
20
25
|
|
|
21
26
|
export { MsgRevoke, MsgExec, MsgGrant };
|
|
22
27
|
|
|
23
28
|
type sendMsgRevokeParams = {
|
|
24
|
-
value: MsgRevoke
|
|
25
|
-
fee?: StdFee
|
|
26
|
-
memo?: string
|
|
29
|
+
value: MsgRevoke;
|
|
30
|
+
fee?: StdFee;
|
|
31
|
+
memo?: string;
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
type sendMsgExecParams = {
|
|
30
|
-
value: MsgExec
|
|
31
|
-
fee?: StdFee
|
|
32
|
-
memo?: string
|
|
35
|
+
value: MsgExec;
|
|
36
|
+
fee?: StdFee;
|
|
37
|
+
memo?: string;
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
type sendMsgGrantParams = {
|
|
36
|
-
value: MsgGrant
|
|
37
|
-
fee?: StdFee
|
|
38
|
-
memo?: string
|
|
41
|
+
value: MsgGrant;
|
|
42
|
+
fee?: StdFee;
|
|
43
|
+
memo?: string;
|
|
39
44
|
};
|
|
40
45
|
|
|
41
|
-
|
|
42
46
|
type msgRevokeParams = {
|
|
43
|
-
value: MsgRevoke
|
|
47
|
+
value: MsgRevoke;
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
type msgExecParams = {
|
|
47
|
-
value: MsgExec
|
|
51
|
+
value: MsgExec;
|
|
48
52
|
};
|
|
49
53
|
|
|
50
54
|
type msgGrantParams = {
|
|
51
|
-
value: MsgGrant
|
|
55
|
+
value: MsgGrant;
|
|
52
56
|
};
|
|
53
57
|
|
|
54
|
-
|
|
55
58
|
export const registry = new Registry(msgTypes);
|
|
56
59
|
|
|
57
60
|
type Field = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
+
name: string;
|
|
62
|
+
type: unknown;
|
|
63
|
+
};
|
|
61
64
|
function getStructure(template) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const structure: { fields: Field[] } = { fields: [] };
|
|
66
|
+
for (let [key, value] of Object.entries(template)) {
|
|
67
|
+
let field = { name: key, type: typeof value };
|
|
68
|
+
structure.fields.push(field);
|
|
69
|
+
}
|
|
70
|
+
return structure;
|
|
68
71
|
}
|
|
69
72
|
const defaultFee = {
|
|
70
73
|
amount: [],
|
|
@@ -72,136 +75,205 @@ const defaultFee = {
|
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
interface TxClientOptions {
|
|
75
|
-
addr: string
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
addr: string;
|
|
79
|
+
prefix: string;
|
|
80
|
+
signer?: OfflineSigner;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
export const txClient = (
|
|
81
|
-
|
|
83
|
+
export const txClient = (
|
|
84
|
+
{ signer, prefix, addr }: TxClientOptions = {
|
|
85
|
+
addr: "http://localhost:26657",
|
|
86
|
+
prefix: "cosmos",
|
|
87
|
+
},
|
|
88
|
+
) => {
|
|
82
89
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
90
|
+
async sendMsgRevoke({
|
|
91
|
+
value,
|
|
92
|
+
fee,
|
|
93
|
+
memo,
|
|
94
|
+
}: sendMsgRevokeParams): Promise<DeliverTxResponse> {
|
|
95
|
+
if (!signer) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
"TxClient:sendMsgRevoke: Unable to sign Tx. Signer is not present.",
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const { address } = (await signer.getAccounts())[0];
|
|
102
|
+
const signingClient = await SigningStargateClient.connectWithSigner(
|
|
103
|
+
addr,
|
|
104
|
+
signer,
|
|
105
|
+
{ registry, prefix },
|
|
106
|
+
);
|
|
107
|
+
let msg = this.msgRevoke({ value: MsgRevoke.fromPartial(value) });
|
|
108
|
+
return await signingClient.signAndBroadcast(
|
|
109
|
+
address,
|
|
110
|
+
[msg],
|
|
111
|
+
fee ? fee : defaultFee,
|
|
112
|
+
memo,
|
|
113
|
+
);
|
|
114
|
+
} catch (e: any) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
"TxClient:sendMsgRevoke: Could not broadcast Tx: " + e.message,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
async sendMsgExec({
|
|
122
|
+
value,
|
|
123
|
+
fee,
|
|
124
|
+
memo,
|
|
125
|
+
}: sendMsgExecParams): Promise<DeliverTxResponse> {
|
|
126
|
+
if (!signer) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
"TxClient:sendMsgExec: Unable to sign Tx. Signer is not present.",
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const { address } = (await signer.getAccounts())[0];
|
|
133
|
+
const signingClient = await SigningStargateClient.connectWithSigner(
|
|
134
|
+
addr,
|
|
135
|
+
signer,
|
|
136
|
+
{ registry, prefix },
|
|
137
|
+
);
|
|
138
|
+
let msg = this.msgExec({ value: MsgExec.fromPartial(value) });
|
|
139
|
+
return await signingClient.signAndBroadcast(
|
|
140
|
+
address,
|
|
141
|
+
[msg],
|
|
142
|
+
fee ? fee : defaultFee,
|
|
143
|
+
memo,
|
|
144
|
+
);
|
|
145
|
+
} catch (e: any) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
"TxClient:sendMsgExec: Could not broadcast Tx: " + e.message,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
async sendMsgGrant({
|
|
153
|
+
value,
|
|
154
|
+
fee,
|
|
155
|
+
memo,
|
|
156
|
+
}: sendMsgGrantParams): Promise<DeliverTxResponse> {
|
|
157
|
+
if (!signer) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
"TxClient:sendMsgGrant: Unable to sign Tx. Signer is not present.",
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const { address } = (await signer.getAccounts())[0];
|
|
164
|
+
const signingClient = await SigningStargateClient.connectWithSigner(
|
|
165
|
+
addr,
|
|
166
|
+
signer,
|
|
167
|
+
{ registry, prefix },
|
|
168
|
+
);
|
|
169
|
+
let msg = this.msgGrant({ value: MsgGrant.fromPartial(value) });
|
|
170
|
+
return await signingClient.signAndBroadcast(
|
|
171
|
+
address,
|
|
172
|
+
[msg],
|
|
173
|
+
fee ? fee : defaultFee,
|
|
174
|
+
memo,
|
|
175
|
+
);
|
|
176
|
+
} catch (e: any) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
"TxClient:sendMsgGrant: Could not broadcast Tx: " + e.message,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
msgRevoke({ value }: msgRevokeParams): EncodeObject {
|
|
184
|
+
try {
|
|
185
|
+
return {
|
|
186
|
+
typeUrl: "/cosmos.authz.v1beta1.MsgRevoke",
|
|
187
|
+
value: MsgRevoke.fromPartial(value),
|
|
188
|
+
};
|
|
189
|
+
} catch (e: any) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
"TxClient:MsgRevoke: Could not create message: " + e.message,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
msgExec({ value }: msgExecParams): EncodeObject {
|
|
197
|
+
try {
|
|
198
|
+
return {
|
|
199
|
+
typeUrl: "/cosmos.authz.v1beta1.MsgExec",
|
|
200
|
+
value: MsgExec.fromPartial(value),
|
|
201
|
+
};
|
|
202
|
+
} catch (e: any) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
"TxClient:MsgExec: Could not create message: " + e.message,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
msgGrant({ value }: msgGrantParams): EncodeObject {
|
|
210
|
+
try {
|
|
211
|
+
return {
|
|
212
|
+
typeUrl: "/cosmos.authz.v1beta1.MsgGrant",
|
|
213
|
+
value: MsgGrant.fromPartial(value),
|
|
214
|
+
};
|
|
215
|
+
} catch (e: any) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
"TxClient:MsgGrant: Could not create message: " + e.message,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
};
|
|
152
222
|
};
|
|
153
223
|
|
|
154
224
|
interface QueryClientOptions {
|
|
155
|
-
addr: string
|
|
225
|
+
addr: string;
|
|
156
226
|
}
|
|
157
227
|
|
|
158
|
-
export const queryClient = (
|
|
228
|
+
export const queryClient = (
|
|
229
|
+
{ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" },
|
|
230
|
+
) => {
|
|
159
231
|
return new Api({ baseURL: addr });
|
|
160
232
|
};
|
|
161
233
|
|
|
162
234
|
class SDKModule {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
235
|
+
public query: ReturnType<typeof queryClient>;
|
|
236
|
+
public tx: ReturnType<typeof txClient>;
|
|
237
|
+
public structure: Record<string, unknown>;
|
|
238
|
+
public registry: Array<[string, GeneratedType]> = [];
|
|
239
|
+
|
|
240
|
+
constructor(client: IgniteClient) {
|
|
241
|
+
this.query = queryClient({ addr: client.env.apiURL });
|
|
242
|
+
this.updateTX(client);
|
|
243
|
+
this.structure = {
|
|
244
|
+
GenericAuthorization: getStructure(
|
|
245
|
+
typeGenericAuthorization.fromPartial({}),
|
|
246
|
+
),
|
|
247
|
+
Grant: getStructure(typeGrant.fromPartial({})),
|
|
248
|
+
GrantAuthorization: getStructure(typeGrantAuthorization.fromPartial({})),
|
|
249
|
+
GrantQueueItem: getStructure(typeGrantQueueItem.fromPartial({})),
|
|
250
|
+
EventGrant: getStructure(typeEventGrant.fromPartial({})),
|
|
251
|
+
EventRevoke: getStructure(typeEventRevoke.fromPartial({})),
|
|
252
|
+
};
|
|
253
|
+
client.on("signer-changed", (signer) => {
|
|
254
|
+
this.updateTX(client);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
updateTX(client: IgniteClient) {
|
|
186
258
|
const methods = txClient({
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
})
|
|
191
|
-
|
|
259
|
+
signer: client.signer,
|
|
260
|
+
addr: client.env.rpcURL,
|
|
261
|
+
prefix: client.env.prefix ?? "cosmos",
|
|
262
|
+
});
|
|
263
|
+
|
|
192
264
|
this.tx = methods;
|
|
193
265
|
for (let m in methods) {
|
|
194
|
-
|
|
266
|
+
this.tx[m] = methods[m].bind(this.tx);
|
|
195
267
|
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const Module = (test: IgniteClient) => {
|
|
200
|
-
return {
|
|
201
|
-
module: {
|
|
202
|
-
CosmosAuthzV1Beta1: new SDKModule(test)
|
|
203
|
-
},
|
|
204
|
-
registry: msgTypes
|
|
205
268
|
}
|
|
206
269
|
}
|
|
207
|
-
|
|
270
|
+
|
|
271
|
+
const Module = (test: IgniteClient) => {
|
|
272
|
+
return {
|
|
273
|
+
module: {
|
|
274
|
+
CosmosAuthzV1Beta1: new SDKModule(test),
|
|
275
|
+
},
|
|
276
|
+
registry: msgTypes,
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
export default Module;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by Ignite ignite.com/cli
|
|
2
2
|
import { SigningStargateClient } from "@cosmjs/stargate";
|
|
3
|
-
import { Registry } from "@cosmjs/proto-signing";
|
|
4
|
-
import { msgTypes } from
|
|
3
|
+
import { Registry, } from "@cosmjs/proto-signing";
|
|
4
|
+
import { msgTypes } from "./registry";
|
|
5
5
|
import { Api } from "./rest";
|
|
6
6
|
import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx";
|
|
7
7
|
import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx";
|
|
@@ -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 { MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, MsgFundCommunityPool, MsgSetWithdrawAddress };
|
|
29
|
+
export { MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, MsgFundCommunityPool, MsgSetWithdrawAddress, };
|
|
30
30
|
export const registry = new Registry(msgTypes);
|
|
31
31
|
function getStructure(template) {
|
|
32
32
|
const structure = { fields: [] };
|
|
@@ -40,94 +40,125 @@ const defaultFee = {
|
|
|
40
40
|
amount: [],
|
|
41
41
|
gas: "200000",
|
|
42
42
|
};
|
|
43
|
-
export const txClient = ({ signer, prefix, addr } = {
|
|
43
|
+
export const txClient = ({ signer, prefix, addr } = {
|
|
44
|
+
addr: "http://localhost:26657",
|
|
45
|
+
prefix: "cosmos",
|
|
46
|
+
}) => {
|
|
44
47
|
return {
|
|
45
|
-
async sendMsgWithdrawDelegatorReward({ value, fee, memo }) {
|
|
48
|
+
async sendMsgWithdrawDelegatorReward({ value, fee, memo, }) {
|
|
46
49
|
if (!signer) {
|
|
47
|
-
throw new Error(
|
|
50
|
+
throw new Error("TxClient:sendMsgWithdrawDelegatorReward: Unable to sign Tx. Signer is not present.");
|
|
48
51
|
}
|
|
49
52
|
try {
|
|
50
53
|
const { address } = (await signer.getAccounts())[0];
|
|
51
54
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
52
|
-
let msg = this.msgWithdrawDelegatorReward({
|
|
55
|
+
let msg = this.msgWithdrawDelegatorReward({
|
|
56
|
+
value: MsgWithdrawDelegatorReward.fromPartial(value),
|
|
57
|
+
});
|
|
53
58
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
54
59
|
}
|
|
55
60
|
catch (e) {
|
|
56
|
-
throw new Error(
|
|
61
|
+
throw new Error("TxClient:sendMsgWithdrawDelegatorReward: Could not broadcast Tx: " +
|
|
62
|
+
e.message);
|
|
57
63
|
}
|
|
58
64
|
},
|
|
59
|
-
async sendMsgWithdrawValidatorCommission({ value, fee, memo }) {
|
|
65
|
+
async sendMsgWithdrawValidatorCommission({ value, fee, memo, }) {
|
|
60
66
|
if (!signer) {
|
|
61
|
-
throw new Error(
|
|
67
|
+
throw new Error("TxClient:sendMsgWithdrawValidatorCommission: Unable to sign Tx. Signer is not present.");
|
|
62
68
|
}
|
|
63
69
|
try {
|
|
64
70
|
const { address } = (await signer.getAccounts())[0];
|
|
65
71
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
66
|
-
let msg = this.msgWithdrawValidatorCommission({
|
|
72
|
+
let msg = this.msgWithdrawValidatorCommission({
|
|
73
|
+
value: MsgWithdrawValidatorCommission.fromPartial(value),
|
|
74
|
+
});
|
|
67
75
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
68
76
|
}
|
|
69
77
|
catch (e) {
|
|
70
|
-
throw new Error(
|
|
78
|
+
throw new Error("TxClient:sendMsgWithdrawValidatorCommission: Could not broadcast Tx: " +
|
|
79
|
+
e.message);
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
|
-
async sendMsgFundCommunityPool({ value, fee, memo }) {
|
|
82
|
+
async sendMsgFundCommunityPool({ value, fee, memo, }) {
|
|
74
83
|
if (!signer) {
|
|
75
|
-
throw new Error(
|
|
84
|
+
throw new Error("TxClient:sendMsgFundCommunityPool: Unable to sign Tx. Signer is not present.");
|
|
76
85
|
}
|
|
77
86
|
try {
|
|
78
87
|
const { address } = (await signer.getAccounts())[0];
|
|
79
88
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
80
|
-
let msg = this.msgFundCommunityPool({
|
|
89
|
+
let msg = this.msgFundCommunityPool({
|
|
90
|
+
value: MsgFundCommunityPool.fromPartial(value),
|
|
91
|
+
});
|
|
81
92
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
82
93
|
}
|
|
83
94
|
catch (e) {
|
|
84
|
-
throw new Error(
|
|
95
|
+
throw new Error("TxClient:sendMsgFundCommunityPool: Could not broadcast Tx: " +
|
|
96
|
+
e.message);
|
|
85
97
|
}
|
|
86
98
|
},
|
|
87
|
-
async sendMsgSetWithdrawAddress({ value, fee, memo }) {
|
|
99
|
+
async sendMsgSetWithdrawAddress({ value, fee, memo, }) {
|
|
88
100
|
if (!signer) {
|
|
89
|
-
throw new Error(
|
|
101
|
+
throw new Error("TxClient:sendMsgSetWithdrawAddress: Unable to sign Tx. Signer is not present.");
|
|
90
102
|
}
|
|
91
103
|
try {
|
|
92
104
|
const { address } = (await signer.getAccounts())[0];
|
|
93
105
|
const signingClient = await SigningStargateClient.connectWithSigner(addr, signer, { registry, prefix });
|
|
94
|
-
let msg = this.msgSetWithdrawAddress({
|
|
106
|
+
let msg = this.msgSetWithdrawAddress({
|
|
107
|
+
value: MsgSetWithdrawAddress.fromPartial(value),
|
|
108
|
+
});
|
|
95
109
|
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo);
|
|
96
110
|
}
|
|
97
111
|
catch (e) {
|
|
98
|
-
throw new Error(
|
|
112
|
+
throw new Error("TxClient:sendMsgSetWithdrawAddress: Could not broadcast Tx: " +
|
|
113
|
+
e.message);
|
|
99
114
|
}
|
|
100
115
|
},
|
|
101
|
-
msgWithdrawDelegatorReward({ value }) {
|
|
116
|
+
msgWithdrawDelegatorReward({ value, }) {
|
|
102
117
|
try {
|
|
103
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
|
|
120
|
+
value: MsgWithdrawDelegatorReward.fromPartial(value),
|
|
121
|
+
};
|
|
104
122
|
}
|
|
105
123
|
catch (e) {
|
|
106
|
-
throw new Error(
|
|
124
|
+
throw new Error("TxClient:MsgWithdrawDelegatorReward: Could not create message: " +
|
|
125
|
+
e.message);
|
|
107
126
|
}
|
|
108
127
|
},
|
|
109
|
-
msgWithdrawValidatorCommission({ value }) {
|
|
128
|
+
msgWithdrawValidatorCommission({ value, }) {
|
|
110
129
|
try {
|
|
111
|
-
return {
|
|
130
|
+
return {
|
|
131
|
+
typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
|
|
132
|
+
value: MsgWithdrawValidatorCommission.fromPartial(value),
|
|
133
|
+
};
|
|
112
134
|
}
|
|
113
135
|
catch (e) {
|
|
114
|
-
throw new Error(
|
|
136
|
+
throw new Error("TxClient:MsgWithdrawValidatorCommission: Could not create message: " +
|
|
137
|
+
e.message);
|
|
115
138
|
}
|
|
116
139
|
},
|
|
117
140
|
msgFundCommunityPool({ value }) {
|
|
118
141
|
try {
|
|
119
|
-
return {
|
|
142
|
+
return {
|
|
143
|
+
typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool",
|
|
144
|
+
value: MsgFundCommunityPool.fromPartial(value),
|
|
145
|
+
};
|
|
120
146
|
}
|
|
121
147
|
catch (e) {
|
|
122
|
-
throw new Error(
|
|
148
|
+
throw new Error("TxClient:MsgFundCommunityPool: Could not create message: " +
|
|
149
|
+
e.message);
|
|
123
150
|
}
|
|
124
151
|
},
|
|
125
|
-
msgSetWithdrawAddress({ value }) {
|
|
152
|
+
msgSetWithdrawAddress({ value, }) {
|
|
126
153
|
try {
|
|
127
|
-
return {
|
|
154
|
+
return {
|
|
155
|
+
typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
|
|
156
|
+
value: MsgSetWithdrawAddress.fromPartial(value),
|
|
157
|
+
};
|
|
128
158
|
}
|
|
129
159
|
catch (e) {
|
|
130
|
-
throw new Error(
|
|
160
|
+
throw new Error("TxClient:MsgSetWithdrawAddress: Could not create message: " +
|
|
161
|
+
e.message);
|
|
131
162
|
}
|
|
132
163
|
},
|
|
133
164
|
};
|
|
@@ -161,7 +192,7 @@ class SDKModule {
|
|
|
161
192
|
DelegatorStartingInfoRecord: getStructure(typeDelegatorStartingInfoRecord.fromPartial({})),
|
|
162
193
|
ValidatorSlashEventRecord: getStructure(typeValidatorSlashEventRecord.fromPartial({})),
|
|
163
194
|
};
|
|
164
|
-
client.on(
|
|
195
|
+
client.on("signer-changed", (signer) => {
|
|
165
196
|
this.updateTX(client);
|
|
166
197
|
});
|
|
167
198
|
}
|
|
@@ -177,13 +208,12 @@ class SDKModule {
|
|
|
177
208
|
}
|
|
178
209
|
}
|
|
179
210
|
}
|
|
180
|
-
;
|
|
181
211
|
const Module = (test) => {
|
|
182
212
|
return {
|
|
183
213
|
module: {
|
|
184
|
-
CosmosDistributionV1Beta1: new SDKModule(test)
|
|
214
|
+
CosmosDistributionV1Beta1: new SDKModule(test),
|
|
185
215
|
},
|
|
186
|
-
registry: msgTypes
|
|
216
|
+
registry: msgTypes,
|
|
187
217
|
};
|
|
188
218
|
};
|
|
189
219
|
export default Module;
|