@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.
- package/README.md +46 -15
- package/dist/sdk/FirmaGovService.d.ts +26 -17
- package/dist/sdk/FirmaGovService.js +282 -150
- package/dist/sdk/FirmaStakingService.d.ts +4 -2
- package/dist/sdk/FirmaStakingService.js +37 -9
- package/dist/sdk/FirmaUtil.d.ts +36 -0
- package/dist/sdk/FirmaUtil.js +139 -0
- package/dist/sdk/firmachain/common/CommonTxClient.js +1 -0
- package/dist/sdk/firmachain/common/modules/gov/messages.js +1 -0
- package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +25 -40
- package/dist/sdk/firmachain/gov/GovQueryClient.js +20 -21
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +6 -0
- package/dist/sdk/firmachain/gov/GovTxClient.js +8 -2
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +3 -2
- package/dist/test/08.gas_estimate.test.js +41 -28
- package/dist/test/13.staking_query.test.js +12 -0
- package/dist/test/16.gov_tx.test.js +139 -58
- package/dist/test/17.gov_query.test.js +18 -18
- package/dist/test/18.util.test.js +74 -0
- package/dist/test/20.slashing_query.test.js +0 -1
- package/dist/test/config_test.js +10 -4
- package/dist/test/config_test.sample.d.ts +6 -0
- package/dist/test/config_test.sample.js +7 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { StakingTxClient, TxMisc, ValidatorDataType, PoolDataType,
|
|
1
|
+
import { StakingTxClient, TxMisc, ValidatorDataType, PoolDataType, DelegationInfo, RedelegationInfo, UndelegationInfo, Pagination, StakingParamType } from "./firmachain/staking";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
4
|
import { DeliverTxResponse } from "./firmachain/common/stargateclient";
|
|
5
5
|
import { Description } from "cosmjs-types/cosmos/staking/v1beta1/staking";
|
|
6
6
|
import { MsgCreateValidator } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
|
7
|
+
import { Params as StakingParams } from "@kintsugi-tech/cosmjs-types/cosmos/staking/v1beta1/staking";
|
|
7
8
|
export declare enum StakingValidatorStatus {
|
|
8
9
|
ALL = "",
|
|
9
10
|
BONDED = "BOND_STATUS_BONDED",
|
|
@@ -43,7 +44,8 @@ export declare class FirmaStakingService {
|
|
|
43
44
|
dataList: DelegationInfo[];
|
|
44
45
|
pagination: Pagination;
|
|
45
46
|
}>;
|
|
46
|
-
getParams(): Promise<
|
|
47
|
+
getParams(): Promise<StakingParamType>;
|
|
48
|
+
getParamsAsStakingParams(): Promise<StakingParams>;
|
|
47
49
|
getPool(): Promise<PoolDataType>;
|
|
48
50
|
getValidator(valoperAddress: string): Promise<ValidatorDataType>;
|
|
49
51
|
getValidatorList(status?: StakingValidatorStatus, paginationKey?: string): Promise<{
|
|
@@ -549,7 +549,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
549
549
|
});
|
|
550
550
|
});
|
|
551
551
|
};
|
|
552
|
-
FirmaStakingService.prototype.
|
|
552
|
+
FirmaStakingService.prototype.getParamsAsStakingParams = function () {
|
|
553
553
|
return __awaiter(this, void 0, void 0, function () {
|
|
554
554
|
var queryClient, result, error_22;
|
|
555
555
|
return __generator(this, function (_a) {
|
|
@@ -557,10 +557,17 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
557
557
|
case 0:
|
|
558
558
|
_a.trys.push([0, 2, , 3]);
|
|
559
559
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
560
|
-
return [4 /*yield*/, queryClient.
|
|
560
|
+
return [4 /*yield*/, queryClient.queryGetParams()];
|
|
561
561
|
case 1:
|
|
562
562
|
result = _a.sent();
|
|
563
|
-
return [2 /*return*/,
|
|
563
|
+
return [2 /*return*/, {
|
|
564
|
+
unbondingTime: FirmaUtil_1.FirmaUtil.createDurationFromString(result.unbonding_time),
|
|
565
|
+
maxValidators: result.max_validators,
|
|
566
|
+
maxEntries: result.max_entries,
|
|
567
|
+
historicalEntries: result.historical_entries,
|
|
568
|
+
bondDenom: result.bond_denom,
|
|
569
|
+
minCommissionRate: FirmaUtil_1.FirmaUtil.processCommissionRate(result.min_commission_rate)
|
|
570
|
+
}];
|
|
564
571
|
case 2:
|
|
565
572
|
error_22 = _a.sent();
|
|
566
573
|
FirmaUtil_1.FirmaUtil.printLog(error_22);
|
|
@@ -570,7 +577,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
570
577
|
});
|
|
571
578
|
});
|
|
572
579
|
};
|
|
573
|
-
FirmaStakingService.prototype.
|
|
580
|
+
FirmaStakingService.prototype.getPool = function () {
|
|
574
581
|
return __awaiter(this, void 0, void 0, function () {
|
|
575
582
|
var queryClient, result, error_23;
|
|
576
583
|
return __generator(this, function (_a) {
|
|
@@ -578,7 +585,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
578
585
|
case 0:
|
|
579
586
|
_a.trys.push([0, 2, , 3]);
|
|
580
587
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
581
|
-
return [4 /*yield*/, queryClient.
|
|
588
|
+
return [4 /*yield*/, queryClient.queryGetPool()];
|
|
582
589
|
case 1:
|
|
583
590
|
result = _a.sent();
|
|
584
591
|
return [2 /*return*/, result];
|
|
@@ -591,9 +598,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
591
598
|
});
|
|
592
599
|
});
|
|
593
600
|
};
|
|
594
|
-
FirmaStakingService.prototype.
|
|
595
|
-
if (status === void 0) { status = StakingValidatorStatus.ALL; }
|
|
596
|
-
if (paginationKey === void 0) { paginationKey = ""; }
|
|
601
|
+
FirmaStakingService.prototype.getValidator = function (valoperAddress) {
|
|
597
602
|
return __awaiter(this, void 0, void 0, function () {
|
|
598
603
|
var queryClient, result, error_24;
|
|
599
604
|
return __generator(this, function (_a) {
|
|
@@ -601,7 +606,7 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
601
606
|
case 0:
|
|
602
607
|
_a.trys.push([0, 2, , 3]);
|
|
603
608
|
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
604
|
-
return [4 /*yield*/, queryClient.
|
|
609
|
+
return [4 /*yield*/, queryClient.queryValidator(valoperAddress)];
|
|
605
610
|
case 1:
|
|
606
611
|
result = _a.sent();
|
|
607
612
|
return [2 /*return*/, result];
|
|
@@ -614,6 +619,29 @@ var FirmaStakingService = /** @class */ (function () {
|
|
|
614
619
|
});
|
|
615
620
|
});
|
|
616
621
|
};
|
|
622
|
+
FirmaStakingService.prototype.getValidatorList = function (status, paginationKey) {
|
|
623
|
+
if (status === void 0) { status = StakingValidatorStatus.ALL; }
|
|
624
|
+
if (paginationKey === void 0) { paginationKey = ""; }
|
|
625
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
626
|
+
var queryClient, result, error_25;
|
|
627
|
+
return __generator(this, function (_a) {
|
|
628
|
+
switch (_a.label) {
|
|
629
|
+
case 0:
|
|
630
|
+
_a.trys.push([0, 2, , 3]);
|
|
631
|
+
queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
|
|
632
|
+
return [4 /*yield*/, queryClient.queryValidators(status.toString(), paginationKey)];
|
|
633
|
+
case 1:
|
|
634
|
+
result = _a.sent();
|
|
635
|
+
return [2 /*return*/, result];
|
|
636
|
+
case 2:
|
|
637
|
+
error_25 = _a.sent();
|
|
638
|
+
FirmaUtil_1.FirmaUtil.printLog(error_25);
|
|
639
|
+
throw error_25;
|
|
640
|
+
case 3: return [2 /*return*/];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
};
|
|
617
645
|
return FirmaStakingService;
|
|
618
646
|
}());
|
|
619
647
|
exports.FirmaStakingService = FirmaStakingService;
|
package/dist/sdk/FirmaUtil.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { FirmaWalletService } from "./FirmaWalletService";
|
|
|
7
7
|
import { ArbitraryVerifyData } from "./firmachain/common/signingstargateclient";
|
|
8
8
|
import { Any } from "./firmachain/google/protobuf/any";
|
|
9
9
|
import { CommonTxClient } from "./firmachain/common/CommonTxClient";
|
|
10
|
+
import { Duration } from "cosmjs-types/google/protobuf/duration";
|
|
10
11
|
export declare class FirmaUtil {
|
|
11
12
|
static config: FirmaConfig;
|
|
12
13
|
static readonly FctDecimal: number;
|
|
@@ -49,6 +50,41 @@ export declare class FirmaUtil {
|
|
|
49
50
|
static makeSignDocWithStringify(signerAddress: string, pubkey: string, messages: readonly EncodeObject[], txMisc?: TxMisc): Promise<string>;
|
|
50
51
|
static getAnyData(registry: Registry, message: EncodeObject): Any;
|
|
51
52
|
static getCommonTxClient(aliceWallet: FirmaWalletService): CommonTxClient;
|
|
53
|
+
/**
|
|
54
|
+
* Parses a duration string to a Duration object.
|
|
55
|
+
* Supports formats like "336h0m0s", "21d", "1000ms", "1s", "1m", "1h", "1ns", "1µs"/"1us"
|
|
56
|
+
*
|
|
57
|
+
* @param durationStr - Duration string to parse (e.g., "336h0m0s", "21d")
|
|
58
|
+
* @returns Duration object with seconds and nanos fields
|
|
59
|
+
*/
|
|
60
|
+
static parseDurationString(durationStr: string): {
|
|
61
|
+
seconds: bigint;
|
|
62
|
+
nanos: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Creates a Duration object from a duration string.
|
|
66
|
+
* This is a convenience method that combines parseDurationString with Duration.fromPartial.
|
|
67
|
+
*
|
|
68
|
+
* @param durationStr - Duration string to parse (e.g., "336h0m0s", "21d")
|
|
69
|
+
* @returns Duration object ready to use with protobuf
|
|
70
|
+
*/
|
|
71
|
+
static createDurationFromString(durationStr: string): Duration;
|
|
72
|
+
/**
|
|
73
|
+
* Normalizes decimal string for Cosmos SDK usage.
|
|
74
|
+
* Converts "0.000000000000000000" to empty string to avoid big.Int conversion errors.
|
|
75
|
+
*
|
|
76
|
+
* @param decimalStr - Decimal string that might cause big.Int conversion issues
|
|
77
|
+
* @returns Normalized string safe for Cosmos SDK usage
|
|
78
|
+
*/
|
|
79
|
+
static normalizeDecimalString(decimalStr: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Safely processes commission rate strings to prevent big.Int conversion errors.
|
|
82
|
+
* This is specifically for handling commission rates that might be "0.000000000000000000".
|
|
83
|
+
*
|
|
84
|
+
* @param commissionRate - Commission rate string from staking params
|
|
85
|
+
* @returns Processed commission rate string safe for protobuf usage
|
|
86
|
+
*/
|
|
87
|
+
static processCommissionRate(commissionRate: string): string;
|
|
52
88
|
}
|
|
53
89
|
export declare const DefaultTxMisc: {
|
|
54
90
|
memo: string;
|
package/dist/sdk/FirmaUtil.js
CHANGED
|
@@ -456,6 +456,145 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
456
456
|
FirmaUtil.getCommonTxClient = function (aliceWallet) {
|
|
457
457
|
return new CommonTxClient_1.CommonTxClient(aliceWallet, FirmaUtil.config.rpcAddress);
|
|
458
458
|
};
|
|
459
|
+
/**
|
|
460
|
+
* Parses a duration string to a Duration object.
|
|
461
|
+
* Supports formats like "336h0m0s", "21d", "1000ms", "1s", "1m", "1h", "1ns", "1µs"/"1us"
|
|
462
|
+
*
|
|
463
|
+
* @param durationStr - Duration string to parse (e.g., "336h0m0s", "21d")
|
|
464
|
+
* @returns Duration object with seconds and nanos fields
|
|
465
|
+
*/
|
|
466
|
+
FirmaUtil.parseDurationString = function (durationStr) {
|
|
467
|
+
if (!durationStr || durationStr.trim() === "") {
|
|
468
|
+
return { seconds: BigInt(0), nanos: 0 };
|
|
469
|
+
}
|
|
470
|
+
var input = durationStr.trim();
|
|
471
|
+
var totalSeconds = 0;
|
|
472
|
+
var totalNanos = 0;
|
|
473
|
+
// Handle negative durations
|
|
474
|
+
var isNegative = input.startsWith('-');
|
|
475
|
+
var cleanInput = isNegative ? input.substring(1) : input;
|
|
476
|
+
// Regular expression to match duration components
|
|
477
|
+
var regex = /(\d+(?:\.\d+)?)(d|h|m|s|ms|µs|us|ns)/g;
|
|
478
|
+
var match;
|
|
479
|
+
var hasMatches = false;
|
|
480
|
+
while ((match = regex.exec(cleanInput)) !== null) {
|
|
481
|
+
hasMatches = true;
|
|
482
|
+
var value = parseFloat(match[1]);
|
|
483
|
+
var unit = match[2];
|
|
484
|
+
switch (unit) {
|
|
485
|
+
case 'd': // days
|
|
486
|
+
totalSeconds += value * 24 * 60 * 60;
|
|
487
|
+
break;
|
|
488
|
+
case 'h': // hours
|
|
489
|
+
totalSeconds += value * 60 * 60;
|
|
490
|
+
break;
|
|
491
|
+
case 'm': // minutes
|
|
492
|
+
totalSeconds += value * 60;
|
|
493
|
+
break;
|
|
494
|
+
case 's': // seconds
|
|
495
|
+
totalSeconds += value;
|
|
496
|
+
break;
|
|
497
|
+
case 'ms': // milliseconds
|
|
498
|
+
totalNanos += value * 1000000;
|
|
499
|
+
break;
|
|
500
|
+
case 'µs':
|
|
501
|
+
case 'us': // microseconds
|
|
502
|
+
totalNanos += value * 1000;
|
|
503
|
+
break;
|
|
504
|
+
case 'ns': // nanoseconds
|
|
505
|
+
totalNanos += value;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (!hasMatches) {
|
|
510
|
+
throw new Error("Invalid duration format: " + durationStr);
|
|
511
|
+
}
|
|
512
|
+
// Convert excess nanos to seconds
|
|
513
|
+
var extraSeconds = Math.floor(totalNanos / 1000000000);
|
|
514
|
+
totalSeconds += extraSeconds;
|
|
515
|
+
totalNanos = totalNanos % 1000000000;
|
|
516
|
+
// Apply negative sign
|
|
517
|
+
var finalSeconds = isNegative ? -totalSeconds : totalSeconds;
|
|
518
|
+
var finalNanos = isNegative ? -totalNanos : totalNanos;
|
|
519
|
+
return {
|
|
520
|
+
seconds: BigInt(Math.floor(finalSeconds)),
|
|
521
|
+
nanos: Math.floor(finalNanos)
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Creates a Duration object from a duration string.
|
|
526
|
+
* This is a convenience method that combines parseDurationString with Duration.fromPartial.
|
|
527
|
+
*
|
|
528
|
+
* @param durationStr - Duration string to parse (e.g., "336h0m0s", "21d")
|
|
529
|
+
* @returns Duration object ready to use with protobuf
|
|
530
|
+
*/
|
|
531
|
+
FirmaUtil.createDurationFromString = function (durationStr) {
|
|
532
|
+
var _a = FirmaUtil.parseDurationString(durationStr), seconds = _a.seconds, nanos = _a.nanos;
|
|
533
|
+
// Import Duration if not already imported
|
|
534
|
+
var Duration = require("./firmachain/google/protobuf/duration").Duration;
|
|
535
|
+
return Duration.fromPartial({
|
|
536
|
+
seconds: seconds,
|
|
537
|
+
nanos: nanos
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Normalizes decimal string for Cosmos SDK usage.
|
|
542
|
+
* Converts "0.000000000000000000" to empty string to avoid big.Int conversion errors.
|
|
543
|
+
*
|
|
544
|
+
* @param decimalStr - Decimal string that might cause big.Int conversion issues
|
|
545
|
+
* @returns Normalized string safe for Cosmos SDK usage
|
|
546
|
+
*/
|
|
547
|
+
FirmaUtil.normalizeDecimalString = function (decimalStr) {
|
|
548
|
+
if (!decimalStr || decimalStr.trim() === "") {
|
|
549
|
+
return "";
|
|
550
|
+
}
|
|
551
|
+
var trimmed = decimalStr.trim();
|
|
552
|
+
// Check if it's a valid decimal number
|
|
553
|
+
if (!/^-?\d*\.?\d*$/.test(trimmed)) {
|
|
554
|
+
return trimmed; // Return as-is if not a valid decimal
|
|
555
|
+
}
|
|
556
|
+
try {
|
|
557
|
+
var num = parseFloat(trimmed);
|
|
558
|
+
// If the number is 0 or very close to 0, return empty string
|
|
559
|
+
if (num === 0 || Math.abs(num) < 1e-18) {
|
|
560
|
+
return "";
|
|
561
|
+
}
|
|
562
|
+
// For non-zero values, return the original string
|
|
563
|
+
return trimmed;
|
|
564
|
+
}
|
|
565
|
+
catch (error) {
|
|
566
|
+
// If parsing fails, return the original string
|
|
567
|
+
return trimmed;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Safely processes commission rate strings to prevent big.Int conversion errors.
|
|
572
|
+
* This is specifically for handling commission rates that might be "0.000000000000000000".
|
|
573
|
+
*
|
|
574
|
+
* @param commissionRate - Commission rate string from staking params
|
|
575
|
+
* @returns Processed commission rate string safe for protobuf usage
|
|
576
|
+
*/
|
|
577
|
+
FirmaUtil.processCommissionRate = function (commissionRate) {
|
|
578
|
+
if (!commissionRate || commissionRate.trim() === "") {
|
|
579
|
+
return "";
|
|
580
|
+
}
|
|
581
|
+
var normalized = FirmaUtil.normalizeDecimalString(commissionRate);
|
|
582
|
+
// For commission rates, if it's effectively zero, return empty string
|
|
583
|
+
if (normalized === "") {
|
|
584
|
+
return "";
|
|
585
|
+
}
|
|
586
|
+
// Ensure the value is within valid commission rate range (0-1)
|
|
587
|
+
try {
|
|
588
|
+
var rate = parseFloat(normalized);
|
|
589
|
+
if (rate < 0 || rate > 1) {
|
|
590
|
+
throw new Error("Invalid commission rate: " + commissionRate + ". Must be between 0 and 1");
|
|
591
|
+
}
|
|
592
|
+
return normalized;
|
|
593
|
+
}
|
|
594
|
+
catch (error) {
|
|
595
|
+
throw new Error("Invalid commission rate format: " + commissionRate);
|
|
596
|
+
}
|
|
597
|
+
};
|
|
459
598
|
FirmaUtil.FctDecimal = 6;
|
|
460
599
|
return FirmaUtil;
|
|
461
600
|
}());
|
|
@@ -22,6 +22,7 @@ var tx_2 = require("cosmjs-types/cosmos/distribution/v1beta1/tx");
|
|
|
22
22
|
var tx_3 = require("cosmjs-types/cosmos/gov/v1beta1/tx");
|
|
23
23
|
var tx_4 = require("cosmjs-types/cosmos/staking/v1beta1/tx");
|
|
24
24
|
var tx_5 = require("cosmjs-types/cosmwasm/wasm/v1/tx");
|
|
25
|
+
// temporarly using kintsugi-tech/cosmjs-types - this will be returned to original cosmjs-types after the PR is merged
|
|
25
26
|
var tx_6 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx");
|
|
26
27
|
var AuthzTxTypes_1 = require("../authz/AuthzTxTypes");
|
|
27
28
|
var ContractTxTypes_1 = require("../contract/ContractTxTypes");
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isMsgCancelProposalEncodeObject = exports.isMsgVoteWeightedEncodeObject = exports.isMsgVoteEncodeObject = exports.isMsgSubmitProposalEncodeObject = exports.isMsgDepositEncodeObject = exports.govTypes = void 0;
|
|
4
4
|
var tx_1 = require("cosmjs-types/cosmos/gov/v1/tx");
|
|
5
5
|
var tx_2 = require("cosmjs-types/cosmos/gov/v1beta1/tx");
|
|
6
|
+
// temporarly using kintsugi-tech/cosmjs-types - this will be returned to original cosmjs-types after the PR is merged
|
|
6
7
|
var tx_3 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx");
|
|
7
8
|
exports.govTypes = [
|
|
8
9
|
["/cosmos.gov.v1.MsgDeposit", tx_1.MsgDeposit],
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Proposal } from "@kintsugi-tech/cosmjs-types/cosmos/gov/v1/gov";
|
|
2
|
+
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
1
3
|
export declare enum ProposalStatus {
|
|
2
4
|
PROPOSAL_STATUS_UNSPECIFIED = 0,
|
|
3
5
|
PROPOSAL_STATUS_DEPOSIT_PERIOD = 1,
|
|
@@ -6,20 +8,23 @@ export declare enum ProposalStatus {
|
|
|
6
8
|
PROPOSAL_STATUS_REJECTED = 4,
|
|
7
9
|
PROPOSAL_STATUS_FAILED = 5
|
|
8
10
|
}
|
|
9
|
-
export interface
|
|
11
|
+
export interface GovParamType {
|
|
12
|
+
min_deposit: Coin[];
|
|
13
|
+
max_deposit_period: string;
|
|
10
14
|
voting_period: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
quorum: string;
|
|
16
|
+
threshold: string;
|
|
17
|
+
veto_threshold: string;
|
|
18
|
+
min_initial_deposit_ratio: string;
|
|
19
|
+
proposal_cancel_ratio: string;
|
|
20
|
+
proposal_cancel_dest: string;
|
|
21
|
+
expedited_voting_period: string;
|
|
22
|
+
expedited_threshold: string;
|
|
23
|
+
expedited_min_deposit: Coin[];
|
|
24
|
+
burn_vote_quorum: boolean;
|
|
25
|
+
burn_proposal_deposit_prevote: boolean;
|
|
26
|
+
burn_vote_veto: boolean;
|
|
27
|
+
min_deposit_ratio: string;
|
|
23
28
|
}
|
|
24
29
|
export interface CurrentVoteInfo {
|
|
25
30
|
yes: string;
|
|
@@ -27,35 +32,15 @@ export interface CurrentVoteInfo {
|
|
|
27
32
|
no: string;
|
|
28
33
|
no_with_veto: string;
|
|
29
34
|
}
|
|
30
|
-
export interface ProposalInfo {
|
|
31
|
-
proposal_id: string;
|
|
32
|
-
content: {
|
|
33
|
-
"@type": string;
|
|
34
|
-
title: string;
|
|
35
|
-
description: string;
|
|
36
|
-
};
|
|
37
|
-
status: string;
|
|
38
|
-
final_tally_result: {
|
|
39
|
-
yes: string;
|
|
40
|
-
abstain: string;
|
|
41
|
-
no: string;
|
|
42
|
-
no_with_veto: string;
|
|
43
|
-
};
|
|
44
|
-
submit_time: string;
|
|
45
|
-
deposit_end_time: string;
|
|
46
|
-
total_deposit: {
|
|
47
|
-
denom: string;
|
|
48
|
-
amount: string;
|
|
49
|
-
}[];
|
|
50
|
-
voting_start_time: string;
|
|
51
|
-
voting_end_time: string;
|
|
52
|
-
}
|
|
53
35
|
export declare class GovQueryClient {
|
|
54
36
|
private readonly axios;
|
|
55
37
|
constructor(baseUrl: string);
|
|
56
38
|
queryGetCurrentVoteInfo(id: string): Promise<CurrentVoteInfo>;
|
|
57
|
-
queryGetParam(): Promise<
|
|
58
|
-
queryGetProposal(id: string): Promise<
|
|
59
|
-
queryGetProposalListByStatus(status: ProposalStatus): Promise<
|
|
60
|
-
queryGetProposalList(
|
|
39
|
+
queryGetParam(): Promise<GovParamType>;
|
|
40
|
+
queryGetProposal(id: string): Promise<Proposal>;
|
|
41
|
+
queryGetProposalListByStatus(status: ProposalStatus): Promise<Proposal[]>;
|
|
42
|
+
queryGetProposalList(pagination?: {
|
|
43
|
+
limit?: number;
|
|
44
|
+
key?: string;
|
|
45
|
+
}): Promise<Proposal[]>;
|
|
61
46
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -77,27 +88,15 @@ var GovQueryClient = /** @class */ (function () {
|
|
|
77
88
|
};
|
|
78
89
|
GovQueryClient.prototype.queryGetParam = function () {
|
|
79
90
|
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
var path,
|
|
91
|
+
var path, result;
|
|
81
92
|
return __generator(this, function (_a) {
|
|
82
93
|
switch (_a.label) {
|
|
83
94
|
case 0:
|
|
84
|
-
path = "/cosmos/gov/
|
|
95
|
+
path = "/cosmos/gov/v1/params/deposit";
|
|
85
96
|
return [4 /*yield*/, this.axios.get(path)];
|
|
86
97
|
case 1:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return [4 /*yield*/, this.axios.get(path)];
|
|
90
|
-
case 2:
|
|
91
|
-
depositResult = _a.sent();
|
|
92
|
-
path = "/cosmos/gov/v1beta1/params/tallying";
|
|
93
|
-
return [4 /*yield*/, this.axios.get(path)];
|
|
94
|
-
case 3:
|
|
95
|
-
tallyingResult = _a.sent();
|
|
96
|
-
return [2 /*return*/, {
|
|
97
|
-
voting_period: votingResult.data.voting_params.voting_period,
|
|
98
|
-
deposit_params: depositResult.data.deposit_params,
|
|
99
|
-
tally_params: tallyingResult.data.tally_params
|
|
100
|
-
}];
|
|
98
|
+
result = _a.sent();
|
|
99
|
+
return [2 /*return*/, result.data.params];
|
|
101
100
|
}
|
|
102
101
|
});
|
|
103
102
|
});
|
|
@@ -108,7 +107,7 @@ var GovQueryClient = /** @class */ (function () {
|
|
|
108
107
|
return __generator(this, function (_a) {
|
|
109
108
|
switch (_a.label) {
|
|
110
109
|
case 0:
|
|
111
|
-
path = "/cosmos/gov/
|
|
110
|
+
path = "/cosmos/gov/v1/proposals/" + id;
|
|
112
111
|
return [4 /*yield*/, this.axios.get(path)];
|
|
113
112
|
case 1:
|
|
114
113
|
result = _a.sent();
|
|
@@ -123,7 +122,7 @@ var GovQueryClient = /** @class */ (function () {
|
|
|
123
122
|
return __generator(this, function (_a) {
|
|
124
123
|
switch (_a.label) {
|
|
125
124
|
case 0:
|
|
126
|
-
path = "/cosmos/gov/
|
|
125
|
+
path = "/cosmos/gov/v1/proposals";
|
|
127
126
|
return [4 /*yield*/, this.axios.get(path, { params: { proposalStatus: status } })];
|
|
128
127
|
case 1:
|
|
129
128
|
result = _a.sent();
|
|
@@ -132,14 +131,14 @@ var GovQueryClient = /** @class */ (function () {
|
|
|
132
131
|
});
|
|
133
132
|
});
|
|
134
133
|
};
|
|
135
|
-
GovQueryClient.prototype.queryGetProposalList = function () {
|
|
134
|
+
GovQueryClient.prototype.queryGetProposalList = function (pagination) {
|
|
136
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
136
|
var path, result;
|
|
138
137
|
return __generator(this, function (_a) {
|
|
139
138
|
switch (_a.label) {
|
|
140
139
|
case 0:
|
|
141
|
-
path = "/cosmos/gov/
|
|
142
|
-
return [4 /*yield*/, this.axios.get(path)];
|
|
140
|
+
path = "/cosmos/gov/v1/proposals";
|
|
141
|
+
return [4 /*yield*/, this.axios.get(path, { params: __assign({}, pagination) })];
|
|
143
142
|
case 1:
|
|
144
143
|
result = _a.sent();
|
|
145
144
|
return [2 /*return*/, result.data.proposals];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Registry, EncodeObject } from "@cosmjs/proto-signing";
|
|
2
2
|
import { MsgDeposit, MsgSubmitProposal, MsgVote } from "cosmjs-types/cosmos/gov/v1beta1/tx";
|
|
3
|
+
import { MsgSubmitProposal as MsgSubmitGenericProposal } from "cosmjs-types/cosmos/gov/v1/tx";
|
|
3
4
|
import { MsgCancelProposal } from "@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx";
|
|
4
5
|
import { FirmaWalletService } from "../../FirmaWalletService";
|
|
5
6
|
import { ITxClient } from "../common/ITxClient";
|
|
@@ -11,6 +12,10 @@ export interface MsgSubmitProposalEncodeObject extends EncodeObject {
|
|
|
11
12
|
readonly typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal";
|
|
12
13
|
readonly value: Partial<MsgSubmitProposal>;
|
|
13
14
|
}
|
|
15
|
+
export interface MsgSubmitGenericProposalEncodeObject extends EncodeObject {
|
|
16
|
+
readonly typeUrl: "/cosmos.gov.v1.MsgSubmitProposal";
|
|
17
|
+
readonly value: Partial<MsgSubmitGenericProposal>;
|
|
18
|
+
}
|
|
14
19
|
export interface MsgVoteEncodeObject extends EncodeObject {
|
|
15
20
|
readonly typeUrl: "/cosmos.gov.v1beta1.MsgVote";
|
|
16
21
|
readonly value: Partial<MsgVote>;
|
|
@@ -24,6 +29,7 @@ export declare class GovTxClient extends ITxClient {
|
|
|
24
29
|
static getRegistry(): Registry;
|
|
25
30
|
static msgDeposit(data: MsgDeposit): MsgDepositEncodeObject;
|
|
26
31
|
static msgSubmitProposal(data: MsgSubmitProposal): MsgSubmitProposalEncodeObject;
|
|
32
|
+
static msgSubmitGenericProposal(data: MsgSubmitGenericProposal): MsgSubmitGenericProposalEncodeObject;
|
|
27
33
|
static msgVote(data: MsgVote): MsgVoteEncodeObject;
|
|
28
34
|
static msgCancelProposal(data: MsgCancelProposal): MsgCancelProposalEncodeObject;
|
|
29
35
|
}
|
|
@@ -18,13 +18,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.GovTxClient = void 0;
|
|
19
19
|
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
20
20
|
var tx_1 = require("cosmjs-types/cosmos/gov/v1beta1/tx");
|
|
21
|
-
var tx_2 = require("
|
|
21
|
+
var tx_2 = require("cosmjs-types/cosmos/gov/v1/tx");
|
|
22
|
+
// temporarly using kintsugi-tech/cosmjs-types - this will be returned to original cosmjs-types after the PR is merged
|
|
23
|
+
var tx_3 = require("@kintsugi-tech/cosmjs-types/cosmos/gov/v1/tx");
|
|
22
24
|
var ITxClient_1 = require("../common/ITxClient");
|
|
23
25
|
var types = [
|
|
24
26
|
["/cosmos.gov.v1beta1.MsgDeposit", tx_1.MsgDeposit],
|
|
25
27
|
["/cosmos.gov.v1beta1.MsgSubmitProposal", tx_1.MsgSubmitProposal],
|
|
28
|
+
["/cosmos.gov.v1.MsgSubmitProposal", tx_2.MsgSubmitProposal],
|
|
26
29
|
["/cosmos.gov.v1beta1.MsgVote", tx_1.MsgVote],
|
|
27
|
-
["/cosmos.gov.v1.MsgCancelProposal",
|
|
30
|
+
["/cosmos.gov.v1.MsgCancelProposal", tx_3.MsgCancelProposal],
|
|
28
31
|
];
|
|
29
32
|
var registry = new proto_signing_1.Registry(types);
|
|
30
33
|
var GovTxClient = /** @class */ (function (_super) {
|
|
@@ -41,6 +44,9 @@ var GovTxClient = /** @class */ (function (_super) {
|
|
|
41
44
|
GovTxClient.msgSubmitProposal = function (data) {
|
|
42
45
|
return { typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", value: data };
|
|
43
46
|
};
|
|
47
|
+
GovTxClient.msgSubmitGenericProposal = function (data) {
|
|
48
|
+
return { typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", value: data };
|
|
49
|
+
};
|
|
44
50
|
GovTxClient.msgVote = function (data) {
|
|
45
51
|
return { typeUrl: "/cosmos.gov.v1beta1.MsgVote", value: data };
|
|
46
52
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Pagination } from "../common";
|
|
2
|
-
export interface
|
|
2
|
+
export interface StakingParamType {
|
|
3
3
|
unbonding_time: string;
|
|
4
4
|
max_validators: number;
|
|
5
5
|
max_entries: number;
|
|
6
6
|
historical_entries: number;
|
|
7
7
|
bond_denom: string;
|
|
8
|
+
min_commission_rate: string;
|
|
8
9
|
}
|
|
9
10
|
export interface PoolDataType {
|
|
10
11
|
not_bonded_tokens: string;
|
|
@@ -96,7 +97,7 @@ export declare class StakingQueryClient {
|
|
|
96
97
|
dataList: DelegationInfo[];
|
|
97
98
|
pagination: Pagination;
|
|
98
99
|
}>;
|
|
99
|
-
queryGetParams(): Promise<
|
|
100
|
+
queryGetParams(): Promise<StakingParamType>;
|
|
100
101
|
queryGetPool(): Promise<PoolDataType>;
|
|
101
102
|
queryValidator(valoperAddress: string): Promise<ValidatorDataType>;
|
|
102
103
|
queryValidators(status: string, paginationKey?: string): Promise<{
|