ton-society / grants-and-bounties

TON Foundation invites talent to imagine and realize projects that have the potential to integrate with the daily lives of users.
https://ton.org/grants
314 stars 137 forks source link

TON Dev environment tool #15

Closed Naltox closed 1 year ago

Naltox commented 2 years ago

Summary

CLI tool for fast and easy setup for TON smart-contract developers. The best analogy is the Hardhat from the Ethereum world.

Context

At this stage there is no such tool for setting up a new smart contract project with easy deployment, testing and debugging using JS/TS, which are standard in crypto world. We have toncli which is a good product, but since its core philosophy is to use Fift & FunC for deploying scripts, testing, etc - it's not that easy for new developers to quickly jump in.

Goals

Deliverables

Definition of Done

Developers are able to setup an environment for developing smart contracts in TON and start experimenting in less than 1 hour.

Reward

cryshado commented 2 years ago

After a detailed study of the description, I am ready to declare that I can take this task to work. A little later, after I have received confirmation, I will be able to provide links to the repositories where development will take place, here.

Starttime: 5 Jul 2022 Deadline: 31 Jul 2022

@Hiyorimi @Naltox Please confirm.

Hiyorimi commented 2 years ago

LGTM. I doubt that somebody else will pick up on current footstep.

Hiyorimi commented 2 years ago

Any activity here?

cryshado commented 2 years ago

Notify me if this task moves to another blockchain (e.g. @everscale-org, or maybe Ethereum/Polygon e.t.c.) 😀

Naltox commented 2 years ago

Hey guys, sharing with you some more detailed thoughts on this task:

Mode detailed Deliverables

Suggested list of commands

init - initiates project creation process

clean - deletes temp. files (if some)

test - runs all tests

deploy - helps to deploy contract(s) to mainnet/testnet

run - runs user-defined scripts

Abstractions

I think we should came up with some abstractions for working with smart contract (both locally & remote).

First of all we should came up with smart contract descriptor (code cell + data cell) & easy way to build it, it’s useful both for local testing and deployment process

Basically we need something like this:

type SmartContractDescriptor = {
    code: Cell
    data: Cell
}

type SmartContractBuilder<Config> = {
    buildCode(config: Config): Cell
    buildData(config: Config): Cell
}

One may came up with better abstractions, but basic idea is the same.

In this case SmartContractBuilder could be used for some standard way of deploying contracts and for building local copy of contract for testing.

Also we might (?) came up with some JSON format for storing SmartContractDescriptor on disk after compilation.

Contract instance

Besides that i think we need some representation of smart contract itself (some class i guess) which could be initialized both from network (by downloading code & data cells), from some config locally of by providing contract descriptor. Also this abstraction should have methods for invoking get methods on contract & sending messages (both locally for testing and remote for deployed ones).

I think this classes should be written by smart-contract developer, but we can provide some templates for this.

As an example for inspiration u suggest to check this repo:

https://github.com/getgems-io/nft-contracts

It solves mostly local running, but i think it illustrates the idea.

Some other option is to came up with some standard way for building messages for contract & have two standard functions sendInternalMessage & sendExternal message for local testing.

In this way developer could reuse functions for building messages.

Creating project

When creating new project tool should create directory with fully initialized Node.js TypeScript project including:

Testing

Tool should provide some basic templates for test written on mocha.

In my opinion tests should use some instance of Contact instance (described above) and operate with it by calling get methods or emulating sending messages.

Also we should provide some helper functions for writing tests, thinks like:

Deploying

Deploying process should be pretty simple, so i propose to use mobile wallets for this.

Both TonKeeper & TonHub support deploying smart-contracts using deep-links.

I think we can generate those deep-links and show them in console (probably we should somehow short them since code cell & data cells are included in those links).

Also it would be helpful to watch if contract was deployed and notify in console.

Interacting with smart contract

Ideally developers should be able to reuse all code & abstractions from tests to work with real-world deployed smart contract. In this way after local development and testing project developer should vale like 80% of code for interacting with deployed contract already and should only write some scripts for sending messages to deployed contract.

Developer should be able to easily write scripts that build some messages for contract, send them to the network and check for results (maybe we can provide some primitives for doing that through QR codes in console, just like in deployment scripts).

Docs

We need this tool to be fully covered with docs and examples, so developers can jump straight to writing some code & seeing results.

Also we need some e2e communication with developer community at the release time (answering to issues, working with PR’s, etc).

Detailed definition of done

Developers should be able to:

Core goal is to came up with some standard universal way for full contract development process including local testing, deployment and interacting with already deployed contracts with as much reuse of code as we can.

Hiyorimi commented 2 years ago

@Naltox can you confirm?

Miandic commented 2 years ago

Looks like no one wants to take up this footstep. We with @Gusarich can try to implement it. @Hiyorimi Can you assign us to this issue?

Hiyorimi commented 2 years ago

@Naltox can you please confirm?

Naltox commented 2 years ago

We are actually working on this one at TonTech and have some progress already, @Hiyorimi maybe you can confirm us? 😁

Gusarich commented 2 years ago

@Naltox Sure! Assigned you to this issue.

ghost commented 1 year ago

@Gusarich @Naltox Are you guys working on this?

delovoyhomie commented 1 year ago

Since blueprint solves this problem, this footstep has lost its relevance.