@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
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import { TxMisc, TotalRewardInfo } from
|
|
1
|
+
import { TxMisc, TotalRewardInfo } from "./firmachain/distribution";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
|
-
import { BroadcastTxResponse } from
|
|
5
|
-
import { Coin } from
|
|
4
|
+
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
5
|
+
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
6
6
|
export declare class FirmaDistributionService {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
7
|
+
private readonly config;
|
|
8
|
+
constructor(config: FirmaConfig);
|
|
9
|
+
getGasEstimationSetWithdrawAddress(wallet: FirmaWalletService, withdrawAddress: string, txMisc?: TxMisc): Promise<number>;
|
|
10
|
+
getGasEstimationFundCommunityPool(wallet: FirmaWalletService, amount: number, txMisc?: TxMisc): Promise<number>;
|
|
11
|
+
getGasEstimationWithdrawValidatorCommission(wallet: FirmaWalletService, validatorAddress: string, txMisc?: TxMisc): Promise<number>;
|
|
12
|
+
getGasEstimationWithdrawAllRewards(wallet: FirmaWalletService, validatorAddress: string, txMisc?: TxMisc): Promise<number>;
|
|
10
13
|
private getSignedTxWithdrawAllRewards;
|
|
11
14
|
private getSignedTxSetWithdrawAddress;
|
|
12
15
|
private getSignedTxFundCommunityPool;
|
|
13
16
|
private getSignedTxWithdrawValidatorCommission;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
setWithdrawAddress(wallet: FirmaWalletService, withdrawAddress: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
18
|
+
fundCommunityPool(wallet: FirmaWalletService, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
19
|
+
withdrawValidatorCommission(wallet: FirmaWalletService, validatorAddres: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
17
20
|
withdrawAllRewards(wallet: FirmaWalletService, validatorAddress: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
18
21
|
getRewardInfo(address: string, validatorAddress: string): Promise<string>;
|
|
19
22
|
getValidatorOutStandingReward(validatorAddress: string): Promise<Coin[]>;
|
|
20
23
|
getValidatorCommission(validatorAddress: string): Promise<Coin[]>;
|
|
21
24
|
getTotalRewardInfo(address: string): Promise<TotalRewardInfo>;
|
|
22
25
|
getCommunityPool(): Promise<string>;
|
|
26
|
+
getWithdrawAddress(address: string): Promise<string>;
|
|
23
27
|
}
|
|
@@ -40,10 +40,10 @@ exports.FirmaDistributionService = void 0;
|
|
|
40
40
|
var distribution_1 = require("./firmachain/distribution");
|
|
41
41
|
var FirmaUtil_1 = require("./FirmaUtil");
|
|
42
42
|
var FirmaDistributionService = /** @class */ (function () {
|
|
43
|
-
function FirmaDistributionService(
|
|
44
|
-
this.
|
|
43
|
+
function FirmaDistributionService(config) {
|
|
44
|
+
this.config = config;
|
|
45
45
|
}
|
|
46
|
-
FirmaDistributionService.prototype.
|
|
46
|
+
FirmaDistributionService.prototype.getGasEstimationSetWithdrawAddress = function (wallet, withdrawAddress, txMisc) {
|
|
47
47
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
48
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
49
|
var txRaw, error_1;
|
|
@@ -51,7 +51,7 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
51
51
|
switch (_a.label) {
|
|
52
52
|
case 0:
|
|
53
53
|
_a.trys.push([0, 3, , 4]);
|
|
54
|
-
return [4 /*yield*/, this.
|
|
54
|
+
return [4 /*yield*/, this.getSignedTxSetWithdrawAddress(wallet, withdrawAddress, txMisc)];
|
|
55
55
|
case 1:
|
|
56
56
|
txRaw = _a.sent();
|
|
57
57
|
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
@@ -65,20 +65,18 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
|
-
FirmaDistributionService.prototype.
|
|
68
|
+
FirmaDistributionService.prototype.getGasEstimationFundCommunityPool = function (wallet, amount, txMisc) {
|
|
69
69
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
70
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var
|
|
71
|
+
var txRaw, error_2;
|
|
72
72
|
return __generator(this, function (_a) {
|
|
73
73
|
switch (_a.label) {
|
|
74
74
|
case 0:
|
|
75
75
|
_a.trys.push([0, 3, , 4]);
|
|
76
|
-
|
|
77
|
-
return [4 /*yield*/, wallet.getAddress()];
|
|
76
|
+
return [4 /*yield*/, this.getSignedTxFundCommunityPool(wallet, amount, txMisc)];
|
|
78
77
|
case 1:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
|
|
78
|
+
txRaw = _a.sent();
|
|
79
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
82
80
|
case 2: return [2 /*return*/, _a.sent()];
|
|
83
81
|
case 3:
|
|
84
82
|
error_2 = _a.sent();
|
|
@@ -89,20 +87,18 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
89
87
|
});
|
|
90
88
|
});
|
|
91
89
|
};
|
|
92
|
-
FirmaDistributionService.prototype.
|
|
90
|
+
FirmaDistributionService.prototype.getGasEstimationWithdrawValidatorCommission = function (wallet, validatorAddress, txMisc) {
|
|
93
91
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
94
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
var
|
|
93
|
+
var txRaw, error_3;
|
|
96
94
|
return __generator(this, function (_a) {
|
|
97
95
|
switch (_a.label) {
|
|
98
96
|
case 0:
|
|
99
97
|
_a.trys.push([0, 3, , 4]);
|
|
100
|
-
|
|
101
|
-
return [4 /*yield*/, wallet.getAddress()];
|
|
98
|
+
return [4 /*yield*/, this.getSignedTxWithdrawValidatorCommission(wallet, validatorAddress, txMisc)];
|
|
102
99
|
case 1:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
|
|
100
|
+
txRaw = _a.sent();
|
|
101
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
106
102
|
case 2: return [2 /*return*/, _a.sent()];
|
|
107
103
|
case 3:
|
|
108
104
|
error_3 = _a.sent();
|
|
@@ -113,21 +109,18 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
113
109
|
});
|
|
114
110
|
});
|
|
115
111
|
};
|
|
116
|
-
FirmaDistributionService.prototype.
|
|
112
|
+
FirmaDistributionService.prototype.getGasEstimationWithdrawAllRewards = function (wallet, validatorAddress, txMisc) {
|
|
117
113
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
118
114
|
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
-
var
|
|
115
|
+
var txRaw, error_4;
|
|
120
116
|
return __generator(this, function (_a) {
|
|
121
117
|
switch (_a.label) {
|
|
122
118
|
case 0:
|
|
123
119
|
_a.trys.push([0, 3, , 4]);
|
|
124
|
-
|
|
125
|
-
return [4 /*yield*/, wallet.getAddress()];
|
|
120
|
+
return [4 /*yield*/, this.getSignedTxWithdrawAllRewards(wallet, validatorAddress, txMisc)];
|
|
126
121
|
case 1:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
message = txClient.msgFundCommunityPool({ depositor: address, amount: [sendAmount] });
|
|
130
|
-
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
|
|
122
|
+
txRaw = _a.sent();
|
|
123
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
131
124
|
case 2: return [2 /*return*/, _a.sent()];
|
|
132
125
|
case 3:
|
|
133
126
|
error_4 = _a.sent();
|
|
@@ -138,7 +131,7 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
138
131
|
});
|
|
139
132
|
});
|
|
140
133
|
};
|
|
141
|
-
FirmaDistributionService.prototype.
|
|
134
|
+
FirmaDistributionService.prototype.getSignedTxWithdrawAllRewards = function (wallet, validatorAddress, txMisc) {
|
|
142
135
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
143
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
144
137
|
var txClient, address, message, error_5;
|
|
@@ -146,12 +139,12 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
146
139
|
switch (_a.label) {
|
|
147
140
|
case 0:
|
|
148
141
|
_a.trys.push([0, 3, , 4]);
|
|
149
|
-
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.
|
|
142
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
150
143
|
return [4 /*yield*/, wallet.getAddress()];
|
|
151
144
|
case 1:
|
|
152
145
|
address = _a.sent();
|
|
153
|
-
message = txClient.
|
|
154
|
-
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this.
|
|
146
|
+
message = txClient.msgWithdrawDelegatorReward({ delegatorAddress: address, validatorAddress: validatorAddress });
|
|
147
|
+
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
155
148
|
case 2: return [2 /*return*/, _a.sent()];
|
|
156
149
|
case 3:
|
|
157
150
|
error_5 = _a.sent();
|
|
@@ -162,19 +155,20 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
162
155
|
});
|
|
163
156
|
});
|
|
164
157
|
};
|
|
165
|
-
FirmaDistributionService.prototype.
|
|
158
|
+
FirmaDistributionService.prototype.getSignedTxSetWithdrawAddress = function (wallet, withdrawAddress, txMisc) {
|
|
166
159
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
167
160
|
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
-
var
|
|
161
|
+
var txClient, address, message, error_6;
|
|
169
162
|
return __generator(this, function (_a) {
|
|
170
163
|
switch (_a.label) {
|
|
171
164
|
case 0:
|
|
172
165
|
_a.trys.push([0, 3, , 4]);
|
|
173
|
-
|
|
166
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
167
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
174
168
|
case 1:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return [4 /*yield*/, txClient.
|
|
169
|
+
address = _a.sent();
|
|
170
|
+
message = txClient.msgSetWithdrawAddress({ delegatorAddress: address, withdrawAddress: withdrawAddress });
|
|
171
|
+
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
178
172
|
case 2: return [2 /*return*/, _a.sent()];
|
|
179
173
|
case 3:
|
|
180
174
|
error_6 = _a.sent();
|
|
@@ -185,19 +179,21 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
185
179
|
});
|
|
186
180
|
});
|
|
187
181
|
};
|
|
188
|
-
FirmaDistributionService.prototype.
|
|
182
|
+
FirmaDistributionService.prototype.getSignedTxFundCommunityPool = function (wallet, amount, txMisc) {
|
|
189
183
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
190
184
|
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
-
var
|
|
185
|
+
var txClient, address, sendAmount, message, error_7;
|
|
192
186
|
return __generator(this, function (_a) {
|
|
193
187
|
switch (_a.label) {
|
|
194
188
|
case 0:
|
|
195
189
|
_a.trys.push([0, 3, , 4]);
|
|
196
|
-
|
|
190
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
191
|
+
return [4 /*yield*/, wallet.getAddress()];
|
|
197
192
|
case 1:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
193
|
+
address = _a.sent();
|
|
194
|
+
sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
|
|
195
|
+
message = txClient.msgFundCommunityPool({ depositor: address, amount: [sendAmount] });
|
|
196
|
+
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
201
197
|
case 2: return [2 /*return*/, _a.sent()];
|
|
202
198
|
case 3:
|
|
203
199
|
error_7 = _a.sent();
|
|
@@ -208,10 +204,77 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
208
204
|
});
|
|
209
205
|
});
|
|
210
206
|
};
|
|
211
|
-
FirmaDistributionService.prototype.
|
|
207
|
+
FirmaDistributionService.prototype.getSignedTxWithdrawValidatorCommission = function (wallet, validatorAddres, txMisc) {
|
|
212
208
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
213
209
|
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
-
var
|
|
210
|
+
var txClient, message, error_8;
|
|
211
|
+
return __generator(this, function (_a) {
|
|
212
|
+
switch (_a.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
_a.trys.push([0, 2, , 3]);
|
|
215
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
216
|
+
message = txClient.msgWithdrawValidatorCommission({ validatorAddress: validatorAddres });
|
|
217
|
+
return [4 /*yield*/, txClient.sign([message], distribution_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
218
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
219
|
+
case 2:
|
|
220
|
+
error_8 = _a.sent();
|
|
221
|
+
FirmaUtil_1.FirmaUtil.printLog(error_8);
|
|
222
|
+
throw error_8;
|
|
223
|
+
case 3: return [2 /*return*/];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
FirmaDistributionService.prototype.setWithdrawAddress = function (wallet, withdrawAddress, txMisc) {
|
|
229
|
+
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
230
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
+
var txRaw, txClient, error_9;
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
switch (_a.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
_a.trys.push([0, 3, , 4]);
|
|
236
|
+
return [4 /*yield*/, this.getSignedTxSetWithdrawAddress(wallet, withdrawAddress, txMisc)];
|
|
237
|
+
case 1:
|
|
238
|
+
txRaw = _a.sent();
|
|
239
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
240
|
+
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
241
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
242
|
+
case 3:
|
|
243
|
+
error_9 = _a.sent();
|
|
244
|
+
FirmaUtil_1.FirmaUtil.printLog(error_9);
|
|
245
|
+
throw error_9;
|
|
246
|
+
case 4: return [2 /*return*/];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
FirmaDistributionService.prototype.fundCommunityPool = function (wallet, amount, txMisc) {
|
|
252
|
+
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
253
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
254
|
+
var txRaw, txClient, error_10;
|
|
255
|
+
return __generator(this, function (_a) {
|
|
256
|
+
switch (_a.label) {
|
|
257
|
+
case 0:
|
|
258
|
+
_a.trys.push([0, 3, , 4]);
|
|
259
|
+
return [4 /*yield*/, this.getSignedTxFundCommunityPool(wallet, amount, txMisc)];
|
|
260
|
+
case 1:
|
|
261
|
+
txRaw = _a.sent();
|
|
262
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
263
|
+
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
264
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
265
|
+
case 3:
|
|
266
|
+
error_10 = _a.sent();
|
|
267
|
+
FirmaUtil_1.FirmaUtil.printLog(error_10);
|
|
268
|
+
throw error_10;
|
|
269
|
+
case 4: return [2 /*return*/];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
FirmaDistributionService.prototype.withdrawValidatorCommission = function (wallet, validatorAddres, txMisc) {
|
|
275
|
+
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var txRaw, txClient, error_11;
|
|
215
278
|
return __generator(this, function (_a) {
|
|
216
279
|
switch (_a.label) {
|
|
217
280
|
case 0:
|
|
@@ -219,13 +282,13 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
219
282
|
return [4 /*yield*/, this.getSignedTxWithdrawValidatorCommission(wallet, validatorAddres, txMisc)];
|
|
220
283
|
case 1:
|
|
221
284
|
txRaw = _a.sent();
|
|
222
|
-
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.
|
|
285
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
223
286
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
224
287
|
case 2: return [2 /*return*/, _a.sent()];
|
|
225
288
|
case 3:
|
|
226
|
-
|
|
227
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
228
|
-
throw
|
|
289
|
+
error_11 = _a.sent();
|
|
290
|
+
FirmaUtil_1.FirmaUtil.printLog(error_11);
|
|
291
|
+
throw error_11;
|
|
229
292
|
case 4: return [2 /*return*/];
|
|
230
293
|
}
|
|
231
294
|
});
|
|
@@ -234,7 +297,7 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
234
297
|
FirmaDistributionService.prototype.withdrawAllRewards = function (wallet, validatorAddress, txMisc) {
|
|
235
298
|
if (txMisc === void 0) { txMisc = distribution_1.DefaultTxMisc; }
|
|
236
299
|
return __awaiter(this, void 0, void 0, function () {
|
|
237
|
-
var txRaw, txClient,
|
|
300
|
+
var txRaw, txClient, error_12;
|
|
238
301
|
return __generator(this, function (_a) {
|
|
239
302
|
switch (_a.label) {
|
|
240
303
|
case 0:
|
|
@@ -242,13 +305,13 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
242
305
|
return [4 /*yield*/, this.getSignedTxWithdrawAllRewards(wallet, validatorAddress, txMisc)];
|
|
243
306
|
case 1:
|
|
244
307
|
txRaw = _a.sent();
|
|
245
|
-
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.
|
|
308
|
+
txClient = new distribution_1.DistributionTxClient(wallet.getRawWallet(), this.config.rpcAddress);
|
|
246
309
|
return [4 /*yield*/, txClient.broadcast(txRaw)];
|
|
247
310
|
case 2: return [2 /*return*/, _a.sent()];
|
|
248
311
|
case 3:
|
|
249
|
-
|
|
250
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
251
|
-
throw
|
|
312
|
+
error_12 = _a.sent();
|
|
313
|
+
FirmaUtil_1.FirmaUtil.printLog(error_12);
|
|
314
|
+
throw error_12;
|
|
252
315
|
case 4: return [2 /*return*/];
|
|
253
316
|
}
|
|
254
317
|
});
|
|
@@ -258,20 +321,20 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
258
321
|
//
|
|
259
322
|
FirmaDistributionService.prototype.getRewardInfo = function (address, validatorAddress) {
|
|
260
323
|
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
-
var queryClient, result,
|
|
324
|
+
var queryClient, result, error_13;
|
|
262
325
|
return __generator(this, function (_a) {
|
|
263
326
|
switch (_a.label) {
|
|
264
327
|
case 0:
|
|
265
328
|
_a.trys.push([0, 2, , 3]);
|
|
266
|
-
queryClient = new distribution_1.DistributionQueryClient(this.
|
|
329
|
+
queryClient = new distribution_1.DistributionQueryClient(this.config.restApiAddress);
|
|
267
330
|
return [4 /*yield*/, queryClient.queryGetRewardInfo(address, validatorAddress)];
|
|
268
331
|
case 1:
|
|
269
332
|
result = _a.sent();
|
|
270
333
|
return [2 /*return*/, result];
|
|
271
334
|
case 2:
|
|
272
|
-
|
|
273
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
274
|
-
throw
|
|
335
|
+
error_13 = _a.sent();
|
|
336
|
+
FirmaUtil_1.FirmaUtil.printLog(error_13);
|
|
337
|
+
throw error_13;
|
|
275
338
|
case 3: return [2 /*return*/];
|
|
276
339
|
}
|
|
277
340
|
});
|
|
@@ -279,20 +342,20 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
279
342
|
};
|
|
280
343
|
FirmaDistributionService.prototype.getValidatorOutStandingReward = function (validatorAddress) {
|
|
281
344
|
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
-
var queryClient, result,
|
|
345
|
+
var queryClient, result, error_14;
|
|
283
346
|
return __generator(this, function (_a) {
|
|
284
347
|
switch (_a.label) {
|
|
285
348
|
case 0:
|
|
286
349
|
_a.trys.push([0, 2, , 3]);
|
|
287
|
-
queryClient = new distribution_1.DistributionQueryClient(this.
|
|
350
|
+
queryClient = new distribution_1.DistributionQueryClient(this.config.restApiAddress);
|
|
288
351
|
return [4 /*yield*/, queryClient.queryGetValidatorOutStandingReward(validatorAddress)];
|
|
289
352
|
case 1:
|
|
290
353
|
result = _a.sent();
|
|
291
354
|
return [2 /*return*/, result];
|
|
292
355
|
case 2:
|
|
293
|
-
|
|
294
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
295
|
-
throw
|
|
356
|
+
error_14 = _a.sent();
|
|
357
|
+
FirmaUtil_1.FirmaUtil.printLog(error_14);
|
|
358
|
+
throw error_14;
|
|
296
359
|
case 3: return [2 /*return*/];
|
|
297
360
|
}
|
|
298
361
|
});
|
|
@@ -300,20 +363,20 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
300
363
|
};
|
|
301
364
|
FirmaDistributionService.prototype.getValidatorCommission = function (validatorAddress) {
|
|
302
365
|
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
-
var queryClient, result,
|
|
366
|
+
var queryClient, result, error_15;
|
|
304
367
|
return __generator(this, function (_a) {
|
|
305
368
|
switch (_a.label) {
|
|
306
369
|
case 0:
|
|
307
370
|
_a.trys.push([0, 2, , 3]);
|
|
308
|
-
queryClient = new distribution_1.DistributionQueryClient(this.
|
|
371
|
+
queryClient = new distribution_1.DistributionQueryClient(this.config.restApiAddress);
|
|
309
372
|
return [4 /*yield*/, queryClient.queryGetValidatorCommission(validatorAddress)];
|
|
310
373
|
case 1:
|
|
311
374
|
result = _a.sent();
|
|
312
375
|
return [2 /*return*/, result];
|
|
313
376
|
case 2:
|
|
314
|
-
|
|
315
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
316
|
-
throw
|
|
377
|
+
error_15 = _a.sent();
|
|
378
|
+
FirmaUtil_1.FirmaUtil.printLog(error_15);
|
|
379
|
+
throw error_15;
|
|
317
380
|
case 3: return [2 /*return*/];
|
|
318
381
|
}
|
|
319
382
|
});
|
|
@@ -321,20 +384,20 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
321
384
|
};
|
|
322
385
|
FirmaDistributionService.prototype.getTotalRewardInfo = function (address) {
|
|
323
386
|
return __awaiter(this, void 0, void 0, function () {
|
|
324
|
-
var queryClient, result,
|
|
387
|
+
var queryClient, result, error_16;
|
|
325
388
|
return __generator(this, function (_a) {
|
|
326
389
|
switch (_a.label) {
|
|
327
390
|
case 0:
|
|
328
391
|
_a.trys.push([0, 2, , 3]);
|
|
329
|
-
queryClient = new distribution_1.DistributionQueryClient(this.
|
|
392
|
+
queryClient = new distribution_1.DistributionQueryClient(this.config.restApiAddress);
|
|
330
393
|
return [4 /*yield*/, queryClient.queryGetTotalRewardInfo(address)];
|
|
331
394
|
case 1:
|
|
332
395
|
result = _a.sent();
|
|
333
396
|
return [2 /*return*/, result];
|
|
334
397
|
case 2:
|
|
335
|
-
|
|
336
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
337
|
-
throw
|
|
398
|
+
error_16 = _a.sent();
|
|
399
|
+
FirmaUtil_1.FirmaUtil.printLog(error_16);
|
|
400
|
+
throw error_16;
|
|
338
401
|
case 3: return [2 /*return*/];
|
|
339
402
|
}
|
|
340
403
|
});
|
|
@@ -342,20 +405,41 @@ var FirmaDistributionService = /** @class */ (function () {
|
|
|
342
405
|
};
|
|
343
406
|
FirmaDistributionService.prototype.getCommunityPool = function () {
|
|
344
407
|
return __awaiter(this, void 0, void 0, function () {
|
|
345
|
-
var queryClient, result,
|
|
408
|
+
var queryClient, result, error_17;
|
|
346
409
|
return __generator(this, function (_a) {
|
|
347
410
|
switch (_a.label) {
|
|
348
411
|
case 0:
|
|
349
412
|
_a.trys.push([0, 2, , 3]);
|
|
350
|
-
queryClient = new distribution_1.DistributionQueryClient(this.
|
|
413
|
+
queryClient = new distribution_1.DistributionQueryClient(this.config.restApiAddress);
|
|
351
414
|
return [4 /*yield*/, queryClient.queryGetCommunityPool()];
|
|
352
415
|
case 1:
|
|
353
416
|
result = _a.sent();
|
|
354
417
|
return [2 /*return*/, result];
|
|
355
418
|
case 2:
|
|
356
|
-
|
|
357
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
358
|
-
throw
|
|
419
|
+
error_17 = _a.sent();
|
|
420
|
+
FirmaUtil_1.FirmaUtil.printLog(error_17);
|
|
421
|
+
throw error_17;
|
|
422
|
+
case 3: return [2 /*return*/];
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
FirmaDistributionService.prototype.getWithdrawAddress = function (address) {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
429
|
+
var queryClient, result, error_18;
|
|
430
|
+
return __generator(this, function (_a) {
|
|
431
|
+
switch (_a.label) {
|
|
432
|
+
case 0:
|
|
433
|
+
_a.trys.push([0, 2, , 3]);
|
|
434
|
+
queryClient = new distribution_1.DistributionQueryClient(this.config.restApiAddress);
|
|
435
|
+
return [4 /*yield*/, queryClient.queryGetWithdrawAddress(address)];
|
|
436
|
+
case 1:
|
|
437
|
+
result = _a.sent();
|
|
438
|
+
return [2 /*return*/, result];
|
|
439
|
+
case 2:
|
|
440
|
+
error_18 = _a.sent();
|
|
441
|
+
FirmaUtil_1.FirmaUtil.printLog(error_18);
|
|
442
|
+
throw error_18;
|
|
359
443
|
case 3: return [2 /*return*/];
|
|
360
444
|
}
|
|
361
445
|
});
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { TxMisc, BasicFeeGrantOption, PeriodicFeeGrantOption } from
|
|
1
|
+
import { TxMisc, BasicFeeGrantOption, PeriodicFeeGrantOption } from "./firmachain/feegrant";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
|
-
import { FeeAllowanceType, FeeAllowanceType1 } from
|
|
5
|
-
import { BroadcastTxResponse } from
|
|
4
|
+
import { FeeAllowanceType, FeeAllowanceType1 } from "./firmachain/feegrant/FeeGrantQueryClient";
|
|
5
|
+
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
6
6
|
export declare class FirmaFeeGrantService {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
7
|
+
private readonly config;
|
|
8
|
+
constructor(config: FirmaConfig);
|
|
9
|
+
getGasEstimationRevokeAllowance(wallet: FirmaWalletService, granteeAddress: string, txMisc?: TxMisc): Promise<number>;
|
|
9
10
|
private getSignedTxRevokeAllowance;
|
|
10
|
-
|
|
11
|
+
revokeAllowance(wallet: FirmaWalletService, granteeAddress: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
11
12
|
private getCoinType;
|
|
13
|
+
getGasEstimationGrantPeriodicAllowance(wallet: FirmaWalletService, granteeAddress: string, feegrantOption: PeriodicFeeGrantOption, txMisc?: TxMisc): Promise<number>;
|
|
12
14
|
private getSignedTxGrantPeriodicAllowance;
|
|
15
|
+
getGasEstimationGrantBasicAllowance(wallet: FirmaWalletService, granteeAddress: string, feegrantOption?: BasicFeeGrantOption, txMisc?: TxMisc): Promise<number>;
|
|
13
16
|
private getSignedTxGrantBasicAllowance;
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
grantPeriodicAllowance(wallet: FirmaWalletService, granteeAddress: string, feegrantOption: PeriodicFeeGrantOption, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
18
|
+
grantBasicAllowance(wallet: FirmaWalletService, granteeAddress: string, feegrantOption?: BasicFeeGrantOption, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
16
19
|
getGranteeAllowance(granterAddress: string, granteeAddress: string): Promise<FeeAllowanceType1>;
|
|
17
20
|
getGranteeAllowanceAll(granteeAddress: string): Promise<FeeAllowanceType[]>;
|
|
18
21
|
}
|