@firmachain/firma-js 0.2.42 → 0.2.44

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.
@@ -10,6 +10,7 @@ export declare class FirmaBankService {
10
10
  getGasEstimationSendToken(wallet: FirmaWalletService, targetAddress: string, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<number>;
11
11
  sendToken(wallet: FirmaWalletService, targetAddress: string, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
12
12
  send(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
13
+ send_raw(wallet: FirmaWalletService, targetAddress: string, ufctAmount: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
13
14
  getTokenBalanceList(address: string): Promise<Token[]>;
14
15
  getTokenBalance(address: string, tokenID: string): Promise<string>;
15
16
  getBalance(address: string): Promise<string>;
@@ -136,9 +136,32 @@ var FirmaBankService = /** @class */ (function () {
136
136
  });
137
137
  });
138
138
  };
139
+ FirmaBankService.prototype.send_raw = function (wallet, targetAddress, ufctAmount, txMisc) {
140
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
141
+ return __awaiter(this, void 0, void 0, function () {
142
+ var txRaw, bankTxClient, error_5;
143
+ return __generator(this, function (_a) {
144
+ switch (_a.label) {
145
+ case 0:
146
+ _a.trys.push([0, 3, , 4]);
147
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, this.config.denom, ufctAmount, txMisc)];
148
+ case 1:
149
+ txRaw = _a.sent();
150
+ bankTxClient = new bank_1.BankTxClient(wallet, this.config.rpcAddress);
151
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
152
+ case 2: return [2 /*return*/, _a.sent()];
153
+ case 3:
154
+ error_5 = _a.sent();
155
+ FirmaUtil_1.FirmaUtil.printLog(error_5);
156
+ throw error_5;
157
+ case 4: return [2 /*return*/];
158
+ }
159
+ });
160
+ });
161
+ };
139
162
  FirmaBankService.prototype.getTokenBalanceList = function (address) {
140
163
  return __awaiter(this, void 0, void 0, function () {
141
- var bankQueryClient, result, tokenList, i, error_5;
164
+ var bankQueryClient, result, tokenList, i, error_6;
142
165
  return __generator(this, function (_a) {
143
166
  switch (_a.label) {
144
167
  case 0:
@@ -156,9 +179,9 @@ var FirmaBankService = /** @class */ (function () {
156
179
  }
157
180
  return [2 /*return*/, tokenList];
158
181
  case 2:
159
- error_5 = _a.sent();
160
- FirmaUtil_1.FirmaUtil.printLog(error_5);
161
- throw error_5;
182
+ error_6 = _a.sent();
183
+ FirmaUtil_1.FirmaUtil.printLog(error_6);
184
+ throw error_6;
162
185
  case 3: return [2 /*return*/];
163
186
  }
164
187
  });
@@ -166,7 +189,7 @@ var FirmaBankService = /** @class */ (function () {
166
189
  };
167
190
  FirmaBankService.prototype.getTokenBalance = function (address, tokenID) {
168
191
  return __awaiter(this, void 0, void 0, function () {
169
- var bankQueryClient, result, error_6;
192
+ var bankQueryClient, result, error_7;
170
193
  return __generator(this, function (_a) {
171
194
  switch (_a.label) {
172
195
  case 0:
@@ -177,9 +200,9 @@ var FirmaBankService = /** @class */ (function () {
177
200
  result = _a.sent();
178
201
  return [2 /*return*/, result.amount];
179
202
  case 2:
180
- error_6 = _a.sent();
181
- FirmaUtil_1.FirmaUtil.printLog(error_6);
182
- throw error_6;
203
+ error_7 = _a.sent();
204
+ FirmaUtil_1.FirmaUtil.printLog(error_7);
205
+ throw error_7;
183
206
  case 3: return [2 /*return*/];
184
207
  }
185
208
  });
@@ -187,7 +210,7 @@ var FirmaBankService = /** @class */ (function () {
187
210
  };
188
211
  FirmaBankService.prototype.getBalance = function (address) {
189
212
  return __awaiter(this, void 0, void 0, function () {
190
- var bankQueryClient, result, error_7;
213
+ var bankQueryClient, result, error_8;
191
214
  return __generator(this, function (_a) {
192
215
  switch (_a.label) {
193
216
  case 0:
@@ -198,9 +221,9 @@ var FirmaBankService = /** @class */ (function () {
198
221
  result = _a.sent();
199
222
  return [2 /*return*/, result.amount];
200
223
  case 2:
201
- error_7 = _a.sent();
202
- FirmaUtil_1.FirmaUtil.printLog(error_7);
203
- throw error_7;
224
+ error_8 = _a.sent();
225
+ FirmaUtil_1.FirmaUtil.printLog(error_8);
226
+ throw error_8;
204
227
  case 3: return [2 /*return*/];
205
228
  }
206
229
  });
@@ -209,7 +232,7 @@ var FirmaBankService = /** @class */ (function () {
209
232
  FirmaBankService.prototype.getSignedTxSend = function (wallet, targetAddress, denom, amount, txMisc) {
210
233
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
211
234
  return __awaiter(this, void 0, void 0, function () {
212
- var bankTxClient, address, sendAmount, message, error_8;
235
+ var bankTxClient, address, sendAmount, message, error_9;
213
236
  return __generator(this, function (_a) {
214
237
  switch (_a.label) {
215
238
  case 0:
@@ -223,9 +246,9 @@ var FirmaBankService = /** @class */ (function () {
223
246
  return [4 /*yield*/, bankTxClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
224
247
  case 2: return [2 /*return*/, _a.sent()];
225
248
  case 3:
226
- error_8 = _a.sent();
227
- FirmaUtil_1.FirmaUtil.printLog(error_8);
228
- throw error_8;
249
+ error_9 = _a.sent();
250
+ FirmaUtil_1.FirmaUtil.printLog(error_9);
251
+ throw error_9;
229
252
  case 4: return [2 /*return*/];
230
253
  }
231
254
  });
@@ -1,7 +1,9 @@
1
1
  import { NftItemType, Pagination, TxMisc } from "./firmachain/nft";
2
2
  import { FirmaConfig } from "./FirmaConfig";
3
3
  import { FirmaWalletService } from "./FirmaWalletService";
4
+ import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
4
5
  import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
6
+ import { EncodeObject } from "@cosmjs/proto-signing";
5
7
  export declare class NftService {
6
8
  private readonly config;
7
9
  constructor(config: FirmaConfig);
@@ -23,9 +25,11 @@ export declare class NftService {
23
25
  private getSignedTxTransfer;
24
26
  transfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
25
27
  getGasEstimationBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<number>;
26
- private getSignedTxBurn;
28
+ getSignedTxBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<TxRaw>;
27
29
  burn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
30
+ getGasEstimationFromEncodeObject(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<number>;
28
31
  getGasEstimationMint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<number>;
29
32
  private getSignedTxMint;
30
33
  mint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
34
+ signAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<BroadcastTxResponse>;
31
35
  }
@@ -298,15 +298,16 @@ var NftService = /** @class */ (function () {
298
298
  });
299
299
  });
300
300
  };
301
- NftService.prototype.getGasEstimationMint = function (wallet, tokenURI, txMisc) {
301
+ NftService.prototype.getGasEstimationFromEncodeObject = function (wallet, msgList, txMisc) {
302
302
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
303
303
  return __awaiter(this, void 0, void 0, function () {
304
- var txRaw, error_12;
304
+ var nftTxClient, txRaw, error_12;
305
305
  return __generator(this, function (_a) {
306
306
  switch (_a.label) {
307
307
  case 0:
308
308
  _a.trys.push([0, 3, , 4]);
309
- return [4 /*yield*/, this.getSignedTxMint(wallet, tokenURI, txMisc)];
309
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
310
+ return [4 /*yield*/, nftTxClient.sign(msgList, (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
310
311
  case 1:
311
312
  txRaw = _a.sent();
312
313
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -320,10 +321,32 @@ var NftService = /** @class */ (function () {
320
321
  });
321
322
  });
322
323
  };
324
+ NftService.prototype.getGasEstimationMint = function (wallet, tokenURI, txMisc) {
325
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
326
+ return __awaiter(this, void 0, void 0, function () {
327
+ var txRaw, error_13;
328
+ return __generator(this, function (_a) {
329
+ switch (_a.label) {
330
+ case 0:
331
+ _a.trys.push([0, 3, , 4]);
332
+ return [4 /*yield*/, this.getSignedTxMint(wallet, tokenURI, txMisc)];
333
+ case 1:
334
+ txRaw = _a.sent();
335
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
336
+ case 2: return [2 /*return*/, _a.sent()];
337
+ case 3:
338
+ error_13 = _a.sent();
339
+ FirmaUtil_1.FirmaUtil.printLog(error_13);
340
+ throw error_13;
341
+ case 4: return [2 /*return*/];
342
+ }
343
+ });
344
+ });
345
+ };
323
346
  NftService.prototype.getSignedTxMint = function (wallet, tokenURI, txMisc) {
324
347
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
325
348
  return __awaiter(this, void 0, void 0, function () {
326
- var address, message, nftTxClient, error_13;
349
+ var address, message, nftTxClient, error_14;
327
350
  return __generator(this, function (_a) {
328
351
  switch (_a.label) {
329
352
  case 0:
@@ -336,9 +359,9 @@ var NftService = /** @class */ (function () {
336
359
  return [4 /*yield*/, nftTxClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
337
360
  case 2: return [2 /*return*/, _a.sent()];
338
361
  case 3:
339
- error_13 = _a.sent();
340
- FirmaUtil_1.FirmaUtil.printLog(error_13);
341
- throw error_13;
362
+ error_14 = _a.sent();
363
+ FirmaUtil_1.FirmaUtil.printLog(error_14);
364
+ throw error_14;
342
365
  case 4: return [2 /*return*/];
343
366
  }
344
367
  });
@@ -347,7 +370,7 @@ var NftService = /** @class */ (function () {
347
370
  NftService.prototype.mint = function (wallet, tokenURI, txMisc) {
348
371
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
349
372
  return __awaiter(this, void 0, void 0, function () {
350
- var txRaw, nftTxClient, error_14;
373
+ var txRaw, nftTxClient, error_15;
351
374
  return __generator(this, function (_a) {
352
375
  switch (_a.label) {
353
376
  case 0:
@@ -359,14 +382,34 @@ var NftService = /** @class */ (function () {
359
382
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
360
383
  case 2: return [2 /*return*/, _a.sent()];
361
384
  case 3:
362
- error_14 = _a.sent();
363
- FirmaUtil_1.FirmaUtil.printLog(error_14);
364
- throw error_14;
385
+ error_15 = _a.sent();
386
+ FirmaUtil_1.FirmaUtil.printLog(error_15);
387
+ throw error_15;
365
388
  case 4: return [2 /*return*/];
366
389
  }
367
390
  });
368
391
  });
369
392
  };
393
+ NftService.prototype.signAndBroadcast = function (wallet, msgList, txMisc) {
394
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
395
+ return __awaiter(this, void 0, void 0, function () {
396
+ var contractTxClient, error_16;
397
+ return __generator(this, function (_a) {
398
+ switch (_a.label) {
399
+ case 0:
400
+ _a.trys.push([0, 2, , 3]);
401
+ contractTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
402
+ return [4 /*yield*/, contractTxClient.signAndBroadcast(msgList, (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
403
+ case 1: return [2 /*return*/, _a.sent()];
404
+ case 2:
405
+ error_16 = _a.sent();
406
+ FirmaUtil_1.FirmaUtil.printLog(error_16);
407
+ throw error_16;
408
+ case 3: return [2 /*return*/];
409
+ }
410
+ });
411
+ });
412
+ };
370
413
  return NftService;
371
414
  }());
372
415
  exports.NftService = NftService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "@cosmjs/tendermint-rpc": "^0.26.0",
39
39
  "@types/pako": "^2.0.0",
40
40
  "axios": "^0.27.2",
41
+ "big-number": "^2.0.0",
41
42
  "cosmjs-types": "^0.2.0",
42
43
  "crypto-js": "^4.1.1",
43
44
  "form-data": "^4.0.0",