create-ton 0.0.3

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.
@@ -0,0 +1,29 @@
1
+ import {Blockchain} from '@ton-community/sandbox'
2
+ import {Cell, toNano} from 'ton-core'
3
+ import {MyContract} from '../wrappers/MyContract'
4
+ import '@ton-community/test-utils'
5
+ import {compile} from '@ton-community/blueprint'
6
+
7
+ describe('MyContract', () => {
8
+ let code: Cell
9
+
10
+ beforeAll(async () => {
11
+ code = await compile('MyContract')
12
+ })
13
+
14
+ it('should deploy', async () => {
15
+ const blockchain = await Blockchain.create()
16
+
17
+ const myContract = blockchain.openContract(await MyContract.createFromConfig({}, code))
18
+
19
+ const deployer = await blockchain.treasury('deployer')
20
+
21
+ const deployResult = await myContract.sendDeploy(deployer.getSender(), toNano('0.05'))
22
+
23
+ expect(deployResult.transactions).toHaveTransaction({
24
+ from: deployer.address,
25
+ to: myContract.address,
26
+ deploy: true,
27
+ })
28
+ })
29
+ })
@@ -0,0 +1,5 @@
1
+ import {CompilerConfig} from '@ton-community/blueprint'
2
+
3
+ export const compile: CompilerConfig = {
4
+ targets: ['contracts/my_contract.fc'],
5
+ }
@@ -0,0 +1,36 @@
1
+ import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from "ton-core";
2
+
3
+ export type MyContractConfig = {
4
+
5
+ }
6
+
7
+ export function myContractConfigToCell(config: MyContractConfig): Cell {
8
+ return beginCell()
9
+ .endCell()
10
+ }
11
+
12
+ export class MyContract implements Contract {
13
+ constructor(
14
+ readonly address: Address,
15
+ readonly init?: { code: Cell, data: Cell },
16
+ ) {}
17
+
18
+ static createFromAddress(address: Address) {
19
+ return new MyContract(address)
20
+ }
21
+
22
+ static createFromConfig(config: MyContractConfig, code: Cell, workchain = 0) {
23
+ const data = myContractConfigToCell(config)
24
+ const init = { code, data }
25
+ return new MyContract(contractAddress(workchain, init), init)
26
+ }
27
+
28
+ async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
29
+ await provider.internal(via, {
30
+ value,
31
+ sendMode: SendMode.PAY_GAS_SEPARATLY,
32
+ body: beginCell()
33
+ .endCell(),
34
+ })
35
+ }
36
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "create-ton",
3
+ "version": "0.0.3",
4
+ "license": "MIT",
5
+ "description": "Tool to quickly create TON projects",
6
+ "author": "TonTech",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ton-community/create-ton.git"
10
+ },
11
+ "files": [
12
+ "dist/**/*"
13
+ ],
14
+ "bin": {
15
+ "create-ton": "./dist/cli.js"
16
+ },
17
+ "scripts": {
18
+ "build": "rm -rf dist && tsc && cp -r template dist/template"
19
+ },
20
+ "devDependencies": {
21
+ "@types/fs-extra": "^11.0.1",
22
+ "@types/inquirer": "^8.0.0",
23
+ "@types/node": "^18.11.18",
24
+ "prettier": "^2.8.3",
25
+ "typescript": "^4.9.5"
26
+ },
27
+ "dependencies": {
28
+ "fs-extra": "^11.1.0",
29
+ "inquirer": "^8.0.0"
30
+ }
31
+ }