You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaScript and TypeScript developers can leverage this library to make OAK-specific API calls, such as timeAutomation.scheduleXcmpTask. For more information on OAK's unique API, refer to the Time Automation Explained in Documentation guide.
In addition, it provides an SDK to help developers simplify the use of automation. It includes the following packages:
Run the following commands to install the latest packages:
npm i @oak-network/api-augment npm i @oak-network/types
Including the Library in Your Code
To include the library in your code, refer to the code snippet provided in ./demo/src for Time Automation code. In summary, the following lines will add type checking of OAK extrinsics to the existing polkadot.js library:
Run the following commands to install the required packages:
npm i @oak-network/config@latest npm i @oak-network/adapter@latest npm i @oak-network/sdk@latest
Developing Applications with the SDK
To develop applications using the SDK, you can refer to the test code as an example. Here's a step-by-step guide:
Start by exporting configurations from @oak-network/config.
Construct a Polkadot API.
Build and initialize an adapter. Utilize the methods provided by the adapter for standard operations.
For more complex operations that involve data exchange between multiple adapters, such as scheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlow, you can leverage the functions provided by the SDK package.
If you would like to develop or test the code in this repository, please follow the guidelines below.
Pre-requisites
Yarn version needs to be equal to or higher than 2 to use Yarn Workspace feature of this monorepo. First run the following command to check the version of Yarn:
yarn --version
Then if yarn version is lower than 2, run the following command to upgrade:
yarn set version berry
Installation
Run the following command to install the necessary dependencies:
yarn # Please use yarn to install dependencies due to the use of Yarn Workspace
Maintaining dependencies across packages
The packages are referring each other by source code, so when one is updated, the new version will be used by other packages. For example, ./packages/sdk/package.json has the following dependency:
By default, the tests are configured to target your local development environment. Before running any commands, please follow the steps in the Quickstart: run Local Network with Zombienet guide to build and run a local relay chain and parachain.
Once the Turing Dev network is running, you should be able to see it on polkadot.js.org/apps.
The default WebSocket endpoint is ws://127.0.0.1:9946 and the default test wallet is Alice (6AwtFW6sYcQ8RcuAJeXdDKuFtUVXj4xW57ghjYQ5xyciT1yd).
You can start the tests by running the following command:
yarn run test
Please note that the tests are not meant to be repeatedly run against live networks. However, you can run them against the Turing Staging environment using the following command:
ENV="Turing Staging" MNEMONIC="" yarn run test
You can also specify the endpoint in the Turing Dev environment:
MNEMONIC="" ENDPOINT="ws://127.0.0.1:9944" yarn run test
SDK Tests
You can start the tests by running the following command:
MNEMONIC="" ENV="Turing Staging" yarn run test:sdk
If you wish to perform local testing, you'll need to launch the parachain test network yourself using the following command:
zombienet spawn zombienets/turing/moonbase.toml
This command will initiate the test network for parachains.
Then, you'll need to specify a test suite since each suite executes tests for a single parachains.
yarn run test:sdk -- -t test-mangata
Compound Tests
If you wish to perform local testing, you'll need to launch the parachain test network yourself using the following command:
If the account hasn't been delegated on-chain yet, you can execute the following command to test the delegateWithAutoCompound interface.
MNEMONIC="" ENV="Turing Dev" yarn run test:delegate
If the account has already been delegated on-chain, or if you've previously tested the delegateWithAutoCompound interface, you can execute the following command to test the delegatorBondMore, setAutoCompound, getDelegation, and getAutoCompoundingDelegationPercentage interfaces.
packages: It store individual code libraries for various parts of the project.
scripts/package-setup: It is a script used for building packages. It utilizes templates/index.cjs as a script.
test: The test folder contains test programs. test/functional is used for testing the Foundational library, while test/sdk is used for testing the SDK library.
demo: It contains example code for developers to learn from.
Updating the packages
To update the code of both packages in this repository, you will first need to run a local version of the Turing Network. Then, using a script and leveraging the chain's API, you can automatically update the TypeScript code in the packages.
1. Run Turing Network Locally
Follow the instructions in the OAK-blockchain GitHub repository to clone the source code and set up the Rust version. Build and run the project. Additionally, set up zombienet to spawn a local network. Assuming zombienet is installed and you are in the OAK-blockchain directory, run the following command:
You are now ready to update the packages' code in this oak.js project. From the root of this project, run the following commands:
yarn cd packages/api-augment yarn run clean:defs yarn run generate
3. Rebuilding packages
The last step is to build the packages' source code in preparation for publishing. Navigate back to the root of the oak.js directory and run the following commands:
yarn run clean yarn run build
The build command will generate distribution files under packages/*/build.
Publishing the Packages
The release creation and publishing process is managed by GitHub Actions. It's important to note that package versions don't need to be consistent across all packages. For example, if changes are made to the api-augment library, there's no requirement to bump the version of the types library as well.
To publish packages, please follow the steps outlined below:
Generate Changeset Marking File:
To initiate a version update, start by running the command yarn run changeset locally. This action will create a marking file in the ./changeset directory. An example of such a change can be found in this PR: example PR link.
Automated Package Version Update:
After the aforementioned PR is merged into the main branch, a GitHub Action will be triggered by the created marking file. This action will automatically generate a new PR, updating the versions of all packages simultaneously. You can observe this process in action with this PR: example PR link. Should you need to add additional changes to the same version, simply repeat step 1 to create another marking file and merge it into the main branch. The original PR associated with the main branch will be updated automatically. Furthermore, a corresponding git tag will be generated for each package as part of this process.
Testing with Dev Version:
If everything appears satisfactory, proceed to merge the above-mentioned PR. Following the successful merge, manually trigger the Publish dev version workflow. This will lead to the publishing of an NPM package version with the dev tag, facilitating thorough testing.
Updating to Latest Tag:
Once confident with the outcome of the dev testing phase, manually initiate the Update dev tag to latest workflow. This workflow will update the npm tag from dev to latest, signifying the readiness of the package for broader use.
You should receive an email from support@npmjs.com if the package is successfully published.
About
Javascript dev-utils library to access OAK Network APIs, leveraging typing decoration of polkadot.js library.