Skip to content

Commit

Permalink
Merge pull request #133 from kommitters/v0.16
Browse files Browse the repository at this point in the history
Release v0.16.0
  • Loading branch information
Odraxs authored Sep 27, 2023
2 parents f2ed161 + a12be76 commit 6adfabc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.16.0 (27.09.2023)

- [Testnet Support](https://github.com/kommitters/soroban.ex/issues/131).

## 0.15.0 (21.09.2023)

- [Soroban Preview 11 support](https://github.com/kommitters/soroban.ex/issues/126).
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
```elixir
def deps do
[
{:soroban, "~> 0.15.0"}
{:soroban, "~> 0.16.0"}
]
end
```
Expand Down Expand Up @@ -199,6 +199,12 @@ Struct.new([field1, field2])

Interaction with the Soroban-RPC server is done through the `Soroban.RPC` module.

Currently, `Soroban.ex` can run on `Futurenet`, `Testnet`, and `Local`, the former being the default network. To use the `Testnet` network change the :stellar_sdk setting, which will also change to the RPC endpoint that works with that network. e.g.

```elixir
config :stellar_sdk, network: :test
```

#### Simulate Transaction

Submit a trial contract invocation to get back return values, expected ledger footprint, and expected costs.
Expand Down
12 changes: 10 additions & 2 deletions lib/rpc/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ defmodule Soroban.RPC.Request do

alias Soroban.RPC.{Client, Error, HTTPError}

@default_url "https://rpc-futurenet.stellar.org:443/"
@base_urls [
test: "https://soroban-testnet.stellar.org",
future: "https://rpc-futurenet.stellar.org",
local: "http://localhost:8000"
]

@type endpoint :: String.t()
@type headers :: [{binary(), binary()}]
Expand All @@ -33,7 +37,8 @@ defmodule Soroban.RPC.Request do

@spec new(endpoint :: endpoint(), opts :: opts()) :: t()
def new(endpoint, opts \\ []) do
url = Keyword.get(opts, :url, @default_url)
default = @base_urls[:future]
url = Keyword.get(opts, :url) || Keyword.get(@base_urls, current_network(), default)

%__MODULE__{
endpoint: endpoint,
Expand All @@ -57,4 +62,7 @@ defmodule Soroban.RPC.Request do
@spec results(response :: response(), opts :: opts()) :: parsed_response()
def results({:ok, results}, as: resource), do: {:ok, resource.new(results)}
def results({:error, error}, _resource), do: {:error, error}

@spec current_network() :: atom()
defp current_network, do: Application.get_env(:stellar_sdk, :network, :future)
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Soroban.MixProject do
use Mix.Project

@version "0.15.0"
@version "0.16.0"
@github_url "https://github.com/kommitters/soroban.ex"

def project do
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Soroban.RPC.RequestTest do
Application.delete_env(:soroban, :http_client_impl)
end)

url = "https://rpc-futurenet.stellar.org:443/"
url = "https://rpc-futurenet.stellar.org"
headers = [{"Content-Type", "application/json"}]
endpoint = "getTransaction"

Expand Down

0 comments on commit 6adfabc

Please sign in to comment.