tealrb 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tealrb/abi.rb +1 -1
- data/lib/tealrb/account.rb +78 -0
- data/lib/tealrb/algod.rb +19 -0
- data/lib/tealrb/app.rb +132 -0
- data/lib/tealrb/app_args.rb +10 -0
- data/lib/tealrb/asset.rb +106 -0
- data/lib/tealrb/box.rb +17 -0
- data/lib/tealrb/byte_opcodes.rb +13 -0
- data/lib/tealrb/contract.rb +332 -121
- data/lib/tealrb/enums.rb +45 -0
- data/lib/tealrb/global.rb +94 -0
- data/lib/tealrb/group_txn.rb +42 -0
- data/lib/tealrb/if_block.rb +17 -24
- data/lib/tealrb/inner_txn.rb +95 -0
- data/lib/tealrb/local.rb +27 -0
- data/lib/tealrb/logs.rb +10 -0
- data/lib/tealrb/maybe_ops.rb +96 -0
- data/lib/tealrb/opcode_type.rb +31 -0
- data/lib/tealrb/opcodes.rb +541 -260
- data/lib/tealrb/rewriters.rb +71 -66
- data/lib/tealrb/scratch.rb +5 -4
- data/lib/tealrb/this_txn.rb +13 -0
- data/lib/tealrb/txn_fields.rb +333 -0
- data/lib/tealrb.rb +47 -18
- metadata +47 -3
- data/lib/tealrb/opcode_modules.rb +0 -904
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa0b901b3fec0aaac180435fd3c65ef27496d41647b130f6e1c944a1b27135b
|
4
|
+
data.tar.gz: 6029f9e2845631561a5647cc5bd4b28f6c9645e39482e4972d4742d27d9667bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88f9e7322b46c08cc316ad5cf2cbfe6f19445efdc2f960487c9e8b5dd278193a609750fd51a4af02ed9074f0a21ef7b04d963e8f8128b1f9f6ddfa15d295d551
|
7
|
+
data.tar.gz: 6695fd3406de69465c71bb5bf25d42f9ba8590072a61ca3a1cf6c6d27c6169b157ad6bc26ed9fc35e12f70d2473d294b64ffa89ede62a930c04a6e9b087f5791
|
data/lib/tealrb/abi.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TEALrb
|
4
|
+
class Account < OpcodeType
|
5
|
+
def initialize(contract)
|
6
|
+
@field = 'Accounts'
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def asset_balance?(_asa_id = nil)
|
11
|
+
@contract.asset_holding_exists? 'AssetBalance'
|
12
|
+
end
|
13
|
+
|
14
|
+
def asset_balance(_asa_id = nil)
|
15
|
+
@contract.asset_holding_value 'AssetBalance'
|
16
|
+
end
|
17
|
+
|
18
|
+
def asset_frozen?(_asa_id = nil)
|
19
|
+
@contract.asset_frozen_exists? 'AssetFrozen'
|
20
|
+
end
|
21
|
+
|
22
|
+
def asset_frozen_value(_asa_id = nil)
|
23
|
+
@contract.asset_frozen_value 'AssetFrozen'
|
24
|
+
end
|
25
|
+
|
26
|
+
def min_balance
|
27
|
+
@contract.acct_param_value 'AcctMinBalance'
|
28
|
+
end
|
29
|
+
|
30
|
+
def balance
|
31
|
+
@contract.acct_param_value 'AcctBalance'
|
32
|
+
end
|
33
|
+
|
34
|
+
def auth_addr
|
35
|
+
@contract.acct_param_value 'AcctAuthAddr'
|
36
|
+
end
|
37
|
+
|
38
|
+
def balance?
|
39
|
+
@contract.acct_has_balance?
|
40
|
+
end
|
41
|
+
|
42
|
+
def uints
|
43
|
+
@contract.acct_param_value 'AcctTotalNumUint'
|
44
|
+
end
|
45
|
+
|
46
|
+
def bytes
|
47
|
+
@contract.acct_param_value 'AcctTotalNumByteSlice'
|
48
|
+
end
|
49
|
+
|
50
|
+
def extra_pages
|
51
|
+
@contract.acct_param_value 'AcctTotalExtraAppPages'
|
52
|
+
end
|
53
|
+
|
54
|
+
def apps_created
|
55
|
+
@contract.acct_param_value 'AcctTotalAppsCreated'
|
56
|
+
end
|
57
|
+
|
58
|
+
def apps_opted_in
|
59
|
+
@contract.acct_param_value 'AcctTotalAppsOptedIn'
|
60
|
+
end
|
61
|
+
|
62
|
+
def assets_created
|
63
|
+
@contract.acct_param_value 'AcctTotalAssetsCreated'
|
64
|
+
end
|
65
|
+
|
66
|
+
def assets
|
67
|
+
@contract.acct_param_value 'AcctTotalAssets'
|
68
|
+
end
|
69
|
+
|
70
|
+
def boxes
|
71
|
+
@contract.acct_param_value 'AcctTotalBoxes'
|
72
|
+
end
|
73
|
+
|
74
|
+
def box_bytes
|
75
|
+
@contract.acct_param_value 'AcctTotalBoxBytes'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/tealrb/algod.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TEALrb
|
4
|
+
class Algod
|
5
|
+
def initialize(url: 'http://localhost:4001', token: 'a' * 64)
|
6
|
+
@conn = Faraday.new(url) do |conn|
|
7
|
+
conn.headers = { 'X-Algo-API-Token' => token }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def compile(source, source_map: true)
|
12
|
+
@conn.post('/v2/teal/compile') do |req|
|
13
|
+
req.params['sourcemap'] = source_map
|
14
|
+
req.body = source
|
15
|
+
req.headers['Content-Type'] = 'text/plain'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/tealrb/app.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TEALrb
|
4
|
+
class App < OpcodeType
|
5
|
+
def initialize(contract)
|
6
|
+
@field = 'Applications'
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [[]byte] Bytecode of Approval Program
|
11
|
+
def approval_program(*_args)
|
12
|
+
@contract.app_param_value 'AppApprovalProgram'
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [[]byte] Bytecode of Clear State Program
|
16
|
+
def clear_state_program(*_args)
|
17
|
+
@contract.app_param_value 'AppClearStateProgram'
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [uint64] Number of uint64 values allowed in Global State
|
21
|
+
def global_num_uint(*_args)
|
22
|
+
@contract.app_param_value 'AppGlobalNumUint'
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [uint64] Number of byte array values allowed in Global State
|
26
|
+
def global_num_byte_slice(*_args)
|
27
|
+
@contract.app_param_value 'AppGlobalNumByteSlice'
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [uint64] Number of uint64 values allowed in Local State
|
31
|
+
def local_num_uint(*_args)
|
32
|
+
@contract.app_param_value 'AppLocalNumUint'
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [uint64] Number of byte array values allowed in Local State
|
36
|
+
def local_num_byte_slice(*_args)
|
37
|
+
@contract.app_param_value 'AppLocalNumByteSlice'
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [uint64] Number of Extra Program Pages of code space
|
41
|
+
def extra_program_pages(*_args)
|
42
|
+
@contract.app_param_value 'AppExtraProgramPages'
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [[]byte] Creator address
|
46
|
+
def creator(*_args)
|
47
|
+
@contract.app_param_value 'AppCreator'
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [[]byte] Address for which this application has authority
|
51
|
+
def address(*_args)
|
52
|
+
@contract.app_param_value 'AppAddress'
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [[]byte] Bytecode of Approval Program
|
56
|
+
def approval_program?(*_args)
|
57
|
+
@contract.app_param_exists? 'AppApprovalProgram'
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [[]byte] Bytecode of Clear State Program
|
61
|
+
def clear_state_program?(*_args)
|
62
|
+
@contract.app_param_exists? 'AppClearStateProgram'
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [uint64] Number of uint64 values allowed in Global State
|
66
|
+
def global_num_uint?(*_args)
|
67
|
+
@contract.app_param_exists? 'AppGlobalNumUint'
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [uint64] Number of byte array values allowed in Global State
|
71
|
+
def global_num_byte_slice?(*_args)
|
72
|
+
@contract.app_param_exists? 'AppGlobalNumByteSlice'
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [uint64] Number of uint64 values allowed in Local State
|
76
|
+
def local_num_uint?(*_args)
|
77
|
+
@contract.app_param_exists? 'AppLocalNumUint'
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [uint64] Number of byte array values allowed in Local State
|
81
|
+
def local_num_byte_slice?(*_args)
|
82
|
+
@contract.app_param_exists? 'AppLocalNumByteSlice'
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [uint64] Number of Extra Program Pages of code space
|
86
|
+
def extra_program_pages?(*_args)
|
87
|
+
@contract.app_param_exists? 'AppExtraProgramPages'
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [[]byte] Creator address
|
91
|
+
def creator?(*_args)
|
92
|
+
@contract.app_param_exists? 'AppCreator'
|
93
|
+
end
|
94
|
+
|
95
|
+
# @return [[]byte] Address for which this application has authority
|
96
|
+
def address?(*_args)
|
97
|
+
@contract.app_param_exists? 'AppAddress'
|
98
|
+
end
|
99
|
+
|
100
|
+
def num_approval_pages?
|
101
|
+
@contract.app_param_exists? 'NumApprovalProgramPages'
|
102
|
+
end
|
103
|
+
|
104
|
+
def num_approval_pages
|
105
|
+
@contract.app_param_value 'NumApprovalProgramPages'
|
106
|
+
end
|
107
|
+
|
108
|
+
def num_clear_pages?
|
109
|
+
@contract.app_param_exists? 'NumClearProgramPages'
|
110
|
+
end
|
111
|
+
|
112
|
+
def num_clear_pages
|
113
|
+
@contract.app_param_value 'NumClearProgramPages'
|
114
|
+
end
|
115
|
+
|
116
|
+
def global_value(_key)
|
117
|
+
@contract.app_global_ex_value
|
118
|
+
end
|
119
|
+
|
120
|
+
def global_exists?(_key)
|
121
|
+
@contract.app_global_ex_exists?
|
122
|
+
end
|
123
|
+
|
124
|
+
def local_value(_account, _key)
|
125
|
+
@contract.app_local_ex_value
|
126
|
+
end
|
127
|
+
|
128
|
+
def local_exists?(_account, _key)
|
129
|
+
@contract.app_local_ex_exists?
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
data/lib/tealrb/asset.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TEALrb
|
4
|
+
class Asset < OpcodeType
|
5
|
+
def initialize(contract)
|
6
|
+
@field = 'Assets'
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def total
|
11
|
+
@contract.asset_param_value 'AssetTotal'
|
12
|
+
end
|
13
|
+
|
14
|
+
def decimals
|
15
|
+
@contract.asset_param_value 'AssetDecimals'
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_frozen
|
19
|
+
@contract.asset_param_value 'AssetDefaultFrozen'
|
20
|
+
end
|
21
|
+
|
22
|
+
def name
|
23
|
+
@contract.asset_param_value 'AssetName'
|
24
|
+
end
|
25
|
+
|
26
|
+
def unit_name
|
27
|
+
@contract.asset_param_value 'AssetUnitName'
|
28
|
+
end
|
29
|
+
|
30
|
+
def url
|
31
|
+
@contract.asset_param_value 'AssetURL'
|
32
|
+
end
|
33
|
+
|
34
|
+
def metadata_hash
|
35
|
+
@contract.asset_param_value 'AssetMetadataHash'
|
36
|
+
end
|
37
|
+
|
38
|
+
def manager
|
39
|
+
@contract.asset_param_value 'AssetManager'
|
40
|
+
end
|
41
|
+
|
42
|
+
def reserve
|
43
|
+
@contract.asset_param_value 'AssetReserve'
|
44
|
+
end
|
45
|
+
|
46
|
+
def freeze
|
47
|
+
@contract.asset_param_value 'AssetFreeze'
|
48
|
+
end
|
49
|
+
|
50
|
+
def clawback
|
51
|
+
@contract.asset_param_value 'AssetClawback'
|
52
|
+
end
|
53
|
+
|
54
|
+
def creator
|
55
|
+
@contract.asset_param_value 'AssetCreator'
|
56
|
+
end
|
57
|
+
|
58
|
+
def total?
|
59
|
+
@contract.asset_param_exists? 'AssetTotal'
|
60
|
+
end
|
61
|
+
|
62
|
+
def decimals?
|
63
|
+
@contract.asset_param_exists? 'AssetDecimals'
|
64
|
+
end
|
65
|
+
|
66
|
+
def default_frozen?
|
67
|
+
@contract.asset_param_exists? 'AssetDefaultFrozen'
|
68
|
+
end
|
69
|
+
|
70
|
+
def name?
|
71
|
+
@contract.asset_param_exists? 'AssetName'
|
72
|
+
end
|
73
|
+
|
74
|
+
def unit_name?
|
75
|
+
@contract.asset_param_exists? 'AssetUnitName'
|
76
|
+
end
|
77
|
+
|
78
|
+
def url?
|
79
|
+
@contract.asset_param_exists? 'AssetURL'
|
80
|
+
end
|
81
|
+
|
82
|
+
def metadata_hash?
|
83
|
+
@contract.asset_param_exists? 'AssetMetadataHash'
|
84
|
+
end
|
85
|
+
|
86
|
+
def manager?
|
87
|
+
@contract.asset_param_exists? 'AssetManager'
|
88
|
+
end
|
89
|
+
|
90
|
+
def reserve?
|
91
|
+
@contract.asset_param_exists? 'AssetReserve'
|
92
|
+
end
|
93
|
+
|
94
|
+
def freeze?
|
95
|
+
@contract.asset_param_exists? 'AssetFreeze'
|
96
|
+
end
|
97
|
+
|
98
|
+
def clawback?
|
99
|
+
@contract.asset_param_exists? 'AssetClawback'
|
100
|
+
end
|
101
|
+
|
102
|
+
def creator?
|
103
|
+
@contract.asset_param_exists? 'AssetCreator'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/lib/tealrb/box.rb
ADDED