1
0
mirror of https://github.com/danog/toncontest.git synced 2024-11-30 04:29:14 +01:00

First commit

This commit is contained in:
Daniil Gentili 2019-09-29 13:54:49 +02:00
parent 5c8ce71d91
commit 6a5a7f9c3c
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
6 changed files with 75 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lib"]
path = lib
url = https://github.com/ton-blockchain/ton/

1
lib Submodule

@ -0,0 +1 @@
Subproject commit fd7a8de9708c9ece8d802890519735b55bc99a8e

3
toolchain/bin/fift Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash -e
$TONLIB_HOME/build/fift "$@"

3
toolchain/bin/funcompile Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash -e
/home/daniil/repos/ton/build/crypto/func -WRS -o "$(basename $1 .fc).fif" "$TONLIB_HOME/crypto/smartcont/stdlib.fc" "$@"

27
toolchain/build.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash -e
cd "$(dirname "$0")"/..
git submodule update --init --recursive
cd lib
grep -q TONLIB_HOME $HOME/.bashrc || {
echo "export TONLIB_HOME=$PWD" >> $HOME/.bashrc
echo 'export FIFTPATH=$TONLIB_HOME/crypto/fift/lib:$TONLIB_HOME/crypto/smartcont' >> $HOME/.bashrc
echo 'export PATH=$PATH:$TONLIB_HOME/../toolchain/bin' >> $HOME/.bashrc
}
git pull origin master
mkdir -p build
cd build
[ ! -f CMakeCache.txt ] && {
cmake ..
}
cmake --build . --target lite-client
cmake --build . --target fift
cmake --build . --target func
cd ../..

38
wallet-code.fc Normal file
View File

@ -0,0 +1,38 @@
;; Simple wallet smart contract
() recv_internal(slice in_msg) impure {
;; do nothing for internal messages
}
() recv_external(slice in_msg) impure {
var signature = in_msg~load_bits(512);
var cs = in_msg;
var (msg_seqno, valid_until) = (cs~load_uint(32), cs~load_uint(32));
throw_if(35, valid_until <= now());
var ds = get_data().begin_parse();
var (stored_seqno, public_key) = (ds~load_uint(32), ds~load_uint(256));
ds.end_parse();
throw_unless(33, msg_seqno == stored_seqno);
throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key));
accept_message();
cs~touch();
var op = cs~load_uint(8);
if (op == 1) {
set_code(cs~load_ref());
} else {
while (cs.slice_refs()) {
var mode = cs~load_uint(8);
send_raw_message(cs~load_ref(), mode);
}
}
cs.end_parse();
set_data(begin_cell().store_uint(stored_seqno + 1, 32).store_uint(public_key, 256).end_cell());
}
;; Get methods
int seqno() method_id {
return get_data().begin_parse().preload_uint(32);
}