create-ton
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -11,2 +11,3 @@ #!/usr/bin/env node | ||
const inquirer_1 = __importDefault(require("inquirer")); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const PACKAGE_JSON = 'package.json'; | ||
@@ -64,19 +65,31 @@ async function main() { | ||
console.log('\nInitialized git repository.\n'); | ||
console.log(`Success! | ||
Now you can run the following to run the default tests: | ||
cd ${name} | ||
npm run test | ||
You can also run the following commands in your project's directory: | ||
npx blueprint create MyContract | ||
creates all the necessary files for a new contract | ||
npx blueprint build | ||
asks you to choose a contract and builds it | ||
npx blueprint run | ||
asks you to choose a script and runs it | ||
`); | ||
console.log(`Success!`); | ||
console.log(chalk_1.default.blueBright(` | ||
____ _ _ _ _____ ____ ____ ___ _ _ _____ | ||
| __ )| | | | | | ____| _ \\| _ \\|_ _| \\ | |_ _| | ||
| _ \\| | | | | | _| | |_) | |_) || || \\| | | | | ||
| |_) | |__| |_| | |___| __/| _ < | || |\\ | | | | ||
|____/|_____\\___/|_____|_| |_| \\_\\___|_| \\_| |_| `)); | ||
console.log(chalk_1.default.blue(` TON development for professionals`)); | ||
console.log(``); | ||
console.log(`Your new project is ready, available commands:`); | ||
console.log(``); | ||
console.log(chalk_1.default.greenBright(` > `) + chalk_1.default.cyanBright(`cd ${name}`)); | ||
console.log(` change directory to your new project`); | ||
console.log(``); | ||
console.log(chalk_1.default.greenBright(` > `) + chalk_1.default.cyanBright(`npm run test`)); | ||
console.log(` run the default project test suite`); | ||
console.log(``); | ||
console.log(chalk_1.default.greenBright(` > `) + chalk_1.default.cyanBright(`npx blueprint build`)); | ||
console.log(` choose a smart contract and build it`); | ||
console.log(``); | ||
console.log(chalk_1.default.greenBright(` > `) + chalk_1.default.cyanBright(`npx blueprint run`)); | ||
console.log(` choose a script and run it (eg. a deploy script)`); | ||
console.log(``); | ||
console.log(chalk_1.default.greenBright(` > `) + chalk_1.default.cyanBright(`npx blueprint create MyNewContract`)); | ||
console.log(` create all the necessary files for a new contract`); | ||
console.log(``); | ||
console.log(`For help and docs visit https://github.com/ton-community/blueprint`); | ||
console.log(``); | ||
} | ||
main().catch(console.error); |
@@ -1,13 +0,13 @@ | ||
import {toNano} from 'ton-core' | ||
import {MyContract} from '../wrappers/MyContract' | ||
import {compile, NetworkProvider} from '@ton-community/blueprint' | ||
import { toNano } from 'ton-core'; | ||
import { MyContract } from '../wrappers/MyContract'; | ||
import { compile, NetworkProvider } from '@ton-community/blueprint'; | ||
export async function run(provider: NetworkProvider) { | ||
const myContract = MyContract.createFromConfig({}, await compile('MyContract')) | ||
const myContract = MyContract.createFromConfig({}, await compile('MyContract')); | ||
await provider.deploy(myContract, toNano('0.05')) | ||
await provider.deploy(myContract, toNano('0.05')); | ||
const openedContract = provider.open(myContract) | ||
const openedContract = provider.open(myContract); | ||
// run methods on `openedContract` | ||
} |
@@ -1,22 +0,22 @@ | ||
import {Blockchain} from '@ton-community/sandbox' | ||
import {Cell, toNano} from 'ton-core' | ||
import {MyContract} from '../wrappers/MyContract' | ||
import '@ton-community/test-utils' | ||
import {compile} from '@ton-community/blueprint' | ||
import { Blockchain } from '@ton-community/sandbox'; | ||
import { Cell, toNano } from 'ton-core'; | ||
import { MyContract } from '../wrappers/MyContract'; | ||
import '@ton-community/test-utils'; | ||
import { compile } from '@ton-community/blueprint'; | ||
describe('MyContract', () => { | ||
let code: Cell | ||
let code: Cell; | ||
beforeAll(async () => { | ||
code = await compile('MyContract') | ||
}) | ||
code = await compile('MyContract'); | ||
}); | ||
it('should deploy', async () => { | ||
const blockchain = await Blockchain.create() | ||
const blockchain = await Blockchain.create(); | ||
const myContract = blockchain.openContract(await MyContract.createFromConfig({}, code)) | ||
const myContract = blockchain.openContract(await MyContract.createFromConfig({}, code)); | ||
const deployer = await blockchain.treasury('deployer') | ||
const deployer = await blockchain.treasury('deployer'); | ||
const deployResult = await myContract.sendDeploy(deployer.getSender(), toNano('0.05')) | ||
const deployResult = await myContract.sendDeploy(deployer.getSender(), toNano('0.05')); | ||
@@ -27,4 +27,4 @@ expect(deployResult.transactions).toHaveTransaction({ | ||
deploy: true, | ||
}) | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); |
@@ -1,5 +0,5 @@ | ||
import {CompilerConfig} from '@ton-community/blueprint' | ||
import { CompilerConfig } from '@ton-community/blueprint'; | ||
export const compile: CompilerConfig = { | ||
targets: ['contracts/my_contract.fc'], | ||
} | ||
}; |
@@ -1,26 +0,20 @@ | ||
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from "ton-core"; | ||
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from 'ton-core'; | ||
export type MyContractConfig = { | ||
export type MyContractConfig = {}; | ||
} | ||
export function myContractConfigToCell(config: MyContractConfig): Cell { | ||
return beginCell() | ||
.endCell() | ||
return beginCell().endCell(); | ||
} | ||
export class MyContract implements Contract { | ||
constructor( | ||
readonly address: Address, | ||
readonly init?: { code: Cell, data: Cell }, | ||
) {} | ||
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {} | ||
static createFromAddress(address: Address) { | ||
return new MyContract(address) | ||
return new MyContract(address); | ||
} | ||
static createFromConfig(config: MyContractConfig, code: Cell, workchain = 0) { | ||
const data = myContractConfigToCell(config) | ||
const init = { code, data } | ||
return new MyContract(contractAddress(workchain, init), init) | ||
const data = myContractConfigToCell(config); | ||
const init = { code, data }; | ||
return new MyContract(contractAddress(workchain, init), init); | ||
} | ||
@@ -32,6 +26,5 @@ | ||
sendMode: SendMode.PAY_GAS_SEPARATLY, | ||
body: beginCell() | ||
.endCell(), | ||
}) | ||
body: beginCell().endCell(), | ||
}); | ||
} | ||
} | ||
} |
{ | ||
"name": "create-ton", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Tool to quickly create TON projects", |
91873
314