- dcl-contracts
- dcl-dapp-scripts
- dcl-blockchain-monitor
- dcl-create-dapp
- dcl-dapp-boilerplate
- Reference
The main idea is to remove the coupling between contracts and decentraland-eth. To do this, we propose a new clien which does two main things:
- Generates a typescript contract interface for a given ABI. It'll look something like this
|____contract-1
| |____artifact.json
| |____index.d.ts
| |____index.ts
-
Publishes the contract interface as an npm package
-
Extra: Use truffle as a peer dependency and add a compilation step to the process. That way it can be run directly on a
Contract.sol
.
Compile an abi:
$ cd contract-repo/
$ ls
.
|____build/
|____contracts/
|____migrations/
|____(...)
$ dcl-contracts compile build/contracts/Contract1.json
# ^ artifact/abi file
# Result:
# |____Contract1
# | |____artifact.json
# | |____index.d.ts
# | |____index.ts
Publish a new Contract.sol:
$ cd contract-repo/
$ ls
.
|____build/
|____contracts/
|____migrations/
|____(...)
$ dcl-contracts publish contracts/Contract1.sol @decentraland-contracts/contract-1 1.0.0
# ^ src file ^ npm name ^ version (shorthand major,minor,pacth).
Using on a js file:
// npm install --save @decentraland-contracts/marketplace
import Marketplace from '@decentraland-contracts/marketplace'
eth.connect({
contracts: [new Marketplace('0x2123')]
})
eth.getContract('Marketplace').publish(/* Typed!! */)
- We probably want to use a project like abi-gen or TypeChain, at least to get some ideas
- Solve npm permissions
- Consider supporting semantic versioning. For example: It should allow
major
as a version argument which will in turn fetch the current version and add a major to it. - Define suitable flags for the command line arguments
We need to simply and abstract the marketplace monitor. The idea is to have a plug and play monitor which allows for different uses.
The main changes are:
- Allow for custom handlers (already possible here)
- Allow for custom processEvents (not possible at the moment, somewhat hardcoded here)
- Add a reducer-like logic to processEvents. The idea
- Maybe simplify the way flags work. Now it uses commander thru decentraland-server. Example here
Add common scripts to a single repo. Inspired in part on how react-scripts works.
For now the idea is to extract away a few recurring scripts.
Some of them currently live on dapp-boilerplates script folder and should be replaced there:
npm run translate
: Uses the default translation to fill the other locales. Expects asrc/Translation
model. Depends on[decentraland-commons](https://github.com/decentraland/decentraland-commons)
- npm run migrate: The current migrate script is based node-pg-migrate. At the time of writing, it is coupled with the folder structure we use.
- npm run create-model: Create the files and folder structure for a new database backed model. At the time of writing, it is coupled with the folder structure we use.
Others still need some refactoring and live on the marketplaces script folder
npm run seed
: This script needs a small re-write. We need to migrate it to Typescript first. Then we need to take care of thegetRandomColumnValue
function which is coupled to the Marketplace. One option is to leave the more generic column names and just delete the others. On top of that we can export aseed
function and allow the user to provide a customgetRandomColumnValue
to use programatically.
This should serve as the main hub or entry point to start new Decentraland dapps. It's not a flesh out idea yet but in principle it should encapsulate:
- Clone decentraland-boilerplate. Maybe change some default names for a supplied name. For example running
dcl-create-dapp AwesomeName
clones the boilerplate and changes the package.json name toAwesomeName
- Include dcl-dapp-scripts
- Flag to add the dcl-blockchain-monitor
The idea (for now) here is to use the boilerplate as a starting point for new libs. That doesn't mean the boilerplate shouldn't exist, but rather that it should be composed of many different libs instead of static code.
There's a ton of work still to be done, but one for reference this are some of the extraible parts of the codebase we've encountered:
- Translations (front+back)
- Storage management (front)
- Trasactions management (front)
- Analytics (front. Missing, needs to be extracted from the marketplace)
- Loading state (front)
- Api script (front.
lib/api.ts
) - Wallet Component and state (front)
- Shared code between front+backend (Missing, needs to be extracted from the marketplace)
Reference for the current libs we're using on Decentraland Dapps and roughly what they do
-
- Log
- utils
- promisify
- sleep
- isEmptyObject
- omit
- mapOmit
- pick
- env
-
- Model
- db
- SQL
- cli
-
- eth
- Contract
- eth.utils