@@ -63,14 +63,16 @@ Please mind that the `makefile` is temporary and an **artifact of the current st
6363``` makefile
6464ANOMA_PATH ?= $(error set the ANOMA_PATH variable to a path to an anoma clone)
6565base-path = .
66- base = HelloWorld
66+ base = SimpleHelloWorld
6767get-message = GetMessage
6868
6969anoma-build-dir = anoma-build
7070anoma-build = $(anoma-build-dir ) /.exists
7171
7272config = $(anoma-build-dir ) /config.yaml
7373
74+ temp-file := $(anoma-build-dir ) /temp_line
75+
7476juvix = $(base-path ) /$(base ) .juvix
7577nockma = $(anoma-build-dir ) /$(base ) .nockma
7678proved = $(anoma-build-dir ) /$(base ) .proved.nockma
@@ -79,7 +81,8 @@ get-message-juvix = $(base-path)/$(get-message).juvix
7981get-message-nockma = $(anoma-build-dir ) /$(get-message ) .nockma
8082get-message-proved = $(anoma-build-dir ) /$(get-message ) .proved.nockma
8183
82- last-unspent-resource = $(anoma-build-dir ) /last-unspent-resources
84+ unspent-resources = $(anoma-build-dir ) /unspent-resources
85+ last-message-txt = $(anoma-build-dir ) /last-message.txt
8386
8487port = $(anoma-build-dir ) /port
8588host = $(anoma-build-dir ) /host
@@ -93,13 +96,28 @@ clean:
9396 @juvix clean
9497 @rm -rf $(anoma-build-dir )
9598
96- .PHONY : start-anoma
97- start-anoma :
98- @juvix dev anoma start --anoma-dir $(ANOMA_PATH )
99-
100- .PHONY : stop-anoma
101- stop-anoma :
102- @juvix dev anoma stop
99+ .PHONY : anoma-start
100+ anoma-start :
101+ rm -f $(config )
102+ ifdef ANOMA_DEBUG
103+ cd $(ANOMA_PATH) && \
104+ mix run --no-halt $(root)/../../start-config.exs
105+ else
106+ juvix dev anoma start --force --anoma-dir $(ANOMA_PATH)
107+ endif
108+
109+ .PHONY : anoma-stop
110+ anoma-stop :
111+ ifdef ANOMA_DEBUG
112+ @echo "ANOMA_DEBUG is incompatible with anoma-stop" && false
113+ else
114+ juvix dev anoma stop
115+ endif
116+
117+ .PHONY : $(message-file )
118+ $(message-file ) : $(anoma-build )
119+ @echo $(message ) \
120+ > $(message-file )
103121
104122$(config ) : $(anoma-build )
105123 @juvix dev anoma print-config > $(config )
@@ -108,10 +126,15 @@ $(config): $(anoma-build)
108126add-transaction : $(proved ) $(config )
109127 @juvix dev anoma -c $(config ) add-transaction $(proved )
110128
111- .PHONY : get-message
112- get-message : $(get-message-nockma ) $(config ) $(last-unspent-resource )
113- @juvix dev anoma -c $(config ) prove $(get-message-nockma ) -o $(get-message-proved ) --arg ' base64:$(last-unspent-resource)'
114- @juvix dev nockma encode --cue --from bytes --to bytes < anoma-build/GetMessage.proved.nockma
129+ .PHONY : get-last-message
130+ get-last-message : $(last-message-txt )
131+ @cat $(last-message-txt )
132+
133+ .PHONY : $(last-message-txt )
134+ $(last-message-txt ) : $(get-message-nockma ) $(config ) $(unspent-resources )
135+ @tail -n 1 $(unspent-resources ) > $(temp-file )
136+ @juvix dev anoma -c $(config ) prove $(get-message-nockma ) -o $(get-message-proved ) --arg ' base64:$(temp-file)'
137+ @juvix dev nockma encode --cue --from bytes --to bytes < anoma-build/GetMessage.proved.nockma > $(last-message-txt )
115138
116139$(nockma ) : $(juvix ) $(anoma-build )
117140 @juvix compile anoma $(juvix ) -o $(nockma )
@@ -122,9 +145,9 @@ $(proved): $(nockma) $(config)
122145$(get-message-nockma ) : $(anoma-build ) $(get-message-juvix )
123146 @juvix compile anoma $(get-message-juvix ) -o $(get-message-nockma )
124147
125- .PHONY : $(last- unspent-resource )
126- $(last- unspent-resource ) : $(anoma-build ) $(host ) $(port )
127- @grpcurl -plaintext $$(cat $(host ) ) :$$(cat $(port ) ) Anoma.Protobuf.IndexerService.ListUnspentResources | jq -r ' .unspentResources[-1] // error("no messages exist")' > $(last- unspent-resource )
148+ .PHONY : $(unspent-resources )
149+ $(unspent-resources ) : $(anoma-build ) $(host ) $(port )
150+ @grpcurl -plaintext $$(cat $(host ) ) :$$(cat $(port ) ) Anoma.Protobuf.IndexerService.ListUnspentResources | jq -r ' .unspentResources[-1] // error("no messages exist")' > $(unspent-resources )
128151
129152$(host ) : $(config )
130153 @yq -r ' .url' $(config ) | tr -d ' \n' > $(host )
@@ -146,7 +169,7 @@ Open a new terminal in your project root:
146169
147170{% code title=" HelloWorld" %}
148171` `` bash
149- make start- anoma # start the Anoma node
172+ make anoma-start # start the Anoma node
150173```
151174{% endcode %}
152175
@@ -157,9 +180,9 @@ Now, once the Anoma Client and Node have started in your first terminal which yo
157180{% code title="HelloWorld" %}
158181``` bash
159182make add-transaction # Submit the HelloWorld transaction to anoma
160- make get-message # Get the message from the latest HelloWorld Resource
183+ make get-last- message # Get the message from the latest HelloWorld Resource
161184# ...
162- make stop- anoma # stop the Anoma node when you've finished
185+ make anoma-stop # stop the Anoma node when you've finished
163186make clean # clean up after yourself
164187```
165188{% endcode %}
0 commit comments