Class: BinaryCodec::XChainBridge
Instance Attribute Summary
#bytes
Class Method Summary
collapse
Instance Method Summary
collapse
from_bytes, from_hex, from_json, get_type_by_name, #to_byte_sink, #to_bytes, #to_hex, #value_of
Constructor Details
#initialize(bytes = nil) ⇒ XChainBridge
Returns a new instance of XChainBridge.
5
6
7
|
# File 'lib/binary-codec/types/xchain_bridge.rb', line 5
def initialize(bytes = nil)
super(bytes || [])
end
|
Class Method Details
.from(value) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/binary-codec/types/xchain_bridge.rb', line 9
def self.from(value)
return value if value.is_a?(XChainBridge)
if value.is_a?(String)
return XChainBridge.new(hex_to_bytes(value))
end
if value.is_a?(Hash)
bytes = []
bytes.concat(AccountId.from(value['LockingChainDoor']).to_bytes)
bytes.concat(Issue.from(value['LockingChainIssue']).to_bytes)
bytes.concat(AccountId.from(value['IssuingChainDoor']).to_bytes)
bytes.concat(Issue.from(value['IssuingChainIssue']).to_bytes)
return XChainBridge.new(bytes)
end
raise StandardError, "Cannot construct XChainBridge from #{value.class}"
end
|
.from_parser(parser, _hint = nil) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/binary-codec/types/xchain_bridge.rb', line 28
def self.from_parser(parser, _hint = nil)
bytes = []
bytes.concat(parser.read(20)) bytes.concat(Issue.from_parser(parser).to_bytes) bytes.concat(parser.read(20)) bytes.concat(Issue.from_parser(parser).to_bytes) XChainBridge.new(bytes)
end
|
Instance Method Details
#to_json(_definitions = nil, _field_name = nil) ⇒ Object