Skip to content

Commit 87d6cfc

Browse files
authored
Merge pull request #304 from trustlines-protocol/feature/md-typedoc
Feature/md typedoc
2 parents be6fa17 + 9fb238f commit 87d6cfc

File tree

12 files changed

+238
-137
lines changed

12 files changed

+238
-137
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ doc.json
88
*~
99
package-lock.json
1010
addresses.json
11+
docs/api
1112

1213
# code coverage
1314
.nyc_output

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ yarn test:e2e
109109
You have to have all components of the trustlines protocol running.
110110
A convenient way to achieve this is by using our [end2end](https://github.com/trustlines-protocol/end2end) setup.
111111

112+
## Documentation
113+
114+
You can find the documentation for the trustlines-clientlib [here](https://dev.trustlines.network/docs/clientlib/clientlib.html).
115+
The underlying markdown files of the documentation can be found in this repository under the `./docs` directory.
116+
To generate the [typedoc](https://typedoc.org/) API reference documentation for this library run `yarn doc`.
117+
112118
## Running injected web3 example
113119

114120
To run the example make sure to have [MetaMask](https://metamask.io/) installed and connected to a JSON RPC.

docs/api-reference-index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# API Reference
2+
3+
## Table of Content
4+
5+
- [`TLNetwork`](./api/classes/_tlnetwork_.tlnetwork.md)
6+
- [`CurrencyNetwork`](./api/classes/_currencynetwork_.currencynetwork.md)
7+
- [`User`](./api/classes/_user_.user.md)
8+
- [`Trustline`](./api/classes/_trustline_.trustline.md)
9+
- [`Payment`](./api/classes/_payment_.payment.md)
10+
- [`Events`](./api/classes/_events_.events.md)
11+
- [`Utils`](<(./api/modules/_utils_.md)>>)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"ts-node": "^7.0.0",
8181
"tslint": "^5.17.0",
8282
"tslint-config-prettier": "^1.18.0",
83-
"typedoc": "^0.14.2",
83+
"typedoc": "^0.16.9",
8484
"types-ethereumjs-util": "0.0.8",
8585
"typescript": "^2.9.2",
8686
"webpack": "^4.16.0",
@@ -94,6 +94,7 @@
9494
"rxjs": "^5.4.1",
9595
"simple-jsonrpc-js": "0.0.10",
9696
"trustlines-contracts-abi": "dev",
97+
"typedoc-plugin-markdown": "^2.2.16",
9798
"ws": "^6.2.1"
9899
}
99100
}

src/CurrencyNetwork.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@ import {
1515
} from './typings'
1616

1717
/**
18-
* The CurrencyNetwork class contains all functions relevant for retrieving
19-
* currency network related information.
18+
* The [[CurrencyNetwork]] class contains all functions relevant for retrieving currency network related information.
19+
* It is meant to be called via a [[TLNetwork]] instance like:
20+
* ```typescript
21+
* const tlNetwork = new TLNetwork(...)
22+
*
23+
* // Get all networks
24+
* tlNetwork.currencyNetwork.getAll().then(
25+
* networks => console.log("All networks:", networks)
26+
* )
27+
* ```
2028
*/
2129
export class CurrencyNetwork {
2230
/**
31+
* @hidden
2332
* Returns general and interest rate decimals for given currency network.
2433
* @param networkAddress Currency network to get decimals for.
2534
* @param decimalsOptions Optional provided decimals if known.
@@ -31,6 +40,7 @@ export class CurrencyNetwork {
3140

3241
private provider: TLProvider
3342

43+
/** @hidden */
3444
constructor(provider: TLProvider) {
3545
this.provider = provider
3646
this.getDecimals = this._getDecimalsCached()
@@ -118,6 +128,7 @@ export class CurrencyNetwork {
118128
}
119129

120130
/**
131+
* @hidden
121132
* Returns a mapping from network address to respective decimals.
122133
* @param networkAddresses List of currency networks.
123134
*/
@@ -138,6 +149,7 @@ export class CurrencyNetwork {
138149
}
139150

140151
/**
152+
* @hidden
141153
* Returns true or false whether given address is a registered currency network.
142154
* @param contractAddress Address which should be checked.
143155
*/

src/Event.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,26 @@ const TOKEN = 'Token'
2323

2424
/**
2525
* The Event class contains all methods related to retrieving event logs.
26+
* It is meant to be called via a [[TLNetwork]] instance like:
27+
* ```typescript
28+
* const tlNetwork = new TLNetwork(
29+
* //...
30+
* )
31+
*
32+
* // Get transfer logs
33+
* tlNetwork.event.get(
34+
* // ...
35+
* ).then(
36+
* events => console.log("Events of loaded user:", events)
37+
* )
38+
* ```
2639
*/
2740
export class Event {
2841
private currencyNetwork: CurrencyNetwork
2942
private provider: TLProvider
3043
private user: User
3144

45+
/** @hidden */
3246
constructor(params: {
3347
currencyNetwork: CurrencyNetwork
3448
provider: TLProvider
@@ -43,7 +57,7 @@ export class Event {
4357
* @hidden
4458
* Returns event logs of loaded user in a specified currency network.
4559
* @param networkAddress Address of a currency network.
46-
* @param filter Event filter object. See `EventFilterOptions` for more information.
60+
* @param filter Event filter object. See [[EventFilterOptions]] for more information.
4761
* @param filter.type Available event types are `Transfer`, `TrustlineUpdateRequest` and `TrustlineUpdate`.
4862
* @param filter.fromBlock Start of block range for event logs.
4963
*/
@@ -73,7 +87,7 @@ export class Event {
7387

7488
/**
7589
* Returns event logs of loaded user in all currency networks.
76-
* @param filter Event filter object. See `EventFilterOptions` for more information.
90+
* @param filter Event filter object. See [[EventFilterOptions]] for more information.
7791
* @param filter.type Available event types are:
7892
* CurrencyNetwork -> `Transfer`, `TrustlineUpdateRequest` and `TrustlineUpdate`
7993
* EthWrapper -> `Transfer`, `Deposit` and `Withdrawal`
@@ -121,6 +135,7 @@ export class Event {
121135
}
122136

123137
/**
138+
* @hidden
124139
* Fetches decimals for given event logs and formats them so that all numerical
125140
* values are `Amount` objects.
126141
* @param rawEvents trustlines network events
@@ -162,6 +177,7 @@ export class Event {
162177
}
163178

164179
/**
180+
* @hidden
165181
* Returns a mapping from address to decimals
166182
* @param addressesMap mapping from address to whether given address is a CurrencyNetwork
167183
* or Token contract.

src/Payment.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,20 @@ import {
2222
} from './typings'
2323

2424
/**
25-
* The Payment class contains all payment related functions. This includes
26-
* trustline transfers and normal ETH transfers.
25+
* The Payment class contains all payment related functions. This includes trustline transfers and TLC transfers.
26+
* It is meant to be called via a [[TLNetwork]] instance like:
27+
* ```typescript
28+
* const tlNetwork = new TLNetwork(
29+
* //...
30+
* )
31+
*
32+
* // Get transfer logs
33+
* tlNetwork.payment.get(
34+
* // ...
35+
* ).then(
36+
* payments => console.log("Payments of loaded user:", payments)
37+
* )
38+
* ```
2739
*/
2840
export class Payment {
2941
private currencyNetwork: CurrencyNetwork
@@ -32,6 +44,7 @@ export class Payment {
3244
private transaction: Transaction
3345
private user: User
3446

47+
/** @hidden */
3548
constructor(params: {
3649
event: Event
3750
user: User
@@ -52,7 +65,7 @@ export class Payment {
5265
* @param receiverAddress Address of receiver of transfer.
5366
* @param value Amount to transfer in biggest unit,
5467
* i.e. 1.5 if currency network has 2 decimals.
55-
* @param options Optional payment options. See `PaymentOptions` for more information.
68+
* @param options Optional payment options. See [[PaymentOptions]] for more information.
5669
* @param options.networkDecimals Decimals of currency network can be provided manually.
5770
* @param options.maximumHops Max. number of hops for transfer.
5871
* @param options.maximumFees Max. transfer fees user is willing to pay.
@@ -122,7 +135,7 @@ export class Payment {
122135
* Prepares a ethereum transaction object for a ETH transfer, where loaded user is the sender.
123136
* @param receiverAddress Address of receiver of transfer.
124137
* @param value Amount of ETH to transfer.
125-
* @param options Payment options. See `PaymentOptions` for more information.
138+
* @param options Payment options. See [[PaymentOptions]] for more information.
126139
* @param options.gasPrice Custom gas price.
127140
* @param options.gasLimit Custom gas limit.
128141
*/
@@ -159,7 +172,7 @@ export class Payment {
159172
* @param receiverAddress Address of receiver of transfer.
160173
* @param value Amount to transfer in biggest unit,
161174
* i.e. 1.23 if currency network has 2 decimals.
162-
* @param options Payment options. See `PaymentOptions` for more information.
175+
* @param options Payment options. See [[PaymentOptions]] for more information.
163176
* @param options.feePayer Either `sender` or `receiver`. Specifies who pays network fees.
164177
* @param options.networkDecimals Decimals of currency network can be provided manually.
165178
* @param options.maximumHops Max. number of hops for transfer.
@@ -211,7 +224,7 @@ export class Payment {
211224
/**
212225
* Returns transfer event logs of loaded user in a specified currency network.
213226
* @param networkAddress Address of currency network.
214-
* @param filter Event filter object. See `EventFilterOptions` for more information.
227+
* @param filter Event filter object. See [[EventFilterOptions]] for more information.
215228
*/
216229
public get(
217230
networkAddress: string,

src/TLNetwork.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,17 @@ import { TLNetworkConfig } from './typings'
3030
import { IdentityWallet } from './wallets/IdentityWallet'
3131

3232
/**
33-
* The TLNetwork class is the single entry-point into the trustline-network.js library.
34-
* It contains all of the library's functionality and all calls to the library should be made through a TLNetwork instance.
33+
* The TLNetwork class is the single entry-point into the trustlines-clientlib.
34+
* It contains all of the library's functionality and all calls to the library should be made through a `TLNetwork` instance.
3535
*/
3636
export class TLNetwork {
3737
/**
3838
* User instance containing all user/keystore related methods.
3939
*/
4040
public user: User
41-
/**
42-
* @hidden
43-
* Transaction instance containing all transaction related methods.
44-
*/
45-
public transaction: Transaction
4641
/**
4742
* Payment instance containing all methods for creating trustline transfers
48-
* and ETH transfers.
43+
* and TLC transfers.
4944
*/
5045
public payment: Payment
5146
/**
@@ -57,23 +52,30 @@ export class TLNetwork {
5752
* related information.
5853
*/
5954
public currencyNetwork: CurrencyNetwork
55+
/**
56+
* Event instance for retrieving and formatting event logs.
57+
*/
58+
public event: Event
6059
/**
6160
* @hidden
61+
* Transaction instance containing all transaction related methods.
6262
*/
63-
public contact: Contact
63+
public transaction: Transaction
6464
/**
65-
* Event instance for retrieving and formatting event logs.
65+
* @hidden
6666
*/
67-
public event: Event
67+
public contact: Contact
6868
/**
6969
* Exchange instance containing all methods for making and taking orders.
70+
* @hidden
7071
*/
7172
public exchange: Exchange
7273
/**
7374
* @hidden
7475
*/
7576
public messaging: Messaging
7677
/**
78+
* @hidden
7779
* EthWrapper instance for wrapping and unwrapping ETH.
7880
*/
7981
public ethWrapper: EthWrapper
@@ -95,8 +97,8 @@ export class TLNetwork {
9597
public provider: TLProvider
9698

9799
/**
98-
* Initiates a new TLNetwork instance that provides the public interface to trustlines-network library.
99-
* @param config Configuration object. See type `tlNetworkConfig` for more information.
100+
* Initiates a new TLNetwork instance that provides the public interface to trustlines-clientlib.
101+
* @param config Configuration object. See [[TLNetworkConfig]] for more information.
100102
*/
101103
constructor(config: TLNetworkConfig = {}) {
102104
const {
@@ -181,13 +183,19 @@ export class TLNetwork {
181183
})
182184
}
183185

186+
/**
187+
* @hidden
188+
*/
184189
public setProvider(provider: TLProvider): void {
185190
if (!(provider instanceof RelayProvider)) {
186191
throw new Error('Provider not supported.')
187192
}
188193
this.provider = provider
189194
}
190195

196+
/**
197+
* @hidden
198+
*/
191199
public setSigner(web3Provider, wallet: TLWallet): void {
192200
const signer: TLSigner = web3Provider
193201
? new Web3Signer(new ethers.providers.Web3Provider(web3Provider))
@@ -205,6 +213,9 @@ export class TLNetwork {
205213
this.signer = signer
206214
}
207215

216+
/**
217+
* @hidden
218+
*/
208219
public setWallet(
209220
walletType: string,
210221
provider: TLProvider,

0 commit comments

Comments
 (0)