Skip to content

Commit 8dc4d41

Browse files
Merge pull request #256 from kommitters/v0.10
Release v0.10.0
2 parents 3836e17 + 71eafaf commit 8dc4d41

File tree

63 files changed

+1257
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1257
-862
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.10.0 (24.04.2023)
4+
5+
* 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).
6+
37
## 0.9.1 (31.03.2023)
48
* Update boundary for InvokeHostFuntion, from `StellarBase.XDR.InvokeHostFunctionOp` to `StellarBase.XDR.Operations.InvokeHostFunction`.
59

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You should only use **`stellar_base`** if you are planning to build on top of it
2626
```elixir
2727
def deps do
2828
[
29-
{:stellar_base, "~> 0.9.1"}
29+
{:stellar_base, "~> 0.10.0"}
3030
]
3131
end
3232
```

lib/xdr/contract/optional_sc_object.ex lib/xdr/contract/optional_sc_map.ex

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
defmodule StellarBase.XDR.OptionalSCObject do
1+
defmodule StellarBase.XDR.OptionalSCMap do
22
@moduledoc """
3-
Representation of Stellar `OptionalSCObject` type.
3+
Representation of Stellar `OptionalSCMap` type.
44
"""
55

6-
alias StellarBase.XDR.SCObject
6+
alias StellarBase.XDR.SCMap
77

88
@behaviour XDR.Declaration
99

10-
@optional_spec XDR.Optional.new(SCObject)
10+
@optional_spec XDR.Optional.new(SCMap)
1111

12-
@type sc_object :: SCObject.t() | nil
12+
@type sc_map :: SCMap.t() | nil
1313

14-
@type t :: %__MODULE__{sc_object: sc_object()}
14+
@type t :: %__MODULE__{sc_map: sc_map()}
1515

16-
defstruct [:sc_object]
16+
defstruct [:sc_map]
1717

18-
@spec new(sc_object :: sc_object()) :: t()
19-
def new(sc_object \\ nil), do: %__MODULE__{sc_object: sc_object}
18+
@spec new(sc_map :: sc_map()) :: t()
19+
def new(sc_map \\ nil), do: %__MODULE__{sc_map: sc_map}
2020

2121
@impl true
22-
def encode_xdr(%__MODULE__{sc_object: sc_object}) do
23-
sc_object
22+
def encode_xdr(%__MODULE__{sc_map: sc_map}) do
23+
sc_map
2424
|> XDR.Optional.new()
2525
|> XDR.Optional.encode_xdr()
2626
end
2727

2828
@impl true
29-
def encode_xdr!(%__MODULE__{sc_object: sc_object}) do
30-
sc_object
29+
def encode_xdr!(%__MODULE__{sc_map: sc_map}) do
30+
sc_map
3131
|> XDR.Optional.new()
3232
|> XDR.Optional.encode_xdr!()
3333
end
@@ -37,8 +37,8 @@ defmodule StellarBase.XDR.OptionalSCObject do
3737

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

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

5454
def decode_xdr!(bytes, optional_spec) do
5555
case XDR.Optional.decode_xdr!(bytes, optional_spec) do
56-
{%XDR.Optional{type: sc_object}, rest} -> {new(sc_object), rest}
56+
{%XDR.Optional{type: sc_map}, rest} -> {new(sc_map), rest}
5757
{nil, rest} -> {new(), rest}
5858
end
5959
end

lib/xdr/contract/optional_sc_vec.ex

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
defmodule StellarBase.XDR.OptionalSCVec do
2+
@moduledoc """
3+
Representation of Stellar `OptionalSCVec` type.
4+
"""
5+
6+
alias StellarBase.XDR.SCVec
7+
8+
@behaviour XDR.Declaration
9+
10+
@optional_spec XDR.Optional.new(SCVec)
11+
12+
@type sc_vec :: SCVec.t() | nil
13+
14+
@type t :: %__MODULE__{sc_vec: sc_vec()}
15+
16+
defstruct [:sc_vec]
17+
18+
@spec new(sc_vec :: sc_vec()) :: t()
19+
def new(sc_vec \\ nil), do: %__MODULE__{sc_vec: sc_vec}
20+
21+
@impl true
22+
def encode_xdr(%__MODULE__{sc_vec: sc_vec}) do
23+
sc_vec
24+
|> XDR.Optional.new()
25+
|> XDR.Optional.encode_xdr()
26+
end
27+
28+
@impl true
29+
def encode_xdr!(%__MODULE__{sc_vec: sc_vec}) do
30+
sc_vec
31+
|> XDR.Optional.new()
32+
|> XDR.Optional.encode_xdr!()
33+
end
34+
35+
@impl true
36+
def decode_xdr(bytes, optional_spec \\ @optional_spec)
37+
38+
def decode_xdr(bytes, optional_spec) do
39+
case XDR.Optional.decode_xdr(bytes, optional_spec) do
40+
{:ok, {%XDR.Optional{type: sc_vec}, rest}} ->
41+
{:ok, {new(sc_vec), rest}}
42+
43+
{:ok, {nil, rest}} ->
44+
{:ok, {new(), rest}}
45+
46+
error ->
47+
error
48+
end
49+
end
50+
51+
@impl true
52+
def decode_xdr!(bytes, optional_spec \\ @optional_spec)
53+
54+
def decode_xdr!(bytes, optional_spec) do
55+
case XDR.Optional.decode_xdr!(bytes, optional_spec) do
56+
{%XDR.Optional{type: sc_vec}, rest} -> {new(sc_vec), rest}
57+
{nil, rest} -> {new(), rest}
58+
end
59+
end
60+
end

lib/xdr/contract/sc_bytes.ex

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
defmodule StellarBase.XDR.SCBytes do
2+
@moduledoc """
3+
Representation of Stellar `SCBytes` type.
4+
"""
5+
alias StellarBase.XDR.VariableOpaque256000
6+
7+
@behaviour XDR.Declaration
8+
9+
@type t :: %__MODULE__{value: binary()}
10+
11+
defstruct [:value]
12+
13+
@spec new(value :: binary()) :: t()
14+
def new(value), do: %__MODULE__{value: value}
15+
16+
@impl true
17+
def encode_xdr(%__MODULE__{value: value}) do
18+
value
19+
|> VariableOpaque256000.new()
20+
|> VariableOpaque256000.encode_xdr()
21+
end
22+
23+
@impl true
24+
def encode_xdr!(%__MODULE__{value: value}) do
25+
value
26+
|> VariableOpaque256000.new()
27+
|> VariableOpaque256000.encode_xdr!()
28+
end
29+
30+
@impl true
31+
def decode_xdr(bytes, term \\ nil)
32+
33+
def decode_xdr(bytes, _term) do
34+
case VariableOpaque256000.decode_xdr(bytes) do
35+
{:ok, {%VariableOpaque256000{opaque: value}, rest}} -> {:ok, {new(value), rest}}
36+
error -> error
37+
end
38+
end
39+
40+
@impl true
41+
def decode_xdr!(bytes, term \\ nil)
42+
43+
def decode_xdr!(bytes, _term) do
44+
{%VariableOpaque256000{opaque: value}, rest} = VariableOpaque256000.decode_xdr!(bytes)
45+
{new(value), rest}
46+
end
47+
end

lib/xdr/contract/sc_contract_code.ex

-63
This file was deleted.
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
defmodule StellarBase.XDR.SCContractExecutable do
2+
@moduledoc """
3+
Representation of Stellar `SCContractExecutable` type.
4+
"""
5+
6+
alias StellarBase.XDR.{Hash, SCContractExecutableType, Void}
7+
8+
@behaviour XDR.Declaration
9+
10+
@arms [
11+
SCCONTRACT_EXECUTABLE_WASM_REF: Hash,
12+
SCCONTRACT_EXECUTABLE_TOKEN: Void
13+
]
14+
15+
@type contract_executable :: Hash.t() | Void.t()
16+
17+
@type t :: %__MODULE__{
18+
contract_executable: contract_executable(),
19+
type: SCContractExecutableType.t()
20+
}
21+
22+
defstruct [:contract_executable, :type]
23+
24+
@spec new(contract_executable :: contract_executable(), type :: SCContractExecutableType.t()) ::
25+
t()
26+
def new(contract_executable, %SCContractExecutableType{} = type),
27+
do: %__MODULE__{contract_executable: contract_executable, type: type}
28+
29+
@impl true
30+
def encode_xdr(%__MODULE__{contract_executable: contract_executable, type: type}) do
31+
type
32+
|> XDR.Union.new(@arms, contract_executable)
33+
|> XDR.Union.encode_xdr()
34+
end
35+
36+
@impl true
37+
def encode_xdr!(%__MODULE__{contract_executable: contract_executable, type: type}) do
38+
type
39+
|> XDR.Union.new(@arms, contract_executable)
40+
|> XDR.Union.encode_xdr!()
41+
end
42+
43+
@impl true
44+
def decode_xdr(bytes, spec \\ union_spec())
45+
46+
def decode_xdr(bytes, spec) do
47+
case XDR.Union.decode_xdr(bytes, spec) do
48+
{:ok, {{type, contract_executable}, rest}} -> {:ok, {new(contract_executable, type), rest}}
49+
error -> error
50+
end
51+
end
52+
53+
@impl true
54+
def decode_xdr!(bytes, spec \\ union_spec())
55+
56+
def decode_xdr!(bytes, spec) do
57+
{{type, contract_executable}, rest} = XDR.Union.decode_xdr!(bytes, spec)
58+
{new(contract_executable, type), rest}
59+
end
60+
61+
@spec union_spec() :: XDR.Union.t()
62+
defp union_spec do
63+
nil
64+
|> SCContractExecutableType.new()
65+
|> XDR.Union.new(@arms)
66+
end
67+
end

lib/xdr/contract/sc_contract_code_type.ex lib/xdr/contract/sc_contract_executable_type.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
defmodule StellarBase.XDR.SCContractCodeType do
1+
defmodule StellarBase.XDR.SCContractExecutableType do
22
@moduledoc """
3-
Representation of Stellar `SCContractCodeType` type.
3+
Representation of Stellar `SCContractExecutableType` type.
44
"""
55

66
@behaviour XDR.Declaration
77

88
@declarations [
9-
SCCONTRACT_CODE_WASM_REF: 0,
10-
SCCONTRACT_CODE_TOKEN: 1
9+
SCCONTRACT_EXECUTABLE_WASM_REF: 0,
10+
SCCONTRACT_EXECUTABLE_TOKEN: 1
1111
]
1212

1313
@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}

0 commit comments

Comments
 (0)