This document outlines the necessary steps to configure your development environment, publish releases, and offers additional helpful information for working with the package.
The first step in setting up your development environment is cloning the repository and navigating to the project's root directory.
git clone git@github.com:ton-connect/sdk.git && cd sdkNext, install all dependencies using the following command:
npm ciNote: The
npm ciinstalls dependencies based on thepackage-lock.jsonfile, ensuring consistent versions as in the repository, and prevents any automatic updates.
Before starting development, you need to build all packages:
nx run-many --target=build --all --parallel=1Note: The
--parallel=1flag ensures packages are built one after the other to avoid potential errors caused by package dependencies.
Next, link the @tonconnect/ui-react package to your project:
cd packages/ui-react && npm linkThen, in your demo dapp directory, run:
npm link @tonconnect/ui-reactReplace the build script in packages/ui/package.json with the following:
{
"scripts": {
"build": "tsc --noEmit --emitDeclarationOnly false && vite build"
}
}
⚠️ Warning: Patch yourpackages/ui/package.jsonfile as above to ensure watch mode functions correctly during the build process. Remember to revert this patch before releasing a new version. This is a temporary workaround and will be addressed in future updates.
Now, build the @tonconnect/ui-react package in watch mode:
nx affected:build --parallel=1 --watchNote: As before,
--parallel=1is used to build packages sequentially, preventing errors due to interdependencies.
Finally, run your project in watch mode and start developing!
The release process is divided into distinct stages to ensure a smooth and error-free deployment. Initially, a beta version of the package is released and the demo applications are accordingly updated. This is followed by rigorous testing of the demo app to verify that the beta version operates as intended. Upon successful completion of the testing phase, the final step is to publish the release version.
Whether you're publishing a beta version or a new release, the process consists of several common steps with slight variations depending on the version type.
TODO: automate this process with an nx plugin.
Update the version of the packages in the following order, one at a time:
@tonconnect/isomorphic-eventsource@tonconnect/isomorphic-fetch@tonconnect/protocol@tonconnect/sdk@tonconnect/ui@tonconnect/ui-react
Only update the packages that have changes or are below another package in this list that has changes. If a package has no changes and is above a package with changes, it does not need to be updated.
If a package depends on another, update the dependency version and make a "chore" commit before moving on to the next package.
For example, if changes were made in @tonconnect/ui and @tonconnect/ui-react, you should first run the following for @tonconnect/ui:
- For a beta version:
nx run ui:version --releaseAs=prerelease --preid=beta
- For a new release:
nx run ui:version --releaseAs=patch
Note: Follow this link to learn more about
--releaseAsand--preid.
After updating the version, build all packages:
nx run-many --target=build --all --parallel=1Note: The
--parallel=1is used to build packages one by one since some packages depend on each other, and parallel building may result in errors.
Next, publish the version of the package. For @tonconnect/ui:
- For a beta version:
cd packages/ui && npm publish --access=public --tag=beta
- For a new release:
cd packages/ui && npm publish --access=public
Note: The
--tag=betais used to publish the package with thebetatag to prevent accidental installation of the beta version.
After publishing the version of @tonconnect/ui, push the commit and tags:
git push origin HEAD
git push origin --tagsAfter publishing the version of @tonconnect/ui, update its version in the dependencies section of @tonconnect/ui-react's package.json file.
/* file: packages/ui-react/package.json */
{
"dependencies": {
"@tonconnect/ui": "CURRENT_VERSION"
}
}TODO: add a step to run
npm installin@tonconnect/ui-reactfor updatingpackage-lock.jsonfile when the step will be tested.
Then, create a "chore" commit to save this change:
git add packages/ui-react/package.json
git commit -m "chore(ui-react): update @tonconnect/ui to CURRENT_VERSION"After publishing the version, repeat the above steps for the next package in the list, e.g. @tonconnect/ui-react.
If you're publishing a new release, make sure to update the demo app as well. Please refer to the Update the demo app section for more details.
TODO: automate this process with the GitHub Actions.
If you don't have the demo-dapp-with-wallet repository, clone it:
git clone git@github.com:ton-connect/demo-dapp-with-wallet.git && cd demo-dapp-with-walletTODO: replace with demo-dapp-with-react-ui repository when it will be updated.
Update the @tonconnect/ui-react package version in the package.json file:
{
"dependencies": {
"@tonconnect/ui-react": "CURRENT_VERSION"
}
}Install the necessary dependencies and update the package-lock.json file:
npm installBuild the demo app and check if it works correctly:
npm run buildCommit the changes and push them to the repository, this will update the GitHub pages:
git add . && git commit -m "chore: update @tonconnect/ui-react to CURRENT_VERSION" && git push origin HEADCaution: Be careful when updating any demo apps, as they are used for testing by the community.
After updating the demo app, test the beta version of the package in the demo app. If everything works correctly, you are ready to publish a new release. Don't forget to repeat the steps for the release version.
Note: Currently, the beta version is tested on the demo-dapp-with-wallet. However, it is recommended to also update the demo-dapp-with-react-ui and use it for testing.
You can access the package via CDN at the following URL: https://unpkg.com/@tonconnect/sdk@latest/dist/tonconnect-sdk.min.js.
The package can be tested using the following demo DApps:
- demo-dapp-with-wallet: Currently utilized for testing beta versions. It needs to be replaced with demo-dapp-with-react-ui.
- demo-dapp-with-react-ui: Currently outdated. It requires an update following the release publication.
- demo-dapp: Currently outdated. It requires an update.
The documentation for this package is generated using typedoc. It is automatically generated and updated by GitHub Actions whenever a new commit is pushed to the main branch.
Please note that the package is currently not compatible with React Native. This issue is expected to be addressed in future updates.