1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const JsonRpcProvider_1 = require("./JsonRpcProvider");
|
4 | const Constant_1 = require("../Constant");
|
5 |
|
6 | class ChainRpcProvider extends JsonRpcProvider_1.JsonRpcProvider {
|
7 | constructor(config) {
|
8 | super(config);
|
9 | this.config = config;
|
10 | }
|
11 | GetBlockChainInfo() {
|
12 | return this.send('GetBlockChainInfo');
|
13 | }
|
14 | getBlockHash(blockHeight) {
|
15 | return this.send('getBlockHash', { blockHeight: blockHeight });
|
16 | }
|
17 | upTime() {
|
18 | return this.send('upTime');
|
19 | }
|
20 | getBestBlock() {
|
21 | return this.send('getBestBlock');
|
22 | }
|
23 | getBlock(params) {
|
24 | return this.send('getBlock', params);
|
25 | }
|
26 | getBlockHeader(params) {
|
27 | return this.send('getBlockHeader', params);
|
28 | }
|
29 | getBalance(address) {
|
30 | return this.send('getBalance', { address: address });
|
31 | }
|
32 | getBalances(addresses) {
|
33 | return this.send('getBalances', { addresses: addresses });
|
34 | }
|
35 | getBlockList(params) {
|
36 | return this.send('getBlockList', params);
|
37 | }
|
38 | getBlockListByHeight(params) {
|
39 | return this.send('getBlockListByHeight', params);
|
40 | }
|
41 | getUtxoByAddress(params) {
|
42 | return new Promise((resolve, reject) => {
|
43 | this.send('getUtxoByAddress', params).then(res => {
|
44 | resolve(res);
|
45 | }).catch(e => {
|
46 | reject(e);
|
47 | });
|
48 | });
|
49 | }
|
50 | getUtxoInPage(params) {
|
51 | return new Promise((resolve, reject) => {
|
52 | this.send('getUtxoInPage', params).then(res => {
|
53 | resolve(res);
|
54 | }).catch(e => {
|
55 | reject(e);
|
56 | });
|
57 | });
|
58 | }
|
59 | getGenesisContractNames() {
|
60 | return this.send('getGenesisContractNames');
|
61 | }
|
62 | getConnectionCount() {
|
63 | return this.send('getConnectionCount');
|
64 | }
|
65 | getInfo() {
|
66 | return this.send('getInfo');
|
67 | }
|
68 | getNetTotals() {
|
69 | return this.send('getNetTotals');
|
70 | }
|
71 | createRawTransaction(params) {
|
72 | return this.send('createRawTransaction', params);
|
73 | }
|
74 | decodeRawTransaction(txHex) {
|
75 | return this.send('decodeRawTransaction', {
|
76 | txHex: txHex
|
77 | });
|
78 | }
|
79 | calculateContractAddress(params) {
|
80 | return this.send('calculateContractAddress', params);
|
81 | }
|
82 | decodeScript(hexScript) {
|
83 | return this.send('decodeScript', {
|
84 | hexScript: hexScript
|
85 | });
|
86 | }
|
87 | getGenesisContract(contractAddress) {
|
88 | return this.send('getGenesisContract', {
|
89 | contractAddress: contractAddress
|
90 | });
|
91 | }
|
92 | getContractAddressesByAssets(assets) {
|
93 | return this.send('getContractAddressesByAssets', {
|
94 | assets: assets
|
95 | });
|
96 | }
|
97 | getContractTemplateList(params) {
|
98 | return this.send('getContractTemplateList', {
|
99 | approved: true,
|
100 | category: params.category,
|
101 | page: params.page,
|
102 | pageSize: params.pageSize
|
103 | });
|
104 | }
|
105 | getContractTemplateName(contractAddress) {
|
106 | return this.send('getContractTemplateName', {
|
107 | contractAddress: contractAddress
|
108 | });
|
109 | }
|
110 | getContractTemplate(contractAddress) {
|
111 | return this.send('getContractTemplate', {
|
112 | contractAddress: contractAddress
|
113 | });
|
114 | }
|
115 | getMPosCfg() {
|
116 | return this.send('getMPosCfg');
|
117 | }
|
118 | callReadOnlyFunction(params) {
|
119 | return this.send('callReadOnlyFunction', params);
|
120 | }
|
121 | getRawTransaction(params) {
|
122 | return this.send('getRawTransaction', params);
|
123 | }
|
124 | getVirtualTransactions(params) {
|
125 | return this.send('getVirtualTransactions', params);
|
126 | }
|
127 | getTransactionReceipt(txId) {
|
128 | return this.send('getTransactionReceipt', {
|
129 | txId: txId
|
130 | });
|
131 | }
|
132 | sendRawTransaction(rawTx) {
|
133 | return this.send('sendRawTransaction', {
|
134 | rawTx: rawTx
|
135 | });
|
136 | }
|
137 | searchRawTransactions(params) {
|
138 | return this.send('searchRawTransactions', params);
|
139 | }
|
140 | searchAllRawTransactions(params) {
|
141 | return this.send('searchAllRawTransactions', params);
|
142 | }
|
143 | getTransactionsByAddresses(params) {
|
144 | return this.send('getTransactionsByAddresses', params);
|
145 | }
|
146 | getMempoolTransactions(txIds = []) {
|
147 | return this.send('getMempoolTransactions', {
|
148 | txIds: txIds
|
149 | });
|
150 | }
|
151 | notifyNewTransactions() {
|
152 | return this.send('notifyNewTransactions');
|
153 | }
|
154 | test(params) {
|
155 | return this.send('test', params);
|
156 | }
|
157 | getContractTemplateInfoByName(params) {
|
158 | return this.send('getContractTemplateInfoByName', params);
|
159 | }
|
160 | getContractTemplateInfoByKey(params) {
|
161 | return this.send('getContractTemplateInfoByKey', params);
|
162 | }
|
163 | estimateGas(params) {
|
164 | return new Promise((resolve, reject) => {
|
165 | this.send('estimateGas', params).then(res => {
|
166 | if (res <= Constant_1.MinGasLimit) {
|
167 | resolve(Constant_1.MinGasLimit);
|
168 | }
|
169 | else {
|
170 | resolve(res);
|
171 | }
|
172 | }).catch(e => {
|
173 | reject(e);
|
174 | });
|
175 | });
|
176 | }
|
177 | runTransaction(params) {
|
178 | return this.send('runTransaction', params);
|
179 | }
|
180 | }
|
181 | exports.ChainRpcProvider = ChainRpcProvider;
|
182 |
|
\ | No newline at end of file |