@firmachain/firma-js 0.3.1 → 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 +47 -13
- package/dist/sdk/FirmaGovService.d.ts +9 -8
- package/dist/sdk/FirmaGovService.js +119 -32
- 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 +22 -49
- package/dist/sdk/firmachain/gov/GovQueryClient.js +20 -28
- package/dist/sdk/firmachain/gov/GovTxClient.js +1 -0
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +2 -2
- package/dist/test/08.gas_estimate.test.js +10 -55
- package/dist/test/13.staking_query.test.js +12 -0
- package/dist/test/16.gov_tx.test.js +69 -57
- 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 +8 -0
- package/package.json +1 -1
|
@@ -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",
|
|
@@ -17,6 +18,13 @@ exports.TestChainConfig = {
|
|
|
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
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";
|
|
20
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";
|
|
21
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";
|
|
22
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";
|