Packages
Low-level elixir library to read, write, hash, and sign XDR primitive constructs used in the Stellar network.
Current section
Files
Jump to
Current section
Files
lib/xdr/transactions/transaction_event.ex
defmodule StellarBase.XDR.TransactionEvent do
@moduledoc """
Automatically generated by xdrgen
DO NOT EDIT or your changes may be overwritten
Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr
Representation of Stellar `TransactionEvent` type.
"""
@behaviour XDR.Declaration
alias StellarBase.XDR.{
TransactionEventStage,
ContractEvent
}
@struct_spec XDR.Struct.new(
stage: TransactionEventStage,
event: ContractEvent
)
@type stage_type :: TransactionEventStage.t()
@type event_type :: ContractEvent.t()
@type t :: %__MODULE__{stage: stage_type(), event: event_type()}
defstruct [:stage, :event]
@spec new(stage :: stage_type(), event :: event_type()) :: t()
def new(
%TransactionEventStage{} = stage,
%ContractEvent{} = event
),
do: %__MODULE__{stage: stage, event: event}
@impl true
def encode_xdr(%__MODULE__{stage: stage, event: event}) do
[stage: stage, event: event]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr()
end
@impl true
def encode_xdr!(%__MODULE__{stage: stage, event: event}) do
[stage: stage, event: event]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr!()
end
@impl true
def decode_xdr(bytes, struct \\ @struct_spec)
def decode_xdr(bytes, struct) do
case XDR.Struct.decode_xdr(bytes, struct) do
{:ok, {%XDR.Struct{components: [stage: stage, event: event]}, rest}} ->
{:ok, {new(stage, event), rest}}
error ->
error
end
end
@impl true
def decode_xdr!(bytes, struct \\ @struct_spec)
def decode_xdr!(bytes, struct) do
{%XDR.Struct{components: [stage: stage, event: event]}, rest} =
XDR.Struct.decode_xdr!(bytes, struct)
{new(stage, event), rest}
end
end