defmodule StellarBase.XDR.OperationResultTr 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 `OperationResultTr` type.
"""
@behaviour XDR.Declaration
alias StellarBase.XDR.OperationType
alias StellarBase.XDR.Operations.{
AccountMergeResult,
AllowTrustResult,
BeginSponsoringFutureReservesResult,
ExtendFootprintTTLResult,
BumpSequenceResult,
ChangeTrustResult,
ClaimClaimableBalanceResult,
ClawbackClaimableBalanceResult,
ClawbackResult,
CreateAccountResult,
CreateClaimableBalanceResult,
EndSponsoringFutureReservesResult,
InflationResult,
InvokeHostFunctionResult,
LiquidityPoolDepositResult,
LiquidityPoolWithdrawResult,
ManageDataResult,
ManageSellOfferResult,
ManageBuyOfferResult,
PaymentResult,
PathPaymentStrictReceiveResult,
PathPaymentStrictSendResult,
RestoreFootprintResult,
RevokeSponsorshipResult,
SetOptionsResult,
SetTrustLineFlagsResult
}
@arms [
CREATE_ACCOUNT: CreateAccountResult,
PAYMENT: PaymentResult,
PATH_PAYMENT_STRICT_RECEIVE: PathPaymentStrictReceiveResult,
MANAGE_SELL_OFFER: ManageSellOfferResult,
CREATE_PASSIVE_SELL_OFFER: ManageSellOfferResult,
SET_OPTIONS: SetOptionsResult,
CHANGE_TRUST: ChangeTrustResult,
ALLOW_TRUST: AllowTrustResult,
ACCOUNT_MERGE: AccountMergeResult,
INFLATION: InflationResult,
MANAGE_DATA: ManageDataResult,
BUMP_SEQUENCE: BumpSequenceResult,
MANAGE_BUY_OFFER: ManageBuyOfferResult,
PATH_PAYMENT_STRICT_SEND: PathPaymentStrictSendResult,
CREATE_CLAIMABLE_BALANCE: CreateClaimableBalanceResult,
CLAIM_CLAIMABLE_BALANCE: ClaimClaimableBalanceResult,
BEGIN_SPONSORING_FUTURE_RESERVES: BeginSponsoringFutureReservesResult,
END_SPONSORING_FUTURE_RESERVES: EndSponsoringFutureReservesResult,
REVOKE_SPONSORSHIP: RevokeSponsorshipResult,
CLAWBACK: ClawbackResult,
CLAWBACK_CLAIMABLE_BALANCE: ClawbackClaimableBalanceResult,
SET_TRUST_LINE_FLAGS: SetTrustLineFlagsResult,
LIQUIDITY_POOL_DEPOSIT: LiquidityPoolDepositResult,
LIQUIDITY_POOL_WITHDRAW: LiquidityPoolWithdrawResult,
INVOKE_HOST_FUNCTION: InvokeHostFunctionResult,
EXTEND_FOOTPRINT_TTL: ExtendFootprintTTLResult,
RESTORE_FOOTPRINT: RestoreFootprintResult
]
@type value ::
CreateAccountResult.t()
| PaymentResult.t()
| PathPaymentStrictReceiveResult.t()
| ManageSellOfferResult.t()
| SetOptionsResult.t()
| ChangeTrustResult.t()
| AllowTrustResult.t()
| AccountMergeResult.t()
| InflationResult.t()
| ManageDataResult.t()
| BumpSequenceResult.t()
| ManageBuyOfferResult.t()
| PathPaymentStrictSendResult.t()
| CreateClaimableBalanceResult.t()
| ClaimClaimableBalanceResult.t()
| BeginSponsoringFutureReservesResult.t()
| EndSponsoringFutureReservesResult.t()
| RevokeSponsorshipResult.t()
| ClawbackResult.t()
| ClawbackClaimableBalanceResult.t()
| SetTrustLineFlagsResult.t()
| LiquidityPoolDepositResult.t()
| LiquidityPoolWithdrawResult.t()
| InvokeHostFunctionResult.t()
| ExtendFootprintTTLResult.t()
| RestoreFootprintResult.t()
@type t :: %__MODULE__{value: value(), type: OperationType.t()}
defstruct [:value, :type]
@spec new(value :: value(), type :: OperationType.t()) :: t()
def new(value, %OperationType{} = type), do: %__MODULE__{value: value, type: type}
@impl true
def encode_xdr(%__MODULE__{value: value, type: type}) do
type
|> XDR.Union.new(@arms, value)
|> XDR.Union.encode_xdr()
end
@impl true
def encode_xdr!(%__MODULE__{value: value, type: type}) do
type
|> XDR.Union.new(@arms, value)
|> XDR.Union.encode_xdr!()
end
@impl true
def decode_xdr(bytes, spec \\ union_spec())
def decode_xdr(bytes, spec) do
case XDR.Union.decode_xdr(bytes, spec) do
{:ok, {{type, value}, rest}} -> {:ok, {new(value, type), rest}}
error -> error
end
end
@impl true
def decode_xdr!(bytes, spec \\ union_spec())
def decode_xdr!(bytes, spec) do
{{type, value}, rest} = XDR.Union.decode_xdr!(bytes, spec)
{new(value, type), rest}
end
@spec union_spec() :: XDR.Union.t()
defp union_spec do
nil
|> OperationType.new()
|> XDR.Union.new(@arms)
end
end