@firmachain/firma-js 0.2.62 → 0.3.0-beta1
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 +4 -1
- package/dist/sdk/FirmaAuthzService.d.ts +8 -8
- package/dist/sdk/FirmaAuthzService.js +12 -6
- package/dist/sdk/FirmaBankService.d.ts +4 -4
- package/dist/sdk/FirmaContractService.d.ts +4 -4
- package/dist/sdk/FirmaCosmWasmCw20.d.ts +14 -14
- package/dist/sdk/FirmaCosmWasmCw721.d.ts +31 -13
- package/dist/sdk/FirmaCosmWasmCw721.js +25 -0
- package/dist/sdk/FirmaCosmWasmCwBridge.d.ts +9 -9
- package/dist/sdk/FirmaCosmWasmCwMarketplace.d.ts +8 -8
- package/dist/sdk/FirmaCosmWasmService.d.ts +8 -8
- package/dist/sdk/FirmaCosmWasmService.js +2 -3
- package/dist/sdk/FirmaDistributionService.d.ts +6 -6
- package/dist/sdk/FirmaFeeGrantService.d.ts +4 -4
- package/dist/sdk/FirmaGovService.d.ts +12 -9
- package/dist/sdk/FirmaGovService.js +162 -97
- package/dist/sdk/FirmaIbcService.d.ts +3 -4
- package/dist/sdk/FirmaIbcService.js +5 -2
- package/dist/sdk/FirmaNftService.d.ts +5 -5
- package/dist/sdk/FirmaStakingService.d.ts +6 -6
- package/dist/sdk/FirmaTokenService.d.ts +5 -5
- package/dist/sdk/FirmaUtil.d.ts +1 -1
- package/dist/sdk/FirmaUtil.js +12 -14
- package/dist/sdk/firmachain/amino/addresses.js +1 -1
- package/dist/sdk/firmachain/amino/aminomsgs.d.ts +10 -0
- package/dist/sdk/firmachain/amino/aminomsgs.js +5 -1
- package/dist/sdk/firmachain/amino/aminotypes.js +27 -10
- package/dist/sdk/firmachain/amino/coins.d.ts +14 -2
- package/dist/sdk/firmachain/amino/coins.js +26 -5
- package/dist/sdk/firmachain/amino/encoding.d.ts +10 -1
- package/dist/sdk/firmachain/amino/encoding.js +21 -3
- package/dist/sdk/firmachain/amino/signdoc.d.ts +21 -3
- package/dist/sdk/firmachain/amino/signdoc.js +37 -11
- package/dist/sdk/firmachain/amino/signer.d.ts +2 -1
- package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +7 -6
- package/dist/sdk/firmachain/authz/AuthzTxTypes.js +7 -6
- package/dist/sdk/firmachain/bank/BankQueryClient.js +1 -1
- package/dist/sdk/firmachain/common/CommonTxClient.js +11 -9
- package/dist/sdk/firmachain/common/ITxClient.d.ts +6 -6
- package/dist/sdk/firmachain/common/ITxClient.js +82 -24
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +4 -9
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +37 -32
- package/dist/sdk/firmachain/common/LedgerWallet.js +4 -8
- package/dist/sdk/firmachain/common/TxCommon.d.ts +1 -2
- package/dist/sdk/firmachain/common/accounts.d.ts +7 -3
- package/dist/sdk/firmachain/common/accounts.js +28 -33
- package/dist/sdk/firmachain/common/aminotypes.d.ts +19 -0
- package/dist/sdk/firmachain/common/aminotypes.js +74 -0
- package/dist/sdk/firmachain/common/events.d.ts +32 -0
- package/dist/sdk/firmachain/common/events.js +18 -0
- package/dist/sdk/firmachain/common/fee.d.ts +26 -0
- package/dist/sdk/firmachain/common/fee.js +83 -0
- package/dist/sdk/firmachain/common/index.d.ts +1 -0
- package/dist/sdk/firmachain/common/index.js +3 -0
- package/dist/sdk/firmachain/common/modules/auth/queries.d.ts +15 -0
- package/dist/sdk/firmachain/common/modules/auth/queries.js +64 -0
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.js +15 -0
- package/dist/sdk/firmachain/common/modules/authz/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/authz/messages.js +9 -0
- package/dist/sdk/firmachain/common/modules/authz/queries.d.ts +10 -0
- package/dist/sdk/firmachain/common/modules/authz/queries.js +88 -0
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.d.ts +35 -0
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.js +85 -0
- package/dist/sdk/firmachain/common/modules/bank/messages.d.ts +8 -0
- package/dist/sdk/firmachain/common/modules/bank/messages.js +12 -0
- package/dist/sdk/firmachain/common/modules/bank/queries.d.ts +15 -0
- package/dist/sdk/firmachain/common/modules/bank/queries.js +128 -0
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.d.ts +14 -0
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.js +11 -0
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.d.ts +44 -0
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.js +113 -0
- package/dist/sdk/firmachain/common/modules/distribution/messages.d.ts +8 -0
- package/dist/sdk/firmachain/common/modules/distribution/messages.js +15 -0
- package/dist/sdk/firmachain/common/modules/distribution/queries.d.ts +16 -0
- package/dist/sdk/firmachain/common/modules/distribution/queries.js +171 -0
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.d.ts +18 -0
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.js +11 -0
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.js +14 -0
- package/dist/sdk/firmachain/common/modules/feegrant/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/feegrant/messages.js +8 -0
- package/dist/sdk/firmachain/common/modules/feegrant/queries.d.ts +9 -0
- package/dist/sdk/firmachain/common/modules/feegrant/queries.js +81 -0
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.d.ts +79 -0
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.js +152 -0
- package/dist/sdk/firmachain/common/modules/gov/messages.d.ts +29 -0
- package/dist/sdk/firmachain/common/modules/gov/messages.js +38 -0
- package/dist/sdk/firmachain/common/modules/gov/queries.d.ts +19 -0
- package/dist/sdk/firmachain/common/modules/gov/queries.js +160 -0
- package/dist/sdk/firmachain/common/modules/group/aminomessages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/group/aminomessages.js +8 -0
- package/dist/sdk/firmachain/common/modules/group/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/group/messages.js +28 -0
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.d.ts +38 -0
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.js +55 -0
- package/dist/sdk/firmachain/common/modules/ibc/messages.d.ts +8 -0
- package/dist/sdk/firmachain/common/modules/ibc/messages.js +32 -0
- package/dist/sdk/firmachain/common/modules/ibc/queries.d.ts +58 -0
- package/dist/sdk/firmachain/common/modules/ibc/queries.js +576 -0
- package/dist/sdk/firmachain/common/modules/index.d.ts +32 -0
- package/dist/sdk/firmachain/common/modules/index.js +101 -0
- package/dist/sdk/firmachain/common/modules/mint/queries.d.ts +21 -0
- package/dist/sdk/firmachain/common/modules/mint/queries.js +95 -0
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.d.ts +12 -0
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.js +11 -0
- package/dist/sdk/firmachain/common/modules/slashing/queries.d.ts +10 -0
- package/dist/sdk/firmachain/common/modules/slashing/queries.js +88 -0
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.d.ts +112 -0
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.js +234 -0
- package/dist/sdk/firmachain/common/modules/staking/messages.d.ts +33 -0
- package/dist/sdk/firmachain/common/modules/staking/messages.js +37 -0
- package/dist/sdk/firmachain/common/modules/staking/queries.d.ts +23 -0
- package/dist/sdk/firmachain/common/modules/staking/queries.js +242 -0
- package/dist/sdk/firmachain/common/modules/tx/queries.d.ts +11 -0
- package/dist/sdk/firmachain/common/modules/tx/queries.js +103 -0
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.d.ts +16 -0
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.js +56 -0
- package/dist/sdk/firmachain/common/modules/vesting/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/vesting/messages.js +7 -0
- package/dist/sdk/firmachain/common/queryclient/index.d.ts +2 -0
- package/dist/sdk/firmachain/common/queryclient/index.js +10 -0
- package/dist/sdk/firmachain/common/queryclient/queryclient.d.ts +75 -0
- package/dist/sdk/firmachain/common/queryclient/queryclient.js +157 -0
- package/dist/sdk/firmachain/common/queryclient/utils.d.ts +33 -0
- package/dist/sdk/firmachain/common/queryclient/utils.js +101 -0
- package/dist/sdk/firmachain/common/search.d.ts +10 -0
- package/dist/sdk/firmachain/common/search.js +7 -0
- package/dist/sdk/firmachain/common/signing.d.ts +8 -3
- package/dist/sdk/firmachain/common/signing.js +24 -12
- package/dist/sdk/firmachain/common/signingstargateclient.d.ts +107 -30
- package/dist/sdk/firmachain/common/signingstargateclient.js +445 -128
- package/dist/sdk/firmachain/common/stargateclient.d.ts +184 -20
- package/dist/sdk/firmachain/common/stargateclient.js +351 -35
- package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +2 -2
- package/dist/sdk/firmachain/contract/ContractTxClient.js +4 -4
- package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +1 -1
- package/dist/sdk/firmachain/contract/ContractTxTypes.js +3 -3
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +1 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +5 -5
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +10 -8
- package/dist/sdk/firmachain/google/protobuf/any.d.ts +3 -2
- package/dist/sdk/firmachain/google/protobuf/any.js +2 -1
- package/dist/sdk/firmachain/google/protobuf/duration.d.ts +3 -2
- package/dist/sdk/firmachain/google/protobuf/duration.js +2 -1
- package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +3 -2
- package/dist/sdk/firmachain/google/protobuf/timestamp.js +2 -1
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +6 -0
- package/dist/sdk/firmachain/gov/GovTxClient.js +6 -1
- package/dist/sdk/firmachain/nft/NftTxClient.d.ts +3 -3
- package/dist/sdk/firmachain/nft/NftTxClient.js +6 -6
- package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +1 -1
- package/dist/sdk/firmachain/nft/NftTxTypes.js +4 -4
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +0 -1
- package/dist/sdk/firmachain/token/TokenTxClient.d.ts +4 -4
- package/dist/sdk/firmachain/token/TokenTxClient.js +8 -8
- package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +1 -1
- package/dist/sdk/firmachain/token/TokenTxTypes.js +5 -5
- package/dist/test/00.wallet.test.d.ts +1 -0
- package/dist/test/00.wallet.test.js +96 -0
- package/dist/test/01.contract_tx.test.d.ts +1 -0
- package/dist/test/01.contract_tx.test.js +157 -0
- package/dist/test/02.contract_query.test.d.ts +1 -0
- package/dist/test/02.contract_query.test.js +245 -0
- package/dist/test/03.contract_scenario.test.d.ts +1 -0
- package/dist/test/03.contract_scenario.test.js +406 -0
- package/dist/test/04.bank_tx.test.d.ts +1 -0
- package/dist/test/04.bank_tx.test.js +126 -0
- package/dist/test/05.bank_query.test.d.ts +1 -0
- package/dist/test/05.bank_query.test.js +162 -0
- package/dist/test/06.feegrant_tx.test.d.ts +1 -0
- package/dist/test/06.feegrant_tx.test.js +161 -0
- package/dist/test/07.feegrant_query.test.d.ts +1 -0
- package/dist/test/07.feegrant_query.test.js +126 -0
- package/dist/test/08.gas_estimate.test.d.ts +1 -0
- package/dist/test/08.gas_estimate.test.js +675 -0
- package/dist/test/09.ipfs.test.d.ts +1 -0
- package/dist/test/09.ipfs.test.js +72 -0
- package/dist/test/10.nft_tx.test.d.ts +1 -0
- package/dist/test/10.nft_tx.test.js +209 -0
- package/dist/test/11.nft_query.test.d.ts +1 -0
- package/dist/test/11.nft_query.test.js +165 -0
- package/dist/test/12.staking_tx.test.d.ts +1 -0
- package/dist/test/12.staking_tx.test.js +199 -0
- package/dist/test/13.staking_query.test.d.ts +1 -0
- package/dist/test/13.staking_query.test.js +263 -0
- package/dist/test/14.distribution_tx.test.d.ts +1 -0
- package/dist/test/14.distribution_tx.test.js +170 -0
- package/dist/test/15.distribution_query.test.d.ts +1 -0
- package/dist/test/15.distribution_query.test.js +243 -0
- package/dist/test/16.gov_tx.test.d.ts +1 -0
- package/dist/test/16.gov_tx.test.js +311 -0
- package/dist/test/17.gov_query.test.d.ts +1 -0
- package/dist/test/17.gov_query.test.js +157 -0
- package/dist/test/18.util.test.d.ts +1 -0
- package/dist/test/18.util.test.js +251 -0
- package/dist/test/19.chain.test.d.ts +1 -0
- package/dist/test/19.chain.test.js +127 -0
- package/dist/test/20.slashing_query.test.d.ts +1 -0
- package/dist/test/20.slashing_query.test.js +112 -0
- package/dist/test/21.token_tx.test.d.ts +1 -0
- package/dist/test/21.token_tx.test.js +149 -0
- package/dist/test/22.token_query.test.d.ts +1 -0
- package/dist/test/22.token_query.test.js +103 -0
- package/dist/test/23.authz_tx.test.d.ts +1 -0
- package/dist/test/23.authz_tx.test.js +350 -0
- package/dist/test/24.authz_query.test.d.ts +1 -0
- package/dist/test/24.authz_query.test.js +203 -0
- package/dist/test/25.cosmwasm_tx.test.d.ts +1 -0
- package/dist/test/25.cosmwasm_tx.test.js +229 -0
- package/dist/test/26.cosmwasm_query.test.d.ts +1 -0
- package/dist/test/26.cosmwasm_query.test.js +209 -0
- package/dist/test/27.arbitary_sign.test.d.ts +1 -0
- package/dist/test/27.arbitary_sign.test.js +159 -0
- package/dist/test/28.ibc_tx.test.d.ts +1 -0
- package/dist/test/28.ibc_tx.test.js +98 -0
- package/dist/test/29.mint_query.test.d.ts +1 -0
- package/dist/test/29.mint_query.test.js +59 -0
- package/dist/test/30.cw20_tx.test.d.ts +1 -0
- package/dist/test/30.cw20_tx.test.js +450 -0
- package/dist/test/31.cw20_query.test.d.ts +1 -0
- package/dist/test/31.cw20_query.test.js +333 -0
- package/dist/test/32.cw721_tx.test.d.ts +1 -0
- package/dist/test/32.cw721_tx.test.js +431 -0
- package/dist/test/33.cw721_query.test.d.ts +1 -0
- package/dist/test/33.cw721_query.test.js +371 -0
- package/dist/test/34.cw_bridge_tx.test.d.ts +1 -0
- package/dist/test/34.cw_bridge_tx.test.js +476 -0
- package/dist/test/35.cw_bridge_tx_low.test.d.ts +1 -0
- package/dist/test/35.cw_bridge_tx_low.test.js +398 -0
- package/dist/test/36.cw_bridge_query.test.d.ts +1 -0
- package/dist/test/36.cw_bridge_query.test.js +318 -0
- package/dist/test/37.cw_marketplace_tx.test.d.ts +1 -0
- package/dist/test/37.cw_marketplace_tx.test.js +794 -0
- package/dist/test/38.cw_marketplace_query.test.d.ts +1 -0
- package/dist/test/38.cw_marketplace_query.test.js +128 -0
- package/dist/test/config_test.d.ts +11 -0
- package/dist/test/config_test.js +29 -0
- package/dist/test/config_test.sample.d.ts +5 -0
- package/dist/test/config_test.sample.js +8 -0
- package/package.json +9 -7
- package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +0 -50
- package/dist/sdk/firmachain/common/signingaminostargateclient.js +0 -267
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var chai_1 = require("chai");
|
|
40
|
+
var gov_1 = require("../sdk/firmachain/gov");
|
|
41
|
+
var FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
42
|
+
var config_test_1 = require("./config_test");
|
|
43
|
+
describe('[17. Gov Query Test]', function () {
|
|
44
|
+
var firma;
|
|
45
|
+
beforeEach(function () {
|
|
46
|
+
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
47
|
+
});
|
|
48
|
+
it('get getProposalList', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
var proposalList;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
proposalList = [];
|
|
52
|
+
if (proposalList.length > 0) {
|
|
53
|
+
chai_1.expect(proposalList[0].proposal_id).to.not.equal('');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
chai_1.expect(proposalList).to.be.deep.equal([]);
|
|
57
|
+
}
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
});
|
|
60
|
+
}); });
|
|
61
|
+
it('get getProposalListByStatus', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
+
var status, proposalList;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
status = gov_1.ProposalStatus.PROPOSAL_STATUS_REJECTED;
|
|
67
|
+
return [4 /*yield*/, firma.Gov.getProposalListByStatus(status)];
|
|
68
|
+
case 1:
|
|
69
|
+
proposalList = _a.sent();
|
|
70
|
+
chai_1.expect(proposalList).to.be.an('array');
|
|
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('');
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
chai_1.expect(proposalList).to.have.lengthOf(0);
|
|
77
|
+
}
|
|
78
|
+
return [2 /*return*/];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}); });
|
|
82
|
+
it('get getProposal', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var proposalList, id, proposal;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
|
|
87
|
+
case 1:
|
|
88
|
+
proposalList = _a.sent();
|
|
89
|
+
if (!(proposalList.length > 0)) return [3 /*break*/, 3];
|
|
90
|
+
id = "1";
|
|
91
|
+
return [4 /*yield*/, firma.Gov.getProposal(id)];
|
|
92
|
+
case 2:
|
|
93
|
+
proposal = _a.sent();
|
|
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);
|
|
97
|
+
return [3 /*break*/, 4];
|
|
98
|
+
case 3:
|
|
99
|
+
chai_1.expect(proposalList).to.have.lengthOf(0);
|
|
100
|
+
_a.label = 4;
|
|
101
|
+
case 4: return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); });
|
|
105
|
+
// integrated function with params/voting, params/deposit, params/tallying
|
|
106
|
+
it('get params', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var param;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0: return [4 /*yield*/, firma.Gov.getParam()];
|
|
111
|
+
case 1:
|
|
112
|
+
param = _a.sent();
|
|
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');
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}); });
|
|
131
|
+
// current tally info
|
|
132
|
+
it('get getCurrentVoteInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
+
var proposalList, proposalId, param;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
|
|
137
|
+
case 1:
|
|
138
|
+
proposalList = _a.sent();
|
|
139
|
+
if (!(proposalList.length > 0)) return [3 /*break*/, 3];
|
|
140
|
+
proposalId = "1";
|
|
141
|
+
return [4 /*yield*/, firma.Gov.getCurrentVoteInfo(proposalId)];
|
|
142
|
+
case 2:
|
|
143
|
+
param = _a.sent();
|
|
144
|
+
chai_1.expect(param).to.be.an('object');
|
|
145
|
+
chai_1.expect(param).to.have.property('yes');
|
|
146
|
+
chai_1.expect(param).to.have.property('abstain');
|
|
147
|
+
chai_1.expect(param).to.have.property('no');
|
|
148
|
+
chai_1.expect(param).to.have.property('no_with_veto');
|
|
149
|
+
return [3 /*break*/, 4];
|
|
150
|
+
case 3:
|
|
151
|
+
chai_1.expect(proposalList).to.have.lengthOf(0);
|
|
152
|
+
_a.label = 4;
|
|
153
|
+
case 4: return [2 /*return*/];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}); });
|
|
157
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var chai_1 = require("chai");
|
|
40
|
+
var FirmaUtil_1 = require("../sdk/FirmaUtil");
|
|
41
|
+
var FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
42
|
+
var config_test_1 = require("./config_test");
|
|
43
|
+
describe('[18. util Test]', function () {
|
|
44
|
+
var firma;
|
|
45
|
+
beforeEach(function () {
|
|
46
|
+
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
47
|
+
});
|
|
48
|
+
// getHashFromString
|
|
49
|
+
it('getSha1HashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
var contractName, result;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
contractName = "testContract1234";
|
|
53
|
+
result = FirmaUtil_1.FirmaUtil.getSha1HashFromString(contractName);
|
|
54
|
+
chai_1.expect(result).to.be.equal("c88753a797d1310b36673e3494005bc7485746b7");
|
|
55
|
+
return [2 /*return*/];
|
|
56
|
+
});
|
|
57
|
+
}); });
|
|
58
|
+
it('getHashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
+
var contractName, result;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
contractName = "testContract1234";
|
|
62
|
+
result = FirmaUtil_1.FirmaUtil.getHashFromString(contractName);
|
|
63
|
+
chai_1.expect(result).to.be.equal("95e55f6b55ccf6b3988a6f9ee6d9c3c0011ea93a2489e7f05d10cada2613c17f");
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
});
|
|
66
|
+
}); });
|
|
67
|
+
it('isValidAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
+
var validAddress, wrongAddress1, wrongAddress2, result;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
validAddress = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsa";
|
|
71
|
+
wrongAddress1 = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsb";
|
|
72
|
+
wrongAddress2 = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsa1";
|
|
73
|
+
result = FirmaUtil_1.FirmaUtil.isValidAddress(validAddress);
|
|
74
|
+
chai_1.expect(result).to.be.equal(true);
|
|
75
|
+
result = FirmaUtil_1.FirmaUtil.isValidAddress(wrongAddress1);
|
|
76
|
+
chai_1.expect(result).to.be.equal(false);
|
|
77
|
+
result = FirmaUtil_1.FirmaUtil.isValidAddress(wrongAddress2);
|
|
78
|
+
chai_1.expect(result).to.be.equal(false);
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
});
|
|
81
|
+
}); });
|
|
82
|
+
it('getValOperAddressFromAccAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var accAddress, valoperAddress, result;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
accAddress = "firma1a85hxs97rxsrf0yzdn72vhfu39sa0dwxv90ghy";
|
|
86
|
+
valoperAddress = "firmavaloper1a85hxs97rxsrf0yzdn72vhfu39sa0dwxjkynh2";
|
|
87
|
+
result = FirmaUtil_1.FirmaUtil.getValOperAddressFromAccAddress(accAddress);
|
|
88
|
+
chai_1.expect(result).to.be.equal(valoperAddress);
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
});
|
|
91
|
+
}); });
|
|
92
|
+
it('getValConsAddressFromConsensusPubKey test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var consensusPubkey, valconsAddress, result;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
consensusPubkey = "InWhZBMP3wKQkwIBCrVqQ+BNoPhV5mTjpwiYHKHCZ/k=";
|
|
96
|
+
valconsAddress = "firmavalcons1fh73gr3f9df7yc390ykdnmeedetlw5ll3dqwje";
|
|
97
|
+
result = FirmaUtil_1.FirmaUtil.getValConsAddressFromAccAddress(consensusPubkey);
|
|
98
|
+
chai_1.expect(result).to.be.equal(valconsAddress);
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
});
|
|
101
|
+
}); });
|
|
102
|
+
it('getAccAddressFromValOperAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
+
var accAddress, valoperAddress, result;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
accAddress = "firma1a85hxs97rxsrf0yzdn72vhfu39sa0dwxv90ghy";
|
|
106
|
+
valoperAddress = "firmavaloper1a85hxs97rxsrf0yzdn72vhfu39sa0dwxjkynh2";
|
|
107
|
+
result = FirmaUtil_1.FirmaUtil.getAccAddressFromValOperAddress(valoperAddress);
|
|
108
|
+
chai_1.expect(result).to.be.equal(accAddress);
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
});
|
|
111
|
+
}); });
|
|
112
|
+
it('getFCTFromUFCTString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
+
var amountUFCT, fct;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
amountUFCT = 1000000;
|
|
116
|
+
fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCT(amountUFCT);
|
|
117
|
+
chai_1.expect(fct).to.be.equal("1");
|
|
118
|
+
amountUFCT = 1234000;
|
|
119
|
+
fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCT(amountUFCT);
|
|
120
|
+
chai_1.expect(fct).to.be.equal("1.234");
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
});
|
|
123
|
+
}); });
|
|
124
|
+
it('getUFCTStringFromFCT test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
+
var amountUFCT, fct;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
amountUFCT = 1;
|
|
128
|
+
fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountUFCT);
|
|
129
|
+
chai_1.expect(fct).to.be.equal("1000000");
|
|
130
|
+
amountUFCT = 1.23;
|
|
131
|
+
fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountUFCT);
|
|
132
|
+
chai_1.expect(fct).to.be.equal("1230000");
|
|
133
|
+
return [2 /*return*/];
|
|
134
|
+
});
|
|
135
|
+
}); });
|
|
136
|
+
it('getFCTFromUFCTString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
137
|
+
var amountUFCT, fct;
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
amountUFCT = "1000000";
|
|
140
|
+
fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCTStr(amountUFCT);
|
|
141
|
+
chai_1.expect(fct).to.be.equal("1");
|
|
142
|
+
amountUFCT = "1234000";
|
|
143
|
+
fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCTStr(amountUFCT);
|
|
144
|
+
chai_1.expect(fct).to.be.equal("1.234");
|
|
145
|
+
return [2 /*return*/];
|
|
146
|
+
});
|
|
147
|
+
}); });
|
|
148
|
+
it('getUFCTStringFromFCT test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
+
var amountUFCT, fct;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
amountUFCT = "1";
|
|
152
|
+
fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUFCT);
|
|
153
|
+
chai_1.expect(fct).to.be.equal("1000000");
|
|
154
|
+
amountUFCT = "1.23";
|
|
155
|
+
fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUFCT);
|
|
156
|
+
chai_1.expect(fct).to.be.equal("1230000");
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
});
|
|
159
|
+
}); });
|
|
160
|
+
it('getTokenFromUTokenString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
|
+
var decimal, amountUToken, token;
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
decimal = 6;
|
|
164
|
+
amountUToken = 1000000;
|
|
165
|
+
token = FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(amountUToken, decimal);
|
|
166
|
+
chai_1.expect(token).to.be.equal("1");
|
|
167
|
+
amountUToken = 1234000;
|
|
168
|
+
token = FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(amountUToken, decimal);
|
|
169
|
+
chai_1.expect(token).to.be.equal("1.234");
|
|
170
|
+
return [2 /*return*/];
|
|
171
|
+
});
|
|
172
|
+
}); });
|
|
173
|
+
it('getUTokenStringFromToken test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var decimal, amountUToken, token;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
decimal = 6;
|
|
177
|
+
amountUToken = 1;
|
|
178
|
+
token = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amountUToken, decimal);
|
|
179
|
+
chai_1.expect(token).to.be.equal("1000000");
|
|
180
|
+
amountUToken = 1.23;
|
|
181
|
+
token = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amountUToken, decimal);
|
|
182
|
+
chai_1.expect(token).to.be.equal("1230000");
|
|
183
|
+
return [2 /*return*/];
|
|
184
|
+
});
|
|
185
|
+
}); });
|
|
186
|
+
it('cutting the ufct decimal point test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
+
var decimal, testUTokenValue, testUTokenValueStr, testTokenValueStr;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
decimal = 6;
|
|
190
|
+
testUTokenValue = 533.827284;
|
|
191
|
+
testUTokenValueStr = "533.827284";
|
|
192
|
+
testTokenValueStr = "0.000533";
|
|
193
|
+
chai_1.expect(FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(testUTokenValueStr, decimal)).to.be.equal(testTokenValueStr);
|
|
194
|
+
chai_1.expect(FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(testUTokenValue, decimal)).to.be.equal(testTokenValueStr);
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
});
|
|
197
|
+
}); });
|
|
198
|
+
it('cutting the decimal point test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
+
var decimal, testTokenValue, testTokenValueStr, testUTokenValue, testUTokenValueStr;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
decimal = 6;
|
|
202
|
+
testTokenValue = 533.827284;
|
|
203
|
+
testTokenValueStr = "533.827284";
|
|
204
|
+
testUTokenValue = 533827284;
|
|
205
|
+
testUTokenValueStr = "533827284";
|
|
206
|
+
chai_1.expect(FirmaUtil_1.FirmaUtil.getUTokenFromToken(testTokenValue, decimal)).to.be.equal(testUTokenValue);
|
|
207
|
+
chai_1.expect(FirmaUtil_1.FirmaUtil.getUTokenStringFromTokenStr(testTokenValueStr, decimal)).to.be.equal(testUTokenValueStr);
|
|
208
|
+
chai_1.expect(FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(testUTokenValueStr, decimal)).to.be.equal(testTokenValueStr);
|
|
209
|
+
chai_1.expect(FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(testUTokenValue, decimal)).to.be.equal(testTokenValueStr);
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
});
|
|
212
|
+
}); });
|
|
213
|
+
it('getTokenFromUTokenString test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
+
var decimal, amountUToken, token;
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
decimal = 6;
|
|
217
|
+
amountUToken = "1000000";
|
|
218
|
+
token = FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(amountUToken, decimal);
|
|
219
|
+
chai_1.expect(token).to.be.equal("1");
|
|
220
|
+
amountUToken = "1234000";
|
|
221
|
+
token = FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(amountUToken, decimal);
|
|
222
|
+
chai_1.expect(token).to.be.equal("1.234");
|
|
223
|
+
return [2 /*return*/];
|
|
224
|
+
});
|
|
225
|
+
}); });
|
|
226
|
+
it('getUTokenStringFromToken test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
227
|
+
var decimal, amountUToken, token;
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
decimal = 6;
|
|
230
|
+
amountUToken = "1";
|
|
231
|
+
token = FirmaUtil_1.FirmaUtil.getUTokenStringFromTokenStr(amountUToken, decimal);
|
|
232
|
+
chai_1.expect(token).to.be.equal("1000000");
|
|
233
|
+
amountUToken = "1.23";
|
|
234
|
+
token = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUToken);
|
|
235
|
+
chai_1.expect(token).to.be.equal("1230000");
|
|
236
|
+
return [2 /*return*/];
|
|
237
|
+
});
|
|
238
|
+
}); });
|
|
239
|
+
it('getFileHashFromBuffer test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
240
|
+
var testString, enc, buffer, hash;
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
testString = "hello world";
|
|
243
|
+
enc = new TextEncoder();
|
|
244
|
+
buffer = enc.encode(testString);
|
|
245
|
+
hash = FirmaUtil_1.FirmaUtil.getFileHashFromBuffer(buffer);
|
|
246
|
+
// hash from sha256 online
|
|
247
|
+
chai_1.expect(hash).to.be.equal("b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");
|
|
248
|
+
return [2 /*return*/];
|
|
249
|
+
});
|
|
250
|
+
}); });
|
|
251
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var chai_1 = require("chai");
|
|
40
|
+
var FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
41
|
+
var config_test_1 = require("./config_test");
|
|
42
|
+
describe('[19. chain Test]', function () {
|
|
43
|
+
var firma;
|
|
44
|
+
beforeEach(function () {
|
|
45
|
+
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
46
|
+
});
|
|
47
|
+
it('getChainStatus test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var result;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, firma.BlockChain.getChainSyncInfo()];
|
|
52
|
+
case 1:
|
|
53
|
+
result = _a.sent();
|
|
54
|
+
chai_1.expect(result).to.be.an('object');
|
|
55
|
+
chai_1.expect(result).to.have.property('latest_block_hash');
|
|
56
|
+
chai_1.expect(result).to.have.property('latest_app_hash');
|
|
57
|
+
chai_1.expect(result).to.have.property('latest_block_height');
|
|
58
|
+
chai_1.expect(result).to.have.property('latest_block_time');
|
|
59
|
+
chai_1.expect(result).to.have.property('earliest_block_hash');
|
|
60
|
+
chai_1.expect(result).to.have.property('earliest_app_hash');
|
|
61
|
+
chai_1.expect(result).to.have.property('earliest_block_height');
|
|
62
|
+
chai_1.expect(result).to.have.property('earliest_block_time');
|
|
63
|
+
chai_1.expect(result).to.have.property('catching_up');
|
|
64
|
+
chai_1.expect(parseInt(result.latest_block_height)).to.be.a('number');
|
|
65
|
+
chai_1.expect(parseInt(result.earliest_block_height)).to.be.a('number');
|
|
66
|
+
chai_1.expect(parseInt(result.latest_block_height)).to.be.greaterThan(0);
|
|
67
|
+
chai_1.expect(parseInt(result.earliest_block_height)).to.be.greaterThan(0);
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); });
|
|
72
|
+
// This test requires a meaningful transaction hash, so it is skipped by default.
|
|
73
|
+
it('getTransactionByHash test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
var txHash, result, error_1;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
txHash = "0x5DA9D094D15660D21947C9EEF1329CCB70117E7BCD3A451F27E5C7AFF5DB6DF0";
|
|
79
|
+
_a.label = 1;
|
|
80
|
+
case 1:
|
|
81
|
+
_a.trys.push([1, 3, , 4]);
|
|
82
|
+
return [4 /*yield*/, firma.BlockChain.getTransactionByHash(txHash)];
|
|
83
|
+
case 2:
|
|
84
|
+
result = _a.sent();
|
|
85
|
+
chai_1.expect(result).to.have.property('hash');
|
|
86
|
+
chai_1.expect(result).to.have.property('height');
|
|
87
|
+
chai_1.expect(result).to.have.property('index');
|
|
88
|
+
chai_1.expect(result).to.have.property('tx_result');
|
|
89
|
+
chai_1.expect(result).to.have.property('tx');
|
|
90
|
+
chai_1.expect(result.hash).to.equal(txHash);
|
|
91
|
+
chai_1.expect(parseInt(result.height)).to.be.greaterThan(0);
|
|
92
|
+
chai_1.expect(result.index).to.be.greaterThanOrEqual(0);
|
|
93
|
+
chai_1.expect(result.tx_result).to.have.property('code');
|
|
94
|
+
chai_1.expect(result.tx_result).to.have.property('data');
|
|
95
|
+
chai_1.expect(result.tx_result).to.have.property('log');
|
|
96
|
+
chai_1.expect(result.tx_result).to.have.property('info');
|
|
97
|
+
chai_1.expect(result.tx_result).to.have.property('gas_wanted');
|
|
98
|
+
chai_1.expect(result.tx_result).to.have.property('gas_used');
|
|
99
|
+
chai_1.expect(result.tx_result).to.have.property('events');
|
|
100
|
+
chai_1.expect(result.tx_result).to.have.property('codespace');
|
|
101
|
+
return [3 /*break*/, 4];
|
|
102
|
+
case 3:
|
|
103
|
+
error_1 = _a.sent();
|
|
104
|
+
chai_1.expect(error_1).to.exist;
|
|
105
|
+
return [3 /*break*/, 4];
|
|
106
|
+
case 4: return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}); });
|
|
110
|
+
it('getChainInfo test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
var result;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, firma.BlockChain.getChainInfo()];
|
|
115
|
+
case 1:
|
|
116
|
+
result = _a.sent();
|
|
117
|
+
chai_1.expect(result).to.have.property('chainId');
|
|
118
|
+
chai_1.expect(result).to.have.property('appVersion');
|
|
119
|
+
chai_1.expect(result).to.have.property('cosmosVersion');
|
|
120
|
+
chai_1.expect(result.chainId).to.not.be.empty;
|
|
121
|
+
chai_1.expect(result.appVersion).to.not.be.empty;
|
|
122
|
+
chai_1.expect(result.cosmosVersion).to.not.be.empty;
|
|
123
|
+
return [2 /*return*/];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}); });
|
|
127
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var chai_1 = require("chai");
|
|
40
|
+
var FirmaSDK_1 = require("../sdk/FirmaSDK");
|
|
41
|
+
var config_test_1 = require("./config_test");
|
|
42
|
+
describe('[20. Slashing Query Test]', function () {
|
|
43
|
+
var firma;
|
|
44
|
+
beforeEach(function () {
|
|
45
|
+
firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
|
|
46
|
+
});
|
|
47
|
+
it('getSlashingParam test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var result;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, firma.Slashing.getSlashingParam()];
|
|
52
|
+
case 1:
|
|
53
|
+
result = _a.sent();
|
|
54
|
+
chai_1.expect(result).to.have.property('signed_blocks_window');
|
|
55
|
+
chai_1.expect(result).to.have.property('min_signed_per_window');
|
|
56
|
+
chai_1.expect(result).to.have.property('downtime_jail_duration');
|
|
57
|
+
chai_1.expect(result).to.have.property('slash_fraction_double_sign');
|
|
58
|
+
chai_1.expect(result).to.have.property('slash_fraction_downtime');
|
|
59
|
+
chai_1.expect(result.signed_blocks_window).to.not.be.empty;
|
|
60
|
+
chai_1.expect(result.min_signed_per_window).to.not.be.empty;
|
|
61
|
+
chai_1.expect(result.downtime_jail_duration).to.not.be.empty;
|
|
62
|
+
chai_1.expect(result.slash_fraction_double_sign).to.not.be.empty;
|
|
63
|
+
chai_1.expect(result.slash_fraction_downtime).to.not.be.empty;
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}); });
|
|
68
|
+
it('getSigningInfos test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var result;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0: return [4 /*yield*/, firma.Slashing.getSigningInfos()];
|
|
73
|
+
case 1:
|
|
74
|
+
result = _a.sent();
|
|
75
|
+
if (result.length > 0) {
|
|
76
|
+
chai_1.expect(result[0]).to.have.property('address');
|
|
77
|
+
chai_1.expect(result[0]).to.have.property('start_height');
|
|
78
|
+
chai_1.expect(result[0]).to.have.property('index_offset');
|
|
79
|
+
chai_1.expect(result[0]).to.have.property('jailed_until');
|
|
80
|
+
chai_1.expect(result[0]).to.have.property('tombstoned');
|
|
81
|
+
chai_1.expect(result[0]).to.have.property('missed_blocks_counter');
|
|
82
|
+
// address가 비어있지 않은지 확인
|
|
83
|
+
chai_1.expect(result[0].address).to.not.be.empty;
|
|
84
|
+
}
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); });
|
|
89
|
+
it('getSigningInfo test', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
var infos, result;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0: return [4 /*yield*/, firma.Slashing.getSigningInfos()];
|
|
94
|
+
case 1:
|
|
95
|
+
infos = _a.sent();
|
|
96
|
+
if (!(infos.length > 0)) return [3 /*break*/, 3];
|
|
97
|
+
return [4 /*yield*/, firma.Slashing.getSigningInfo(infos[0].address)];
|
|
98
|
+
case 2:
|
|
99
|
+
result = _a.sent();
|
|
100
|
+
chai_1.expect(result).to.have.property('address');
|
|
101
|
+
chai_1.expect(result).to.have.property('start_height');
|
|
102
|
+
chai_1.expect(result).to.have.property('index_offset');
|
|
103
|
+
chai_1.expect(result).to.have.property('jailed_until');
|
|
104
|
+
chai_1.expect(result).to.have.property('tombstoned');
|
|
105
|
+
chai_1.expect(result).to.have.property('missed_blocks_counter');
|
|
106
|
+
chai_1.expect(result.address).to.equal(infos[0].address);
|
|
107
|
+
_a.label = 3;
|
|
108
|
+
case 3: return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); });
|
|
112
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|