@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
|
@@ -465,17 +465,17 @@ describe('[08. Gas Estimation Test]', function () {
|
|
|
465
465
|
}
|
|
466
466
|
});
|
|
467
467
|
}); });
|
|
468
|
-
it
|
|
469
|
-
var initialDepositFCT, title,
|
|
468
|
+
it("7-2. Gov submitCommunityPoolSpendProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
469
|
+
var initialDepositFCT, title, summary, amountFCT, recipient, gas;
|
|
470
470
|
return __generator(this, function (_a) {
|
|
471
471
|
switch (_a.label) {
|
|
472
472
|
case 0:
|
|
473
473
|
initialDepositFCT = 2500;
|
|
474
474
|
title = "Community spend proposal";
|
|
475
|
-
|
|
475
|
+
summary = "Proposal to spend from community pool";
|
|
476
476
|
amountFCT = 1000;
|
|
477
477
|
recipient = bobAddress;
|
|
478
|
-
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitCommunityPoolSpendProposal(aliceWallet, title,
|
|
478
|
+
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitCommunityPoolSpendProposal(aliceWallet, title, summary, initialDepositFCT, amountFCT, recipient)];
|
|
479
479
|
case 1:
|
|
480
480
|
gas = _a.sent();
|
|
481
481
|
chai_1.expect(gas).to.not.equal(0);
|
|
@@ -483,54 +483,67 @@ describe('[08. Gas Estimation Test]', function () {
|
|
|
483
483
|
}
|
|
484
484
|
});
|
|
485
485
|
}); });
|
|
486
|
-
it
|
|
487
|
-
var initialDepositFCT, title,
|
|
486
|
+
it("7-3. Gov submitStakingParamsUpdateProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
487
|
+
var initialDepositFCT, title, summary, params, metadata, gas;
|
|
488
488
|
return __generator(this, function (_a) {
|
|
489
489
|
switch (_a.label) {
|
|
490
490
|
case 0:
|
|
491
|
-
initialDepositFCT =
|
|
492
|
-
title = "
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
subspace: "staking",
|
|
496
|
-
key: "MaxValidators",
|
|
497
|
-
value: "100",
|
|
498
|
-
}];
|
|
499
|
-
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitParameterChangeProposal(aliceWallet, title, description, initialDepositFCT, changeParamList)];
|
|
491
|
+
initialDepositFCT = 5000;
|
|
492
|
+
title = "Staking parameter change proposal";
|
|
493
|
+
summary = "This is a Staking parameter change proposal";
|
|
494
|
+
return [4 /*yield*/, firma.Staking.getParamsAsStakingParams()];
|
|
500
495
|
case 1:
|
|
496
|
+
params = _a.sent();
|
|
497
|
+
params.maxValidators = 100;
|
|
498
|
+
metadata = "";
|
|
499
|
+
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitStakingParamsUpdateProposal(aliceWallet, title, summary, initialDepositFCT, params, metadata)];
|
|
500
|
+
case 2:
|
|
501
501
|
gas = _a.sent();
|
|
502
502
|
chai_1.expect(gas).to.not.equal(0);
|
|
503
503
|
return [2 /*return*/];
|
|
504
504
|
}
|
|
505
505
|
});
|
|
506
506
|
}); });
|
|
507
|
-
it
|
|
508
|
-
var initialDepositFCT, title,
|
|
507
|
+
it("7-4, Gov submitGovParamsUpdateProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
508
|
+
var initialDepositFCT, title, summary, params, metadata, gas;
|
|
509
509
|
return __generator(this, function (_a) {
|
|
510
510
|
switch (_a.label) {
|
|
511
511
|
case 0:
|
|
512
|
-
initialDepositFCT =
|
|
513
|
-
title = "
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
upgradeHeight = 20000000;
|
|
517
|
-
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitSoftwareUpgradeProposalByHeight(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeHeight)];
|
|
512
|
+
initialDepositFCT = 5000;
|
|
513
|
+
title = "Gov parameter change proposal";
|
|
514
|
+
summary = "This is a Gov parameter change proposal";
|
|
515
|
+
return [4 /*yield*/, firma.Gov.getParamAsGovParams()];
|
|
518
516
|
case 1:
|
|
517
|
+
params = _a.sent();
|
|
518
|
+
params.burnProposalDepositPrevote = true;
|
|
519
|
+
metadata = "";
|
|
520
|
+
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitGovParamsUpdateProposal(aliceWallet, title, summary, initialDepositFCT, params, metadata)];
|
|
521
|
+
case 2:
|
|
519
522
|
gas = _a.sent();
|
|
520
523
|
chai_1.expect(gas).to.not.equal(0);
|
|
521
524
|
return [2 /*return*/];
|
|
522
525
|
}
|
|
523
526
|
});
|
|
524
527
|
}); });
|
|
525
|
-
it
|
|
526
|
-
var initialDepositFCT, title,
|
|
528
|
+
it("7-5. Gov submitSoftwareUpgradeProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
529
|
+
var initialDepositFCT, title, summary, plan, metadata, gas;
|
|
527
530
|
return __generator(this, function (_a) {
|
|
528
531
|
switch (_a.label) {
|
|
529
532
|
case 0:
|
|
530
|
-
initialDepositFCT =
|
|
533
|
+
initialDepositFCT = 5000;
|
|
531
534
|
title = "Software Upgrade proposal1";
|
|
532
|
-
|
|
533
|
-
|
|
535
|
+
summary = "This is a software upgrade proposal";
|
|
536
|
+
plan = {
|
|
537
|
+
name: 'v0.5.1',
|
|
538
|
+
time: {
|
|
539
|
+
seconds: BigInt(0),
|
|
540
|
+
nanos: 0
|
|
541
|
+
},
|
|
542
|
+
height: BigInt(1050000),
|
|
543
|
+
info: ''
|
|
544
|
+
};
|
|
545
|
+
metadata = "";
|
|
546
|
+
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitSoftwareUpgradeProposal(aliceWallet, title, summary, initialDepositFCT, plan, metadata)];
|
|
534
547
|
case 1:
|
|
535
548
|
gas = _a.sent();
|
|
536
549
|
chai_1.expect(gas).to.not.equal(0);
|
|
@@ -137,6 +137,18 @@ describe('[13. Staking Query Test]', function () {
|
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
}); });
|
|
140
|
+
it('6-1.get getParamsAsStakingParams', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
+
var result;
|
|
142
|
+
return __generator(this, function (_a) {
|
|
143
|
+
switch (_a.label) {
|
|
144
|
+
case 0: return [4 /*yield*/, firma.Staking.getParamsAsStakingParams()];
|
|
145
|
+
case 1:
|
|
146
|
+
result = _a.sent();
|
|
147
|
+
chai_1.expect(result.maxValidators).to.not.equal(0);
|
|
148
|
+
return [2 /*return*/];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}); });
|
|
140
152
|
// user side
|
|
141
153
|
it('7.get userside getTotalDelegationInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
142
154
|
var wallet, result, _a, _b;
|
|
@@ -134,17 +134,17 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
}); });
|
|
137
|
-
it
|
|
138
|
-
var initialDepositFCT, title,
|
|
137
|
+
it('SubmitCommunityPoolSpendProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
138
|
+
var initialDepositFCT, title, summary, amountFCT, recipient, result;
|
|
139
139
|
return __generator(this, function (_a) {
|
|
140
140
|
switch (_a.label) {
|
|
141
141
|
case 0:
|
|
142
|
-
initialDepositFCT =
|
|
142
|
+
initialDepositFCT = 2500;
|
|
143
143
|
title = "Community spend proposal1";
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
recipient =
|
|
147
|
-
return [4 /*yield*/, firma.Gov.submitCommunityPoolSpendProposal(aliceWallet, title,
|
|
144
|
+
summary = "This is a community spend proposal";
|
|
145
|
+
amountFCT = 1000;
|
|
146
|
+
recipient = aliceAddress;
|
|
147
|
+
return [4 /*yield*/, firma.Gov.submitCommunityPoolSpendProposal(aliceWallet, title, summary, initialDepositFCT, amountFCT, recipient)];
|
|
148
148
|
case 1:
|
|
149
149
|
result = _a.sent();
|
|
150
150
|
chai_1.expect(result.code).to.equal(0);
|
|
@@ -152,43 +152,42 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
}); });
|
|
155
|
-
it
|
|
156
|
-
var
|
|
155
|
+
it('SubmitStakingParamsUpdateProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
156
|
+
var title, summary, initialDepositFCT, params, metadata, result;
|
|
157
157
|
return __generator(this, function (_a) {
|
|
158
158
|
switch (_a.label) {
|
|
159
159
|
case 0:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
subspace: "staking",
|
|
165
|
-
key: "MaxValidators",
|
|
166
|
-
value: "100",
|
|
167
|
-
}];
|
|
168
|
-
return [4 /*yield*/, firma.Gov.submitParameterChangeProposal(aliceWallet, title, description, initialDepositFCT, changeParamList)];
|
|
160
|
+
title = "Staking Parameter Change proposal";
|
|
161
|
+
summary = "This is a Staking Parameter change proposal";
|
|
162
|
+
initialDepositFCT = 2500;
|
|
163
|
+
return [4 /*yield*/, firma.Staking.getParamsAsStakingParams()];
|
|
169
164
|
case 1:
|
|
165
|
+
params = _a.sent();
|
|
166
|
+
params.maxValidators = 100;
|
|
167
|
+
params.historicalEntries = 10000;
|
|
168
|
+
metadata = "";
|
|
169
|
+
return [4 /*yield*/, firma.Gov.submitStakingParamsUpdateProposal(aliceWallet, title, summary, initialDepositFCT, params, metadata)];
|
|
170
|
+
case 2:
|
|
170
171
|
result = _a.sent();
|
|
171
172
|
chai_1.expect(result.code).to.equal(0);
|
|
172
173
|
return [2 /*return*/];
|
|
173
174
|
}
|
|
174
175
|
});
|
|
175
176
|
}); });
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var initialDepositFCT, title, description, upgradeName, upgradeHeight, gas, fee, result;
|
|
177
|
+
it('SubmitGovParamsUpdateProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var title, summary, initialDepositFCT, params, metadata, result;
|
|
179
179
|
return __generator(this, function (_a) {
|
|
180
180
|
switch (_a.label) {
|
|
181
181
|
case 0:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
upgradeHeight = 558800;
|
|
187
|
-
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitSoftwareUpgradeProposalByHeight(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeHeight)];
|
|
182
|
+
title = "Gov Parameter Change proposal";
|
|
183
|
+
summary = "This is a Gov Parameter change proposal";
|
|
184
|
+
initialDepositFCT = 2500;
|
|
185
|
+
return [4 /*yield*/, firma.Gov.getParamAsGovParams()];
|
|
188
186
|
case 1:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
params = _a.sent();
|
|
188
|
+
params.burnProposalDepositPrevote = true;
|
|
189
|
+
metadata = "";
|
|
190
|
+
return [4 /*yield*/, firma.Gov.submitGovParamsUpdateProposal(aliceWallet, title, summary, initialDepositFCT, params, metadata)];
|
|
192
191
|
case 2:
|
|
193
192
|
result = _a.sent();
|
|
194
193
|
chai_1.expect(result.code).to.equal(0);
|
|
@@ -196,19 +195,32 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
196
195
|
}
|
|
197
196
|
});
|
|
198
197
|
}); });
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
var initialDepositFCT, title, description, result;
|
|
198
|
+
it('SubmitSoftwareUpgradeProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
+
var initialDeposit, title, summary, plan, metadata, gas, fee, result;
|
|
202
200
|
return __generator(this, function (_a) {
|
|
203
201
|
switch (_a.label) {
|
|
204
202
|
case 0:
|
|
205
|
-
|
|
206
|
-
title = "
|
|
207
|
-
|
|
208
|
-
|
|
203
|
+
initialDeposit = 5000;
|
|
204
|
+
title = "CancelProposal test proposal";
|
|
205
|
+
summary = "This is a Text & CancelProposal";
|
|
206
|
+
plan = {
|
|
207
|
+
name: 'v0.5.1',
|
|
208
|
+
time: {
|
|
209
|
+
seconds: BigInt(0),
|
|
210
|
+
nanos: 0
|
|
211
|
+
},
|
|
212
|
+
height: BigInt(1050000),
|
|
213
|
+
info: ''
|
|
214
|
+
};
|
|
215
|
+
metadata = "";
|
|
216
|
+
return [4 /*yield*/, firma.Gov.getGasEstimationSubmitSoftwareUpgradeProposal(aliceWallet, title, summary, initialDeposit, plan, metadata)];
|
|
209
217
|
case 1:
|
|
218
|
+
gas = _a.sent();
|
|
219
|
+
fee = Math.ceil(gas * 0.1);
|
|
220
|
+
return [4 /*yield*/, firma.Gov.submitSoftwareUpgradeProposal(aliceWallet, title, summary, initialDeposit, plan, metadata, { gas: gas, fee: fee })];
|
|
221
|
+
case 2:
|
|
210
222
|
result = _a.sent();
|
|
211
|
-
chai_1.expect(result.code).to.equal(0);
|
|
223
|
+
chai_1.expect(result.code).to.be.equal(0);
|
|
212
224
|
return [2 /*return*/];
|
|
213
225
|
}
|
|
214
226
|
});
|
|
@@ -243,27 +255,8 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
243
255
|
}
|
|
244
256
|
});
|
|
245
257
|
}); });
|
|
246
|
-
// NOTICE: time-based upgrades have been deprecated in the SDK: invalid request
|
|
247
|
-
/*it.skip('SubmitSoftwareUpgradeProposalByTime Test', async () => {
|
|
248
|
-
|
|
249
|
-
const initialDepositFCT = 8;
|
|
250
|
-
const title = "Software Upgrade proposal2";
|
|
251
|
-
const description = "This is a software upgrade proposal";
|
|
252
|
-
|
|
253
|
-
const expirationDate = new Date();
|
|
254
|
-
expirationDate.setMinutes(expirationDate.getMinutes() + 3);
|
|
255
|
-
|
|
256
|
-
const upgradeName = "v0.2.4";
|
|
257
|
-
const upgradeTime = expirationDate;
|
|
258
|
-
const upgradeInfo = "info?";
|
|
259
|
-
|
|
260
|
-
var result = await firma.Gov.SubmitSoftwareUpgradeProposalByTime(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeTime);
|
|
261
|
-
|
|
262
|
-
console.log(result);
|
|
263
|
-
expect(result.code).to.equal(0);
|
|
264
|
-
});*/
|
|
265
258
|
// TODO: get recent gov proposal list and then set proposalId for below case
|
|
266
|
-
var tempProposalId =
|
|
259
|
+
var tempProposalId = 1;
|
|
267
260
|
// more deposit after initial deposit case
|
|
268
261
|
it.skip('Deposit OK', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
269
262
|
var proposalId, amount, result;
|
|
@@ -308,4 +301,92 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
308
301
|
}
|
|
309
302
|
});
|
|
310
303
|
}); });
|
|
304
|
+
it('SubmitCommunityPoolSpendProposal & Deposit & Vote scenario test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
305
|
+
var initialDepositFCT, title, summary, amountFCT, recipient, result, proposalId, addDepositAmount;
|
|
306
|
+
return __generator(this, function (_a) {
|
|
307
|
+
switch (_a.label) {
|
|
308
|
+
case 0:
|
|
309
|
+
initialDepositFCT = 2500;
|
|
310
|
+
title = "Community spend proposal1";
|
|
311
|
+
summary = "This is a community spend proposal";
|
|
312
|
+
amountFCT = 1000;
|
|
313
|
+
recipient = aliceAddress;
|
|
314
|
+
return [4 /*yield*/, firma.Gov.submitCommunityPoolSpendProposal(aliceWallet, title, summary, initialDepositFCT, amountFCT, recipient)];
|
|
315
|
+
case 1:
|
|
316
|
+
result = _a.sent();
|
|
317
|
+
chai_1.expect(result.code).to.equal(0);
|
|
318
|
+
proposalId = extractValue(result.events, "submit_proposal", "proposal_id");
|
|
319
|
+
addDepositAmount = 2500;
|
|
320
|
+
return [4 /*yield*/, firma.Gov.deposit(aliceWallet, proposalId, addDepositAmount)];
|
|
321
|
+
case 2:
|
|
322
|
+
result = _a.sent();
|
|
323
|
+
chai_1.expect(result.code).to.equal(0);
|
|
324
|
+
return [4 /*yield*/, firma.Gov.vote(aliceWallet, proposalId, common_1.VotingOption.VOTE_OPTION_YES)];
|
|
325
|
+
case 3:
|
|
326
|
+
result = _a.sent();
|
|
327
|
+
chai_1.expect(result.code).to.equal(0);
|
|
328
|
+
return [4 /*yield*/, firma.Gov.vote(aliceWallet, proposalId, common_1.VotingOption.VOTE_OPTION_NO)];
|
|
329
|
+
case 4:
|
|
330
|
+
result = _a.sent();
|
|
331
|
+
chai_1.expect(result.code).to.equal(0);
|
|
332
|
+
return [2 /*return*/];
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}); });
|
|
336
|
+
it('SubmitGovParamsUpdateProposal Test - failure case (missing parameter)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
337
|
+
var title, summary, initialDeposit, proposalParams, metadata, errorMsg, error_1;
|
|
338
|
+
return __generator(this, function (_a) {
|
|
339
|
+
switch (_a.label) {
|
|
340
|
+
case 0:
|
|
341
|
+
title = "Gov Parameter Change fail proposal";
|
|
342
|
+
summary = "This is a Gov Parameter change proposal";
|
|
343
|
+
initialDeposit = 5000;
|
|
344
|
+
proposalParams = {
|
|
345
|
+
burnVoteQuorum: false
|
|
346
|
+
};
|
|
347
|
+
metadata = "";
|
|
348
|
+
errorMsg = "All governance parameters must be provided. Use getParamAsGovParams() to get current values and override only the parameters you want to change.";
|
|
349
|
+
_a.label = 1;
|
|
350
|
+
case 1:
|
|
351
|
+
_a.trys.push([1, 3, , 4]);
|
|
352
|
+
return [4 /*yield*/, firma.Gov.submitGovParamsUpdateProposal(aliceWallet, title, summary, initialDeposit, proposalParams, metadata)];
|
|
353
|
+
case 2:
|
|
354
|
+
_a.sent();
|
|
355
|
+
return [3 /*break*/, 4];
|
|
356
|
+
case 3:
|
|
357
|
+
error_1 = _a.sent();
|
|
358
|
+
chai_1.expect(error_1.message).to.equal(errorMsg);
|
|
359
|
+
return [3 /*break*/, 4];
|
|
360
|
+
case 4: return [2 /*return*/];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}); });
|
|
364
|
+
it('SubmitStakingParamsUpdateProposal Test - failure case (missing parameter)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
365
|
+
var title, summary, initialDeposit, proposalParams, metadata, errorMsg, error_2;
|
|
366
|
+
return __generator(this, function (_a) {
|
|
367
|
+
switch (_a.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
title = "Staking Parameter Change fail proposal";
|
|
370
|
+
summary = "This is a Staking Parameter change proposal";
|
|
371
|
+
initialDeposit = 5000;
|
|
372
|
+
proposalParams = {
|
|
373
|
+
maxValidators: 100
|
|
374
|
+
};
|
|
375
|
+
metadata = "";
|
|
376
|
+
errorMsg = "All staking parameters must be provided. Use Staking.getParamsAsStakingParams() to get current values and override only the parameters you want to change.";
|
|
377
|
+
_a.label = 1;
|
|
378
|
+
case 1:
|
|
379
|
+
_a.trys.push([1, 3, , 4]);
|
|
380
|
+
return [4 /*yield*/, firma.Gov.submitStakingParamsUpdateProposal(aliceWallet, title, summary, initialDeposit, proposalParams, metadata)];
|
|
381
|
+
case 2:
|
|
382
|
+
_a.sent();
|
|
383
|
+
return [3 /*break*/, 4];
|
|
384
|
+
case 3:
|
|
385
|
+
error_2 = _a.sent();
|
|
386
|
+
chai_1.expect(error_2.message).to.equal(errorMsg);
|
|
387
|
+
return [3 /*break*/, 4];
|
|
388
|
+
case 4: return [2 /*return*/];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}); });
|
|
311
392
|
});
|
|
@@ -50,7 +50,7 @@ describe('[17. Gov Query Test]', function () {
|
|
|
50
50
|
return __generator(this, function (_a) {
|
|
51
51
|
proposalList = [];
|
|
52
52
|
if (proposalList.length > 0) {
|
|
53
|
-
chai_1.expect(proposalList[0].
|
|
53
|
+
chai_1.expect(proposalList[0].id).to.not.equal('');
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
chai_1.expect(proposalList).to.be.deep.equal([]);
|
|
@@ -69,8 +69,8 @@ describe('[17. Gov Query Test]', function () {
|
|
|
69
69
|
proposalList = _a.sent();
|
|
70
70
|
chai_1.expect(proposalList).to.be.an('array');
|
|
71
71
|
if (proposalList.length > 0) {
|
|
72
|
-
chai_1.expect(proposalList[0]).to.have.property('
|
|
73
|
-
chai_1.expect(proposalList[0].
|
|
72
|
+
chai_1.expect(proposalList[0]).to.have.property('id');
|
|
73
|
+
chai_1.expect(proposalList[0].id).to.not.equal('');
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
chai_1.expect(proposalList).to.have.lengthOf(0);
|
|
@@ -92,8 +92,8 @@ describe('[17. Gov Query Test]', function () {
|
|
|
92
92
|
case 2:
|
|
93
93
|
proposal = _a.sent();
|
|
94
94
|
chai_1.expect(proposal).to.be.an('object');
|
|
95
|
-
chai_1.expect(proposal).to.have.property('
|
|
96
|
-
chai_1.expect(proposal.
|
|
95
|
+
chai_1.expect(proposal).to.have.property('id');
|
|
96
|
+
chai_1.expect(proposal.id).to.equal(id);
|
|
97
97
|
return [3 /*break*/, 4];
|
|
98
98
|
case 3:
|
|
99
99
|
chai_1.expect(proposalList).to.have.lengthOf(0);
|
|
@@ -111,19 +111,19 @@ describe('[17. Gov Query Test]', function () {
|
|
|
111
111
|
case 1:
|
|
112
112
|
param = _a.sent();
|
|
113
113
|
chai_1.expect(param).to.be.an('object');
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
chai_1.expect(param
|
|
114
|
+
return [2 /*return*/];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}); });
|
|
118
|
+
// integrated function with params/voting, params/deposit, params/tallying - GovParams
|
|
119
|
+
it('get params as GovParams', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
+
var param;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0: return [4 /*yield*/, firma.Gov.getParamAsGovParams()];
|
|
124
|
+
case 1:
|
|
125
|
+
param = _a.sent();
|
|
126
|
+
chai_1.expect(param).to.be.an('object');
|
|
127
127
|
return [2 /*return*/];
|
|
128
128
|
}
|
|
129
129
|
});
|
|
@@ -248,4 +248,78 @@ describe('[18. util Test]', function () {
|
|
|
248
248
|
return [2 /*return*/];
|
|
249
249
|
});
|
|
250
250
|
}); });
|
|
251
|
+
it('parseDurationString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
252
|
+
var testString, duration;
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
testString = "1800s";
|
|
255
|
+
duration = FirmaUtil_1.FirmaUtil.parseDurationString(testString);
|
|
256
|
+
// Correct way to test object properties
|
|
257
|
+
chai_1.expect(duration.seconds).to.be.equal(BigInt(1800));
|
|
258
|
+
chai_1.expect(duration.nanos).to.be.equal(0);
|
|
259
|
+
return [2 /*return*/];
|
|
260
|
+
});
|
|
261
|
+
}); });
|
|
262
|
+
it('createDurationFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
263
|
+
var testString, duration;
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
testString = "1800s";
|
|
266
|
+
duration = FirmaUtil_1.FirmaUtil.createDurationFromString(testString);
|
|
267
|
+
chai_1.expect(duration.seconds).to.be.equal(BigInt(1800));
|
|
268
|
+
chai_1.expect(duration.nanos).to.be.equal(0);
|
|
269
|
+
return [2 /*return*/];
|
|
270
|
+
});
|
|
271
|
+
}); });
|
|
272
|
+
it('normalizeDecimalString test - success case', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
273
|
+
var result;
|
|
274
|
+
return __generator(this, function (_a) {
|
|
275
|
+
result = FirmaUtil_1.FirmaUtil.normalizeDecimalString("0.000000000000000000");
|
|
276
|
+
chai_1.expect(result).to.equal("");
|
|
277
|
+
return [2 /*return*/];
|
|
278
|
+
});
|
|
279
|
+
}); });
|
|
280
|
+
it('normalizeDecimalString test - failure case', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
281
|
+
var result;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
result = FirmaUtil_1.FirmaUtil.normalizeDecimalString("0.000000000000000000");
|
|
284
|
+
chai_1.expect(result).to.not.equal("0.000000000000000000");
|
|
285
|
+
return [2 /*return*/];
|
|
286
|
+
});
|
|
287
|
+
}); });
|
|
288
|
+
it('processCommissionRate test - success case', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
|
+
var result;
|
|
290
|
+
return __generator(this, function (_a) {
|
|
291
|
+
result = FirmaUtil_1.FirmaUtil.processCommissionRate("0.000000000000000000");
|
|
292
|
+
chai_1.expect(result).to.equal("");
|
|
293
|
+
result = FirmaUtil_1.FirmaUtil.processCommissionRate("0.1");
|
|
294
|
+
chai_1.expect(result).to.equal("0.1");
|
|
295
|
+
result = FirmaUtil_1.FirmaUtil.processCommissionRate("1");
|
|
296
|
+
chai_1.expect(result).to.equal("1");
|
|
297
|
+
result = FirmaUtil_1.FirmaUtil.processCommissionRate(" 0.75 ");
|
|
298
|
+
chai_1.expect(result).to.equal("0.75");
|
|
299
|
+
result = FirmaUtil_1.FirmaUtil.processCommissionRate("");
|
|
300
|
+
chai_1.expect(result).to.equal("");
|
|
301
|
+
return [2 /*return*/];
|
|
302
|
+
});
|
|
303
|
+
}); });
|
|
304
|
+
it('processCommissionRate - failure cases', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
305
|
+
var testString;
|
|
306
|
+
return __generator(this, function (_a) {
|
|
307
|
+
testString = "1.01";
|
|
308
|
+
try {
|
|
309
|
+
FirmaUtil_1.FirmaUtil.processCommissionRate(testString);
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
chai_1.expect(error.message).to.equal("Invalid commission rate format: 1.01");
|
|
313
|
+
}
|
|
314
|
+
// Invalid commission rate: -0.1. Must be >= 0
|
|
315
|
+
testString = "-0.1";
|
|
316
|
+
try {
|
|
317
|
+
FirmaUtil_1.FirmaUtil.processCommissionRate(testString);
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
chai_1.expect(error.message).to.equal("Invalid commission rate format: -0.1");
|
|
321
|
+
}
|
|
322
|
+
return [2 /*return*/];
|
|
323
|
+
});
|
|
324
|
+
}); });
|
|
251
325
|
});
|
|
@@ -79,7 +79,6 @@ describe('[20. Slashing Query Test]', function () {
|
|
|
79
79
|
chai_1.expect(result[0]).to.have.property('jailed_until');
|
|
80
80
|
chai_1.expect(result[0]).to.have.property('tombstoned');
|
|
81
81
|
chai_1.expect(result[0]).to.have.property('missed_blocks_counter');
|
|
82
|
-
// address가 비어있지 않은지 확인
|
|
83
82
|
chai_1.expect(result[0].address).to.not.be.empty;
|
|
84
83
|
}
|
|
85
84
|
return [2 /*return*/];
|
package/dist/test/config_test.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signerMnemonic4 = exports.signerMnemonic3 = exports.signerMnemonic2 = exports.signerMnemonic1 = exports.firmaFeeMnemonic = exports.feeMnemonic = exports.bobMnemonic = exports.aliceMnemonic = exports.validatorMnemonic = exports.TestChainConfig = void 0;
|
|
4
|
+
// export let TestChainConfig: FirmaConfig = FirmaConfig.TestNetConfig;
|
|
4
5
|
exports.TestChainConfig = {
|
|
5
6
|
chainID: "roma-1",
|
|
6
7
|
rpcAddress: "http://192.168.30.47:26657",
|
|
@@ -16,10 +17,15 @@ exports.TestChainConfig = {
|
|
|
16
17
|
isShowLog: false,
|
|
17
18
|
};
|
|
18
19
|
exports.validatorMnemonic = "angry water bunker where iron absurd cruise deliver clutch unique creek pyramid arch express flush pill lens concert absent enemy boring mom nuclear rose";
|
|
19
|
-
exports.aliceMnemonic = "immune flavor record sphere foam planet faint grid disorder flag minute eternal beef sea camp surge extra scorpion pistol plastic happy siren juice found";
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
// export const
|
|
20
|
+
exports.aliceMnemonic = "immune flavor record sphere foam planet faint grid disorder flag minute eternal beef sea camp surge extra scorpion pistol plastic happy siren juice found";
|
|
21
|
+
// voting test
|
|
22
|
+
// export const aliceMnemonic = "long shallow crumble clown truth book oval render seed canal buffalo assist sadness elbow afraid catalog brother trade food subject must luggage bread neither";
|
|
23
|
+
// export const aliceMnemonic = "angry water bunker where iron absurd cruise deliver clutch unique creek pyramid arch express flush pill lens concert absent enemy boring mom nuclear rose";
|
|
24
|
+
// export const aliceMnemonic = "stadium lonely midnight okay meat rib awesome wealth phone leisure turn prosper notable label fruit define little also father silver half drill bargain antique";
|
|
25
|
+
// export const aliceMnemonic = "uncle banana theme relax oak prosper volcano glad industry bicycle tower thrive jelly curious luggage frame that defy reason jewel figure begin nice moon";
|
|
26
|
+
// export const aliceMnemonic = "rebel engine situate catalog blood strong satisfy aerobic cupboard again vivid twice flag work taxi heart fruit island ribbon hungry cheap ordinary horse foam";
|
|
27
|
+
// export const aliceMnemonic = "ladder damage art company shield glance cushion float need layer rare toast intact grief wet point write season correct access mix bomb accident estate";
|
|
28
|
+
exports.bobMnemonic = "innocent enforce visit tilt job kitten actual glory flash feed wonder license rubber outer drum sun fuel relax roof universe enrich pulse fine grid";
|
|
23
29
|
exports.feeMnemonic = "long shallow crumble clown truth book oval render seed canal buffalo assist sadness elbow afraid catalog brother trade food subject must luggage bread neither";
|
|
24
30
|
exports.firmaFeeMnemonic = "arrest dynamic typical lunch original glare truth narrow stairs clip canyon space alley chat drive sudden music bubble time mesh color office minor draft";
|
|
25
31
|
// export const firmaFeeMnemonic = "child material talent property foot sign talent congress cargo pistol suspect screen leader owner type style patch amused stable flame sure fluid april acoustic";
|
|
@@ -3,3 +3,9 @@ export declare let TestChainConfig: FirmaConfig;
|
|
|
3
3
|
export declare const validatorMnemonic = "";
|
|
4
4
|
export declare const aliceMnemonic = "";
|
|
5
5
|
export declare const bobMnemonic = "";
|
|
6
|
+
export declare const feeMnemonic = "";
|
|
7
|
+
export declare const firmaFeeMnemonic = "";
|
|
8
|
+
export declare const signerMnemonic1 = "";
|
|
9
|
+
export declare const signerMnemonic2 = "";
|
|
10
|
+
export declare const signerMnemonic3 = "";
|
|
11
|
+
export declare const signerMnemonic4 = "";
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bobMnemonic = exports.aliceMnemonic = exports.validatorMnemonic = exports.TestChainConfig = void 0;
|
|
3
|
+
exports.signerMnemonic4 = exports.signerMnemonic3 = exports.signerMnemonic2 = exports.signerMnemonic1 = exports.firmaFeeMnemonic = exports.feeMnemonic = exports.bobMnemonic = exports.aliceMnemonic = exports.validatorMnemonic = exports.TestChainConfig = void 0;
|
|
4
4
|
var FirmaConfig_1 = require("../sdk/FirmaConfig");
|
|
5
5
|
exports.TestChainConfig = FirmaConfig_1.FirmaConfig.TestNetConfig;
|
|
6
6
|
exports.validatorMnemonic = "";
|
|
7
7
|
exports.aliceMnemonic = "";
|
|
8
8
|
exports.bobMnemonic = "";
|
|
9
|
+
exports.feeMnemonic = "";
|
|
10
|
+
exports.firmaFeeMnemonic = "";
|
|
11
|
+
exports.signerMnemonic1 = "";
|
|
12
|
+
exports.signerMnemonic2 = "";
|
|
13
|
+
exports.signerMnemonic3 = "";
|
|
14
|
+
exports.signerMnemonic4 = "";
|