@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.
- package/LICENSE +21 -0
- package/README.md +153 -154
- package/dist/sdk/FirmaBankService.d.ts +5 -5
- package/dist/sdk/FirmaBankService.js +30 -30
- package/dist/sdk/FirmaConfig.d.ts +3 -3
- package/dist/sdk/FirmaContractService.d.ts +5 -5
- package/dist/sdk/FirmaContractService.js +19 -19
- package/dist/sdk/FirmaDistributionService.d.ts +13 -9
- package/dist/sdk/FirmaDistributionService.js +162 -78
- package/dist/sdk/FirmaFeeGrantService.d.ts +11 -8
- package/dist/sdk/FirmaFeeGrantService.js +128 -53
- package/dist/sdk/FirmaGovService.d.ts +28 -16
- package/dist/sdk/FirmaGovService.js +447 -119
- package/dist/sdk/FirmaIpfsService.d.ts +4 -4
- package/dist/sdk/FirmaIpfsService.js +14 -14
- package/dist/sdk/FirmaNftService.d.ts +4 -4
- package/dist/sdk/FirmaNftService.js +18 -20
- package/dist/sdk/FirmaSDK.js +2 -1
- package/dist/sdk/FirmaStakingService.d.ts +9 -6
- package/dist/sdk/FirmaStakingService.js +177 -97
- package/dist/sdk/FirmaUtil.d.ts +3 -2
- package/dist/sdk/FirmaUtil.js +16 -11
- package/dist/sdk/FirmaWalletService.d.ts +6 -6
- package/dist/sdk/FirmaWalletService.js +22 -22
- package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +1 -1
- package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
- package/dist/sdk/firmachain/bank/BankTxClient.d.ts +3 -4
- package/dist/sdk/firmachain/bank/BankTxClient.js +2 -2
- package/dist/sdk/firmachain/common/ITxClient.d.ts +5 -5
- package/dist/sdk/firmachain/common/ITxClient.js +7 -7
- package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +1 -1
- package/dist/sdk/firmachain/common/TendermintQueryClient.js +5 -4
- package/dist/sdk/firmachain/common/accounts.js +25 -20
- package/dist/sdk/firmachain/common/signingstargateclient.js +3 -3
- package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/contract/ContractQueryClient.js +17 -11
- package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +3 -4
- package/dist/sdk/firmachain/contract/ContractTxClient.js +3 -3
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +2 -1
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +33 -16
- package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +5 -6
- package/dist/sdk/firmachain/distribution/DistributionTxClient.js +3 -3
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +4 -4
- package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +3 -4
- package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +2 -2
- package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +51 -3
- package/dist/sdk/firmachain/gov/GovQueryClient.js +62 -11
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +4 -5
- package/dist/sdk/firmachain/gov/GovTxClient.js +3 -3
- package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/nft/NftQueryClient.js +11 -8
- package/dist/sdk/firmachain/nft/NftTxClient.d.ts +4 -5
- package/dist/sdk/firmachain/nft/NftTxClient.js +3 -3
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +3 -1
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +48 -16
- package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +6 -7
- package/dist/sdk/firmachain/staking/StakingTxClient.js +2 -2
- 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
|
-
|
|
3
|
-
|
|
4
|
-
[
|
|
1
|
+
# firma-js
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40firmachain%2Ffirma-js)
|
|
4
|
+
[](https://github.com/firmachain/firma-js/releases)
|
|
5
|
+
[](https://github.com/firmachain/firma-js/blob/master/LICENSE)
|
|
6
|
+

|
|
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
|
|
1
|
+
import { TxMisc } from "./firmachain/bank";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
|
-
import { BroadcastTxResponse } from
|
|
4
|
+
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
5
5
|
export declare class FirmaBankService {
|
|
6
|
-
private
|
|
7
|
-
constructor(
|
|
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(
|
|
44
|
-
this.
|
|
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.
|
|
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
|
|
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
|
-
|
|
77
|
-
return [4 /*yield*/, wallet.getAddress()];
|
|
76
|
+
return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, amount, txMisc)];
|
|
78
77
|
case 1:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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.
|
|
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
|
|
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,
|
|
101
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
107
|
+
case 3: return [2 /*return*/];
|
|
112
108
|
}
|
|
113
109
|
});
|
|
114
110
|
});
|
|
115
111
|
};
|
|
116
|
-
FirmaBankService.prototype.
|
|
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
|
|
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,
|
|
123
|
-
|
|
124
|
-
return [4 /*yield*/,
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
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
|
|
2
|
-
import { EncodeObject } from
|
|
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
|
|
5
|
+
import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
|
|
6
6
|
export declare class ContractService {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
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(
|
|
44
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
152
|
-
return [4 /*yield*/, contractTxClient.sign(txList, contract_1.getSignAndBroadcastOption(this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
381
|
-
return [4 /*yield*/, contractTxClient.signAndBroadcast(msgList, contract_1.getSignAndBroadcastOption(this.
|
|
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();
|