lib/universa/contract.rb in universa-0.2.2 vs lib/universa/contract.rb in universa-0.2.3
- old
+ new
@@ -1,5 +1,7 @@
+require 'bigdecimal'
+
module Universa
# Adapter for Universa ChangeOwnerPermission
class ChangeOwnerPermission < RemoteAdapter
remote_class "com.icodici.universa.contract.permissions.ChangeOwnerPermission"
@@ -18,10 +20,22 @@
class Role < RemoteAdapter
remote_class "com.icodici.universa.contract.roles.Role"
end
+ # adapter for Universa TransactionPack
+ class TransactionPack < RemoteAdapter
+ remote_class "com.icodici.universa.contract.TransactionPack"
+
+ # Unpack the transaction pack
+ # @return [TransactionPack] unpacked
+ def self.unpack(packed_transaction)
+ packed_transaction.force_encoding('binary')
+ invoke_static 'unpack', packed_transaction
+ end
+ end
+
# Adapter for Universa +HashId+ class, helps to avoid confusion when using different
# representations of the ID.
class HashId < RemoteAdapter
remote_class "com.icodici.universa.HashId"
@@ -207,10 +221,10 @@
# end
# Helper for many token-like contracts containing state.data.amount
# @return [BigDecimal] amount or nil
def amount
- v = state[:amount] and BigDecimal(v.to_s)
+ v = state[:amount] and BigDecimal.new(v.to_s)
end
# Write helper for many token-like contracts containing state.data.amount. Saves value
# in state.data.anomount and properly encodes it so it will be preserved on packing.
#
\ No newline at end of file