Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.10.0 #256

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.10.0 (24.04.2023)

* Add [Soroban Preview 8](https://soroban.stellar.org/docs/reference/releases#preview-8-april-4th-2023) Support in the XDR version: [7356dc237ee0db5626561c129fb3fa4beaabbac6](https://github.com/stellar/stellar-xdr/commit/7356dc237ee0db5626561c129fb3fa4beaabbac6) with its respective [Preview 8 changes](https://github.com/stellar/stellar-xdr/compare/df18148747e807618acf4639db41c4fd6f0be9fc...7356dc237ee0db5626561c129fb3fa4beaabbac6#diff-891b3a6e0eb8f9ac887a8129e2c821931837fb42224200ee78cce639eeb61c15).

## 0.9.1 (31.03.2023)
* Update boundary for InvokeHostFuntion, from `StellarBase.XDR.InvokeHostFunctionOp` to `StellarBase.XDR.Operations.InvokeHostFunction`.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You should only use **`stellar_base`** if you are planning to build on top of it
```elixir
def deps do
[
{:stellar_base, "~> 0.9.1"}
{:stellar_base, "~> 0.10.0"}
]
end
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
defmodule StellarBase.XDR.OptionalSCObject do
defmodule StellarBase.XDR.OptionalSCMap do
@moduledoc """
Representation of Stellar `OptionalSCObject` type.
Representation of Stellar `OptionalSCMap` type.
"""

alias StellarBase.XDR.SCObject
alias StellarBase.XDR.SCMap

@behaviour XDR.Declaration

@optional_spec XDR.Optional.new(SCObject)
@optional_spec XDR.Optional.new(SCMap)

@type sc_object :: SCObject.t() | nil
@type sc_map :: SCMap.t() | nil

@type t :: %__MODULE__{sc_object: sc_object()}
@type t :: %__MODULE__{sc_map: sc_map()}

defstruct [:sc_object]
defstruct [:sc_map]

@spec new(sc_object :: sc_object()) :: t()
def new(sc_object \\ nil), do: %__MODULE__{sc_object: sc_object}
@spec new(sc_map :: sc_map()) :: t()
def new(sc_map \\ nil), do: %__MODULE__{sc_map: sc_map}

@impl true
def encode_xdr(%__MODULE__{sc_object: sc_object}) do
sc_object
def encode_xdr(%__MODULE__{sc_map: sc_map}) do
sc_map
|> XDR.Optional.new()
|> XDR.Optional.encode_xdr()
end

@impl true
def encode_xdr!(%__MODULE__{sc_object: sc_object}) do
sc_object
def encode_xdr!(%__MODULE__{sc_map: sc_map}) do
sc_map
|> XDR.Optional.new()
|> XDR.Optional.encode_xdr!()
end
Expand All @@ -37,8 +37,8 @@ defmodule StellarBase.XDR.OptionalSCObject do

def decode_xdr(bytes, optional_spec) do
case XDR.Optional.decode_xdr(bytes, optional_spec) do
{:ok, {%XDR.Optional{type: sc_object}, rest}} ->
{:ok, {new(sc_object), rest}}
{:ok, {%XDR.Optional{type: sc_map}, rest}} ->
{:ok, {new(sc_map), rest}}

{:ok, {nil, rest}} ->
{:ok, {new(), rest}}
Expand All @@ -53,7 +53,7 @@ defmodule StellarBase.XDR.OptionalSCObject do

def decode_xdr!(bytes, optional_spec) do
case XDR.Optional.decode_xdr!(bytes, optional_spec) do
{%XDR.Optional{type: sc_object}, rest} -> {new(sc_object), rest}
{%XDR.Optional{type: sc_map}, rest} -> {new(sc_map), rest}
{nil, rest} -> {new(), rest}
end
end
Expand Down
60 changes: 60 additions & 0 deletions lib/xdr/contract/optional_sc_vec.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
defmodule StellarBase.XDR.OptionalSCVec do
@moduledoc """
Representation of Stellar `OptionalSCVec` type.
"""

alias StellarBase.XDR.SCVec

@behaviour XDR.Declaration

@optional_spec XDR.Optional.new(SCVec)

@type sc_vec :: SCVec.t() | nil

@type t :: %__MODULE__{sc_vec: sc_vec()}

defstruct [:sc_vec]

@spec new(sc_vec :: sc_vec()) :: t()
def new(sc_vec \\ nil), do: %__MODULE__{sc_vec: sc_vec}

@impl true
def encode_xdr(%__MODULE__{sc_vec: sc_vec}) do
sc_vec
|> XDR.Optional.new()
|> XDR.Optional.encode_xdr()
end

@impl true
def encode_xdr!(%__MODULE__{sc_vec: sc_vec}) do
sc_vec
|> XDR.Optional.new()
|> XDR.Optional.encode_xdr!()
end

@impl true
def decode_xdr(bytes, optional_spec \\ @optional_spec)

def decode_xdr(bytes, optional_spec) do
case XDR.Optional.decode_xdr(bytes, optional_spec) do
{:ok, {%XDR.Optional{type: sc_vec}, rest}} ->
{:ok, {new(sc_vec), rest}}

{:ok, {nil, rest}} ->
{:ok, {new(), rest}}

error ->
error
end
end

@impl true
def decode_xdr!(bytes, optional_spec \\ @optional_spec)

def decode_xdr!(bytes, optional_spec) do
case XDR.Optional.decode_xdr!(bytes, optional_spec) do
{%XDR.Optional{type: sc_vec}, rest} -> {new(sc_vec), rest}
{nil, rest} -> {new(), rest}
end
end
end
47 changes: 47 additions & 0 deletions lib/xdr/contract/sc_bytes.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
defmodule StellarBase.XDR.SCBytes do
@moduledoc """
Representation of Stellar `SCBytes` type.
"""
alias StellarBase.XDR.VariableOpaque256000

@behaviour XDR.Declaration

@type t :: %__MODULE__{value: binary()}

defstruct [:value]

@spec new(value :: binary()) :: t()
def new(value), do: %__MODULE__{value: value}

@impl true
def encode_xdr(%__MODULE__{value: value}) do
value
|> VariableOpaque256000.new()
|> VariableOpaque256000.encode_xdr()
end

@impl true
def encode_xdr!(%__MODULE__{value: value}) do
value
|> VariableOpaque256000.new()
|> VariableOpaque256000.encode_xdr!()
end

@impl true
def decode_xdr(bytes, term \\ nil)

def decode_xdr(bytes, _term) do
case VariableOpaque256000.decode_xdr(bytes) do
{:ok, {%VariableOpaque256000{opaque: value}, rest}} -> {:ok, {new(value), rest}}
error -> error
end
end

@impl true
def decode_xdr!(bytes, term \\ nil)

def decode_xdr!(bytes, _term) do
{%VariableOpaque256000{opaque: value}, rest} = VariableOpaque256000.decode_xdr!(bytes)
{new(value), rest}
end
end
63 changes: 0 additions & 63 deletions lib/xdr/contract/sc_contract_code.ex

This file was deleted.

67 changes: 67 additions & 0 deletions lib/xdr/contract/sc_contract_executable.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
defmodule StellarBase.XDR.SCContractExecutable do
@moduledoc """
Representation of Stellar `SCContractExecutable` type.
"""

alias StellarBase.XDR.{Hash, SCContractExecutableType, Void}

@behaviour XDR.Declaration

@arms [
SCCONTRACT_EXECUTABLE_WASM_REF: Hash,
SCCONTRACT_EXECUTABLE_TOKEN: Void
]

@type contract_executable :: Hash.t() | Void.t()

@type t :: %__MODULE__{
contract_executable: contract_executable(),
type: SCContractExecutableType.t()
}

defstruct [:contract_executable, :type]

@spec new(contract_executable :: contract_executable(), type :: SCContractExecutableType.t()) ::
t()
def new(contract_executable, %SCContractExecutableType{} = type),
do: %__MODULE__{contract_executable: contract_executable, type: type}

@impl true
def encode_xdr(%__MODULE__{contract_executable: contract_executable, type: type}) do
type
|> XDR.Union.new(@arms, contract_executable)
|> XDR.Union.encode_xdr()
end

@impl true
def encode_xdr!(%__MODULE__{contract_executable: contract_executable, type: type}) do
type
|> XDR.Union.new(@arms, contract_executable)
|> 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, contract_executable}, rest}} -> {:ok, {new(contract_executable, type), rest}}
error -> error
end
end

@impl true
def decode_xdr!(bytes, spec \\ union_spec())

def decode_xdr!(bytes, spec) do
{{type, contract_executable}, rest} = XDR.Union.decode_xdr!(bytes, spec)
{new(contract_executable, type), rest}
end

@spec union_spec() :: XDR.Union.t()
defp union_spec do
nil
|> SCContractExecutableType.new()
|> XDR.Union.new(@arms)
end
end
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
defmodule StellarBase.XDR.SCContractCodeType do
defmodule StellarBase.XDR.SCContractExecutableType do
@moduledoc """
Representation of Stellar `SCContractCodeType` type.
Representation of Stellar `SCContractExecutableType` type.
"""

@behaviour XDR.Declaration

@declarations [
SCCONTRACT_CODE_WASM_REF: 0,
SCCONTRACT_CODE_TOKEN: 1
SCCONTRACT_EXECUTABLE_WASM_REF: 0,
SCCONTRACT_EXECUTABLE_TOKEN: 1
]

@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}
Expand Down
Loading
Loading