Module: FlowClient::CadenceType

Defined in:
lib/flow_client/cadence_type.rb

Class Method Summary collapse

Class Method Details

.Address(address) ⇒ Object



46
47
48
# File 'lib/flow_client/cadence_type.rb', line 46

def self.Address(address)
  OpenStruct.new(type: "Address", value: address.to_s)
end

.Array(values) ⇒ Object



130
131
132
# File 'lib/flow_client/cadence_type.rb', line 130

def self.Array(values)
  OpenStruct.new(type: "Array", value: values)
end

.Bool(bool) ⇒ Object



42
43
44
# File 'lib/flow_client/cadence_type.rb', line 42

def self.Bool(bool)
  OpenStruct.new(type: "Bool", value: bool.to_s.downcase == "true")
end

.Capability(path, address, borrow_type) ⇒ Object



157
158
159
160
161
162
163
164
165
166
# File 'lib/flow_client/cadence_type.rb', line 157

def self.Capability(path, address, borrow_type)
  OpenStruct.new(
    type: "Capability",
    value: OpenStruct.new(
      path: path.to_s,
      address: address.to_s,
      borrowType: borrow_type.to_s
    )
  )
end

.Composite(type, value) ⇒ Object



168
169
170
171
172
173
174
175
# File 'lib/flow_client/cadence_type.rb', line 168

def self.Composite(type, value)
  valid_types = %i[struct resource event contract enum]
  unless valid_types.include? type
    raise ArgumentError, "incorrect type, expected :struct, :resource, :event, :contract or :enum"
  end

  OpenStruct.new(type: type.to_s.capitalize, value: value)
end

.CompositeValue(id, fields) ⇒ Object



177
178
179
# File 'lib/flow_client/cadence_type.rb', line 177

def self.CompositeValue(id, fields)
  OpenStruct.new(id: id, fields: fields)
end

.Dictionary(values) ⇒ Object



134
135
136
# File 'lib/flow_client/cadence_type.rb', line 134

def self.Dictionary(values)
  OpenStruct.new(type: "Dictionary", value: values)
end

.DictionaryValue(key, value) ⇒ Object



138
139
140
# File 'lib/flow_client/cadence_type.rb', line 138

def self.DictionaryValue(key, value)
  OpenStruct.new(key: key, value: value)
end

.Field(name, value) ⇒ Object



181
182
183
# File 'lib/flow_client/cadence_type.rb', line 181

def self.Field(name, value)
  OpenStruct.new(name: name, value: value)
end

.Fix64(value) ⇒ Object



122
123
124
# File 'lib/flow_client/cadence_type.rb', line 122

def self.Fix64(value)
  OpenStruct.new(type: "Fix64", value: value.to_s)
end

.Int(value) ⇒ Object



50
51
52
# File 'lib/flow_client/cadence_type.rb', line 50

def self.Int(value)
  OpenStruct.new(type: "Int", value: value.to_s)
end

.Int128(value) ⇒ Object



90
91
92
# File 'lib/flow_client/cadence_type.rb', line 90

def self.Int128(value)
  OpenStruct.new(type: "Int128", value: value.to_s)
end

.Int16(value) ⇒ Object



66
67
68
# File 'lib/flow_client/cadence_type.rb', line 66

def self.Int16(value)
  OpenStruct.new(type: "Int16", value: value.to_s)
end

.Int256(value) ⇒ Object



98
99
100
# File 'lib/flow_client/cadence_type.rb', line 98

def self.Int256(value)
  OpenStruct.new(type: "Int256", value: value.to_s)
end

.Int32(value) ⇒ Object



74
75
76
# File 'lib/flow_client/cadence_type.rb', line 74

def self.Int32(value)
  OpenStruct.new(type: "Int32", value: value.to_s)
end

.Int64(value) ⇒ Object



82
83
84
# File 'lib/flow_client/cadence_type.rb', line 82

def self.Int64(value)
  OpenStruct.new(type: "Int64", value: value.to_s)
end

.Int8(value) ⇒ Object



58
59
60
# File 'lib/flow_client/cadence_type.rb', line 58

def self.Int8(value)
  OpenStruct.new(type: "Int8", value: value.to_s)
end

.Optional(value = nil) ⇒ Object

Returns an OpenStruct representing a Cadence Optional type

Examples:

@arg = FlowClient::CadenceType.Optional("Hello world!")
@arg = FlowClient::CadenceType.Optional()

Parameters:

  • the (String)

    string value



28
29
30
# File 'lib/flow_client/cadence_type.rb', line 28

def self.Optional(value = nil)
  OpenStruct.new(type: "Optional", value: value)
end

.Path(domain, identifier) ⇒ Object



142
143
144
145
146
147
148
149
150
151
# File 'lib/flow_client/cadence_type.rb', line 142

def self.Path(domain, identifier)
  unless %w[storage private public].include? domain.to_s.downcase
    raise raise ArgumentError, "Domain can only be one of storage, private or public"
  end

  OpenStruct.new(
    type: "Path",
    value: OpenStruct.new(domain: domain, identifier: identifier)
  )
end

.String(value) ⇒ Object

Returns an OpenStruct representing a Cadence String type

Examples:

@arg = FlowClient::CadenceType.String("Hello world!")

Parameters:

  • the (String)

    string value



15
16
17
# File 'lib/flow_client/cadence_type.rb', line 15

def self.String(value)
  OpenStruct.new(type: "String", value: value.to_s)
end

.Type(type_value) ⇒ Object



153
154
155
# File 'lib/flow_client/cadence_type.rb', line 153

def self.Type(type_value)
  OpenStruct.new(type: "Type", value: OpenStruct.new(staticType: type_value.to_s))
end

.UFix64(value) ⇒ Object



126
127
128
# File 'lib/flow_client/cadence_type.rb', line 126

def self.UFix64(value)
  OpenStruct.new(type: "UFix64", value: value.to_s)
end

.UInt(value) ⇒ Object



54
55
56
# File 'lib/flow_client/cadence_type.rb', line 54

def self.UInt(value)
  OpenStruct.new(type: "UInt", value: value.to_s)
end

.UInt128(value) ⇒ Object



94
95
96
# File 'lib/flow_client/cadence_type.rb', line 94

def self.UInt128(value)
  OpenStruct.new(type: "UInt128", value: value.to_s)
end

.UInt16(value) ⇒ Object



70
71
72
# File 'lib/flow_client/cadence_type.rb', line 70

def self.UInt16(value)
  OpenStruct.new(type: "UInt16", value: value.to_s)
end

.UInt256(value) ⇒ Object



102
103
104
# File 'lib/flow_client/cadence_type.rb', line 102

def self.UInt256(value)
  OpenStruct.new(type: "UInt256", value: value.to_s)
end

.UInt32(value) ⇒ Object



78
79
80
# File 'lib/flow_client/cadence_type.rb', line 78

def self.UInt32(value)
  OpenStruct.new(type: "UInt32", value: value.to_s)
end

.UInt64(value) ⇒ Object



86
87
88
# File 'lib/flow_client/cadence_type.rb', line 86

def self.UInt64(value)
  OpenStruct.new(type: "UInt64", value: value.to_s)
end

.UInt8(value) ⇒ Object



62
63
64
# File 'lib/flow_client/cadence_type.rb', line 62

def self.UInt8(value)
  OpenStruct.new(type: "UInt8", value: value.to_s)
end

.VoidObject

Returns an OpenStruct representing a Cadence Void type

Examples:

@arg = FlowClient::CadenceType.Void()


38
39
40
# File 'lib/flow_client/cadence_type.rb', line 38

def self.Void
  OpenStruct.new(type: "Void")
end

.Word16(value) ⇒ Object



110
111
112
# File 'lib/flow_client/cadence_type.rb', line 110

def self.Word16(value)
  OpenStruct.new(type: "Word16", value: value.to_s)
end

.Word32(value) ⇒ Object



114
115
116
# File 'lib/flow_client/cadence_type.rb', line 114

def self.Word32(value)
  OpenStruct.new(type: "Word32", value: value.to_s)
end

.Word64(value) ⇒ Object



118
119
120
# File 'lib/flow_client/cadence_type.rb', line 118

def self.Word64(value)
  OpenStruct.new(type: "Word64", value: value.to_s)
end

.Word8(value) ⇒ Object



106
107
108
# File 'lib/flow_client/cadence_type.rb', line 106

def self.Word8(value)
  OpenStruct.new(type: "Word8", value: value.to_s)
end