@firmachain/firma-js 0.2.2 → 0.2.6

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -154
  3. package/dist/sdk/FirmaBankService.d.ts +5 -5
  4. package/dist/sdk/FirmaBankService.js +30 -30
  5. package/dist/sdk/FirmaConfig.d.ts +3 -3
  6. package/dist/sdk/FirmaContractService.d.ts +5 -5
  7. package/dist/sdk/FirmaContractService.js +19 -19
  8. package/dist/sdk/FirmaDistributionService.d.ts +13 -9
  9. package/dist/sdk/FirmaDistributionService.js +162 -78
  10. package/dist/sdk/FirmaFeeGrantService.d.ts +11 -8
  11. package/dist/sdk/FirmaFeeGrantService.js +128 -53
  12. package/dist/sdk/FirmaGovService.d.ts +28 -16
  13. package/dist/sdk/FirmaGovService.js +447 -119
  14. package/dist/sdk/FirmaIpfsService.d.ts +4 -4
  15. package/dist/sdk/FirmaIpfsService.js +14 -14
  16. package/dist/sdk/FirmaNftService.d.ts +4 -4
  17. package/dist/sdk/FirmaNftService.js +18 -20
  18. package/dist/sdk/FirmaSDK.js +2 -1
  19. package/dist/sdk/FirmaStakingService.d.ts +9 -6
  20. package/dist/sdk/FirmaStakingService.js +177 -97
  21. package/dist/sdk/FirmaUtil.d.ts +3 -2
  22. package/dist/sdk/FirmaUtil.js +16 -11
  23. package/dist/sdk/FirmaWalletService.d.ts +6 -6
  24. package/dist/sdk/FirmaWalletService.js +22 -22
  25. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +1 -1
  26. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  27. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +3 -4
  28. package/dist/sdk/firmachain/bank/BankTxClient.js +2 -2
  29. package/dist/sdk/firmachain/common/ITxClient.d.ts +5 -5
  30. package/dist/sdk/firmachain/common/ITxClient.js +7 -7
  31. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +1 -1
  32. package/dist/sdk/firmachain/common/TendermintQueryClient.js +5 -4
  33. package/dist/sdk/firmachain/common/accounts.js +25 -20
  34. package/dist/sdk/firmachain/common/signingstargateclient.js +3 -3
  35. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +2 -2
  36. package/dist/sdk/firmachain/contract/ContractQueryClient.js +17 -11
  37. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +3 -4
  38. package/dist/sdk/firmachain/contract/ContractTxClient.js +3 -3
  39. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +2 -1
  40. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +33 -16
  41. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +5 -6
  42. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +3 -3
  43. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +2 -2
  44. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +4 -4
  45. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +3 -4
  46. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +2 -2
  47. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +51 -3
  48. package/dist/sdk/firmachain/gov/GovQueryClient.js +62 -11
  49. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +4 -5
  50. package/dist/sdk/firmachain/gov/GovTxClient.js +3 -3
  51. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +2 -2
  52. package/dist/sdk/firmachain/nft/NftQueryClient.js +11 -8
  53. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +4 -5
  54. package/dist/sdk/firmachain/nft/NftTxClient.js +3 -3
  55. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +3 -1
  56. package/dist/sdk/firmachain/staking/StakingQueryClient.js +48 -16
  57. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +6 -7
  58. package/dist/sdk/firmachain/staking/StakingTxClient.js +2 -2
  59. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import { FirmaConfig } from "./FirmaConfig";
2
2
  export declare class IpfsService {
3
- private _config;
4
- private _ipfsNodeClient;
5
- private _protocol;
6
- constructor(_config: FirmaConfig);
3
+ private readonly config;
4
+ private ipfsNodeClient;
5
+ private readonly protocol;
6
+ constructor(config: FirmaConfig);
7
7
  addJson(jsonData: string): Promise<string>;
8
8
  addBuffer(buffer: ArrayBuffer): Promise<string>;
9
9
  addFile(fileUrl: string): Promise<string>;
@@ -51,21 +51,21 @@ var ipfs_http_client_1 = require("ipfs-http-client");
51
51
  var fs_1 = __importDefault(require("fs"));
52
52
  var FirmaUtil_1 = require("./FirmaUtil");
53
53
  var IpfsService = /** @class */ (function () {
54
- function IpfsService(_config) {
55
- this._config = _config;
56
- if (_config.ipfsNodeAddress.includes("https://")) {
57
- this._protocol = "https";
54
+ function IpfsService(config) {
55
+ this.config = config;
56
+ if (config.ipfsNodeAddress.includes("https://")) {
57
+ this.protocol = "https";
58
58
  }
59
- else if (_config.ipfsNodeAddress.includes("http://")) {
60
- this._protocol = "http";
59
+ else if (config.ipfsNodeAddress.includes("http://")) {
60
+ this.protocol = "http";
61
61
  }
62
62
  else {
63
- this._protocol = "https";
63
+ this.protocol = "https";
64
64
  }
65
- var address = _config.ipfsNodeAddress;
65
+ var address = config.ipfsNodeAddress;
66
66
  address = address.replace("https://", "");
67
67
  address = address.replace("http://", "");
68
- this._ipfsNodeClient = ipfs_http_client_1.create({ host: address, port: _config.ipfsNodePort, protocol: this._protocol });
68
+ this.ipfsNodeClient = ipfs_http_client_1.create({ host: address, port: config.ipfsNodePort, protocol: this.protocol });
69
69
  }
70
70
  IpfsService.prototype.addJson = function (jsonData) {
71
71
  return __awaiter(this, void 0, void 0, function () {
@@ -74,7 +74,7 @@ var IpfsService = /** @class */ (function () {
74
74
  switch (_a.label) {
75
75
  case 0:
76
76
  _a.trys.push([0, 2, , 3]);
77
- return [4 /*yield*/, this._ipfsNodeClient.add(jsonData)];
77
+ return [4 /*yield*/, this.ipfsNodeClient.add(jsonData)];
78
78
  case 1:
79
79
  result = _a.sent();
80
80
  return [2 /*return*/, result.cid.toString()];
@@ -94,7 +94,7 @@ var IpfsService = /** @class */ (function () {
94
94
  switch (_a.label) {
95
95
  case 0:
96
96
  _a.trys.push([0, 2, , 3]);
97
- return [4 /*yield*/, this._ipfsNodeClient.add(buffer)];
97
+ return [4 /*yield*/, this.ipfsNodeClient.add(buffer)];
98
98
  case 1:
99
99
  result = _a.sent();
100
100
  return [2 /*return*/, result.cid.toString()];
@@ -115,7 +115,7 @@ var IpfsService = /** @class */ (function () {
115
115
  case 0:
116
116
  _a.trys.push([0, 2, , 3]);
117
117
  data = fs_1.default.readFileSync(fileUrl);
118
- return [4 /*yield*/, this._ipfsNodeClient.add(data)];
118
+ return [4 /*yield*/, this.ipfsNodeClient.add(data)];
119
119
  case 1:
120
120
  result = _a.sent();
121
121
  return [2 /*return*/, result.cid.toString()];
@@ -136,7 +136,7 @@ var IpfsService = /** @class */ (function () {
136
136
  switch (_b.label) {
137
137
  case 0:
138
138
  _b.trys.push([0, 13, , 14]);
139
- stream = this._ipfsNodeClient.get(hash);
139
+ stream = this.ipfsNodeClient.get(hash);
140
140
  data = "";
141
141
  _b.label = 1;
142
142
  case 1:
@@ -178,7 +178,7 @@ var IpfsService = /** @class */ (function () {
178
178
  });
179
179
  };
180
180
  IpfsService.prototype.getURLFromHash = function (hash) {
181
- return this._config.ipfsWebApiAddress + "/ipfs/" + hash;
181
+ return this.config.ipfsWebApiAddress + "/ipfs/" + hash;
182
182
  };
183
183
  return IpfsService;
184
184
  }());
@@ -1,10 +1,10 @@
1
- import { NftItemType, Pagination, TxMisc } from './firmachain/nft';
1
+ import { NftItemType, Pagination, TxMisc } from "./firmachain/nft";
2
2
  import { FirmaConfig } from "./FirmaConfig";
3
3
  import { FirmaWalletService } from "./FirmaWalletService";
4
- import { BroadcastTxResponse } from './firmachain/common/stargateclient';
4
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
5
5
  export declare class NftService {
6
- private _config;
7
- constructor(_config: FirmaConfig);
6
+ private readonly config;
7
+ constructor(config: FirmaConfig);
8
8
  getNftItemAll(paginationKey?: string): Promise<{
9
9
  dataList: NftItemType[];
10
10
  pagination: Pagination;
@@ -40,8 +40,8 @@ exports.NftService = void 0;
40
40
  var nft_1 = require("./firmachain/nft");
41
41
  var FirmaUtil_1 = require("./FirmaUtil");
42
42
  var NftService = /** @class */ (function () {
43
- function NftService(_config) {
44
- this._config = _config;
43
+ function NftService(config) {
44
+ this.config = config;
45
45
  }
46
46
  NftService.prototype.getNftItemAll = function (paginationKey) {
47
47
  if (paginationKey === void 0) { paginationKey = ""; }
@@ -51,7 +51,7 @@ var NftService = /** @class */ (function () {
51
51
  switch (_a.label) {
52
52
  case 0:
53
53
  _a.trys.push([0, 2, , 3]);
54
- nftQueryClient = new nft_1.NftQueryClient(this._config.restApiAddress);
54
+ nftQueryClient = new nft_1.NftQueryClient(this.config.restApiAddress);
55
55
  return [4 /*yield*/, nftQueryClient.queryNftItemAll(paginationKey)];
56
56
  case 1: return [2 /*return*/, _a.sent()];
57
57
  case 2:
@@ -70,7 +70,7 @@ var NftService = /** @class */ (function () {
70
70
  switch (_a.label) {
71
71
  case 0:
72
72
  _a.trys.push([0, 2, , 3]);
73
- nftQueryClient = new nft_1.NftQueryClient(this._config.restApiAddress);
73
+ nftQueryClient = new nft_1.NftQueryClient(this.config.restApiAddress);
74
74
  return [4 /*yield*/, nftQueryClient.queryNftItem(nftId)];
75
75
  case 1:
76
76
  nftItem = _a.sent();
@@ -97,12 +97,12 @@ var NftService = /** @class */ (function () {
97
97
  nftTotal = _a.sent();
98
98
  totalPerPage = 100;
99
99
  nftItemList = [];
100
- nftQueryClient = new nft_1.NftQueryClient(this._config.restApiAddress);
100
+ nftQueryClient = new nft_1.NftQueryClient(this.config.restApiAddress);
101
101
  current = 0;
102
102
  nextTarget = nftTotal;
103
103
  nextKey = "";
104
104
  if (nftTotal > totalPerPage) {
105
- if (paginationKey != "")
105
+ if (paginationKey !== "")
106
106
  current = Number.parseInt(paginationKey);
107
107
  nextTarget = current + totalPerPage;
108
108
  if (nextTarget >= nftTotal)
@@ -125,9 +125,7 @@ var NftService = /** @class */ (function () {
125
125
  case 5:
126
126
  i++;
127
127
  return [3 /*break*/, 2];
128
- case 6:
129
- // current가 0일때만 total을 주고, 그외의 index에서는 0을 줌 (cosmos 방식과 동일하게 처리)
130
- return [2 /*return*/, { dataList: nftItemList, pagination: { next_key: nextKey, total: (current == 0 ? nftTotal : 0) } }];
128
+ case 6: return [2 /*return*/, { dataList: nftItemList, pagination: { next_key: nextKey, total: (current === 0 ? nftTotal : 0) } }];
131
129
  case 7:
132
130
  error_3 = _a.sent();
133
131
  FirmaUtil_1.FirmaUtil.printLog(error_3);
@@ -144,7 +142,7 @@ var NftService = /** @class */ (function () {
144
142
  switch (_a.label) {
145
143
  case 0:
146
144
  _a.trys.push([0, 3, , 4]);
147
- nftQueryClient = new nft_1.NftQueryClient(this._config.restApiAddress);
145
+ nftQueryClient = new nft_1.NftQueryClient(this.config.restApiAddress);
148
146
  return [4 /*yield*/, nftQueryClient.queryTokenOfOwnerByIndex(ownerAddress, index.toString())];
149
147
  case 1:
150
148
  nftID = _a.sent();
@@ -166,7 +164,7 @@ var NftService = /** @class */ (function () {
166
164
  switch (_a.label) {
167
165
  case 0:
168
166
  _a.trys.push([0, 2, , 3]);
169
- nftQueryClient = new nft_1.NftQueryClient(this._config.restApiAddress);
167
+ nftQueryClient = new nft_1.NftQueryClient(this.config.restApiAddress);
170
168
  return [4 /*yield*/, nftQueryClient.queryBalanceOf(ownerAddress)];
171
169
  case 1:
172
170
  total = _a.sent();
@@ -213,9 +211,9 @@ var NftService = /** @class */ (function () {
213
211
  return [4 /*yield*/, wallet.getAddress()];
214
212
  case 1:
215
213
  address = _a.sent();
216
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this._config.rpcAddress);
214
+ nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
217
215
  message = nftTxClient.msgTransfer({ owner: address, toAddress: toAddress, nftId: parseInt(nftID) });
218
- return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
216
+ return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
219
217
  case 2: return [2 /*return*/, _a.sent()];
220
218
  case 3:
221
219
  error_7 = _a.sent();
@@ -237,7 +235,7 @@ var NftService = /** @class */ (function () {
237
235
  return [4 /*yield*/, this.getSignedTxTransfer(wallet, toAddress, nftID, txMisc)];
238
236
  case 1:
239
237
  txRaw = _a.sent();
240
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this._config.rpcAddress);
238
+ nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
241
239
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
242
240
  case 2: return [2 /*return*/, _a.sent()];
243
241
  case 3:
@@ -282,9 +280,9 @@ var NftService = /** @class */ (function () {
282
280
  return [4 /*yield*/, wallet.getAddress()];
283
281
  case 1:
284
282
  address = _a.sent();
285
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this._config.rpcAddress);
283
+ nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
286
284
  message = nftTxClient.msgBurn({ owner: address, nftId: parseInt(nftID) });
287
- return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
285
+ return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
288
286
  case 2: return [2 /*return*/, _a.sent()];
289
287
  case 3:
290
288
  error_10 = _a.sent();
@@ -306,7 +304,7 @@ var NftService = /** @class */ (function () {
306
304
  return [4 /*yield*/, this.getSignedTxBurn(wallet, nftID, txMisc)];
307
305
  case 1:
308
306
  txRaw = _a.sent();
309
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this._config.rpcAddress);
307
+ nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
310
308
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
311
309
  case 2: return [2 /*return*/, _a.sent()];
312
310
  case 3:
@@ -351,9 +349,9 @@ var NftService = /** @class */ (function () {
351
349
  return [4 /*yield*/, wallet.getAddress()];
352
350
  case 1:
353
351
  address = _a.sent();
354
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this._config.rpcAddress);
352
+ nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
355
353
  message = nftTxClient.msgMint({ owner: address, tokenURI: tokenURI });
356
- return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
354
+ return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
357
355
  case 2: return [2 /*return*/, _a.sent()];
358
356
  case 3:
359
357
  error_13 = _a.sent();
@@ -375,7 +373,7 @@ var NftService = /** @class */ (function () {
375
373
  return [4 /*yield*/, this.getSignedTxMint(wallet, tokenURI, txMisc)];
376
374
  case 1:
377
375
  txRaw = _a.sent();
378
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this._config.rpcAddress);
376
+ nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
379
377
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
380
378
  case 2: return [2 /*return*/, _a.sent()];
381
379
  case 3:
@@ -11,6 +11,7 @@ var FirmaIpfsService_1 = require("./FirmaIpfsService");
11
11
  var FirmaWalletService_1 = require("./FirmaWalletService");
12
12
  var FirmaUtil_1 = require("./FirmaUtil");
13
13
  var FirmaGovService_1 = require("./FirmaGovService");
14
+ //import config = FirmaUtil.config;
14
15
  var FirmaSDK = /** @class */ (function () {
15
16
  function FirmaSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Contract, Ipfs) {
16
17
  if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
@@ -32,7 +33,7 @@ var FirmaSDK = /** @class */ (function () {
32
33
  this.Nft = Nft;
33
34
  this.Contract = Contract;
34
35
  this.Ipfs = Ipfs;
35
- FirmaUtil_1.FirmaUtil.Config = Config;
36
+ FirmaUtil_1.FirmaUtil.config = Config;
36
37
  }
37
38
  return FirmaSDK;
38
39
  }());
@@ -1,14 +1,15 @@
1
- import { TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo } from './firmachain/staking';
1
+ import { TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo } from "./firmachain/staking";
2
2
  import { FirmaWalletService } from "./FirmaWalletService";
3
3
  import { FirmaConfig } from "./FirmaConfig";
4
- import { BroadcastTxResponse } from './firmachain/common/stargateclient';
5
- import { Description } from 'cosmjs-types/cosmos/staking/v1beta1/staking';
6
- import { MsgCreateValidator } from 'cosmjs-types/cosmos/staking/v1beta1/tx';
4
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
5
+ import { Description } from "cosmjs-types/cosmos/staking/v1beta1/staking";
6
+ import { MsgCreateValidator } from "cosmjs-types/cosmos/staking/v1beta1/tx";
7
7
  export declare class FirmaStakingService {
8
- private _config;
9
- constructor(_config: FirmaConfig);
8
+ private readonly config;
9
+ constructor(config: FirmaConfig);
10
10
  getGasEstimationDelegate(wallet: FirmaWalletService, validatorAddres: string, amount: number, txMisc?: TxMisc): Promise<number>;
11
11
  getGasEstimationUndelegate(wallet: FirmaWalletService, validatorAddres: string, amount: number, txMisc?: TxMisc): Promise<number>;
12
+ getGasEstimationRedelegate(wallet: FirmaWalletService, validatorSrcAddress: string, validatorDstAddress: string, amount: number, txMisc?: TxMisc): Promise<number>;
12
13
  private getSignedTxDelegate;
13
14
  private getSignedTxUndelegate;
14
15
  private getSignedTxRedelegate;
@@ -19,6 +20,8 @@ export declare class FirmaStakingService {
19
20
  redelegate(wallet: FirmaWalletService, validatorSrcAddress: string, validatorDstAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
20
21
  undelegate(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
21
22
  delegate(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
23
+ getUndelegationInfoFromValidator(address: string, validatorAddress: string): Promise<UndelegationInfo>;
24
+ getDelegationInfoFromValidator(address: string, validatorAddress: string): Promise<DelegationInfo>;
22
25
  getTotalUndelegateInfo(address: string): Promise<UndelegationInfo[]>;
23
26
  getTotalRedelegationInfo(address: string): Promise<RedelegationInfo[]>;
24
27
  getUndelegationListFromValidator(valoperAddress: string): Promise<UndelegationInfo[]>;