Skip to content

Commit 505ad81

Browse files
authored
Merge pull request #242 from kommitters/v0.9
Release v0.9.0
2 parents 16b1ad1 + 5e77a0d commit 505ad81

325 files changed

Lines changed: 15106 additions & 342 deletions

File tree

Some content is hidden

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

.github/workflows/cd.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
2121
steps:
2222
- name: Harden Runner
23-
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
23+
uses: step-security/harden-runner@1f99358870fe1c846a3ccba386cc2b2246836776 # v2.2.1
2424
with:
2525
disable-sudo: true
2626
egress-policy: block
@@ -29,12 +29,12 @@ jobs:
2929
hex.pm:443
3030
repo.hex.pm:443
3131
32-
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
32+
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
3333
- uses: erlef/setup-elixir@e3f6ffe2878180f57318bf13febd3933ee81f664 # v1.15.2
3434
with:
3535
otp-version: ${{ matrix.otp }}
3636
elixir-version: ${{ matrix.elixir }}
37-
- uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
37+
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
3838
with:
3939
path: deps
4040
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
MIX_ENV: test
2323
steps:
2424
- name: Harden Runner
25-
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
25+
uses: step-security/harden-runner@1f99358870fe1c846a3ccba386cc2b2246836776 # v2.2.1
2626
with:
2727
disable-sudo: true
2828
egress-policy: block
@@ -32,7 +32,7 @@ jobs:
3232
repo.hex.pm:443
3333
3434
- name: Checkout Github repo
35-
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
35+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
3636

3737
- name: Sets up an Erlang/OTP environment
3838
uses: erlef/setup-elixir@e3f6ffe2878180f57318bf13febd3933ee81f664 # v1.15.2
@@ -47,7 +47,7 @@ jobs:
4747
echo "::set-output name=mix_hash::$mix_hash"
4848
4949
- name: Cache dependecies
50-
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
50+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
5151
with:
5252
path: deps
5353
key: ${{ runner.os }}-mix-${{ steps.set_vars.outputs.mix_hash }}
@@ -56,7 +56,7 @@ jobs:
5656
5757
- name: Cache PLT files
5858
id: plt-cache
59-
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
59+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
6060
with:
6161
path: |
6262
_build
@@ -90,7 +90,7 @@ jobs:
9090
runs-on: ubuntu-20.04
9191
steps:
9292
- name: Harden Runner
93-
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
93+
uses: step-security/harden-runner@1f99358870fe1c846a3ccba386cc2b2246836776 # v2.2.1
9494
with:
9595
disable-sudo: true
9696
egress-policy: block

.github/workflows/scorecards.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
steps:
2424
- name: Harden Runner
25-
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
25+
uses: step-security/harden-runner@1f99358870fe1c846a3ccba386cc2b2246836776 # v2.2.1
2626
with:
2727
disable-sudo: true
2828
egress-policy: block
@@ -37,7 +37,7 @@ jobs:
3737
sigstore-tuf-root.storage.googleapis.com:443
3838
3939
- name: "Checkout code"
40-
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
40+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
4141
with:
4242
persist-credentials: false
4343

@@ -69,6 +69,6 @@ jobs:
6969

7070
# Upload the results to GitHub's code scanning dashboard.
7171
- name: "Upload to code-scanning"
72-
uses: github/codeql-action/upload-sarif@959cbb7472c4d4ad70cdfe6f4976053fe48ab394 # v2.1.37
72+
uses: github/codeql-action/upload-sarif@04df1262e6247151b5ac09cd2c303ac36ad3f62b # v2.2.9
7373
with:
7474
sarif_file: results.sarif

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ stellar_sdk-*.tar
2828

2929
# DS_Store
3030
.DS_Store
31+
32+
.elixir_ls

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.9.0 (29.03.2023)
4+
* Add [CAP-0046 support](https://github.com/kommitters/stellar_base/issues/223) in the XDR version: [df18148747e807618acf4639db41c4fd6f0be9fc](https://github.com/stellar/stellar-xdr/commit/df18148747e807618acf4639db41c4fd6f0be9fc) which corresponds to the [Soroban Preview 7](https://soroban.stellar.org/docs/reference/releases#preview-7-february-16th-2023).
5+
* Update all dependencies.
6+
* Fix LICENSE badge URL.
7+
38
## 0.8.11 (16.01.2023)
49
* Update all dependencies.
510
* Block egress traffic in GitHub Actions.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Coverage Status](https://img.shields.io/coveralls/github/kommitters/stellar_base?style=for-the-badge)](https://coveralls.io/github/kommitters/stellar_base)
66
[![Version Badge](https://img.shields.io/hexpm/v/stellar_base?style=for-the-badge)](https://hexdocs.pm/stellar_base)
77
![Downloads Badge](https://img.shields.io/hexpm/dt/stellar_base?style=for-the-badge)
8-
[![License badge](https://img.shields.io/hexpm/l/stellar_base.svg?style=for-the-badge)](https://github.com/kommitters/stellar_base/blob/main/LICENSE.md)
8+
[![License badge](https://img.shields.io/hexpm/l/stellar_base.svg?style=for-the-badge)](https://github.com/kommitters/stellar_base/blob/main/LICENSE)
99
[![OpenSSF Best Practices](https://img.shields.io/cii/summary/6461?label=openssf%20best%20practices&style=for-the-badge)](https://bestpractices.coreinfrastructure.org/projects/6461)
1010
[![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/kommitters/stellar_base?label=openssf%20scorecard&style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/kommitters/stellar_base)
1111

@@ -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.8.11"}
29+
{:stellar_base, "~> 0.9.0"}
3030
]
3131
end
3232
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
defmodule StellarBase.XDR.SCEnvMetaEntry do
2+
@moduledoc """
3+
Representation of Stellar `SCEnvMetaEntry` type.
4+
"""
5+
6+
alias StellarBase.XDR.{UInt64, SCEnvMetaKind}
7+
8+
@behaviour XDR.Declaration
9+
10+
@arms [
11+
SC_ENV_META_KIND_INTERFACE_VERSION: UInt64
12+
]
13+
14+
@type entry :: UInt64.t()
15+
16+
@type t :: %__MODULE__{entry: entry(), kind: SCEnvMetaKind.t()}
17+
18+
defstruct [:entry, :kind]
19+
20+
@spec new(entry :: entry(), kind :: SCEnvMetaKind.t()) :: t()
21+
def new(entry, %SCEnvMetaKind{} = kind), do: %__MODULE__{entry: entry, kind: kind}
22+
23+
@impl true
24+
def encode_xdr(%__MODULE__{entry: entry, kind: kind}) do
25+
kind
26+
|> XDR.Union.new(@arms, entry)
27+
|> XDR.Union.encode_xdr()
28+
end
29+
30+
@impl true
31+
def encode_xdr!(%__MODULE__{entry: entry, kind: kind}) do
32+
kind
33+
|> XDR.Union.new(@arms, entry)
34+
|> XDR.Union.encode_xdr!()
35+
end
36+
37+
@impl true
38+
def decode_xdr(bytes, spec \\ union_spec())
39+
40+
def decode_xdr(bytes, spec) do
41+
case XDR.Union.decode_xdr(bytes, spec) do
42+
{:ok, {{kind, entry}, rest}} -> {:ok, {new(entry, kind), rest}}
43+
error -> error
44+
end
45+
end
46+
47+
@impl true
48+
def decode_xdr!(bytes, spec \\ union_spec())
49+
50+
def decode_xdr!(bytes, spec) do
51+
{{kind, entry}, rest} = XDR.Union.decode_xdr!(bytes, spec)
52+
{new(entry, kind), rest}
53+
end
54+
55+
@spec union_spec() :: XDR.Union.t()
56+
defp union_spec do
57+
nil
58+
|> SCEnvMetaKind.new()
59+
|> XDR.Union.new(@arms)
60+
end
61+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
defmodule StellarBase.XDR.SCEnvMetaKind do
2+
@moduledoc """
3+
Representation of Stellar `SCEnvMetaKind` type.
4+
"""
5+
6+
@behaviour XDR.Declaration
7+
8+
@declarations [
9+
SC_ENV_META_KIND_INTERFACE_VERSION: 0
10+
]
11+
12+
@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}
13+
14+
@type t :: %__MODULE__{identifier: atom()}
15+
16+
defstruct [:identifier]
17+
18+
@spec new(type :: atom()) :: t()
19+
def new(type \\ :SC_ENV_META_KIND_INTERFACE_VERSION), do: %__MODULE__{identifier: type}
20+
21+
@impl true
22+
def encode_xdr(%__MODULE__{identifier: type}) do
23+
@declarations
24+
|> XDR.Enum.new(type)
25+
|> XDR.Enum.encode_xdr()
26+
end
27+
28+
@impl true
29+
def encode_xdr!(%__MODULE__{identifier: type}) do
30+
@declarations
31+
|> XDR.Enum.new(type)
32+
|> XDR.Enum.encode_xdr!()
33+
end
34+
35+
@impl true
36+
def decode_xdr(bytes, spec \\ @enum_spec)
37+
38+
def decode_xdr(bytes, spec) do
39+
case XDR.Enum.decode_xdr(bytes, spec) do
40+
{:ok, {%XDR.Enum{identifier: type}, rest}} -> {:ok, {new(type), rest}}
41+
error -> error
42+
end
43+
end
44+
45+
@impl true
46+
def decode_xdr!(bytes, spec \\ @enum_spec)
47+
48+
def decode_xdr!(bytes, spec) do
49+
{%XDR.Enum{identifier: type}, rest} = XDR.Enum.decode_xdr!(bytes, spec)
50+
{new(type), rest}
51+
end
52+
end

lib/xdr/contract/int128_parts.ex

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

0 commit comments

Comments
 (0)