@firmachain/firma-js 0.3.7 → 0.4.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.
Files changed (128) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/sdk/FirmaAuthzService.js +20 -15
  4. package/dist/sdk/FirmaBankService.d.ts +1 -1
  5. package/dist/sdk/FirmaBankService.js +5 -4
  6. package/dist/sdk/FirmaConfig.js +4 -4
  7. package/dist/sdk/FirmaContractService.js +10 -8
  8. package/dist/sdk/FirmaDistributionService.js +37 -22
  9. package/dist/sdk/FirmaFeeGrantService.d.ts +0 -1
  10. package/dist/sdk/FirmaFeeGrantService.js +12 -14
  11. package/dist/sdk/FirmaGovService.d.ts +14 -0
  12. package/dist/sdk/FirmaGovService.js +74 -47
  13. package/dist/sdk/FirmaIbcService.js +4 -3
  14. package/dist/sdk/FirmaNftService.d.ts +3 -3
  15. package/dist/sdk/FirmaNftService.js +13 -10
  16. package/dist/sdk/FirmaStakingService.js +12 -9
  17. package/dist/sdk/FirmaTokenService.js +17 -14
  18. package/dist/sdk/FirmaUtil.js +1 -1
  19. package/dist/sdk/FirmaWalletService.d.ts +1 -1
  20. package/dist/sdk/FirmaWalletService.js +11 -23
  21. package/dist/sdk/firmachain/authz/AuthzTxClient.js +2 -0
  22. package/dist/sdk/firmachain/bank/BankTxClient.js +1 -1
  23. package/dist/sdk/firmachain/common/CommonTxClient.js +3 -1
  24. package/dist/sdk/firmachain/common/FirmaLedger.d.ts +49 -0
  25. package/dist/sdk/firmachain/common/FirmaLedger.js +301 -0
  26. package/dist/sdk/firmachain/common/ITxClient.d.ts +1 -1
  27. package/dist/sdk/firmachain/common/ITxClient.js +6 -4
  28. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +5 -13
  29. package/dist/sdk/firmachain/common/LedgerWallet.js +1266 -124
  30. package/dist/sdk/firmachain/common/SigningProtobufStargateClient.js +3 -4
  31. package/dist/sdk/firmachain/common/SigningStargateClient.d.ts +2 -3
  32. package/dist/sdk/firmachain/common/SigningStargateClient.js +7 -10
  33. package/dist/sdk/firmachain/common/index.d.ts +1 -0
  34. package/dist/sdk/firmachain/common/index.js +1 -0
  35. package/dist/sdk/firmachain/common/signing.d.ts +4 -10
  36. package/dist/sdk/firmachain/common/signing.js +13 -60
  37. package/dist/sdk/firmachain/contract/ContractTxClient.js +1 -1
  38. package/dist/sdk/firmachain/contract/ContractTxTypes.js +54 -8
  39. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +1 -1
  40. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +3 -1
  41. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +1 -2
  42. package/dist/sdk/firmachain/google/protobuf/any.js +0 -12
  43. package/dist/sdk/firmachain/gov/GovTxClient.js +3 -0
  44. package/dist/sdk/firmachain/nft/NftTxClient.js +1 -1
  45. package/dist/sdk/firmachain/token/TokenTxClient.js +1 -1
  46. package/package.json +16 -8
  47. package/dist/test/00.wallet.test.d.ts +0 -1
  48. package/dist/test/00.wallet.test.js +0 -96
  49. package/dist/test/01.contract_tx.test.d.ts +0 -1
  50. package/dist/test/01.contract_tx.test.js +0 -157
  51. package/dist/test/02.contract_query.test.d.ts +0 -1
  52. package/dist/test/02.contract_query.test.js +0 -245
  53. package/dist/test/03.contract_scenario.test.d.ts +0 -1
  54. package/dist/test/03.contract_scenario.test.js +0 -406
  55. package/dist/test/04.bank_tx.test.d.ts +0 -1
  56. package/dist/test/04.bank_tx.test.js +0 -126
  57. package/dist/test/05.bank_query.test.d.ts +0 -1
  58. package/dist/test/05.bank_query.test.js +0 -162
  59. package/dist/test/06.feegrant_tx.test.d.ts +0 -1
  60. package/dist/test/06.feegrant_tx.test.js +0 -185
  61. package/dist/test/07.feegrant_query.test.d.ts +0 -1
  62. package/dist/test/07.feegrant_query.test.js +0 -129
  63. package/dist/test/08.gas_estimate.test.d.ts +0 -1
  64. package/dist/test/08.gas_estimate.test.js +0 -728
  65. package/dist/test/09.ipfs.test.d.ts +0 -1
  66. package/dist/test/09.ipfs.test.js +0 -72
  67. package/dist/test/10.nft_tx.test.d.ts +0 -1
  68. package/dist/test/10.nft_tx.test.js +0 -209
  69. package/dist/test/11.nft_query.test.d.ts +0 -1
  70. package/dist/test/11.nft_query.test.js +0 -165
  71. package/dist/test/12.staking_tx.test.d.ts +0 -1
  72. package/dist/test/12.staking_tx.test.js +0 -211
  73. package/dist/test/13.staking_query.test.d.ts +0 -1
  74. package/dist/test/13.staking_query.test.js +0 -275
  75. package/dist/test/14.distribution_tx.test.d.ts +0 -1
  76. package/dist/test/14.distribution_tx.test.js +0 -170
  77. package/dist/test/15.distribution_query.test.d.ts +0 -1
  78. package/dist/test/15.distribution_query.test.js +0 -243
  79. package/dist/test/16.gov_tx.test.d.ts +0 -1
  80. package/dist/test/16.gov_tx.test.js +0 -396
  81. package/dist/test/17.gov_query.test.d.ts +0 -1
  82. package/dist/test/17.gov_query.test.js +0 -181
  83. package/dist/test/18.util.test.d.ts +0 -1
  84. package/dist/test/18.util.test.js +0 -354
  85. package/dist/test/19.chain.test.d.ts +0 -1
  86. package/dist/test/19.chain.test.js +0 -127
  87. package/dist/test/20.slashing_query.test.d.ts +0 -1
  88. package/dist/test/20.slashing_query.test.js +0 -111
  89. package/dist/test/21.token_tx.test.d.ts +0 -1
  90. package/dist/test/21.token_tx.test.js +0 -149
  91. package/dist/test/22.token_query.test.d.ts +0 -1
  92. package/dist/test/22.token_query.test.js +0 -103
  93. package/dist/test/23.authz_tx.test.d.ts +0 -1
  94. package/dist/test/23.authz_tx.test.js +0 -380
  95. package/dist/test/24.authz_query.test.d.ts +0 -1
  96. package/dist/test/24.authz_query.test.js +0 -202
  97. package/dist/test/25.cosmwasm_tx.test.d.ts +0 -1
  98. package/dist/test/25.cosmwasm_tx.test.js +0 -229
  99. package/dist/test/26.cosmwasm_query.test.d.ts +0 -1
  100. package/dist/test/26.cosmwasm_query.test.js +0 -275
  101. package/dist/test/27.arbitrary_sign.test.d.ts +0 -1
  102. package/dist/test/27.arbitrary_sign.test.js +0 -162
  103. package/dist/test/28.ibc_tx.test.d.ts +0 -1
  104. package/dist/test/28.ibc_tx.test.js +0 -98
  105. package/dist/test/29.mint_query.test.d.ts +0 -1
  106. package/dist/test/29.mint_query.test.js +0 -59
  107. package/dist/test/30.cw20_tx.test.d.ts +0 -1
  108. package/dist/test/30.cw20_tx.test.js +0 -450
  109. package/dist/test/31.cw20_query.test.d.ts +0 -1
  110. package/dist/test/31.cw20_query.test.js +0 -333
  111. package/dist/test/32.cw721_tx.test.d.ts +0 -1
  112. package/dist/test/32.cw721_tx.test.js +0 -431
  113. package/dist/test/33.cw721_query.test.d.ts +0 -1
  114. package/dist/test/33.cw721_query.test.js +0 -371
  115. package/dist/test/34.cw_bridge_tx.test.d.ts +0 -1
  116. package/dist/test/34.cw_bridge_tx.test.js +0 -476
  117. package/dist/test/35.cw_bridge_tx_low.test.d.ts +0 -1
  118. package/dist/test/35.cw_bridge_tx_low.test.js +0 -398
  119. package/dist/test/36.cw_bridge_query.test.d.ts +0 -1
  120. package/dist/test/36.cw_bridge_query.test.js +0 -318
  121. package/dist/test/37.cw_marketplace_tx.test.d.ts +0 -1
  122. package/dist/test/37.cw_marketplace_tx.test.js +0 -794
  123. package/dist/test/38.cw_marketplace_query.test.d.ts +0 -1
  124. package/dist/test/38.cw_marketplace_query.test.js +0 -128
  125. package/dist/test/config_test.d.ts +0 -11
  126. package/dist/test/config_test.js +0 -14
  127. package/dist/test/config_test.sample.d.ts +0 -11
  128. package/dist/test/config_test.sample.js +0 -14
@@ -1,181 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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
- 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*/];
62
- }
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*/];
82
- }
83
- });
84
- }); });
85
- it('get getProposalListByStatus', function () { return __awaiter(void 0, void 0, void 0, function () {
86
- var status, proposalList;
87
- return __generator(this, function (_a) {
88
- switch (_a.label) {
89
- case 0:
90
- status = gov_1.ProposalStatus.PROPOSAL_STATUS_REJECTED;
91
- return [4 /*yield*/, firma.Gov.getProposalListByStatus(status)];
92
- case 1:
93
- proposalList = _a.sent();
94
- (0, chai_1.expect)(proposalList).to.be.an('array');
95
- if (proposalList.length > 0) {
96
- (0, chai_1.expect)(proposalList[0]).to.have.property('id');
97
- (0, chai_1.expect)(proposalList[0].id).to.not.equal('');
98
- }
99
- else {
100
- (0, chai_1.expect)(proposalList).to.have.lengthOf(0);
101
- }
102
- return [2 /*return*/];
103
- }
104
- });
105
- }); });
106
- it('get getProposal', function () { return __awaiter(void 0, void 0, void 0, function () {
107
- var proposalList, id, proposal;
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
111
- case 1:
112
- proposalList = _a.sent();
113
- if (!(proposalList.length > 0)) return [3 /*break*/, 3];
114
- id = "1";
115
- return [4 /*yield*/, firma.Gov.getProposal(id)];
116
- case 2:
117
- proposal = _a.sent();
118
- (0, chai_1.expect)(proposal).to.be.an('object');
119
- (0, chai_1.expect)(proposal).to.have.property('id');
120
- (0, chai_1.expect)(proposal.id).to.equal(id);
121
- return [3 /*break*/, 4];
122
- case 3:
123
- (0, chai_1.expect)(proposalList).to.have.lengthOf(0);
124
- _a.label = 4;
125
- case 4: return [2 /*return*/];
126
- }
127
- });
128
- }); });
129
- // integrated function with params/voting, params/deposit, params/tallying
130
- it('get params', function () { return __awaiter(void 0, void 0, void 0, function () {
131
- var param;
132
- return __generator(this, function (_a) {
133
- switch (_a.label) {
134
- case 0: return [4 /*yield*/, firma.Gov.getParam()];
135
- case 1:
136
- param = _a.sent();
137
- (0, chai_1.expect)(param).to.be.an('object');
138
- return [2 /*return*/];
139
- }
140
- });
141
- }); });
142
- // integrated function with params/voting, params/deposit, params/tallying - GovParams
143
- it('get params as GovParams', function () { return __awaiter(void 0, void 0, void 0, function () {
144
- var param;
145
- return __generator(this, function (_a) {
146
- switch (_a.label) {
147
- case 0: return [4 /*yield*/, firma.Gov.getParamAsGovParams()];
148
- case 1:
149
- param = _a.sent();
150
- (0, chai_1.expect)(param).to.be.an('object');
151
- return [2 /*return*/];
152
- }
153
- });
154
- }); });
155
- // current tally info
156
- it('get getCurrentVoteInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
157
- var proposalList, proposalId, param;
158
- return __generator(this, function (_a) {
159
- switch (_a.label) {
160
- case 0: return [4 /*yield*/, firma.Gov.getProposalList()];
161
- case 1:
162
- proposalList = _a.sent();
163
- if (!(proposalList.length > 0)) return [3 /*break*/, 3];
164
- proposalId = "1";
165
- return [4 /*yield*/, firma.Gov.getCurrentVoteInfo(proposalId)];
166
- case 2:
167
- param = _a.sent();
168
- (0, chai_1.expect)(param).to.be.an('object');
169
- (0, chai_1.expect)(param).to.have.property('yes_count');
170
- (0, chai_1.expect)(param).to.have.property('abstain_count');
171
- (0, chai_1.expect)(param).to.have.property('no_count');
172
- (0, chai_1.expect)(param).to.have.property('no_with_veto_count');
173
- return [3 /*break*/, 4];
174
- case 3:
175
- (0, chai_1.expect)(proposalList).to.have.lengthOf(0);
176
- _a.label = 4;
177
- case 4: return [2 /*return*/];
178
- }
179
- });
180
- }); });
181
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,354 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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
- var FirmaConfig_1 = require("../sdk/FirmaConfig");
44
- describe('[18. util Test]', function () {
45
- var firma;
46
- var aliceWallet;
47
- var aliceAddress;
48
- beforeEach(function () {
49
- return __awaiter(this, void 0, void 0, function () {
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0:
53
- firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
54
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
55
- case 1:
56
- aliceWallet = _a.sent();
57
- return [4 /*yield*/, aliceWallet.getAddress()];
58
- case 2:
59
- aliceAddress = _a.sent();
60
- return [2 /*return*/];
61
- }
62
- });
63
- });
64
- });
65
- // getHashFromString
66
- it('getSha1HashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
67
- var contractName, result;
68
- return __generator(this, function (_a) {
69
- contractName = "testContract1234";
70
- result = FirmaUtil_1.FirmaUtil.getSha1HashFromString(contractName);
71
- (0, chai_1.expect)(result).to.be.equal("c88753a797d1310b36673e3494005bc7485746b7");
72
- return [2 /*return*/];
73
- });
74
- }); });
75
- it('getHashFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
76
- var contractName, result;
77
- return __generator(this, function (_a) {
78
- contractName = "testContract1234";
79
- result = FirmaUtil_1.FirmaUtil.getHashFromString(contractName);
80
- (0, chai_1.expect)(result).to.be.equal("95e55f6b55ccf6b3988a6f9ee6d9c3c0011ea93a2489e7f05d10cada2613c17f");
81
- return [2 /*return*/];
82
- });
83
- }); });
84
- it('isValidAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
85
- var validAddress, wrongAddress1, wrongAddress2, result;
86
- return __generator(this, function (_a) {
87
- validAddress = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsa";
88
- wrongAddress1 = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsb";
89
- wrongAddress2 = "firma134pp6s2nv7pl4mxu58aeufdd6fv5s2zujrrmsa1";
90
- result = FirmaUtil_1.FirmaUtil.isValidAddress(validAddress);
91
- (0, chai_1.expect)(result).to.be.equal(true);
92
- result = FirmaUtil_1.FirmaUtil.isValidAddress(wrongAddress1);
93
- (0, chai_1.expect)(result).to.be.equal(false);
94
- result = FirmaUtil_1.FirmaUtil.isValidAddress(wrongAddress2);
95
- (0, chai_1.expect)(result).to.be.equal(false);
96
- return [2 /*return*/];
97
- });
98
- }); });
99
- it('getValOperAddressFromAccAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
100
- var accAddress, valoperAddress, result;
101
- return __generator(this, function (_a) {
102
- accAddress = "firma1a85hxs97rxsrf0yzdn72vhfu39sa0dwxv90ghy";
103
- valoperAddress = "firmavaloper1a85hxs97rxsrf0yzdn72vhfu39sa0dwxjkynh2";
104
- result = FirmaUtil_1.FirmaUtil.getValOperAddressFromAccAddress(accAddress);
105
- (0, chai_1.expect)(result).to.be.equal(valoperAddress);
106
- return [2 /*return*/];
107
- });
108
- }); });
109
- it('getValConsAddressFromConsensusPubKey test', function () { return __awaiter(void 0, void 0, void 0, function () {
110
- var consensusPubkey, valconsAddress, result;
111
- return __generator(this, function (_a) {
112
- consensusPubkey = "InWhZBMP3wKQkwIBCrVqQ+BNoPhV5mTjpwiYHKHCZ/k=";
113
- valconsAddress = "firmavalcons1fh73gr3f9df7yc390ykdnmeedetlw5ll3dqwje";
114
- result = FirmaUtil_1.FirmaUtil.getValConsAddressFromAccAddress(consensusPubkey);
115
- (0, chai_1.expect)(result).to.be.equal(valconsAddress);
116
- return [2 /*return*/];
117
- });
118
- }); });
119
- it('getAccAddressFromValOperAddress test', function () { return __awaiter(void 0, void 0, void 0, function () {
120
- var accAddress, valoperAddress, result;
121
- return __generator(this, function (_a) {
122
- accAddress = "firma1a85hxs97rxsrf0yzdn72vhfu39sa0dwxv90ghy";
123
- valoperAddress = "firmavaloper1a85hxs97rxsrf0yzdn72vhfu39sa0dwxjkynh2";
124
- result = FirmaUtil_1.FirmaUtil.getAccAddressFromValOperAddress(valoperAddress);
125
- (0, chai_1.expect)(result).to.be.equal(accAddress);
126
- return [2 /*return*/];
127
- });
128
- }); });
129
- it('getFCTFromUFCTString test', function () { return __awaiter(void 0, void 0, void 0, function () {
130
- var amountUFCT, fct;
131
- return __generator(this, function (_a) {
132
- amountUFCT = 1000000;
133
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCT(amountUFCT);
134
- (0, chai_1.expect)(fct).to.be.equal("1");
135
- amountUFCT = 1234000;
136
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCT(amountUFCT);
137
- (0, chai_1.expect)(fct).to.be.equal("1.234");
138
- return [2 /*return*/];
139
- });
140
- }); });
141
- it('getUFCTStringFromFCT test', function () { return __awaiter(void 0, void 0, void 0, function () {
142
- var amountUFCT, fct;
143
- return __generator(this, function (_a) {
144
- amountUFCT = 1;
145
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountUFCT);
146
- (0, chai_1.expect)(fct).to.be.equal("1000000");
147
- amountUFCT = 1.23;
148
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountUFCT);
149
- (0, chai_1.expect)(fct).to.be.equal("1230000");
150
- return [2 /*return*/];
151
- });
152
- }); });
153
- it('getFCTFromUFCTString test', function () { return __awaiter(void 0, void 0, void 0, function () {
154
- var amountUFCT, fct;
155
- return __generator(this, function (_a) {
156
- amountUFCT = "1000000";
157
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCTStr(amountUFCT);
158
- (0, chai_1.expect)(fct).to.be.equal("1");
159
- amountUFCT = "1234000";
160
- fct = FirmaUtil_1.FirmaUtil.getFCTStringFromUFCTStr(amountUFCT);
161
- (0, chai_1.expect)(fct).to.be.equal("1.234");
162
- return [2 /*return*/];
163
- });
164
- }); });
165
- it('getUFCTStringFromFCT test', function () { return __awaiter(void 0, void 0, void 0, function () {
166
- var amountUFCT, fct;
167
- return __generator(this, function (_a) {
168
- amountUFCT = "1";
169
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUFCT);
170
- (0, chai_1.expect)(fct).to.be.equal("1000000");
171
- amountUFCT = "1.23";
172
- fct = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUFCT);
173
- (0, chai_1.expect)(fct).to.be.equal("1230000");
174
- return [2 /*return*/];
175
- });
176
- }); });
177
- it('getTokenFromUTokenString test', function () { return __awaiter(void 0, void 0, void 0, function () {
178
- var decimal, amountUToken, token;
179
- return __generator(this, function (_a) {
180
- decimal = 6;
181
- amountUToken = 1000000;
182
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(amountUToken, decimal);
183
- (0, chai_1.expect)(token).to.be.equal("1");
184
- amountUToken = 1234000;
185
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(amountUToken, decimal);
186
- (0, chai_1.expect)(token).to.be.equal("1.234");
187
- return [2 /*return*/];
188
- });
189
- }); });
190
- it('getUTokenStringFromToken test', function () { return __awaiter(void 0, void 0, void 0, function () {
191
- var decimal, amountUToken, token;
192
- return __generator(this, function (_a) {
193
- decimal = 6;
194
- amountUToken = 1;
195
- token = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amountUToken, decimal);
196
- (0, chai_1.expect)(token).to.be.equal("1000000");
197
- amountUToken = 1.23;
198
- token = FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amountUToken, decimal);
199
- (0, chai_1.expect)(token).to.be.equal("1230000");
200
- return [2 /*return*/];
201
- });
202
- }); });
203
- it('cutting the ufct decimal point test', function () { return __awaiter(void 0, void 0, void 0, function () {
204
- var decimal, testUTokenValue, testUTokenValueStr, testTokenValueStr;
205
- return __generator(this, function (_a) {
206
- decimal = 6;
207
- testUTokenValue = 533.827284;
208
- testUTokenValueStr = "533.827284";
209
- testTokenValueStr = "0.000533";
210
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(testUTokenValueStr, decimal)).to.be.equal(testTokenValueStr);
211
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(testUTokenValue, decimal)).to.be.equal(testTokenValueStr);
212
- return [2 /*return*/];
213
- });
214
- }); });
215
- it('cutting the decimal point test', function () { return __awaiter(void 0, void 0, void 0, function () {
216
- var decimal, testTokenValue, testTokenValueStr, testUTokenValue, testUTokenValueStr;
217
- return __generator(this, function (_a) {
218
- decimal = 6;
219
- testTokenValue = 533.827284;
220
- testTokenValueStr = "533.827284";
221
- testUTokenValue = 533827284;
222
- testUTokenValueStr = "533827284";
223
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getUTokenFromToken(testTokenValue, decimal)).to.be.equal(testUTokenValue);
224
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getUTokenStringFromTokenStr(testTokenValueStr, decimal)).to.be.equal(testUTokenValueStr);
225
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(testUTokenValueStr, decimal)).to.be.equal(testTokenValueStr);
226
- (0, chai_1.expect)(FirmaUtil_1.FirmaUtil.getTokenStringFromUToken(testUTokenValue, decimal)).to.be.equal(testTokenValueStr);
227
- return [2 /*return*/];
228
- });
229
- }); });
230
- it('getTokenFromUTokenString test', function () { return __awaiter(void 0, void 0, void 0, function () {
231
- var decimal, amountUToken, token;
232
- return __generator(this, function (_a) {
233
- decimal = 6;
234
- amountUToken = "1000000";
235
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(amountUToken, decimal);
236
- (0, chai_1.expect)(token).to.be.equal("1");
237
- amountUToken = "1234000";
238
- token = FirmaUtil_1.FirmaUtil.getTokenStringFromUTokenStr(amountUToken, decimal);
239
- (0, chai_1.expect)(token).to.be.equal("1.234");
240
- return [2 /*return*/];
241
- });
242
- }); });
243
- it('getUTokenStringFromToken test', function () { return __awaiter(void 0, void 0, void 0, function () {
244
- var decimal, amountUToken, token;
245
- return __generator(this, function (_a) {
246
- decimal = 6;
247
- amountUToken = "1";
248
- token = FirmaUtil_1.FirmaUtil.getUTokenStringFromTokenStr(amountUToken, decimal);
249
- (0, chai_1.expect)(token).to.be.equal("1000000");
250
- amountUToken = "1.23";
251
- token = FirmaUtil_1.FirmaUtil.getUFCTStringFromFCTStr(amountUToken);
252
- (0, chai_1.expect)(token).to.be.equal("1230000");
253
- return [2 /*return*/];
254
- });
255
- }); });
256
- it('getFileHashFromBuffer test', function () { return __awaiter(void 0, void 0, void 0, function () {
257
- var testString, enc, buffer, hash;
258
- return __generator(this, function (_a) {
259
- testString = "hello world";
260
- enc = new TextEncoder();
261
- buffer = enc.encode(testString);
262
- hash = FirmaUtil_1.FirmaUtil.getFileHashFromBuffer(buffer);
263
- // hash from sha256 online
264
- (0, chai_1.expect)(hash).to.be.equal("b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");
265
- return [2 /*return*/];
266
- });
267
- }); });
268
- it('parseDurationString test', function () { return __awaiter(void 0, void 0, void 0, function () {
269
- var testString, duration;
270
- return __generator(this, function (_a) {
271
- testString = "1800s";
272
- duration = FirmaUtil_1.FirmaUtil.parseDurationString(testString);
273
- // Correct way to test object properties
274
- (0, chai_1.expect)(duration.seconds).to.be.equal(BigInt(1800));
275
- (0, chai_1.expect)(duration.nanos).to.be.equal(0);
276
- return [2 /*return*/];
277
- });
278
- }); });
279
- it('createDurationFromString test', function () { return __awaiter(void 0, void 0, void 0, function () {
280
- var testString, duration;
281
- return __generator(this, function (_a) {
282
- testString = "1800s";
283
- duration = FirmaUtil_1.FirmaUtil.createDurationFromString(testString);
284
- (0, chai_1.expect)(duration.seconds).to.be.equal(BigInt(1800));
285
- (0, chai_1.expect)(duration.nanos).to.be.equal(0);
286
- return [2 /*return*/];
287
- });
288
- }); });
289
- it('processCommissionRateAsDecimal test - success case', function () { return __awaiter(void 0, void 0, void 0, function () {
290
- var result;
291
- return __generator(this, function (_a) {
292
- result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.000000000000000000");
293
- (0, chai_1.expect)(result).to.equal("0");
294
- result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1");
295
- (0, chai_1.expect)(result).to.equal("1000000000000000000");
296
- result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.99999999999999999999999");
297
- (0, chai_1.expect)(result).to.equal("999999999999999999");
298
- result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.3719281729181018373290120300000831");
299
- (0, chai_1.expect)(result).to.equal("371928172918101837");
300
- result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.000000000000000000");
301
- (0, chai_1.expect)(result).to.equal("1000000000000000000");
302
- result = FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(" 0.75 ");
303
- (0, chai_1.expect)(result).to.equal("750000000000000000");
304
- return [2 /*return*/];
305
- });
306
- }); });
307
- it('processCommissionRateAsDecimal test - failure cases', function () { return __awaiter(void 0, void 0, void 0, function () {
308
- return __generator(this, function (_a) {
309
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("."); }).to.throw("Invalid commission rate format: .");
310
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(""); }).to.throw("Invalid commission rate format: ");
311
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(" "); }).to.throw("Invalid commission rate format: ");
312
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("null"); }).to.throw("Invalid commission rate format: null");
313
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.1abc"); }).to.throw("Invalid commission rate format: 0.1abc");
314
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.1.2"); }).to.throw("Invalid commission rate format: 0.1.2");
315
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("--0.5"); }).to.throw("Invalid commission rate format: --0.5");
316
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.01"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
317
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("2"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
318
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.1"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
319
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-0.1"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
320
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-1"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
321
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-0.01"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
322
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("-0.000000000000000001"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
323
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("1.00000000000000000001"); }).to.throw("Invalid commission rate range. Must be between 0 and 1 inclusive.");
324
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal("0.5%"); }).to.throw("Invalid commission rate format: 0.5%");
325
- (0, chai_1.expect)(function () { return FirmaUtil_1.FirmaUtil.processCommissionRateAsDecimal(" 0.5 extra"); }).to.throw("Invalid commission rate format: 0.5 extra");
326
- return [2 /*return*/];
327
- });
328
- }); });
329
- it('getAccountInfo test', function () { return __awaiter(void 0, void 0, void 0, function () {
330
- var result;
331
- return __generator(this, function (_a) {
332
- switch (_a.label) {
333
- case 0: return [4 /*yield*/, FirmaUtil_1.FirmaUtil.getAccountInfo(aliceAddress)];
334
- case 1:
335
- result = _a.sent();
336
- (0, chai_1.expect)(result).to.have.property('account_number');
337
- (0, chai_1.expect)(result).to.have.property('sequence');
338
- return [2 /*return*/];
339
- }
340
- });
341
- }); });
342
- it('getChainId test', function () { return __awaiter(void 0, void 0, void 0, function () {
343
- var result;
344
- return __generator(this, function (_a) {
345
- switch (_a.label) {
346
- case 0: return [4 /*yield*/, FirmaUtil_1.FirmaUtil.getChainId()];
347
- case 1:
348
- result = _a.sent();
349
- (0, chai_1.expect)(result).to.be.equal(FirmaConfig_1.FirmaConfig.DevNetConfig.chainID);
350
- return [2 /*return*/];
351
- }
352
- });
353
- }); });
354
- });
@@ -1 +0,0 @@
1
- export {};