create-ton
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -8,2 +8,10 @@ # Changelog | ||
## [0.4.0] - 2023-05-04 | ||
### Changed | ||
- Updated template readme | ||
- Updated template jest config to use TypeScript | ||
- Updated dependencies: blueprint to 0.9.0, sandbox to 0.10.0 | ||
## [0.3.0] - 2023-04-07 | ||
@@ -10,0 +18,0 @@ |
@@ -12,3 +12,4 @@ #!/usr/bin/env node | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const PACKAGE_JSON = 'package.json'; | ||
const FILES_WITH_NAME_TEMPLATE = ['package.json', 'README.md']; | ||
const NAME_TEMPLATE = '{{name}}'; | ||
async function main() { | ||
@@ -62,3 +63,3 @@ console.log(); | ||
for (const file of await fs_extra_1.default.readdir(basePath)) { | ||
if (file === PACKAGE_JSON) | ||
if (FILES_WITH_NAME_TEMPLATE.includes(file)) | ||
continue; | ||
@@ -71,3 +72,5 @@ await fs_extra_1.default.copy(path_1.default.join(basePath, file), path_1.default.join(name, file)); | ||
`); | ||
await fs_extra_1.default.writeFile(path_1.default.join(name, PACKAGE_JSON), (await fs_extra_1.default.readFile(path_1.default.join(basePath, PACKAGE_JSON))).toString().replace('{{name}}', name)); | ||
for (const file of FILES_WITH_NAME_TEMPLATE) { | ||
await fs_extra_1.default.writeFile(path_1.default.join(name, file), (await fs_extra_1.default.readFile(path_1.default.join(basePath, file))).toString().replace(NAME_TEMPLATE, name)); | ||
} | ||
console.log(`[2/${steps}] Installing dependencies...\n`); | ||
@@ -74,0 +77,0 @@ const execOpts = { |
@@ -9,4 +9,4 @@ { | ||
"devDependencies": { | ||
"@ton-community/blueprint": "^0.8.0", | ||
"@ton-community/sandbox": "^0.8.0", | ||
"@ton-community/blueprint": "^0.9.0", | ||
"@ton-community/sandbox": "^0.10.0", | ||
"@ton-community/test-utils": "^0.2.0", | ||
@@ -13,0 +13,0 @@ "@types/jest": "^29.5.0", |
@@ -1,76 +0,29 @@ | ||
# TON project | ||
# {{name}} | ||
Starter template for a new TON project - FunC contracts, unit tests, compilation and deployment scripts. | ||
## Project structure | ||
## Layout | ||
- `contracts` - source code of all the smart contracts of the project and their dependencies. | ||
- `wrappers` - wrapper classes (implementing `Contract` from ton-core) for the contracts, including any [de]serialization primitives and compilation functions. | ||
- `tests` - tests for the contracts. | ||
- `scripts` - scripts used by the project, mainly the deployment scripts. | ||
- `contracts` - contains the source code of all the smart contracts of the project and their dependencies. | ||
- `wrappers` - contains the wrapper classes (implementing `Contract` from ton-core) for the contracts, including any [de]serialization primitives and compilation functions. | ||
- `tests` - tests for the contracts. Would typically use the wrappers. | ||
- `scripts` - contains scripts used by the project, mainly the deployment scripts. | ||
## How to use | ||
## Repo contents / tech stack | ||
1. Compiling FunC - [https://github.com/ton-community/func-js](https://github.com/ton-community/func-js) | ||
2. Testing TON smart contracts - [https://github.com/ton-community/sandbox](https://github.com/ton-community/sandbox) | ||
3. Deployment of contracts is supported with [TON Connect 2](https://github.com/ton-connect/), [Tonhub wallet](https://tonhub.com/), using mnemonics, or via a direct `ton://` deeplink | ||
### Build | ||
## How to use | ||
* Run `npm create ton@latest` | ||
`npx blueprint build` or `yarn blueprint build` | ||
### Building a contract | ||
1. Interactively | ||
1. Run `yarn blueprint build` | ||
2. Choose the contract you'd like to build | ||
1. Non-interactively | ||
1. Run `yarn blueprint build <CONTRACT>` | ||
2. example: `yarn blueprint build pingpong` | ||
### Test | ||
### Deploying a contract | ||
1. Interactively | ||
1. Run `yarn blueprint run` | ||
2. Choose the contract you'd like to deploy | ||
3. Choose whether you're deploying on mainnet or testnet | ||
4. Choose how to deploy: | ||
1. With a TON Connect compatible wallet | ||
2. A `ton://` deep link / QR code | ||
3. Tonhub wallet | ||
4. Mnemonic | ||
5. Deploy the contract | ||
2. Non-interactively | ||
1. Run `yarn blueprint run <CONTRACT> --<NETWORK> --<DEPLOY_METHOD>` | ||
2. example: `yarn blueprint run pingpong --mainnet --tonconnect` | ||
`npx blueprint test` or `yarn blueprint test` | ||
### Testing | ||
1. Run `yarn test` | ||
### Deploy or run another script | ||
## Adding your own contract | ||
1. Run `yarn blueprint create <CONTRACT>` | ||
2. example: `yarn blueprint create MyContract` | ||
`npx blueprint run` or `yarn blueprint run` | ||
* Write code | ||
* FunC contracts are located in `contracts/*.fc` | ||
* Standalone root contracts are located in `contracts/*.fc` | ||
* Shared imports (when breaking code to multiple files) are in `contracts/imports/*.fc` | ||
* Tests in TypeScript are located in `test/*.spec.ts` | ||
* Wrapper classes for interacting with the contract are located in `wrappers/*.ts` | ||
* Any scripts (including deployers) are located in `scripts/*.ts` | ||
### Add a new contract | ||
* Build | ||
* Builder configs are located in `wrappers/*.compile.ts` | ||
* In the root repo dir, run in terminal `yarn blueprint build` | ||
* Compilation errors will appear on screen, if applicable | ||
* Resulting build artifacts include: | ||
* `build/*.compiled.json` - the binary code cell of the compiled contract (for deployment). Saved in a hex format within a json file to support webapp imports | ||
`npx blueprint create ContractName` or `yarn blueprint create ContractName` | ||
* Test | ||
* In the root repo dir, run in terminal `yarn test` | ||
* Don't forget to build (or rebuild) before running tests | ||
* Tests are running inside Node.js by running TVM in web-assembly using [sandbox](https://github.com/ton-community/sandbox) | ||
* Deploy | ||
* Run `yarn blueprint run <deployscript>` | ||
* Contracts will be rebuilt on each execution | ||
* Follow the on-screen instructions of the deploy script | ||
# License | ||
MIT |
{ | ||
"name": "create-ton", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Tool to quickly create TON projects", |
156
46800