defmodule StellarBase.XDR.SorobanTransactionData 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 `SorobanTransactionData` type.
"""
@behaviour XDR.Declaration
alias StellarBase.XDR.{
SorobanResources,
Int64,
ExtensionPoint
}
@struct_spec XDR.Struct.new(
resources: SorobanResources,
refundable_fee: Int64,
ext: ExtensionPoint
)
@type resources_type :: SorobanResources.t()
@type refundable_fee_type :: Int64.t()
@type ext_type :: ExtensionPoint.t()
@type t :: %__MODULE__{
resources: resources_type(),
refundable_fee: refundable_fee_type(),
ext: ext_type()
}
defstruct [:resources, :refundable_fee, :ext]
@spec new(
resources :: resources_type(),
refundable_fee :: refundable_fee_type(),
ext :: ext_type()
) :: t()
def new(
%SorobanResources{} = resources,
%Int64{} = refundable_fee,
%ExtensionPoint{} = ext
),
do: %__MODULE__{resources: resources, refundable_fee: refundable_fee, ext: ext}
@impl true
def encode_xdr(%__MODULE__{resources: resources, refundable_fee: refundable_fee, ext: ext}) do
[resources: resources, refundable_fee: refundable_fee, ext: ext]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr()
end
@impl true
def encode_xdr!(%__MODULE__{resources: resources, refundable_fee: refundable_fee, ext: ext}) do
[resources: resources, refundable_fee: refundable_fee, ext: ext]
|> 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: [resources: resources, refundable_fee: refundable_fee, ext: ext]},
rest}} ->
{:ok, {new(resources, refundable_fee, ext), rest}}
error ->
error
end
end
@impl true
def decode_xdr!(bytes, struct \\ @struct_spec)
def decode_xdr!(bytes, struct) do
{%XDR.Struct{components: [resources: resources, refundable_fee: refundable_fee, ext: ext]},
rest} = XDR.Struct.decode_xdr!(bytes, struct)
{new(resources, refundable_fee, ext), rest}
end
end