@firmachain/firma-js 0.3.0-beta1 → 0.3.2

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.
@@ -35,16 +35,21 @@ 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");
41
- var FirmaUtil_1 = require("./FirmaUtil");
42
44
  var any_1 = require("./firmachain/google/protobuf/any");
45
+ var FirmaUtil_1 = require("./FirmaUtil");
43
46
  var gov_2 = require("cosmjs-types/cosmos/gov/v1beta1/gov");
44
- var distribution_1 = require("cosmjs-types/cosmos/distribution/v1beta1/distribution");
45
- var params_1 = require("cosmjs-types/cosmos/params/v1beta1/params");
46
- var upgrade_1 = require("cosmjs-types/cosmos/upgrade/v1beta1/upgrade");
47
- var tx_1 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx");
47
+ var tx_1 = require("cosmjs-types/cosmos/staking/v1beta1/tx");
48
+ var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
49
+ // temporarly using kintsugi-tech/cosmjs-types - this will be returned to original cosmjs-types after the PR is merged
50
+ var tx_2 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx");
51
+ var tx_3 = require("@kintsugi-tech/cosmjs-types/cosmos/upgrade/v1beta1/tx");
52
+ var tx_4 = require("@kintsugi-tech/cosmjs-types/cosmos/distribution/v1beta1/tx");
48
53
  var FirmaGovService = /** @class */ (function () {
49
54
  function FirmaGovService(config) {
50
55
  this.config = config;
@@ -95,15 +100,23 @@ var FirmaGovService = /** @class */ (function () {
95
100
  });
96
101
  });
97
102
  };
98
- FirmaGovService.prototype.getGasEstimationSubmitCancelSoftwareUpgradeProposal = function (wallet, title, description, initialDepositFCT, txMisc) {
103
+ FirmaGovService.prototype.getGasEstimationSubmitSoftwareUpgradeProposal = function (wallet, title, summary, initialDepositFCT, plan, metadata, txMisc) {
104
+ if (metadata === void 0) { metadata = ""; }
99
105
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
100
106
  return __awaiter(this, void 0, void 0, function () {
101
- var txRaw, error_3;
107
+ var message, txRaw, error_3;
102
108
  return __generator(this, function (_a) {
103
109
  switch (_a.label) {
104
110
  case 0:
105
111
  _a.trys.push([0, 3, , 4]);
106
- return [4 /*yield*/, this.getSignedTxSubmitCancelSoftwareUpgradeProposal(wallet, title, description, initialDepositFCT, txMisc)];
112
+ message = {
113
+ typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
114
+ value: tx_3.MsgSoftwareUpgrade.encode(tx_3.MsgSoftwareUpgrade.fromPartial({
115
+ authority: FirmaGovService.GOV_AUTHORITY,
116
+ plan: plan
117
+ })).finish()
118
+ };
119
+ return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txMisc)];
107
120
  case 1:
108
121
  txRaw = _a.sent();
109
122
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -117,23 +130,34 @@ var FirmaGovService = /** @class */ (function () {
117
130
  });
118
131
  });
119
132
  };
120
- FirmaGovService.prototype.getGasEstimationSubmitSoftwareUpgradeProposalByHeight = function (wallet, title, description, initialDepositFCT, upgradeName, height, txMisc) {
133
+ FirmaGovService.prototype.getGasEstimationSubmitStakingParamsUpdateProposal = function (wallet, title, summary, initialDepositFCT, params, metadata, txMisc) {
134
+ if (metadata === void 0) { metadata = ""; }
121
135
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
122
136
  return __awaiter(this, void 0, void 0, function () {
123
- var upgradeHeight, plan, txRaw, error_4;
137
+ var requestedParams, fromPartialParams, message, txRaw, error_4;
124
138
  return __generator(this, function (_a) {
125
139
  switch (_a.label) {
126
140
  case 0:
127
141
  _a.trys.push([0, 3, , 4]);
128
- upgradeHeight = BigInt(height);
129
- plan = {
130
- name: upgradeName,
131
- time: undefined,
132
- height: upgradeHeight,
133
- info: undefined,
134
- upgradedClientState: undefined
142
+ requestedParams = {
143
+ authority: FirmaGovService.GOV_AUTHORITY,
144
+ params: params
145
+ };
146
+ fromPartialParams = tx_1.MsgUpdateParams.fromPartial({
147
+ authority: FirmaGovService.GOV_AUTHORITY,
148
+ params: params
149
+ });
150
+ if (!fast_deep_equal_1.default(requestedParams.params, fromPartialParams.params)) {
151
+ throw new Error("All staking parameters must be provided. Use Staking.getParamsAsStakingParams() to get current values and override only the parameters you want to change.");
152
+ }
153
+ message = {
154
+ typeUrl: "/cosmos.staking.v1beta1.MsgUpdateParams",
155
+ value: tx_1.MsgUpdateParams.encode(tx_1.MsgUpdateParams.fromPartial({
156
+ authority: FirmaGovService.GOV_AUTHORITY,
157
+ params: params
158
+ })).finish()
135
159
  };
136
- return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDepositFCT, plan, txMisc)];
160
+ return [4 /*yield*/, this.getSignedTxSubmitStakingParamsUpdateProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txMisc)];
137
161
  case 1:
138
162
  txRaw = _a.sent();
139
163
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -147,15 +171,34 @@ var FirmaGovService = /** @class */ (function () {
147
171
  });
148
172
  });
149
173
  };
150
- FirmaGovService.prototype.getGasEstimationSubmitParameterChangeProposal = function (wallet, title, description, initialDepositFCT, paramList, txMisc) {
174
+ FirmaGovService.prototype.getGasEstimationSubmitGovParamsUpdateProposal = function (wallet, title, summary, initialDepositFCT, params, metadata, txMisc) {
175
+ if (metadata === void 0) { metadata = ""; }
151
176
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
152
177
  return __awaiter(this, void 0, void 0, function () {
153
- var txRaw, error_5;
178
+ var requestedParams, fromPartialParams, message, txRaw, error_5;
154
179
  return __generator(this, function (_a) {
155
180
  switch (_a.label) {
156
181
  case 0:
157
182
  _a.trys.push([0, 3, , 4]);
158
- return [4 /*yield*/, this.getSignedTxSubmitParameterChangeProposal(wallet, title, description, initialDepositFCT, paramList, txMisc)];
183
+ requestedParams = {
184
+ authority: FirmaGovService.GOV_AUTHORITY,
185
+ params: params
186
+ };
187
+ fromPartialParams = tx_2.MsgUpdateParams.fromPartial({
188
+ authority: FirmaGovService.GOV_AUTHORITY,
189
+ params: params
190
+ });
191
+ if (!fast_deep_equal_1.default(requestedParams.params, fromPartialParams.params)) {
192
+ throw new Error("All governance parameters must be provided. Use getParamAsGovParams() to get current values and override only the parameters you want to change.");
193
+ }
194
+ message = {
195
+ typeUrl: "/cosmos.gov.v1.MsgUpdateParams",
196
+ value: tx_2.MsgUpdateParams.encode(tx_2.MsgUpdateParams.fromPartial({
197
+ authority: FirmaGovService.GOV_AUTHORITY,
198
+ params: params
199
+ })).finish()
200
+ };
201
+ return [4 /*yield*/, this.getSignedTxSubmitGovParamsUpdateProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txMisc)];
159
202
  case 1:
160
203
  txRaw = _a.sent();
161
204
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -169,15 +212,27 @@ var FirmaGovService = /** @class */ (function () {
169
212
  });
170
213
  });
171
214
  };
172
- FirmaGovService.prototype.getGasEstimationSubmitCommunityPoolSpendProposal = function (wallet, title, description, initialDepositFCT, amount, recipient, txMisc) {
215
+ FirmaGovService.prototype.getGasEstimationSubmitCommunityPoolSpendProposal = function (wallet, title, summary, initialDepositFCT, amountFCT, recipient, txMisc) {
173
216
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
174
217
  return __awaiter(this, void 0, void 0, function () {
175
- var txRaw, error_6;
218
+ var amount, message, txRaw, error_6;
176
219
  return __generator(this, function (_a) {
177
220
  switch (_a.label) {
178
221
  case 0:
179
222
  _a.trys.push([0, 3, , 4]);
180
- return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, description, initialDepositFCT, amount, recipient, txMisc)];
223
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT);
224
+ message = {
225
+ typeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend",
226
+ value: Uint8Array.from(tx_4.MsgCommunityPoolSpend.encode(tx_4.MsgCommunityPoolSpend.fromPartial({
227
+ authority: FirmaGovService.GOV_AUTHORITY,
228
+ recipient: recipient,
229
+ amount: [{
230
+ denom: this.config.denom,
231
+ amount: amount.toString()
232
+ }]
233
+ })).finish())
234
+ };
235
+ return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, summary, initialDepositFCT, [message], recipient, txMisc)];
181
236
  case 1:
182
237
  txRaw = _a.sent();
183
238
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -268,34 +323,30 @@ var FirmaGovService = /** @class */ (function () {
268
323
  });
269
324
  });
270
325
  };
271
- FirmaGovService.prototype.getSignedTxSubmitCancelSoftwareUpgradeProposal = function (wallet, title, description, initialDepositFCT, txMisc) {
326
+ FirmaGovService.prototype.getSignedTxSubmitSoftwareUpgradeProposal = function (wallet, title, summary, initialDepositFCT, messages, metadata, txMisc) {
327
+ if (metadata === void 0) { metadata = ""; }
272
328
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
273
329
  return __awaiter(this, void 0, void 0, function () {
274
- var initialDepositAmount, proposal, content, proposer, message, txClient, error_10;
330
+ var proposer, initialDeposit, message, txClient, error_10;
275
331
  return __generator(this, function (_a) {
276
332
  switch (_a.label) {
277
333
  case 0:
278
334
  _a.trys.push([0, 3, , 4]);
279
- initialDepositAmount = {
280
- denom: this.config.denom,
281
- amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
282
- };
283
- proposal = upgrade_1.CancelSoftwareUpgradeProposal.fromPartial({
284
- title: title,
285
- description: description,
286
- });
287
- content = any_1.Any.fromPartial({
288
- typeUrl: "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal",
289
- value: Uint8Array.from(upgrade_1.CancelSoftwareUpgradeProposal.encode(proposal).finish()),
290
- });
291
335
  return [4 /*yield*/, wallet.getAddress()];
292
336
  case 1:
293
337
  proposer = _a.sent();
294
- message = gov_1.GovTxClient.msgSubmitProposal({
295
- content: content,
296
- initialDeposit: [initialDepositAmount],
297
- proposer: proposer
298
- });
338
+ initialDeposit = [{ amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT), denom: this.config.denom }];
339
+ message = {
340
+ typeUrl: "/cosmos.gov.v1.MsgSubmitProposal",
341
+ value: tx_2.MsgSubmitProposal.fromPartial({
342
+ title: title,
343
+ summary: summary,
344
+ metadata: metadata,
345
+ messages: messages,
346
+ proposer: proposer,
347
+ initialDeposit: initialDeposit
348
+ })
349
+ };
299
350
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
300
351
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
301
352
  case 2: return [2 /*return*/, _a.sent()];
@@ -308,35 +359,30 @@ var FirmaGovService = /** @class */ (function () {
308
359
  });
309
360
  });
310
361
  };
311
- FirmaGovService.prototype.getSignedTxSubmitSoftwareUpgradeProposal = function (wallet, title, description, initialDepositFCT, plan, txMisc) {
362
+ FirmaGovService.prototype.getSignedTxSubmitStakingParamsUpdateProposal = function (wallet, title, summary, initialDepositFCT, messages, metadata, txMisc) {
363
+ if (metadata === void 0) { metadata = ""; }
312
364
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
313
365
  return __awaiter(this, void 0, void 0, function () {
314
- var initialDepositAmount, proposal, content, proposer, message, txClient, error_11;
366
+ var proposer, initialDeposit, message, txClient, error_11;
315
367
  return __generator(this, function (_a) {
316
368
  switch (_a.label) {
317
369
  case 0:
318
370
  _a.trys.push([0, 3, , 4]);
319
- initialDepositAmount = {
320
- denom: this.config.denom,
321
- amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
322
- };
323
- proposal = upgrade_1.SoftwareUpgradeProposal.fromPartial({
324
- title: title,
325
- description: description,
326
- plan: plan,
327
- });
328
- content = any_1.Any.fromPartial({
329
- typeUrl: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal",
330
- value: Uint8Array.from(upgrade_1.SoftwareUpgradeProposal.encode(proposal).finish()),
331
- });
332
371
  return [4 /*yield*/, wallet.getAddress()];
333
372
  case 1:
334
373
  proposer = _a.sent();
335
- message = gov_1.GovTxClient.msgSubmitProposal({
336
- content: content,
337
- initialDeposit: [initialDepositAmount],
338
- proposer: proposer
339
- });
374
+ initialDeposit = [{ amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT), denom: this.config.denom }];
375
+ message = {
376
+ typeUrl: "/cosmos.gov.v1.MsgSubmitProposal",
377
+ value: tx_2.MsgSubmitProposal.fromPartial({
378
+ title: title,
379
+ summary: summary,
380
+ metadata: metadata,
381
+ messages: messages,
382
+ proposer: proposer,
383
+ initialDeposit: initialDeposit
384
+ })
385
+ };
340
386
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
341
387
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
342
388
  case 2: return [2 /*return*/, _a.sent()];
@@ -349,35 +395,30 @@ var FirmaGovService = /** @class */ (function () {
349
395
  });
350
396
  });
351
397
  };
352
- FirmaGovService.prototype.getSignedTxSubmitParameterChangeProposal = function (wallet, title, description, initialDepositFCT, paramList, txMisc) {
398
+ FirmaGovService.prototype.getSignedTxSubmitGovParamsUpdateProposal = function (wallet, title, summary, initialDepositFCT, messages, metadata, txMisc) {
399
+ if (metadata === void 0) { metadata = ""; }
353
400
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
354
401
  return __awaiter(this, void 0, void 0, function () {
355
- var initialDepositAmount, proposal, content, proposer, message, txClient, error_12;
402
+ var proposer, initialDeposit, message, txClient, error_12;
356
403
  return __generator(this, function (_a) {
357
404
  switch (_a.label) {
358
405
  case 0:
359
406
  _a.trys.push([0, 3, , 4]);
360
- initialDepositAmount = {
361
- denom: this.config.denom,
362
- amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
363
- };
364
- proposal = params_1.ParameterChangeProposal.fromPartial({
365
- title: title,
366
- description: description,
367
- changes: paramList,
368
- });
369
- content = any_1.Any.fromPartial({
370
- typeUrl: "/cosmos.params.v1beta1.ParameterChangeProposal",
371
- value: Uint8Array.from(params_1.ParameterChangeProposal.encode(proposal).finish()),
372
- });
373
407
  return [4 /*yield*/, wallet.getAddress()];
374
408
  case 1:
375
409
  proposer = _a.sent();
376
- message = gov_1.GovTxClient.msgSubmitProposal({
377
- content: content,
378
- initialDeposit: [initialDepositAmount],
379
- proposer: proposer
380
- });
410
+ initialDeposit = [{ amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT), denom: this.config.denom }];
411
+ message = {
412
+ typeUrl: "/cosmos.gov.v1.MsgSubmitProposal",
413
+ value: tx_2.MsgSubmitProposal.fromPartial({
414
+ title: title,
415
+ summary: summary,
416
+ metadata: metadata,
417
+ messages: messages,
418
+ proposer: proposer,
419
+ initialDeposit: initialDeposit
420
+ })
421
+ };
381
422
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
382
423
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
383
424
  case 2: return [2 /*return*/, _a.sent()];
@@ -390,37 +431,30 @@ var FirmaGovService = /** @class */ (function () {
390
431
  });
391
432
  });
392
433
  };
393
- FirmaGovService.prototype.getSignedTxSubmitCommunityPoolSpendProposal = function (wallet, title, description, initialDepositFCT, amount, recipient, txMisc) {
434
+ FirmaGovService.prototype.getSignedTxSubmitCommunityPoolSpendProposal = function (wallet, title, summary, initialDepositFCT, messages, metadata, txMisc) {
435
+ if (metadata === void 0) { metadata = ""; }
394
436
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
395
437
  return __awaiter(this, void 0, void 0, function () {
396
- var initialDepositAmount, sendAmount, proposal, content, proposer, message, txClient, error_13;
438
+ var proposer, initialDeposit, message, txClient, error_13;
397
439
  return __generator(this, function (_a) {
398
440
  switch (_a.label) {
399
441
  case 0:
400
442
  _a.trys.push([0, 3, , 4]);
401
- initialDepositAmount = {
402
- denom: this.config.denom,
403
- amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
404
- };
405
- sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
406
- proposal = distribution_1.CommunityPoolSpendProposal.fromPartial({
407
- title: title,
408
- description: description,
409
- recipient: recipient,
410
- amount: [sendAmount]
411
- });
412
- content = any_1.Any.fromPartial({
413
- typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal",
414
- value: Uint8Array.from(distribution_1.CommunityPoolSpendProposal.encode(proposal).finish()),
415
- });
416
443
  return [4 /*yield*/, wallet.getAddress()];
417
444
  case 1:
418
445
  proposer = _a.sent();
419
- message = gov_1.GovTxClient.msgSubmitProposal({
420
- content: content,
421
- initialDeposit: [initialDepositAmount],
422
- proposer: proposer
423
- });
446
+ initialDeposit = [{ amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT), denom: this.config.denom }];
447
+ message = {
448
+ typeUrl: "/cosmos.gov.v1.MsgSubmitProposal",
449
+ value: tx_2.MsgSubmitProposal.fromPartial({
450
+ title: title,
451
+ summary: summary,
452
+ metadata: metadata,
453
+ messages: messages,
454
+ proposer: proposer,
455
+ initialDeposit: initialDeposit,
456
+ })
457
+ };
424
458
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
425
459
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
426
460
  case 2: return [2 /*return*/, _a.sent()];
@@ -444,7 +478,7 @@ var FirmaGovService = /** @class */ (function () {
444
478
  proposer = _a.sent();
445
479
  message = {
446
480
  typeUrl: "/cosmos.gov.v1.MsgCancelProposal",
447
- value: tx_1.MsgCancelProposal.fromPartial({
481
+ value: tx_2.MsgCancelProposal.fromPartial({
448
482
  proposalId: BigInt(proposalId),
449
483
  proposer: proposer
450
484
  })
@@ -456,15 +490,23 @@ var FirmaGovService = /** @class */ (function () {
456
490
  });
457
491
  });
458
492
  };
459
- FirmaGovService.prototype.submitCancelSoftwareUpgradeProposal = function (wallet, title, description, initialDeposit, txMisc) {
493
+ FirmaGovService.prototype.submitSoftwareUpgradeProposal = function (wallet, title, summary, initialDepositFCT, plan, metadata, txMisc) {
494
+ if (metadata === void 0) { metadata = ""; }
460
495
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
461
496
  return __awaiter(this, void 0, void 0, function () {
462
- var txRaw, txClient, error_14;
497
+ var message, txRaw, txClient, error_14;
463
498
  return __generator(this, function (_a) {
464
499
  switch (_a.label) {
465
500
  case 0:
466
501
  _a.trys.push([0, 3, , 4]);
467
- return [4 /*yield*/, this.getSignedTxSubmitCancelSoftwareUpgradeProposal(wallet, title, description, initialDeposit, txMisc)];
502
+ message = {
503
+ typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
504
+ value: tx_3.MsgSoftwareUpgrade.encode(tx_3.MsgSoftwareUpgrade.fromPartial({
505
+ authority: FirmaGovService.GOV_AUTHORITY,
506
+ plan: plan
507
+ })).finish()
508
+ };
509
+ return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txMisc)];
468
510
  case 1:
469
511
  txRaw = _a.sent();
470
512
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
@@ -479,23 +521,34 @@ var FirmaGovService = /** @class */ (function () {
479
521
  });
480
522
  });
481
523
  };
482
- FirmaGovService.prototype.submitSoftwareUpgradeProposalByHeight = function (wallet, title, description, initialDeposit, upgradeName, height, txMisc) {
524
+ FirmaGovService.prototype.submitStakingParamsUpdateProposal = function (wallet, title, summary, initialDepositFCT, params, metadata, txMisc) {
525
+ if (metadata === void 0) { metadata = ""; }
483
526
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
484
527
  return __awaiter(this, void 0, void 0, function () {
485
- var upgradeHeight, plan, txRaw, txClient, error_15;
528
+ var requestedParams, fromPartialParams, message, txRaw, txClient, error_15;
486
529
  return __generator(this, function (_a) {
487
530
  switch (_a.label) {
488
531
  case 0:
489
532
  _a.trys.push([0, 3, , 4]);
490
- upgradeHeight = BigInt(height);
491
- plan = {
492
- name: upgradeName,
493
- time: undefined,
494
- height: upgradeHeight,
495
- info: undefined,
496
- upgradedClientState: undefined
533
+ requestedParams = {
534
+ authority: FirmaGovService.GOV_AUTHORITY,
535
+ params: params
536
+ };
537
+ fromPartialParams = tx_1.MsgUpdateParams.fromPartial({
538
+ authority: FirmaGovService.GOV_AUTHORITY,
539
+ params: params
540
+ });
541
+ if (!fast_deep_equal_1.default(requestedParams.params, fromPartialParams.params)) {
542
+ throw new Error("All staking parameters must be provided. Use Staking.getParamsAsStakingParams() to get current values and override only the parameters you want to change.");
543
+ }
544
+ message = {
545
+ typeUrl: "/cosmos.staking.v1beta1.MsgUpdateParams",
546
+ value: tx_1.MsgUpdateParams.encode(tx_1.MsgUpdateParams.fromPartial({
547
+ authority: FirmaGovService.GOV_AUTHORITY,
548
+ params: params
549
+ })).finish()
497
550
  };
498
- return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDeposit, plan, txMisc)];
551
+ return [4 /*yield*/, this.getSignedTxSubmitStakingParamsUpdateProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txMisc)];
499
552
  case 1:
500
553
  txRaw = _a.sent();
501
554
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
@@ -510,22 +563,34 @@ var FirmaGovService = /** @class */ (function () {
510
563
  });
511
564
  });
512
565
  };
513
- FirmaGovService.prototype.submitSoftwareUpgradeProposalByTime = function (wallet, title, description, initialDeposit, upgradeName, upgradeTime, txMisc) {
514
- if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
566
+ FirmaGovService.prototype.submitGovParamsUpdateProposal = function (wallet, title, summary, initialDepositFCT, params, metadata, txmisc) {
567
+ if (metadata === void 0) { metadata = ""; }
568
+ if (txmisc === void 0) { txmisc = FirmaUtil_1.DefaultTxMisc; }
515
569
  return __awaiter(this, void 0, void 0, function () {
516
- var plan, txRaw, txClient, error_16;
570
+ var requestedParams, fromPartialParams, message, txRaw, txClient, error_16;
517
571
  return __generator(this, function (_a) {
518
572
  switch (_a.label) {
519
573
  case 0:
520
574
  _a.trys.push([0, 3, , 4]);
521
- plan = {
522
- name: upgradeName,
523
- time: upgradeTime,
524
- height: undefined,
525
- info: undefined,
526
- upgradedClientState: undefined
575
+ requestedParams = {
576
+ authority: FirmaGovService.GOV_AUTHORITY,
577
+ params: params
578
+ };
579
+ fromPartialParams = tx_2.MsgUpdateParams.fromPartial({
580
+ authority: FirmaGovService.GOV_AUTHORITY,
581
+ params: params
582
+ });
583
+ if (!fast_deep_equal_1.default(requestedParams.params, fromPartialParams.params)) {
584
+ throw new Error("All governance parameters must be provided. Use getParamAsGovParams() to get current values and override only the parameters you want to change.");
585
+ }
586
+ message = {
587
+ typeUrl: "/cosmos.gov.v1.MsgUpdateParams",
588
+ value: tx_2.MsgUpdateParams.encode(tx_2.MsgUpdateParams.fromPartial({
589
+ authority: FirmaGovService.GOV_AUTHORITY,
590
+ params: params
591
+ })).finish()
527
592
  };
528
- return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDeposit, plan, txMisc)];
593
+ return [4 /*yield*/, this.getSignedTxSubmitGovParamsUpdateProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txmisc)];
529
594
  case 1:
530
595
  txRaw = _a.sent();
531
596
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
@@ -540,15 +605,28 @@ var FirmaGovService = /** @class */ (function () {
540
605
  });
541
606
  });
542
607
  };
543
- FirmaGovService.prototype.submitParameterChangeProposal = function (wallet, title, description, initialDeposit, paramList, txMisc) {
608
+ FirmaGovService.prototype.submitCommunityPoolSpendProposal = function (wallet, title, summary, initialDepositFCT, amountFCT, recipient, metadata, txMisc) {
609
+ if (metadata === void 0) { metadata = ""; }
544
610
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
545
611
  return __awaiter(this, void 0, void 0, function () {
546
- var txRaw, txClient, error_17;
612
+ var amount, message, txRaw, txClient, error_17;
547
613
  return __generator(this, function (_a) {
548
614
  switch (_a.label) {
549
615
  case 0:
550
616
  _a.trys.push([0, 3, , 4]);
551
- return [4 /*yield*/, this.getSignedTxSubmitParameterChangeProposal(wallet, title, description, initialDeposit, paramList, txMisc)];
617
+ amount = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT);
618
+ message = {
619
+ typeUrl: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend",
620
+ value: Uint8Array.from(tx_4.MsgCommunityPoolSpend.encode(tx_4.MsgCommunityPoolSpend.fromPartial({
621
+ authority: FirmaGovService.GOV_AUTHORITY,
622
+ recipient: recipient,
623
+ amount: [{
624
+ denom: this.config.denom,
625
+ amount: amount.toString()
626
+ }]
627
+ })).finish())
628
+ };
629
+ return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, summary, initialDepositFCT, [message], metadata, txMisc)];
552
630
  case 1:
553
631
  txRaw = _a.sent();
554
632
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
@@ -563,7 +641,7 @@ var FirmaGovService = /** @class */ (function () {
563
641
  });
564
642
  });
565
643
  };
566
- FirmaGovService.prototype.submitCommunityPoolSpendProposal = function (wallet, title, description, initialDeposit, amount, recipient, txMisc) {
644
+ FirmaGovService.prototype.submitTextProposal = function (wallet, title, description, initialDeposit, txMisc) {
567
645
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
568
646
  return __awaiter(this, void 0, void 0, function () {
569
647
  var txRaw, txClient, error_18;
@@ -571,7 +649,7 @@ var FirmaGovService = /** @class */ (function () {
571
649
  switch (_a.label) {
572
650
  case 0:
573
651
  _a.trys.push([0, 3, , 4]);
574
- return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, description, initialDeposit, amount, recipient, txMisc)];
652
+ return [4 /*yield*/, this.getSignedTxSubmitTextProposal(wallet, title, description, initialDeposit, txMisc)];
575
653
  case 1:
576
654
  txRaw = _a.sent();
577
655
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
@@ -586,25 +664,39 @@ var FirmaGovService = /** @class */ (function () {
586
664
  });
587
665
  });
588
666
  };
589
- FirmaGovService.prototype.submitTextProposal = function (wallet, title, description, initialDeposit, txMisc) {
667
+ FirmaGovService.prototype.submitGenericProposal = function (wallet, title, summary, initialDeposit, metadata, msgs, txMisc) {
590
668
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
591
669
  return __awaiter(this, void 0, void 0, function () {
592
- var txRaw, txClient, error_19;
670
+ var proposer, message, txClient, signed, error_19;
593
671
  return __generator(this, function (_a) {
594
672
  switch (_a.label) {
595
673
  case 0:
596
- _a.trys.push([0, 3, , 4]);
597
- return [4 /*yield*/, this.getSignedTxSubmitTextProposal(wallet, title, description, initialDeposit, txMisc)];
674
+ _a.trys.push([0, 4, , 5]);
675
+ return [4 /*yield*/, wallet.getAddress()];
598
676
  case 1:
599
- txRaw = _a.sent();
677
+ proposer = _a.sent();
678
+ message = {
679
+ typeUrl: "/cosmos.gov.v1.MsgSubmitProposal",
680
+ value: tx_2.MsgSubmitProposal.fromPartial({
681
+ title: title,
682
+ summary: summary,
683
+ metadata: metadata,
684
+ messages: msgs,
685
+ proposer: proposer,
686
+ initialDeposit: initialDeposit,
687
+ })
688
+ };
600
689
  txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
601
- return [4 /*yield*/, txClient.broadcast(txRaw)];
602
- case 2: return [2 /*return*/, _a.sent()];
603
- case 3:
690
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
691
+ case 2:
692
+ signed = _a.sent();
693
+ return [4 /*yield*/, txClient.broadcast(signed)];
694
+ case 3: return [2 /*return*/, _a.sent()];
695
+ case 4:
604
696
  error_19 = _a.sent();
605
697
  FirmaUtil_1.FirmaUtil.printLog(error_19);
606
698
  throw error_19;
607
- case 4: return [2 /*return*/];
699
+ case 5: return [2 /*return*/];
608
700
  }
609
701
  });
610
702
  });
@@ -772,7 +864,7 @@ var FirmaGovService = /** @class */ (function () {
772
864
  });
773
865
  });
774
866
  };
775
- FirmaGovService.prototype.getProposal = function (id) {
867
+ FirmaGovService.prototype.getParamAsGovParams = function () {
776
868
  return __awaiter(this, void 0, void 0, function () {
777
869
  var queryClient, result, error_27;
778
870
  return __generator(this, function (_a) {
@@ -780,10 +872,28 @@ var FirmaGovService = /** @class */ (function () {
780
872
  case 0:
781
873
  _a.trys.push([0, 2, , 3]);
782
874
  queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
783
- return [4 /*yield*/, queryClient.queryGetProposal(id)];
875
+ return [4 /*yield*/, queryClient.queryGetParam()];
784
876
  case 1:
785
877
  result = _a.sent();
786
- return [2 /*return*/, result];
878
+ // return as GovParams type
879
+ return [2 /*return*/, {
880
+ minDeposit: result.min_deposit,
881
+ maxDepositPeriod: FirmaUtil_1.FirmaUtil.createDurationFromString(result.max_deposit_period),
882
+ votingPeriod: FirmaUtil_1.FirmaUtil.createDurationFromString(result.voting_period),
883
+ quorum: result.quorum,
884
+ threshold: result.threshold,
885
+ vetoThreshold: result.veto_threshold,
886
+ minInitialDepositRatio: result.min_initial_deposit_ratio,
887
+ proposalCancelRatio: result.proposal_cancel_ratio,
888
+ proposalCancelDest: result.proposal_cancel_dest,
889
+ expeditedVotingPeriod: FirmaUtil_1.FirmaUtil.createDurationFromString(result.expedited_voting_period),
890
+ expeditedThreshold: result.expedited_threshold,
891
+ expeditedMinDeposit: result.expedited_min_deposit,
892
+ burnVoteQuorum: result.burn_vote_quorum,
893
+ burnProposalDepositPrevote: result.burn_proposal_deposit_prevote,
894
+ burnVoteVeto: result.burn_vote_veto,
895
+ minDepositRatio: result.min_deposit_ratio
896
+ }];
787
897
  case 2:
788
898
  error_27 = _a.sent();
789
899
  FirmaUtil_1.FirmaUtil.printLog(error_27);
@@ -793,7 +903,7 @@ var FirmaGovService = /** @class */ (function () {
793
903
  });
794
904
  });
795
905
  };
796
- FirmaGovService.prototype.getProposalListByStatus = function (status) {
906
+ FirmaGovService.prototype.getProposal = function (id) {
797
907
  return __awaiter(this, void 0, void 0, function () {
798
908
  var queryClient, result, error_28;
799
909
  return __generator(this, function (_a) {
@@ -801,7 +911,7 @@ var FirmaGovService = /** @class */ (function () {
801
911
  case 0:
802
912
  _a.trys.push([0, 2, , 3]);
803
913
  queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
804
- return [4 /*yield*/, queryClient.queryGetProposalListByStatus(status)];
914
+ return [4 /*yield*/, queryClient.queryGetProposal(id)];
805
915
  case 1:
806
916
  result = _a.sent();
807
917
  return [2 /*return*/, result];
@@ -814,7 +924,7 @@ var FirmaGovService = /** @class */ (function () {
814
924
  });
815
925
  });
816
926
  };
817
- FirmaGovService.prototype.getProposalList = function () {
927
+ FirmaGovService.prototype.getProposalListByStatus = function (status) {
818
928
  return __awaiter(this, void 0, void 0, function () {
819
929
  var queryClient, result, error_29;
820
930
  return __generator(this, function (_a) {
@@ -822,7 +932,7 @@ var FirmaGovService = /** @class */ (function () {
822
932
  case 0:
823
933
  _a.trys.push([0, 2, , 3]);
824
934
  queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
825
- return [4 /*yield*/, queryClient.queryGetProposalList()];
935
+ return [4 /*yield*/, queryClient.queryGetProposalListByStatus(status)];
826
936
  case 1:
827
937
  result = _a.sent();
828
938
  return [2 /*return*/, result];
@@ -835,6 +945,28 @@ var FirmaGovService = /** @class */ (function () {
835
945
  });
836
946
  });
837
947
  };
948
+ FirmaGovService.prototype.getProposalList = function () {
949
+ return __awaiter(this, void 0, void 0, function () {
950
+ var queryClient, result, error_30;
951
+ return __generator(this, function (_a) {
952
+ switch (_a.label) {
953
+ case 0:
954
+ _a.trys.push([0, 2, , 3]);
955
+ queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
956
+ return [4 /*yield*/, queryClient.queryGetProposalList()];
957
+ case 1:
958
+ result = _a.sent();
959
+ return [2 /*return*/, result];
960
+ case 2:
961
+ error_30 = _a.sent();
962
+ FirmaUtil_1.FirmaUtil.printLog(error_30);
963
+ throw error_30;
964
+ case 3: return [2 /*return*/];
965
+ }
966
+ });
967
+ });
968
+ };
969
+ FirmaGovService.GOV_AUTHORITY = "firma10d07y265gmmuvt4z0w9aw880jnsr700j53mj8f";
838
970
  return FirmaGovService;
839
971
  }());
840
972
  exports.FirmaGovService = FirmaGovService;