Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit c62513f

Browse files
committed
Refactored - 1.0.1
1 parent 45ecaa6 commit c62513f

File tree

6 files changed

+864
-405
lines changed

6 files changed

+864
-405
lines changed

README.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def main():
125125
# `<b swap B, b>`
126126
builder().b(swap())
127127
# `<b swap ref, b>`
128-
builder().ref(swap())
128+
builder().r(swap())
129129
# `<b b{1001} s, b>`
130130
builder().s('b{1001}')
131131
# `<b 3 16 u, .s b>`
@@ -149,7 +149,7 @@ def main():
149149
file('test.bin').write()
150150
# deserialize data from a file
151151
# transforms in `"test.bin" file>B B>boc <s 7 u@+ 2 s@+ 256 B@+ ref@+`
152-
file('test.bin').deserialize().u(7).s(2).b(256).ref()
152+
file('test.bin').deserialize().u(7).s(2).b(256).r()
153153

154154
# deserialize data and safe something to constants
155155
# transforms in:
@@ -162,27 +162,7 @@ def main():
162162
.u(7)
163163
.s(2)
164164
.b(256, const=a)
165-
.ref(const=b))
166-
167-
main()
168-
```
169-
170-
#### Simple loops
171-
172-
```python
173-
from fift.fift import *
174-
175-
@script()
176-
def main():
177-
# Simple loop. Transforms in `1 { 1+ } 1 times`
178-
times(3, '1+').before(1)
179-
# Reads a value from a constant and sum itself in each iteration of the loop
180-
# writing a new value to the constant
181-
# Transforms in:
182-
# 1 constant a
183-
# @' a { dup + =: a } 3 times
184-
a = const('a', 1)
185-
times(3, assign(a, dup(), '+')).before(a)
165+
.r(const=b))
186166

187167
main()
188168
```

examples/__init__.py

Whitespace-only changes.

examples/chksign.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
https://test.ton.org/fiftbase.pdf#page=30&zoom=100,0,172
3+
"""
4+
5+
from fift.fift import *
6+
7+
8+
@script()
9+
def main():
10+
pos_neg_cond = (cond('0<')
11+
.pos(String('negative').print())
12+
.neg(String('positive').print()))
13+
14+
check_sign = word('check_sign', dupnz(), (cond()
15+
.pos(pos_neg_cond)
16+
.neg(String('zero').print())))
17+
18+
check_sign(-17)
19+
check_sign(0)
20+
check_sign(3)
21+
22+
23+
print(main())

examples/wallet.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from fift.fift import *
2+
3+
4+
def usage():
5+
return word(
6+
'usage',
7+
string(
8+
'usage:',
9+
const('$0'),
10+
' <filename-base> <dest-addr> <seqno> <amount> [-B <body-boc>] [-C <transfer-comment>] [<savefile>]'
11+
).print(cr=True),
12+
string(
13+
'Creates a request to simple wallet created by new-wallet.fif, '
14+
'with private key loaded from file <filename-base>.pk and address '
15+
'from <filename-base>.addr, and saves it into <savefile>.boc (\'wallet-query.boc\' by default)'
16+
).print(cr=True),
17+
halt(1)
18+
)
19+
20+
21+
@script()
22+
def main():
23+
include('TonUtil.fif')
24+
25+
usage()
26+
27+
28+
print(main())

0 commit comments

Comments
 (0)