@firmachain/firma-js 0.3.7-beta1 → 0.3.7-beta3

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.
@@ -43,5 +43,10 @@ export declare class FirmaGovService {
43
43
  getParamAsGovParams(): Promise<GovParams>;
44
44
  getProposal(id: string): Promise<Proposal>;
45
45
  getProposalListByStatus(status: ProposalStatus): Promise<Proposal[]>;
46
- getProposalList(): Promise<Proposal[]>;
46
+ getProposalList(pagination?: {
47
+ offset?: number;
48
+ limit?: number;
49
+ reverse?: boolean;
50
+ }): Promise<Proposal[]>;
51
+ getAllProposalList(): Promise<Proposal[]>;
47
52
  }
@@ -35,6 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
38
63
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
65
  };
@@ -931,7 +956,7 @@ var FirmaGovService = /** @class */ (function () {
931
956
  });
932
957
  });
933
958
  };
934
- FirmaGovService.prototype.getProposalList = function () {
959
+ FirmaGovService.prototype.getProposalList = function (pagination) {
935
960
  return __awaiter(this, void 0, void 0, function () {
936
961
  var queryClient, result, error_30;
937
962
  return __generator(this, function (_a) {
@@ -939,7 +964,7 @@ var FirmaGovService = /** @class */ (function () {
939
964
  case 0:
940
965
  _a.trys.push([0, 2, , 3]);
941
966
  queryClient = new gov_1.GovQueryClient(this.config.restApiAddress);
942
- return [4 /*yield*/, queryClient.queryGetProposalList()];
967
+ return [4 /*yield*/, queryClient.queryGetProposalList(pagination)];
943
968
  case 1:
944
969
  result = _a.sent();
945
970
  return [2 /*return*/, result];
@@ -952,6 +977,39 @@ var FirmaGovService = /** @class */ (function () {
952
977
  });
953
978
  });
954
979
  };
980
+ FirmaGovService.prototype.getAllProposalList = function () {
981
+ return __awaiter(this, void 0, void 0, function () {
982
+ var allProposals, currentOffset, limit, proposals, error_31;
983
+ return __generator(this, function (_a) {
984
+ switch (_a.label) {
985
+ case 0:
986
+ _a.trys.push([0, 4, , 5]);
987
+ allProposals = [];
988
+ currentOffset = 0;
989
+ limit = 100;
990
+ _a.label = 1;
991
+ case 1:
992
+ if (!true) return [3 /*break*/, 3];
993
+ return [4 /*yield*/, this.getProposalList({ offset: currentOffset, limit: limit })];
994
+ case 2:
995
+ proposals = _a.sent();
996
+ if (proposals.length === 0)
997
+ return [3 /*break*/, 3];
998
+ allProposals = __spreadArray(__spreadArray([], __read(allProposals), false), __read(proposals), false);
999
+ if (proposals.length < limit)
1000
+ return [3 /*break*/, 3];
1001
+ currentOffset += limit;
1002
+ return [3 /*break*/, 1];
1003
+ case 3: return [2 /*return*/, allProposals];
1004
+ case 4:
1005
+ error_31 = _a.sent();
1006
+ FirmaUtil_1.FirmaUtil.printLog(error_31);
1007
+ throw error_31;
1008
+ case 5: return [2 /*return*/];
1009
+ }
1010
+ });
1011
+ });
1012
+ };
955
1013
  FirmaGovService.GOV_AUTHORITY = "firma10d07y265gmmuvt4z0w9aw880jnsr700j53mj8f";
956
1014
  return FirmaGovService;
957
1015
  }());
@@ -27,10 +27,10 @@ export interface GovParamType {
27
27
  min_deposit_ratio: string;
28
28
  }
29
29
  export interface CurrentVoteInfo {
30
- yes: string;
31
- abstain: string;
32
- no: string;
33
- no_with_veto: string;
30
+ yes_count: string;
31
+ abstain_count: string;
32
+ no_count: string;
33
+ no_with_veto_count: string;
34
34
  }
35
35
  export declare class GovQueryClient {
36
36
  private readonly axios;
@@ -40,7 +40,8 @@ export declare class GovQueryClient {
40
40
  queryGetProposal(id: string): Promise<Proposal>;
41
41
  queryGetProposalListByStatus(status: ProposalStatus): Promise<Proposal[]>;
42
42
  queryGetProposalList(pagination?: {
43
+ offset?: number;
43
44
  limit?: number;
44
- key?: string;
45
+ reverse?: boolean;
45
46
  }): Promise<Proposal[]>;
46
47
  }
@@ -1,15 +1,4 @@
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
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -133,12 +122,17 @@ var GovQueryClient = /** @class */ (function () {
133
122
  };
134
123
  GovQueryClient.prototype.queryGetProposalList = function (pagination) {
135
124
  return __awaiter(this, void 0, void 0, function () {
136
- var path, result;
125
+ var path, params, result;
137
126
  return __generator(this, function (_a) {
138
127
  switch (_a.label) {
139
128
  case 0:
140
129
  path = "/cosmos/gov/v1/proposals";
141
- return [4 /*yield*/, this.axios.get(path, { params: __assign({}, pagination) })];
130
+ params = {
131
+ "pagination.offset": pagination === null || pagination === void 0 ? void 0 : pagination.offset,
132
+ "pagination.limit": pagination === null || pagination === void 0 ? void 0 : pagination.limit,
133
+ "pagination.reverse": pagination === null || pagination === void 0 ? void 0 : pagination.reverse,
134
+ };
135
+ return [4 /*yield*/, this.axios.get(path, { params: params })];
142
136
  case 1:
143
137
  result = _a.sent();
144
138
  return [2 /*return*/, result.data.proposals];
@@ -48,14 +48,38 @@ describe('[17. Gov Query Test]', function () {
48
48
  it('get getProposalList', function () { return __awaiter(void 0, void 0, void 0, function () {
49
49
  var proposalList;
50
50
  return __generator(this, function (_a) {
51
- proposalList = [];
52
- if (proposalList.length > 0) {
53
- (0, chai_1.expect)(proposalList[0].id).to.not.equal('');
51
+ switch (_a.label) {
52
+ case 0: return [4 /*yield*/, firma.Gov.getProposalList({ reverse: true })];
53
+ case 1:
54
+ proposalList = _a.sent();
55
+ if (proposalList.length > 0) {
56
+ (0, chai_1.expect)(proposalList[0].id).to.not.equal('');
57
+ }
58
+ else {
59
+ (0, chai_1.expect)(proposalList).to.be.deep.equal([]);
60
+ }
61
+ return [2 /*return*/];
54
62
  }
55
- else {
56
- (0, chai_1.expect)(proposalList).to.be.deep.equal([]);
63
+ });
64
+ }); });
65
+ it('get getAllProposalList', function () { return __awaiter(void 0, void 0, void 0, function () {
66
+ var allProposals;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0: return [4 /*yield*/, firma.Gov.getAllProposalList()];
70
+ case 1:
71
+ allProposals = _a.sent();
72
+ // Check if proposals are properly ordered by ID
73
+ if (allProposals.length > 0) {
74
+ // Basic checks
75
+ (0, chai_1.expect)(allProposals[0].id).to.not.equal('');
76
+ (0, chai_1.expect)(allProposals.length).to.be.greaterThan(0);
77
+ }
78
+ else {
79
+ (0, chai_1.expect)(allProposals).to.be.deep.equal([]);
80
+ }
81
+ return [2 /*return*/];
57
82
  }
58
- return [2 /*return*/];
59
83
  });
60
84
  }); });
61
85
  it('get getProposalListByStatus', function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -1,11 +1,11 @@
1
1
  import { FirmaConfig } from '../sdk/FirmaConfig';
2
2
  export declare let TestChainConfig: FirmaConfig;
3
- export declare const validatorMnemonic = "uncle banana theme relax oak prosper volcano glad industry bicycle tower thrive jelly curious luggage frame that defy reason jewel figure begin nice moon";
4
- export declare const aliceMnemonic = "ozone unfold device pave lemon potato omit insect column wise cover hint narrow large provide kidney episode clay notable milk mention dizzy muffin crazy";
5
- export declare const bobMnemonic = "burst torch enemy quick crime slogan trust wood hamster way armor visual common language close park leg ill ball board couch nose theory must";
3
+ export declare const validatorMnemonic = "";
4
+ export declare const aliceMnemonic = "";
5
+ export declare const bobMnemonic = "";
6
6
  export declare const feeMnemonic = "";
7
7
  export declare const firmaFeeMnemonic = "";
8
- export declare const signerMnemonic1 = "owner pottery smile evolve pig base lady dismiss badge purchase divide royal medal buffalo miss carbon kiwi gate draft mouse yard reunion thank wage";
9
- export declare const signerMnemonic2 = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
10
- export declare const signerMnemonic3 = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
11
- export declare const signerMnemonic4 = "sand mule spice strike summer invite hybrid inner deputy truly cabin little fence smart erase roast gesture raccoon side love odor decorate action lunar";
8
+ export declare const signerMnemonic1 = "";
9
+ export declare const signerMnemonic2 = "";
10
+ export declare const signerMnemonic3 = "";
11
+ export declare const signerMnemonic4 = "";
@@ -1,44 +1,14 @@
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
- // TESTNET
5
- // export let TestChainConfig: FirmaConfig = FirmaConfig.TestNetConfig;
6
- // Validator 1
7
- // export const validatorMnemonic = "owner pottery smile evolve pig base lady dismiss badge purchase divide royal medal buffalo miss carbon kiwi gate draft mouse yard reunion thank wage";
8
- // Validator 2
9
- // export const validatorMnemonic = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
10
- // validator 3
11
- // export const validatorMnemonic = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
12
- // 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";
13
- // export const bobMnemonic = "certain bean eager measure crawl cliff innocent practice gas ladder board aspect fish link sweet raccoon staff long crumble skin special width click plastic";
14
- // export const feeMnemonic = "";
15
- // export const firmaFeeMnemonic = "";
16
- // export const signerMnemonic1 = "owner pottery smile evolve pig base lady dismiss badge purchase divide royal medal buffalo miss carbon kiwi gate draft mouse yard reunion thank wage";
17
- // export const signerMnemonic2 = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
18
- // export const signerMnemonic3 = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
19
- // export const signerMnemonic4 = "sand mule spice strike summer invite hybrid inner deputy truly cabin little fence smart erase roast gesture raccoon side love odor decorate action lunar";
20
- // DEVNET
21
- exports.TestChainConfig = {
22
- chainID: "roma-1",
23
- rpcAddress: "http://192.168.30.47:26657",
24
- restApiAddress: "http://192.168.30.47:1317",
25
- ipfsNodeAddress: "https://ipfs-dev.firmachain.dev",
26
- ipfsNodePort: 5001,
27
- ipfsWebApiAddress: "https://ipfs-dev.firmachain.dev",
28
- hdPath: "m/44'/7777777'/",
29
- prefix: "firma",
30
- denom: "ufct",
31
- defaultFee: 20000,
32
- defaultGas: 200000,
33
- isShowLog: true,
34
- };
35
- // Validator
36
- exports.validatorMnemonic = "uncle banana theme relax oak prosper volcano glad industry bicycle tower thrive jelly curious luggage frame that defy reason jewel figure begin nice moon";
37
- exports.aliceMnemonic = "ozone unfold device pave lemon potato omit insect column wise cover hint narrow large provide kidney episode clay notable milk mention dizzy muffin crazy";
38
- exports.bobMnemonic = "burst torch enemy quick crime slogan trust wood hamster way armor visual common language close park leg ill ball board couch nose theory must";
4
+ var FirmaConfig_1 = require("../sdk/FirmaConfig");
5
+ exports.TestChainConfig = FirmaConfig_1.FirmaConfig.TestNetConfig;
6
+ exports.validatorMnemonic = "";
7
+ exports.aliceMnemonic = "";
8
+ exports.bobMnemonic = "";
39
9
  exports.feeMnemonic = "";
40
10
  exports.firmaFeeMnemonic = "";
41
- exports.signerMnemonic1 = "owner pottery smile evolve pig base lady dismiss badge purchase divide royal medal buffalo miss carbon kiwi gate draft mouse yard reunion thank wage";
42
- exports.signerMnemonic2 = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
43
- exports.signerMnemonic3 = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
44
- exports.signerMnemonic4 = "sand mule spice strike summer invite hybrid inner deputy truly cabin little fence smart erase roast gesture raccoon side love odor decorate action lunar";
11
+ exports.signerMnemonic1 = "";
12
+ exports.signerMnemonic2 = "";
13
+ exports.signerMnemonic3 = "";
14
+ exports.signerMnemonic4 = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.3.7-beta1",
3
+ "version": "0.3.7-beta3",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",