@firmachain/firma-js 0.3.7-beta2 → 0.3.7
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/dist/sdk/FirmaGovService.d.ts +6 -1
- package/dist/sdk/FirmaGovService.js +60 -2
- package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +2 -1
- package/dist/sdk/firmachain/gov/GovQueryClient.js +7 -13
- package/dist/test/16.gov_tx.test.js +8 -6
- package/dist/test/17.gov_query.test.js +30 -6
- package/dist/test/config_test.d.ts +5 -7
- package/dist/test/config_test.js +6 -39
- package/package.json +1 -1
|
@@ -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(
|
|
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
|
}());
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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];
|
|
@@ -258,7 +258,7 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
258
258
|
});
|
|
259
259
|
}); });
|
|
260
260
|
// TODO: get recent gov proposal list and then set proposalId for below case
|
|
261
|
-
var tempProposalId =
|
|
261
|
+
var tempProposalId = 420;
|
|
262
262
|
// more deposit after initial deposit case
|
|
263
263
|
it.skip('Deposit OK', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
264
264
|
var proposalId, amount, result;
|
|
@@ -275,16 +275,18 @@ describe('[16. Gov Tx Test]', function () {
|
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
277
|
}); });
|
|
278
|
-
it
|
|
279
|
-
var proposalId,
|
|
278
|
+
it('Vote - alice YES', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
279
|
+
var proposalId, validatorWallet3;
|
|
280
280
|
return __generator(this, function (_a) {
|
|
281
281
|
switch (_a.label) {
|
|
282
282
|
case 0:
|
|
283
283
|
proposalId = tempProposalId;
|
|
284
|
-
return [4 /*yield*/, firma.
|
|
284
|
+
return [4 /*yield*/, firma.Wallet.fromMnemonic("main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive")];
|
|
285
285
|
case 1:
|
|
286
|
-
|
|
287
|
-
(
|
|
286
|
+
validatorWallet3 = _a.sent();
|
|
287
|
+
return [4 /*yield*/, firma.Gov.vote(validatorWallet3, proposalId, common_1.VotingOption.VOTE_OPTION_NO_WITH_VETO)];
|
|
288
|
+
case 2:
|
|
289
|
+
_a.sent();
|
|
288
290
|
return [2 /*return*/];
|
|
289
291
|
}
|
|
290
292
|
});
|
|
@@ -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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
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,13 +1,11 @@
|
|
|
1
1
|
import { FirmaConfig } from '../sdk/FirmaConfig';
|
|
2
2
|
export declare let TestChainConfig: FirmaConfig;
|
|
3
|
-
export declare const validatorMnemonic = "
|
|
4
|
-
export declare const validatorMnemonic2 = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
|
|
5
|
-
export declare const validatorMnemonic3 = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
|
|
3
|
+
export declare 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";
|
|
6
4
|
export declare 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";
|
|
7
5
|
export declare 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";
|
|
8
6
|
export declare const feeMnemonic = "";
|
|
9
7
|
export declare const firmaFeeMnemonic = "";
|
|
10
|
-
export declare const signerMnemonic1 = "
|
|
11
|
-
export declare const signerMnemonic2 = "
|
|
12
|
-
export declare const signerMnemonic3 = "
|
|
13
|
-
export declare const signerMnemonic4 = "
|
|
8
|
+
export declare const signerMnemonic1 = "";
|
|
9
|
+
export declare const signerMnemonic2 = "";
|
|
10
|
+
export declare const signerMnemonic3 = "";
|
|
11
|
+
export declare const signerMnemonic4 = "";
|
package/dist/test/config_test.js
CHANGED
|
@@ -1,47 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signerMnemonic4 = exports.signerMnemonic3 = exports.signerMnemonic2 = exports.signerMnemonic1 = exports.firmaFeeMnemonic = exports.feeMnemonic = exports.bobMnemonic = exports.aliceMnemonic = exports.
|
|
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
|
-
// TESTNET
|
|
6
5
|
exports.TestChainConfig = FirmaConfig_1.FirmaConfig.TestNetConfig;
|
|
7
|
-
|
|
8
|
-
exports.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";
|
|
9
|
-
// Validator 2
|
|
10
|
-
exports.validatorMnemonic2 = "clump erupt type lucky mask pig soup runway wrestle suspect element involve stamp civil auction resource blame same journey start unaware crush ten draw";
|
|
11
|
-
// validator 3
|
|
12
|
-
exports.validatorMnemonic3 = "main shallow liberty desk super palm remind throw track legal warrior client garbage type insect first token keen subway pony curtain pitch yellow arrive";
|
|
6
|
+
exports.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";
|
|
13
7
|
exports.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";
|
|
14
8
|
exports.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";
|
|
15
9
|
exports.feeMnemonic = "";
|
|
16
10
|
exports.firmaFeeMnemonic = "";
|
|
17
|
-
exports.signerMnemonic1 = "
|
|
18
|
-
exports.signerMnemonic2 = "
|
|
19
|
-
exports.signerMnemonic3 = "
|
|
20
|
-
exports.signerMnemonic4 = "
|
|
21
|
-
/*
|
|
22
|
-
// DEVNET
|
|
23
|
-
export let TestChainConfig: FirmaConfig = {
|
|
24
|
-
chainID: "roma-1",
|
|
25
|
-
rpcAddress: "http://192.168.30.47:26657",
|
|
26
|
-
restApiAddress: "http://192.168.30.47:1317",
|
|
27
|
-
ipfsNodeAddress: "https://ipfs-dev.firmachain.dev",
|
|
28
|
-
ipfsNodePort: 5001,
|
|
29
|
-
ipfsWebApiAddress: "https://ipfs-dev.firmachain.dev",
|
|
30
|
-
hdPath: "m/44'/7777777'/",
|
|
31
|
-
prefix: "firma",
|
|
32
|
-
denom: "ufct",
|
|
33
|
-
defaultFee: 20000,
|
|
34
|
-
defaultGas: 200000,
|
|
35
|
-
isShowLog: true,
|
|
36
|
-
};
|
|
37
|
-
// Validator
|
|
38
|
-
export 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";
|
|
39
|
-
export 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";
|
|
40
|
-
export 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";
|
|
41
|
-
export const feeMnemonic = "";
|
|
42
|
-
export const firmaFeeMnemonic = "";
|
|
43
|
-
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";
|
|
44
|
-
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";
|
|
45
|
-
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";
|
|
46
|
-
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";
|
|
47
|
-
*/
|
|
11
|
+
exports.signerMnemonic1 = "";
|
|
12
|
+
exports.signerMnemonic2 = "";
|
|
13
|
+
exports.signerMnemonic3 = "";
|
|
14
|
+
exports.signerMnemonic4 = "";
|