How to add a constant to ligolang
Purpose
For Maintenance
Procedures
vendor/ligo-utils/tezos-proto-alpha is duplicated codebase against Tezos
src/proto-alpha/lib-protocol is equivalent dir in the Tezos codebase
If you've already added an opcode to the Tezos, just replace this dir by it.
This step will be obsoleted when Labnet has been launched
operator.ml is the core part to add a constant. If you typo or miss a charactor here, ligo compiler would fail and say "unbound variable 'level' found". I experienced that I've changed that line correctly however I've met the unbound variable error.
I changed "now" constant to "nowa" and I could confirmed my change is correctly reflected to docker container
Then I tried "level" constant, it works fine. Feels like cache issue.
How to build
source ./scripts/distribution/generic/env_variables.sh
sh ./scripts/distribution/generic/build.sh "debian" "debian" "10"
docker image will be generated
This image is 5GB or some. You need a huge storage space or external storage
It's embarassing that docker external storage setting is very plausible usecase but not supported.
You'll consume 500MB for each build. So you need good connection.
Update ligo command reference. This ligo executable is just a bash script and running a docker image
docker images and see your latest build
vi /usr/local/bin/ligo and point your image's tagname
How to test the constant
compile-expression: ligo compile-expression "level" -s pascaligo
compile-contract: ligo compile-contract "$(cat src/test/contracts/level_lock.ligo)" main
You need to write your own sample contract by using your constant/operation.
How to upload ligo-image to Dockerhub
You need to build an image with your Dockerhub's account's username/reponame tag.
./scripts/distribution/generic/build.sh is controlling that. You can comment out existing one and add your own.
So now you can see repository name sgtn/ligo and tag name level like thingy in docker images
I created a repo named ligo with account name sgtn
Add yourself as a collaborator
Run docker login and login in CLI
Then run this docker push sgtn/ligo:level