-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from kommitters/v0.8
Release v0.8
- Loading branch information
Showing
39 changed files
with
1,577 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: StellarSDK CD | ||
|
||
on: | ||
release: | ||
types: | ||
[published] | ||
|
||
jobs: | ||
publish: | ||
name: Publish Release to HEX PM | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
otp: ['23.3'] | ||
elixir: ['1.11'] | ||
env: | ||
HEX_API_KEY: ${{ secrets.HEX_API_KEY }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: erlef/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ matrix.otp }} | ||
elixir-version: ${{ matrix.elixir }} | ||
- uses: actions/cache@v3 | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
restore-keys: | | ||
${{ runner.os }}-mix- | ||
- name: Install Dependencies | ||
run: | | ||
rm -rf deps _build | ||
mix deps.get | ||
- name: Publish | ||
run: HEX_API_KEY=$HEX_API_KEY mix hex.publish --yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
defmodule Stellar.Horizon.FeeStat do | ||
@moduledoc """ | ||
Represents a `FeeStat` resource from Horizon API. | ||
""" | ||
|
||
@behaviour Stellar.Horizon.Resource | ||
|
||
alias Stellar.Horizon.Mapping | ||
|
||
@type t :: %__MODULE__{ | ||
last_ledger: non_neg_integer(), | ||
last_ledger_base_fee: non_neg_integer(), | ||
ledger_capacity_usage: float(), | ||
fee_charged: map(), | ||
max_fee: map() | ||
} | ||
|
||
defstruct [ | ||
:last_ledger, | ||
:last_ledger_base_fee, | ||
:ledger_capacity_usage, | ||
:fee_charged, | ||
:max_fee | ||
] | ||
|
||
@mapping [ | ||
last_ledger: :integer, | ||
last_ledger_base_fee: :integer, | ||
ledger_capacity_usage: :float | ||
] | ||
|
||
@impl true | ||
def new(attrs, opts \\ []) | ||
|
||
def new(attrs, _opts) do | ||
%__MODULE__{} | ||
|> Mapping.build(attrs) | ||
|> Mapping.parse(@mapping) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
defmodule Stellar.Horizon.FeeStats do | ||
@moduledoc """ | ||
Exposes functions to interact with FeeStats in Horizon. | ||
You can: | ||
* Retrieve the fee stats. | ||
Horizon API reference: https://developers.stellar.org/api/aggregations/fee-stats/ | ||
""" | ||
|
||
alias Stellar.Horizon.{Error, FeeStat, Request} | ||
|
||
@type resource :: FeeStat.t() | ||
@type response :: {:ok, resource()} | {:error, Error.t()} | ||
|
||
@endpoint "fee_stats" | ||
|
||
@doc """ | ||
Retrieves information of the fee stats. | ||
## Examples | ||
iex> FeeStats.retrieve() | ||
{:ok, %FeeStat{}} | ||
""" | ||
|
||
@spec retrieve :: response() | ||
def retrieve do | ||
:get | ||
|> Request.new(@endpoint) | ||
|> Request.perform() | ||
|> Request.results(as: FeeStat) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
defmodule Stellar.Horizon.OrderBook do | ||
@moduledoc """ | ||
Represents an `OrderBook` resource from Horizon API. | ||
""" | ||
|
||
@behaviour Stellar.Horizon.Resource | ||
|
||
alias Stellar.Horizon.Mapping | ||
alias Stellar.Horizon.OrderBook.Price | ||
|
||
@type t :: %__MODULE__{ | ||
bids: list(Price.t()), | ||
asks: list(Price.t()), | ||
base: map(), | ||
counter: map() | ||
} | ||
|
||
defstruct [ | ||
:bids, | ||
:asks, | ||
:base, | ||
:counter | ||
] | ||
|
||
@mapping [ | ||
bids: {:list, :struct, Price}, | ||
asks: {:list, :struct, Price} | ||
] | ||
|
||
@impl true | ||
def new(attrs, opts \\ []) | ||
|
||
def new(attrs, _opts) do | ||
%__MODULE__{} | ||
|> Mapping.build(attrs) | ||
|> Mapping.parse(@mapping) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule Stellar.Horizon.OrderBook.Price do | ||
@moduledoc """ | ||
Represents a `Price` for an order book. | ||
""" | ||
|
||
@behaviour Stellar.Horizon.Resource | ||
|
||
alias Stellar.Horizon.Mapping | ||
|
||
@type t :: %__MODULE__{ | ||
price_r: map(), | ||
price: float(), | ||
amount: float() | ||
} | ||
|
||
defstruct [ | ||
:price_r, | ||
:price, | ||
:amount | ||
] | ||
|
||
@mapping [ | ||
price: :float, | ||
amount: :float | ||
] | ||
|
||
@impl true | ||
def new(attrs, opts \\ []) | ||
|
||
def new(attrs, _opts) do | ||
%__MODULE__{} | ||
|> Mapping.build(attrs) | ||
|> Mapping.parse(@mapping) | ||
end | ||
end |
Oops, something went wrong.