Skip to content

Commit

Permalink
fix: improve docs (#674)
Browse files Browse the repository at this point in the history
* fix: improve docs

* fix: remove version from package.json

* fix: update prepare-packages script

* fix: update prepare-packages script

---------

Co-authored-by: Rodolfo Pietro CalabrΓ² <[email protected]>
  • Loading branch information
fabiorigam and rodolfopietro97 authored Mar 6, 2024
1 parent 15b145b commit 6239b47
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 69 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,45 @@ For advanced testing scenarios, you may require a custom data starting point wit
3. **Restart thor-solo**:
- Rebuild and restart the thor-solo container with the updated Dockerfile. This will launch thor-solo with your custom data starting point.


## Documentation and Examples

- The `./docs` directory houses extensive code examples written as executable demonstrations.
- Dive into the [examples](./docs/README.md) for a hands-on understanding of the SDK capabilities.
- For a comprehensive overview of the package structure, please refer to our [Architecture Diagrams](./docs/diagrams/) located in the documentation directory.
On the `/docs` folder you cna find the comprehensive **SDK documentation** and executable code examples. We've designed these examples not just for learning purposes but also as integration tests, ensuring that the provided code snippets are always functional and up-to-date.

### Examples

Our code examples reside in the `./docs/examples` folder. Each example is a stand-alone script that showcases various operations achievable with the SDK. Some of the code examples require a Thor Solo node to be available.

To run the scripts within `./docs/examples` as tests, use:
``` bash
yarn test:examples
```

**NOTE**: Tests require thor-solo to be running locally. You can run and stop separately thor solo node with `yarn start-thor-solo` and `yarn stop-thor-solo` or run all tests with `yarn test:examples:solo` which will start thor solo node, run all tests and stop thor solo at the end.

### Templates

In the `./docs/templates` folder, you'll find markdown files used to build our final documentation. These templates can include links to example files, dynamically expanded into code snippets during documentation generation.

For instance:

\[example](examples/accounts/bip39.ts)

The above link, when processed during documentation build, expands into the content of the linked file, ensuring our documentation is as practical as possible.

Note: links that are to be expanded must have text \[example]

### Usage

To build the documentation, expanding examples into code snippets, use:
``` bash
yarn build
```

### Architecture diagrams

For a comprehensive overview of the package structure, please refer to our [Architecture Diagrams](./docs/diagrams/) located in the documentation directory.


- You can also create and test your examples using `yarn test:examples` command (with solo `yarn test:examples:solo`).

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion apps/sdk-user/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "rm -rf ./dist && tsup src/index.ts --format cjs,esm --dts"
},
"dependencies": {
"@vechain/vechain-sdk-core": "0.0.13",
"@vechain/vechain-sdk-core": "0.0.15",
"typescript": "^5.3.3"
}
}
4 changes: 2 additions & 2 deletions apps/vechain-sdk-hardhat-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"deploy-testnet": "npx hardhat run scripts/deploy.ts --network vechain_testnet"
},
"dependencies": {
"@vechain/vechain-sdk-hardhat-plugin": "0.0.13",
"@vechain/vechain-sdk-core": "0.0.13"
"@vechain/vechain-sdk-hardhat-plugin": "0.0.15",
"@vechain/vechain-sdk-core": "0.0.15"
},
"devDependencies": {
"hardhat": "^2.20.1",
Expand Down
4 changes: 2 additions & 2 deletions apps/vechain-sdk-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"react": "^18",
"react-dom": "^18",
"next": "14.1.0",
"@vechain/vechain-sdk-core": "0.0.13",
"@vechain/vechain-sdk-network": "0.0.13"
"@vechain/vechain-sdk-core": "0.0.15",
"@vechain/vechain-sdk-network": "0.0.15"
},
"devDependencies": {
"typescript": "^5",
Expand Down
45 changes: 10 additions & 35 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,21 @@
# Code Examples & Documentation
# Vechain SDK

Welcome to the `/docs` folder, your go-to resource for comprehensive **SDK documentation** and executable code examples. We've designed these examples not just for learning purposes but also as integration tests, ensuring that the provided code snippets are always functional and up-to-date.
Welcome to the official documentation for the vechain SDK!

## Structure
This SDK provides developers with tools and resources to integrate vechain blockchain functionality into their applications with ease. Whether you're building decentralized applications (dApps), managing digital assets, or exploring blockchain-based solutions, this SDK offers a comprehensive set of features to interact with the VeChainThor blockchain.

### Examples
## Installation

Our code examples reside in the `/examples` folder. Each example is a stand-alone script that showcases various operations achievable with the SDK.
To begin using the vechain SDK, run the following command:

Some of the code examples require a Thor Solo node to be available.

### Templates

In the `/templates` folder, you'll find markdown files used to build our final documentation. These templates can include links to example files, dynamically expanded into code snippets during documentation generation.

For instance:

\[example](examples/accounts/bip39.ts)

The above link, when processed during documentation build, expands into the content of the linked file, ensuring our documentation is as practical as possible.

Note: links that are to be expanded must have text \[example]

## Usage

### Execute Examples as Tests

To run the scripts within /examples as tests, use:
``` bash
yarn test:examples
npm install @vechain/vechain-sdk
```

**NOTE**: Tests require thor-solo to be running locally. You can run and stop separately thor solo node with `yarn start-thor-solo` and `yarn stop-thor-solo` or run all tests with `yarn test:examples:solo` which will start thor solo node, run all tests and stop thor solo at the end.

## Contributing

### Build Documentation

To build the documentation, expanding examples into code snippets, use:
``` bash
yarn build
```
We welcome contributions from the community to improve the vechain SDK. If you want to contribute, please review our Contribution Guidelines for more information.

Feel free to explore the examples and templates, and don't hesitate to reach out if you have any questions or need further assistance.
## License

Happy coding with the vechain SDK!
The vechain SDK is licensed under the MIT License, which allows for both personal and commercial use.
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "1.0.0",
"version": "0.0.15",
"description": "Documentation for the SDK with examples",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -20,7 +20,7 @@
"test:examples:solo": "(yarn start-thor-solo && yarn test:examples && yarn stop-thor-solo) || yarn stop-thor-solo"
},
"dependencies": {
"@vechain/vechain-sdk-core": "0.0.13",
"@vechain/vechain-sdk-core": "0.0.15",
"typescript": "^5.3.3"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "vechain-sdk",
"version": "1.1.0",
"description": "The official JavaScript SDK for vechain",
"repository": "https://github.com/vechain/vechain-sdk.git",
"author": "vechain Foundation",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-core",
"version": "0.0.13",
"version": "0.0.15",
"description": "Includes modules for fundamental operations like hashing and cryptography",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -25,7 +25,7 @@
"dependencies": {
"@ethereumjs/rlp": "^5.0.2",
"@types/elliptic": "^6.4.18",
"@vechain/vechain-sdk-errors": "0.0.13",
"@vechain/vechain-sdk-errors": "0.0.15",
"blakejs": "^1.2.1",
"elliptic": "^6.5.5",
"ethers": "6.11.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-errors",
"version": "0.0.13",
"version": "0.0.15",
"description": "This module is dedicated to managing and customizing errors within the SDK",
"author": "vechain Foundation",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-hardhat-plugin",
"version": "0.0.13",
"version": "0.0.15",
"description": "This module allows to create smart contracts and interact with them using the vechain SDK and Hardhat",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -22,6 +22,6 @@
"test": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit"
},
"dependencies": {
"@vechain/vechain-sdk-provider": "0.0.13"
"@vechain/vechain-sdk-provider": "0.0.15"
}
}
4 changes: 2 additions & 2 deletions packages/logging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-logging",
"version": "0.0.13",
"version": "0.0.15",
"description": "This module provides functionality to logging data for vechain-sdk",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -20,6 +20,6 @@
"test": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit"
},
"dependencies": {
"@vechain/vechain-sdk-errors": "0.0.13"
"@vechain/vechain-sdk-errors": "0.0.15"
}
}
6 changes: 3 additions & 3 deletions packages/network/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-network",
"version": "0.0.13",
"version": "0.0.15",
"description": "This module allows to connect you seamlessly to the VechainThor blockchain",
"author": "vechain Foundation",
"license": "MIT",
Expand Down Expand Up @@ -28,8 +28,8 @@
},
"dependencies": {
"@types/ws": "^8.5.10",
"@vechain/vechain-sdk-core": "0.0.13",
"@vechain/vechain-sdk-errors": "0.0.13",
"@vechain/vechain-sdk-core": "0.0.15",
"@vechain/vechain-sdk-errors": "0.0.15",
"axios": "^1.6.7"
}
}
10 changes: 5 additions & 5 deletions packages/provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-provider",
"version": "0.0.13",
"version": "0.0.15",
"description": "This module is dedicated to managing the compatibility with ethers and EVM world",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -25,9 +25,9 @@
"test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo"
},
"dependencies": {
"@vechain/vechain-sdk-network": "0.0.13",
"@vechain/vechain-sdk-wallet": "0.0.13",
"@vechain/vechain-sdk-core": "0.0.13",
"@vechain/vechain-sdk-logging": "0.0.13"
"@vechain/vechain-sdk-network": "0.0.15",
"@vechain/vechain-sdk-wallet": "0.0.15",
"@vechain/vechain-sdk-core": "0.0.15",
"@vechain/vechain-sdk-logging": "0.0.15"
}
}
8 changes: 4 additions & 4 deletions packages/rpc-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-rpc-proxy",
"version": "0.0.13",
"version": "0.0.15",
"description": "Proxy Thor's RESTful API to Eth JSON-RPC",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -19,9 +19,9 @@
"start": "yarn build && node dist/index.js"
},
"dependencies": {
"@vechain/vechain-sdk-network": "0.0.13",
"@vechain/vechain-sdk-provider": "0.0.13",
"@vechain/vechain-sdk-wallet": "0.0.13",
"@vechain/vechain-sdk-network": "0.0.15",
"@vechain/vechain-sdk-provider": "0.0.15",
"@vechain/vechain-sdk-wallet": "0.0.15",
"cors": "^2.8.5",
"express": "^4.18.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/vechain-sdk-wallet",
"version": "0.0.13",
"version": "0.0.15",
"description": "This module provides functionality for creating and managing vechain wallets, as well as signing and broadcasting transactions securely on the VechainThor blockchain",
"author": "vechain Foundation",
"license": "MIT",
Expand All @@ -21,6 +21,6 @@
"test": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit"
},
"dependencies": {
"@vechain/vechain-sdk-network": "0.0.13"
"@vechain/vechain-sdk-network": "0.0.15"
}
}
23 changes: 22 additions & 1 deletion scripts/prepare-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const updatePackageVersions = (version: string): void => {
const docsPath = path.resolve(__dirname, `../docs`);
const docsJsonPath = path.resolve(docsPath, './package.json');
const docsJson = JSON.parse(fs.readFileSync(docsJsonPath, 'utf8'));
docsJson.version = version;
fs.writeFileSync(docsJsonPath, JSON.stringify(docsJson, null, 2));

if (docsJson.dependencies != null) {
for (const dep of Object.keys(docsJson.dependencies)) {
Expand All @@ -73,4 +75,23 @@ const updatePackageVersions = (version: string): void => {
fs.writeFileSync(docsJsonPath, JSON.stringify(docsJson, null, 2));
};

updatePackageVersions('0.0.14');
const preparePackages = async () => {
const version = process.argv[2];

if (!version?.match(/^\d+\.\d+\.\d+$/)) {
console.error(
`🚨 You must specify a semantic version as the first argument 🚨`
);
process.exit(1);
}

console.log(' Version:');
console.log(` - 🏷 Updating package versions to ${version}...`);
updatePackageVersions(version);
console.log(' - βœ… Updated!');
};

preparePackages().catch((e) => {
console.error(e);
process.exit(1);
});

1 comment on commit 6239b47

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 100%
100% (2836/2836) 100% (572/572) 100% (576/576)
Title Tests Skipped Failures Errors Time
core 409 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 50s ⏱️
network 249 0 πŸ’€ 0 ❌ 0 πŸ”₯ 3m 56s ⏱️
errors 48 0 πŸ’€ 0 ❌ 0 πŸ”₯ 19.115s ⏱️

Please sign in to comment.