Module: FlowClient::CadenceType

Defined in:
lib/flow_client/cadence_type.rb

Class Method Summary collapse

Class Method Details

.Address(address) ⇒ Object


21
22
23
# File 'lib/flow_client/cadence_type.rb', line 21

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

.Array(values) ⇒ Object


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

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

.Bool(bool) ⇒ Object


17
18
19
# File 'lib/flow_client/cadence_type.rb', line 17

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

.Capability(path, address, borrow_type) ⇒ Object


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

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

Raises:

  • (ArgumentError)

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

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

.CompositeValue(id, fields) ⇒ Object


157
158
159
# File 'lib/flow_client/cadence_type.rb', line 157

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

.Dictionary(values) ⇒ Object


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

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

.DictionaryValue(key, value) ⇒ Object


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

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

.Field(name, value) ⇒ Object


161
162
163
# File 'lib/flow_client/cadence_type.rb', line 161

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

.Fix64(value) ⇒ Object


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

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

.Int(value) ⇒ Object


25
26
27
# File 'lib/flow_client/cadence_type.rb', line 25

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

.Int128(value) ⇒ Object


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

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

.Int16(value) ⇒ Object


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

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

.Int256(value) ⇒ Object


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

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

.Int32(value) ⇒ Object


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

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

.Int64(value) ⇒ Object


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

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

.Int8(value) ⇒ Object


33
34
35
# File 'lib/flow_client/cadence_type.rb', line 33

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

.Optional(value = nil) ⇒ Object


9
10
11
# File 'lib/flow_client/cadence_type.rb', line 9

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

.Path(domain, identifier) ⇒ Object


125
126
127
128
129
130
131
132
133
134
# File 'lib/flow_client/cadence_type.rb', line 125

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

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

.String(value) ⇒ Object


5
6
7
# File 'lib/flow_client/cadence_type.rb', line 5

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

.Type(type_value) ⇒ Object


136
137
138
# File 'lib/flow_client/cadence_type.rb', line 136

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

.UFix64(value) ⇒ Object


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

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

.UInt(value) ⇒ Object


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

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

.UInt128(value) ⇒ Object


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

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

.UInt16(value) ⇒ Object


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

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

.UInt256(value) ⇒ Object


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

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

.UInt32(value) ⇒ Object


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

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

.UInt64(value) ⇒ Object


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

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

.UInt8(value) ⇒ Object


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

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

.VoidObject


13
14
15
# File 'lib/flow_client/cadence_type.rb', line 13

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

.Word16(value) ⇒ Object


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

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

.Word32(value) ⇒ Object


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

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

.Word64(value) ⇒ Object


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

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

.Word8(value) ⇒ Object


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

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