Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit ddb9bc3

Browse files
author
Noel
authored
Format json, markdown files (#372)
* chore: config prettier for json * style: format json files * chore: prettier for markdown * style: format markdown
1 parent 89d58d5 commit ddb9bc3

File tree

20 files changed

+97
-106
lines changed

20 files changed

+97
-106
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
54
---
65

76
**Describe the bug**
7+
88
<!-- A clear and concise description of what the bug is. -->
99

1010
**To Reproduce**
11+
1112
<!-- Steps to reproduce the behavior:
1213
1. Go to '...'
1314
2. Click on '....'
1415
3. Scroll down to '....'
1516
4. See error -->
1617

1718
**Expected behavior**
19+
1820
<!-- A clear and concise description of what you expected to happen. -->
1921

2022
**Screenshots**
23+
2124
<!-- If applicable, add screenshots to help explain your problem. -->
2225

2326
**Desktop (please complete the following information):**
27+
2428
<!-- - OS: [e.g. iOS]
2529
- Browser [e.g. chrome, safari]
2630
- Version [e.g. 22] -->
2731

2832
**Smartphone (please complete the following information):**
33+
2934
<!-- - Device: [e.g. iPhone6]
3035
- OS: [e.g. iOS8.1]
3136
- Browser [e.g. stock browser, safari]
3237
- Version [e.g. 22] -->
3338

3439
**Additional context**
40+
3541
<!-- Add any other context about the problem here. -->
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
54
---
65

76
**Is your feature request related to a problem? Please describe.**
7+
88
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
99

1010
**Describe the solution you'd like**
11+
1112
<!-- A clear and concise description of what you want to happen. -->
1213

1314
**Describe alternatives you've considered**
15+
1416
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
1517

1618
**Additional context**
19+
1720
<!-- Add any other context or screenshots about the feature request here. -->

.prettierignore

-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@
33
#################################
44
.tmp/
55
node_modules/
6-
package.json
7-
.travis.yml
8-
*.md
9-
*.html
106
dist
117
coverage

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"options": {
1111
"parser": "json"
1212
}
13+
},
14+
{
15+
"files": "*.md",
16+
"options": { "parser": "markdown" }
1317
}
1418
]
1519
}

README.md

+41-43
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Zilliqa-JavaScript-Library API
2+
23
[![Build Status](https://travis-ci.com/Zilliqa/Zilliqa-JavaScript-Library.svg?branch=dev)](https://travis-ci.com/Zilliqa/Zilliqa-JavaScript-Library)
34
[![codecov](https://codecov.io/gh/Zilliqa/Zilliqa-JavaScript-Library/branch/feature/monorepo/graph/badge.svg)](https://codecov.io/gh/Zilliqa/Zilliqa)
45
[![Discord Chat](https://img.shields.io/discord/308323056592486420.svg)](https://discord.gg/XMRE9tt)
@@ -18,21 +19,20 @@ other modules to function.
1819
The following table provides a description of each module and what you may
1920
want to use it for.
2021

21-
| package | description | dependencies |
22-
| --- | --- | --- |
23-
| [`@zilliqa-js/core`](./packages/zilliqa-js-core) | Core abstractions and base classes, such as `HTTPProvider` and network logic for interfacing with the Zilliqa JSON-RPC. | none |
24-
| [`@zilliqa-js/account`](./packages/zilliqa-js-account) | `Wallet`, `Account` and `Transaction` abstractions live in this package. | `@zilliqa-js/core`, `@zilliqa-js/crypto`, `@zilliqa-js/util`, `@zilliqa-js/proto` |
25-
| [`@zilliqa-js/blockchain`](./packages/zilliqa-js-blockchain) | Main interface to the Zilliqa `JSON-RPC`. | none |
26-
| [`@zilliqa-js/contract`](./packages/zilliqa-js-contract) | Exposes a `Contracts` module that takes care of smart contract deployment and interaction. | `@zilliqa-js/account`, `@zilliqa-js/blockchain`, `@zilliqa-js/core`, `@zilliqa-js/util` |
27-
| [`@zilliqa-js/crypto`](./packages/zilliqa-js-crypto) | Exposes several loosely-coupled cryptographic convenience functions for working with the Zilliqa blockchain and its cryptographic primitives, such as Schnorr signatures. | `@zilliqa-js/util` |
28-
| [`@zilliqa-js/proto`](./packages/zilliqa-js-proto) | Protobuf source files and corresponding generated JS modules. | none |
29-
| [`@zilliqa-js/util`](./packages/zilliqa-js-util) | Miscellaneous functions that take care of serialisation/deserialisation and validation. | none |
30-
| [`@zilliqa-js/viewblock`](https://github.com/Ashlar/zilliqa-js-viewblock) | Library interfacing with ViewBlock's APIs | `@zilliqa-js/crypto` |
31-
22+
| package | description | dependencies |
23+
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
24+
| [`@zilliqa-js/core`](./packages/zilliqa-js-core) | Core abstractions and base classes, such as `HTTPProvider` and network logic for interfacing with the Zilliqa JSON-RPC. | none |
25+
| [`@zilliqa-js/account`](./packages/zilliqa-js-account) | `Wallet`, `Account` and `Transaction` abstractions live in this package. | `@zilliqa-js/core`, `@zilliqa-js/crypto`, `@zilliqa-js/util`, `@zilliqa-js/proto` |
26+
| [`@zilliqa-js/blockchain`](./packages/zilliqa-js-blockchain) | Main interface to the Zilliqa `JSON-RPC`. | none |
27+
| [`@zilliqa-js/contract`](./packages/zilliqa-js-contract) | Exposes a `Contracts` module that takes care of smart contract deployment and interaction. | `@zilliqa-js/account`, `@zilliqa-js/blockchain`, `@zilliqa-js/core`, `@zilliqa-js/util` |
28+
| [`@zilliqa-js/crypto`](./packages/zilliqa-js-crypto) | Exposes several loosely-coupled cryptographic convenience functions for working with the Zilliqa blockchain and its cryptographic primitives, such as Schnorr signatures. | `@zilliqa-js/util` |
29+
| [`@zilliqa-js/proto`](./packages/zilliqa-js-proto) | Protobuf source files and corresponding generated JS modules. | none |
30+
| [`@zilliqa-js/util`](./packages/zilliqa-js-util) | Miscellaneous functions that take care of serialisation/deserialisation and validation. | none |
31+
| [`@zilliqa-js/viewblock`](https://github.com/Ashlar/zilliqa-js-viewblock) | Library interfacing with ViewBlock's APIs | `@zilliqa-js/crypto` |
3232

3333
## Pre-Requisite (Windows Users)
3434

35-
`zilliqa-js` uses [`scrypt`](https://www.npmjs.com/package/scrypt) library which depends on `node-gyp` in order to compile the binaries from source on Windows.
35+
`zilliqa-js` uses [`scrypt`](https://www.npmjs.com/package/scrypt) library which depends on `node-gyp` in order to compile the binaries from source on Windows.
3636
`node-gyp` on Windows requires users to install additional Visual Studio Build tools.
3737

3838
To install the required Visual Studio Build tools:
@@ -45,7 +45,6 @@ npm config set msvs_version 2015 # 2015 is more compatible; though 2017 may work
4545

4646
Refer to https://github.com/nodejs/node-gyp#installation for more information about `node-gyp` installation on Windows.
4747

48-
4948
## Installation
5049

5150
It is recommended that developers install the JavaScript client by making use
@@ -62,17 +61,15 @@ yarn add bn.js
6261

6362
## Quick Start
6463

65-
>**Ideally, you should [Create a new Nucleus Wallet](https://dev-wallet.zilliqa.com/generate) (an [open source](https://github.com/Zilliqa/nucleus-wallet) Zilliqa testnet wallet)**.
64+
> **Ideally, you should [Create a new Nucleus Wallet](https://dev-wallet.zilliqa.com/generate) (an [open source](https://github.com/Zilliqa/nucleus-wallet) Zilliqa testnet wallet)**.
6665
>
67-
>You should 'fund' the wallet by sending testnet ZIL tokens from the [ZIL faucet](https://dev-wallet.zilliqa.com/faucet)
66+
> You should 'fund' the wallet by sending testnet ZIL tokens from the [ZIL faucet](https://dev-wallet.zilliqa.com/faucet)
6867
>
69-
>You should then replace the value of `const privateKey` with the one from this wallet.
68+
> You should then replace the value of `const privateKey` with the one from this wallet.
7069
>
71-
>The code should work with the existing private key but this cannot be guaranteed.
72-
70+
> The code should work with the existing private key but this cannot be guaranteed.
7371
7472
```javascript
75-
7673
const { BN, Long, bytes, units } = require('@zilliqa-js/util');
7774
const { Zilliqa } = require('@zilliqa-js/zilliqa');
7875
const {
@@ -268,15 +265,15 @@ async function testBlockchain() {
268265
}
269266

270267
testBlockchain();
271-
272268
```
269+
273270
### Notes on the Quick Start script
274271

275272
#### Note 1: Account balance
276273

277-
The account balance is an object with two fields, `balance` and `nonce`.
274+
The account balance is an object with two fields, `balance` and `nonce`.
278275

279-
`balance` is the account balance in Qa, which is the lowest denomination in Zilliqa.
276+
`balance` is the account balance in Qa, which is the lowest denomination in Zilliqa.
280277
For more information about gas accounting, please refer to here: https://forum.zilliqa.com/t/gas-accounting-in-zilliqa/199
281278

282279
`nonce` is a counter that keeps track of how many transactions are sent from a given address. In Zilliqa, every transaction sent from an address must have a unique nonce.
@@ -288,33 +285,34 @@ For more information about gas accounting, please refer to here: https://forum.z
288285
#### Note 2: Retrieving transaction receipt
289286

290287
An example of a transaction receipt is this:
288+
291289
```json
292290
{
293-
"cumulative_gas": 357,
294-
"epoch_num": "676201",
295-
"event_logs": [
291+
"cumulative_gas": 357,
292+
"epoch_num": "676201",
293+
"event_logs": [
294+
{
295+
"_eventname": "setHello()",
296+
"address": "0x7a4aa130650396ab7c4006c471576a8404f5092b",
297+
"params": [
296298
{
297-
"_eventname": "setHello()",
298-
"address": "0x7a4aa130650396ab7c4006c471576a8404f5092b",
299-
"params": [
300-
{
301-
"type": "Int32",
302-
"value": "2",
303-
"vname": "code"
304-
}
305-
]
299+
"type": "Int32",
300+
"value": "2",
301+
"vname": "code"
306302
}
307-
],
308-
"success": true
303+
]
304+
}
305+
],
306+
"success": true
309307
}
310308
```
311309

312310
`event_logs` comprises of all the events emitted in the transaction. For example, if your transaction calls a transition which emits 3 events, it will be an array of three events. The `address` is the contract address of the contract which emits the event.
313311

314312
`success` indicates if the transaction is successful.
315313

316-
317314
## Examples
315+
318316
For more examples, visit this [repository](https://github.com/Zilliqa/Zilliqa-JavaScript-Library-Examples).
319317

320318
## API Documentation
@@ -352,6 +350,7 @@ yarn bootstrap
352350
# watch TS source files and recompile on change
353351
yarn build:ts -w
354352
```
353+
355354
### Tests
356355

357356
Tests for each package reside in `packages/src/*/tests`, and are run using
@@ -367,20 +366,19 @@ Once it has been installed and executed, you can run `yarn release:local` to sim
367366

368367
#### rollup
369368

370-
`zilliqa-js` is bundled using `rollup`. To build the distributable bundles, simple run `yarn bundle`.
369+
`zilliqa-js` is bundled using `rollup`. To build the distributable bundles, simple run `yarn bundle`.
371370
This will output two bundles, `*.umd.js` and `*.esm.js`, to `packages/*/dist`. Node.js clients
372371
are pointed to the `umd` bundle, and bundlers are pointed to `esm`.
373372

374-
*NOTE: these bundles are _not_ minified.*
373+
_NOTE: these bundles are *not* minified._
375374

376375
#### webpack
377376

378-
To build an all-in-one static js file, first install `webpack` globally using `yarn global add webpack`. Then run `yarn build:web`.
377+
To build an all-in-one static js file, first install `webpack` globally using `yarn global add webpack`. Then run `yarn build:web`.
379378
This will generate a `dist` folder in the current path, which contains a file called `zilliqa.min.js`. It can be used in normal html file. (A more specific example please refer to `example/webpack`)
380379

381-
*NOTE: there may be some issue to install webpack with npm, thus using yarn is a recommended way*
380+
_NOTE: there may be some issue to install webpack with npm, thus using yarn is a recommended way_
382381

383-
## Licence
382+
## Licence
384383

385384
You can view our [licence here](LICENSE).
386-

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
"test": "jest --verbose -c jest.config.js --rootDir=.",
2323
"release": "yarn bootstrap && yarn bundle && lerna publish --exact",
2424
"release:local": "yarn bootstrap && yarn bundle && lerna exec 'npm publish --registry http://localhost:4873'",
25-
"prettier": "prettier '**/*.{ts,tsx,js}' --config .prettierrc",
25+
"prettier": "prettier '**/*.{ts,tsx,js,json,md}' --config .prettierrc",
2626
"format": "yarn prettier -- --write",
2727
"lint": "eslint . --ext .ts -c .eslintrc.js",
2828
"validate": "yarn lint && yarn prettier -- --list-different && yarn bootstrap && yarn test"
2929
},
30-
"workspaces": [
31-
"packages/*"
32-
],
30+
"workspaces": ["packages/*"],
3331
"devDependencies": {
3432
"@types/bn.js": "^4.11.3",
3533
"@types/camelcase": "^4.1.0",

packages/zilliqa-js-account/README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# @zilliqa-js/account
2+
23
> Classes for managing accounts and account-related actions.
34
45
# Interfaces
@@ -24,6 +25,7 @@ interface TxParams {
2425
signature?: string;
2526
}
2627
```
28+
2729
When you give `nonce`, you should give `pubKey` together.
2830

2931
# Classes
@@ -156,7 +158,7 @@ Adds an `Account` to the `Wallet`.
156158

157159
### `addByKeystore(keystore: string, passphrase: string): Promise<string>`
158160

159-
Adds an account by keystore. This method is asynchronous and returns a `Promise<string>`, in order not to block on the underlying decryption operation.
161+
Adds an account by keystore. This method is asynchronous and returns a `Promise<string>`, in order not to block on the underlying decryption operation.
160162

161163
**Parameters**
162164

@@ -221,13 +223,13 @@ Sets the default account to sign with.
221223
### `sign(transaction: Transaction, offlineSign?: boolean): Promise<Transaction>`
222224

223225
Sign a `Transaction` with the default `Account`. This method is asynchronous
224-
as it will attempt to obtain the `nonce` from the `Provider`.
226+
as it will attempt to obtain the `nonce` from the `Provider`.
225227
There is an offline mode that can be activated manually by setting the optional `offlineSign` parameter.
226228

227229
**Parameters**
228230

229231
- `transaction`: `Transaction` - a `Transaction` instance.
230-
- `offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
232+
- `offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
231233

232234
**Note**: In offline mode, the nonce must be explicitly set in the Transaction object.
233235

@@ -245,9 +247,9 @@ There is an offline mode that can be activated manually by setting the optional
245247

246248
- `transaction`: `Transaction` - a `Transaction` instance.
247249
- `address`: `string` - the address of the `Account` to be used for signing.
248-
- `offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
250+
- `offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
249251

250-
**Note**: In offline mode, the nonce must be explicitly set in the Transaction object.
252+
**Note**: In offline mode, the nonce must be explicitly set in the Transaction object.
251253

252254
**Returns**
253255

@@ -300,7 +302,7 @@ for (const signedTx of batchResult) {
300302

301303
## `Transaction`
302304

303-
A class that represents a single `Transaction` on the Zilliqa network. It is a functor. Its purpose is to encode the possible states a Transaction can be in: Confirmed, Rejected, Pending, or Initialised (i.e., not broadcasted).
305+
A class that represents a single `Transaction` on the Zilliqa network. It is a functor. Its purpose is to encode the possible states a Transaction can be in: Confirmed, Rejected, Pending, or Initialised (i.e., not broadcasted).
304306

305307
## Members
306308

@@ -344,7 +346,7 @@ const txParams = {
344346
toAddr: '20_byte_hex_string',
345347
amount: new BN(8),
346348
gasPrice: new BN(100),
347-
gasLimit: Long.fromNumber(888)
349+
gasLimit: Long.fromNumber(888),
348350
};
349351
const tx = Transaction.confirm(txParams, new HTTPProvider('http://my-api.com'));
350352

@@ -502,9 +504,8 @@ for providing a payload to `signTransaction`.
502504
**Parameters**
503505
504506
- `tx`: `TxParams` - plain object containing core transaction fields that must
505-
be used when generating a signature.
507+
be used when generating a signature.
506508
507509
**Returns**
508510
509511
- `Buffer` - the bytes of the `protobuf`-serialised transaction fields.
510-
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "../tsconfig.test.json"
2+
"extends": "../tsconfig.test.json"
33
}

packages/zilliqa-js-account/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
"include": ["src", "../../typings/**/*.d.ts"],
88
"references": [
9-
{"path": "../zilliqa-js-core"},
10-
{"path": "../zilliqa-js-crypto"},
11-
{"path": "../zilliqa-js-util"}
9+
{ "path": "../zilliqa-js-core" },
10+
{ "path": "../zilliqa-js-crypto" },
11+
{ "path": "../zilliqa-js-util" }
1212
]
1313
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
{
22
"extends": "../../tsconfig.test.json",
3-
"include": [
4-
"src",
5-
"test",
6-
"../../typings/**/*.d.ts"
7-
],
3+
"include": ["src", "test", "../../typings/**/*.d.ts"],
84
"references": [
9-
{"path": "../zilliqa-js-core"},
10-
{"path": "../zilliqa-js-crypto"},
11-
{"path": "../zilliqa-js-util"}
5+
{ "path": "../zilliqa-js-core" },
6+
{ "path": "../zilliqa-js-crypto" },
7+
{ "path": "../zilliqa-js-util" }
128
]
139
}

0 commit comments

Comments
 (0)