1 | # ๐ฅ @effectai/effect-js
|
2 |
|
3 | <p align="center"><img src="https://effect.network/img/logo/logo.png" width="400px"></p>
|
4 |
|
5 | Effect Network SDK for integration with [https://effect.network](https://effect.network)
|
6 |
|
7 | ## โ๏ธ Installation
|
8 |
|
9 | The official distribution for the package is available at [npm](https://www.npmjs.com/package/@effectai/effect-js).
|
10 | Note that the module available under the `@effectai/effect-js` namespace is for ECMAScript modules, if you want to use the module in a CommonJS environment (require), you can use the `@effectai/effect-js@cjs` module.
|
11 | Note, that if you are using NodeJS, the minimum version required is `v18`.
|
12 |
|
13 | ### ESM
|
14 |
|
15 | ```bash
|
16 | npm i @effectai/effect-js
|
17 | ```
|
18 |
|
19 | ```js
|
20 | import { EffectSdk } from "@effectai/effect-js";
|
21 | ```
|
22 |
|
23 | ### CommonJS
|
24 |
|
25 | ```bash
|
26 | npm i @effectai/effect-js@cjs
|
27 | ```
|
28 |
|
29 | ```js
|
30 | const { EffectSdk } = require("@effectai/effect-js");
|
31 | ```
|
32 |
|
33 | ## Quickstart
|
34 |
|
35 | Take a look at the quick start [guide](https://developer.effect.network/quickstart/) to understand how to install and use the library.
|
36 |
|
37 | ## SDK-Reference
|
38 |
|
39 | The SDK reference is available here: [SDK-Reference](https://effectai.github.io/effect-js/)
|
40 |
|
41 | ## ๐ฆ Development
|
42 |
|
43 | The best way to get to know how this module works is by adding features while you can run it. So there are some examples provided to provide an idea of how to create a transaction with the Effect Network.
|
44 |
|
45 | Clone the project
|
46 |
|
47 | ```bash
|
48 | git clone https://github.com/effectai/effect-js.git
|
49 | ```
|
50 |
|
51 | Install dependencies and dev-dependencies
|
52 |
|
53 | ```bash
|
54 | npm ci
|
55 | ```
|
56 |
|
57 | It is now possible to start compiling the typescript files to the module spec of your choice, for now, the following module specs are supported: [ESM, CommonJS]
|
58 |
|
59 | ```bash
|
60 | npm run build # esmodules
|
61 | npm run build:cjs # commonjs
|
62 | ```
|
63 |
|
64 | Link it. Now it is possible to use `npm link` to link the compiled typescript code to your project, from the directory of your project, run the following command.
|
65 |
|
66 | ```bash
|
67 | npm link /path/to/effect-js/
|
68 | ```
|
69 |
|
70 | From your project folder, you should be able to import the compiled code from `effect-js`. Depending on your environment, use `import` or `require` as [described above](## โ๏ธ Installation).
|
71 |
|
72 | ## ๐งช Testing
|
73 |
|
74 | The testing framework used for this project is [ViTest](https://vitest.dev) and is configured to run the tests in the `test` directory.
|
75 | Remember to copy the `test/.env.test.example` file to `test/.env.test` and fill in the values for your environment.
|
76 | Currently, these variables are required:
|
77 |
|
78 | - `VITE_EOSACC=yourEosAccountName`
|
79 | - `VITE_EOSPERM=yourEosAccountPermission`
|
80 | - `VITE_EOSPK=yourEosAccountPrivateKey`
|
81 |
|
82 | ```bash
|
83 | cp test/.env.test.example test/.env.test
|
84 |
|
85 | npm run test
|
86 | # OR
|
87 | npm run test:watch
|
88 | ```
|
89 |
|
90 | ## ๐ Publishing
|
91 |
|
92 | Run the following command to build the source, increment the version, and publish the `dist` transpile code and types to the npm repository, assuming you have the correct credentials.
|
93 |
|
94 | Make sure the git is clean, and everything has been committed, and run the following.
|
95 |
|
96 | ```bash
|
97 | npm run publish:public
|
98 | ```
|
99 |
|
100 | Running `publish:next` will publish a pre-release of the SDK to the npm repository. Users will need to explicitly opt-in to use it.
|
101 |
|
102 | ```bash
|
103 | npm run publish:next
|
104 | ```
|