Giter Club home page Giter Club logo

blueprint's Introduction

Blueprint

A development environment for TON blockchain for writing, testing, and deploying smart contracts.

Table of Contents

Quick start 🚀

Run the command in terminal to create a new project and follow the on-screen instructions:

npm create ton@latest

Overview

Blueprint is an all-in-one development environment designed to enhance the process of creating, testing, and deploying smart contracts on TON blockchain using FunC and Tact languages

Core features

  • Create a development environment from template - npm create ton@latest
  • Streamlined workflow for building, testing and deploying smart contracts
  • Dead simple deployment to mainnet/testnet using your favorite wallet (eg. Tonkeeper)
  • Blazing fast testing of multiple smart contracts in an isolated blockchain running in-process

Tech stack

  1. Compiling FunC with https://github.com/ton-community/func-js
  2. Compiling Tact with https://github.com/tact-lang/tact
  3. Testing smart contracts with https://github.com/ton-org/sandbox
  4. Deploying smart contracts with TON Connect 2, Tonhub wallet or a ton:// deeplink

Requirements

Features overview

Project creation

  1. Run and follow the on-screen instructions:   npm create ton@latest   or   npx create-ton@latest
  2. From the project directory run   npm/yarn install   to install dependencies

Directory structure

  • contracts/ - Source code in FunC or Tact for all smart contracts and their imports
  • wrappers/ - TypeScript interface classes for all contracts (implementing Contract from @ton/core)
    • include message [de]serialization primitives, getter wrappers and compilation functions
    • used by the test suite and client code to interact with the contracts from TypeScript
  • compilables/ - Compilations scripts for contracts
  • tests/ - TypeScript test suite for all contracts (relying on Sandbox for in-process tests)
  • scripts/ - Deployment scripts to mainnet/testnet and other scripts interacting with live contracts
  • build/ - Compilation artifacts created here after running a build command

Building contracts

  1. You need a compilation script in compilables/<CONTRACT>.compile.ts - example
  2. Run interactive:    npx blueprint build   or   yarn blueprint build
  3. Non-interactive:   npx/yarn blueprint build <CONTRACT>   OR build all contracts   yarn blueprint build --all
    • Example: yarn blueprint build counter
  4. Build results are generated in build/<CONTRACT>.compiled.json
  5. Tact generated files are located in build/<CONTRACT> directory

Running the test suites

  1. Run in terminal:   npx blueprint test   or   yarn blueprint test
  2. Alternative method:   npm test   or   yarn test
  3. You can specify test file to run:   npm/yarn test <CONTRACT>
    • Example: yarn test counter

Learn more about writing tests from the Sandbox's documentation - here.

Deploying contracts

  1. You need a deployment script in scripts/deploy<CONTRACT>.ts - example
  2. Run interactive:    npx blueprint run   or   yarn blueprint run
  3. Non-interactive:   npx/yarn blueprint run deploy<CONTRACT> --<NETWORK> --<DEPLOY_METHOD>
    • Example: yarn blueprint run deployCounter --mainnet --tonconnect

Custom scripts

  1. Custom scripts should be located in scripts folder
  2. Script file must have exported function run
export async function run(provider: NetworkProvider) {
  // 
}
  1. Script can be run using npx/yarn blueprint run <SCRIPT> command

Updating FunC version

FunC version can be updated using npx/yarn blueprint set func command

Help and additional commands

Run in terminal:   npx blueprint help   or   yarn blueprint help

Contract development

Before developing, make sure that your current working directory is located in the root of the project created using npm create ton@latest

Creating contracts

  1. Run interactive:    npx blueprint create   or   yarn blueprint create
  2. Non-interactive:   npx/yarn blueprint create <CONTRACT> --type <TYPE> (type can be func-empty, func-counter, tact-empty, tact-counter)
    • Example: yarn blueprint create MyNewContract --type func-empty

Writing contract code

FunC

  1. Implement the standalone FunC root contract in contracts/<CONTRACT>.fc
  2. Implement shared FunC imports (if breaking code to multiple files) in contracts/imports/*.fc
  3. Implement wrapper TypeScript class in wrappers/<CONTRACT>.ts to encode messages and decode getters

Tact

  1. Implement tact contract in contracts/<CONTRACT>.tact
  2. Wrappers will be automatically generated in build/<CONTRACT>/tact_<CONTRACT>.ts

Testing contracts

  1. Implement TypeScript tests in tests/<CONTRACT>.spec.ts
  2. Rely on the wrapper TypeScript class from wrappers/<CONTRACT>.ts to interact with the contract

Learn more about writing tests from the Sandbox's documentation - here.

Configuration

A config may be created in order to control some of blueprint's features. If a config is needed, create a blueprint.config.ts file in the root of your project with something like this:

import { Config } from '@ton/blueprint';

export const config: Config = {
    // config contents
};

It is important that the config is exported, is named config, and is not default exported.

Config's features are explained below.

Plugins

Blueprint has a plugin system to allow the community to develop their own additions for the ecosystem without the need to change blueprint's code.

In order to use plugins, add a plugins array to your config:

import { Config } from '@ton/blueprint';
import { ScaffoldPlugin } from 'blueprint-scaffold';

export const config: Config = {
    plugins: [new ScaffoldPlugin()],
};

(This example shows how to add the scaffold plugin)

Here are some of the plugins developed by the community:

  • scaffold - allows developers to quickly create a simple dapp automatically using the wrappers' code

Custom network

A custom network may be specified by using the --custom flags, which you can read about by running blueprint help run, but it can be tiresome to use these at all times. Instead, to specify a custom network to always be used (unless --custom flags are present), add a network object to your config:

import { Config } from '@ton/blueprint';

export const config: Config = {
    network: {
        endpoint: 'https://toncenter.com/api/v2/jsonRPC',
        type: 'mainnet',
        version: 'v2',
        key: 'YOUR_API_KEY',
    },
};

The above config parameters are equivalent to the arguments in the following command:

npx blueprint run --custom https://toncenter.com/api/v2/jsonRPC --custom-version v2 --custom-type mainnet --custom-key YOUR_API_KEY

Properties of the network object have the same semantics as the --custom flags with respective names (see blueprint help run).

You can also use custom network to verify contracts, like so:

npx blueprint verify --custom https://toncenter.com/api/v2/jsonRPC --custom-version v2 --custom-type mainnet --custom-key YOUR_API_KEY

(or similarly using the config), however custom type MUST be specified as either mainnet or testnet when verifying.

Contributors

Special thanks to @qdevstudio for their logo for blueprint.

License

MIT

Donations

TON - EQAQR1d1Q4NaE5EefwUMdrr1QvXg-8mDB0XI2-fwDBD0nYxC

blueprint's People

Contributors

1ixi1 avatar a-bahdanau avatar anton-trunov avatar arterialist avatar braveltd avatar gusarich avatar ikardanoff avatar jokly avatar kardanovir avatar krigga avatar naltox avatar novusnota avatar pixelplex avatar reveloper avatar talkol avatar thekiba avatar trinketer22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blueprint's Issues

problem with build to ts

I don't know if it's related to the blueprint, but I think it is. After building my contract, everything goes well and so does the deployment.

I want to send an address to a function (I tried also to send to simple functions, just empty ones that take an address as an argumentnet).

Function in contract:

get fun ContractPatient(owner: Address): Address
    {
        return contractAddress(initOf Patient(myAddress(),owner));
    }

In react js , vite:

     const patient = useAsyncInitialize(async () =>
    {
        if (!patientsContract || !client) return;
        console.log(patientsContract);

        const addr = await patientsContract.getContractPatient(
            Address.parse(wallet)
        )

        return client.open(Patient.fromAddress(addr))
    }, [patientsContract, client])

And I get the following error, what could this be related to?

Uncaught (in promise) Error: Invalid address. Got EQD47c2WNNyLqSVPS0-x6DiAjWx1EzB_FVqwSThYKeI2Fe34
    at BitBuilder.writeAddress (BitBuilder.js:266:15)
    at _Builder.storeAddress (Builder.js:237:20)
    at TupleBuilder.writeAddress (builder.js:102:80)
    at Patients.getContractPatient (tact_Patients.ts:711:17)
    at Proxy.<anonymous> (openContract.js:38:47)
    at useIntegrationContract.js:29:45
    at useAsyncInitialize.js:11:28
    at useAsyncInitialize.js:12:11
    at commitHookEffectListMount (react-dom_client.js:24344:34)
    at commitPassiveMountOnFiber (react-dom_client.js:25592:19)

I'm using JS. Blueprint test < it's OK! Example (Success.)

it('reg', async () =>
    {
        const message: Registration =
        {
            $$type: 'Registration',
            address: deployer.address.toString()
        }

        await patients.send(deployer.getSender(),
            {
                value: toNano("0.5")
            }, message);

        const addressContract = await patients.getContractPatient(deployer.address);
        const patient = blockchain.openContract(Patient.fromAddress(addressContract));

        console.log((await patient.getAllDocs()).values());
        expect((await patient.getAllDocs()).values().length === 0);
    });

I try

I also have a method that returns String. Blueprint test is ok. There is an error on the client again, analog Map. I think have problem with compile to TS after blueprint build

Uncaught (in promise) Error: Not a cell: null
    at _TupleReader.readCell (reader.js:101:19)
    at _TupleReader.readString (reader.js:157:22)
    at Patient.getAllDocs (tact_Patient.ts:724:29)
    at async onClick (App.tsx:44:32)

Add increaseCounter script example to Counter template

scripts/increaseCounter.ts

export async function run(provider: NetworkProvider) {
  const addrString = await provider.ui().input('enter address');
  const counter = provider.open(Counter.createFromAddress(Address.parse(addrString)));

  await counter.sendIncrease(provider.sender(), {
    increaseBy: 1,
    value: toNano('0.05')
  })
}

Tact compiler options support

I come across a problem: I needed to see tact's dump results testing a contract build through blueprint. I've noticied that there is no support for tact's options so i've created a PR to add this. #49

[feat] Add option to choose test target in `npx blueprint test`

Background

Currently npx blueprint build allows for specifying a build target. However for npx blueprint test, it's not possible to specify only 1 file to test, so every time all tests are run which is unnecessarily time-consuming in a large project.

Proposed solution

Make the syntax of npx blueprint build and npx blueprint test consistent:

  • npx blueprint test displays the chooser of all files in ./tests folder
  • npx blueprint test --all runs all tests.
  • npx blueprint test [target] runs only the specified test.

Adding the cases for contract name not in "PascalCase"

image

As you can see, if the user type in smallCase for contract name. Will get error but didn't fallback a new notification.

Maybe can adding this to ask user type in Contract Name again and asked to follow with PascalCase

Move deploy and contract creation to beforeEach()

It would make more sense that the test template creates the contract within a beforeEach hook instead of a separate test, because most tests would need a deployed contract ready to use.

describe('MyContract', () => {
    let code: Cell;
    let contract: OpenedContract<MyContract>;
    let blockchain: Blockchain;

    beforeAll(async () => {
        code = await compile('MyContract');
    });

    beforeEach(async () => {
        blockchain = await Blockchain.create();
        contract = blockchain.openContract(
            MyContract.createFromConfig({}, code)
        );
        const deployer = await blockchain.treasury('deployer');
        const deployResult = await replayAttack.sendDeploy(deployer.getSender(), toNano('0.05'));

        expect(deployResult.transactions).toHaveTransaction({
            from: deployer.address,
            to: replayAttack.address,
            deploy: true,
        });
    });

...

Tact imports don't work

code:

import "@stdlib/ownable";
import "@stdlib/stoppable";
import "./imports/messages";

const day: Int = (24 * 60 * 60);
const year: Int =  24 * 60 * 60 * 365;
...

When running

npx blueprint build

Get this error:
Error: Could not resolve import ./imports/messages
I think the problem is with the blueprint framework since file exists and is located properly

[Tact] The `external` syntax not support in blueprint.

once I compile the code will get this error:
image

And the way to solve in Tact repo will be like this in example: User can set the parameter in tact.config.json file to let compiler support with external words.

For example here: https://github.com/tact-lang/tact-template/blob/main/tact.config.json
{ "projects": [{ "name": "sample", "path": "./sources/contract.tact", "output": "./sources/output", "options":{ "external": true } }] }

hope can support this in Blueprint @tact language. Thanks.

Error position is incorrect when tests fail

If a test fails, the error line and column is wrong and the displayed source code shows the incorrect snippet from the file.

It looks like that there is a problem with source map or ts-jest, but I can't figure out a solution to fix it.

To recreate the error, create an example project, create a contract based on the counter template, then add an artificial error to one of the tests and run yarn blueprint test. I added throw new Error(); to the first line of should increase counter test case and here is the output that I get:

yarn run v1.22.19
$ /Users/x/Desktop/example/node_modules/.bin/blueprint test

> [email protected] test
> jest

 FAIL  tests/HelloWorld.spec.ts
  HelloWorld
    ✓ should deploy (1326 ms)
    ✕ should increase counter (1 ms)

  ● HelloWorld › should increase counter



      26 |
      27 |         const deployer = await blockchain.treasury('deployer');
    > 28 |
         | ^
      29 |         const deployResult = await helloWorld.sendDeploy(deployer.getSender(), toNano('0.05'));
      30 |
      31 |         expect(deployResult.transactions).toHaveTransaction({

      at Object.<anonymous> (tests/HelloWorld.spec.ts:28:15)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 passed, 2 total
Snapshots:   0 total
Time:        4.514 s, estimated 6 s
Ran all test suites.
Error: Command failed: npm test
    at checkExecSyncError (node:child_process:841:11)
    at execSync (node:child_process:912:15)
    at test (/Users/x/Desktop/example/node_modules/@ton-community/blueprint/dist/cli/test.js:7:34)
    at main (/Users/x/Desktop/example/node_modules/@ton-community/blueprint/dist/cli/cli.js:36:11)
    at Object.<anonymous> (/Users/x/Desktop/example/node_modules/@ton-community/blueprint/dist/cli/cli.js:41:1)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 57761,
  stdout: null,
  stderr: null
}
✨  Done in 6.46s.

Tact code auto-generate the TS module implement in Blueprint

Currently, if you run yarn build in the Tact project, you can get the TS module directly. There's no need to write it yourself.

https://github.com/howardpen9/nft-template-in-tact/tree/tutorial/sources

For me, the current blueprint should also implement this, as it can significantly reduce the unnecessary time spent coding to set up those modules, especially in the FunC current template.

You can find references here about how other projects have solved this by using Blueprint in the Tact language.

https://github.com/Ton-Dynasty/tondynasty-contracts

[Feature] Implement non-interactive project creating.

Right now we use npx create ton@latest, then define project folder and first created contract name and type of contract...

This is interactive, but we can make it non-interactive.

For example:

NextJS:
pnpm create next-app - template for nextjs. reference
non-interactive way - pnpm create next-app myProjectFolder --ts --use-pnpm
React: (create-react-app)
'npx create-react-app myProjectFolder'

Can be in blueprint

pnpm create ton@latest myProjectFolder --func --empty reference
Where:
myProjectFolder - stands for Project name
--func - stands for Func contract
--empty - stands for An empty contract

Using mnemonic to connect your wallets

I was trying to deploy my smart contract using mnemonic but I was not able to find any reference or README on what should I set the values of WALLET_MNEMONIC and WALLET_VERSION variables in system env, So as I was using v4 wallet I am creating this issue to share what to put inside WALLET_VERSION's value.

make sure you set "v4" and your seed words should be separated with spaces inside WALLET_MNEMONIC.

Hope this can be helpful to some people.

Something like this:
image

empty contract naming handling

when running "npm create ton"
If I know I'll be using the "Empty contract" choice for a contract called "MultiSig",
the CLI tool should ask what's the contract name, and all files and classes should adhere to that.
Otherwise it's a hassle to go and rename everything.

Deploy contract on mainnet failed

Despite increasing to attempts and sleepDuration
I see the same error

Error: Contract was not deployed. Check your wallet's transactions

await round.sendDeploy(provider.sender(), toNano('0.05'));
await provider.waitForDeploy(round.address, 50, 2500);

ERROR: create project

┌──(fake㉿errData)-[~/go/src/github.com/hatersduck]
└─$ npm -v               
10.2.4
                                                                                
┌──(fake㉿errData)-[~/go/src/github.com/hatersduck]
└─$ node -v
v20.11.1
                                                                                
┌──(fake㉿errData)-[~/go/src/github.com/hatersduck]
└─$ npm create ton@latest

? Project name Re
? First created contract name (PascalCase) Count
? Choose the project template An empty contract (FunC)

[1/3] Copying files...
[2/3] Installing dependencies...

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @ton/[email protected]
npm ERR! node_modules/@ton/core
npm ERR!   dev @ton/core@"^0.53.0" from the root project
npm ERR!   peer @ton/core@">=0.49.2" from @ton/[email protected]
npm ERR!   node_modules/@ton/blueprint
npm ERR!     dev @ton/blueprint@"^0.15.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @ton/core@">=0.56.0" from @ton/[email protected]
npm ERR! node_modules/@ton/ton
npm ERR!   dev @ton/ton@"^13.9.0" from the root project
npm ERR!   peer @ton/ton@">=13.4.1" from @ton/[email protected]
npm ERR!   node_modules/@ton/blueprint
npm ERR!     dev @ton/blueprint@"^0.15.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /home/fake/.npm/_logs/2024-02-24T13_14_23_170Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /home/fake/.npm/_logs/2024-02-24T13_14_23_170Z-debug-0.log
Error: Command failed: npm install
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at main (/home/fake/.npm/_npx/b56225140edd990c/node_modules/create-ton/dist/cli.js:103:42) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 10732,
  stdout: null,
  stderr: null
}

Using npm create creates project from legacy repo

I've noticed that this repo migrated to a @ton/... namespace like other repos and the old one no longer receives updates, but using

npm create ton@latest

creates a project using legacy repos:

"devDependencies": {
	"@ton-community/blueprint": "^0.12.0",
	"@ton-community/sandbox": "^0.11.0",
	"@ton-community/test-utils": "^0.3.0",
	"@types/jest": "^29.5.0",
	"@types/node": "^20.2.5",
	"jest": "^29.5.0",
	"prettier": "^2.8.6",
	"ton": "~13.6.0",
	"ton-core": "^0.51.0",
	"ton-crypto": "^3.2.0",
	"ts-jest": "^29.0.5",
	"ts-node": "^10.9.1",
	"typescript": "^4.9.5"
}

TON-Connect-SDK bridge requests don't work

I am running npx blueprint run command in vs code terminal (bash)
Choose the script, testnet, pick TON Connect compatible mobile wallet (Tonkeeper), get this:

Connected to wallet at address: EQAXUIBw-EDVtnCxd65Z2M21KTDr07RoBL6BYf-TBCd6dYvk

Sending transaction. Approve in your wallet...[TON_CONNECT_SDK] Send http-bridge request: {
method: 'sendTransaction',
params: [
'{"messages":[{"address":"EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c","amount":"20000000","payload":"te6cckEBAwEARgABMQAAAAEAAAGJ1Dnp6QAAAAAAAAAAQDRzvAgBAUOAAuoQDh8IGrbOFi71yzsZtqUmHXp2jQCX0Cw/8mCE706wAgAGMTIzk9o5cw=="}],"valid_until":1691483012556,"from":"0:17508070f840d5b670b177ae59d8cdb52930ebd3b46804be8161ff9304277a75","network":"-3"}'
],
id: '70'
}

But nothing happens.
I've checked it connects to the right wallet.

Relative Tact's import don't work

relative imports don't work. Error: Could not resolve import ../imports/messages.tact
When i have given structure:

root/
--imports/
----messages.tact
--jetton/
----jetton_master.tact

and with this compile configs:

export const compile: CompilerConfig = {
    lang: 'tact',
    target: 'root/jetton/jetton_master.tact',
    options: {
        debug: false,
    },
};

linked issue: #51

bug: memory leak

When compiling a large project using npx blueprint build --all, the following error occurs:

(node:3805163) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

The error does not happen if each component is built separately.

Improvements Request

  1. To make integration with IDE https://github.com/ton-org/create-ton/blob/main/src/cli.ts must allow --contractName and --type to be specified in command line arguments

After working on the blueprint, there are several minor requests:

  1. Create an enum ExitCodes with standard TVM error codes.

  2. Allow using v4r2 for the wallet version in the .env file (currently, it's not obvious that v4 alone is insufficient).

  3. Since TonHub has integrated TonConnect, it is possible to exclude TonHub separately from the deployment methods.

  4. It is highly desirable for the toHaveTransaction method to return the transaction itself or provide another way to find a transaction based on its parameters. For example, sometimes we only know that value < 1 ton, and it's currently difficult to perform such checks.

It can be public method findTransactions(filter): Transaction[] that used by toHaveTransaction

  1. During the testing of the vesting wallet, we wrote code for externals. Please include it in the standard distribution. https://github.com/ton-blockchain/vesting-contract

Error while using Approve in your wallet option for scripts for write operations on chain

Whenever I try to use blueprint ts scripts to perform actions using the option
TON Connect compatible mobile wallet (example: Tonkeeper)

Requests for txs are not being displayed on TONKeeper, but read only operations are performed without any hiccups

Is there anything which I can do to resolve this?
I usually give up after 3 tries, and scan the code for tx and perform the action manually

Deploy to minnet return 500.

I'm trying to upload to minetest. I get an error of '500 Internal Error'. When you deploy to testnet, everything works.
blueprint 0.15.0
I use the standard deployment script.

Unable to resolve certain dependency during project creation

  1. Run interactive project builder
npm create ton@latest 
  1. Provide name & first contract name
  2. Error occurred

Output:

[1/3] Copying files...
[2/3] Installing dependencies...

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/ton-core
npm ERR!   dev ton-core@"^0.49.0" from the root project
npm ERR!   peer ton-core@">=0.48.0" from @ton-community/[email protected]
npm ERR!   node_modules/@ton-community/blueprint
npm ERR!     dev @ton-community/blueprint@"^0.12.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer ton-core@">=0.51.0" from [email protected]
npm ERR! node_modules/ton
npm ERR!   dev ton@"^13.4.1" from the root project
npm ERR!   peer ton@">=13.4.1" from @ton-community/[email protected]
npm ERR!   node_modules/@ton-community/blueprint
npm ERR!     dev @ton-community/blueprint@"^0.12.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/stragner/.npm/_logs/2023-08-20T17_01_01_699Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/stragner/.npm/_logs/2023-08-20T17_01_01_699Z-debug-0.log
Error: Command failed: npm install
    at checkExecSyncError (node:child_process:885:11)
    at execSync (node:child_process:957:15)
    at main (/Users/stragner/.npm/_npx/b56225140edd990c/node_modules/create-ton/dist/cli.js:97:42) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 19504,
  stdout: null,
  stderr: null
}

`Proveder.internal` dosen't send txn for wallet approvel

Code example:

import { Address, toNano } from "ton-core";
import { NetworkProvider } from "@ton-community/blueprint";

export async function run(network: NetworkProvider) {
  const provider = network.provider(Address.parse("EQCsRPdF0OBVT9PqMuYIF9GQSoJjxTVEt1CyEYt2lDiofL9P"));
  const sender = network.sender();

  let args = {
    value: toNano("0.05"),
  };

  provider.internal(sender, args);
}

Console log:

yarn deploy
yarn run v1.22.19
$ cd src && blueprint run
? Choose file to use 
? Choose file to use test
? Which network do you want to use? 
  mainnet 
? Which network do you want to use? testnet
? Which wallet are you using? (Use arrow keys)
❯ TON Connect compatible mobile wallet (example: Tonkeeper) 
? Which wallet are you using? TON Connect compatible mobile wallet (example: Tonkeeper)
Connected to wallet at address: EQBqZ484AjxqZ3GeRr7nEGA4a-7ig3U9X44P2fwX2_uz7Yyb
Sending transaction. Approve in your wallet...

✨  Done in 10.87s.

On Sending transaction. Approve in your wallet... txn should appear in Tonkeeper wallet but does not appear and the script ends automatically without waiting for confirmation. The same thing with the TonHub wallet.

Version: 0.2.0

Deploy command fails when use testnet

Hi. Thanks for great work of team of this project! But there is a issue, when I deploy to testnet.

OS: MacOS
Node: v16.15.1

  1. yarn blueprint run
  2. Choose file to use deployCollection
  3. Which network do you want to use? testnet
  4. Which wallet are you using? TON Connect compatible mobile wallet (example: Tonkeeper)
  5. Choose your wallet Tonkeeper

I see QR, and scan it (of course before I have switched Tonkeeper to Testnet). After that I see error in console:

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open '/<my project root>/temp/testnet/tonconnect/ton-connect-storage_http-bridge-gateway::https:/bridge.tonapi.io/bridge'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/<my project root>/temp/testnet/tonconnect/ton-connect-storage_http-bridge-gateway::https:/bridge.tonapi.io/bridge'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

As I see, /<my project root>/temp/testnet/tonconnect directory is always empty.

Thanks for your help.

Error in accessing network config while running deploy scripts

It looks like that when running a script (in the scripts folder), if your script tries to access network config, it will fail.

I asked about this on the dev chat, and as I understand, the lite-client doesn't have this ability too. Maybe blueprint is using lite-client under the hood, and the root of the problem is there.

Anyway, I think it's very handy and useful to be able to access network config in scripts.

Support for Tact v1.2.0

Would be great if you could also update the counter template to use the += operator which is available since Tact v1.2.0 (it's available on NPM now):

    receive(msg: Add) {
        self.counter += msg.amount;
    }

debug support

It would be great if there was a way to pass the debug: true option to tact, so that you could use dump in contracts to aid debugging.

[feature request] - FunC wrapper's code generator

The biggest challenge to implement this is messages structures. We can implement the storage structure and message structure in the contract configuration file or a separate file.

counter.json

{
    "name" : "Counter",
    "storage": {
        "counter" : {
            "type" : "uint",
            "size" : "64"
        }
    },
    "messages" : [{
        "name" : "Add",
        "op_code" : "0x1",
        "body" : {
            "amount" : {
                "type" : "uint",
                "size" : "64"
            }
        }
    }],
}

Getting `Cannot read properties of undefined (reading 'v4-testnet')` Error

Hello!
I am getting Cannot read properties of undefined (reading 'v4-testnet') error each time I run npx blueprint run contract --testnet --mnemonic

I don't know why it is happening. I think something is wrong with the json response which does not contain 'v4-testnet' key but when I open the ton-access v4 endpoint url manually I see it there.

Errors occurred while creating a new project.

npm create ton@latest or npx create-ton@latest.

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@tonconnect%2fsdk - Not found
npm ERR! 404
npm ERR! 404 '@tonconnect/sdk@^2.1.3' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2023-07-14T21_12_49_239Z-debug-0.log
Error: Command failed: npm install
at checkExecSyncError (node:child_process:885:11)
at execSync (node:child_process:957:15)
at main (/Users/mac/.npm/_npx/b56225140edd990c/node_modules/create-ton/dist/cli.js:87:42) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 83190,
stdout: null,
stderr: null
}

Deploy contract to testnet failed , used NetworkProvider, always timeout to connect orbs.network

Create a counter template , An error occurred while deploying the contract:

adapter: [Function: httpAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 5000,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'User-Agent': 'axios/0.25.0',
      'Content-Length': 2254,
      host: 'ton.access.orbs.network'
    },
    method: 'post',
    url: 'https://ton.access.orbs.network/44A2c0ff5Bd3F8B62C092Ab4D238bEE463E644A2/1/testnet/ton-api-v4/send'

How to use my own rpc instead of default ?

Error in deploying large contracts with TonConnect

I have a large contract, which I should also pass the code of two child contracts to it on deployment. When I try to deploy it using TonConnect option, in TonKeeper I get a weird error, and deployment fails.

After more investigation, it looks like that when the total size of deployment is more than a certain limit, this error happens. I checked it by removing the code for one of the child contracts in the deployment and it was successfully deployed (although the result was the contract in an incorrect state).

I tried the mnemonic option and it was successfully deployed the big contract with two child contracts.

Mainnet addresses in testnet

Addresses, when connected to testnet are displayed in the mainnet format. For example, when using waitForDeploy or in the message "Connected to address ..." when using Ton Connect.

Deprecate `provider.deploy` in favor of `waitDeploy`

The goal is to standardize the deployment between sandbox, ton library and now blueprint. We teach the developers to create sendDeploy() in their wrapper for the deployment and then we don't use it in blueprint.

old code:

export async function run(provider: NetworkProvider) {
    const counter = Counter.createFromConfig({}, await compile('Counter'));
    await provider.deploy(counter, toNano('0.05'));
    const openedContract = provider.open(counter);
    // run methods on `openedContract`
}

new code:

export async function run(provider: NetworkProvider) {
    const contract = Counter.createFromConfig({}, await compile('Counter'))
    if (await provider.isContractDeployed(contract.address)) {
      // print already deployed and exit
    }
    const counter = provider.open(contract);
    await counter.sendDeploy(provider.sender(), toNano('0.05'));
    await provider.waitDeployed(counter);    
}

This exposes some smells with naming. The name for provider: NetworkProvider is confusing in the run function. This argument resembles ton library's TonClient more than anything. The name should probably be changed to client: NetworkClient and then the code will be nearly identical to ton library with client.isContractDeployed and client.open.

The `Counter` example should add the file educate people how to read contract value in default.

For now, the default contract is great and having the get method.

But now they don't have any idea or file is using the get method we set in Contract level.

Like these part, how to use those get functions:

    async getCounter(provider: ContractProvider) {
        const result = await provider.get('get_counter', []);
        return result.stack.readNumber();
    }

    async getID(provider: ContractProvider) {
        const result = await provider.get('get_id', []);
        return result.stack.readNumber();
    }
    ````

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.