Skip to content

Commit

Permalink
Support stellar transaction
Browse files Browse the repository at this point in the history
Co-authored-by: norn <keliumJU@users.noreply.github.com>
  • Loading branch information
CristhianRodriguezMolina and keliumJU committed Oct 26, 2023
1 parent c4a4140 commit 196bec7
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 306 deletions.
6 changes: 3 additions & 3 deletions lib/xdr/transactions/operation_body.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule StellarBase.XDR.OperationBody do
alias StellarBase.XDR.Operations.{
AllowTrust,
BeginSponsoringFutureReserves,
BumpFootprintExpiration,
ExtendFootprintTTL,
BumpSequence,
ChangeTrust,
Clawback,
Expand Down Expand Up @@ -69,7 +69,7 @@ defmodule StellarBase.XDR.OperationBody do
LIQUIDITY_POOL_DEPOSIT: LiquidityPoolDeposit,
LIQUIDITY_POOL_WITHDRAW: LiquidityPoolWithdraw,
INVOKE_HOST_FUNCTION: InvokeHostFunction,
BUMP_FOOTPRINT_EXPIRATION: BumpFootprintExpiration,
EXTEND_FOOTPRINT_TTL: ExtendFootprintTTL,
RESTORE_FOOTPRINT: RestoreFootprint
]

Expand Down Expand Up @@ -98,7 +98,7 @@ defmodule StellarBase.XDR.OperationBody do
| LiquidityPoolDeposit.t()
| LiquidityPoolWithdraw.t()
| InvokeHostFunction.t()
| BumpFootprintExpiration.t()
| ExtendFootprintTTL.t()
| RestoreFootprint.t()

@type t :: %__MODULE__{value: value(), type: OperationType.t()}
Expand Down
6 changes: 3 additions & 3 deletions lib/xdr/transactions/operation_result_tr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule StellarBase.XDR.OperationResultTr do
AccountMergeResult,
AllowTrustResult,
BeginSponsoringFutureReservesResult,
BumpFootprintExpirationResult,
ExtendFootprintTTLResult,
BumpSequenceResult,
ChangeTrustResult,
ClaimClaimableBalanceResult,
Expand Down Expand Up @@ -67,7 +67,7 @@ defmodule StellarBase.XDR.OperationResultTr do
LIQUIDITY_POOL_DEPOSIT: LiquidityPoolDepositResult,
LIQUIDITY_POOL_WITHDRAW: LiquidityPoolWithdrawResult,
INVOKE_HOST_FUNCTION: InvokeHostFunctionResult,
BUMP_FOOTPRINT_EXPIRATION: BumpFootprintExpirationResult,
EXTEND_FOOTPRINT_TTL: ExtendFootprintTTLResult,
RESTORE_FOOTPRINT: RestoreFootprintResult
]

Expand Down Expand Up @@ -96,7 +96,7 @@ defmodule StellarBase.XDR.OperationResultTr do
| LiquidityPoolDepositResult.t()
| LiquidityPoolWithdrawResult.t()
| InvokeHostFunctionResult.t()
| BumpFootprintExpirationResult.t()
| ExtendFootprintTTLResult.t()
| RestoreFootprintResult.t()

@type t :: %__MODULE__{value: value(), type: OperationType.t()}
Expand Down
2 changes: 1 addition & 1 deletion lib/xdr/transactions/operation_type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule StellarBase.XDR.OperationType do
LIQUIDITY_POOL_DEPOSIT: 22,
LIQUIDITY_POOL_WITHDRAW: 23,
INVOKE_HOST_FUNCTION: 24,
BUMP_FOOTPRINT_EXPIRATION: 25,
EXTEND_FOOTPRINT_TTL: 25,
RESTORE_FOOTPRINT: 26
]

Expand Down
73 changes: 0 additions & 73 deletions lib/xdr/transactions/operations/bump_footprint_expiration.ex

This file was deleted.

73 changes: 73 additions & 0 deletions lib/xdr/transactions/operations/extend_footprint_ttl.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
defmodule StellarBase.XDR.Operations.ExtendFootprintTTL 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 `ExtendFootprintTTL` type.
"""

@behaviour XDR.Declaration

alias StellarBase.XDR.{
ExtensionPoint,
UInt32
}

@struct_spec XDR.Struct.new(
ext: ExtensionPoint,
extend_to: UInt32
)

@type ext_type :: ExtensionPoint.t()
@type extend_to_type :: UInt32.t()

@type t :: %__MODULE__{ext: ext_type(), extend_to: extend_to_type()}

defstruct [:ext, :extend_to]

@spec new(ext :: ext_type(), extend_to :: extend_to_type()) :: t()
def new(
%ExtensionPoint{} = ext,
%UInt32{} = extend_to
),
do: %__MODULE__{ext: ext, extend_to: extend_to}

@impl true
def encode_xdr(%__MODULE__{ext: ext, extend_to: extend_to}) do
[ext: ext, extend_to: extend_to]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr()
end

@impl true
def encode_xdr!(%__MODULE__{ext: ext, extend_to: extend_to}) do
[ext: ext, extend_to: extend_to]
|> 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: [ext: ext, extend_to: extend_to]}, rest}} ->
{:ok, {new(ext, extend_to), rest}}

error ->
error
end
end

@impl true
def decode_xdr!(bytes, struct \\ @struct_spec)

def decode_xdr!(bytes, struct) do
{%XDR.Struct{components: [ext: ext, extend_to: extend_to]}, rest} =
XDR.Struct.decode_xdr!(bytes, struct)

{new(ext, extend_to), rest}
end
end
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResult do
defmodule StellarBase.XDR.Operations.ExtendFootprintTTLResult 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 `BumpFootprintExpirationResult` type.
Representation of Stellar `ExtendFootprintTTLResult` type.
"""

@behaviour XDR.Declaration

alias StellarBase.XDR.Void
alias StellarBase.XDR.Operations.BumpFootprintExpirationResultCode
alias StellarBase.XDR.Operations.ExtendFootprintTTLResultCode

@arms [
BUMP_FOOTPRINT_EXPIRATION_SUCCESS: Void,
BUMP_FOOTPRINT_EXPIRATION_MALFORMED: Void,
BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: Void,
BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: Void
EXTEND_FOOTPRINT_TTL_SUCCESS: Void,
EXTEND_FOOTPRINT_TTL_MALFORMED: Void,
EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: Void,
EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: Void
]

@type value ::
Void.t()

@type t :: %__MODULE__{value: value(), type: BumpFootprintExpirationResultCode.t()}
@type t :: %__MODULE__{value: value(), type: ExtendFootprintTTLResultCode.t()}

defstruct [:value, :type]

@spec new(value :: value(), type :: BumpFootprintExpirationResultCode.t()) :: t()
def new(value, %BumpFootprintExpirationResultCode{} = type),
@spec new(value :: value(), type :: ExtendFootprintTTLResultCode.t()) :: t()
def new(value, %ExtendFootprintTTLResultCode{} = type),
do: %__MODULE__{value: value, type: type}

@impl true
Expand Down Expand Up @@ -66,7 +66,7 @@ defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResult do
@spec union_spec() :: XDR.Union.t()
defp union_spec do
nil
|> BumpFootprintExpirationResultCode.new()
|> ExtendFootprintTTLResultCode.new()
|> XDR.Union.new(@arms)
end
end
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResultCode do
defmodule StellarBase.XDR.Operations.ExtendFootprintTTLResultCode 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 `BumpFootprintExpirationResultCode` type.
Representation of Stellar `ExtendFootprintTTLResultCode` type.
"""

@behaviour XDR.Declaration

@declarations [
BUMP_FOOTPRINT_EXPIRATION_SUCCESS: 0,
BUMP_FOOTPRINT_EXPIRATION_MALFORMED: -1,
BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: -2,
BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: -3
EXTEND_FOOTPRINT_TTL_SUCCESS: 0,
EXTEND_FOOTPRINT_TTL_MALFORMED: -1,
EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: -2,
EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: -3
]

@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}
Expand All @@ -24,7 +24,7 @@ defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResultCode do
defstruct [:identifier]

@spec new(type :: atom()) :: t()
def new(type \\ :BUMP_FOOTPRINT_EXPIRATION_SUCCESS), do: %__MODULE__{identifier: type}
def new(type \\ :EXTEND_FOOTPRINT_TTL_SUCCESS), do: %__MODULE__{identifier: type}

@impl true
def encode_xdr(%__MODULE__{identifier: type}) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule StellarBase.XDR.Operations.InvokeHostFunctionResult do
INVOKE_HOST_FUNCTION_MALFORMED: Void,
INVOKE_HOST_FUNCTION_TRAPPED: Void,
INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: Void,
INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: Void,
INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: Void,
INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: Void
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule StellarBase.XDR.Operations.InvokeHostFunctionResultCode do
INVOKE_HOST_FUNCTION_MALFORMED: -1,
INVOKE_HOST_FUNCTION_TRAPPED: -2,
INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: -3,
INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: -4,
INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: -4,
INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: -5
]

Expand Down
32 changes: 16 additions & 16 deletions lib/xdr/transactions/soroban_transaction_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,43 @@ defmodule StellarBase.XDR.SorobanTransactionData do
@struct_spec XDR.Struct.new(
ext: ExtensionPoint,
resources: SorobanResources,
refundable_fee: Int64
resource_fee: Int64
)

@type ext_type :: ExtensionPoint.t()
@type resources_type :: SorobanResources.t()
@type refundable_fee_type :: Int64.t()
@type resource_fee_type :: Int64.t()

@type t :: %__MODULE__{
ext: ext_type(),
resources: resources_type(),
refundable_fee: refundable_fee_type()
resource_fee: resource_fee_type()
}

defstruct [:ext, :resources, :refundable_fee]
defstruct [:ext, :resources, :resource_fee]

@spec new(
ext :: ext_type(),
resources :: resources_type(),
refundable_fee :: refundable_fee_type()
resource_fee :: resource_fee_type()
) :: t()
def new(
%ExtensionPoint{} = ext,
%SorobanResources{} = resources,
%Int64{} = refundable_fee
%Int64{} = resource_fee
),
do: %__MODULE__{ext: ext, resources: resources, refundable_fee: refundable_fee}
do: %__MODULE__{ext: ext, resources: resources, resource_fee: resource_fee}

@impl true
def encode_xdr(%__MODULE__{ext: ext, resources: resources, refundable_fee: refundable_fee}) do
[ext: ext, resources: resources, refundable_fee: refundable_fee]
def encode_xdr(%__MODULE__{ext: ext, resources: resources, resource_fee: resource_fee}) do
[ext: ext, resources: resources, resource_fee: resource_fee]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr()
end

@impl true
def encode_xdr!(%__MODULE__{ext: ext, resources: resources, refundable_fee: refundable_fee}) do
[ext: ext, resources: resources, refundable_fee: refundable_fee]
def encode_xdr!(%__MODULE__{ext: ext, resources: resources, resource_fee: resource_fee}) do
[ext: ext, resources: resources, resource_fee: resource_fee]
|> XDR.Struct.new()
|> XDR.Struct.encode_xdr!()
end
Expand All @@ -66,9 +66,9 @@ defmodule StellarBase.XDR.SorobanTransactionData do
def decode_xdr(bytes, struct) do
case XDR.Struct.decode_xdr(bytes, struct) do
{:ok,
{%XDR.Struct{components: [ext: ext, resources: resources, refundable_fee: refundable_fee]},
{%XDR.Struct{components: [ext: ext, resources: resources, resource_fee: resource_fee]},
rest}} ->
{:ok, {new(ext, resources, refundable_fee), rest}}
{:ok, {new(ext, resources, resource_fee), rest}}

error ->
error
Expand All @@ -79,9 +79,9 @@ defmodule StellarBase.XDR.SorobanTransactionData do
def decode_xdr!(bytes, struct \\ @struct_spec)

def decode_xdr!(bytes, struct) do
{%XDR.Struct{components: [ext: ext, resources: resources, refundable_fee: refundable_fee]},
rest} = XDR.Struct.decode_xdr!(bytes, struct)
{%XDR.Struct{components: [ext: ext, resources: resources, resource_fee: resource_fee]}, rest} =
XDR.Struct.decode_xdr!(bytes, struct)

{new(ext, resources, refundable_fee), rest}
{new(ext, resources, resource_fee), rest}
end
end
Loading

0 comments on commit 196bec7

Please sign in to comment.