defmodule StellarBase.XDR.CreateContractArgsV2 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 `CreateContractArgsV2` type. """ @behaviour XDR.Declaration alias StellarBase.XDR.{ ContractIDPreimage, ContractExecutable, SCValList } @struct_spec XDR.Struct.new( contract_id_preimage: ContractIDPreimage, executable: ContractExecutable, constructor_args: SCValList ) @type contract_id_preimage_type :: ContractIDPreimage.t() @type executable_type :: ContractExecutable.t() @type constructor_args_type :: SCValList.t() @type t :: %__MODULE__{ contract_id_preimage: contract_id_preimage_type(), executable: executable_type(), constructor_args: constructor_args_type() } defstruct [:contract_id_preimage, :executable, :constructor_args] @spec new( contract_id_preimage :: contract_id_preimage_type(), executable :: executable_type(), constructor_args :: constructor_args_type() ) :: t() def new( %ContractIDPreimage{} = contract_id_preimage, %ContractExecutable{} = executable, %SCValList{} = constructor_args ), do: %__MODULE__{ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args } @impl true def encode_xdr(%__MODULE__{ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args }) do [ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args ] |> XDR.Struct.new() |> XDR.Struct.encode_xdr() end @impl true def encode_xdr!(%__MODULE__{ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args }) do [ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args ] |> 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: [ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args ] }, rest}} -> {:ok, {new(contract_id_preimage, executable, constructor_args), rest}} error -> error end end @impl true def decode_xdr!(bytes, struct \\ @struct_spec) def decode_xdr!(bytes, struct) do {%XDR.Struct{ components: [ contract_id_preimage: contract_id_preimage, executable: executable, constructor_args: constructor_args ] }, rest} = XDR.Struct.decode_xdr!(bytes, struct) {new(contract_id_preimage, executable, constructor_args), rest} end end