@firmachain/firma-js 0.2.43 → 0.2.45

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.
@@ -31,7 +31,7 @@ var FirmaConfig = /** @class */ (function () {
31
31
  isShowLog: true,
32
32
  };
33
33
  FirmaConfig.TestNetConfig = {
34
- chainID: "imperium-3",
34
+ chainID: "imperium-4",
35
35
  rpcAddress: "https://lcd-testnet.firmachain.dev:26657",
36
36
  restApiAddress: "https://lcd-testnet.firmachain.dev:1317",
37
37
  ipfsNodeAddress: "https://ipfs-dev.firmachain.dev",
@@ -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;
@@ -29,6 +29,8 @@ export declare class FirmaUtil {
29
29
  static getSha1HashFromString(text: string): string;
30
30
  static getHashFromString(text: string): string;
31
31
  static isValidAddress(address: string): boolean;
32
+ static buf2hex(buffer: Uint8Array): string;
33
+ static getHexAddressFromAddress(address: string): string;
32
34
  static getValOperAddressFromAccAddress(address: string): string;
33
35
  static getAccAddressFromValOperAddress(address: string): string;
34
36
  static getSignerDataForLedger(address: string): Promise<SignerData>;
@@ -46,6 +46,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
49
74
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
75
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
76
  };
@@ -186,6 +211,15 @@ var FirmaUtil = /** @class */ (function () {
186
211
  }
187
212
  return false;
188
213
  };
214
+ FirmaUtil.buf2hex = function (buffer) {
215
+ return __spreadArray([], __read(new Uint8Array(buffer)), false).map(function (x) { return x.toString(16).padStart(2, '0'); })
216
+ .join('');
217
+ };
218
+ // for evm address support
219
+ FirmaUtil.getHexAddressFromAddress = function (address) {
220
+ var data = encoding_1.Bech32.decode(address).data;
221
+ return "0x" + FirmaUtil.buf2hex(data);
222
+ };
189
223
  FirmaUtil.getValOperAddressFromAccAddress = function (address) {
190
224
  var data = encoding_1.Bech32.decode(address).data;
191
225
  return encoding_1.Bech32.encode(FirmaUtil.config.prefix + "valoper", data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -36,8 +36,10 @@
36
36
  "@cosmjs/math": "^0.26.0",
37
37
  "@cosmjs/proto-signing": "^0.25.6",
38
38
  "@cosmjs/tendermint-rpc": "^0.26.0",
39
+ "@tharsis/address-converter": "^0.1.8",
39
40
  "@types/pako": "^2.0.0",
40
41
  "axios": "^0.27.2",
42
+ "big-number": "^2.0.0",
41
43
  "cosmjs-types": "^0.2.0",
42
44
  "crypto-js": "^4.1.1",
43
45
  "form-data": "^4.0.0",