@firmachain/firma-js 0.2.2 → 0.2.6
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/LICENSE +21 -0
- package/README.md +153 -154
- package/dist/sdk/FirmaBankService.d.ts +5 -5
- package/dist/sdk/FirmaBankService.js +30 -30
- package/dist/sdk/FirmaConfig.d.ts +3 -3
- package/dist/sdk/FirmaContractService.d.ts +5 -5
- package/dist/sdk/FirmaContractService.js +19 -19
- package/dist/sdk/FirmaDistributionService.d.ts +13 -9
- package/dist/sdk/FirmaDistributionService.js +162 -78
- package/dist/sdk/FirmaFeeGrantService.d.ts +11 -8
- package/dist/sdk/FirmaFeeGrantService.js +128 -53
- package/dist/sdk/FirmaGovService.d.ts +28 -16
- package/dist/sdk/FirmaGovService.js +447 -119
- package/dist/sdk/FirmaIpfsService.d.ts +4 -4
- package/dist/sdk/FirmaIpfsService.js +14 -14
- package/dist/sdk/FirmaNftService.d.ts +4 -4
- package/dist/sdk/FirmaNftService.js +18 -20
- package/dist/sdk/FirmaSDK.js +2 -1
- package/dist/sdk/FirmaStakingService.d.ts +9 -6
- package/dist/sdk/FirmaStakingService.js +177 -97
- package/dist/sdk/FirmaUtil.d.ts +3 -2
- package/dist/sdk/FirmaUtil.js +16 -11
- package/dist/sdk/FirmaWalletService.d.ts +6 -6
- package/dist/sdk/FirmaWalletService.js +22 -22
- package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +1 -1
- package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
- package/dist/sdk/firmachain/bank/BankTxClient.d.ts +3 -4
- package/dist/sdk/firmachain/bank/BankTxClient.js +2 -2
- package/dist/sdk/firmachain/common/ITxClient.d.ts +5 -5
- package/dist/sdk/firmachain/common/ITxClient.js +7 -7
- package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +1 -1
- package/dist/sdk/firmachain/common/TendermintQueryClient.js +5 -4
- package/dist/sdk/firmachain/common/accounts.js +25 -20
- package/dist/sdk/firmachain/common/signingstargateclient.js +3 -3
- package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/contract/ContractQueryClient.js +17 -11
- package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +3 -4
- package/dist/sdk/firmachain/contract/ContractTxClient.js +3 -3
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +2 -1
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +33 -16
- package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +5 -6
- package/dist/sdk/firmachain/distribution/DistributionTxClient.js +3 -3
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +4 -4
- package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +3 -4
- package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +2 -2
- package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +51 -3
- package/dist/sdk/firmachain/gov/GovQueryClient.js +62 -11
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +4 -5
- package/dist/sdk/firmachain/gov/GovTxClient.js +3 -3
- package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/nft/NftQueryClient.js +11 -8
- package/dist/sdk/firmachain/nft/NftTxClient.d.ts +4 -5
- package/dist/sdk/firmachain/nft/NftTxClient.js +3 -3
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +3 -1
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +48 -16
- package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +6 -7
- package/dist/sdk/firmachain/staking/StakingTxClient.js +2 -2
- package/package.json +1 -1
|
@@ -35,6 +35,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
exports.FirmaGovService = void 0;
|
|
40
43
|
var gov_1 = require("./firmachain/gov");
|
|
@@ -44,19 +47,21 @@ var gov_2 = require("cosmjs-types/cosmos/gov/v1beta1/gov");
|
|
|
44
47
|
var distribution_1 = require("cosmjs-types/cosmos/distribution/v1beta1/distribution");
|
|
45
48
|
var params_1 = require("cosmjs-types/cosmos/params/v1beta1/params");
|
|
46
49
|
var upgrade_1 = require("cosmjs-types/cosmos/upgrade/v1beta1/upgrade");
|
|
50
|
+
var long_1 = __importDefault(require("long"));
|
|
47
51
|
var FirmaGovService = /** @class */ (function () {
|
|
48
|
-
function FirmaGovService(
|
|
49
|
-
this.
|
|
52
|
+
function FirmaGovService(config) {
|
|
53
|
+
this.config = config;
|
|
50
54
|
}
|
|
51
|
-
FirmaGovService.prototype.
|
|
55
|
+
FirmaGovService.prototype.getGasEstimationVote = function (wallet, proposalId, option, txMisc) {
|
|
52
56
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
53
57
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var txRaw, error_1;
|
|
58
|
+
var longId, txRaw, error_1;
|
|
55
59
|
return __generator(this, function (_a) {
|
|
56
60
|
switch (_a.label) {
|
|
57
61
|
case 0:
|
|
58
62
|
_a.trys.push([0, 3, , 4]);
|
|
59
|
-
|
|
63
|
+
longId = long_1.default.fromInt(proposalId);
|
|
64
|
+
return [4 /*yield*/, this.getSignedTxVote(wallet, longId, option, txMisc)];
|
|
60
65
|
case 1:
|
|
61
66
|
txRaw = _a.sent();
|
|
62
67
|
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
@@ -70,16 +75,156 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
70
75
|
});
|
|
71
76
|
});
|
|
72
77
|
};
|
|
73
|
-
FirmaGovService.prototype.
|
|
78
|
+
FirmaGovService.prototype.getGasEstimationDeposit = function (wallet, proposalId, amount, txMisc) {
|
|
74
79
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
75
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var
|
|
81
|
+
var longId, txRaw, error_2;
|
|
77
82
|
return __generator(this, function (_a) {
|
|
78
83
|
switch (_a.label) {
|
|
79
84
|
case 0:
|
|
80
|
-
_a.trys.push([0,
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
_a.trys.push([0, 3, , 4]);
|
|
86
|
+
longId = long_1.default.fromInt(proposalId);
|
|
87
|
+
return [4 /*yield*/, this.getSignedTxDeposit(wallet, longId, amount, txMisc)];
|
|
88
|
+
case 1:
|
|
89
|
+
txRaw = _a.sent();
|
|
90
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
91
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
92
|
+
case 3:
|
|
93
|
+
error_2 = _a.sent();
|
|
94
|
+
FirmaUtil_1.FirmaUtil.printLog(error_2);
|
|
95
|
+
throw error_2;
|
|
96
|
+
case 4: return [2 /*return*/];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
FirmaGovService.prototype.getGasEstimationSubmitCancelSoftwareUpgradeProposal = function (wallet, title, description, initialDepositFCT, txMisc) {
|
|
102
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var txRaw, error_3;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
_a.trys.push([0, 3, , 4]);
|
|
109
|
+
return [4 /*yield*/, this.getSignedTxSubmitCancelSoftwareUpgradeProposal(wallet, title, description, initialDepositFCT, txMisc)];
|
|
110
|
+
case 1:
|
|
111
|
+
txRaw = _a.sent();
|
|
112
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
113
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
114
|
+
case 3:
|
|
115
|
+
error_3 = _a.sent();
|
|
116
|
+
FirmaUtil_1.FirmaUtil.printLog(error_3);
|
|
117
|
+
throw error_3;
|
|
118
|
+
case 4: return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
FirmaGovService.prototype.getGasEstimationSubmitSoftwareUpgradeProposalByHeight = function (wallet, title, description, initialDepositFCT, upgradeName, height, txMisc) {
|
|
124
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var plan, txRaw, error_4;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
_a.trys.push([0, 3, , 4]);
|
|
131
|
+
plan = {
|
|
132
|
+
name: upgradeName,
|
|
133
|
+
time: undefined,
|
|
134
|
+
height: height,
|
|
135
|
+
info: undefined,
|
|
136
|
+
upgradedClientState: undefined
|
|
137
|
+
};
|
|
138
|
+
return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDepositFCT, plan, txMisc)];
|
|
139
|
+
case 1:
|
|
140
|
+
txRaw = _a.sent();
|
|
141
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
142
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
143
|
+
case 3:
|
|
144
|
+
error_4 = _a.sent();
|
|
145
|
+
FirmaUtil_1.FirmaUtil.printLog(error_4);
|
|
146
|
+
throw error_4;
|
|
147
|
+
case 4: return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
FirmaGovService.prototype.getGasEstimationSubmitParameterChangeProposal = function (wallet, title, description, initialDepositFCT, paramList, txMisc) {
|
|
153
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
var txRaw, error_5;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0:
|
|
159
|
+
_a.trys.push([0, 3, , 4]);
|
|
160
|
+
return [4 /*yield*/, this.getSignedTxSubmitParameterChangeProposal(wallet, title, description, initialDepositFCT, paramList, txMisc)];
|
|
161
|
+
case 1:
|
|
162
|
+
txRaw = _a.sent();
|
|
163
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
164
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
165
|
+
case 3:
|
|
166
|
+
error_5 = _a.sent();
|
|
167
|
+
FirmaUtil_1.FirmaUtil.printLog(error_5);
|
|
168
|
+
throw error_5;
|
|
169
|
+
case 4: return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
FirmaGovService.prototype.getGasEstimationSubmitCommunityPoolSpendProposal = function (wallet, title, description, initialDepositFCT, amount, recipient, txMisc) {
|
|
175
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
var txRaw, error_6;
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
switch (_a.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
_a.trys.push([0, 3, , 4]);
|
|
182
|
+
return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, description, initialDepositFCT, amount, recipient, txMisc)];
|
|
183
|
+
case 1:
|
|
184
|
+
txRaw = _a.sent();
|
|
185
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
186
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
187
|
+
case 3:
|
|
188
|
+
error_6 = _a.sent();
|
|
189
|
+
FirmaUtil_1.FirmaUtil.printLog(error_6);
|
|
190
|
+
throw error_6;
|
|
191
|
+
case 4: return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
FirmaGovService.prototype.getGasEstimationSubmitTextProposal = function (wallet, title, description, initialDepositFCT, txMisc) {
|
|
197
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var txRaw, error_7;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
_a.trys.push([0, 3, , 4]);
|
|
204
|
+
return [4 /*yield*/, this.getSignedTxSubmitTextProposal(wallet, title, description, initialDepositFCT, txMisc)];
|
|
205
|
+
case 1:
|
|
206
|
+
txRaw = _a.sent();
|
|
207
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
208
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
209
|
+
case 3:
|
|
210
|
+
error_7 = _a.sent();
|
|
211
|
+
FirmaUtil_1.FirmaUtil.printLog(error_7);
|
|
212
|
+
throw error_7;
|
|
213
|
+
case 4: return [2 /*return*/];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
FirmaGovService.prototype.getSignedTxSubmitTextProposal = function (wallet, title, description, initialDepositFCT, txMisc) {
|
|
219
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
+
var txClient, sendAmount, proposal, content, proposer, message, error_8;
|
|
222
|
+
return __generator(this, function (_a) {
|
|
223
|
+
switch (_a.label) {
|
|
224
|
+
case 0:
|
|
225
|
+
_a.trys.push([0, 3, , 4]);
|
|
226
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
227
|
+
sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT) };
|
|
83
228
|
proposal = gov_2.TextProposal.fromPartial({
|
|
84
229
|
title: title,
|
|
85
230
|
description: description,
|
|
@@ -88,28 +233,74 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
88
233
|
typeUrl: "/cosmos.gov.v1beta1.TextProposal",
|
|
89
234
|
value: Uint8Array.from(gov_2.TextProposal.encode(proposal).finish()),
|
|
90
235
|
});
|
|
236
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
237
|
+
case 1:
|
|
238
|
+
proposer = _a.sent();
|
|
91
239
|
message = txClient.msgSubmitProposal({ content: content, initialDeposit: [sendAmount], proposer: proposer });
|
|
92
|
-
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.
|
|
93
|
-
case
|
|
94
|
-
case
|
|
95
|
-
|
|
96
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
97
|
-
throw
|
|
98
|
-
case
|
|
240
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
241
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
242
|
+
case 3:
|
|
243
|
+
error_8 = _a.sent();
|
|
244
|
+
FirmaUtil_1.FirmaUtil.printLog(error_8);
|
|
245
|
+
throw error_8;
|
|
246
|
+
case 4: return [2 /*return*/];
|
|
99
247
|
}
|
|
100
248
|
});
|
|
101
249
|
});
|
|
102
250
|
};
|
|
103
|
-
FirmaGovService.prototype.
|
|
251
|
+
FirmaGovService.prototype.getSignedTxSubmitCancelSoftwareUpgradeProposal = function (wallet, title, description, initialDepositFCT, txMisc) {
|
|
104
252
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
105
253
|
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
var txClient, initialDepositAmount, proposal, content, message,
|
|
254
|
+
var txClient, initialDepositAmount, proposal, content, proposer, message, error_9;
|
|
107
255
|
return __generator(this, function (_a) {
|
|
108
256
|
switch (_a.label) {
|
|
109
257
|
case 0:
|
|
110
|
-
_a.trys.push([0,
|
|
111
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
112
|
-
initialDepositAmount = {
|
|
258
|
+
_a.trys.push([0, 3, , 4]);
|
|
259
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
260
|
+
initialDepositAmount = {
|
|
261
|
+
denom: this.config.denom,
|
|
262
|
+
amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
|
|
263
|
+
};
|
|
264
|
+
proposal = upgrade_1.CancelSoftwareUpgradeProposal.fromPartial({
|
|
265
|
+
title: title,
|
|
266
|
+
description: description,
|
|
267
|
+
});
|
|
268
|
+
content = any_1.Any.fromPartial({
|
|
269
|
+
typeUrl: "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal",
|
|
270
|
+
value: Uint8Array.from(upgrade_1.SoftwareUpgradeProposal.encode(proposal).finish()),
|
|
271
|
+
});
|
|
272
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
273
|
+
case 1:
|
|
274
|
+
proposer = _a.sent();
|
|
275
|
+
message = txClient.msgSubmitProposal({
|
|
276
|
+
content: content,
|
|
277
|
+
initialDeposit: [initialDepositAmount],
|
|
278
|
+
proposer: proposer
|
|
279
|
+
});
|
|
280
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
281
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
282
|
+
case 3:
|
|
283
|
+
error_9 = _a.sent();
|
|
284
|
+
FirmaUtil_1.FirmaUtil.printLog(error_9);
|
|
285
|
+
throw error_9;
|
|
286
|
+
case 4: return [2 /*return*/];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
FirmaGovService.prototype.getSignedTxSubmitSoftwareUpgradeProposal = function (wallet, title, description, initialDepositFCT, plan, txMisc) {
|
|
292
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
var txClient, initialDepositAmount, proposal, content, proposer, message, error_10;
|
|
295
|
+
return __generator(this, function (_a) {
|
|
296
|
+
switch (_a.label) {
|
|
297
|
+
case 0:
|
|
298
|
+
_a.trys.push([0, 3, , 4]);
|
|
299
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
300
|
+
initialDepositAmount = {
|
|
301
|
+
denom: this.config.denom,
|
|
302
|
+
amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
|
|
303
|
+
};
|
|
113
304
|
proposal = upgrade_1.SoftwareUpgradeProposal.fromPartial({
|
|
114
305
|
title: title,
|
|
115
306
|
description: description,
|
|
@@ -119,28 +310,38 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
119
310
|
typeUrl: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal",
|
|
120
311
|
value: Uint8Array.from(upgrade_1.SoftwareUpgradeProposal.encode(proposal).finish()),
|
|
121
312
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
313
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
314
|
+
case 1:
|
|
315
|
+
proposer = _a.sent();
|
|
316
|
+
message = txClient.msgSubmitProposal({
|
|
317
|
+
content: content,
|
|
318
|
+
initialDeposit: [initialDepositAmount],
|
|
319
|
+
proposer: proposer
|
|
320
|
+
});
|
|
321
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
322
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
323
|
+
case 3:
|
|
324
|
+
error_10 = _a.sent();
|
|
325
|
+
FirmaUtil_1.FirmaUtil.printLog(error_10);
|
|
326
|
+
throw error_10;
|
|
327
|
+
case 4: return [2 /*return*/];
|
|
130
328
|
}
|
|
131
329
|
});
|
|
132
330
|
});
|
|
133
331
|
};
|
|
134
|
-
FirmaGovService.prototype.
|
|
332
|
+
FirmaGovService.prototype.getSignedTxSubmitParameterChangeProposal = function (wallet, title, description, initialDepositFCT, paramList, txMisc) {
|
|
135
333
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
136
334
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var txClient, initialDepositAmount, proposal, content, message,
|
|
335
|
+
var txClient, initialDepositAmount, proposal, content, proposer, message, error_11;
|
|
138
336
|
return __generator(this, function (_a) {
|
|
139
337
|
switch (_a.label) {
|
|
140
338
|
case 0:
|
|
141
|
-
_a.trys.push([0,
|
|
142
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
143
|
-
initialDepositAmount = {
|
|
339
|
+
_a.trys.push([0, 3, , 4]);
|
|
340
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
341
|
+
initialDepositAmount = {
|
|
342
|
+
denom: this.config.denom,
|
|
343
|
+
amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
|
|
344
|
+
};
|
|
144
345
|
proposal = params_1.ParameterChangeProposal.fromPartial({
|
|
145
346
|
title: title,
|
|
146
347
|
description: description,
|
|
@@ -150,29 +351,39 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
150
351
|
typeUrl: "/cosmos.params.v1beta1.ParameterChangeProposal",
|
|
151
352
|
value: Uint8Array.from(params_1.ParameterChangeProposal.encode(proposal).finish()),
|
|
152
353
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
354
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
355
|
+
case 1:
|
|
356
|
+
proposer = _a.sent();
|
|
357
|
+
message = txClient.msgSubmitProposal({
|
|
358
|
+
content: content,
|
|
359
|
+
initialDeposit: [initialDepositAmount],
|
|
360
|
+
proposer: proposer
|
|
361
|
+
});
|
|
362
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
363
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
364
|
+
case 3:
|
|
365
|
+
error_11 = _a.sent();
|
|
366
|
+
FirmaUtil_1.FirmaUtil.printLog(error_11);
|
|
367
|
+
throw error_11;
|
|
368
|
+
case 4: return [2 /*return*/];
|
|
161
369
|
}
|
|
162
370
|
});
|
|
163
371
|
});
|
|
164
372
|
};
|
|
165
|
-
FirmaGovService.prototype.
|
|
373
|
+
FirmaGovService.prototype.getSignedTxSubmitCommunityPoolSpendProposal = function (wallet, title, description, initialDepositFCT, amount, recipient, txMisc) {
|
|
166
374
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
167
375
|
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
-
var txClient, initialDepositAmount, sendAmount, proposal, content, message,
|
|
376
|
+
var txClient, initialDepositAmount, sendAmount, proposal, content, proposer, message, error_12;
|
|
169
377
|
return __generator(this, function (_a) {
|
|
170
378
|
switch (_a.label) {
|
|
171
379
|
case 0:
|
|
172
|
-
_a.trys.push([0,
|
|
173
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
174
|
-
initialDepositAmount = {
|
|
175
|
-
|
|
380
|
+
_a.trys.push([0, 3, , 4]);
|
|
381
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
382
|
+
initialDepositAmount = {
|
|
383
|
+
denom: this.config.denom,
|
|
384
|
+
amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
|
|
385
|
+
};
|
|
386
|
+
sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
|
|
176
387
|
proposal = distribution_1.CommunityPoolSpendProposal.fromPartial({
|
|
177
388
|
title: title,
|
|
178
389
|
description: description,
|
|
@@ -183,22 +394,52 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
183
394
|
typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal",
|
|
184
395
|
value: Uint8Array.from(distribution_1.CommunityPoolSpendProposal.encode(proposal).finish()),
|
|
185
396
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
397
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
398
|
+
case 1:
|
|
399
|
+
proposer = _a.sent();
|
|
400
|
+
message = txClient.msgSubmitProposal({
|
|
401
|
+
content: content,
|
|
402
|
+
initialDeposit: [initialDepositAmount],
|
|
403
|
+
proposer: proposer
|
|
404
|
+
});
|
|
405
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
406
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
407
|
+
case 3:
|
|
408
|
+
error_12 = _a.sent();
|
|
409
|
+
FirmaUtil_1.FirmaUtil.printLog(error_12);
|
|
410
|
+
throw error_12;
|
|
411
|
+
case 4: return [2 /*return*/];
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
FirmaGovService.prototype.submitCancelSoftwareUpgradeProposal = function (wallet, title, description, initialDeposit, txMisc) {
|
|
417
|
+
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
418
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
419
|
+
var txRaw, txClient, error_13;
|
|
420
|
+
return __generator(this, function (_a) {
|
|
421
|
+
switch (_a.label) {
|
|
422
|
+
case 0:
|
|
423
|
+
_a.trys.push([0, 3, , 4]);
|
|
424
|
+
return [4 /*yield*/, this.getSignedTxSubmitCancelSoftwareUpgradeProposal(wallet, title, description, initialDeposit, txMisc)];
|
|
425
|
+
case 1:
|
|
426
|
+
txRaw = _a.sent();
|
|
427
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
428
|
+
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
429
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
430
|
+
case 3:
|
|
431
|
+
error_13 = _a.sent();
|
|
432
|
+
FirmaUtil_1.FirmaUtil.printLog(error_13);
|
|
433
|
+
throw error_13;
|
|
434
|
+
case 4: return [2 /*return*/];
|
|
194
435
|
}
|
|
195
436
|
});
|
|
196
437
|
});
|
|
197
438
|
};
|
|
198
|
-
FirmaGovService.prototype.
|
|
439
|
+
FirmaGovService.prototype.submitSoftwareUpgradeProposalByHeight = function (wallet, title, description, initialDeposit, upgradeName, height, txMisc) {
|
|
199
440
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
200
441
|
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
var plan, txRaw, txClient,
|
|
442
|
+
var plan, txRaw, txClient, error_14;
|
|
202
443
|
return __generator(this, function (_a) {
|
|
203
444
|
switch (_a.label) {
|
|
204
445
|
case 0:
|
|
@@ -210,25 +451,25 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
210
451
|
info: undefined,
|
|
211
452
|
upgradedClientState: undefined
|
|
212
453
|
};
|
|
213
|
-
return [4 /*yield*/, this.
|
|
454
|
+
return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDeposit, plan, txMisc)];
|
|
214
455
|
case 1:
|
|
215
456
|
txRaw = _a.sent();
|
|
216
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
457
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
217
458
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
218
459
|
case 2: return [2 /*return*/, _a.sent()];
|
|
219
460
|
case 3:
|
|
220
|
-
|
|
221
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
222
|
-
throw
|
|
461
|
+
error_14 = _a.sent();
|
|
462
|
+
FirmaUtil_1.FirmaUtil.printLog(error_14);
|
|
463
|
+
throw error_14;
|
|
223
464
|
case 4: return [2 /*return*/];
|
|
224
465
|
}
|
|
225
466
|
});
|
|
226
467
|
});
|
|
227
468
|
};
|
|
228
|
-
FirmaGovService.prototype.
|
|
469
|
+
FirmaGovService.prototype.submitSoftwareUpgradeProposalByTime = function (wallet, title, description, initialDeposit, upgradeName, upgradeTime, txMisc) {
|
|
229
470
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
230
471
|
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
-
var plan, txRaw, txClient,
|
|
472
|
+
var plan, txRaw, txClient, error_15;
|
|
232
473
|
return __generator(this, function (_a) {
|
|
233
474
|
switch (_a.label) {
|
|
234
475
|
case 0:
|
|
@@ -240,85 +481,85 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
240
481
|
info: undefined,
|
|
241
482
|
upgradedClientState: undefined
|
|
242
483
|
};
|
|
243
|
-
return [4 /*yield*/, this.
|
|
484
|
+
return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDeposit, plan, txMisc)];
|
|
244
485
|
case 1:
|
|
245
486
|
txRaw = _a.sent();
|
|
246
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
487
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
247
488
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
248
489
|
case 2: return [2 /*return*/, _a.sent()];
|
|
249
490
|
case 3:
|
|
250
|
-
|
|
251
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
252
|
-
throw
|
|
491
|
+
error_15 = _a.sent();
|
|
492
|
+
FirmaUtil_1.FirmaUtil.printLog(error_15);
|
|
493
|
+
throw error_15;
|
|
253
494
|
case 4: return [2 /*return*/];
|
|
254
495
|
}
|
|
255
496
|
});
|
|
256
497
|
});
|
|
257
498
|
};
|
|
258
|
-
FirmaGovService.prototype.
|
|
499
|
+
FirmaGovService.prototype.submitParameterChangeProposal = function (wallet, title, description, initialDeposit, paramList, txMisc) {
|
|
259
500
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
260
501
|
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
-
var txRaw, txClient,
|
|
502
|
+
var txRaw, txClient, error_16;
|
|
262
503
|
return __generator(this, function (_a) {
|
|
263
504
|
switch (_a.label) {
|
|
264
505
|
case 0:
|
|
265
506
|
_a.trys.push([0, 3, , 4]);
|
|
266
|
-
return [4 /*yield*/, this.
|
|
507
|
+
return [4 /*yield*/, this.getSignedTxSubmitParameterChangeProposal(wallet, title, description, initialDeposit, paramList, txMisc)];
|
|
267
508
|
case 1:
|
|
268
509
|
txRaw = _a.sent();
|
|
269
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
510
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
270
511
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
271
512
|
case 2: return [2 /*return*/, _a.sent()];
|
|
272
513
|
case 3:
|
|
273
|
-
|
|
274
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
275
|
-
throw
|
|
514
|
+
error_16 = _a.sent();
|
|
515
|
+
FirmaUtil_1.FirmaUtil.printLog(error_16);
|
|
516
|
+
throw error_16;
|
|
276
517
|
case 4: return [2 /*return*/];
|
|
277
518
|
}
|
|
278
519
|
});
|
|
279
520
|
});
|
|
280
521
|
};
|
|
281
|
-
FirmaGovService.prototype.
|
|
522
|
+
FirmaGovService.prototype.submitCommunityPoolSpendProposal = function (wallet, title, description, initialDeposit, amount, recipient, txMisc) {
|
|
282
523
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
283
524
|
return __awaiter(this, void 0, void 0, function () {
|
|
284
|
-
var txRaw, txClient,
|
|
525
|
+
var txRaw, txClient, error_17;
|
|
285
526
|
return __generator(this, function (_a) {
|
|
286
527
|
switch (_a.label) {
|
|
287
528
|
case 0:
|
|
288
529
|
_a.trys.push([0, 3, , 4]);
|
|
289
|
-
return [4 /*yield*/, this.
|
|
530
|
+
return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, description, initialDeposit, amount, recipient, txMisc)];
|
|
290
531
|
case 1:
|
|
291
532
|
txRaw = _a.sent();
|
|
292
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
533
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
293
534
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
294
535
|
case 2: return [2 /*return*/, _a.sent()];
|
|
295
536
|
case 3:
|
|
296
|
-
|
|
297
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
298
|
-
throw
|
|
537
|
+
error_17 = _a.sent();
|
|
538
|
+
FirmaUtil_1.FirmaUtil.printLog(error_17);
|
|
539
|
+
throw error_17;
|
|
299
540
|
case 4: return [2 /*return*/];
|
|
300
541
|
}
|
|
301
542
|
});
|
|
302
543
|
});
|
|
303
544
|
};
|
|
304
|
-
FirmaGovService.prototype.
|
|
545
|
+
FirmaGovService.prototype.submitTextProposal = function (wallet, title, description, initialDeposit, txMisc) {
|
|
305
546
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
306
547
|
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
-
var txRaw, txClient,
|
|
548
|
+
var txRaw, txClient, error_18;
|
|
308
549
|
return __generator(this, function (_a) {
|
|
309
550
|
switch (_a.label) {
|
|
310
551
|
case 0:
|
|
311
552
|
_a.trys.push([0, 3, , 4]);
|
|
312
|
-
return [4 /*yield*/, this.getSignedTxSubmitTextProposal(wallet, title, description, initialDeposit,
|
|
553
|
+
return [4 /*yield*/, this.getSignedTxSubmitTextProposal(wallet, title, description, initialDeposit, txMisc)];
|
|
313
554
|
case 1:
|
|
314
555
|
txRaw = _a.sent();
|
|
315
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
556
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
316
557
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
317
558
|
case 2: return [2 /*return*/, _a.sent()];
|
|
318
559
|
case 3:
|
|
319
|
-
|
|
320
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
321
|
-
throw
|
|
560
|
+
error_18 = _a.sent();
|
|
561
|
+
FirmaUtil_1.FirmaUtil.printLog(error_18);
|
|
562
|
+
throw error_18;
|
|
322
563
|
case 4: return [2 /*return*/];
|
|
323
564
|
}
|
|
324
565
|
});
|
|
@@ -327,7 +568,7 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
327
568
|
FirmaGovService.prototype.getSignedTxVote = function (wallet, proposalId, option, txMisc) {
|
|
328
569
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
329
570
|
return __awaiter(this, void 0, void 0, function () {
|
|
330
|
-
var voter, txClient, message,
|
|
571
|
+
var voter, txClient, message, error_19;
|
|
331
572
|
return __generator(this, function (_a) {
|
|
332
573
|
switch (_a.label) {
|
|
333
574
|
case 0:
|
|
@@ -335,37 +576,38 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
335
576
|
return [4 /*yield*/, wallet.getAddress()];
|
|
336
577
|
case 1:
|
|
337
578
|
voter = _a.sent();
|
|
338
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
579
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
339
580
|
message = txClient.msgVote({ proposalId: proposalId, voter: voter, option: option });
|
|
340
|
-
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.
|
|
581
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
341
582
|
case 2: return [2 /*return*/, _a.sent()];
|
|
342
583
|
case 3:
|
|
343
|
-
|
|
344
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
345
|
-
throw
|
|
584
|
+
error_19 = _a.sent();
|
|
585
|
+
FirmaUtil_1.FirmaUtil.printLog(error_19);
|
|
586
|
+
throw error_19;
|
|
346
587
|
case 4: return [2 /*return*/];
|
|
347
588
|
}
|
|
348
589
|
});
|
|
349
590
|
});
|
|
350
591
|
};
|
|
351
|
-
FirmaGovService.prototype.
|
|
592
|
+
FirmaGovService.prototype.vote = function (wallet, proposalId, option, txMisc) {
|
|
352
593
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
353
594
|
return __awaiter(this, void 0, void 0, function () {
|
|
354
|
-
var txRaw, txClient,
|
|
595
|
+
var longId, txRaw, txClient, error_20;
|
|
355
596
|
return __generator(this, function (_a) {
|
|
356
597
|
switch (_a.label) {
|
|
357
598
|
case 0:
|
|
358
599
|
_a.trys.push([0, 3, , 4]);
|
|
359
|
-
|
|
600
|
+
longId = long_1.default.fromInt(proposalId);
|
|
601
|
+
return [4 /*yield*/, this.getSignedTxVote(wallet, longId, option, txMisc)];
|
|
360
602
|
case 1:
|
|
361
603
|
txRaw = _a.sent();
|
|
362
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
604
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
363
605
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
364
606
|
case 2: return [2 /*return*/, _a.sent()];
|
|
365
607
|
case 3:
|
|
366
|
-
|
|
367
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
368
|
-
throw
|
|
608
|
+
error_20 = _a.sent();
|
|
609
|
+
FirmaUtil_1.FirmaUtil.printLog(error_20);
|
|
610
|
+
throw error_20;
|
|
369
611
|
case 4: return [2 /*return*/];
|
|
370
612
|
}
|
|
371
613
|
});
|
|
@@ -374,51 +616,137 @@ var FirmaGovService = /** @class */ (function () {
|
|
|
374
616
|
FirmaGovService.prototype.getSignedTxDeposit = function (wallet, proposalId, amount, txMisc) {
|
|
375
617
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
376
618
|
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
-
var txClient, depositor, sendAmount, message,
|
|
619
|
+
var txClient, depositor, sendAmount, message, error_21;
|
|
378
620
|
return __generator(this, function (_a) {
|
|
379
621
|
switch (_a.label) {
|
|
380
622
|
case 0:
|
|
381
623
|
_a.trys.push([0, 3, , 4]);
|
|
382
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
624
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
383
625
|
return [4 /*yield*/, wallet.getAddress()];
|
|
384
626
|
case 1:
|
|
385
627
|
depositor = _a.sent();
|
|
386
|
-
sendAmount = { denom: this.
|
|
628
|
+
sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
|
|
387
629
|
message = txClient.msgDeposit({ proposalId: proposalId, depositor: depositor, amount: [sendAmount] });
|
|
388
|
-
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.
|
|
630
|
+
return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
389
631
|
case 2: return [2 /*return*/, _a.sent()];
|
|
390
632
|
case 3:
|
|
391
|
-
|
|
392
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
393
|
-
throw
|
|
633
|
+
error_21 = _a.sent();
|
|
634
|
+
FirmaUtil_1.FirmaUtil.printLog(error_21);
|
|
635
|
+
throw error_21;
|
|
394
636
|
case 4: return [2 /*return*/];
|
|
395
637
|
}
|
|
396
638
|
});
|
|
397
639
|
});
|
|
398
640
|
};
|
|
399
|
-
FirmaGovService.prototype.
|
|
641
|
+
FirmaGovService.prototype.deposit = function (wallet, proposalId, amount, txMisc) {
|
|
400
642
|
if (txMisc === void 0) { txMisc = gov_1.DefaultTxMisc; }
|
|
401
643
|
return __awaiter(this, void 0, void 0, function () {
|
|
402
|
-
var txRaw, txClient,
|
|
644
|
+
var longId, txRaw, txClient, error_22;
|
|
403
645
|
return __generator(this, function (_a) {
|
|
404
646
|
switch (_a.label) {
|
|
405
647
|
case 0:
|
|
406
648
|
_a.trys.push([0, 3, , 4]);
|
|
407
|
-
|
|
649
|
+
longId = long_1.default.fromInt(proposalId);
|
|
650
|
+
return [4 /*yield*/, this.getSignedTxDeposit(wallet, longId, amount, txMisc)];
|
|
408
651
|
case 1:
|
|
409
652
|
txRaw = _a.sent();
|
|
410
|
-
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.
|
|
653
|
+
txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
411
654
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
412
655
|
case 2: return [2 /*return*/, _a.sent()];
|
|
413
656
|
case 3:
|
|
414
|
-
|
|
415
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
416
|
-
throw
|
|
657
|
+
error_22 = _a.sent();
|
|
658
|
+
FirmaUtil_1.FirmaUtil.printLog(error_22);
|
|
659
|
+
throw error_22;
|
|
417
660
|
case 4: return [2 /*return*/];
|
|
418
661
|
}
|
|
419
662
|
});
|
|
420
663
|
});
|
|
421
664
|
};
|
|
665
|
+
//query
|
|
666
|
+
FirmaGovService.prototype.getParam = function () {
|
|
667
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
668
|
+
var queryClient, result, error_23;
|
|
669
|
+
return __generator(this, function (_a) {
|
|
670
|
+
switch (_a.label) {
|
|
671
|
+
case 0:
|
|
672
|
+
_a.trys.push([0, 2, , 3]);
|
|
673
|
+
queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
|
|
674
|
+
return [4 /*yield*/, queryClient.queryGetParam()];
|
|
675
|
+
case 1:
|
|
676
|
+
result = _a.sent();
|
|
677
|
+
return [2 /*return*/, result];
|
|
678
|
+
case 2:
|
|
679
|
+
error_23 = _a.sent();
|
|
680
|
+
FirmaUtil_1.FirmaUtil.printLog(error_23);
|
|
681
|
+
throw error_23;
|
|
682
|
+
case 3: return [2 /*return*/];
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
FirmaGovService.prototype.getProposal = function (id) {
|
|
688
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
689
|
+
var queryClient, result, error_24;
|
|
690
|
+
return __generator(this, function (_a) {
|
|
691
|
+
switch (_a.label) {
|
|
692
|
+
case 0:
|
|
693
|
+
_a.trys.push([0, 2, , 3]);
|
|
694
|
+
queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
|
|
695
|
+
return [4 /*yield*/, queryClient.queryGetProposal(id)];
|
|
696
|
+
case 1:
|
|
697
|
+
result = _a.sent();
|
|
698
|
+
return [2 /*return*/, result];
|
|
699
|
+
case 2:
|
|
700
|
+
error_24 = _a.sent();
|
|
701
|
+
FirmaUtil_1.FirmaUtil.printLog(error_24);
|
|
702
|
+
throw error_24;
|
|
703
|
+
case 3: return [2 /*return*/];
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
};
|
|
708
|
+
FirmaGovService.prototype.getProposalListByStatus = function (status) {
|
|
709
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
710
|
+
var queryClient, result, error_25;
|
|
711
|
+
return __generator(this, function (_a) {
|
|
712
|
+
switch (_a.label) {
|
|
713
|
+
case 0:
|
|
714
|
+
_a.trys.push([0, 2, , 3]);
|
|
715
|
+
queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
|
|
716
|
+
return [4 /*yield*/, queryClient.queryGetProposalListByStatus(status)];
|
|
717
|
+
case 1:
|
|
718
|
+
result = _a.sent();
|
|
719
|
+
return [2 /*return*/, result];
|
|
720
|
+
case 2:
|
|
721
|
+
error_25 = _a.sent();
|
|
722
|
+
FirmaUtil_1.FirmaUtil.printLog(error_25);
|
|
723
|
+
throw error_25;
|
|
724
|
+
case 3: return [2 /*return*/];
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
};
|
|
729
|
+
FirmaGovService.prototype.getProposalList = function () {
|
|
730
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
731
|
+
var queryClient, result, error_26;
|
|
732
|
+
return __generator(this, function (_a) {
|
|
733
|
+
switch (_a.label) {
|
|
734
|
+
case 0:
|
|
735
|
+
_a.trys.push([0, 2, , 3]);
|
|
736
|
+
queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
|
|
737
|
+
return [4 /*yield*/, queryClient.queryGetProposalList()];
|
|
738
|
+
case 1:
|
|
739
|
+
result = _a.sent();
|
|
740
|
+
return [2 /*return*/, result];
|
|
741
|
+
case 2:
|
|
742
|
+
error_26 = _a.sent();
|
|
743
|
+
FirmaUtil_1.FirmaUtil.printLog(error_26);
|
|
744
|
+
throw error_26;
|
|
745
|
+
case 3: return [2 /*return*/];
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
};
|
|
422
750
|
return FirmaGovService;
|
|
423
751
|
}());
|
|
424
752
|
exports.FirmaGovService = FirmaGovService;
|