@firmachain/firma-js 0.3.1 → 0.3.3

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.
@@ -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].proposal_id).to.not.equal('');
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('proposal_id');
73
- chai_1.expect(proposalList[0].proposal_id).to.not.equal('');
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('proposal_id');
96
- chai_1.expect(proposal.proposal_id).to.equal(id);
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
- chai_1.expect(param).to.have.property('voting_period');
115
- chai_1.expect(param).to.have.property('deposit_params');
116
- chai_1.expect(param.deposit_params).to.have.property('min_deposit');
117
- chai_1.expect(param.deposit_params).to.have.property('max_deposit_period');
118
- chai_1.expect(param.deposit_params.min_deposit).to.be.an('array');
119
- if (param.deposit_params.min_deposit.length > 0) {
120
- chai_1.expect(param.deposit_params.min_deposit[0]).to.have.property('denom');
121
- chai_1.expect(param.deposit_params.min_deposit[0]).to.have.property('amount');
122
- }
123
- chai_1.expect(param).to.have.property('tally_params');
124
- chai_1.expect(param.tally_params).to.have.property('quorum');
125
- chai_1.expect(param.tally_params).to.have.property('threshold');
126
- chai_1.expect(param.tally_params).to.have.property('veto_threshold');
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
  });
@@ -38,12 +38,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var chai_1 = require("chai");
40
40
  var FirmaUtil_1 = require("../sdk/FirmaUtil");
41
- var FirmaSDK_1 = require("../sdk/FirmaSDK");
42
- var config_test_1 = require("./config_test");
43
41
  describe('[18. util Test]', function () {
44
- var firma;
45
42
  beforeEach(function () {
46
- firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
47
43
  });
48
44
  // getHashFromString
49
45
  it('getSha1HashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -248,4 +244,69 @@ describe('[18. util Test]', function () {
248
244
  return [2 /*return*/];
249
245
  });
250
246
  }); });
247
+ it('parseDurationString test', function () { return __awaiter(void 0, void 0, void 0, function () {
248
+ var testString, duration;
249
+ return __generator(this, function (_a) {
250
+ testString = "1800s";
251
+ duration = FirmaUtil_1.FirmaUtil.parseDurationString(testString);
252
+ // Correct way to test object properties
253
+ chai_1.expect(duration.seconds).to.be.equal(BigInt(1800));
254
+ chai_1.expect(duration.nanos).to.be.equal(0);
255
+ return [2 /*return*/];
256
+ });
257
+ }); });
258
+ it('createDurationFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
259
+ var testString, duration;
260
+ return __generator(this, function (_a) {
261
+ testString = "1800s";
262
+ duration = FirmaUtil_1.FirmaUtil.createDurationFromString(testString);
263
+ chai_1.expect(duration.seconds).to.be.equal(BigInt(1800));
264
+ chai_1.expect(duration.nanos).to.be.equal(0);
265
+ return [2 /*return*/];
266
+ });
267
+ }); });
268
+ it('processCommissionRateAsDecimal test - success case', function () { return __awaiter(void 0, void 0, void 0, function () {
269
+ var result;
270
+ return __generator(this, function (_a) {
271
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.000000000000000000");
272
+ chai_1.expect(result).to.equal("0");
273
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1");
274
+ chai_1.expect(result).to.equal("1000000000000000000");
275
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.99999999999999999999999");
276
+ chai_1.expect(result).to.equal("999999999999999999");
277
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.3719281729181018373290120300000831");
278
+ chai_1.expect(result).to.equal("371928172918101837");
279
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.000000000000000000");
280
+ chai_1.expect(result).to.equal("1000000000000000000");
281
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(" 0.75 ");
282
+ chai_1.expect(result).to.equal("750000000000000000");
283
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(".23");
284
+ chai_1.expect(result).to.equal("230000000000000000");
285
+ result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(".9999990000000");
286
+ chai_1.expect(result).to.equal("999999000000000000");
287
+ return [2 /*return*/];
288
+ });
289
+ }); });
290
+ it('processCommissionRateAsDecimal test - failure cases', function () { return __awaiter(void 0, void 0, void 0, function () {
291
+ return __generator(this, function (_a) {
292
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("."); }).to.throw("Invalid commission rate format");
293
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(""); }).to.throw("Invalid commission rate format: ");
294
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(" "); }).to.throw("Invalid commission rate format: ");
295
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("null"); }).to.throw("Invalid commission rate format: null");
296
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.1abc"); }).to.throw("Invalid commission rate format: 0.1abc");
297
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.1.2"); }).to.throw("Invalid commission rate format");
298
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("--0.5"); }).to.throw("Invalid commission rate format");
299
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.01"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
300
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("2"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
301
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.1"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
302
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-0.1"); }).to.throw("Invalid commission rate format");
303
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-1"); }).to.throw("Invalid commission rate format");
304
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-0.01"); }).to.throw("Invalid commission rate format: -0.01");
305
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-0.000000000000000001"); }).to.throw("Invalid commission rate format");
306
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.00000000000000000001"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
307
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.5%"); }).to.throw("Invalid commission rate format");
308
+ chai_1.expect(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(" 0.5 extra"); }).to.throw("Invalid commission rate format");
309
+ return [2 /*return*/];
310
+ });
311
+ }); });
251
312
  });
@@ -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*/];
@@ -1,7 +1,7 @@
1
1
  import { FirmaConfig } from '../sdk/FirmaConfig';
2
2
  export declare let TestChainConfig: FirmaConfig;
3
3
  export declare const 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";
4
- export declare const 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";
4
+ export declare 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";
5
5
  export declare const 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";
6
6
  export declare const 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";
7
7
  export declare const 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";
@@ -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,7 +17,22 @@ 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
+ // DEVNET
21
+ // export const 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";
22
+ // TESTNET
23
+ // export const aliceMnemonic = "harvest galaxy sniff include record undo width oven tired sad month text museum curious firm mountain flash assault oval sand ribbon blouse consider lens";
24
+ // VALIDATOR
25
+ // export const aliceMnemonic = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
26
+ // export const aliceMnemonic = "owner pottery smile evolve pig base lady dismiss badge purchase divide royal medal buffalo miss carbon kiwi gate draft mouse yard reunion thank wage";
27
+ // export const aliceMnemonic = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
28
+ // voting test
29
+ // 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";
30
+ // export const aliceMnemonic = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
31
+ exports.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";
32
+ // 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";
33
+ // 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";
34
+ // 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";
35
+ // 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
36
  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
37
  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
38
  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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -41,6 +41,7 @@
41
41
  "@types/pako": "2.0.0",
42
42
  "axios": "0.27.2",
43
43
  "big-number": "2.0.0",
44
+ "bignumber.js": "^9.3.0",
44
45
  "cosmjs-types": "0.9.0",
45
46
  "crypto-js": "4.1.1",
46
47
  "fast-deep-equal": "^3.1.3",
@@ -50,6 +51,7 @@
50
51
  "readline-sync": "1.4.10"
51
52
  },
52
53
  "devDependencies": {
54
+ "@types/bignumber.js": "^4.0.0",
53
55
  "@types/chai": "4.2.21",
54
56
  "@types/mocha": "9.0.0",
55
57
  "@types/node": "16.4.3",