Skip to content

Commit

Permalink
Merge pull request #166 from kommitters/v0.6
Browse files Browse the repository at this point in the history
Release v0.6.1
  • Loading branch information
jhonatan-kmt authored Jul 21, 2022
2 parents 2d10c5f + 153bde7 commit d9243bc
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 18 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.6.1 (21.07.2022)
* Add the flags property to the OfferEntry.
* Add security policy to repository.

## 0.6.0 (21.03.2022)
* XDR types for LedgerEntryExtension, ClaimableBalanceEntry, ClaimableBalanceFlags, DataEntry, TrustLineEntry and OfferEntryFlags.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You should only use **`stellar_base`** if you are planning to build on top of it
```elixir
def deps do
[
{:stellar_base, "~> 0.6.0"}
{:stellar_base, "~> 0.6.1"}
]
end
```
Expand Down
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Reporting Security Issues

To report a security issue, please email [oss@kommit.co](mailto:oss@kommit.co) with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue.

If the issue is confirmed as a vulnerability, we will open a Security Advisory and acknowledge your contributions as part of it.
20 changes: 15 additions & 5 deletions lib/xdr/ledger_entries/offer_entry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ defmodule StellarBase.XDR.OfferEntry do
For example an Offer is selling 10A where 1A is priced at 1.5B
"""
alias StellarBase.XDR.{AccountID, Asset, Int64, Price}
alias StellarBase.XDR.Ext
alias StellarBase.XDR.{AccountID, Asset, Int64, Price, UInt32, Ext}

@behaviour XDR.Declaration

Expand All @@ -19,6 +18,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying: Asset,
amount: Int64,
price: Price,
flags: UInt32,
ext: Ext
)

Expand All @@ -29,10 +29,11 @@ defmodule StellarBase.XDR.OfferEntry do
buying: Asset.t(),
amount: Int64.t(),
price: Price.t(),
flags: UInt32.t(),
ext: Ext.t()
}

defstruct [:seller_id, :offer_id, :selling, :buying, :amount, :price, :ext]
defstruct [:seller_id, :offer_id, :selling, :buying, :amount, :price, :flags, :ext]

@spec new(
seller_id :: AccountID.t(),
Expand All @@ -41,6 +42,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying :: Asset.t(),
amount :: Int64.t(),
price :: Price.t(),
flags :: UInt32.t(),
ext :: Ext.t()
) ::
t()
Expand All @@ -51,6 +53,7 @@ defmodule StellarBase.XDR.OfferEntry do
%Asset{} = buying,
%Int64{} = amount,
%Price{} = price,
%UInt32{} = flags,
%Ext{} = ext
),
do: %__MODULE__{
Expand All @@ -60,6 +63,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
}

Expand All @@ -71,6 +75,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
}) do
[
Expand All @@ -80,6 +85,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
]
|> XDR.Struct.new()
Expand All @@ -94,6 +100,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
}) do
[
Expand All @@ -103,6 +110,7 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
]
|> XDR.Struct.new()
Expand All @@ -123,10 +131,11 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
]
}, rest}} ->
{:ok, {new(seller_id, offer_id, selling, buying, amount, price, ext), rest}}
{:ok, {new(seller_id, offer_id, selling, buying, amount, price, flags, ext), rest}}

error ->
error
Expand All @@ -145,10 +154,11 @@ defmodule StellarBase.XDR.OfferEntry do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
]
}, rest} = XDR.Struct.decode_xdr!(bytes, struct)

{new(seller_id, offer_id, selling, buying, amount, price, ext), rest}
{new(seller_id, offer_id, selling, buying, amount, price, flags, ext), rest}
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule StellarBase.MixProject do
use Mix.Project

@github_url "https://github.com/kommitters/stellar_base"
@version "0.6.0"
@version "0.6.1"

def project do
[
Expand Down
18 changes: 13 additions & 5 deletions test/xdr/ledger_entries/offer_entry_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule StellarBase.XDR.OfferEntryTest do

import StellarBase.Test.Utils, only: [create_account_id: 1, create_asset: 2]

alias StellarBase.XDR.{Ext, Int32, Int64, OfferEntry, Price}
alias StellarBase.XDR.{Ext, Int32, Int64, OfferEntry, Price, UInt32}

describe "OfferEntry Operation" do
setup do
Expand All @@ -27,6 +27,8 @@ defmodule StellarBase.XDR.OfferEntryTest do

price = Price.new(Int32.new(1), Int32.new(10))

flags = UInt32.new(1)

ext = Ext.new()

%{
Expand All @@ -36,8 +38,10 @@ defmodule StellarBase.XDR.OfferEntryTest do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext,
offer_entry: OfferEntry.new(seller_id, offer_id, selling, buying, amount, price, ext),
offer_entry:
OfferEntry.new(seller_id, offer_id, selling, buying, amount, price, flags, ext),
binary:
<<0, 0, 0, 0, 155, 142, 186, 248, 150, 56, 85, 29, 207, 158, 164, 247, 67, 32, 113, 16,
107, 135, 171, 14, 45, 179, 214, 155, 117, 165, 56, 34, 114, 247, 89, 216, 0, 0, 0, 0,
Expand All @@ -46,7 +50,7 @@ defmodule StellarBase.XDR.OfferEntryTest do
25, 212, 179, 73, 138, 2, 227, 119, 0, 0, 0, 2, 66, 84, 67, 78, 69, 87, 50, 48, 50,
49, 0, 0, 0, 0, 0, 0, 114, 213, 178, 144, 98, 27, 186, 154, 137, 68, 149, 154, 124,
205, 198, 221, 187, 173, 152, 33, 210, 37, 10, 76, 25, 212, 179, 73, 138, 2, 227, 119,
0, 0, 0, 0, 0, 76, 75, 64, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 0>>
0, 0, 0, 0, 0, 76, 75, 64, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0>>
}
end

Expand All @@ -57,15 +61,19 @@ defmodule StellarBase.XDR.OfferEntryTest do
buying: buying,
amount: amount,
price: price,
flags: flags,
ext: ext
} do
%OfferEntry{
seller_id: ^seller_id,
offer_id: ^offer_id,
selling: ^selling,
buying: ^buying,
amount: ^amount
} = OfferEntry.new(seller_id, offer_id, selling, buying, amount, price, ext)
amount: ^amount,
price: ^price,
flags: ^flags,
ext: ^ext
} = OfferEntry.new(seller_id, offer_id, selling, buying, amount, price, flags, ext)
end

test "encode_xdr/1", %{offer_entry: offer_entry, binary: binary} do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ defmodule StellarBase.XDR.Operations.ManageOfferSuccessResultTest do
Int32,
Int64,
OfferEntry,
Price
Price,
UInt32
}

alias StellarBase.XDR.Operations.{ManageOffer, ManageOfferEffect, ManageOfferSuccessResult}
Expand Down Expand Up @@ -76,7 +77,7 @@ defmodule StellarBase.XDR.Operations.ManageOfferSuccessResultTest do
10, 76, 25, 212, 179, 73, 138, 2, 227, 119, 0, 0, 0, 2, 66, 84, 67, 78, 69, 87, 50,
48, 50, 49, 0, 0, 0, 0, 0, 0, 114, 213, 178, 144, 98, 27, 186, 154, 137, 68, 149, 154,
124, 205, 198, 221, 187, 173, 152, 33, 210, 37, 10, 76, 25, 212, 179, 73, 138, 2, 227,
119, 0, 0, 0, 0, 0, 76, 75, 64, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 0>>
119, 0, 0, 0, 0, 0, 76, 75, 64, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0>>
}
end

Expand Down Expand Up @@ -112,6 +113,7 @@ defmodule StellarBase.XDR.Operations.ManageOfferSuccessResultTest do
offer_id = Int64.new(123_456)
amount = Int64.new(5_000_000)
price = Price.new(Int32.new(1), Int32.new(10))
flags = UInt32.new(1)
ext = Ext.new()

selling =
Expand All @@ -127,7 +129,7 @@ defmodule StellarBase.XDR.Operations.ManageOfferSuccessResultTest do
)

seller_id
|> OfferEntry.new(offer_id, selling, buying, amount, price, ext)
|> OfferEntry.new(offer_id, selling, buying, amount, price, flags, ext)
|> ManageOffer.new(ManageOfferEffect.new(:MANAGE_OFFER_CREATED))
end
end
8 changes: 5 additions & 3 deletions test/xdr/transactions/operations/manage_offer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule StellarBase.XDR.Operations.ManageOfferTest do

import StellarBase.Test.Utils

alias StellarBase.XDR.{Ext, Int32, Int64, OfferEntry, Price}
alias StellarBase.XDR.{Ext, Int32, Int64, OfferEntry, Price, UInt32}
alias StellarBase.XDR.Operations.{ManageOffer, ManageOfferEffect}

describe "ManageOffer" do
Expand All @@ -28,11 +28,13 @@ defmodule StellarBase.XDR.Operations.ManageOfferTest do

price = Price.new(Int32.new(1), Int32.new(10))

flags = UInt32.new(1)

ext = Ext.new()

effect = ManageOfferEffect.new(:MANAGE_OFFER_CREATED)

offer = OfferEntry.new(seller_id, offer_id, selling, buying, amount, price, ext)
offer = OfferEntry.new(seller_id, offer_id, selling, buying, amount, price, flags, ext)

%{
effect: effect,
Expand All @@ -46,7 +48,7 @@ defmodule StellarBase.XDR.Operations.ManageOfferTest do
37, 10, 76, 25, 212, 179, 73, 138, 2, 227, 119, 0, 0, 0, 2, 66, 84, 67, 78, 69, 87,
50, 48, 50, 49, 0, 0, 0, 0, 0, 0, 114, 213, 178, 144, 98, 27, 186, 154, 137, 68, 149,
154, 124, 205, 198, 221, 187, 173, 152, 33, 210, 37, 10, 76, 25, 212, 179, 73, 138, 2,
227, 119, 0, 0, 0, 0, 0, 76, 75, 64, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 0>>
227, 119, 0, 0, 0, 0, 0, 76, 75, 64, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0>>
}
end

Expand Down

0 comments on commit d9243bc

Please sign in to comment.