From cb04429da0ba0fbeee17cbda77601af37f6a3cf5 Mon Sep 17 00:00:00 2001 From: Einer Zapata Date: Mon, 28 Mar 2022 15:50:46 -0500 Subject: [PATCH 1/3] Add the flags property to the OfferEntry (#156) --- lib/xdr/ledger_entries/offer_entry.ex | 20 ++++++++++++++----- test/xdr/ledger_entries/offer_entry_test.exs | 18 ++++++++++++----- .../manage_offer_success_result_test.exs | 8 +++++--- .../operations/manage_offer_test.exs | 8 +++++--- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/xdr/ledger_entries/offer_entry.ex b/lib/xdr/ledger_entries/offer_entry.ex index 372c72b8..53cdde5a 100644 --- a/lib/xdr/ledger_entries/offer_entry.ex +++ b/lib/xdr/ledger_entries/offer_entry.ex @@ -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 @@ -19,6 +18,7 @@ defmodule StellarBase.XDR.OfferEntry do buying: Asset, amount: Int64, price: Price, + flags: UInt32, ext: Ext ) @@ -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(), @@ -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() @@ -51,6 +53,7 @@ defmodule StellarBase.XDR.OfferEntry do %Asset{} = buying, %Int64{} = amount, %Price{} = price, + %UInt32{} = flags, %Ext{} = ext ), do: %__MODULE__{ @@ -60,6 +63,7 @@ defmodule StellarBase.XDR.OfferEntry do buying: buying, amount: amount, price: price, + flags: flags, ext: ext } @@ -71,6 +75,7 @@ defmodule StellarBase.XDR.OfferEntry do buying: buying, amount: amount, price: price, + flags: flags, ext: ext }) do [ @@ -80,6 +85,7 @@ defmodule StellarBase.XDR.OfferEntry do buying: buying, amount: amount, price: price, + flags: flags, ext: ext ] |> XDR.Struct.new() @@ -94,6 +100,7 @@ defmodule StellarBase.XDR.OfferEntry do buying: buying, amount: amount, price: price, + flags: flags, ext: ext }) do [ @@ -103,6 +110,7 @@ defmodule StellarBase.XDR.OfferEntry do buying: buying, amount: amount, price: price, + flags: flags, ext: ext ] |> XDR.Struct.new() @@ -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 @@ -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 diff --git a/test/xdr/ledger_entries/offer_entry_test.exs b/test/xdr/ledger_entries/offer_entry_test.exs index 58ef011b..10ab7128 100644 --- a/test/xdr/ledger_entries/offer_entry_test.exs +++ b/test/xdr/ledger_entries/offer_entry_test.exs @@ -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 @@ -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() %{ @@ -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, @@ -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 @@ -57,6 +61,7 @@ defmodule StellarBase.XDR.OfferEntryTest do buying: buying, amount: amount, price: price, + flags: flags, ext: ext } do %OfferEntry{ @@ -64,8 +69,11 @@ defmodule StellarBase.XDR.OfferEntryTest do 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 diff --git a/test/xdr/transactions/operations/manage_offer_success_result_test.exs b/test/xdr/transactions/operations/manage_offer_success_result_test.exs index 6210557e..cd878b54 100644 --- a/test/xdr/transactions/operations/manage_offer_success_result_test.exs +++ b/test/xdr/transactions/operations/manage_offer_success_result_test.exs @@ -12,7 +12,8 @@ defmodule StellarBase.XDR.Operations.ManageOfferSuccessResultTest do Int32, Int64, OfferEntry, - Price + Price, + UInt32 } alias StellarBase.XDR.Operations.{ManageOffer, ManageOfferEffect, ManageOfferSuccessResult} @@ -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 @@ -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 = @@ -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 diff --git a/test/xdr/transactions/operations/manage_offer_test.exs b/test/xdr/transactions/operations/manage_offer_test.exs index c6a94ec7..50fcb1c0 100644 --- a/test/xdr/transactions/operations/manage_offer_test.exs +++ b/test/xdr/transactions/operations/manage_offer_test.exs @@ -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 @@ -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, @@ -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 From 88fb11538a908974c41f2e9f45bcc9eb07f50b5d Mon Sep 17 00:00:00 2001 From: David Santiago Pinchao Date: Thu, 21 Jul 2022 16:59:25 -0500 Subject: [PATCH 2/3] add security policy to repository (#163) --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..9afd9af7 --- /dev/null +++ b/SECURITY.md @@ -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. From 153bde7eeb38d444529996dd0b941a0bd239d746 Mon Sep 17 00:00:00 2001 From: David Santiago Pinchao Date: Thu, 21 Jul 2022 17:14:24 -0500 Subject: [PATCH 3/3] Prepare to release v0.6.1 (#165) --- CHANGELOG.md | 4 ++++ README.md | 2 +- mix.exs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6b9cdc..4e1b3dbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index e5585b86..b0081984 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/mix.exs b/mix.exs index 0ad2bd34..cb087f73 100644 --- a/mix.exs +++ b/mix.exs @@ -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 [