Tools for FRAME chain builders to publish chain specific offline transaction generation libraries.
Table of contents
The polkadot.js based txwrapper suite of packages provides chain builders with the tools to quickly create, test, and maintain a library of helper functions for offline transaction generation with their chain. End users can then use these chain specific packages to create an offline transaction workflow. (We sometimes refer to chain specific libs as txwrappers.)
For example, those looking to construct a transaction offline on Polkadot would require @substrate/txwrapper-polkadot. @substrate/txwrapper-polkadot is built by requiring @substrate/txwrapper-core, @substrate/txwrapper-registry, @substrate/txwrapper-substrate and re-exporting utilities and dispatchables relevant to Polkadot.
- @substrate/txwrapper-polkadot Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Rococo, Westend, Statemint and Statemine.
- @substrate/txwrapper-core The essentials for creating a chain specific txwrapper lib.
- @substrate/txwrapper-registry Registry creation support, catering to chains with types in @polkadot/apps-config.
- @substrate/txwrapper-substrate Selected dispatchables of Substrate pallets, to be re-exported by txwrappers (e.g. @substrate/txwrapper-polkadot).
- @substrate/txwrapper-orml Selected dispatchables of ORML pallets, to be re-exported by txwrappers (e.g. txwrapper-acala).
- @substrate/txwrapper-example Usage examples including how to construct, sign, and decode an extrinsic with @substrate/txwrapper-polkadot.
- @substrate/txwrapper-template Template package for chain builders.
End user examples
Chain builder guide
Click here to find our guide for chain builders. The guide explains how to make a chain specific txwrapper.
Develop, contribute, and maintain
Build all packages:
yarn run build
We welcome contributions!
Before submitting your PR, make sure to run the following commands
Run all tests:
yarn run test
Run the linter:
yarn run lint # or to automatically fix warnings: yarn run lint --fix
Txwrapper-core runs on yarn berry. It is a package manager local to the repo, and requires updating from time to time. The releases for yarn berry can be found here. Below are the steps to updating yarn.
$ yarn set version <version> $ yarn $ yarn dedupe
Release & Publishing
Ensure that your version of
npmis 7 or above. Check with
npm --versionand, if needed, upgrade with
npm install -g npm(which may need to be prefixed with
sudodepending on the permissions set on your global
node_modulesfolder). If this is not true, an empty binary will be pushed on publish.
Checkout a branch
In order to update all the polkadot-js dependencies and resolutions, run
yarn up '@polkadot/*'.
Ensure there are no issues by running the following commands. If any type errors occur due to the updated dependencies, please file an issue here.
yarn run build yarn dedupe yarn run test yarn run lint
If all tests pass and all packages build successfully, commit your changes with the following format
fix(types): Update polkadot-js deps to get the latest types. Then push your branch up to Github for review, then merge. The release tooling takes care of bumping the version so no need for a manual update (see below).
This libraries release process uses Lerna, and the following below is required to have a successful release.
N.B. Ensure you have
GH_TOKENenv variable set to a GitHub personal access token (PAT) so lerna can publish the release on github.
The publisher will need publishing permissions to the @substrate npm org.
Make sure you're logged in to
Make sure to be in the
git pull origin main.
Before deploying a new release run the following sanity checks.
yarn run build yarn run test
Deploy the new release. It is important to note there will be a step that asks you to confirm whether or not the version bump is correct. Please confirm with the maintainers the suggested versions are correct.
yarn run deploy
This repo requires signed and verified commits, so when using a yubikey there are several points where you are required to sign a commit while Lerna sets up the github release. The output from Lerna won't warn you that you have to sign it, so the
deploystep will error if you forget. I'd advise keeping an eye on your Yubikey; it'll start flashing when it's needed to sign something.
If you don't sign a commit in time and get an error, you may need to "undo" some steps:
- If a new commit was created locally,
git reset --hard HEAD~1to undo it.
- If a new tag was created locally,
git tag -d <new-version>to remove it.
rm -rf lerna-debug.logto remove it.
If you forget to login to NPM, the GitHub steps will all complete successfully, but the publishing step will fail. In that case, you can do the following:
yarn run buildto ensure that all packages are built and ready to be published (This is important;
yarn run deploydoes this for us, but if we skip to publishing, we must ensure that the packages are in a good state ourselves).
npx lerna publish from-packageto publish the packages.
If you don't have the permissions you need on the GitHub repository, you may find that you're able to push a tag but not the actual commit. In this case, you can delete the version tag on GitHub with
git push origin :<new-version>.
- If a new commit was created locally,