-
Notifications
You must be signed in to change notification settings - Fork 211
Description
Abstract
Critical issue in Tact smart-contract development is external dependency management. For example, practically every DeFi service wants to work with Jettons, and the way people do it now is by copy-pasting it (we've done it twice in tact-lang repos already: dex and cookbook).
This approach has a lot of issues with it: updating your dependencies (what if we fix vulnerability in jettons, we need to manually update it everywhere else) and keeping track of what is scope of development
Proposal
Let's implement package system based on npm, similar to how Solidity handles it.
For this we need:
1. Node modules import resolution
import "@kaladin13/tact-jetton/src/contracts/base/messages.tact";
contract SmthWithJettons() {
receive() {
cashback(sender());
}
// use stuff from npm module
receive(msg: JettonTransfer) {
}
}There is PR #3014 with one way of implementing this. We can extend this and do something like:
{
"projects": [
{
"name": "smth-with-jettons",
"path": "./src/main.tact",
// ...
"importPaths": [
"node_modules",
"../other-tact-project/src"
]
}
]
}2. Tooling for Tact project packaging and publishing to npm
Basically, to publish Tact project to npm means to publish contract files and wrappers for them. Given the tact.config.json, we know both the location and list of wrappers and contracts.
I propose new Tact CLI command:
tact package --config 'tact.config.json' --project ProjectNameThis command will:
- prompt contract-package semantic version and name
- scan project based on
tact.config.json - list all contracts in this project
- build contracts and generate
*.tswrappers - create folder with package name and
package.jsoninside it with filledfiles: []field,versionandname - create index.ts that will module export all wrappers exports from single place
(So yeah, this is simply default tact build functionality, but with package.json generation)
Here is Kaladin13/jetton@7af9888 what I've done in Jetton repo fork to publish it to npm, we can automate this and proposed tact package command will do exactly that
After tact package, the developer should run npm publish and npm will handle the rest.
Installing Tact package published like this will be as simple as:
yarn add @kaladin13/tact-jettonAfter implementing node_modules import resolution, this will give access both to wrappers in typescript code (perfect for frontend developers and further dApp pipeline) and contract exports in Tact source code