@firmachain/firma-js 0.2.21 → 0.2.22

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.
@@ -44,7 +44,7 @@ var TokenService = /** @class */ (function () {
44
44
  this.config = config;
45
45
  }
46
46
  TokenService.prototype.getGasEstimationCreateToken = function (wallet, tokenName, tokenSymbol, tokenURI, totalSupply, decimal, isMintable, isBurnable, txMisc) {
47
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
47
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
48
48
  return __awaiter(this, void 0, void 0, function () {
49
49
  var newTotalSupply, txRaw, error_1;
50
50
  return __generator(this, function (_a) {
@@ -67,7 +67,7 @@ var TokenService = /** @class */ (function () {
67
67
  });
68
68
  };
69
69
  TokenService.prototype.getGasEstimationMint = function (wallet, tokenID, amount, decimal, toAddress, txMisc) {
70
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
70
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
71
71
  return __awaiter(this, void 0, void 0, function () {
72
72
  var newAmount, txRaw, error_2;
73
73
  return __generator(this, function (_a) {
@@ -90,7 +90,7 @@ var TokenService = /** @class */ (function () {
90
90
  });
91
91
  };
92
92
  TokenService.prototype.getGasEstimationBurn = function (wallet, tokenID, amount, decimal, txMisc) {
93
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
93
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
94
94
  return __awaiter(this, void 0, void 0, function () {
95
95
  var newAmount, txRaw, error_3;
96
96
  return __generator(this, function (_a) {
@@ -113,7 +113,7 @@ var TokenService = /** @class */ (function () {
113
113
  });
114
114
  };
115
115
  TokenService.prototype.getGasEstimationUpdateTokenURI = function (wallet, tokenID, tokenURI, txMisc) {
116
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
116
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
117
117
  return __awaiter(this, void 0, void 0, function () {
118
118
  var txRaw, error_4;
119
119
  return __generator(this, function (_a) {
@@ -135,7 +135,7 @@ var TokenService = /** @class */ (function () {
135
135
  });
136
136
  };
137
137
  TokenService.prototype.getSignedTxUpdateTokenURI = function (wallet, tokenID, tokenURI, txMisc) {
138
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
138
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
139
139
  return __awaiter(this, void 0, void 0, function () {
140
140
  var address, txClient, message, error_5;
141
141
  return __generator(this, function (_a) {
@@ -151,7 +151,7 @@ var TokenService = /** @class */ (function () {
151
151
  tokenID: tokenID,
152
152
  tokenURI: tokenURI
153
153
  });
154
- return [4 /*yield*/, txClient.sign([message], token_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
154
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
155
155
  case 2: return [2 /*return*/, _a.sent()];
156
156
  case 3:
157
157
  error_5 = _a.sent();
@@ -163,7 +163,7 @@ var TokenService = /** @class */ (function () {
163
163
  });
164
164
  };
165
165
  TokenService.prototype.getSignedTxBurn = function (wallet, tokenID, amount, txMisc) {
166
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
166
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
167
167
  return __awaiter(this, void 0, void 0, function () {
168
168
  var address, txClient, message, error_6;
169
169
  return __generator(this, function (_a) {
@@ -179,7 +179,7 @@ var TokenService = /** @class */ (function () {
179
179
  tokenID: tokenID,
180
180
  amount: amount
181
181
  });
182
- return [4 /*yield*/, txClient.sign([message], token_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
182
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
183
183
  case 2: return [2 /*return*/, _a.sent()];
184
184
  case 3:
185
185
  error_6 = _a.sent();
@@ -191,7 +191,7 @@ var TokenService = /** @class */ (function () {
191
191
  });
192
192
  };
193
193
  TokenService.prototype.getSignedTxMint = function (wallet, tokenID, amount, toAddress, txMisc) {
194
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
194
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
195
195
  return __awaiter(this, void 0, void 0, function () {
196
196
  var address, txClient, message, error_7;
197
197
  return __generator(this, function (_a) {
@@ -208,7 +208,7 @@ var TokenService = /** @class */ (function () {
208
208
  amount: amount,
209
209
  toAddress: toAddress
210
210
  });
211
- return [4 /*yield*/, txClient.sign([message], token_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
211
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
212
212
  case 2: return [2 /*return*/, _a.sent()];
213
213
  case 3:
214
214
  error_7 = _a.sent();
@@ -220,7 +220,7 @@ var TokenService = /** @class */ (function () {
220
220
  });
221
221
  };
222
222
  TokenService.prototype.getSignedTxCreateToken = function (wallet, tokenName, tokenSymbol, tokenURI, totalSupply, decimal, isMintable, isBurnable, txMisc) {
223
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
223
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
224
224
  return __awaiter(this, void 0, void 0, function () {
225
225
  var address, txClient, message, error_8;
226
226
  return __generator(this, function (_a) {
@@ -241,7 +241,7 @@ var TokenService = /** @class */ (function () {
241
241
  mintable: isMintable,
242
242
  burnable: isBurnable
243
243
  });
244
- return [4 /*yield*/, txClient.sign([message], token_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
244
+ return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
245
245
  case 2: return [2 /*return*/, _a.sent()];
246
246
  case 3:
247
247
  error_8 = _a.sent();
@@ -254,7 +254,7 @@ var TokenService = /** @class */ (function () {
254
254
  };
255
255
  //./firmachaind tx token mint ukai 1000000 firma1jmg3kwy5hntx66nl93dyk2d92943394qsf6gcf --from alice --fees 2000ufct --chain-id imperium-2
256
256
  TokenService.prototype.createToken = function (wallet, tokenName, tokenSymbol, tokenURI, totalSupply, decimal, isMintable, isBurnable, txMisc) {
257
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
257
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
258
258
  return __awaiter(this, void 0, void 0, function () {
259
259
  var newTotalSupply, txRaw, nftTxClient, error_9;
260
260
  return __generator(this, function (_a) {
@@ -278,7 +278,7 @@ var TokenService = /** @class */ (function () {
278
278
  });
279
279
  };
280
280
  TokenService.prototype.mint = function (wallet, tokenID, amount, decimal, toAddress, txMisc) {
281
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
281
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
282
282
  return __awaiter(this, void 0, void 0, function () {
283
283
  var newAmount, txRaw, nftTxClient, error_10;
284
284
  return __generator(this, function (_a) {
@@ -302,7 +302,7 @@ var TokenService = /** @class */ (function () {
302
302
  });
303
303
  };
304
304
  TokenService.prototype.burn = function (wallet, tokenID, amount, decimal, txMisc) {
305
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
305
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
306
306
  return __awaiter(this, void 0, void 0, function () {
307
307
  var newAmount, txRaw, nftTxClient, error_11;
308
308
  return __generator(this, function (_a) {
@@ -326,7 +326,7 @@ var TokenService = /** @class */ (function () {
326
326
  });
327
327
  };
328
328
  TokenService.prototype.updateTokenURI = function (wallet, tokenID, tokenURI, txMisc) {
329
- if (txMisc === void 0) { txMisc = token_1.DefaultTxMisc; }
329
+ if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
330
330
  return __awaiter(this, void 0, void 0, function () {
331
331
  var txRaw, nftTxClient, error_12;
332
332
  return __generator(this, function (_a) {
@@ -1,10 +1,12 @@
1
1
  import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
2
2
  import { FirmaConfig } from "./FirmaConfig";
3
3
  import { SignerData } from "./firmachain/common/LedgerSigningStargateClient";
4
+ import { SignAndBroadcastOptions, TxMisc } from "./firmachain/common";
4
5
  export declare class FirmaUtil {
5
6
  static config: FirmaConfig;
6
7
  static readonly FctDecimal: number;
7
8
  constructor(firmaConfig: FirmaConfig);
9
+ static getSignAndBroadcastOption(denom: string, txMisc: TxMisc): SignAndBroadcastOptions;
8
10
  static getUTokenStringFromTokenStr(tokenAmount: string, decimal: number): string;
9
11
  static getTokenStringFromUTokenStr(uTokenAmount: string, decimal: number): string;
10
12
  static getUTokenStringFromToken(tokenAmount: number, decimal: number): string;
@@ -24,3 +26,10 @@ export declare class FirmaUtil {
24
26
  static estimateGasRaw(txRaw: Uint8Array): Promise<number>;
25
27
  static printLog(log: any): void;
26
28
  }
29
+ export declare const DefaultTxMisc: {
30
+ memo: string;
31
+ fee: number;
32
+ gas: number;
33
+ feeGranter: string;
34
+ };
35
+ export declare const getSignAndBroadcastOption: typeof FirmaUtil.getSignAndBroadcastOption;
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.FirmaUtil = void 0;
39
+ exports.getSignAndBroadcastOption = exports.DefaultTxMisc = exports.FirmaUtil = void 0;
40
40
  var fs_1 = require("fs");
41
41
  var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
42
42
  var TendermintQueryClient_1 = require("./firmachain/common/TendermintQueryClient");
@@ -49,6 +49,20 @@ var FirmaUtil = /** @class */ (function () {
49
49
  function FirmaUtil(firmaConfig) {
50
50
  FirmaUtil.config = firmaConfig;
51
51
  }
52
+ FirmaUtil.getSignAndBroadcastOption = function (denom, txMisc) {
53
+ if (txMisc.memo == null)
54
+ txMisc.memo = "";
55
+ // INFO: if fee or gas data is not set default, those value will be null. So we have to double check it.
56
+ if (txMisc.fee == 0 || txMisc.fee == null)
57
+ txMisc.fee = FirmaUtil.config.defaultFee;
58
+ if (txMisc.gas == 0 || txMisc.gas == null)
59
+ txMisc.gas = FirmaUtil.config.defaultGas;
60
+ if (txMisc.feeGranter == null)
61
+ txMisc.feeGranter = "";
62
+ var gasFeeAmount = { denom: denom, amount: txMisc.fee.toString() };
63
+ var defaultFee = { amount: [gasFeeAmount], gas: txMisc.gas.toString(), granter: txMisc.feeGranter };
64
+ return { fee: defaultFee, memo: txMisc.memo };
65
+ };
52
66
  FirmaUtil.getUTokenStringFromTokenStr = function (tokenAmount, decimal) {
53
67
  var fct = Number.parseFloat(tokenAmount);
54
68
  var decimalMutiplyer = Math.pow(10, decimal);
@@ -208,3 +222,5 @@ var FirmaUtil = /** @class */ (function () {
208
222
  return FirmaUtil;
209
223
  }());
210
224
  exports.FirmaUtil = FirmaUtil;
225
+ exports.DefaultTxMisc = { memo: "", fee: 0, gas: 0, feeGranter: "" };
226
+ exports.getSignAndBroadcastOption = FirmaUtil.getSignAndBroadcastOption;
@@ -28,13 +28,6 @@ export interface TxMisc {
28
28
  gas?: number;
29
29
  feeGranter?: string;
30
30
  }
31
- export declare function getSignAndBroadcastOption(denom: string, txMisc?: TxMisc): SignAndBroadcastOptions;
32
- export declare const DefaultTxMisc: {
33
- memo: string;
34
- fee: number;
35
- gas: number;
36
- feeGranter: string;
37
- };
38
31
  export interface SignAndBroadcastOptions {
39
32
  fee: StdFee;
40
33
  memo: string;
@@ -1,23 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VotingOption = exports.DefaultTxMisc = exports.getSignAndBroadcastOption = exports.DefaultBasicFeeGrantOption = void 0;
3
+ exports.VotingOption = exports.DefaultBasicFeeGrantOption = void 0;
4
4
  exports.DefaultBasicFeeGrantOption = { spendLimit: undefined, expiration: undefined };
5
- function getSignAndBroadcastOption(denom, txMisc) {
6
- if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
7
- if (txMisc.memo == null)
8
- txMisc.memo = "";
9
- if (txMisc.fee == null)
10
- txMisc.fee = 200000;
11
- if (txMisc.gas == null)
12
- txMisc.gas = 200000;
13
- if (txMisc.feeGranter == null)
14
- txMisc.feeGranter = "";
15
- var gasFeeAmount = { denom: denom, amount: txMisc.fee.toString() };
16
- var defaultFee = { amount: [gasFeeAmount], gas: txMisc.gas.toString(), granter: txMisc.feeGranter };
17
- return { fee: defaultFee, memo: txMisc.memo };
18
- }
19
- exports.getSignAndBroadcastOption = getSignAndBroadcastOption;
20
- exports.DefaultTxMisc = { memo: "", fee: 200000, gas: 200000, feeGranter: "" };
21
5
  var VotingOption;
22
6
  (function (VotingOption) {
23
7
  /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",