Module: Scale::Types

Defined in:
lib/scale.rb,
lib/scale/base.rb,
lib/scale/trie.rb,
lib/scale/block.rb,
lib/scale/types.rb,
lib/type_builder.rb,
lib/metadata/metadata.rb,
lib/metadata/metadata_v0.rb,
lib/metadata/metadata_v1.rb,
lib/metadata/metadata_v2.rb,
lib/metadata/metadata_v3.rb,
lib/metadata/metadata_v4.rb,
lib/metadata/metadata_v5.rb,
lib/metadata/metadata_v6.rb,
lib/metadata/metadata_v7.rb,
lib/metadata/metadata_v8.rb,
lib/metadata/metadata_v9.rb,
lib/metadata/metadata_v10.rb,
lib/metadata/metadata_v11.rb,
lib/metadata/metadata_v12.rb,
lib/metadata/metadata_v13.rb

Defined Under Namespace

Modules: Array, Base, Enum, FixedWidthInt, FixedWidthUInt, Option, Set, Struct, Tuple, Vec, VecU8FixedLength Classes: AccountId, AccountIdAddress, AccountIndex, Address, ApprovalFlag, Attestation, AuthoritiesChange, AuthorityId, AuthorityWeight, BabeAuthorityWeight, Balance, BalanceLock, BalanceOf, Bidder, BlockAttestations, BlockNumber, Bool, BoxProposal, Bytes, ChangesTrieRoot, CodeHash, Compact, CompactMoment, Consensus, Conviction, EcdsaSignature, EdgewareKeys, EdgewareQueuedKeys, Era, EraIndex, EraPoints, EraRewards, EthereumAddress, EventRecord, EventRecords, Exposure, Extrinsic, Gas, GenericAddress, GenericBlock, GenericConsensusEngineId, GenericMultiAddress, H160, H256, H512, Hash, HeadData, Hex, I128, I16, I32, I64, I8, Identity, IdentityType, IncludedBlocks, IndividualExposure, InherentOfflineReport, KeyValue, LegacyKeys, LegacyQueuedKeys, LockPeriods, LogDigest, Metadata, MetadataModule, MetadataModuleCall, MetadataModuleCallArgument, MetadataModuleError, MetadataModuleEvent, MetadataModuleStorage, MetadataV0, MetadataV0Event, MetadataV0EventModule, MetadataV0Module, MetadataV0ModuleCallArgument, MetadataV0ModuleFunction, MetadataV0ModuleStorage, MetadataV0Section, MetadataV1, MetadataV10, MetadataV11, MetadataV12, MetadataV12Module, MetadataV13, MetadataV13Module, MetadataV13ModuleStorage, MetadataV13ModuleStorageEntry, MetadataV1Module, MetadataV1ModuleStorage, MetadataV2, MetadataV3, MetadataV4, MetadataV4Module, MetadataV4ModuleStorage, MetadataV5, MetadataV5Module, MetadataV5ModuleStorage, MetadataV6, MetadataV6Module, MetadataV6ModuleConstants, MetadataV6ModuleStorage, MetadataV7, MetadataV7Module, MetadataV7ModuleConstants, MetadataV7ModuleStorage, MetadataV7ModuleStorageEntry, MetadataV8, MetadataV8Module, MetadataV9, Moment, NewAccountOutcome, Null, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId, OptionBool, Other, ParaId, ParachainDispatchOrigin, Perbill, Permill, Phase, Points, PreRuntime, PrefabWasmModule, PropIndex, ProposalCategory, ProposalContents, ProposalIndex, ProposalPreimage, ProposalStage, ProposalTitle, QueuedKeys, RawAddress, ReferendumIndex, ReportIdOf, RewardDestination, Seal, SealV0, SessionIndex, SessionKey, SessionKeysSubstrate, SetIndex, SlashJournalEntry, StakingLedger, StorageHasher, StoredPendingChange, StoredState, String, TallyType, TrieNode, U128, U16, U256, U32, U512, U64, U8, UnlockChunk, UpwardMessage, ValidatorId, ValidatorPrefsLegacy, VecH512Length2, VecNextAuthority, VecQueuedKeys, VecU8Length128, VecU8Length16, VecU8Length2, VecU8Length20, VecU8Length256, VecU8Length3, VecU8Length32, VecU8Length4, VecU8Length64, VecU8Length8, Vote, VoteIndex, VoteOutcome, VoteStage, VoteThreshold, VoteType, VoterInfo, Votes, WinningDataEntry, WithdrawReasons

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debugObject

Returns the value of attribute debug.



47
48
49
# File 'lib/scale.rb', line 47

def debug
  @debug
end

.loggerObject

Returns the value of attribute logger.



47
48
49
# File 'lib/scale.rb', line 47

def logger
  @logger
end

Class Method Details

.check_typesObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/scale.rb', line 50

def self.check_types
  TypeRegistry.instance.all_types.keys.each do |key|
    begin
      type = self.get(key)
    rescue => ex
      puts "[[ERROR]] #{key}: #{ex}"
    end
  end
  true
end

.get(type_info) ⇒ Object

type_info: type_string or type_def

type_string: hard coded type name, Compact, H128, Vec<Compact>, (U32, U128), ...
type_def   : struct, enum, set

if type_string start_with Scale::Types::, it is treat as a hard coded type



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/type_builder.rb', line 10

def get(type_info)
  if type_info.class == ::String 
    if type_info.start_with?('Scale::Types::')
      return get_hard_coded_type(type_info)
    end

    # find the final type from registry
    type_info = fix_name(type_info)
    type_info = get_final_type_from_registry(type_info)
  end

  build_type(type_info)
end