@firmachain/firma-js 0.2.29 → 0.2.32

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 (52) hide show
  1. package/dist/sdk/FirmaAuthzService.d.ts +41 -0
  2. package/dist/sdk/FirmaAuthzService.js +633 -0
  3. package/dist/sdk/FirmaBankService.d.ts +2 -1
  4. package/dist/sdk/FirmaBankService.js +3 -0
  5. package/dist/sdk/FirmaCosmWasmService.d.ts +38 -0
  6. package/dist/sdk/FirmaCosmWasmService.js +667 -0
  7. package/dist/sdk/FirmaDistributionService.d.ts +2 -1
  8. package/dist/sdk/FirmaDistributionService.js +3 -0
  9. package/dist/sdk/FirmaIbcService.d.ts +15 -0
  10. package/dist/sdk/FirmaIbcService.js +144 -0
  11. package/dist/sdk/FirmaMobileSDK.d.ts +3 -1
  12. package/dist/sdk/FirmaMobileSDK.js +4 -1
  13. package/dist/sdk/FirmaSDK.d.ts +7 -1
  14. package/dist/sdk/FirmaSDK.js +10 -1
  15. package/dist/sdk/FirmaStakingService.d.ts +18 -5
  16. package/dist/sdk/FirmaStakingService.js +15 -8
  17. package/dist/sdk/FirmaUtil.d.ts +7 -0
  18. package/dist/sdk/FirmaUtil.js +69 -1
  19. package/dist/sdk/FirmaWalletService.d.ts +3 -0
  20. package/dist/sdk/FirmaWalletService.js +18 -10
  21. package/dist/sdk/firmachain/amino/signer.d.ts +1 -2
  22. package/dist/sdk/firmachain/authz/AuthzQueryClient.d.ts +48 -0
  23. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +142 -0
  24. package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +22 -0
  25. package/dist/sdk/firmachain/authz/AuthzTxClient.js +44 -0
  26. package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +147 -0
  27. package/dist/sdk/firmachain/authz/AuthzTxTypes.js +358 -0
  28. package/dist/sdk/firmachain/authz/index.d.ts +3 -0
  29. package/dist/sdk/firmachain/authz/index.js +15 -0
  30. package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -0
  31. package/dist/sdk/firmachain/common/ITxClient.js +9 -0
  32. package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +50 -0
  33. package/dist/sdk/firmachain/common/signingaminostargateclient.js +267 -0
  34. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.d.ts +52 -0
  35. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +193 -0
  36. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +37 -0
  37. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +56 -0
  38. package/dist/sdk/firmachain/cosmwasm/index.d.ts +3 -0
  39. package/dist/sdk/firmachain/cosmwasm/index.js +15 -0
  40. package/dist/sdk/firmachain/ibc/IbcQueryClient.d.ts +34 -0
  41. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +71 -0
  42. package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +12 -0
  43. package/dist/sdk/firmachain/ibc/IbcTxClient.js +36 -0
  44. package/dist/sdk/firmachain/ibc/index.d.ts +3 -0
  45. package/dist/sdk/firmachain/ibc/index.js +15 -0
  46. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +17 -4
  47. package/dist/sdk/firmachain/staking/StakingQueryClient.js +38 -18
  48. package/package.json +4 -2
  49. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +0 -94
  50. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +0 -437
  51. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +0 -23
  52. package/dist/sdk/firmachain/amino/secp256k1wallet.js +0 -141
@@ -0,0 +1,667 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.FirmaCosmWasmService = void 0;
43
+ var cosmwasm_1 = require("./firmachain/cosmwasm");
44
+ var encoding_1 = require("@cosmjs/encoding");
45
+ var FirmaUtil_1 = require("./FirmaUtil");
46
+ var pako_1 = __importDefault(require("pako"));
47
+ var long_1 = __importDefault(require("long"));
48
+ var FirmaCosmWasmService = /** @class */ (function () {
49
+ function FirmaCosmWasmService(config) {
50
+ this.config = config;
51
+ }
52
+ FirmaCosmWasmService.prototype.getTxClient = function (wallet) {
53
+ return new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
54
+ };
55
+ FirmaCosmWasmService.prototype.getGasEstimationStoreCode = function (wallet, wasmCode, accessConfig, txMisc) {
56
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ var txRaw, error_1;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0:
62
+ _a.trys.push([0, 3, , 4]);
63
+ return [4 /*yield*/, this.getSignedTxStoreCode(wallet, wasmCode, accessConfig, txMisc)];
64
+ case 1:
65
+ txRaw = _a.sent();
66
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
67
+ case 2: return [2 /*return*/, _a.sent()];
68
+ case 3:
69
+ error_1 = _a.sent();
70
+ FirmaUtil_1.FirmaUtil.printLog(error_1);
71
+ throw error_1;
72
+ case 4: return [2 /*return*/];
73
+ }
74
+ });
75
+ });
76
+ };
77
+ FirmaCosmWasmService.prototype.storeCode = function (wallet, wasmCode, accessConfig, txMisc) {
78
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var txRaw, bankTxClient, error_2;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0:
84
+ _a.trys.push([0, 3, , 4]);
85
+ return [4 /*yield*/, this.getSignedTxStoreCode(wallet, wasmCode, accessConfig, txMisc)];
86
+ case 1:
87
+ txRaw = _a.sent();
88
+ bankTxClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
89
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
90
+ case 2: return [2 /*return*/, _a.sent()];
91
+ case 3:
92
+ error_2 = _a.sent();
93
+ FirmaUtil_1.FirmaUtil.printLog(error_2);
94
+ throw error_2;
95
+ case 4: return [2 /*return*/];
96
+ }
97
+ });
98
+ });
99
+ };
100
+ FirmaCosmWasmService.prototype.getGasEstimationUpdateAdmin = function (wallet, contractAddress, adminAddress, txMisc) {
101
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var txRaw, error_3;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ _a.trys.push([0, 3, , 4]);
108
+ return [4 /*yield*/, this.getSignedTxUpdateAdmin(wallet, contractAddress, adminAddress, txMisc)];
109
+ case 1:
110
+ txRaw = _a.sent();
111
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
112
+ case 2: return [2 /*return*/, _a.sent()];
113
+ case 3:
114
+ error_3 = _a.sent();
115
+ FirmaUtil_1.FirmaUtil.printLog(error_3);
116
+ throw error_3;
117
+ case 4: return [2 /*return*/];
118
+ }
119
+ });
120
+ });
121
+ };
122
+ FirmaCosmWasmService.prototype.updateAdmin = function (wallet, contractAddress, adminAddress, txMisc) {
123
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
124
+ return __awaiter(this, void 0, void 0, function () {
125
+ var txRaw, bankTxClient, error_4;
126
+ return __generator(this, function (_a) {
127
+ switch (_a.label) {
128
+ case 0:
129
+ _a.trys.push([0, 3, , 4]);
130
+ return [4 /*yield*/, this.getSignedTxUpdateAdmin(wallet, contractAddress, adminAddress, txMisc)];
131
+ case 1:
132
+ txRaw = _a.sent();
133
+ bankTxClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
134
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
135
+ case 2: return [2 /*return*/, _a.sent()];
136
+ case 3:
137
+ error_4 = _a.sent();
138
+ FirmaUtil_1.FirmaUtil.printLog(error_4);
139
+ throw error_4;
140
+ case 4: return [2 /*return*/];
141
+ }
142
+ });
143
+ });
144
+ };
145
+ FirmaCosmWasmService.prototype.getGasEstimationClearAdmin = function (wallet, contractAddress, txMisc) {
146
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ var txRaw, error_5;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ _a.trys.push([0, 3, , 4]);
153
+ return [4 /*yield*/, this.getSignedTxClearAdmin(wallet, contractAddress, txMisc)];
154
+ case 1:
155
+ txRaw = _a.sent();
156
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
157
+ case 2: return [2 /*return*/, _a.sent()];
158
+ case 3:
159
+ error_5 = _a.sent();
160
+ FirmaUtil_1.FirmaUtil.printLog(error_5);
161
+ throw error_5;
162
+ case 4: return [2 /*return*/];
163
+ }
164
+ });
165
+ });
166
+ };
167
+ FirmaCosmWasmService.prototype.clearAdmin = function (wallet, contractAddress, txMisc) {
168
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ var txRaw, bankTxClient, error_6;
171
+ return __generator(this, function (_a) {
172
+ switch (_a.label) {
173
+ case 0:
174
+ _a.trys.push([0, 3, , 4]);
175
+ return [4 /*yield*/, this.getSignedTxClearAdmin(wallet, contractAddress, txMisc)];
176
+ case 1:
177
+ txRaw = _a.sent();
178
+ bankTxClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
179
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
180
+ case 2: return [2 /*return*/, _a.sent()];
181
+ case 3:
182
+ error_6 = _a.sent();
183
+ FirmaUtil_1.FirmaUtil.printLog(error_6);
184
+ throw error_6;
185
+ case 4: return [2 /*return*/];
186
+ }
187
+ });
188
+ });
189
+ };
190
+ FirmaCosmWasmService.prototype.getGasEstimationMigrateContract = function (wallet, contractAddress, codeId, msg, txMisc) {
191
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
192
+ return __awaiter(this, void 0, void 0, function () {
193
+ var txRaw, error_7;
194
+ return __generator(this, function (_a) {
195
+ switch (_a.label) {
196
+ case 0:
197
+ _a.trys.push([0, 3, , 4]);
198
+ return [4 /*yield*/, this.getSignedTxMigrateContract(wallet, contractAddress, codeId, msg, txMisc)];
199
+ case 1:
200
+ txRaw = _a.sent();
201
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
202
+ case 2: return [2 /*return*/, _a.sent()];
203
+ case 3:
204
+ error_7 = _a.sent();
205
+ FirmaUtil_1.FirmaUtil.printLog(error_7);
206
+ throw error_7;
207
+ case 4: return [2 /*return*/];
208
+ }
209
+ });
210
+ });
211
+ };
212
+ FirmaCosmWasmService.prototype.migrateContract = function (wallet, contractAddress, codeId, msg, txMisc) {
213
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
214
+ return __awaiter(this, void 0, void 0, function () {
215
+ var txRaw, bankTxClient, error_8;
216
+ return __generator(this, function (_a) {
217
+ switch (_a.label) {
218
+ case 0:
219
+ _a.trys.push([0, 3, , 4]);
220
+ return [4 /*yield*/, this.getSignedTxMigrateContract(wallet, contractAddress, codeId, msg, txMisc)];
221
+ case 1:
222
+ txRaw = _a.sent();
223
+ bankTxClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
224
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
225
+ case 2: return [2 /*return*/, _a.sent()];
226
+ case 3:
227
+ error_8 = _a.sent();
228
+ FirmaUtil_1.FirmaUtil.printLog(error_8);
229
+ throw error_8;
230
+ case 4: return [2 /*return*/];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ FirmaCosmWasmService.prototype.getGasEstimationExecuteContract = function (wallet, contractAddress, msg, funds, txMisc) {
236
+ if (funds === void 0) { funds = []; }
237
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ var txRaw, error_9;
240
+ return __generator(this, function (_a) {
241
+ switch (_a.label) {
242
+ case 0:
243
+ _a.trys.push([0, 3, , 4]);
244
+ return [4 /*yield*/, this.getSignedTxExecuteContract(wallet, contractAddress, msg, funds, txMisc)];
245
+ case 1:
246
+ txRaw = _a.sent();
247
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
248
+ case 2: return [2 /*return*/, _a.sent()];
249
+ case 3:
250
+ error_9 = _a.sent();
251
+ FirmaUtil_1.FirmaUtil.printLog(error_9);
252
+ throw error_9;
253
+ case 4: return [2 /*return*/];
254
+ }
255
+ });
256
+ });
257
+ };
258
+ FirmaCosmWasmService.prototype.executeContract = function (wallet, contractAddress, msg, funds, txMisc) {
259
+ if (funds === void 0) { funds = []; }
260
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
261
+ return __awaiter(this, void 0, void 0, function () {
262
+ var txRaw, bankTxClient, error_10;
263
+ return __generator(this, function (_a) {
264
+ switch (_a.label) {
265
+ case 0:
266
+ _a.trys.push([0, 3, , 4]);
267
+ return [4 /*yield*/, this.getSignedTxExecuteContract(wallet, contractAddress, msg, funds, txMisc)];
268
+ case 1:
269
+ txRaw = _a.sent();
270
+ bankTxClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
271
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
272
+ case 2: return [2 /*return*/, _a.sent()];
273
+ case 3:
274
+ error_10 = _a.sent();
275
+ FirmaUtil_1.FirmaUtil.printLog(error_10);
276
+ throw error_10;
277
+ case 4: return [2 /*return*/];
278
+ }
279
+ });
280
+ });
281
+ };
282
+ FirmaCosmWasmService.prototype.getGasEstimationInstantiateContract = function (wallet, admin, codeId, label, msg, funds, txMisc) {
283
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
284
+ return __awaiter(this, void 0, void 0, function () {
285
+ var txRaw, error_11;
286
+ return __generator(this, function (_a) {
287
+ switch (_a.label) {
288
+ case 0:
289
+ _a.trys.push([0, 3, , 4]);
290
+ return [4 /*yield*/, this.getSignedTxInstantiateContract(wallet, admin, codeId, label, msg, funds, txMisc)];
291
+ case 1:
292
+ txRaw = _a.sent();
293
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
294
+ case 2: return [2 /*return*/, _a.sent()];
295
+ case 3:
296
+ error_11 = _a.sent();
297
+ FirmaUtil_1.FirmaUtil.printLog(error_11);
298
+ throw error_11;
299
+ case 4: return [2 /*return*/];
300
+ }
301
+ });
302
+ });
303
+ };
304
+ FirmaCosmWasmService.prototype.instantiateContract = function (wallet, admin, codeId, label, msg, funds, txMisc) {
305
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ var txRaw, bankTxClient, error_12;
308
+ return __generator(this, function (_a) {
309
+ switch (_a.label) {
310
+ case 0:
311
+ _a.trys.push([0, 3, , 4]);
312
+ return [4 /*yield*/, this.getSignedTxInstantiateContract(wallet, admin, codeId, label, msg, funds, txMisc)];
313
+ case 1:
314
+ txRaw = _a.sent();
315
+ bankTxClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
316
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
317
+ case 2: return [2 /*return*/, _a.sent()];
318
+ case 3:
319
+ error_12 = _a.sent();
320
+ FirmaUtil_1.FirmaUtil.printLog(error_12);
321
+ throw error_12;
322
+ case 4: return [2 /*return*/];
323
+ }
324
+ });
325
+ });
326
+ };
327
+ FirmaCosmWasmService.prototype.getSignedTxInstantiateContract = function (wallet, admin, codeId, label, msg, funds, txMisc) {
328
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
329
+ return __awaiter(this, void 0, void 0, function () {
330
+ var txClient, address, utfMsg, message, error_13;
331
+ return __generator(this, function (_a) {
332
+ switch (_a.label) {
333
+ case 0:
334
+ _a.trys.push([0, 3, , 4]);
335
+ txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
336
+ return [4 /*yield*/, wallet.getAddress()];
337
+ case 1:
338
+ address = _a.sent();
339
+ utfMsg = encoding_1.toUtf8(msg);
340
+ message = txClient.msgInstantiateContract({ sender: address, admin: admin, codeId: long_1.default.fromString(codeId), label: label, msg: utfMsg, funds: funds });
341
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
342
+ case 2: return [2 /*return*/, _a.sent()];
343
+ case 3:
344
+ error_13 = _a.sent();
345
+ FirmaUtil_1.FirmaUtil.printLog(error_13);
346
+ throw error_13;
347
+ case 4: return [2 /*return*/];
348
+ }
349
+ });
350
+ });
351
+ };
352
+ FirmaCosmWasmService.prototype.getSignedTxUpdateAdmin = function (wallet, contractAddress, adminAddress, txMisc) {
353
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
354
+ return __awaiter(this, void 0, void 0, function () {
355
+ var txClient, address, message, error_14;
356
+ return __generator(this, function (_a) {
357
+ switch (_a.label) {
358
+ case 0:
359
+ _a.trys.push([0, 3, , 4]);
360
+ txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
361
+ return [4 /*yield*/, wallet.getAddress()];
362
+ case 1:
363
+ address = _a.sent();
364
+ message = txClient.msgUpdateAdmin({ sender: address, contract: contractAddress, newAdmin: adminAddress });
365
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
366
+ case 2: return [2 /*return*/, _a.sent()];
367
+ case 3:
368
+ error_14 = _a.sent();
369
+ FirmaUtil_1.FirmaUtil.printLog(error_14);
370
+ throw error_14;
371
+ case 4: return [2 /*return*/];
372
+ }
373
+ });
374
+ });
375
+ };
376
+ FirmaCosmWasmService.prototype.getSignedTxClearAdmin = function (wallet, contractAddress, txMisc) {
377
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
378
+ return __awaiter(this, void 0, void 0, function () {
379
+ var txClient, address, message, error_15;
380
+ return __generator(this, function (_a) {
381
+ switch (_a.label) {
382
+ case 0:
383
+ _a.trys.push([0, 3, , 4]);
384
+ txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
385
+ return [4 /*yield*/, wallet.getAddress()];
386
+ case 1:
387
+ address = _a.sent();
388
+ message = txClient.msgClearAdmin({ sender: address, contract: contractAddress });
389
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
390
+ case 2: return [2 /*return*/, _a.sent()];
391
+ case 3:
392
+ error_15 = _a.sent();
393
+ FirmaUtil_1.FirmaUtil.printLog(error_15);
394
+ throw error_15;
395
+ case 4: return [2 /*return*/];
396
+ }
397
+ });
398
+ });
399
+ };
400
+ FirmaCosmWasmService.prototype.getSignedTxMigrateContract = function (wallet, contractAddress, codeId, msg, txMisc) {
401
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
402
+ return __awaiter(this, void 0, void 0, function () {
403
+ var txClient, address, utfMsg, message, error_16;
404
+ return __generator(this, function (_a) {
405
+ switch (_a.label) {
406
+ case 0:
407
+ _a.trys.push([0, 3, , 4]);
408
+ txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
409
+ return [4 /*yield*/, wallet.getAddress()];
410
+ case 1:
411
+ address = _a.sent();
412
+ utfMsg = encoding_1.toUtf8(msg);
413
+ message = txClient.msgMigrateContract({ sender: address, contract: contractAddress, codeId: long_1.default.fromString(codeId), msg: utfMsg });
414
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
415
+ case 2: return [2 /*return*/, _a.sent()];
416
+ case 3:
417
+ error_16 = _a.sent();
418
+ FirmaUtil_1.FirmaUtil.printLog(error_16);
419
+ throw error_16;
420
+ case 4: return [2 /*return*/];
421
+ }
422
+ });
423
+ });
424
+ };
425
+ FirmaCosmWasmService.prototype.getSignedTxExecuteContract = function (wallet, contractAddress, msg, funds, txMisc) {
426
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
427
+ return __awaiter(this, void 0, void 0, function () {
428
+ var txClient, address, utfMsg, message, error_17;
429
+ return __generator(this, function (_a) {
430
+ switch (_a.label) {
431
+ case 0:
432
+ _a.trys.push([0, 3, , 4]);
433
+ txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
434
+ return [4 /*yield*/, wallet.getAddress()];
435
+ case 1:
436
+ address = _a.sent();
437
+ utfMsg = encoding_1.toUtf8(msg);
438
+ message = txClient.msgExecuteContract({ sender: address, contract: contractAddress, msg: utfMsg, funds: funds });
439
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
440
+ case 2: return [2 /*return*/, _a.sent()];
441
+ case 3:
442
+ error_17 = _a.sent();
443
+ FirmaUtil_1.FirmaUtil.printLog(error_17);
444
+ throw error_17;
445
+ case 4: return [2 /*return*/];
446
+ }
447
+ });
448
+ });
449
+ };
450
+ FirmaCosmWasmService.prototype.getSignedTxStoreCode = function (wallet, wasmCode, accessConfig, txMisc) {
451
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
452
+ return __awaiter(this, void 0, void 0, function () {
453
+ var txClient, address, compressed, message, error_18;
454
+ return __generator(this, function (_a) {
455
+ switch (_a.label) {
456
+ case 0:
457
+ _a.trys.push([0, 3, , 4]);
458
+ txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
459
+ return [4 /*yield*/, wallet.getAddress()];
460
+ case 1:
461
+ address = _a.sent();
462
+ compressed = pako_1.default.gzip(wasmCode, { level: 9 });
463
+ message = txClient.msgStoreCode({ sender: address, wasmByteCode: compressed, instantiatePermission: accessConfig });
464
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
465
+ case 2: return [2 /*return*/, _a.sent()];
466
+ case 3:
467
+ error_18 = _a.sent();
468
+ FirmaUtil_1.FirmaUtil.printLog(error_18);
469
+ throw error_18;
470
+ case 4: return [2 /*return*/];
471
+ }
472
+ });
473
+ });
474
+ };
475
+ // query
476
+ FirmaCosmWasmService.prototype.getCodeList = function () {
477
+ return __awaiter(this, void 0, void 0, function () {
478
+ var queryClient, result, error_19;
479
+ return __generator(this, function (_a) {
480
+ switch (_a.label) {
481
+ case 0:
482
+ _a.trys.push([0, 2, , 3]);
483
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
484
+ return [4 /*yield*/, queryClient.getCodeInfoList()];
485
+ case 1:
486
+ result = _a.sent();
487
+ return [2 /*return*/, result];
488
+ case 2:
489
+ error_19 = _a.sent();
490
+ FirmaUtil_1.FirmaUtil.printLog(error_19);
491
+ throw error_19;
492
+ case 3: return [2 /*return*/];
493
+ }
494
+ });
495
+ });
496
+ };
497
+ FirmaCosmWasmService.prototype.getCodeData = function (codeId) {
498
+ return __awaiter(this, void 0, void 0, function () {
499
+ var queryClient, result, error_20;
500
+ return __generator(this, function (_a) {
501
+ switch (_a.label) {
502
+ case 0:
503
+ _a.trys.push([0, 2, , 3]);
504
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
505
+ return [4 /*yield*/, queryClient.getCodeData(codeId)];
506
+ case 1:
507
+ result = _a.sent();
508
+ return [2 /*return*/, result];
509
+ case 2:
510
+ error_20 = _a.sent();
511
+ FirmaUtil_1.FirmaUtil.printLog(error_20);
512
+ throw error_20;
513
+ case 3: return [2 /*return*/];
514
+ }
515
+ });
516
+ });
517
+ };
518
+ FirmaCosmWasmService.prototype.getContractListFromCodeId = function (codeId) {
519
+ return __awaiter(this, void 0, void 0, function () {
520
+ var queryClient, result, error_21;
521
+ return __generator(this, function (_a) {
522
+ switch (_a.label) {
523
+ case 0:
524
+ _a.trys.push([0, 2, , 3]);
525
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
526
+ return [4 /*yield*/, queryClient.getContractListFromCodeId(codeId)];
527
+ case 1:
528
+ result = _a.sent();
529
+ return [2 /*return*/, result];
530
+ case 2:
531
+ error_21 = _a.sent();
532
+ FirmaUtil_1.FirmaUtil.printLog(error_21);
533
+ throw error_21;
534
+ case 3: return [2 /*return*/];
535
+ }
536
+ });
537
+ });
538
+ };
539
+ FirmaCosmWasmService.prototype.getContractInfo = function (codeId) {
540
+ return __awaiter(this, void 0, void 0, function () {
541
+ var queryClient, result, error_22;
542
+ return __generator(this, function (_a) {
543
+ switch (_a.label) {
544
+ case 0:
545
+ _a.trys.push([0, 2, , 3]);
546
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
547
+ return [4 /*yield*/, queryClient.getContractInfo(codeId)];
548
+ case 1:
549
+ result = _a.sent();
550
+ return [2 /*return*/, result];
551
+ case 2:
552
+ error_22 = _a.sent();
553
+ FirmaUtil_1.FirmaUtil.printLog(error_22);
554
+ throw error_22;
555
+ case 3: return [2 /*return*/];
556
+ }
557
+ });
558
+ });
559
+ };
560
+ FirmaCosmWasmService.prototype.getContractHistory = function (codeId) {
561
+ return __awaiter(this, void 0, void 0, function () {
562
+ var queryClient, result, error_23;
563
+ return __generator(this, function (_a) {
564
+ switch (_a.label) {
565
+ case 0:
566
+ _a.trys.push([0, 2, , 3]);
567
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
568
+ return [4 /*yield*/, queryClient.getContractHistory(codeId)];
569
+ case 1:
570
+ result = _a.sent();
571
+ return [2 /*return*/, result];
572
+ case 2:
573
+ error_23 = _a.sent();
574
+ FirmaUtil_1.FirmaUtil.printLog(error_23);
575
+ throw error_23;
576
+ case 3: return [2 /*return*/];
577
+ }
578
+ });
579
+ });
580
+ };
581
+ FirmaCosmWasmService.prototype.getContractRawQueryData = function (contractAddress, hexString) {
582
+ return __awaiter(this, void 0, void 0, function () {
583
+ var queryClient, result, error_24;
584
+ return __generator(this, function (_a) {
585
+ switch (_a.label) {
586
+ case 0:
587
+ _a.trys.push([0, 2, , 3]);
588
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
589
+ return [4 /*yield*/, queryClient.getContractRawQueryData(contractAddress, hexString)];
590
+ case 1:
591
+ result = _a.sent();
592
+ return [2 /*return*/, result];
593
+ case 2:
594
+ error_24 = _a.sent();
595
+ FirmaUtil_1.FirmaUtil.printLog(error_24);
596
+ throw error_24;
597
+ case 3: return [2 /*return*/];
598
+ }
599
+ });
600
+ });
601
+ };
602
+ FirmaCosmWasmService.prototype.getContractSmartQueryData = function (contractAddress, query) {
603
+ return __awaiter(this, void 0, void 0, function () {
604
+ var queryClient, result, error_25;
605
+ return __generator(this, function (_a) {
606
+ switch (_a.label) {
607
+ case 0:
608
+ _a.trys.push([0, 2, , 3]);
609
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
610
+ return [4 /*yield*/, queryClient.getContractSmartQueryData(contractAddress, query)];
611
+ case 1:
612
+ result = _a.sent();
613
+ return [2 /*return*/, result];
614
+ case 2:
615
+ error_25 = _a.sent();
616
+ FirmaUtil_1.FirmaUtil.printLog(error_25);
617
+ throw error_25;
618
+ case 3: return [2 /*return*/];
619
+ }
620
+ });
621
+ });
622
+ };
623
+ FirmaCosmWasmService.prototype.getContractState = function (codeId) {
624
+ return __awaiter(this, void 0, void 0, function () {
625
+ var queryClient, result, error_26;
626
+ return __generator(this, function (_a) {
627
+ switch (_a.label) {
628
+ case 0:
629
+ _a.trys.push([0, 2, , 3]);
630
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
631
+ return [4 /*yield*/, queryClient.getContractState(codeId)];
632
+ case 1:
633
+ result = _a.sent();
634
+ return [2 /*return*/, result];
635
+ case 2:
636
+ error_26 = _a.sent();
637
+ FirmaUtil_1.FirmaUtil.printLog(error_26);
638
+ throw error_26;
639
+ case 3: return [2 /*return*/];
640
+ }
641
+ });
642
+ });
643
+ };
644
+ FirmaCosmWasmService.prototype.getPinnedCodeList = function () {
645
+ return __awaiter(this, void 0, void 0, function () {
646
+ var queryClient, result, error_27;
647
+ return __generator(this, function (_a) {
648
+ switch (_a.label) {
649
+ case 0:
650
+ _a.trys.push([0, 2, , 3]);
651
+ queryClient = new cosmwasm_1.CosmWasmQueryClient(this.config.restApiAddress);
652
+ return [4 /*yield*/, queryClient.getPinnedCodeList()];
653
+ case 1:
654
+ result = _a.sent();
655
+ return [2 /*return*/, result];
656
+ case 2:
657
+ error_27 = _a.sent();
658
+ FirmaUtil_1.FirmaUtil.printLog(error_27);
659
+ throw error_27;
660
+ case 3: return [2 /*return*/];
661
+ }
662
+ });
663
+ });
664
+ };
665
+ return FirmaCosmWasmService;
666
+ }());
667
+ exports.FirmaCosmWasmService = FirmaCosmWasmService;
@@ -1,4 +1,4 @@
1
- import { TxMisc, TotalRewardInfo } from "./firmachain/distribution";
1
+ import { DistributionTxClient, TxMisc, TotalRewardInfo } from "./firmachain/distribution";
2
2
  import { FirmaWalletService } from "./FirmaWalletService";
3
3
  import { FirmaConfig } from "./FirmaConfig";
4
4
  import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
@@ -7,6 +7,7 @@ import { DelegationInfo } from "./firmachain/staking";
7
7
  export declare class FirmaDistributionService {
8
8
  private readonly config;
9
9
  constructor(config: FirmaConfig);
10
+ getTxClient(wallet: FirmaWalletService): DistributionTxClient;
10
11
  getGasEstimationSetWithdrawAddress(wallet: FirmaWalletService, withdrawAddress: string, txMisc?: TxMisc): Promise<number>;
11
12
  getGasEstimationFundCommunityPool(wallet: FirmaWalletService, amount: number, txMisc?: TxMisc): Promise<number>;
12
13
  getGasEstimationWithdrawValidatorCommission(wallet: FirmaWalletService, validatorAddress: string, txMisc?: TxMisc): Promise<number>;