defmodule StellarBase.XDR.HashIDPreimageCreateContractArgs 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 `HashIDPreimageCreateContractArgs` type. """ @behaviour XDR.Declaration alias StellarBase.XDR.{ Hash, SCContractExecutable, UInt256 } @struct_spec XDR.Struct.new( network_id: Hash, executable: SCContractExecutable, salt: UInt256 ) @type network_id_type :: Hash.t() @type executable_type :: SCContractExecutable.t() @type salt_type :: UInt256.t() @type t :: %__MODULE__{ network_id: network_id_type(), executable: executable_type(), salt: salt_type() } defstruct [:network_id, :executable, :salt] @spec new(network_id :: network_id_type(), executable :: executable_type(), salt :: salt_type()) :: t() def new( %Hash{} = network_id, %SCContractExecutable{} = executable, %UInt256{} = salt ), do: %__MODULE__{network_id: network_id, executable: executable, salt: salt} @impl true def encode_xdr(%__MODULE__{network_id: network_id, executable: executable, salt: salt}) do [network_id: network_id, executable: executable, salt: salt] |> XDR.Struct.new() |> XDR.Struct.encode_xdr() end @impl true def encode_xdr!(%__MODULE__{network_id: network_id, executable: executable, salt: salt}) do [network_id: network_id, executable: executable, salt: salt] |> 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: [network_id: network_id, executable: executable, salt: salt]}, rest}} -> {:ok, {new(network_id, executable, salt), rest}} error -> error end end @impl true def decode_xdr!(bytes, struct \\ @struct_spec) def decode_xdr!(bytes, struct) do {%XDR.Struct{components: [network_id: network_id, executable: executable, salt: salt]}, rest} = XDR.Struct.decode_xdr!(bytes, struct) {new(network_id, executable, salt), rest} end end