Class: CLType

Inherits:
Object
  • Object
show all
Defined in:
lib/types/cl_type.rb

Overview

Casper types, i.e. types which can be stored and manipulated by smart contracts. Provides a description of the underlying data type of a CLValue.

Constant Summary collapse

TAGS =
{
  # Boolean primitive.
  Bool:  0,
  # Signed 32-bit integer primitive.
  I32:  1,
  # Signed 64-bit integer primitive.
  I64:  2,
  # Unsigned 8-bit integer primitive.
  U8:  3,
  # Unsigned 32-bit integer primitive.
  U32:  4,
  # Unsigned 64-bit integer primitive.
  U64:  5,
  # Unsigned 128-bit integer primitive.
  U128:  6,
  # Unsigned 256-bit integer primitive.
  U256:  7,
  # Unsigned 512-bit integer primitive.
  U512:  8,
  # Singleton value without additional semantics.
  Unit: 9,
  # A string. e.g. "Hello, World!".
  String: 10,
  # Global state key.
  Key: 11,
  # Unforgeable reference.
  URef: 12,
  # Optional value of the given type Option(CLType).
  Option: 13,
  # Variable-length list of values of a single `CLType` List(CLType).
  List: 14,
  # Fixed-length list of a single `CLType` (normally a Byte).
  ByteArray: 15,
  # Co-product of the the given types; one variant meaning success, the other failure.
  Result: 16,
  # Key-value association where keys and values have the given types Map(CLType, CLType).
  Map: 17,
  # Single value of the given type Tuple1(CLType).
  Tuple1: 18,
  # Pair consisting of elements of the given types Tuple2(CLType, CLType).
  Tuple2: 19,
  # Triple consisting of elements of the given types Tuple3(CLType, CLType, CLType).
  Tuple3: 20,
  # Indicates the type is not known.
  Any: 21,
  # A Public key.
  PublicKey: 22
}

Instance Method Summary collapse

Constructor Details

#initialize(value = nil) ⇒ CLType

Returns a new instance of CLType.



55
56
57
# File 'lib/types/cl_type.rb', line 55

def initialize(value = nil)
  @value = value
end

Instance Method Details

#get_cl_type_tag(key) ⇒ Object



72
73
74
# File 'lib/types/cl_type.rb', line 72

def get_cl_type_tag(key)   
  TAGS[key]
end


68
69
70
# File 'lib/types/cl_type.rb', line 68

def get_link_to

end

#get_tag_key(value) ⇒ String

Parameters:

  • value (Integer)

Returns:

  • (String)


78
79
80
# File 'lib/types/cl_type.rb', line 78

def get_tag_key(value)
  TAGS.key(value).to_s
end

#get_tag_valueInteger

Returns tag_value.

Returns:

  • (Integer)

    tag_value



83
84
85
# File 'lib/types/cl_type.rb', line 83

def get_tag_value
  @tag_value
end

#get_tagsObject



87
88
89
# File 'lib/types/cl_type.rb', line 87

def get_tags
  TAGS
end

#tag_value_isvalid(value) ⇒ Boolean

Parameters:

  • value (Integer)

Returns:



93
94
95
# File 'lib/types/cl_type.rb', line 93

def tag_value_isvalid(value)
  TAGS.has_value?(value)
end

#to_jsonObject



64
65
66
# File 'lib/types/cl_type.rb', line 64

def to_json

end

#to_stringString

Returns:

  • (String)


60
61
62
# File 'lib/types/cl_type.rb', line 60

def to_string

end