Class: Types::Address
- Inherits:
-
Object
- Object
- Types::Address
- Defined in:
- lib/soliscript/simulacrum.rb
Instance Method Summary collapse
-
#_account ⇒ Object
add ethereum account “magic” e.g.
- #balance ⇒ Object
- #send(value) ⇒ Object
-
#transfer(value) ⇒ Object
check - transfer same as send (but with different rollback/error exception policy?).
Instance Method Details
#_account ⇒ Object
add ethereum account “magic” e.g. balance (getter), send (method), transfer (method)
118 119 120 121 |
# File 'lib/soliscript/simulacrum.rb', line 118 def _account ## get "attached" account - make private? why? why not Account[ @value ] end |
#balance ⇒ Object
123 |
# File 'lib/soliscript/simulacrum.rb', line 123 def balance() _account.balance; end |
#send(value) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/soliscript/simulacrum.rb', line 125 def send( value ) ## note: always use simple string in account lookup!!! from = Account[ Simulacrum.msg.sender.as_data ] to = _account ## check for more datatypes or (simply) use to_int or to_i - why? why not? value = value.is_a?( UInt ) ? value.as_data : value ## check for below 0 - why? why not? if value > from.balance raise ArgumentError, "insufficent funds - account has #{from.balance} and required min. #{value}; sorry" end from.balance -= value to.balance += value end |
#transfer(value) ⇒ Object
check - transfer same as send (but with different rollback/error exception policy?)
143 |
# File 'lib/soliscript/simulacrum.rb', line 143 def transfer( value ) send( value ); end |