-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ral
58 lines (48 loc) · 1.23 KB
/
test.ral
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Contract Math() {
@using(readonly = true)
pub fn pow(x: U256, y: U256) -> (U256) {
let mut i = 0
let mut result = 1
while (i < y) {
result = result * x
i = i + 1
}
return result
}
@using(readonly = true)
pub fn normalizeAmount(amount: U256, decimals: U256) -> (U256) {
if (decimals > 8) {
return amount / pow(10, decimals - 8)
}
return amount
}
pub fn deNormalizeAmount(amount: U256, decimals: U256) -> (U256) {
if (decimals > 8) {
return amount * pow(10, decimals - 8)
}
return amount
}
}
Contract MetaData() {
@using(preapprovedAssets = true, assetsInContract = false)
pub fn foo() -> () {
transferAlph!(callerAddress!(), callerAddress!(), 1 alph)
return
}
@using(preapprovedAssets = false, assetsInContract = true)
fn bar() -> () {
transferAlphToSelf!(selfAddress!(), 1 alph)
return
}
@using(readonly = true)
fn baz() -> () {
return
}
}
Contract Warnings(@unused a: U256, b: U256) {
const C = 0
@using(readonly = true)
pub fn foo(@unused x: U256, y: U256) -> () {
return
}
}