@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 FirmaChain, PTE.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,154 +1,153 @@
1
- # firma-js
2
- Javascript SDK for FirmaChain
3
-
4
- [![npm version](https://badge.fury.io/js/%40firmachain%2Ffirma-js.svg)](https://badge.fury.io/js/%40firmachain%2Ffirma-js)
5
-
6
- ## Install
7
- You can install `firma-js` using [NPM](https://www.npmjs.com/package/@firmachain/firma-js)
8
- ```
9
- yarn add @firmachain/firma-js
10
- ```
11
- or
12
- ```
13
- npm i @firmachain/firma-js
14
- ```
15
-
16
- ## Usage
17
- ### Initializing SDK
18
- ```js
19
- const {Firma} = require('@firmachain/firma-js');
20
-
21
- const chainId = 'imperium-0001';
22
- const lcdUrl = 'http://localhost:1317';
23
-
24
- const firma = new Firma(chainId, lcdUrl);
25
- ```
26
-
27
- ### Create account
28
- ```js
29
- const {Wallet} = require('@firmachain/firma-js');
30
-
31
- const mnemonic = Wallet.generateMnemonic();
32
- const index = 0;
33
-
34
- const wallet = Wallet.fromMnemonic(mnemonic, index);
35
-
36
- console.log(wallet.accAddress);
37
- ```
38
-
39
- ### Import account by private key
40
- ```js
41
- const {Wallet} = require('@firmachain/firma-js');
42
-
43
- const wallet = Wallet.fromPrivateKey(privateKey);
44
-
45
- console.log(wallet.accAddress);
46
- ```
47
-
48
- ### Get current block number
49
- ```js
50
- firma.blockchain.getBlockNumber().then((blockNumber) => {
51
- console.log(blockNumber);
52
- }).catch((e) => {
53
- console.error(e);
54
- };
55
- ```
56
-
57
- ### Get FIRMA balance of specific account
58
- ```js
59
- firma.account.getBalance(address).then((balance) => {
60
- console.log(balance);
61
- }).catch((e) => {
62
- console.error(e);
63
- };
64
- ```
65
-
66
- ### Get transaction by hash
67
- ```js
68
- firma.tx.getTransactionByHash(txHash).then((tx) => {
69
- console.log(tx)
70
- }).catch((e) => {
71
- console.error(e);
72
- });
73
- ```
74
-
75
- ### Create Message (MsgSend) & StdTx
76
- ```js
77
- const {MsgSend, StdTx} = require('@firmachain/firma-js');
78
- const msg = new MsgSend(fromAddress, toAddress, (1 * 10 ** 6)); //send 1 FIRMA to toAddress
79
- const stdTx = new StdTx(msg);
80
- ```
81
-
82
- ### Calculate gas
83
- ```js
84
- const gasAdjustment = 2;
85
- firma.tx.estimateGas(stdTx, gasAdjustment).then((fee) => {
86
- // return Fee object
87
- stdTx.setFee(fee);
88
- }).catch((e) => {
89
- console.log(e);
90
- });
91
- ```
92
-
93
- ### Sign Transaction & Broadcast Transaction
94
- ```js
95
- const {Wallet} = require('@firmachain/firma-js');
96
- const wallet = Wallet.fromPrivateKey(privateKey);
97
-
98
- firma.signStdTx(stdTx, wallet).then((tx) => {
99
- firma.tx.broadcast(tx).then((result) => {
100
- console.log('result', result);
101
- }).catch((e) => {
102
- console.log(e);
103
- });
104
- }).catch((e) => {
105
- console.log(e);
106
- });
107
- ```
108
-
109
- ### Shortcut of sign transaction
110
- ```js
111
- firma.createAndSign(wallet, msg).then((signedTx) => {
112
- firma.tx.broadcast(signedTx).then(console.log)
113
- })
114
- ```
115
-
116
- ### Mint NFT
117
- ```js
118
- // MintNFT msg
119
- // image, tokenURI, description are metadata
120
- const msg = new MsgMintNFT("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b", testAccount.accAddress, 'https://ipfs.infura.io:5001/api/v0/cat?arg=QmfWVHyTiVXscS4kHENQRXKD5ug1qd2UQJAE6aCX5ch2Eq', "test description", "https://ipfs.infura.io:5001/api/v0/cat?arg=QmTF7NerdGZhnDPJj3Yj51gqH18o8kLtgkgtVjMLk1V9tx");
121
-
122
- firma.createAndSign(wallet, msg).then((signedTx) => {
123
- firma.tx.broadcast(signedTx).then(console.log)
124
- }).catch(console.error)
125
-
126
- ```
127
-
128
- ### Transfer NFT
129
- ```js
130
- // TransferNFT msg
131
- const msg = new MsgTransferNFT("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b", testAccount.accAddress, 'firma1rhfahdeh2f644f8mjeclyzp2jn9cshs0md8z5a');
132
-
133
- firma.createAndSign(wallet, msg).then((signedTx) => {
134
- firma.tx.broadcast(signedTx).then(console.log)
135
- }).catch(console.error);
136
- ```
137
-
138
-
139
- ### Burn NFT
140
- ```js
141
- // BurnNFT msg
142
- const msg = new MsgBurnNFT("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b", testAccount.accAddress);
143
-
144
- firma.createAndSign(wallet, msg).then((signedTx) => {
145
- firma.tx.broadcast(signedTx).then(console.log)
146
- }).catch(console.error);
147
-
148
- ```
149
-
150
-
151
-
152
- ## License
153
- MIT
154
- [See LICENSE](https://github.com/FirmaChain/firma-js/blob/main/LICENSE)
1
+ # firma-js
2
+
3
+ [![npm version](https://badge.fury.io/js/%40firmachain%2Ffirma-js.svg)](https://badge.fury.io/js/%40firmachain%2Ffirma-js)
4
+ [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/firmachain/firma-js)](https://github.com/firmachain/firma-js/releases)
5
+ [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/firmachain/firma-js/blob/master/LICENSE)
6
+ ![Lines of code](https://img.shields.io/tokei/lines/github/firmachain/firma-js)
7
+
8
+ Javascript SDK for FirmaChain
9
+
10
+
11
+ ## Install
12
+ You can install `firma-js` using [NPM](https://www.npmjs.com/package/@firmachain/firma-js)
13
+ ```
14
+ yarn add @firmachain/firma-js
15
+ ```
16
+ or
17
+ ```
18
+ npm i @firmachain/firma-js
19
+ ```
20
+
21
+ ## Usage
22
+ ### Initializing SDK
23
+ ```js
24
+ const {Firma} = require('@firmachain/firma-js');
25
+
26
+ const chainId = 'imperium-0001';
27
+ const lcdUrl = 'http://localhost:1317';
28
+
29
+ const firma = new Firma(chainId, lcdUrl);
30
+ ```
31
+
32
+ ### Create account
33
+ ```js
34
+ const {Wallet} = require('@firmachain/firma-js');
35
+
36
+ const mnemonic = Wallet.generateMnemonic();
37
+ const index = 0;
38
+
39
+ const wallet = Wallet.fromMnemonic(mnemonic, index);
40
+
41
+ console.log(wallet.accAddress);
42
+ ```
43
+
44
+ ### Import account by private key
45
+ ```js
46
+ const {Wallet} = require('@firmachain/firma-js');
47
+
48
+ const wallet = Wallet.fromPrivateKey(privateKey);
49
+
50
+ console.log(wallet.accAddress);
51
+ ```
52
+
53
+ ### Get current block number
54
+ ```js
55
+ firma.blockchain.getBlockNumber().then((blockNumber) => {
56
+ console.log(blockNumber);
57
+ }).catch((e) => {
58
+ console.error(e);
59
+ };
60
+ ```
61
+
62
+ ### Get FIRMA balance of specific account
63
+ ```js
64
+ firma.account.getBalance(address).then((balance) => {
65
+ console.log(balance);
66
+ }).catch((e) => {
67
+ console.error(e);
68
+ };
69
+ ```
70
+
71
+ ### Get transaction by hash
72
+ ```js
73
+ firma.tx.getTransactionByHash(txHash).then((tx) => {
74
+ console.log(tx)
75
+ }).catch((e) => {
76
+ console.error(e);
77
+ });
78
+ ```
79
+
80
+ ### Create Message (MsgSend) & StdTx
81
+ ```js
82
+ const {MsgSend, StdTx} = require('@firmachain/firma-js');
83
+ const msg = new MsgSend(fromAddress, toAddress, (1 * 10 ** 6)); //send 1 FIRMA to toAddress
84
+ const stdTx = new StdTx(msg);
85
+ ```
86
+
87
+ ### Calculate gas
88
+ ```js
89
+ const gasAdjustment = 2;
90
+ firma.tx.estimateGas(stdTx, gasAdjustment).then((fee) => {
91
+ // return Fee object
92
+ stdTx.setFee(fee);
93
+ }).catch((e) => {
94
+ console.log(e);
95
+ });
96
+ ```
97
+
98
+ ### Sign Transaction & Broadcast Transaction
99
+ ```js
100
+ const {Wallet} = require('@firmachain/firma-js');
101
+ const wallet = Wallet.fromPrivateKey(privateKey);
102
+
103
+ firma.signStdTx(stdTx, wallet).then((tx) => {
104
+ firma.tx.broadcast(tx).then((result) => {
105
+ console.log('result', result);
106
+ }).catch((e) => {
107
+ console.log(e);
108
+ });
109
+ }).catch((e) => {
110
+ console.log(e);
111
+ });
112
+ ```
113
+
114
+ ### Shortcut of sign transaction
115
+ ```js
116
+ firma.createAndSign(wallet, msg).then((signedTx) => {
117
+ firma.tx.broadcast(signedTx).then(console.log)
118
+ })
119
+ ```
120
+
121
+ ### Mint NFT
122
+ ```js
123
+ // MintNFT msg
124
+ // image, tokenURI, description are metadata
125
+ const msg = new MsgMintNFT("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b", testAccount.accAddress, 'https://ipfs.infura.io:5001/api/v0/cat?arg=QmfWVHyTiVXscS4kHENQRXKD5ug1qd2UQJAE6aCX5ch2Eq', "test description", "https://ipfs.infura.io:5001/api/v0/cat?arg=QmTF7NerdGZhnDPJj3Yj51gqH18o8kLtgkgtVjMLk1V9tx");
126
+
127
+ firma.createAndSign(wallet, msg).then((signedTx) => {
128
+ firma.tx.broadcast(signedTx).then(console.log)
129
+ }).catch(console.error)
130
+
131
+ ```
132
+
133
+ ### Transfer NFT
134
+ ```js
135
+ // TransferNFT msg
136
+ const msg = new MsgTransferNFT("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b", testAccount.accAddress, 'firma1rhfahdeh2f644f8mjeclyzp2jn9cshs0md8z5a');
137
+
138
+ firma.createAndSign(wallet, msg).then((signedTx) => {
139
+ firma.tx.broadcast(signedTx).then(console.log)
140
+ }).catch(console.error);
141
+ ```
142
+
143
+
144
+ ### Burn NFT
145
+ ```js
146
+ // BurnNFT msg
147
+ const msg = new MsgBurnNFT("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b", testAccount.accAddress);
148
+
149
+ firma.createAndSign(wallet, msg).then((signedTx) => {
150
+ firma.tx.broadcast(signedTx).then(console.log)
151
+ }).catch(console.error);
152
+
153
+ ```
@@ -1,12 +1,12 @@
1
- import { TxMisc } from './firmachain/bank';
1
+ import { TxMisc } from "./firmachain/bank";
2
2
  import { FirmaWalletService } from "./FirmaWalletService";
3
3
  import { FirmaConfig } from "./FirmaConfig";
4
- import { BroadcastTxResponse } from './firmachain/common/stargateclient';
4
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
5
5
  export declare class FirmaBankService {
6
- private _config;
7
- constructor(_config: FirmaConfig);
6
+ private readonly config;
7
+ constructor(config: FirmaConfig);
8
8
  getGasEstimationSend(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<number>;
9
- private getSignedTxSend;
10
9
  send(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
11
10
  getBalance(address: string): Promise<string>;
11
+ private getSignedTxSend;
12
12
  }
@@ -40,8 +40,8 @@ exports.FirmaBankService = void 0;
40
40
  var bank_1 = require("./firmachain/bank");
41
41
  var FirmaUtil_1 = require("./FirmaUtil");
42
42
  var FirmaBankService = /** @class */ (function () {
43
- function FirmaBankService(_config) {
44
- this._config = _config;
43
+ function FirmaBankService(config) {
44
+ this.config = config;
45
45
  }
46
46
  FirmaBankService.prototype.getGasEstimationSend = function (wallet, targetAddress, amount, txMisc) {
47
47
  if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
@@ -65,21 +65,19 @@ var FirmaBankService = /** @class */ (function () {
65
65
  });
66
66
  });
67
67
  };
68
- FirmaBankService.prototype.getSignedTxSend = function (wallet, targetAddress, amount, txMisc) {
68
+ FirmaBankService.prototype.send = function (wallet, targetAddress, amount, txMisc) {
69
69
  if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
70
70
  return __awaiter(this, void 0, void 0, function () {
71
- var bankTxClient, address, sendAmount, message, error_2;
71
+ var txRaw, bankTxClient, error_2;
72
72
  return __generator(this, function (_a) {
73
73
  switch (_a.label) {
74
74
  case 0:
75
75
  _a.trys.push([0, 3, , 4]);
76
- bankTxClient = new bank_1.BankTxClient(wallet.getRawWallet(), this._config.rpcAddress);
77
- return [4 /*yield*/, wallet.getAddress()];
76
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, amount, txMisc)];
78
77
  case 1:
79
- address = _a.sent();
80
- sendAmount = { denom: this._config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
81
- message = bankTxClient.msgSend({ fromAddress: address, toAddress: targetAddress, amount: [sendAmount] });
82
- return [4 /*yield*/, bankTxClient.sign([message], bank_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
78
+ txRaw = _a.sent();
79
+ bankTxClient = new bank_1.BankTxClient(wallet.getRawWallet(), this.config.rpcAddress);
80
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
83
81
  case 2: return [2 /*return*/, _a.sent()];
84
82
  case 3:
85
83
  error_2 = _a.sent();
@@ -90,46 +88,48 @@ var FirmaBankService = /** @class */ (function () {
90
88
  });
91
89
  });
92
90
  };
93
- FirmaBankService.prototype.send = function (wallet, targetAddress, amount, txMisc) {
94
- if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
91
+ FirmaBankService.prototype.getBalance = function (address) {
95
92
  return __awaiter(this, void 0, void 0, function () {
96
- var txRaw, bankTxClient, error_3;
93
+ var bankQueryClient, result, error_3;
97
94
  return __generator(this, function (_a) {
98
95
  switch (_a.label) {
99
96
  case 0:
100
- _a.trys.push([0, 3, , 4]);
101
- return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, amount, txMisc)];
97
+ _a.trys.push([0, 2, , 3]);
98
+ bankQueryClient = new bank_1.BankQueryClient(this.config.restApiAddress);
99
+ return [4 /*yield*/, bankQueryClient.queryBalance(address, this.config.denom)];
102
100
  case 1:
103
- txRaw = _a.sent();
104
- bankTxClient = new bank_1.BankTxClient(wallet.getRawWallet(), this._config.rpcAddress);
105
- return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
106
- case 2: return [2 /*return*/, _a.sent()];
107
- case 3:
101
+ result = _a.sent();
102
+ return [2 /*return*/, result];
103
+ case 2:
108
104
  error_3 = _a.sent();
109
105
  FirmaUtil_1.FirmaUtil.printLog(error_3);
110
106
  throw error_3;
111
- case 4: return [2 /*return*/];
107
+ case 3: return [2 /*return*/];
112
108
  }
113
109
  });
114
110
  });
115
111
  };
116
- FirmaBankService.prototype.getBalance = function (address) {
112
+ FirmaBankService.prototype.getSignedTxSend = function (wallet, targetAddress, amount, txMisc) {
113
+ if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
117
114
  return __awaiter(this, void 0, void 0, function () {
118
- var bankQueryClient, result, error_4;
115
+ var bankTxClient, address, sendAmount, message, error_4;
119
116
  return __generator(this, function (_a) {
120
117
  switch (_a.label) {
121
118
  case 0:
122
- _a.trys.push([0, 2, , 3]);
123
- bankQueryClient = new bank_1.BankQueryClient(this._config.restApiAddress);
124
- return [4 /*yield*/, bankQueryClient.queryBalance(address, this._config.denom)];
119
+ _a.trys.push([0, 3, , 4]);
120
+ bankTxClient = new bank_1.BankTxClient(wallet.getRawWallet(), this.config.rpcAddress);
121
+ return [4 /*yield*/, wallet.getAddress()];
125
122
  case 1:
126
- result = _a.sent();
127
- return [2 /*return*/, result];
128
- case 2:
123
+ address = _a.sent();
124
+ sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
125
+ message = bankTxClient.msgSend({ fromAddress: address, toAddress: targetAddress, amount: [sendAmount] });
126
+ return [4 /*yield*/, bankTxClient.sign([message], bank_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
127
+ case 2: return [2 /*return*/, _a.sent()];
128
+ case 3:
129
129
  error_4 = _a.sent();
130
130
  FirmaUtil_1.FirmaUtil.printLog(error_4);
131
131
  throw error_4;
132
- case 3: return [2 /*return*/];
132
+ case 4: return [2 /*return*/];
133
133
  }
134
134
  });
135
135
  });
@@ -10,7 +10,7 @@ export declare class FirmaConfig {
10
10
  denom: string;
11
11
  isShowLog: boolean;
12
12
  constructor(chainID: string, rpcAddress: string, restApiAddress: string, ipfsNodeAddress: string, ipfsNodePort: number, ipfsWebApiAddress: string, hdPath: string, prefix: string, denom: string, isShowLog: boolean);
13
- static DevNetConfig: FirmaConfig;
14
- static TestNetConfig: FirmaConfig;
15
- static MainNetConfig: FirmaConfig;
13
+ static readonly DevNetConfig: FirmaConfig;
14
+ static readonly TestNetConfig: FirmaConfig;
15
+ static readonly MainNetConfig: FirmaConfig;
16
16
  }
@@ -1,11 +1,11 @@
1
- import { ContractLogType, ContractFileType, Pagination, TxMisc } from './firmachain/contract';
2
- import { EncodeObject } from '@cosmjs/proto-signing';
1
+ import { ContractLogType, ContractFileType, Pagination, TxMisc } from "./firmachain/contract";
2
+ import { EncodeObject } from "@cosmjs/proto-signing";
3
3
  import { FirmaConfig } from "./FirmaConfig";
4
4
  import { FirmaWalletService } from "./FirmaWalletService";
5
- import { BroadcastTxResponse } from './firmachain/common/stargateclient';
5
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
6
6
  export declare class ContractService {
7
- private _config;
8
- constructor(_config: FirmaConfig);
7
+ private readonly config;
8
+ constructor(config: FirmaConfig);
9
9
  getContractLogAll(paginationKey?: string): Promise<{
10
10
  dataList: ContractLogType[];
11
11
  pagination: Pagination;
@@ -40,8 +40,8 @@ exports.ContractService = void 0;
40
40
  var contract_1 = require("./firmachain/contract");
41
41
  var FirmaUtil_1 = require("./FirmaUtil");
42
42
  var ContractService = /** @class */ (function () {
43
- function ContractService(_config) {
44
- this._config = _config;
43
+ function ContractService(config) {
44
+ this.config = config;
45
45
  }
46
46
  ContractService.prototype.getContractLogAll = function (paginationKey) {
47
47
  if (paginationKey === void 0) { paginationKey = ""; }
@@ -51,7 +51,7 @@ var ContractService = /** @class */ (function () {
51
51
  switch (_a.label) {
52
52
  case 0:
53
53
  _a.trys.push([0, 2, , 3]);
54
- contractQueryClient = new contract_1.ContractQueryClient(this._config.restApiAddress);
54
+ contractQueryClient = new contract_1.ContractQueryClient(this.config.restApiAddress);
55
55
  return [4 /*yield*/, contractQueryClient.queryContractLogAll(paginationKey)];
56
56
  case 1: return [2 /*return*/, _a.sent()];
57
57
  case 2:
@@ -71,7 +71,7 @@ var ContractService = /** @class */ (function () {
71
71
  switch (_a.label) {
72
72
  case 0:
73
73
  _a.trys.push([0, 2, , 3]);
74
- contractQueryClient = new contract_1.ContractQueryClient(this._config.restApiAddress);
74
+ contractQueryClient = new contract_1.ContractQueryClient(this.config.restApiAddress);
75
75
  return [4 /*yield*/, contractQueryClient.queryContractFileAll(paginationKey)];
76
76
  case 1: return [2 /*return*/, _a.sent()];
77
77
  case 2:
@@ -90,7 +90,7 @@ var ContractService = /** @class */ (function () {
90
90
  switch (_a.label) {
91
91
  case 0:
92
92
  _a.trys.push([0, 2, , 3]);
93
- contractQueryClient = new contract_1.ContractQueryClient(this._config.restApiAddress);
93
+ contractQueryClient = new contract_1.ContractQueryClient(this.config.restApiAddress);
94
94
  return [4 /*yield*/, contractQueryClient.queryContractFile(fileHash)];
95
95
  case 1: return [2 /*return*/, _a.sent()];
96
96
  case 2:
@@ -109,7 +109,7 @@ var ContractService = /** @class */ (function () {
109
109
  switch (_a.label) {
110
110
  case 0:
111
111
  _a.trys.push([0, 2, , 3]);
112
- contractQueryClient = new contract_1.ContractQueryClient(this._config.restApiAddress);
112
+ contractQueryClient = new contract_1.ContractQueryClient(this.config.restApiAddress);
113
113
  return [4 /*yield*/, contractQueryClient.queryIsContractOwner(fileHash, ownerAddress)];
114
114
  case 1: return [2 /*return*/, _a.sent()];
115
115
  case 2:
@@ -128,7 +128,7 @@ var ContractService = /** @class */ (function () {
128
128
  switch (_a.label) {
129
129
  case 0:
130
130
  _a.trys.push([0, 2, , 3]);
131
- contractQueryClient = new contract_1.ContractQueryClient(this._config.restApiAddress);
131
+ contractQueryClient = new contract_1.ContractQueryClient(this.config.restApiAddress);
132
132
  return [4 /*yield*/, contractQueryClient.queryContractLog(logId)];
133
133
  case 1: return [2 /*return*/, _a.sent()];
134
134
  case 2:
@@ -148,8 +148,8 @@ var ContractService = /** @class */ (function () {
148
148
  switch (_a.label) {
149
149
  case 0:
150
150
  _a.trys.push([0, 3, , 4]);
151
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
152
- return [4 /*yield*/, contractTxClient.sign(txList, contract_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
151
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
152
+ return [4 /*yield*/, contractTxClient.sign(txList, contract_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
153
153
  case 1:
154
154
  txRaw = _a.sent();
155
155
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -195,7 +195,7 @@ var ContractService = /** @class */ (function () {
195
195
  return [4 /*yield*/, wallet.getAddress()];
196
196
  case 1:
197
197
  address = _a.sent();
198
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
198
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
199
199
  return [2 /*return*/, contractTxClient.msgCreateContractFile({
200
200
  creator: address,
201
201
  fileHash: fileHash,
@@ -223,7 +223,7 @@ var ContractService = /** @class */ (function () {
223
223
  return [4 /*yield*/, wallet.getAddress()];
224
224
  case 1:
225
225
  address = _a.sent();
226
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
226
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
227
227
  message = contractTxClient.msgCreateContractFile({
228
228
  creator: address,
229
229
  fileHash: fileHash,
@@ -231,7 +231,7 @@ var ContractService = /** @class */ (function () {
231
231
  ownerList: ownerList,
232
232
  metaDataJsonString: metaDataJsonString
233
233
  });
234
- return [4 /*yield*/, contractTxClient.sign([message], contract_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
234
+ return [4 /*yield*/, contractTxClient.sign([message], contract_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
235
235
  case 2: return [2 /*return*/, _a.sent()];
236
236
  case 3:
237
237
  error_9 = _a.sent();
@@ -253,7 +253,7 @@ var ContractService = /** @class */ (function () {
253
253
  return [4 /*yield*/, this.getSignedTxCreateContractFile(wallet, fileHash, timeStamp, ownerList, metaDataJsonString, txMisc)];
254
254
  case 1:
255
255
  txRaw = _a.sent();
256
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
256
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
257
257
  return [4 /*yield*/, contractTxClient.broadcast(txRaw)];
258
258
  case 2: return [2 /*return*/, _a.sent()];
259
259
  case 3:
@@ -298,7 +298,7 @@ var ContractService = /** @class */ (function () {
298
298
  return [4 /*yield*/, wallet.getAddress()];
299
299
  case 1:
300
300
  address = _a.sent();
301
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
301
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
302
302
  message = contractTxClient.msgAddContractLog({
303
303
  creator: address,
304
304
  contractHash: contractHash,
@@ -307,7 +307,7 @@ var ContractService = /** @class */ (function () {
307
307
  ownerAddress: ownerAddress,
308
308
  jsonString: jsonString
309
309
  });
310
- return [4 /*yield*/, contractTxClient.sign([message], contract_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
310
+ return [4 /*yield*/, contractTxClient.sign([message], contract_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
311
311
  case 2: return [2 /*return*/, _a.sent()];
312
312
  case 3:
313
313
  error_12 = _a.sent();
@@ -329,7 +329,7 @@ var ContractService = /** @class */ (function () {
329
329
  return [4 /*yield*/, this.getSignedTxAddContractLog(wallet, contractHash, timeStamp, eventName, ownerAddress, jsonString, txMisc)];
330
330
  case 1:
331
331
  txRaw = _a.sent();
332
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
332
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
333
333
  return [4 /*yield*/, contractTxClient.broadcast(txRaw)];
334
334
  case 2: return [2 /*return*/, _a.sent()];
335
335
  case 3:
@@ -351,7 +351,7 @@ var ContractService = /** @class */ (function () {
351
351
  return [4 /*yield*/, wallet.getAddress()];
352
352
  case 1:
353
353
  address = _a.sent();
354
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
354
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
355
355
  return [2 /*return*/, contractTxClient.msgAddContractLog({
356
356
  creator: address,
357
357
  contractHash: contractHash,
@@ -377,8 +377,8 @@ var ContractService = /** @class */ (function () {
377
377
  switch (_a.label) {
378
378
  case 0:
379
379
  _a.trys.push([0, 2, , 3]);
380
- contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this._config.rpcAddress);
381
- return [4 /*yield*/, contractTxClient.signAndBroadcast(msgList, contract_1.getSignAndBroadcastOption(this._config.denom, txMisc))];
380
+ contractTxClient = new contract_1.ContractTxClient(wallet.getRawWallet(), this.config.rpcAddress);
381
+ return [4 /*yield*/, contractTxClient.signAndBroadcast(msgList, contract_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
382
382
  case 1: return [2 /*return*/, _a.sent()];
383
383
  case 2:
384
384
  error_15 = _a.sent();