@firmachain/firma-js 0.2.46 → 0.2.48

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.
Files changed (132) hide show
  1. package/dist/index.js +1 -5
  2. package/dist/sdk/FirmaAuthzService.js +5 -5
  3. package/dist/sdk/FirmaBankService.js +1 -1
  4. package/dist/sdk/FirmaChainService.d.ts +5 -0
  5. package/dist/sdk/FirmaChainService.js +44 -0
  6. package/dist/sdk/FirmaContractService.js +5 -5
  7. package/dist/sdk/FirmaCosmWasmCw20.d.ts +17 -0
  8. package/dist/sdk/FirmaCosmWasmCw20.js +269 -0
  9. package/dist/sdk/FirmaCosmWasmService.js +9 -9
  10. package/dist/sdk/FirmaDistributionService.js +5 -5
  11. package/dist/sdk/FirmaFeeGrantService.js +3 -3
  12. package/dist/sdk/FirmaGovService.js +7 -7
  13. package/dist/sdk/FirmaIbcService.js +1 -1
  14. package/dist/sdk/FirmaNftService.js +5 -5
  15. package/dist/sdk/FirmaSDK.d.ts +3 -1
  16. package/dist/sdk/FirmaSDK.js +4 -1
  17. package/dist/sdk/FirmaStakingService.js +5 -5
  18. package/dist/sdk/FirmaTokenService.js +4 -4
  19. package/dist/sdk/FirmaUtil.js +16 -20
  20. package/dist/sdk/FirmaWalletService.js +3 -3
  21. package/dist/sdk/firmachain/amino/addresses.js +11 -11
  22. package/dist/sdk/firmachain/amino/aminotypes.js +32 -36
  23. package/dist/sdk/firmachain/amino/encoding.js +26 -30
  24. package/dist/sdk/firmachain/amino/multisig.js +5 -5
  25. package/dist/sdk/firmachain/amino/signature.js +4 -4
  26. package/dist/sdk/firmachain/amino/signdoc.js +1 -1
  27. package/dist/sdk/firmachain/amino/wallet.js +10 -14
  28. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +3 -3
  29. package/dist/sdk/firmachain/authz/index.js +1 -5
  30. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  31. package/dist/sdk/firmachain/bank/index.js +1 -5
  32. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
  33. package/dist/sdk/firmachain/common/LedgerWallet.js +10 -14
  34. package/dist/sdk/firmachain/common/accounts.js +2 -2
  35. package/dist/sdk/firmachain/common/index.js +1 -5
  36. package/dist/sdk/firmachain/common/signing.js +5 -9
  37. package/dist/sdk/firmachain/common/signingaminostargateclient.js +16 -16
  38. package/dist/sdk/firmachain/common/signingstargateclient.js +14 -18
  39. package/dist/sdk/firmachain/common/stargateclient.js +6 -6
  40. package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
  41. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
  42. package/dist/sdk/firmachain/contract/index.js +1 -5
  43. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +8 -8
  44. package/dist/sdk/firmachain/cosmwasm/index.js +1 -5
  45. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
  46. package/dist/sdk/firmachain/distribution/index.js +1 -5
  47. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
  48. package/dist/sdk/firmachain/feegrant/index.js +1 -5
  49. package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
  50. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
  51. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
  52. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
  53. package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
  54. package/dist/sdk/firmachain/gov/index.js +1 -5
  55. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +1 -1
  56. package/dist/sdk/firmachain/ibc/index.js +1 -5
  57. package/dist/sdk/firmachain/mint/index.js +1 -5
  58. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
  59. package/dist/sdk/firmachain/nft/index.js +1 -5
  60. package/dist/sdk/firmachain/slashing/index.js +1 -5
  61. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +2 -2
  62. package/dist/sdk/firmachain/staking/StakingQueryClient.js +8 -8
  63. package/dist/sdk/firmachain/staking/index.js +1 -5
  64. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
  65. package/dist/sdk/firmachain/token/index.js +1 -5
  66. package/package.json +24 -24
  67. package/dist/test/00.wallet.test.d.ts +0 -1
  68. package/dist/test/00.wallet.test.js +0 -87
  69. package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.d.ts +0 -1
  70. package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.js +0 -302
  71. package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.d.ts +0 -1
  72. package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.js +0 -436
  73. package/dist/test/01.contract_tx.test.d.ts +0 -1
  74. package/dist/test/01.contract_tx.test.js +0 -146
  75. package/dist/test/02.contract_query.test.d.ts +0 -1
  76. package/dist/test/02.contract_query.test.js +0 -219
  77. package/dist/test/03.contract_scenario.test.d.ts +0 -1
  78. package/dist/test/03.contract_scenario.test.js +0 -559
  79. package/dist/test/04.bank_tx.test.d.ts +0 -1
  80. package/dist/test/04.bank_tx.test.js +0 -124
  81. package/dist/test/05.bank_query.test.d.ts +0 -1
  82. package/dist/test/05.bank_query.test.js +0 -164
  83. package/dist/test/06.feegrant_tx.test.d.ts +0 -1
  84. package/dist/test/06.feegrant_tx.test.js +0 -173
  85. package/dist/test/07.feegrant_query.test.d.ts +0 -1
  86. package/dist/test/07.feegrant_query.test.js +0 -81
  87. package/dist/test/08.gas_estimate.test.d.ts +0 -1
  88. package/dist/test/08.gas_estimate.test.js +0 -702
  89. package/dist/test/09.ipfs.test.d.ts +0 -1
  90. package/dist/test/09.ipfs.test.js +0 -69
  91. package/dist/test/10.nft_tx.test.d.ts +0 -1
  92. package/dist/test/10.nft_tx.test.js +0 -137
  93. package/dist/test/11.nft_query.test.d.ts +0 -1
  94. package/dist/test/11.nft_query.test.js +0 -167
  95. package/dist/test/12.staking_tx.test.d.ts +0 -1
  96. package/dist/test/12.staking_tx.test.js +0 -213
  97. package/dist/test/13.staking_query.test.d.ts +0 -1
  98. package/dist/test/13.staking_query.test.js +0 -206
  99. package/dist/test/14.distribution_tx.test.d.ts +0 -1
  100. package/dist/test/14.distribution_tx.test.js +0 -176
  101. package/dist/test/15.distribution_query.test.d.ts +0 -1
  102. package/dist/test/15.distribution_query.test.js +0 -216
  103. package/dist/test/16.gov_tx.test.d.ts +0 -1
  104. package/dist/test/16.gov_tx.test.js +0 -237
  105. package/dist/test/17.gov_query.test.d.ts +0 -1
  106. package/dist/test/17.gov_query.test.js +0 -115
  107. package/dist/test/18.util.test.d.ts +0 -1
  108. package/dist/test/18.util.test.js +0 -246
  109. package/dist/test/19.chain.test.d.ts +0 -1
  110. package/dist/test/19.chain.test.js +0 -67
  111. package/dist/test/20.slashing_query.test.d.ts +0 -1
  112. package/dist/test/20.slashing_query.test.js +0 -82
  113. package/dist/test/21.token_tx.test.d.ts +0 -1
  114. package/dist/test/21.token_tx.test.js +0 -154
  115. package/dist/test/22.token_query.test.d.ts +0 -1
  116. package/dist/test/22.token_query.test.js +0 -96
  117. package/dist/test/23.authz_tx.test.d.ts +0 -1
  118. package/dist/test/23.authz_tx.test.js +0 -468
  119. package/dist/test/24.authz_query.test.d.ts +0 -1
  120. package/dist/test/24.authz_query.test.js +0 -140
  121. package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
  122. package/dist/test/25.cosmwasm_tx.test.js +0 -188
  123. package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
  124. package/dist/test/26.cosmwasm_query.test.js +0 -167
  125. package/dist/test/27.arbitary_sign.test.d.ts +0 -1
  126. package/dist/test/27.arbitary_sign.test.js +0 -164
  127. package/dist/test/28.ibc_tx.test.d.ts +0 -1
  128. package/dist/test/28.ibc_tx.test.js +0 -83
  129. package/dist/test/29.mint_query.copy.d.ts +0 -1
  130. package/dist/test/29.mint_query.copy.js +0 -54
  131. package/dist/test/config_test.d.ts +0 -5
  132. package/dist/test/config_test.js +0 -27
@@ -1,237 +0,0 @@
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 common_1 = require("../sdk/firmachain/common");
41
- var FirmaSDK_1 = require("../sdk/FirmaSDK");
42
- var config_test_1 = require("./config_test");
43
- // If test it, the properties of the chain change, so skip it.
44
- describe.skip('[16. Gov Tx Test]', function () {
45
- var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
46
- // Test order
47
- // 1. submitProposal
48
- // 2. deposit(for pass minium deposit value)
49
- // 3. vote
50
- it('SubmitTextProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
51
- var wallet, initialDepositFCT, title, description, result;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
55
- case 1:
56
- wallet = _a.sent();
57
- initialDepositFCT = 10;
58
- title = "test submit proposal";
59
- description = "test description";
60
- return [4 /*yield*/, firma.Gov.submitTextProposal(wallet, title, description, initialDepositFCT)];
61
- case 2:
62
- result = _a.sent();
63
- console.log(result);
64
- (0, chai_1.expect)(result.code).to.equal(0);
65
- return [2 /*return*/];
66
- }
67
- });
68
- }); });
69
- it('SubmitCommunityPoolSpendProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
70
- var aliceWallet, bobWallet, initialDepositFCT, title, description, amount, recipient, result;
71
- return __generator(this, function (_a) {
72
- switch (_a.label) {
73
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
74
- case 1:
75
- aliceWallet = _a.sent();
76
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
77
- case 2:
78
- bobWallet = _a.sent();
79
- initialDepositFCT = 10;
80
- title = "Community spend proposal1";
81
- description = "This is a community spend proposal";
82
- amount = 1000;
83
- return [4 /*yield*/, bobWallet.getAddress()];
84
- case 3:
85
- recipient = _a.sent();
86
- return [4 /*yield*/, firma.Gov.submitCommunityPoolSpendProposal(aliceWallet, title, description, initialDepositFCT, amount, recipient)];
87
- case 4:
88
- result = _a.sent();
89
- console.log(result);
90
- (0, chai_1.expect)(result.code).to.equal(0);
91
- return [2 /*return*/];
92
- }
93
- });
94
- }); });
95
- it('SubmitParameterChangeProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
96
- var aliceWallet, initialDepositFCT, title, description, changeParamList, result;
97
- return __generator(this, function (_a) {
98
- switch (_a.label) {
99
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
100
- case 1:
101
- aliceWallet = _a.sent();
102
- initialDepositFCT = 10;
103
- title = "Parameter Change proposal1";
104
- description = "This is a Parameter change proposal";
105
- changeParamList = [{
106
- subspace: "staking",
107
- key: "MaxValidators",
108
- value: "100",
109
- }];
110
- return [4 /*yield*/, firma.Gov.submitParameterChangeProposal(aliceWallet, title, description, initialDepositFCT, changeParamList)];
111
- case 2:
112
- result = _a.sent();
113
- console.log(result);
114
- (0, chai_1.expect)(result.code).to.equal(0);
115
- return [2 /*return*/];
116
- }
117
- });
118
- }); });
119
- it('SubmitSoftwareUpgradeProposalByHeight Test', function () { return __awaiter(void 0, void 0, void 0, function () {
120
- var aliceWallet, initialDepositFCT, title, description, upgradeName, upgradeHeight, result;
121
- return __generator(this, function (_a) {
122
- switch (_a.label) {
123
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
124
- case 1:
125
- aliceWallet = _a.sent();
126
- initialDepositFCT = 10000;
127
- title = "Software Upgrade proposal1";
128
- description = "This is a software upgrade proposal";
129
- upgradeName = "v0.2.7";
130
- upgradeHeight = 20000000;
131
- return [4 /*yield*/, firma.Gov.submitSoftwareUpgradeProposalByHeight(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeHeight)];
132
- case 2:
133
- result = _a.sent();
134
- console.log(result);
135
- (0, chai_1.expect)(result.code).to.equal(0);
136
- return [2 /*return*/];
137
- }
138
- });
139
- }); });
140
- it('SubmitCancelSoftwareUpgradeProposal Test', function () { return __awaiter(void 0, void 0, void 0, function () {
141
- var aliceWallet, initialDepositFCT, title, description, result;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
145
- case 1:
146
- aliceWallet = _a.sent();
147
- initialDepositFCT = 1000;
148
- title = "Software Upgrade proposal1";
149
- description = "This is a software upgrade proposal";
150
- return [4 /*yield*/, firma.Gov.submitCancelSoftwareUpgradeProposal(aliceWallet, title, description, initialDepositFCT)];
151
- case 2:
152
- result = _a.sent();
153
- console.log(result);
154
- (0, chai_1.expect)(result.code).to.equal(0);
155
- return [2 /*return*/];
156
- }
157
- });
158
- }); });
159
- // NOTICE: time-based upgrades have been deprecated in the SDK: invalid request
160
- /*it.skip('SubmitSoftwareUpgradeProposalByTime Test', async () => {
161
-
162
- const aliceWallet = await firma.Wallet.fromMnemonic(aliceMnemonic);
163
- const bobWallet = await firma.Wallet.fromMnemonic(bobMnemonic);
164
-
165
- const initialDepositFCT = 8;
166
- const title = "Software Upgrade proposal2";
167
- const description = "This is a software upgrade proposal";
168
-
169
- const expirationDate = new Date();
170
- expirationDate.setMinutes(expirationDate.getMinutes() + 3);
171
-
172
- const upgradeName = "v0.2.4";
173
- const upgradeTime = expirationDate;
174
- const upgradeInfo = "info?";
175
-
176
- var result = await firma.Gov.SubmitSoftwareUpgradeProposalByTime(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeTime);
177
-
178
- console.log(result);
179
- expect(result.code).to.equal(0);
180
- });*/
181
- // TODO: get recent gov proposal list and then set proposalId for below case
182
- var tempProposalId = 1;
183
- // more deposit after initial deposit case
184
- it('Deposit OK', function () { return __awaiter(void 0, void 0, void 0, function () {
185
- var wallet, proposalId, amount, result;
186
- return __generator(this, function (_a) {
187
- switch (_a.label) {
188
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
189
- case 1:
190
- wallet = _a.sent();
191
- proposalId = tempProposalId;
192
- amount = 1000;
193
- return [4 /*yield*/, firma.Gov.deposit(wallet, proposalId, amount)];
194
- case 2:
195
- result = _a.sent();
196
- //console.log(result);
197
- (0, chai_1.expect)(result.code).to.equal(0);
198
- return [2 /*return*/];
199
- }
200
- });
201
- }); });
202
- it('Vote - alice YES', function () { return __awaiter(void 0, void 0, void 0, function () {
203
- var wallet, proposalId, result;
204
- return __generator(this, function (_a) {
205
- switch (_a.label) {
206
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
207
- case 1:
208
- wallet = _a.sent();
209
- proposalId = tempProposalId;
210
- return [4 /*yield*/, firma.Gov.vote(wallet, proposalId, common_1.VotingOption.VOTE_OPTION_YES)];
211
- case 2:
212
- result = _a.sent();
213
- //console.log(result);
214
- (0, chai_1.expect)(result.code).to.equal(0);
215
- return [2 /*return*/];
216
- }
217
- });
218
- }); });
219
- it('Vote - bob NO', function () { return __awaiter(void 0, void 0, void 0, function () {
220
- var wallet, proposalId, result;
221
- return __generator(this, function (_a) {
222
- switch (_a.label) {
223
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
224
- case 1:
225
- wallet = _a.sent();
226
- proposalId = tempProposalId;
227
- return [4 /*yield*/, firma.Gov.vote(wallet, proposalId, common_1.VotingOption.VOTE_OPTION_NO)];
228
- case 2:
229
- result = _a.sent();
230
- //console.log(result);
231
- (0, chai_1.expect)(result.code).to.equal(0);
232
- return [2 /*return*/];
233
- }
234
- });
235
- }); });
236
- // TODO: more voting case need it!
237
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,115 +0,0 @@
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 gov_1 = require("../sdk/firmachain/gov");
40
- var FirmaSDK_1 = require("../sdk/FirmaSDK");
41
- var config_test_1 = require("./config_test");
42
- describe('[17. Gov Query Test]', function () {
43
- var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
44
- it('get getProposalList', function () { return __awaiter(void 0, void 0, void 0, function () {
45
- var proposalList;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
49
- case 1:
50
- proposalList = _a.sent();
51
- return [2 /*return*/];
52
- }
53
- });
54
- }); });
55
- it('get getProposalListByStatus', function () { return __awaiter(void 0, void 0, void 0, function () {
56
- var status, proposalList;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- status = gov_1.ProposalStatus.PROPOSAL_STATUS_REJECTED;
61
- return [4 /*yield*/, firma.Gov.getProposalListByStatus(status)];
62
- case 1:
63
- proposalList = _a.sent();
64
- return [2 /*return*/];
65
- }
66
- });
67
- }); });
68
- it('get getProposal', function () { return __awaiter(void 0, void 0, void 0, function () {
69
- var proposalList, id, proposal;
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
73
- case 1:
74
- proposalList = _a.sent();
75
- if (!(proposalList.length > 0)) return [3 /*break*/, 3];
76
- id = "1";
77
- return [4 /*yield*/, firma.Gov.getProposal(id)];
78
- case 2:
79
- proposal = _a.sent();
80
- _a.label = 3;
81
- case 3: return [2 /*return*/];
82
- }
83
- });
84
- }); });
85
- // integrated function with params/voting, params/deposit, params/tallying
86
- it('get params', function () { return __awaiter(void 0, void 0, void 0, function () {
87
- var param;
88
- return __generator(this, function (_a) {
89
- switch (_a.label) {
90
- case 0: return [4 /*yield*/, firma.Gov.getParam()];
91
- case 1:
92
- param = _a.sent();
93
- return [2 /*return*/];
94
- }
95
- });
96
- }); });
97
- // current tally info
98
- it('get getCurrentVoteInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
99
- var proposalList, proposalId, param;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
103
- case 1:
104
- proposalList = _a.sent();
105
- if (!(proposalList.length > 0)) return [3 /*break*/, 3];
106
- proposalId = "1";
107
- return [4 /*yield*/, firma.Gov.getCurrentVoteInfo(proposalId)];
108
- case 2:
109
- param = _a.sent();
110
- _a.label = 3;
111
- case 3: return [2 /*return*/];
112
- }
113
- });
114
- }); });
115
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,246 +0,0 @@
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
- describe('[18. util Test]', function () {
42
- // getHashFromString
43
- it('getSha1HashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
44
- var contractName, result;
45
- return __generator(this, function (_a) {
46
- contractName = "testContract1234";
47
- result = FirmaUtil_1.FirmaUtil.getSha1HashFromString(contractName);
48
- (0, chai_1.expect)(result).to.be.equal("c88753a797d1310b36673e3494005bc7485746b7");
49
- return [2 /*return*/];
50
- });
51
- }); });
52
- it('getHashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
53
- var contractName, result;
54
- return __generator(this, function (_a) {
55
- contractName = "testContract1234";
56
- result = FirmaUtil_1.FirmaUtil.getHashFromString(contractName);
57
- (0, chai_1.expect)(result).to.be.equal("95e55f6b55ccf6b3988a6f9ee6d9c3c0011ea93a2489e7f05d10cada2613c17f");
58
- return [2 /*return*/];
59
- });
60
- }); });
61
- it('isValidAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
62
- var validAddress, wrongAddress1, wrongAddress2, result;
63
- return __generator(this, function (_a) {
64
- validAddress = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsa";
65
- wrongAddress1 = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsb";
66
- wrongAddress2 = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsa1";
67
- result = FirmaUtil_1.FirmaUtil.isValidAddress(validAddress);
68
- (0, chai_1.expect)(result).to.be.equal(true);
69
- result = FirmaUtil_1.FirmaUtil.isValidAddress(wrongAddress1);
70
- (0, chai_1.expect)(result).to.be.equal(false);
71
- result = FirmaUtil_1.FirmaUtil.isValidAddress(wrongAddress2);
72
- (0, chai_1.expect)(result).to.be.equal(false);
73
- return [2 /*return*/];
74
- });
75
- }); });
76
- it('getValOperAddressFromAccAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
77
- var accAddress, valoperAddress, result;
78
- return __generator(this, function (_a) {
79
- accAddress = "firma1a85hxs97rxsrf0yzdn72vhfu39sa0dwxv90ghy";
80
- valoperAddress = "firmavaloper1a85hxs97rxsrf0yzdn72vhfu39sa0dwxjkynh2";
81
- result = FirmaUtil_1.FirmaUtil.getValOperAddressFromAccAddress(accAddress);
82
- (0, chai_1.expect)(result).to.be.equal(valoperAddress);
83
- return [2 /*return*/];
84
- });
85
- }); });
86
- it('getValConsAddressFromConsensusPubKey test', function () { return __awaiter(void 0, void 0, void 0, function () {
87
- var consensusPubkey, valconsAddress, result;
88
- return __generator(this, function (_a) {
89
- consensusPubkey = "InWhZBMP3wKQkwIBCrVqQ+BNoPhV5mTjpwiYHKHCZ/k=";
90
- valconsAddress = "firmavalcons1fh73gr3f9df7yc390ykdnmeedetlw5ll3dqwje";
91
- result = FirmaUtil_1.FirmaUtil.getValConsAddressFromAccAddress(consensusPubkey);
92
- //console.log(result);
93
- (0, chai_1.expect)(result).to.be.equal(valconsAddress);
94
- return [2 /*return*/];
95
- });
96
- }); });
97
- it('getAccAddressFromValOperAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
98
- var accAddress, valoperAddress, result;
99
- return __generator(this, function (_a) {
100
- accAddress = "firma1a85hxs97rxsrf0yzdn72vhfu39sa0dwxv90ghy";
101
- valoperAddress = "firmavaloper1a85hxs97rxsrf0yzdn72vhfu39sa0dwxjkynh2";
102
- result = FirmaUtil_1.FirmaUtil.getAccAddressFromValOperAddress(valoperAddress);
103
- (0, chai_1.expect)(result).to.be.equal(accAddress);
104
- return [2 /*return*/];
105
- });
106
- }); });
107
- it('getFCTFromUFCTString test', function () { return __awaiter(void 0, void 0, void 0, function () {
108
- var amountUFCT, fct;
109
- return __generator(this, function (_a) {
110
- amountUFCT = 1000000;
111
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCT(amountUFCT);
112
- (0, chai_1.expect)(fct).to.be.equal("1");
113
- amountUFCT = 1234000;
114
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCT(amountUFCT);
115
- (0, chai_1.expect)(fct).to.be.equal("1.234");
116
- return [2 /*return*/];
117
- });
118
- }); });
119
- it('getUFCTStringFromFCT test', function () { return __awaiter(void 0, void 0, void 0, function () {
120
- var amountUFCT, fct;
121
- return __generator(this, function (_a) {
122
- amountUFCT = 1;
123
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountUFCT);
124
- (0, chai_1.expect)(fct).to.be.equal("1000000");
125
- amountUFCT = 1.23;
126
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountUFCT);
127
- (0, chai_1.expect)(fct).to.be.equal("1230000");
128
- return [2 /*return*/];
129
- });
130
- }); });
131
- it('getFCTFromUFCTString test', function () { return __awaiter(void 0, void 0, void 0, function () {
132
- var amountUFCT, fct;
133
- return __generator(this, function (_a) {
134
- amountUFCT = "1000000";
135
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCTStr(amountUFCT);
136
- (0, chai_1.expect)(fct).to.be.equal("1");
137
- amountUFCT = "1234000";
138
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCTStr(amountUFCT);
139
- (0, chai_1.expect)(fct).to.be.equal("1.234");
140
- return [2 /*return*/];
141
- });
142
- }); });
143
- it('getUFCTStringFromFCT test', function () { return __awaiter(void 0, void 0, void 0, function () {
144
- var amountUFCT, fct;
145
- return __generator(this, function (_a) {
146
- amountUFCT = "1";
147
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUFCT);
148
- (0, chai_1.expect)(fct).to.be.equal("1000000");
149
- amountUFCT = "1.23";
150
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUFCT);
151
- (0, chai_1.expect)(fct).to.be.equal("1230000");
152
- return [2 /*return*/];
153
- });
154
- }); });
155
- it('getTokenFromUTokenString test', function () { return __awaiter(void 0, void 0, void 0, function () {
156
- var decimal, amountUToken, token;
157
- return __generator(this, function (_a) {
158
- decimal = 6;
159
- amountUToken = 1000000;
160
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(amountUToken, decimal);
161
- (0, chai_1.expect)(token).to.be.equal("1");
162
- amountUToken = 1234000;
163
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(amountUToken, decimal);
164
- (0, chai_1.expect)(token).to.be.equal("1.234");
165
- return [2 /*return*/];
166
- });
167
- }); });
168
- it('getUTokenStringFromToken test', function () { return __awaiter(void 0, void 0, void 0, function () {
169
- var decimal, amountUToken, token;
170
- return __generator(this, function (_a) {
171
- decimal = 6;
172
- amountUToken = 1;
173
- token = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amountUToken, decimal);
174
- (0, chai_1.expect)(token).to.be.equal("1000000");
175
- amountUToken = 1.23;
176
- token = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amountUToken, decimal);
177
- (0, chai_1.expect)(token).to.be.equal("1230000");
178
- return [2 /*return*/];
179
- });
180
- }); });
181
- it('cutting the ufct decimal point test', function () { return __awaiter(void 0, void 0, void 0, function () {
182
- var decimal, testUTokenValue, testUTokenValueStr, testTokenValueStr;
183
- return __generator(this, function (_a) {
184
- decimal = 6;
185
- testUTokenValue = 533.827284;
186
- testUTokenValueStr = "533.827284";
187
- testTokenValueStr = "0.000533";
188
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(testUTokenValueStr, decimal)).to.be.equal(testTokenValueStr);
189
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(testUTokenValue, decimal)).to.be.equal(testTokenValueStr);
190
- return [2 /*return*/];
191
- });
192
- }); });
193
- it('cutting the decimal point test', function () { return __awaiter(void 0, void 0, void 0, function () {
194
- var decimal, testTokenValue, testTokenValueStr, testUTokenValue, testUTokenValueStr;
195
- return __generator(this, function (_a) {
196
- decimal = 6;
197
- testTokenValue = 533.827284;
198
- testTokenValueStr = "533.827284";
199
- testUTokenValue = 533827284;
200
- testUTokenValueStr = "533827284";
201
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getUTokenFromToken(testTokenValue, decimal)).to.be.equal(testUTokenValue);
202
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getUTokenStringFromTokenStr(testTokenValueStr, decimal)).to.be.equal(testUTokenValueStr);
203
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(testUTokenValueStr, decimal)).to.be.equal(testTokenValueStr);
204
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(testUTokenValue, decimal)).to.be.equal(testTokenValueStr);
205
- return [2 /*return*/];
206
- });
207
- }); });
208
- it('getTokenFromUTokenString test', function () { return __awaiter(void 0, void 0, void 0, function () {
209
- var decimal, amountUToken, token;
210
- return __generator(this, function (_a) {
211
- decimal = 6;
212
- amountUToken = "1000000";
213
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(amountUToken, decimal);
214
- (0, chai_1.expect)(token).to.be.equal("1");
215
- amountUToken = "1234000";
216
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(amountUToken, decimal);
217
- (0, chai_1.expect)(token).to.be.equal("1.234");
218
- return [2 /*return*/];
219
- });
220
- }); });
221
- it('getUTokenStringFromToken test', function () { return __awaiter(void 0, void 0, void 0, function () {
222
- var decimal, amountUToken, token;
223
- return __generator(this, function (_a) {
224
- decimal = 6;
225
- amountUToken = "1";
226
- token = FirmaUtil_1.FirmaUtil.getUTokenStringFromTokenStr(amountUToken, decimal);
227
- (0, chai_1.expect)(token).to.be.equal("1000000");
228
- amountUToken = "1.23";
229
- token = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUToken);
230
- (0, chai_1.expect)(token).to.be.equal("1230000");
231
- return [2 /*return*/];
232
- });
233
- }); });
234
- it('getFileHashFromBuffer test', function () { return __awaiter(void 0, void 0, void 0, function () {
235
- var testString, enc, buffer, hash;
236
- return __generator(this, function (_a) {
237
- testString = "hello world";
238
- enc = new TextEncoder();
239
- buffer = enc.encode(testString);
240
- hash = FirmaUtil_1.FirmaUtil.getFileHashFromBuffer(buffer);
241
- // hash from sha256 online
242
- (0, chai_1.expect)(hash).to.be.equal("b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");
243
- return [2 /*return*/];
244
- });
245
- }); });
246
- });
@@ -1 +0,0 @@
1
- export {};