Class: CcipDirectoryAndConfigurationRestApiV1::ChainDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb

Overview

ChainDetails Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(chain_id:, display_name:, selector:, internal_id:, fee_tokens:, router:, rmn:, chain_type:, chain_family:, supported:, registry_module: SKIP, token_admin_registry: SKIP, token_pool_factory: SKIP, fee_quoter: SKIP, mcms: SKIP, additional_properties: nil) ⇒ ChainDetails

Returns a new instance of ChainDetails.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 114

def initialize(chain_id:, display_name:, selector:, internal_id:,
               fee_tokens:, router:, rmn:, chain_type:, chain_family:,
               supported:, registry_module: SKIP,
               token_admin_registry: SKIP, token_pool_factory: SKIP,
               fee_quoter: SKIP, mcms: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @chain_id = chain_id
  @display_name = display_name
  @selector = selector
  @internal_id = internal_id
  @fee_tokens = fee_tokens
  @router = router
  @rmn = rmn
  @chain_type = chain_type
  @chain_family = chain_family
  @supported = supported
  @registry_module = registry_module unless registry_module == SKIP
  @token_admin_registry = token_admin_registry unless token_admin_registry == SKIP
  @token_pool_factory = token_pool_factory unless token_pool_factory == SKIP
  @fee_quoter = fee_quoter unless fee_quoter == SKIP
  @mcms = mcms unless mcms == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#chain_familyChainFamily

Blockchain family grouping

Returns:



50
51
52
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 50

def chain_family
  @chain_family
end

#chain_idObject

Identifier of the chain (numeric for EVM chains, string for Solana/Aptos chains)

Returns:

  • (Object)


15
16
17
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 15

def chain_id
  @chain_id
end

#chain_typeChainType

Type of blockchain

Returns:



46
47
48
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 46

def chain_type
  @chain_type
end

#display_nameString

Human-readable name of the chain. For supported chains, this comes from configuration. For unsupported chains, it is derived from the internalId.

Returns:

  • (String)


20
21
22
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 20

def display_name
  @display_name
end

#fee_quoterString

Fee Quoter address (Solana chains only)

Returns:

  • (String)


71
72
73
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 71

def fee_quoter
  @fee_quoter
end

#fee_tokensObject

Fee tokens - either as string symbols or enriched objects with addresses. Empty array for unsupported chains.

Returns:

  • (Object)


33
34
35
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 33

def fee_tokens
  @fee_tokens
end

#internal_idString

Internal identifier for the chain

Returns:

  • (String)


28
29
30
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 28

def internal_id
  @internal_id
end

#mcmsString

MCMS (Multi-Chain Management Service) address (Aptos chains only)

Returns:

  • (String)


75
76
77
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 75

def mcms
  @mcms
end

#registry_moduleString

Registry Module contract address (EVM chains only)

Returns:

  • (String)


59
60
61
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 59

def registry_module
  @registry_module
end

#rmnString

Risk Management Network contract address. Empty string for unsupported chains.

Returns:

  • (String)


42
43
44
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 42

def rmn
  @rmn
end

#routerString

CCIP Router contract address. Empty string for unsupported chains.

Returns:

  • (String)


37
38
39
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 37

def router
  @router
end

#selectorString

CCIP chain selector

Returns:

  • (String)


24
25
26
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 24

def selector
  @selector
end

#supportedTrueClass | FalseClass

Whether this chain is fully supported with complete configuration. Unsupported chains have minimal details (empty router, rmn, feeTokens).

Returns:

  • (TrueClass | FalseClass)


55
56
57
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 55

def supported
  @supported
end

#token_admin_registryString

Token Admin Registry contract address (EVM and Aptos chains)

Returns:

  • (String)


63
64
65
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 63

def token_admin_registry
  @token_admin_registry
end

#token_pool_factoryString

Token Pool Factory contract address (EVM chains only)

Returns:

  • (String)


67
68
69
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 67

def token_pool_factory
  @token_pool_factory
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 141

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  chain_id = hash.key?('chainId') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ChainDetailsChainId), hash['chainId']
  ) : nil
  display_name = hash.key?('displayName') ? hash['displayName'] : nil
  selector = hash.key?('selector') ? hash['selector'] : nil
  internal_id = hash.key?('internalId') ? hash['internalId'] : nil
  fee_tokens = hash.key?('feeTokens') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ChainDetailsFeeTokens), hash['feeTokens']
  ) : nil
  router = hash.key?('router') ? hash['router'] : nil
  rmn = hash.key?('rmn') ? hash['rmn'] : nil
  chain_type = hash.key?('chainType') ? hash['chainType'] : nil
  chain_family = hash.key?('chainFamily') ? hash['chainFamily'] : nil
  supported = hash.key?('supported') ? hash['supported'] : nil
  registry_module =
    hash.key?('registryModule') ? hash['registryModule'] : SKIP
  token_admin_registry =
    hash.key?('tokenAdminRegistry') ? hash['tokenAdminRegistry'] : SKIP
  token_pool_factory =
    hash.key?('tokenPoolFactory') ? hash['tokenPoolFactory'] : SKIP
  fee_quoter = hash.key?('feeQuoter') ? hash['feeQuoter'] : SKIP
  mcms = hash.key?('mcms') ? hash['mcms'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  ChainDetails.new(chain_id: chain_id,
                   display_name: display_name,
                   selector: selector,
                   internal_id: internal_id,
                   fee_tokens: fee_tokens,
                   router: router,
                   rmn: rmn,
                   chain_type: chain_type,
                   chain_family: chain_family,
                   supported: supported,
                   registry_module: registry_module,
                   token_admin_registry: token_admin_registry,
                   token_pool_factory: token_pool_factory,
                   fee_quoter: fee_quoter,
                   mcms: mcms,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 78

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['chain_id'] = 'chainId'
  @_hash['display_name'] = 'displayName'
  @_hash['selector'] = 'selector'
  @_hash['internal_id'] = 'internalId'
  @_hash['fee_tokens'] = 'feeTokens'
  @_hash['router'] = 'router'
  @_hash['rmn'] = 'rmn'
  @_hash['chain_type'] = 'chainType'
  @_hash['chain_family'] = 'chainFamily'
  @_hash['supported'] = 'supported'
  @_hash['registry_module'] = 'registryModule'
  @_hash['token_admin_registry'] = 'tokenAdminRegistry'
  @_hash['token_pool_factory'] = 'tokenPoolFactory'
  @_hash['fee_quoter'] = 'feeQuoter'
  @_hash['mcms'] = 'mcms'
  @_hash
end

.nullablesObject

An array for nullable fields



110
111
112
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 110

def self.nullables
  []
end

.optionalsObject

An array for optional fields



99
100
101
102
103
104
105
106
107
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 99

def self.optionals
  %w[
    registry_module
    token_admin_registry
    token_pool_factory
    fee_quoter
    mcms
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (ChainDetails | Hash)

    value against the validation is performed.



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 196

def self.validate(value)
  if value.instance_of? self
    return (
      UnionTypeLookUp.get(:ChainDetailsChainId)
                     .validate(value.chain_id) and
        APIHelper.valid_type?(value.display_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.selector,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.internal_id,
                              ->(val) { val.instance_of? String }) and
        UnionTypeLookUp.get(:ChainDetailsFeeTokens)
                       .validate(value.fee_tokens) and
        APIHelper.valid_type?(value.router,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.rmn,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.chain_type,
                              ->(val) { ChainType.validate(val) }) and
        APIHelper.valid_type?(value.chain_family,
                              ->(val) { ChainFamily.validate(val) }) and
        APIHelper.valid_type?(value.supported,
                              ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass })
    )
  end

  return false unless value.instance_of? Hash

  (
    UnionTypeLookUp.get(:ChainDetailsChainId)
                   .validate(value['chainId']) and
      APIHelper.valid_type?(value['displayName'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['selector'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['internalId'],
                            ->(val) { val.instance_of? String }) and
      UnionTypeLookUp.get(:ChainDetailsFeeTokens)
                     .validate(value['feeTokens']) and
      APIHelper.valid_type?(value['router'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['rmn'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['chainType'],
                            ->(val) { ChainType.validate(val) }) and
      APIHelper.valid_type?(value['chainFamily'],
                            ->(val) { ChainFamily.validate(val) }) and
      APIHelper.valid_type?(value['supported'],
                            ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



260
261
262
263
264
265
266
267
268
269
270
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 260

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} chain_id: #{@chain_id.inspect}, display_name: #{@display_name.inspect},"\
  " selector: #{@selector.inspect}, internal_id: #{@internal_id.inspect}, fee_tokens:"\
  " #{@fee_tokens.inspect}, router: #{@router.inspect}, rmn: #{@rmn.inspect}, chain_type:"\
  " #{@chain_type.inspect}, chain_family: #{@chain_family.inspect}, supported:"\
  " #{@supported.inspect}, registry_module: #{@registry_module.inspect}, token_admin_registry:"\
  " #{@token_admin_registry.inspect}, token_pool_factory: #{@token_pool_factory.inspect},"\
  " fee_quoter: #{@fee_quoter.inspect}, mcms: #{@mcms.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



249
250
251
252
253
254
255
256
257
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_details.rb', line 249

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} chain_id: #{@chain_id}, display_name: #{@display_name}, selector:"\
  " #{@selector}, internal_id: #{@internal_id}, fee_tokens: #{@fee_tokens}, router:"\
  " #{@router}, rmn: #{@rmn}, chain_type: #{@chain_type}, chain_family: #{@chain_family},"\
  " supported: #{@supported}, registry_module: #{@registry_module}, token_admin_registry:"\
  " #{@token_admin_registry}, token_pool_factory: #{@token_pool_factory}, fee_quoter:"\
  " #{@fee_quoter}, mcms: #{@mcms}, additional_properties: #{@additional_properties}>"
end