Skip to content

Commit d85c922

Browse files
committed
update game contract
1 parent 3e68631 commit d85c922

File tree

3 files changed

+227
-3
lines changed

3 files changed

+227
-3
lines changed

content/hacking/captain-game.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ draft = false
1717
<div class="heading">Table of Contents</div>
1818

1919
- [My hacklog](#my-hacklog)
20+
- [2021-02-14](#2021-02-14)
2021
- [2021-02-13](#2021-02-13)
2122
- [2021-02-06](#2021-02-06)
2223
- [2021-02-04](#2021-02-04)
@@ -41,6 +42,116 @@ Captain game with Parity ink.
4142
## My hacklog {#my-hacklog}
4243

4344

45+
### 2021-02-14 {#2021-02-14}
46+
47+
Some differences between ink's doc and my terminal:
48+
49+
[ink's doc](https://paritytech.github.io/ink-docs/cargo-contract-cli):
50+
51+
```shell
52+
cargo-contract 0.8.0
53+
Utilities to develop Wasm smart contracts.
54+
55+
USAGE:
56+
cargo contract <SUBCOMMAND>
57+
58+
OPTIONS:
59+
-h, --help Prints help information
60+
-V, --version Prints version information
61+
62+
SUBCOMMANDS:
63+
new Setup and create a new smart contract project
64+
build Compiles the contract, generates metadata, bundles both together in a '.contract' file
65+
check Check that the code builds as Wasm; does not output any build artifact to the top level `target/` directory
66+
test Test the smart contract off-chain
67+
deploy Upload the smart contract code to the chain
68+
instantiate Instantiate a deployed smart contract
69+
help Prints this message or the help of the given subcommand(s)
70+
```
71+
72+
My terminal:
73+
74+
```shell
75+
$ cargo contract --version
76+
cargo-contract 0.8.0
77+
78+
$ cargo contract --help
79+
cargo-contract 0.8.0
80+
Utilities to develop Wasm smart contracts
81+
82+
USAGE:
83+
cargo contract <SUBCOMMAND>
84+
85+
OPTIONS:
86+
-h, --help Prints help information
87+
-V, --version Prints version information
88+
89+
SUBCOMMANDS:
90+
new Setup and create a new smart contract project
91+
build Compiles the contract, generates metadata, bundles both together in a `<name>.contract`
92+
file
93+
generate-metadata Command has been deprecated, use `cargo contract build` instead
94+
check Check that the code builds as Wasm; does not output any build artifact to the top level
95+
`target/` directory
96+
test Test the smart contract off-chain
97+
help Prints this message or the help of the given subcommand(s)
98+
99+
$ cargo contract deploy
100+
error: Found argument 'deploy' which wasn't expected, or isn't valid in this context
101+
102+
USAGE:
103+
cargo contract <SUBCOMMAND>
104+
105+
For more information try --help
106+
```
107+
108+
While there isn't a `upgrade` or `update` command, I installed it again:
109+
110+
```shell
111+
$ cargo install cargo-contract --vers 0.8.0 --force --locked
112+
```
113+
114+
But, `cargo contract --help` doesn't show me any differences.
115+
116+
Gladly, I find something from GitHub:
117+
[cargo-contract](https://github.com/paritytech/cargo-contract)
118+
119+
**[Features](https://github.com/paritytech/cargo-contract#features)**
120+
121+
> The \`deploy\` and \`instantiate\` subcommands are ****disabled by default****, since they are not fully stable yet and increase the build time.
122+
>
123+
> If you want to try them, you need to enable the \`extrinsics\` feature:
124+
>
125+
> \`cargo install --git <https://github.com/paritytech/cargo-contract> cargo-contract --features extrinsics --force\`
126+
>
127+
> Once they are stable and the compilation time is acceptable, we will consider removing the \`extrinsics\` feature.
128+
129+
I am trying but it doesn't work: it's broken, and Brian has submitted a PR to fix it.
130+
131+
```shell
132+
$ cargo install --git https://github.com/paritytech/cargo-contract cargo-contract --features extrinsics --force
133+
134+
...
135+
error: aborting due to 60 previous errors
136+
137+
Some errors have detailed explanations: E0034, E0308.
138+
For more information about an error, try `rustc --explain E0034`.
139+
error: could not compile `bitvec`
140+
141+
To learn more, run the command again with --verbose.
142+
warning: build failed, waiting for other jobs to finish...
143+
error: failed to compile `cargo-contract v0.8.0 (https://github.com/paritytech/cargo-contract#79dbcb65)`, intermediate artifacts can be found at `/var/folders/g5/hf7q78jn0vngnqtqj_3qfm6r0000gn/T/cargo-installBtwvjf`
144+
145+
Caused by:
146+
build failed
147+
```
148+
149+
Changes in the smart contract:
150+
I add more verification in the run-highest-level logic that
151+
prints congratulations and
152+
**do not** level\_up once the player's run\_level\_2 is succeeded.
153+
154+
44155
### 2021-02-13 {#2021-02-13}
45156

46157
Test with submit\_level and run\_level + level\_up after run\_level succeed:
@@ -62,7 +173,7 @@ Test with submit\_level and run\_level + level\_up after run\_level succeed:
62173
63174
Now a player can submit (and run) programs up to 3 levels.
64175
65-
I also add more `Debugging` log.
176+
I also add more `Debugging` log, and clean up the code.
66177
67178
68179
### 2021-02-06 {#2021-02-06}

content/hacking/cs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ The videos' quality isn't great, and I give up.
5151
Then I move to another lecture:
5252
[MIT 6.006 Introduction to Algorithms, Fall 2011](https://www.youtube.com/watch?v=HtSuA80QTyo&list=PLUl4u3cNGP61Oq3tWYp6V%5FF-5jb5L2iHb&index=1)
5353

54+
More lectures on MIT website:
55+
<https://ocw.mit.edu/courses/find-by-topic/>
56+
5457

5558
## About types {#about-types}
5659

notes.org

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,115 @@ Captain game with Parity ink.
301301

302302
*** My hacklog
303303

304+
**** 2021-02-14
305+
306+
Some differences between ink's doc and my terminal:
307+
308+
[[https://paritytech.github.io/ink-docs/cargo-contract-cli][ink's doc]]:
309+
310+
#+begin_src shell
311+
cargo-contract 0.8.0
312+
Utilities to develop Wasm smart contracts.
313+
314+
USAGE:
315+
cargo contract <SUBCOMMAND>
316+
317+
OPTIONS:
318+
-h, --help Prints help information
319+
-V, --version Prints version information
320+
321+
SUBCOMMANDS:
322+
new Setup and create a new smart contract project
323+
build Compiles the contract, generates metadata, bundles both together in a '.contract' file
324+
check Check that the code builds as Wasm; does not output any build artifact to the top level `target/` directory
325+
test Test the smart contract off-chain
326+
deploy Upload the smart contract code to the chain
327+
instantiate Instantiate a deployed smart contract
328+
help Prints this message or the help of the given subcommand(s)
329+
#+end_src
330+
331+
My terminal:
332+
333+
#+begin_src shell
334+
$ cargo contract --version
335+
cargo-contract 0.8.0
336+
337+
$ cargo contract --help
338+
cargo-contract 0.8.0
339+
Utilities to develop Wasm smart contracts
340+
341+
USAGE:
342+
cargo contract <SUBCOMMAND>
343+
344+
OPTIONS:
345+
-h, --help Prints help information
346+
-V, --version Prints version information
347+
348+
SUBCOMMANDS:
349+
new Setup and create a new smart contract project
350+
build Compiles the contract, generates metadata, bundles both together in a `<name>.contract`
351+
file
352+
generate-metadata Command has been deprecated, use `cargo contract build` instead
353+
check Check that the code builds as Wasm; does not output any build artifact to the top level
354+
`target/` directory
355+
test Test the smart contract off-chain
356+
help Prints this message or the help of the given subcommand(s)
357+
358+
$ cargo contract deploy
359+
error: Found argument 'deploy' which wasn't expected, or isn't valid in this context
360+
361+
USAGE:
362+
cargo contract <SUBCOMMAND>
363+
364+
For more information try --help
365+
#+end_src
366+
367+
While there isn't a ~upgrade~ or ~update~ command, I installed it again:
368+
369+
#+begin_src shell
370+
$ cargo install cargo-contract --vers 0.8.0 --force --locked
371+
#+end_src
372+
373+
But, ~cargo contract --help~ doesn't show me any differences.
374+
375+
Gladly, I find something from GitHub:
376+
[[https://github.com/paritytech/cargo-contract][cargo-contract]]
377+
378+
*[[https://github.com/paritytech/cargo-contract#features][Features]]*
379+
380+
> The `deploy` and `instantiate` subcommands are **disabled by default**, since they are not fully stable yet and increase the build time.
381+
>
382+
> If you want to try them, you need to enable the `extrinsics` feature:
383+
>
384+
> `cargo install --git https://github.com/paritytech/cargo-contract cargo-contract --features extrinsics --force`
385+
>
386+
> Once they are stable and the compilation time is acceptable, we will consider removing the `extrinsics` feature.
387+
388+
I am trying but it doesn't work: it's broken, and Brian has submitted a PR to fix it.
389+
390+
#+begin_src shell
391+
$ cargo install --git https://github.com/paritytech/cargo-contract cargo-contract --features extrinsics --force
392+
393+
...
394+
error: aborting due to 60 previous errors
395+
396+
Some errors have detailed explanations: E0034, E0308.
397+
For more information about an error, try `rustc --explain E0034`.
398+
error: could not compile `bitvec`
399+
400+
To learn more, run the command again with --verbose.
401+
warning: build failed, waiting for other jobs to finish...
402+
error: failed to compile `cargo-contract v0.8.0 (https://github.com/paritytech/cargo-contract#79dbcb65)`, intermediate artifacts can be found at `/var/folders/g5/hf7q78jn0vngnqtqj_3qfm6r0000gn/T/cargo-installBtwvjf`
403+
404+
Caused by:
405+
build failed
406+
#+end_src
407+
408+
Changes in the smart contract:
409+
I add more verification in the run-highest-level logic that
410+
prints congratulations and
411+
*do not* level_up once the player's run_level_2 is succeeded.
412+
304413
**** 2021-02-13
305414

306415
Test with submit_level and run_level + level_up after run_level succeed:
@@ -322,7 +431,7 @@ Test with submit_level and run_level + level_up after run_level succeed:
322431

323432
Now a player can submit (and run) programs up to 3 levels.
324433

325-
I also add more ~Debugging~ log.
434+
I also add more ~Debugging~ log, and clean up the code.
326435

327436

328437
**** 2021-02-06
@@ -3256,7 +3365,8 @@ The videos' quality isn't great, and I give up.
32563365
Then I move to another lecture:
32573366
[[https://www.youtube.com/watch?v=HtSuA80QTyo&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb&index=1][MIT 6.006 Introduction to Algorithms, Fall 2011]]
32583367

3259-
3368+
More lectures on MIT website:
3369+
https://ocw.mit.edu/courses/find-by-topic/
32603370

32613371

32623372
*** About types

0 commit comments

Comments
 (0)