@firmachain/firma-js 0.2.62 → 0.2.64

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 (83) hide show
  1. package/dist/sdk/FirmaCosmWasmCw721.d.ts +18 -0
  2. package/dist/sdk/FirmaCosmWasmCw721.js +25 -0
  3. package/dist/test/00.wallet.test.d.ts +1 -0
  4. package/dist/test/00.wallet.test.js +90 -0
  5. package/dist/test/01.contract_tx.test.d.ts +1 -0
  6. package/dist/test/01.contract_tx.test.js +149 -0
  7. package/dist/test/02.contract_query.test.d.ts +1 -0
  8. package/dist/test/02.contract_query.test.js +222 -0
  9. package/dist/test/03.contract_scenario.test.d.ts +1 -0
  10. package/dist/test/03.contract_scenario.test.js +562 -0
  11. package/dist/test/04.bank_tx.test.d.ts +1 -0
  12. package/dist/test/04.bank_tx.test.js +127 -0
  13. package/dist/test/05.bank_query.test.d.ts +1 -0
  14. package/dist/test/05.bank_query.test.js +167 -0
  15. package/dist/test/06.feegrant_tx.test.d.ts +1 -0
  16. package/dist/test/06.feegrant_tx.test.js +176 -0
  17. package/dist/test/07.feegrant_query.test.d.ts +1 -0
  18. package/dist/test/07.feegrant_query.test.js +84 -0
  19. package/dist/test/08.gas_estimate.test.d.ts +1 -0
  20. package/dist/test/08.gas_estimate.test.js +703 -0
  21. package/dist/test/09.ipfs.test.d.ts +1 -0
  22. package/dist/test/09.ipfs.test.js +72 -0
  23. package/dist/test/10.nft_tx.test.d.ts +1 -0
  24. package/dist/test/10.nft_tx.test.js +177 -0
  25. package/dist/test/11.nft_query.test.d.ts +1 -0
  26. package/dist/test/11.nft_query.test.js +170 -0
  27. package/dist/test/12.staking_tx.test.d.ts +1 -0
  28. package/dist/test/12.staking_tx.test.js +216 -0
  29. package/dist/test/13.staking_query.test.d.ts +1 -0
  30. package/dist/test/13.staking_query.test.js +209 -0
  31. package/dist/test/14.distribution_tx.test.d.ts +1 -0
  32. package/dist/test/14.distribution_tx.test.js +179 -0
  33. package/dist/test/15.distribution_query.test.d.ts +1 -0
  34. package/dist/test/15.distribution_query.test.js +219 -0
  35. package/dist/test/16.gov_tx.test.d.ts +1 -0
  36. package/dist/test/16.gov_tx.test.js +240 -0
  37. package/dist/test/17.gov_query.test.d.ts +1 -0
  38. package/dist/test/17.gov_query.test.js +118 -0
  39. package/dist/test/18.util.test.d.ts +1 -0
  40. package/dist/test/18.util.test.js +246 -0
  41. package/dist/test/19.chain.test.d.ts +1 -0
  42. package/dist/test/19.chain.test.js +81 -0
  43. package/dist/test/20.slashing_query.test.d.ts +1 -0
  44. package/dist/test/20.slashing_query.test.js +82 -0
  45. package/dist/test/21.token_tx.test.d.ts +1 -0
  46. package/dist/test/21.token_tx.test.js +157 -0
  47. package/dist/test/22.token_query.test.d.ts +1 -0
  48. package/dist/test/22.token_query.test.js +99 -0
  49. package/dist/test/23.authz_tx.test.d.ts +1 -0
  50. package/dist/test/23.authz_tx.test.js +471 -0
  51. package/dist/test/24.authz_query.test.d.ts +1 -0
  52. package/dist/test/24.authz_query.test.js +143 -0
  53. package/dist/test/25.cosmwasm_tx.test.d.ts +1 -0
  54. package/dist/test/25.cosmwasm_tx.test.js +191 -0
  55. package/dist/test/26.cosmwasm_query.test.d.ts +1 -0
  56. package/dist/test/26.cosmwasm_query.test.js +169 -0
  57. package/dist/test/27.arbitary_sign.test.d.ts +1 -0
  58. package/dist/test/27.arbitary_sign.test.js +167 -0
  59. package/dist/test/28.ibc_tx.test.d.ts +1 -0
  60. package/dist/test/28.ibc_tx.test.js +86 -0
  61. package/dist/test/29.mint_query.test.d.ts +1 -0
  62. package/dist/test/29.mint_query.test.js +57 -0
  63. package/dist/test/30.cw20_tx.test.d.ts +1 -0
  64. package/dist/test/30.cw20_tx.test.js +515 -0
  65. package/dist/test/31.cw20_query.test.d.ts +1 -0
  66. package/dist/test/31.cw20_query.test.js +187 -0
  67. package/dist/test/32.cw721_tx.test.d.ts +1 -0
  68. package/dist/test/32.cw721_tx.test.js +433 -0
  69. package/dist/test/33.cw721_query.test.d.ts +1 -0
  70. package/dist/test/33.cw721_query.test.js +219 -0
  71. package/dist/test/34.cw_bridge_tx.test.d.ts +1 -0
  72. package/dist/test/34.cw_bridge_tx.test.js +365 -0
  73. package/dist/test/35.cw_bridge_tx_low.test.d.ts +1 -0
  74. package/dist/test/35.cw_bridge_tx_low.test.js +258 -0
  75. package/dist/test/36.cw_bridge_query.test.d.ts +1 -0
  76. package/dist/test/36.cw_bridge_query.test.js +182 -0
  77. package/dist/test/37.cw_marketplace_tx.test.d.ts +1 -0
  78. package/dist/test/37.cw_marketplace_tx.test.js +794 -0
  79. package/dist/test/38.cw_marketplace_query.test.d.ts +1 -0
  80. package/dist/test/38.cw_marketplace_query.test.js +128 -0
  81. package/dist/test/config_test.d.ts +5 -0
  82. package/dist/test/config_test.js +20 -0
  83. package/package.json +1 -1
@@ -0,0 +1,703 @@
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 FirmaSDK_1 = require("../sdk/FirmaSDK");
40
+ var FirmaUtil_1 = require("../sdk/FirmaUtil");
41
+ var config_test_1 = require("./config_test");
42
+ var common_1 = require("../sdk/firmachain/common");
43
+ describe.skip('[08. Gas Estimation Test]', function () {
44
+ var firma;
45
+ beforeEach(function () {
46
+ firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
47
+ });
48
+ it("1-1. bank send gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
49
+ var wallet, targetWallet, amount, gas, _a, _b, _c, error_1;
50
+ return __generator(this, function (_d) {
51
+ switch (_d.label) {
52
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
53
+ case 1:
54
+ wallet = _d.sent();
55
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
56
+ case 2:
57
+ targetWallet = _d.sent();
58
+ amount = 1;
59
+ _d.label = 3;
60
+ case 3:
61
+ _d.trys.push([3, 6, , 7]);
62
+ _b = (_a = firma.Bank).getGasEstimationSend;
63
+ _c = [wallet];
64
+ return [4 /*yield*/, targetWallet.getAddress()];
65
+ case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent(), amount]))];
66
+ case 5:
67
+ gas = _d.sent();
68
+ console.log("estimateGas : " + gas);
69
+ return [3 /*break*/, 7];
70
+ case 6:
71
+ error_1 = _d.sent();
72
+ console.log(error_1);
73
+ return [3 /*break*/, 7];
74
+ case 7: return [2 /*return*/];
75
+ }
76
+ });
77
+ }); });
78
+ it("1-2. bank sendToken gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
79
+ var wallet, targetWallet, amount, tokenID, decimal, gas, _a, _b, _c, error_2;
80
+ return __generator(this, function (_d) {
81
+ switch (_d.label) {
82
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
83
+ case 1:
84
+ wallet = _d.sent();
85
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
86
+ case 2:
87
+ targetWallet = _d.sent();
88
+ amount = 1;
89
+ tokenID = "ukomx";
90
+ decimal = 6;
91
+ _d.label = 3;
92
+ case 3:
93
+ _d.trys.push([3, 6, , 7]);
94
+ _b = (_a = firma.Bank).getGasEstimationSendToken;
95
+ _c = [wallet];
96
+ return [4 /*yield*/, targetWallet.getAddress()];
97
+ case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent(), tokenID, amount, decimal]))];
98
+ case 5:
99
+ gas = _d.sent();
100
+ console.log("estimateGas : " + gas);
101
+ return [3 /*break*/, 7];
102
+ case 6:
103
+ error_2 = _d.sent();
104
+ console.log(error_2);
105
+ return [3 /*break*/, 7];
106
+ case 7: return [2 /*return*/];
107
+ }
108
+ });
109
+ }); });
110
+ it("2-1. Contract addContractLog getGasEstimationFromUnSignedTxList gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
111
+ var wallet, contractHash, timeStamp, eventName, ownerAddress, jsonString, tx1, gas;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
115
+ case 1:
116
+ wallet = _a.sent();
117
+ contractHash = "0xsalkdjfasldkjf2";
118
+ timeStamp = Math.round(+new Date() / 1000);
119
+ ;
120
+ eventName = "CreateContract";
121
+ return [4 /*yield*/, wallet.getAddress()];
122
+ case 2:
123
+ ownerAddress = _a.sent();
124
+ jsonString = "{}";
125
+ return [4 /*yield*/, firma.Contract.getUnsignedTxAddContractLog(wallet, contractHash, timeStamp, eventName, ownerAddress, jsonString)];
126
+ case 3:
127
+ tx1 = _a.sent();
128
+ return [4 /*yield*/, firma.Contract.getGasEstimationFromUnSignedTxList(wallet, [tx1, tx1, tx1, tx1, tx1])];
129
+ case 4:
130
+ gas = _a.sent();
131
+ console.log("estimateGas : " + gas);
132
+ return [2 /*return*/];
133
+ }
134
+ });
135
+ }); });
136
+ it("2-2. Contract addContractLog gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
137
+ var wallet, contractHash, timeStamp, eventName, ownerAddress, jsonString, gas;
138
+ return __generator(this, function (_a) {
139
+ switch (_a.label) {
140
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
141
+ case 1:
142
+ wallet = _a.sent();
143
+ contractHash = "0xsalkdjfasldkjf2";
144
+ timeStamp = Math.round(+new Date() / 1000);
145
+ ;
146
+ eventName = "CreateContract";
147
+ return [4 /*yield*/, wallet.getAddress()];
148
+ case 2:
149
+ ownerAddress = _a.sent();
150
+ jsonString = "{}";
151
+ return [4 /*yield*/, firma.Contract.getGasEstimationAddContractLog(wallet, contractHash, timeStamp, eventName, ownerAddress, jsonString)];
152
+ case 3:
153
+ gas = _a.sent();
154
+ console.log("estimateGas : " + gas);
155
+ return [2 /*return*/];
156
+ }
157
+ });
158
+ }); });
159
+ it("2-3. Contract createContractFile gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
160
+ var wallet, timeStamp, fileHash, ownerAddress, ownerList, jsonString, gas;
161
+ return __generator(this, function (_a) {
162
+ switch (_a.label) {
163
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
164
+ case 1:
165
+ wallet = _a.sent();
166
+ timeStamp = Math.round(+new Date() / 1000);
167
+ fileHash = "0xklsdjflaksjflaksjf" + timeStamp;
168
+ return [4 /*yield*/, wallet.getAddress()];
169
+ case 2:
170
+ ownerAddress = _a.sent();
171
+ ownerList = [ownerAddress, ownerAddress];
172
+ jsonString = "{}";
173
+ return [4 /*yield*/, firma.Contract.getGasEstimationCreateContractFile(wallet, fileHash, timeStamp, ownerList, jsonString)];
174
+ case 3:
175
+ gas = _a.sent();
176
+ console.log("estimateGas : " + gas);
177
+ return [2 /*return*/];
178
+ }
179
+ });
180
+ }); });
181
+ it("3-1. NFT Mint gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
182
+ var wallet, gas;
183
+ return __generator(this, function (_a) {
184
+ switch (_a.label) {
185
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
186
+ case 1:
187
+ wallet = _a.sent();
188
+ return [4 /*yield*/, firma.Nft.getGasEstimationMint(wallet, "https://naver.com")];
189
+ case 2:
190
+ gas = _a.sent();
191
+ console.log("estimateGas : " + gas);
192
+ return [2 /*return*/];
193
+ }
194
+ });
195
+ }); });
196
+ it("3-2. NFT Transfer gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
197
+ var wallet, targetWallet, result, jsonData, nftId, gas, _a, _b, _c;
198
+ return __generator(this, function (_d) {
199
+ switch (_d.label) {
200
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
201
+ case 1:
202
+ wallet = _d.sent();
203
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
204
+ case 2:
205
+ targetWallet = _d.sent();
206
+ return [4 /*yield*/, firma.Nft.mint(wallet, "https://naver.com")];
207
+ case 3:
208
+ result = _d.sent();
209
+ jsonData = JSON.parse(result.rawLog);
210
+ nftId = jsonData[0]["events"][0]["attributes"][2]["value"];
211
+ _b = (_a = firma.Nft).getGasEstimationTransfer;
212
+ _c = [wallet];
213
+ return [4 /*yield*/, targetWallet.getAddress()];
214
+ case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent(), nftId]))];
215
+ case 5:
216
+ gas = _d.sent();
217
+ console.log("estimateGas : " + gas);
218
+ return [2 /*return*/];
219
+ }
220
+ });
221
+ }); });
222
+ it("3-3. NFT Burn gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
223
+ var wallet, result, jsonData, nftId, gas;
224
+ return __generator(this, function (_a) {
225
+ switch (_a.label) {
226
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
227
+ case 1:
228
+ wallet = _a.sent();
229
+ return [4 /*yield*/, firma.Nft.mint(wallet, "https://naver.com")];
230
+ case 2:
231
+ result = _a.sent();
232
+ jsonData = JSON.parse(result.rawLog);
233
+ nftId = jsonData[0]["events"][0]["attributes"][2]["value"];
234
+ return [4 /*yield*/, firma.Nft.getGasEstimationBurn(wallet, nftId)];
235
+ case 3:
236
+ gas = _a.sent();
237
+ console.log("estimateGas : " + gas);
238
+ return [2 /*return*/];
239
+ }
240
+ });
241
+ }); });
242
+ it.skip("4-1. Feegrant GrantPeriodicAllowance gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
243
+ var aliceWallet, bobWallet, spendLimit, expirationDate, periodicAllowanceData, gas, _a, _b, _c;
244
+ return __generator(this, function (_d) {
245
+ switch (_d.label) {
246
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
247
+ case 1:
248
+ aliceWallet = _d.sent();
249
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
250
+ case 2:
251
+ bobWallet = _d.sent();
252
+ spendLimit = 200000;
253
+ expirationDate = new Date();
254
+ expirationDate.setMinutes(expirationDate.getMinutes() + 2);
255
+ periodicAllowanceData = {
256
+ // basicSpendLimit: undefined,
257
+ // basicExpiration: undefined,
258
+ periodSeconds: 30,
259
+ periodSpendLimit: 2000,
260
+ periodCanSpend: 10000,
261
+ periodReset: expirationDate
262
+ };
263
+ _b = (_a = firma.FeeGrant).getGasEstimationGrantPeriodicAllowance;
264
+ _c = [aliceWallet];
265
+ return [4 /*yield*/, bobWallet.getAddress()];
266
+ case 3: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent(), periodicAllowanceData]))];
267
+ case 4:
268
+ gas = _d.sent();
269
+ console.log("estimateGas : " + gas);
270
+ return [2 /*return*/];
271
+ }
272
+ });
273
+ }); });
274
+ it.skip("4-2. Feegrant GrantBasicAllowance gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
275
+ var aliceWallet, bobWallet, gas, _a, _b, _c;
276
+ return __generator(this, function (_d) {
277
+ switch (_d.label) {
278
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
279
+ case 1:
280
+ aliceWallet = _d.sent();
281
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
282
+ case 2:
283
+ bobWallet = _d.sent();
284
+ _b = (_a = firma.FeeGrant).getGasEstimationGrantBasicAllowance;
285
+ _c = [aliceWallet];
286
+ return [4 /*yield*/, bobWallet.getAddress()];
287
+ case 3: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
288
+ case 4:
289
+ gas = _d.sent();
290
+ console.log("estimateGas : " + gas);
291
+ return [2 /*return*/];
292
+ }
293
+ });
294
+ }); });
295
+ it("4-3. Feegrant revokeAllowance gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
296
+ var aliceWallet, bobWallet, gas, _a, _b, _c;
297
+ return __generator(this, function (_d) {
298
+ switch (_d.label) {
299
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
300
+ case 1:
301
+ aliceWallet = _d.sent();
302
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
303
+ case 2:
304
+ bobWallet = _d.sent();
305
+ _b = (_a = firma.FeeGrant).getGasEstimationRevokeAllowance;
306
+ _c = [aliceWallet];
307
+ return [4 /*yield*/, bobWallet.getAddress()];
308
+ case 3: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
309
+ case 4:
310
+ gas = _d.sent();
311
+ console.log("estimateGas : " + gas);
312
+ return [2 /*return*/];
313
+ }
314
+ });
315
+ }); });
316
+ // var result = await firma.Staking.delegate(wallet, validatorAddress, amountFCT);
317
+ // var result = await firma.Staking.undelegate(wallet, validatorAddress, amount);
318
+ //let result1 = await firma.Staking.redelegate(wallet, srcValidatorAddress, dstValidatorAddress, amount,{ gas: 300000, fee: 3000 });
319
+ it("5-1. Staking delegate gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
320
+ var wallet, validatorWallet, validatorAddress, _a, _b, amountFCT, gas;
321
+ return __generator(this, function (_c) {
322
+ switch (_c.label) {
323
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
324
+ case 1:
325
+ wallet = _c.sent();
326
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.validatorMnemonic)];
327
+ case 2:
328
+ validatorWallet = _c.sent();
329
+ _b = (_a = FirmaUtil_1.FirmaUtil).getValOperAddressFromAccAddress;
330
+ return [4 /*yield*/, validatorWallet.getAddress()];
331
+ case 3:
332
+ validatorAddress = _b.apply(_a, [_c.sent()]);
333
+ amountFCT = 60;
334
+ return [4 /*yield*/, firma.Staking.getGasEstimationDelegate(wallet, validatorAddress, amountFCT)];
335
+ case 4:
336
+ gas = _c.sent();
337
+ console.log("estimateGas : " + gas);
338
+ return [2 /*return*/];
339
+ }
340
+ });
341
+ }); });
342
+ it("5-2. Staking undelegate gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
343
+ var wallet, validatorWallet, validatorAddress, _a, _b, amount, gas;
344
+ return __generator(this, function (_c) {
345
+ switch (_c.label) {
346
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
347
+ case 1:
348
+ wallet = _c.sent();
349
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.validatorMnemonic)];
350
+ case 2:
351
+ validatorWallet = _c.sent();
352
+ _b = (_a = FirmaUtil_1.FirmaUtil).getValOperAddressFromAccAddress;
353
+ return [4 /*yield*/, validatorWallet.getAddress()];
354
+ case 3:
355
+ validatorAddress = _b.apply(_a, [_c.sent()]);
356
+ amount = 5;
357
+ return [4 /*yield*/, firma.Staking.getGasEstimationUndelegate(wallet, validatorAddress, amount)];
358
+ case 4:
359
+ gas = _c.sent();
360
+ console.log("estimateGas : " + gas);
361
+ return [2 /*return*/];
362
+ }
363
+ });
364
+ }); });
365
+ it("5-3. Staking redelegate gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
366
+ var wallet, validatorList, srcValidatorAddress, dstValidatorAddress, amount, gas, error_3;
367
+ return __generator(this, function (_a) {
368
+ switch (_a.label) {
369
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
370
+ case 1:
371
+ wallet = _a.sent();
372
+ return [4 /*yield*/, firma.Staking.getValidatorList()];
373
+ case 2:
374
+ validatorList = (_a.sent()).dataList;
375
+ if (validatorList.length < 2)
376
+ return [2 /*return*/];
377
+ srcValidatorAddress = validatorList[0].operator_address;
378
+ dstValidatorAddress = validatorList[1].operator_address;
379
+ amount = 10;
380
+ _a.label = 3;
381
+ case 3:
382
+ _a.trys.push([3, 5, , 6]);
383
+ return [4 /*yield*/, firma.Staking.getGasEstimationRedelegate(wallet, srcValidatorAddress, dstValidatorAddress, amount, { gas: 300000, fee: 30000 })];
384
+ case 4:
385
+ gas = _a.sent();
386
+ console.log("estimateGas : " + gas);
387
+ return [3 /*break*/, 6];
388
+ case 5:
389
+ error_3 = _a.sent();
390
+ console.log(error_3);
391
+ return [3 /*break*/, 6];
392
+ case 6: return [2 /*return*/];
393
+ }
394
+ });
395
+ }); });
396
+ it("6-1. Distribution withdrawAllRewards gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
397
+ var wallet, delegationList, _a, _b, validatorAddress, gas;
398
+ return __generator(this, function (_c) {
399
+ switch (_c.label) {
400
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
401
+ case 1:
402
+ wallet = _c.sent();
403
+ _b = (_a = firma.Staking).getTotalDelegationInfo;
404
+ return [4 /*yield*/, wallet.getAddress()];
405
+ case 2: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
406
+ case 3: return [4 /*yield*/, (_c.sent()).dataList];
407
+ case 4:
408
+ delegationList = (_c.sent());
409
+ validatorAddress = delegationList[0].delegation.validator_address;
410
+ return [4 /*yield*/, firma.Distribution.getGasEstimationWithdrawAllRewards(wallet, validatorAddress)];
411
+ case 5:
412
+ gas = _c.sent();
413
+ console.log("estimateGas : " + gas);
414
+ return [2 /*return*/];
415
+ }
416
+ });
417
+ }); });
418
+ it("6-2. Distribution withdrawValidatorCommission gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
419
+ var wallet, address, validatorAddress, gas;
420
+ return __generator(this, function (_a) {
421
+ switch (_a.label) {
422
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.validatorMnemonic)];
423
+ case 1:
424
+ wallet = _a.sent();
425
+ return [4 /*yield*/, wallet.getAddress()];
426
+ case 2:
427
+ address = _a.sent();
428
+ validatorAddress = FirmaUtil_1.FirmaUtil.getValOperAddressFromAccAddress(address);
429
+ return [4 /*yield*/, firma.Distribution.getGasEstimationWithdrawValidatorCommission(wallet, validatorAddress)];
430
+ case 3:
431
+ gas = _a.sent();
432
+ console.log("estimateGas : " + gas);
433
+ return [2 /*return*/];
434
+ }
435
+ });
436
+ }); });
437
+ it("6-3. Distribution fundCommunityPool gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
438
+ var wallet, amount, gas;
439
+ return __generator(this, function (_a) {
440
+ switch (_a.label) {
441
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.validatorMnemonic)];
442
+ case 1:
443
+ wallet = _a.sent();
444
+ amount = 1;
445
+ return [4 /*yield*/, firma.Distribution.getGasEstimationFundCommunityPool(wallet, amount)];
446
+ case 2:
447
+ gas = _a.sent();
448
+ console.log("estimateGas : " + gas);
449
+ return [2 /*return*/];
450
+ }
451
+ });
452
+ }); });
453
+ it("6-4. Distribution setWithdrawAddress gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
454
+ var aliceWallet, bobWallet, gas, _a, _b, _c;
455
+ return __generator(this, function (_d) {
456
+ switch (_d.label) {
457
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
458
+ case 1:
459
+ aliceWallet = _d.sent();
460
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
461
+ case 2:
462
+ bobWallet = _d.sent();
463
+ _b = (_a = firma.Distribution).getGasEstimationSetWithdrawAddress;
464
+ _c = [aliceWallet];
465
+ return [4 /*yield*/, bobWallet.getAddress()];
466
+ case 3: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
467
+ case 4:
468
+ gas = _d.sent();
469
+ console.log("estimateGas : " + gas);
470
+ return [2 /*return*/];
471
+ }
472
+ });
473
+ }); });
474
+ // var result = await firma.Gov.submitTextProposal(wallet, title, description, initialDepositFCT);
475
+ // var result = await firma.Gov.submitCommunityPoolSpendProposal(aliceWallet, title, description, initialDepositFCT, amount, recipient);
476
+ // var result = await firma.Gov.submitParameterChangeProposal(aliceWallet, title, description, initialDepositFCT, changeParamList);
477
+ // var result = await firma.Gov.submitSoftwareUpgradeProposalByHeight(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeHeight);
478
+ // var result = await firma.Gov.submitCancelSoftwareUpgradeProposal(aliceWallet, title, description, initialDepositFCT);
479
+ // var result = await firma.Gov.deposit(wallet, proposalId, amount);
480
+ // var result = await firma.Gov.vote(wallet, proposalId, VotingOption.VOTE_OPTION_YES);
481
+ it("7-1. Gov submitTextProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
482
+ var wallet, initialDepositFCT, title, description, result, gas;
483
+ return __generator(this, function (_a) {
484
+ switch (_a.label) {
485
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
486
+ case 1:
487
+ wallet = _a.sent();
488
+ initialDepositFCT = 10;
489
+ title = "test submit proposal";
490
+ description = "test description";
491
+ return [4 /*yield*/, firma.Gov.submitTextProposal(wallet, title, description, initialDepositFCT)];
492
+ case 2:
493
+ result = _a.sent();
494
+ return [4 /*yield*/, firma.Gov.getGasEstimationSubmitTextProposal(wallet, title, description, initialDepositFCT)];
495
+ case 3:
496
+ gas = _a.sent();
497
+ console.log("estimateGas : " + gas);
498
+ return [2 /*return*/];
499
+ }
500
+ });
501
+ }); });
502
+ it("7-2. Gov submitCommunityPoolSpendProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
503
+ var aliceWallet, bobWallet, initialDepositFCT, title, description, amount, recipient, gas;
504
+ return __generator(this, function (_a) {
505
+ switch (_a.label) {
506
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
507
+ case 1:
508
+ aliceWallet = _a.sent();
509
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
510
+ case 2:
511
+ bobWallet = _a.sent();
512
+ initialDepositFCT = 10;
513
+ title = "Community spend proposal1";
514
+ description = "This is a community spend proposal";
515
+ amount = 1000;
516
+ return [4 /*yield*/, bobWallet.getAddress()];
517
+ case 3:
518
+ recipient = _a.sent();
519
+ return [4 /*yield*/, firma.Gov.getGasEstimationSubmitCommunityPoolSpendProposal(aliceWallet, title, description, initialDepositFCT, amount, recipient)];
520
+ case 4:
521
+ gas = _a.sent();
522
+ console.log("estimateGas : " + gas);
523
+ return [2 /*return*/];
524
+ }
525
+ });
526
+ }); });
527
+ it("7-3. Gov submitParameterChangeProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
528
+ var aliceWallet, initialDepositFCT, title, description, changeParamList, gas;
529
+ return __generator(this, function (_a) {
530
+ switch (_a.label) {
531
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
532
+ case 1:
533
+ aliceWallet = _a.sent();
534
+ initialDepositFCT = 10;
535
+ title = "Parameter Change proposal1";
536
+ description = "This is a Parameter change proposal";
537
+ changeParamList = [{
538
+ subspace: "staking",
539
+ key: "MaxValidators",
540
+ value: "100",
541
+ }];
542
+ return [4 /*yield*/, firma.Gov.getGasEstimationSubmitParameterChangeProposal(aliceWallet, title, description, initialDepositFCT, changeParamList)];
543
+ case 2:
544
+ gas = _a.sent();
545
+ console.log("estimateGas : " + gas);
546
+ return [2 /*return*/];
547
+ }
548
+ });
549
+ }); });
550
+ it("7-4. Gov submitSoftwareUpgradeProposalByHeight gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
551
+ var aliceWallet, initialDepositFCT, title, description, upgradeName, upgradeHeight, gas;
552
+ return __generator(this, function (_a) {
553
+ switch (_a.label) {
554
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
555
+ case 1:
556
+ aliceWallet = _a.sent();
557
+ initialDepositFCT = 10000;
558
+ title = "Software Upgrade proposal1";
559
+ description = "This is a software upgrade proposal";
560
+ upgradeName = "v0.2.7";
561
+ upgradeHeight = 20000000;
562
+ return [4 /*yield*/, firma.Gov.getGasEstimationSubmitSoftwareUpgradeProposalByHeight(aliceWallet, title, description, initialDepositFCT, upgradeName, upgradeHeight)];
563
+ case 2:
564
+ gas = _a.sent();
565
+ console.log("estimateGas : " + gas);
566
+ return [2 /*return*/];
567
+ }
568
+ });
569
+ }); });
570
+ it("7-5. Gov submitCancelSoftwareUpgradeProposal gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
571
+ var aliceWallet, initialDepositFCT, title, description, gas;
572
+ return __generator(this, function (_a) {
573
+ switch (_a.label) {
574
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
575
+ case 1:
576
+ aliceWallet = _a.sent();
577
+ initialDepositFCT = 1000;
578
+ title = "Software Upgrade proposal1";
579
+ description = "This is a software upgrade proposal";
580
+ return [4 /*yield*/, firma.Gov.getGasEstimationSubmitCancelSoftwareUpgradeProposal(aliceWallet, title, description, initialDepositFCT)];
581
+ case 2:
582
+ gas = _a.sent();
583
+ console.log("estimateGas : " + gas);
584
+ return [2 /*return*/];
585
+ }
586
+ });
587
+ }); });
588
+ it("7-6. Gov deposit gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
589
+ var wallet, proposalId, amount, result, gas;
590
+ return __generator(this, function (_a) {
591
+ switch (_a.label) {
592
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
593
+ case 1:
594
+ wallet = _a.sent();
595
+ proposalId = 1;
596
+ amount = 1000;
597
+ return [4 /*yield*/, firma.Gov.deposit(wallet, proposalId, amount)];
598
+ case 2:
599
+ result = _a.sent();
600
+ return [4 /*yield*/, firma.Gov.getGasEstimationDeposit(wallet, proposalId, amount)];
601
+ case 3:
602
+ gas = _a.sent();
603
+ console.log("estimateGas : " + gas);
604
+ return [2 /*return*/];
605
+ }
606
+ });
607
+ }); });
608
+ it("7-7. Gov vote gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
609
+ var wallet, proposalId, gas;
610
+ return __generator(this, function (_a) {
611
+ switch (_a.label) {
612
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
613
+ case 1:
614
+ wallet = _a.sent();
615
+ proposalId = 1;
616
+ return [4 /*yield*/, firma.Gov.getGasEstimationVote(wallet, proposalId, common_1.VotingOption.VOTE_OPTION_YES)];
617
+ case 2:
618
+ gas = _a.sent();
619
+ console.log("estimateGas : " + gas);
620
+ return [2 /*return*/];
621
+ }
622
+ });
623
+ }); });
624
+ it("8-1. Token createToken gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
625
+ var wallet, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable, gas;
626
+ return __generator(this, function (_a) {
627
+ switch (_a.label) {
628
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
629
+ case 1:
630
+ wallet = _a.sent();
631
+ tokenName = "KOMX TOKEN";
632
+ symbol = "KOMX63232";
633
+ tokenURI = "https://naver.com";
634
+ totalSupply = 10000;
635
+ decimal = 6;
636
+ mintable = true;
637
+ burnable = true;
638
+ return [4 /*yield*/, firma.Token.getGasEstimationCreateToken(wallet, tokenName, symbol, tokenURI, totalSupply, decimal, mintable, burnable)];
639
+ case 2:
640
+ gas = _a.sent();
641
+ console.log("estimateGas : " + gas);
642
+ return [2 /*return*/];
643
+ }
644
+ });
645
+ }); });
646
+ it("8-2. Token mint gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
647
+ var wallet, bobAddress, tokenID, amount, decimal, gas;
648
+ return __generator(this, function (_a) {
649
+ switch (_a.label) {
650
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
651
+ case 1:
652
+ wallet = _a.sent();
653
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
654
+ case 2: return [4 /*yield*/, (_a.sent()).getAddress()];
655
+ case 3:
656
+ bobAddress = _a.sent();
657
+ tokenID = "ukomx6";
658
+ amount = 10000;
659
+ decimal = 6;
660
+ return [4 /*yield*/, firma.Token.getGasEstimationMint(wallet, tokenID, amount, decimal, bobAddress)];
661
+ case 4:
662
+ gas = _a.sent();
663
+ console.log("estimateGas : " + gas);
664
+ return [2 /*return*/];
665
+ }
666
+ });
667
+ }); });
668
+ it("8-3. Token burn gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
669
+ var wallet, tokenID, amount, decimal, gas;
670
+ return __generator(this, function (_a) {
671
+ switch (_a.label) {
672
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
673
+ case 1:
674
+ wallet = _a.sent();
675
+ tokenID = "ukomx6";
676
+ amount = 10;
677
+ decimal = 6;
678
+ return [4 /*yield*/, firma.Token.getGasEstimationBurn(wallet, tokenID, amount, decimal)];
679
+ case 2:
680
+ gas = _a.sent();
681
+ console.log("estimateGas : " + gas);
682
+ return [2 /*return*/];
683
+ }
684
+ });
685
+ }); });
686
+ it("8-4. Token updateTokenURI gas estimation", function () { return __awaiter(void 0, void 0, void 0, function () {
687
+ var wallet, tokenID, tokenURI, gas;
688
+ return __generator(this, function (_a) {
689
+ switch (_a.label) {
690
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
691
+ case 1:
692
+ wallet = _a.sent();
693
+ tokenID = "ukomx6";
694
+ tokenURI = "https://firmachain.org";
695
+ return [4 /*yield*/, firma.Token.getGasEstimationUpdateTokenURI(wallet, tokenID, tokenURI)];
696
+ case 2:
697
+ gas = _a.sent();
698
+ console.log("estimateGas : " + gas);
699
+ return [2 /*return*/];
700
+ }
701
+ });
702
+ }); });
703
+ });