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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c937c416e2b2f337bdef2100c573862ed55a40e864d5a19f2cef3c737e823608
4
- data.tar.gz: 0c09c2850d71f1392e0afc44943a62a0fed55153b6ef60b19700527639e43d84
3
+ metadata.gz: 3aa0b901b3fec0aaac180435fd3c65ef27496d41647b130f6e1c944a1b27135b
4
+ data.tar.gz: 6029f9e2845631561a5647cc5bd4b28f6c9645e39482e4972d4742d27d9667bd
5
5
  SHA512:
6
- metadata.gz: 762827b72f11790427f51fd8021da4ef5ce2af3598b792b3b59b5ccf247fb1240cc9a0658482c09979167094a4337b9c93f27d025ae15ad603a32621c603123f
7
- data.tar.gz: 135d42f56fdcd7520ca0677f4afb93e988b7151716fc534ba33682a0b51e1eee6ff5f0100b3ca14c2299948ab20fd9b338837e77289f2a62e6b1df8cd0c64f8d
6
+ metadata.gz: 88f9e7322b46c08cc316ad5cf2cbfe6f19445efdc2f960487c9e8b5dd278193a609750fd51a4af02ed9074f0a21ef7b04d963e8f8128b1f9f6ddfa15d295d551
7
+ data.tar.gz: 6695fd3406de69465c71bb5bf25d42f9ba8590072a61ca3a1cf6c6d27c6169b157ad6bc26ed9fc35e12f70d2473d294b64ffa89ede62a930c04a6e9b087f5791
data/lib/tealrb/abi.rb CHANGED
@@ -20,7 +20,7 @@ module TEALrb
20
20
  @methods = []
21
21
  end
22
22
 
23
- def add_method(name:, desc:, args:, returns:)
23
+ def add_method(name:, desc:, args:, returns:, **_kwargs)
24
24
  @methods << {
25
25
  name: name,
26
26
  desc: desc,
@@ -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
@@ -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
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TEALrb
4
+ class AppArgs < OpcodeType
5
+ def initialize(contract)
6
+ @field = 'ApplicationArgs'
7
+ super
8
+ end
9
+ end
10
+ end
@@ -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
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TEALrb
4
+ class Box
5
+ def initialize(contract)
6
+ @contract = contract
7
+ end
8
+
9
+ def [](key)
10
+ @contract.box_value key
11
+ end
12
+
13
+ def []=(key, value)
14
+ @contract.box_put key, value
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TEALrb
4
+ module ByteOpcodes
5
+ def byte_b64(b64)
6
+ @teal << "byte b64 #{b64}"
7
+ end
8
+
9
+ def byte_b32(b32)
10
+ @teal << "byte b32 #{b32}"
11
+ end
12
+ end
13
+ end