Skip to content

Commit

Permalink
Merge pull request #139 from kommitters/v0.17
Browse files Browse the repository at this point in the history
Release v0.17.0
  • Loading branch information
MarioRodriguezS authored Oct 26, 2023
2 parents 6adfabc + c683d75 commit 9866c29
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 12 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.17.0 (26.10.2023)

- [Allow deploying an asset contract by a diferent invoker than the asset issuer](https://github.com/kommitters/soroban.ex/issues/136).

## 0.16.0 (27.09.2023)

- [Testnet Support](https://github.com/kommitters/soroban.ex/issues/131).
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
```elixir
def deps do
[
{:soroban, "~> 0.16.0"}
{:soroban, "~> 0.17.0"}
]
end
```
Expand Down Expand Up @@ -650,6 +650,7 @@ secret_key = "SCA..."
**Parameters**

- `asset_code`: String from 1 to 12 characters indicating the asset symbol.
- `asset_issuer`: Public key of the asset issuer.
- `secret_key`: Secret key of the function invoker responsible for signing the transaction.

```elixir
Expand All @@ -658,9 +659,10 @@ alias Soroban.RPC.SendTransactionResponse
alias Soroban.Contract.DeployAssetContract

asset_code = "DBZ"
asset_issuer = "GBL..."
secret_key = "SCA..."

{:ok, %SendTransactionResponse{hash: hash}} = Contract.deploy_asset(asset_code, secret_key)
{:ok, %SendTransactionResponse{hash: hash}} = Contract.deploy_asset(asset_code, asset_issuer, secret_key)

{:ok,
%Soroban.RPC.SendTransactionResponse{
Expand Down
1 change: 1 addition & 0 deletions lib/contract.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ defmodule Soroban.Contract do

defdelegate deploy_asset(
asset_code,
asset_issuer,
source_secret_key
),
to: DeployAssetContract,
Expand Down
11 changes: 8 additions & 3 deletions lib/contract/deploy_asset_contract.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ defmodule Soroban.Contract.DeployAssetContract do
@type invoke_host_function :: InvokeHostFunction.t()
@type secret_key :: binary()
@type send_response :: {:ok, SendTransactionResponse.t()}
@type asset_issuer :: binary()

@spec deploy(asset_code :: asset_code(), secret_key :: secret_key()) :: send_response()
def deploy(asset_code, secret_key) do
@spec deploy(
asset_code :: asset_code(),
asset_issuer :: asset_issuer(),
secret_key :: secret_key()
) :: send_response()
def deploy(asset_code, asset_issuer, secret_key) do
with {public_key, _secret} = keypair <- Stellar.KeyPair.from_secret_seed(secret_key),
{:ok, seq_num} <- Accounts.fetch_next_sequence_number(public_key),
%Account{} = source_account <- Account.new(public_key),
%SequenceNumber{} = sequence_number <- SequenceNumber.new(seq_num),
%Signature{} = signature <- Signature.new(keypair),
%Asset{} = asset <- Asset.new(code: asset_code, issuer: public_key),
%Asset{} = asset <- Asset.new(code: asset_code, issuer: asset_issuer),
%InvokeHostFunction{} = invoke_host_function_op <- create_host_function_deploy_op(asset) do
invoke_host_function_op
|> RPCCalls.simulate(source_account, sequence_number)
Expand Down
4 changes: 2 additions & 2 deletions 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.16.0"
@version "0.17.0"
@github_url "https://github.com/kommitters/soroban.ex"

def project do
Expand Down Expand Up @@ -44,7 +44,7 @@ defmodule Soroban.MixProject do
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.30", only: :dev, runtime: false},
{:excoveralls, "~> 0.17", only: :test},
{:stellar_sdk, "~> 0.18"},
{:stellar_sdk, "~> 0.18.1"},
{:hackney, "~> 1.18"}
]
end
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"},
"castore": {:hex, :castore, "1.0.4", "ff4d0fb2e6411c0479b1d965a814ea6d00e51eb2f58697446e9c41a97d940b28", [:mix], [], "hexpm", "9418c1b8144e11656f0be99943db4caf04612e3eaecefb5dae9a2a87565584f8"},
"certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"},
"crc": {:hex, :crc, "0.10.5", "ee12a7c056ac498ef2ea985ecdc9fa53c1bfb4e53a484d9f17ff94803707dfd8", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3e673b6495a9525c5c641585af1accba59a1eb33de697bedf341e247012c2c7f"},
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
Expand All @@ -13,7 +13,7 @@
"ex_doc": {:hex, :ex_doc, "0.30.4", "e8395c8e3c007321abb30a334f9f7c0858d80949af298302daf77553468c0c39", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9a19f0c50ffaa02435668f5242f2b2a61d46b541ebf326884505dfd3dd7af5e4"},
"excoveralls": {:hex, :excoveralls, "0.17.1", "83fa7906ef23aa7fc8ad7ee469c357a63b1b3d55dd701ff5b9ce1f72442b2874", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "95bc6fda953e84c60f14da4a198880336205464e75383ec0f570180567985ae0"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"hackney": {:hex, :hackney, "1.19.0", "ee1f3722f6b065ac25fec264651d83bb4707a2cf1f8fb39be7720d73ff8aad3f", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "002839773ec04b3c415629546295b9348931c92c3c00812f060c5f9b5834395e"},
"hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
Expand All @@ -25,6 +25,6 @@
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
"stellar_base": {:hex, :stellar_base, "0.14.0", "210540f579e3d223816a421d88e636716fd092559006f8e5b5a733092e439138", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:crc, "~> 0.10.0", [hex: :crc, repo: "hexpm", optional: false]}, {:elixir_xdr, "~> 0.3", [hex: :elixir_xdr, repo: "hexpm", optional: false]}], "hexpm", "d9576229fbc8fc571f5ba0c747c1ab0a6f28f83f8f7cb9825d023444c8f45d56"},
"stellar_sdk": {:hex, :stellar_sdk, "0.18.0", "8a32ea283873cef57b90f4c1347531d99d35ceb1a4388c56738299744e00753b", [:mix], [{:ed25519, "~> 1.3", [hex: :ed25519, repo: "hexpm", optional: false]}, {:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:stellar_base, "~> 0.14", [hex: :stellar_base, repo: "hexpm", optional: false]}], "hexpm", "a297025d844f9473a5fd14a6515aaee95af401a56d6af2a168b0640fa2e32fba"},
"stellar_sdk": {:hex, :stellar_sdk, "0.18.1", "050553829477a7f6f9b3d6ada04eaee6b1f2e5faa43f11d07d865e77ba21b48f", [:mix], [{:ed25519, "~> 1.3", [hex: :ed25519, repo: "hexpm", optional: false]}, {:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:stellar_base, "~> 0.14", [hex: :stellar_base, repo: "hexpm", optional: false]}], "hexpm", "67d159452ac4c179f73a9cc3108483e6383c7cf5dc6486b3e8c16599e8af29b4"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
}
19 changes: 18 additions & 1 deletion test/contract/deploy_asset_contract_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ defmodule Soroban.Contract.DeployAssetContractTest do
%{
source_public: "GBNDWIM7DPYZJ2RLJ3IESXBIO4C2SVF6PWZXS3DLODJSBQWBMKY5U4M3",
source_secret: "SDRD4CSRGPWUIPRDS5O3CJBNJME5XVGWNI677MZDD4OD2ZL2R6K5IQ24",
asset_issuer: "GB2LNFAIQWPJPMLQRDRD7FFY5VIJUBCZIQBWRR2L3RSOVWGH3T5Z56SN",
asset_code: "ZZZ",
envelope_xdr:
"AAAAAgAAAABaOyGfG/GU6itO0ElcKHcFqVS+fbN5bGtw0yDCwWKx2gABNuQABPEIAAAAPgAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAQAAAAEAAAABWlpaAAAAAABaOyGfG/GU6itO0ElcKHcFqVS+fbN5bGtw0yDCwWKx2gAAAAEAAAAAAAAAAQAAAAAAAAACAAAABgAAAAEJjPko7iuhBRtsY0aDQ2Einilpmj/rDyGds/qx5seSNAAAABQAAAABAAAAB4w32Y19ZRfshxeO+Nw4BNSkE0ZhibcEWId4SVzs0PZPAAAAAABO+DAAABjwAAAAAAAAAAAAAAANAAAAAA=="
Expand All @@ -97,6 +98,22 @@ defmodule Soroban.Contract.DeployAssetContractTest do

test "deploy/2", %{
asset_code: asset_code,
source_public: source_public,
source_secret: source_secret
} do
{:ok,
%SendTransactionResponse{
status: "PENDING",
hash: "308f5f3c7b2c0a690e7e19b6d14c22af87763f5ae483d6d1af43b9639732d206",
latest_ledger: "602691",
latest_ledger_close_time: "1683814245",
error_result_xdr: nil
}} = DeployAssetContract.deploy(asset_code, source_public, source_secret)
end

test "deploy/2 with a different invoker than the issuer of the asset", %{
asset_code: asset_code,
asset_issuer: asset_issuer,
source_secret: source_secret
} do
{:ok,
Expand All @@ -106,7 +123,7 @@ defmodule Soroban.Contract.DeployAssetContractTest do
latest_ledger: "602691",
latest_ledger_close_time: "1683814245",
error_result_xdr: nil
}} = DeployAssetContract.deploy(asset_code, source_secret)
}} = DeployAssetContract.deploy(asset_code, asset_issuer, source_secret)
end

test "retrieve_unsigned_xdr_to_deploy_asset/2", %{
Expand Down
4 changes: 3 additions & 1 deletion test/contract_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ defmodule Soroban.ContractTest do

test "deploy_asset/2", %{
asset_code: asset_code,
source_secret: source_secret
source_secret: source_secret,
source_public: source_public
} do
{:ok,
%SendTransactionResponse{
Expand All @@ -384,6 +385,7 @@ defmodule Soroban.ContractTest do
}} =
Contract.deploy_asset(
asset_code,
source_public,
source_secret
)
end
Expand Down

0 comments on commit 9866c29

Please sign in to comment.