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
echo "New version from local build folder: $new_version"
63
+
64
+
# Debugging: Print the values of $highest_version and $current_dev_version
65
+
echo "Current Dev Version: $current_dev_version"
66
+
echo "Highest Version: $highest_version"
67
+
68
+
# Compare the new version with the current dev version and the highest version; If we publish a lower than the highest version, it will be rejected by npm.
69
+
# TODO: I was not able to check if the new version is higher than both the current dev version and the highest version yet, so the check is very simple here. Ideally, we should check if the new version is higher.
70
+
if [ "$new_version" != "$current_dev_version" ]; then
71
+
echo "New version $new_version is different from NPM dev tag version $current_dev_version; publishing..."
58
72
npm publish --tag dev
59
73
else
60
-
echo "Package is up to date."
74
+
echo "Skip publish since there’s no higher version number."
Copy file name to clipboardExpand all lines: README.md
+135-12
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,20 @@
1
1
# oak.js OAK Network JavaScript SDK
2
2
3
-
The `oak.js` library is a JavaScript extension of `polkadot.js` that provides type decorations for OAK Network functions. It requires the installation of the following packages:
3
+
The `oak.js` library is a JavaScript extension of `polkadot.js`.
4
4
5
+
It provides type decorations for OAK Network functions. It requires the installation of the following packages:
5
6
-`@oak-network/api-augment`, available at [npmjs.com/@oak-network/api-augment](https://www.npmjs.com/package/@oak-network/api-augment)
6
7
-`@oak-network/types`, available at [npmjs.com/@oak-network/types](https://www.npmjs.com/package/@oak-network/types)
7
8
8
9
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](https://docs.oak.tech/docs/time-automation-explained/) guide.
9
10
10
-
## Usage
11
+
In addition, it provides an SDK to help developers simplify the use of automation. It includes the following packages:
12
+
-`@oak-network/sdk-types`, available at [npmjs.com/@oak-network/sdk-types](https://www.npmjs.com/package/@oak-network/sdk-types)
13
+
-`@oak-network/config`, available at [npmjs.com/@oak-network/config](https://www.npmjs.com/package/@oak-network/config)
14
+
-`@oak-network/adapter`, available at [npmjs.com/@oak-network/adapter](https://www.npmjs.com/package/@oak-network/adapter)
15
+
-`@oak-network/sdk`, available at [npmjs.com/@oak-network/sdk](https://www.npmjs.com/package/@oak-network/sdk)
Run the following commands to install the required packages:
47
+
48
+
```bash
49
+
npm i @oak-network/sdk-types@latest
50
+
npm i @oak-network/config@latest
51
+
npm i @oak-network/adapter@latest
52
+
npm i @oak-network/sdk@latest
53
+
```
54
+
55
+
### Developing Applications with the SDK
56
+
57
+
To develop applications using the SDK, you can refer to the test code as an example. Here's a step-by-step guide:
58
+
59
+
- Start by exporting configurations from @oak-network/config.
60
+
61
+
- Construct a Polkadot API.
62
+
63
+
- Build and initialize an adapter. Utilize the methods provided by the adapter for standard operations.
64
+
65
+
- 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.
37
103
38
104
### Installation
39
105
Run the following command to install the necessary dependencies:
40
106
41
107
```bash
42
-
npm i
108
+
yarn # Please use yarn to install dependencies due to the use of Yarn Workspace
43
109
```
44
110
45
-
### Running Tests
111
+
### Running Foundational Tests
46
112
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](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9946#/accounts) guide to build and run a local relay chain and parachain.
47
113
48
114
Once the Turing Dev network is running, you should be able to see it on [polkadot.js.org/apps](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9946#/accounts).
@@ -51,20 +117,77 @@ The default WebSocket endpoint is `ws://127.0.0.1:9946` and the default test wa
51
117
52
118
You can start the tests by running the following command:
53
119
```bash
54
-
npm run test
120
+
yarn run test
55
121
```
56
122
57
123
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:
58
124
```bash
59
-
ENV="Turing Staging" MNEMONIC="<MNEMONIC>"npm run test
125
+
ENV="Turing Staging" MNEMONIC="<MNEMONIC>"yarn run test
60
126
```
61
127
62
128
You can also specify the endpoint in the Turing Dev environment:
63
129
64
130
```bash
65
-
MNEMONIC="<MNEMONIC>" ENDPOINT="ws://127.0.0.1:9944"npm run test
131
+
MNEMONIC="<MNEMONIC>" ENDPOINT="ws://127.0.0.1:9944"yarn run test
66
132
```
67
133
134
+
### SDK Tests
135
+
136
+
You can start the tests by running the following command:
137
+
138
+
```bash
139
+
MNEMONIC="<MNEMONIC>" ENV="Turing Staging" yarn run test:sdk
140
+
```
141
+
142
+
If you wish to perform local testing, you'll need to launch the parachain test network yourself using the following command:
143
+
144
+
```bash
145
+
zombienet spawn zombienets/turing/moonbase.toml
146
+
```
147
+
148
+
This command will initiate the test network for parachains.
149
+
150
+
Then, you'll need to specify a test suite since each suite executes tests for a single parachains.
151
+
152
+
```bash
153
+
yarn run test:sdk -- -t test-mangata
154
+
```
155
+
156
+
## File structure
157
+
158
+
```
159
+
.
160
+
├── LICENSE
161
+
├── README.md
162
+
├── babel.config.js
163
+
├── demo
164
+
├── jest.config.js
165
+
├── media
166
+
├── package.json
167
+
├── packages
168
+
│ ├── adapter
169
+
│ ├── api-augment
170
+
│ ├── config
171
+
│ ├── sdk
172
+
│ ├── sdk-types
173
+
│ └── types
174
+
├── scripts
175
+
│ └── package-setup
176
+
├── templates
177
+
│ └── index.cjs
178
+
├── test
179
+
│ ├── functional
180
+
│ ├── sdk
181
+
│ └── utils
182
+
├── tsconfig.build.json
183
+
├── tsconfig.json
184
+
```
185
+
186
+
-`packages`: It store individual code libraries for various parts of the project.
187
+
-`scripts/package-setup`: It is a script used for building packages. It utilizes templates/index.cjs as a script.
188
+
-`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.
189
+
-`demo`: It contains example code for developers to learn from.
190
+
68
191
## Updating the packages
69
192
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.
You are now ready to update the packages' code in this oak.js project. From the root of this project, run the following commands:
81
204
82
205
```bash
83
-
npm install
206
+
yarn
84
207
cd packages/api-augment
85
-
npm run clean:defs
86
-
npm run generate
208
+
yarn run clean:defs
209
+
yarn run generate
87
210
```
88
211
89
212
## 3. Rebuilding packages
90
213
91
214
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:
92
215
93
216
```bash
94
-
npm run clean
95
-
npm run build
217
+
yarn run clean
218
+
yarn run build
96
219
```
97
220
98
221
The build command will generate distribution files under `packages/api-augment/build`.
0 commit comments