Skip to content

Commit 4de9a2a

Browse files
author
Fabrice Bascoulergue
committed
Add documentation and generated docs
1 parent 05184f8 commit 4de9a2a

34 files changed

+2108
-7
lines changed

docs/lib/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
# @lum-network/sdk-javascript
2+
3+
## Table of contents
4+
5+
### Namespaces
6+
7+
- [LumConstants](modules/lumconstants.md)
8+
- [LumMessages](modules/lummessages.md)
9+
- [LumTypes](modules/lumtypes.md)
10+
- [LumUtils](modules/lumutils.md)
11+
12+
### Classes
13+
14+
- [LumClient](classes/lumclient.md)
15+
- [LumWallet](classes/lumwallet.md)

docs/lib/classes/lumclient.md

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
# Class: LumClient
2+
3+
## Table of contents
4+
5+
### Constructors
6+
7+
- [constructor](lumclient.md#constructor)
8+
9+
### Properties
10+
11+
- [chainId](lumclient.md#chainid)
12+
- [queryClient](lumclient.md#queryclient)
13+
- [tmClient](lumclient.md#tmclient)
14+
15+
### Methods
16+
17+
- [broadcastTx](lumclient.md#broadcasttx)
18+
- [disconnect](lumclient.md#disconnect)
19+
- [getAccount](lumclient.md#getaccount)
20+
- [getAccountUnverified](lumclient.md#getaccountunverified)
21+
- [getBalance](lumclient.md#getbalance)
22+
- [getBalancesUnverified](lumclient.md#getbalancesunverified)
23+
- [getBlock](lumclient.md#getblock)
24+
- [getBlockHeight](lumclient.md#getblockheight)
25+
- [getChainId](lumclient.md#getchainid)
26+
- [getTx](lumclient.md#gettx)
27+
- [getValidators](lumclient.md#getvalidators)
28+
- [searchTx](lumclient.md#searchtx)
29+
- [signAndBroadcastTx](lumclient.md#signandbroadcasttx)
30+
- [signTx](lumclient.md#signtx)
31+
- [txsQuery](lumclient.md#txsquery)
32+
- [connect](lumclient.md#connect)
33+
34+
## Constructors
35+
36+
### constructor
37+
38+
\+ **new LumClient**(`tmClient`: *Client*): [*LumClient*](lumclient.md)
39+
40+
Create a LumClient instance using a tendermint RPC client
41+
42+
#### Parameters:
43+
44+
Name | Type | Description |
45+
:------ | :------ | :------ |
46+
`tmClient` | *Client* | tendermint RPC client |
47+
48+
**Returns:** [*LumClient*](lumclient.md)
49+
50+
## Properties
51+
52+
### chainId
53+
54+
`Private` `Optional` **chainId**: *undefined* \| *string*
55+
56+
___
57+
58+
### queryClient
59+
60+
`Readonly` **queryClient**: *QueryClient* & AuthExtension & BankExtension
61+
62+
___
63+
64+
### tmClient
65+
66+
`Readonly` **tmClient**: *Client*
67+
68+
## Methods
69+
70+
### broadcastTx
71+
72+
**broadcastTx**(`tx`: *Uint8Array*): *Promise*<BroadcastTxCommitResponse\>
73+
74+
Broadcast a signed transaction
75+
Basic usage would be to use the signTx method prior to calling this method
76+
77+
#### Parameters:
78+
79+
Name | Type | Description |
80+
:------ | :------ | :------ |
81+
`tx` | *Uint8Array* | signed transaction to broadcast |
82+
83+
**Returns:** *Promise*<BroadcastTxCommitResponse\>
84+
85+
___
86+
87+
### disconnect
88+
89+
**disconnect**(): *void*
90+
91+
Disconnect the underlying tendermint client
92+
93+
**Returns:** *void*
94+
95+
___
96+
97+
### getAccount
98+
99+
**getAccount**(`address`: *string*): *Promise*<*null* \| [*Account*](../interfaces/lumtypes.account.md)\>
100+
101+
Get account information
102+
103+
#### Parameters:
104+
105+
Name | Type | Description |
106+
:------ | :------ | :------ |
107+
`address` | *string* | wallet address |
108+
109+
**Returns:** *Promise*<*null* \| [*Account*](../interfaces/lumtypes.account.md)\>
110+
111+
___
112+
113+
### getAccountUnverified
114+
115+
**getAccountUnverified**(`address`: *string*): *Promise*<*null* \| [*Account*](../interfaces/lumtypes.account.md)\>
116+
117+
Get account information without verifying its existence
118+
119+
#### Parameters:
120+
121+
Name | Type | Description |
122+
:------ | :------ | :------ |
123+
`address` | *string* | wallet address |
124+
125+
**Returns:** *Promise*<*null* \| [*Account*](../interfaces/lumtypes.account.md)\>
126+
127+
___
128+
129+
### getBalance
130+
131+
**getBalance**(`address`: *string*, `searchDenom`: *string*): *Promise*<*null* \| [*Coin*](../interfaces/lumtypes.coin.md)\>
132+
133+
Get account balance
134+
135+
#### Parameters:
136+
137+
Name | Type | Description |
138+
:------ | :------ | :------ |
139+
`address` | *string* | wallet address |
140+
`searchDenom` | *string* | Coin denomination (ex: lum) |
141+
142+
**Returns:** *Promise*<*null* \| [*Coin*](../interfaces/lumtypes.coin.md)\>
143+
144+
___
145+
146+
### getBalancesUnverified
147+
148+
**getBalancesUnverified**(`address`: *string*): *Promise*<[*Coin*](../interfaces/lumtypes.coin.md)[]\>
149+
150+
Get all account balances without verifying their existence
151+
152+
#### Parameters:
153+
154+
Name | Type | Description |
155+
:------ | :------ | :------ |
156+
`address` | *string* | wallet address |
157+
158+
**Returns:** *Promise*<[*Coin*](../interfaces/lumtypes.coin.md)[]\>
159+
160+
___
161+
162+
### getBlock
163+
164+
**getBlock**(`height?`: *number*): *Promise*<BlockResponse\>
165+
166+
Get a block by height
167+
168+
#### Parameters:
169+
170+
Name | Type | Description |
171+
:------ | :------ | :------ |
172+
`height?` | *number* | block height to get (default to current height) |
173+
174+
**Returns:** *Promise*<BlockResponse\>
175+
176+
___
177+
178+
### getBlockHeight
179+
180+
**getBlockHeight**(): *Promise*<number\>
181+
182+
Get the current block height
183+
184+
**Returns:** *Promise*<number\>
185+
186+
___
187+
188+
### getChainId
189+
190+
**getChainId**(): *Promise*<string\>
191+
192+
Get the chain id
193+
194+
**Returns:** *Promise*<string\>
195+
196+
___
197+
198+
### getTx
199+
200+
**getTx**(`hash`: *Uint8Array*, `includeProof?`: *boolean*): *Promise*<*null* \| TxResponse\>
201+
202+
Get a transaction by Hash
203+
204+
#### Parameters:
205+
206+
Name | Type | Description |
207+
:------ | :------ | :------ |
208+
`hash` | *Uint8Array* | transaction hash to retrieve |
209+
`includeProof?` | *boolean* | whether or not to include proof of the transaction inclusion in the block |
210+
211+
**Returns:** *Promise*<*null* \| TxResponse\>
212+
213+
___
214+
215+
### getValidators
216+
217+
**getValidators**(`blockHeight?`: *number*): *Promise*<ValidatorsResponse\>
218+
219+
Get all validators
220+
Validators are sorted first by voting power (descending), then by address (ascending)
221+
222+
#### Parameters:
223+
224+
Name | Type | Description |
225+
:------ | :------ | :------ |
226+
`blockHeight?` | *number* | block height to return. If no height is provided, it will fetch validator set which corresponds to the latest block |
227+
228+
**Returns:** *Promise*<ValidatorsResponse\>
229+
230+
___
231+
232+
### searchTx
233+
234+
**searchTx**(`queries`: *string*[], `page?`: *number*, `perPage?`: *number*, `includeProof?`: *boolean*): *Promise*<TxResponse[]\>
235+
236+
Search for transactions (paginated)
237+
All queries will be run and results will be deduplicated, merged and sorted by block height
238+
239+
Queries:
240+
To tell which events you want, you need to provide a query. query is a string, which has a form: "condition AND condition ..." (no OR at the moment). condition has a form: "key operation operand". key is a string with a restricted set of possible symbols ( \t\n\r\()"'=>< are not allowed). operation can be "=", "<", "<=", ">", ">=", "CONTAINS" AND "EXISTS". operand can be a string (escaped with single quotes), number, date or time.
241+
Examples: tm.event = 'NewBlock' # new blocks tm.event = 'CompleteProposal' # node got a complete proposal tm.event = 'Tx' AND tx.hash = 'XYZ' # single transaction tm.event = 'Tx' AND tx.height = 5 # all txs of the fifth block tx.height = 5 # all txs of the fifth block
242+
Tendermint provides a few predefined keys: tm.event, tx.hash and tx.height. Note for transactions, you can define additional keys by providing events with DeliverTx response.
243+
244+
#### Parameters:
245+
246+
Name | Type | Default value | Description |
247+
:------ | :------ | :------ | :------ |
248+
`queries` | *string*[] | - | queries to run (see utils/search for helpers) |
249+
`page` | *number* | 1 | page to query (default to 1) |
250+
`perPage` | *number* | 30 | result per pages (default to 30) |
251+
`includeProof?` | *boolean* | - | whether or not to include proofs of the transactions inclusion in the block |
252+
253+
**Returns:** *Promise*<TxResponse[]\>
254+
255+
___
256+
257+
### signAndBroadcastTx
258+
259+
**signAndBroadcastTx**(`wallet`: [*LumWallet*](lumwallet.md), `messages`: [*Message*](../interfaces/lummessages.message.md)[], `fee`: [*Fee*](../interfaces/lumtypes.fee.md), `memo?`: *string*): *Promise*<BroadcastTxCommitResponse\>
260+
261+
Signs and broadcast the transaction using the specified wallet and messages
262+
263+
#### Parameters:
264+
265+
Name | Type | Description |
266+
:------ | :------ | :------ |
267+
`wallet` | [*LumWallet*](lumwallet.md) | signing wallet |
268+
`messages` | [*Message*](../interfaces/lummessages.message.md)[] | messages to sign |
269+
`fee` | [*Fee*](../interfaces/lumtypes.fee.md) | requested fee |
270+
`memo?` | *string* | optional memo for the transaction |
271+
272+
**Returns:** *Promise*<BroadcastTxCommitResponse\>
273+
274+
___
275+
276+
### signTx
277+
278+
**signTx**(`wallet`: [*LumWallet*](lumwallet.md), `messages`: [*Message*](../interfaces/lummessages.message.md)[], `fee`: [*Fee*](../interfaces/lumtypes.fee.md), `memo?`: *string*): *Promise*<Uint8Array\>
279+
280+
Signs the messages using the provided wallet and builds the transaction
281+
282+
#### Parameters:
283+
284+
Name | Type | Description |
285+
:------ | :------ | :------ |
286+
`wallet` | [*LumWallet*](lumwallet.md) | signing wallet |
287+
`messages` | [*Message*](../interfaces/lummessages.message.md)[] | messages to sign |
288+
`fee` | [*Fee*](../interfaces/lumtypes.fee.md) | requested fee |
289+
`memo?` | *string* | optional memo for the transaction |
290+
291+
**Returns:** *Promise*<Uint8Array\>
292+
293+
___
294+
295+
### txsQuery
296+
297+
`Private`**txsQuery**(`params`: TxSearchParams): *Promise*<TxResponse[]\>
298+
299+
Run a tx search
300+
301+
#### Parameters:
302+
303+
Name | Type | Description |
304+
:------ | :------ | :------ |
305+
`params` | TxSearchParams | Search params |
306+
307+
**Returns:** *Promise*<TxResponse[]\>
308+
309+
___
310+
311+
### connect
312+
313+
`Static`**connect**(`endpoint`: *string*): *Promise*<[*LumClient*](lumclient.md)\>
314+
315+
Creates a new LumClient for the given endpoint
316+
Uses HTTP when the URL schema is http or https, uses WebSockets otherwise
317+
318+
#### Parameters:
319+
320+
Name | Type | Description |
321+
:------ | :------ | :------ |
322+
`endpoint` | *string* | Blockchain node RPC url |
323+
324+
**Returns:** *Promise*<[*LumClient*](lumclient.md)\>

0 commit comments

Comments
 (0)