Skip to content

Commit c869252

Browse files
0xNeshiericglaumakiopenGianfrancoBazzaniarturoBeccar
authored
Add Stylus Contracts (#470)
Co-authored-by: Eric Lau <[email protected]> Co-authored-by: makiopen <[email protected]> Co-authored-by: GianfrancoBazzani <[email protected]> Co-authored-by: Arturo Beccar-Varela <[email protected]> Co-authored-by: Cove Marquis-Bortoli <[email protected]> Co-authored-by: immrsd <[email protected]> Co-authored-by: Boyan Barakov <[email protected]>
1 parent ba62518 commit c869252

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+5192
-7
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- solidity
2727
- cairo
2828
- stellar
29+
- stylus
2930

3031
runs-on: ubuntu-latest
3132
steps:

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ dist
22
*.tsbuildinfo
33
node_modules
44

5-
65
.env
76
.env.local
8-
.vscode/
7+
.vscode/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
"typescript-eslint": "^8.24.1",
2929
"wsrun": "^5.2.4"
3030
}
31-
}
31+
}

packages/core/stylus/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/cache
2+
/artifacts
3+
/contracts/generated
4+
/openzeppelin-contracts.json

packages/core/stylus/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 0.2.0-alpha.3 (2025-03-04)
4+
5+
- Initial version. ([#470](https://github.com/OpenZeppelin/contracts-wizard/pull/470))

packages/core/stylus/LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

packages/core/stylus/NOTICE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
OpenZeppelin Contracts Wizard
2+
Copyright (C) 2021-2025 Zeppelin Group Ltd
3+
4+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.
5+
6+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
7+
8+
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

packages/core/stylus/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# OpenZeppelin Contracts Wizard for Stylus
2+
3+
Interactively build a contract out of components from OpenZeppelin Contracts for Stylus. Provide parameters and desired features for the kind of contract that you want, and the Wizard will generate all of the code necessary. The resulting code is ready to be compiled and deployed, or it can serve as a starting point and customized further with application specific logic.
4+
5+
This package provides a programmatic API. For a web interface, see https://wizard.openzeppelin.com/stylus
6+
7+
### Installation
8+
9+
`npm install @openzeppelin/wizard-stylus`
10+
11+
### Contract types
12+
13+
The following contract types are supported:
14+
- `erc20`
15+
- `erc721`
16+
- `erc1155`
17+
18+
Each contract type has functions/constants as defined below.
19+
20+
### Functions
21+
22+
#### `print`
23+
```js
24+
function print(opts?: ERC20Options): string
25+
```
26+
```js
27+
function print(opts?: ERC721Options): string
28+
```
29+
```js
30+
function print(opts?: ERC1155Options): string
31+
```
32+
Returns a string representation of a contract generated using the provided options. If `opts` is not provided, uses [`defaults`](#defaults).
33+
34+
#### `defaults`
35+
```js
36+
const defaults: Required<ERC20Options>
37+
```
38+
```js
39+
const defaults: Required<ERC721Options>
40+
```
41+
```js
42+
const defaults: Required<ERC1155Options>
43+
```
44+
The default options that are used for [`print`](#print).
45+
46+
#### `isAccessControlRequired`
47+
```js
48+
function isAccessControlRequired(opts: Partial<ERC20Options>): boolean
49+
```
50+
```js
51+
function isAccessControlRequired(opts: Partial<ERC721Options>): boolean
52+
```
53+
```js
54+
function isAccessControlRequired(opts: Partial<ERC1155Options>): boolean
55+
```
56+
Whether any of the provided options require access control to be enabled. If this returns `true`, then calling `print` with the same options would cause the `access` option to default to `'ownable'` if it was `undefined` or `false`.
57+
58+
### Examples
59+
60+
Import the contract type(s) (for example, `erc20`) that you want to use from the `@openzeppelin/wizard-stylus` package:
61+
62+
```js
63+
import { erc20 } from '@openzeppelin/wizard-stylus';
64+
```
65+
66+
To generate the source code for an ERC20 contract with all of the default settings:
67+
```js
68+
const contract = erc20.print();
69+
```
70+
71+
To generate the source code for an ERC20 contract with some custom settings:
72+
```js
73+
const contract = erc20.print({
74+
name: 'ExampleToken',
75+
flashmint: true,
76+
permit: false,
77+
});
78+
```
79+
80+
To generate the source code for an ERC20 contract with all of the defaults but is burnable:
81+
```js
82+
const contract = erc20.print({
83+
...erc20.defaults,
84+
burnable: true,
85+
});
86+
```

packages/core/stylus/ava.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
extensions: ['ts'],
3+
require: ['ts-node/register'],
4+
watchmode: {
5+
ignoreChanges: ['contracts', 'artifacts', 'cache'],
6+
},
7+
timeout: '10m',
8+
workerThreads: false,
9+
};

packages/core/stylus/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@openzeppelin/wizard-stylus",
3+
"version": "0.2.0-alpha.3",
4+
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Stylus",
5+
"license": "AGPL-3.0-only",
6+
"repository": "https://github.com/OpenZeppelin/contracts-wizard",
7+
"main": "dist/index.js",
8+
"ts:main": "src/index.ts",
9+
"files": [
10+
"LICENSE",
11+
"NOTICE",
12+
"/dist",
13+
"/src",
14+
"!**/*.test.*"
15+
],
16+
"scripts": {
17+
"prepare": "tsc",
18+
"prepublish": "rimraf dist *.tsbuildinfo",
19+
"test": "ava",
20+
"test:watch": "ava --watch",
21+
"version": "node ../../../scripts/bump-changelog.js"
22+
},
23+
"devDependencies": {
24+
"@types/node": "^18.0.0",
25+
"@types/semver": "^7.5.7",
26+
"ava": "^6.0.0",
27+
"rimraf": "^5.0.0",
28+
"ts-node": "^10.4.0",
29+
"typescript": "^5.0.0",
30+
"semver": "^7.6.0"
31+
}
32+
}

0 commit comments

Comments
 (0)