Class: Contract

Inherits:
Object
  • Object
show all
Includes:
Address
Defined in:
lib/universum/universum.rb

Constant Summary collapse

@@directory =
{}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Address

#_add, #_sub, #address, #balance, #send, #transfer, zero

Class Method Details

.[](key) ⇒ Object



198
# File 'lib/universum/universum.rb', line 198

def self.[]( key ) find_by_address( key ); end

.allObject



201
# File 'lib/universum/universum.rb', line 201

def self.all() @@directory.values; end

.at(key) ⇒ Object

another “classic” alias for find_by_address



197
# File 'lib/universum/universum.rb', line 197

def self.at( key) find_by_address( key ); end

.find(key) ⇒ Object

make find_by_address the default finder



196
# File 'lib/universum/universum.rb', line 196

def self.find( key ) find_by_address( key ); end

.find_by_address(key) ⇒ Object



191
192
193
194
195
# File 'lib/universum/universum.rb', line 191

def self.find_by_address( key )
   ## clean key (allow "embedded" class name e.g 0x4de2ee8 (SatoshiDice))
   key = key.gsub(/\(.+\)/, '' ).strip
   @@directory[ key ];
end

.payable(*args) ⇒ Object

function sig(nature) macro for types (dummy for now) e.g. use like

payable :process
payable :initialize
payable :bet, Integer
payable :lend_money, Address => Bool   ## returns Bool


215
# File 'lib/universum/universum.rb', line 215

def self.payable( *args ); end

.store(key, o) ⇒ Object

store (add) new contract object (o) to hash / directory



200
# File 'lib/universum/universum.rb', line 200

def self.store( key, o ) @@directory.store( key, o ); end

Instance Method Details

#assert(condition) ⇒ Object



225
226
227
228
229
230
231
# File 'lib/universum/universum.rb', line 225

def assert( condition )
  if condition == true
    ## do nothing
  else
    raise 'Contract Assertion Failed; Contract Halted (Stopped)'
  end
end

#blockObject



237
# File 'lib/universum/universum.rb', line 237

def block()      Universum.block;        end

#blockhash(number) ⇒ Object



238
239
240
241
# File 'lib/universum/universum.rb', line 238

def blockhash( number )
  ## todo/fix: only allow going back 255 blocks; check if number is in range!!!
  Universum.blockhash( number )
end

#log(event) ⇒ Object



235
# File 'lib/universum/universum.rb', line 235

def log( event ) Universum.log( event ); end

#msgObject



236
# File 'lib/universum/universum.rb', line 236

def msg()        Universum.msg;          end

#receiveObject

todo/double check: auto-add payable default fallback - why? why not?



221
222
# File 'lib/universum/universum.rb', line 221

def receive    ## @payable default fallback - use different name - why? why not? (e.g. handle/process/etc.)
end

#thisObject

returns current contract



234
# File 'lib/universum/universum.rb', line 234

def this()       Universum.this;         end