@alephium/web3 0.2.0-rc.6 → 0.2.0-rc.9

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.
Files changed (83) hide show
  1. package/.eslintignore +2 -2
  2. package/README.md +2 -135
  3. package/contracts/greeter/greeter.ral +1 -1
  4. package/dist/alephium-web3.min.js +1 -1
  5. package/dist/alephium-web3.min.js.LICENSE.txt +0 -17
  6. package/dist/alephium-web3.min.js.map +1 -1
  7. package/dist/scripts/create-project.js +1 -1
  8. package/dist/src/api/api-alephium.d.ts +19 -6
  9. package/dist/src/api/api-explorer.d.ts +16 -16
  10. package/dist/src/api/index.js +5 -1
  11. package/dist/src/contract/contract.d.ts +27 -10
  12. package/dist/src/contract/contract.js +105 -64
  13. package/dist/src/contract/index.js +5 -1
  14. package/dist/src/global.d.ts +3 -0
  15. package/{src/utils/djb2.test.ts → dist/src/global.js} +20 -17
  16. package/dist/src/index.d.ts +2 -0
  17. package/dist/src/index.js +20 -1
  18. package/dist/src/signer/index.d.ts +0 -1
  19. package/dist/src/signer/index.js +5 -2
  20. package/dist/src/signer/signer.d.ts +1 -1
  21. package/dist/src/signer/signer.js +8 -3
  22. package/dist/src/transaction/index.d.ts +0 -1
  23. package/dist/src/transaction/index.js +5 -2
  24. package/dist/src/utils/index.d.ts +0 -1
  25. package/dist/src/utils/index.js +5 -2
  26. package/dist/src/utils/subscription.d.ts +0 -1
  27. package/dist/src/utils/subscription.js +2 -1
  28. package/dist/src/utils/utils.d.ts +3 -2
  29. package/dist/src/utils/utils.js +16 -15
  30. package/jest-config.json +11 -0
  31. package/package.json +6 -32
  32. package/scripts/create-project.ts +1 -1
  33. package/src/api/api-alephium.ts +14 -0
  34. package/src/contract/contract.ts +157 -69
  35. package/src/{test/index.ts → global.ts} +14 -10
  36. package/src/index.ts +3 -0
  37. package/src/signer/index.ts +0 -1
  38. package/src/signer/signer.ts +3 -2
  39. package/src/transaction/index.ts +0 -1
  40. package/src/utils/index.ts +0 -1
  41. package/src/utils/subscription.ts +2 -2
  42. package/src/utils/utils.ts +7 -7
  43. package/templates/base/package.json +2 -2
  44. package/templates/base/src/greeter.ts +8 -7
  45. package/templates/react/package.json +2 -2
  46. package/templates/react/src/App.tsx +2 -2
  47. package/.eslintrc.json +0 -21
  48. package/LICENSE +0 -165
  49. package/contracts/add/add.ral +0 -13
  50. package/contracts/main.ral +0 -4
  51. package/contracts/sub/sub.ral +0 -10
  52. package/contracts/test/metadata.ral +0 -18
  53. package/contracts/test/warnings.ral +0 -8
  54. package/dist/src/signer/node-wallet.d.ts +0 -13
  55. package/dist/src/signer/node-wallet.js +0 -60
  56. package/dist/src/test/index.d.ts +0 -7
  57. package/dist/src/test/index.js +0 -41
  58. package/dist/src/test/privatekey-wallet.d.ts +0 -12
  59. package/dist/src/test/privatekey-wallet.js +0 -68
  60. package/dist/src/transaction/sign-verify.d.ts +0 -2
  61. package/dist/src/transaction/sign-verify.js +0 -58
  62. package/dist/src/utils/password-crypto.d.ts +0 -2
  63. package/dist/src/utils/password-crypto.js +0 -69
  64. package/gitignore +0 -9
  65. package/src/contract/ralph.test.ts +0 -178
  66. package/src/fixtures/address.json +0 -36
  67. package/src/fixtures/balance.json +0 -9
  68. package/src/fixtures/self-clique.json +0 -19
  69. package/src/fixtures/transaction.json +0 -13
  70. package/src/fixtures/transactions.json +0 -179
  71. package/src/signer/fixtures/genesis.json +0 -26
  72. package/src/signer/fixtures/wallets.json +0 -26
  73. package/src/signer/node-wallet.ts +0 -74
  74. package/src/test/privatekey-wallet.ts +0 -58
  75. package/src/transaction/sign-verify.test.ts +0 -50
  76. package/src/transaction/sign-verify.ts +0 -39
  77. package/src/utils/address.test.ts +0 -47
  78. package/src/utils/password-crypto.test.ts +0 -27
  79. package/src/utils/password-crypto.ts +0 -77
  80. package/src/utils/utils.test.ts +0 -161
  81. package/test/contract.test.ts +0 -213
  82. package/test/events.test.ts +0 -143
  83. package/test/transaction.test.ts +0 -74
package/.eslintignore CHANGED
@@ -1,2 +1,2 @@
1
- dist/
2
- templates/
1
+ **/dist/
2
+ **/templates/
package/README.md CHANGED
@@ -1,136 +1,3 @@
1
- # Alephium Web3
1
+ # `@alephium/web3`
2
2
 
3
- [![Github CI][test-badge]][test-link]
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
@@ -1,7 +1,7 @@
1
1
  Contract Greeter(btcPrice: U256) implements GreeterInterface {
2
2
  @using(readonly = true)
3
3
  pub fn greet() -> U256 {
4
- checkPermission!(true, 0)
4
+ checkCaller!(true, 0)
5
5
  return btcPrice
6
6
  }
7
7
  }