@alephium/web3 0.2.0-rc.3 → 0.2.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -2
- package/README.md +2 -135
- package/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +117 -17
- package/dist/src/api/api-alephium.js +145 -79
- package/dist/src/api/api-explorer.d.ts +163 -48
- package/dist/src/api/api-explorer.js +157 -34
- package/dist/src/api/index.d.ts +14 -2
- package/dist/src/api/index.js +46 -4
- package/dist/src/api/types.d.ts +23 -0
- package/dist/src/api/types.js +240 -0
- package/dist/src/api/utils.d.ts +6 -0
- package/dist/{scripts/rename-gitignore.js → src/api/utils.js} +11 -6
- package/dist/src/contract/contract.d.ts +110 -73
- package/dist/src/contract/contract.js +395 -451
- package/dist/src/contract/events.d.ts +4 -4
- package/dist/src/contract/events.js +2 -1
- package/dist/src/contract/index.js +5 -1
- package/dist/src/contract/ralph.d.ts +5 -4
- package/dist/src/contract/ralph.js +27 -1
- package/dist/src/global.d.ts +4 -0
- package/dist/{scripts/stop-devnet.js → src/global.js} +17 -11
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +23 -1
- package/dist/src/signer/index.d.ts +0 -1
- package/dist/src/signer/index.js +5 -2
- package/dist/src/signer/signer.d.ts +35 -28
- package/dist/src/signer/signer.js +79 -47
- package/dist/src/transaction/index.d.ts +0 -1
- package/dist/src/transaction/index.js +5 -2
- package/dist/src/transaction/status.d.ts +2 -1
- package/dist/src/transaction/status.js +2 -1
- package/dist/src/utils/bs58.d.ts +1 -0
- package/dist/src/utils/bs58.js +13 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +5 -2
- package/dist/src/utils/subscription.d.ts +0 -3
- package/dist/src/utils/subscription.js +0 -1
- package/dist/src/utils/utils.d.ts +4 -9
- package/dist/src/utils/utils.js +20 -24
- package/jest-config.json +11 -0
- package/package.json +11 -47
- package/src/api/api-alephium.ts +169 -25
- package/src/api/api-explorer.ts +234 -51
- package/src/api/index.ts +53 -3
- package/src/api/types.ts +233 -0
- package/{scripts/rename-gitignore.js → src/api/utils.ts} +7 -6
- package/src/contract/contract.ts +582 -550
- package/src/contract/events.ts +6 -5
- package/src/contract/ralph.ts +29 -4
- package/src/{transaction/sign-verify.ts → global.ts} +14 -15
- package/src/index.ts +7 -0
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +122 -85
- package/src/transaction/index.ts +0 -1
- package/src/transaction/status.ts +5 -2
- package/src/utils/bs58.ts +11 -0
- package/src/utils/index.ts +0 -1
- package/src/utils/subscription.ts +0 -4
- package/src/utils/utils.ts +11 -19
- package/.eslintrc.json +0 -21
- package/LICENSE +0 -165
- package/contracts/add/add.ral +0 -16
- package/contracts/greeter/greeter.ral +0 -7
- package/contracts/greeter/greeter_interface.ral +0 -3
- package/contracts/greeter_main.ral +0 -9
- package/contracts/main.ral +0 -6
- package/contracts/sub/sub.ral +0 -9
- package/contracts/test/metadata.ral +0 -17
- package/contracts/test/warnings.ral +0 -5
- package/dev/user.conf +0 -29
- package/dist/scripts/create-project.d.ts +0 -2
- package/dist/scripts/create-project.js +0 -125
- package/dist/scripts/rename-gitignore.d.ts +0 -1
- package/dist/scripts/start-devnet.d.ts +0 -1
- package/dist/scripts/start-devnet.js +0 -131
- package/dist/scripts/stop-devnet.d.ts +0 -1
- package/dist/src/signer/node-wallet.d.ts +0 -13
- package/dist/src/signer/node-wallet.js +0 -60
- package/dist/src/test/index.d.ts +0 -7
- package/dist/src/test/index.js +0 -41
- package/dist/src/test/privatekey-wallet.d.ts +0 -12
- package/dist/src/test/privatekey-wallet.js +0 -68
- package/dist/src/transaction/sign-verify.d.ts +0 -2
- package/dist/src/transaction/sign-verify.js +0 -58
- package/dist/src/utils/password-crypto.d.ts +0 -2
- package/dist/src/utils/password-crypto.js +0 -69
- package/gitignore +0 -10
- package/scripts/create-project.ts +0 -137
- package/scripts/start-devnet.js +0 -141
- package/scripts/stop-devnet.js +0 -32
- package/src/contract/ralph.test.ts +0 -178
- package/src/fixtures/address.json +0 -36
- package/src/fixtures/balance.json +0 -9
- package/src/fixtures/self-clique.json +0 -19
- package/src/fixtures/transaction.json +0 -13
- package/src/fixtures/transactions.json +0 -179
- package/src/signer/fixtures/genesis.json +0 -26
- package/src/signer/fixtures/wallets.json +0 -26
- package/src/signer/node-wallet.ts +0 -74
- package/src/test/index.ts +0 -32
- package/src/test/privatekey-wallet.ts +0 -58
- package/src/transaction/sign-verify.test.ts +0 -50
- package/src/utils/address.test.ts +0 -47
- package/src/utils/djb2.test.ts +0 -35
- package/src/utils/password-crypto.test.ts +0 -27
- package/src/utils/password-crypto.ts +0 -77
- package/src/utils/utils.test.ts +0 -161
- package/templates/base/README.md +0 -34
- package/templates/base/package.json +0 -35
- package/templates/base/src/greeter.ts +0 -41
- package/templates/base/tsconfig.json +0 -19
- package/templates/react/README.md +0 -34
- package/templates/react/config-overrides.js +0 -18
- package/templates/react/package.json +0 -66
- package/templates/react/src/App.tsx +0 -42
- package/templates/react/src/artifacts/greeter.ral.json +0 -26
- package/templates/react/src/artifacts/greeter_main.ral.json +0 -22
- package/templates/shared/.eslintrc.json +0 -12
- package/templates/shared/scripts/header.js +0 -0
- package/test/contract.test.ts +0 -197
- package/test/events.test.ts +0 -138
- package/test/transaction.test.ts +0 -72
package/.eslintignore
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
dist/
|
|
2
|
-
templates/
|
|
1
|
+
**/dist/
|
|
2
|
+
**/templates/
|
package/README.md
CHANGED
|
@@ -1,136 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@alephium/web3`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[![Code Coverage][coverage-badge]][coverage-link]
|
|
5
|
-
[![NPM][npm-badge]][npm-link]
|
|
6
|
-
[![code style: prettier][prettier-badge]][prettier-link]
|
|
7
|
-
|
|
8
|
-
A JavaScript/TypeScript library for building decentralized applications and smart contracts on Alephium.
|
|
9
|
-
|
|
10
|
-
You could run the following command to scaffold a skeleton project for smart contract development:
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
npx @alephium/web3 <project-dir> [-t template-name]
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Install
|
|
17
|
-
|
|
18
|
-
### In Node projects
|
|
19
|
-
|
|
20
|
-
```shell
|
|
21
|
-
npm install @alephium/web3
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
💥 Until our library is stable, breaking changes will be introduced in **minor** versions (instead of the traditional major versions of semver). We recommend allowing patch-level updates and to always read the [release notes][release-notes] for breaking changes.
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
// package.json
|
|
28
|
-
{
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@alephium/web3": "~X.Y.Z"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### In browser projects
|
|
36
|
-
|
|
37
|
-
All you have to do is to include the library in your HTML document. The `alephium` global variable will be available.
|
|
38
|
-
|
|
39
|
-
```html
|
|
40
|
-
<script src="alephium-web3.min.js"></script>
|
|
41
|
-
<script>
|
|
42
|
-
const { walletGenerate } = alephium
|
|
43
|
-
const wallet = walletGenerate()
|
|
44
|
-
console.log(wallet)
|
|
45
|
-
</script>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
You can either build the library by cloning this repo and running the build script (the file will be located at `/dist/alephium-web3.min.js`), or simply using a CDN.
|
|
49
|
-
|
|
50
|
-
```shell
|
|
51
|
-
npm run build
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
#### via UNPKG CDN
|
|
55
|
-
|
|
56
|
-
```html
|
|
57
|
-
<script src="https://unpkg.com/@alephium/web3@X.Y.Z/dist/alephium-web3.min.js"></script>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
#### via jsDelivr CDN
|
|
61
|
-
|
|
62
|
-
```html
|
|
63
|
-
<script src="https://cdn.jsdelivr.net/npm/@alephium/web3@X.Y.Z/dist/alephium-web3.min.js"></script>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Development
|
|
67
|
-
|
|
68
|
-
### Update schemas
|
|
69
|
-
|
|
70
|
-
One first needs to update the version number of `alephium` and `explorer-backend` in `package.json`. Kindly note that one needs to check the compatibility of both OpenAPI files manually.
|
|
71
|
-
|
|
72
|
-
Typings can automatically generated using the following command:
|
|
73
|
-
|
|
74
|
-
```shell
|
|
75
|
-
npm run update-schemas
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Packaging
|
|
79
|
-
|
|
80
|
-
We need to include the `.gitignore` file inside the npm package so that it can be used by the `dist/cli/create-project.js` script. To do that we define the `prepack` and `postpack` npm scripts that will rename the `.gitignore` file to `gitignore`, pack it into the package, and rename it back to `.gitignore`. Similar approach has been followed by `create-react-app`<sup>[1]</sup>.
|
|
81
|
-
|
|
82
|
-
### Release
|
|
83
|
-
|
|
84
|
-
To release a new version:
|
|
85
|
-
|
|
86
|
-
1. Create a commit that updates the package version in package.json and package-lock.json and a tag with:
|
|
87
|
-
```shell
|
|
88
|
-
npm version patch # if you want to bump the patch version, without breaking changes
|
|
89
|
-
npm version minor # if you want to bump the minor version, with breaking changes
|
|
90
|
-
npm version prerelease --preid=rc # if you want to create a release candidate
|
|
91
|
-
npm version prerelease --preid=leman # if you want to create a leman prerelease
|
|
92
|
-
```
|
|
93
|
-
2. Push the tag to GitHub and trigger the publish workflow that will publish it on NPM with:
|
|
94
|
-
|
|
95
|
-
```shell
|
|
96
|
-
git push [remote] <tag>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
3. Unless you are on `master`, create a new branch and push it to GitHub so that the tagged commit belongs to a branch of this repo with:
|
|
100
|
-
```shell
|
|
101
|
-
git checkout -b <tag>
|
|
102
|
-
git push
|
|
103
|
-
```
|
|
104
|
-
Otherwise, just push to `master`.
|
|
105
|
-
|
|
106
|
-
## Build
|
|
107
|
-
|
|
108
|
-
Compile the TypeScript files into JavaScript:
|
|
109
|
-
|
|
110
|
-
```shell
|
|
111
|
-
npm run build
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Testing
|
|
115
|
-
|
|
116
|
-
```shell
|
|
117
|
-
npm run start-devnet # this will start a devnet for smart contract tests
|
|
118
|
-
npm test
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
or, to watch for changes:
|
|
122
|
-
|
|
123
|
-
```shell
|
|
124
|
-
npm run test:watch
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
[test-badge]: https://github.com/alephium/alephium-web3/actions/workflows/test.yml/badge.svg
|
|
128
|
-
[test-link]: https://github.com/alephium/alephium-web3/actions/workflows/test.yml
|
|
129
|
-
[coverage-badge]: https://codecov.io/gh/alephium/alephium-web3/branch/master/graph/badge.svg
|
|
130
|
-
[coverage-link]: https://codecov.io/gh/alephium/alephium-web3
|
|
131
|
-
[npm-badge]: https://img.shields.io/npm/v/@alephium/web3.svg
|
|
132
|
-
[npm-link]: https://www.npmjs.org/package/@alephium/web3
|
|
133
|
-
[prettier-badge]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg
|
|
134
|
-
[prettier-link]: https://github.com/prettier/prettier
|
|
135
|
-
[release-notes]: https://github.com/alephium/alephium-web3/releases
|
|
136
|
-
[1]: https://github.com/facebook/create-react-app/blob/2da5517689b7510ff8d8b0148ce372782cb285d7/packages/react-scripts/scripts/init.js#L264-L278
|
|
3
|
+
The package is the core of web3 SDKs
|