Skip to content

Commit

Permalink
Update contract and adding use_relayer field
Browse files Browse the repository at this point in the history
  • Loading branch information
gokuseii committed Apr 19, 2023
1 parent abe4d86 commit 1ad7458
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 51 deletions.
49 changes: 26 additions & 23 deletions internal/gobind/Swapica.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions internal/service/match_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (r *indexer) handleCreatedMatches(ctx context.Context, opts *bind.FilterOpt
return errors.Wrap(err, "failed to filter MatchCreated events")
}
for it.Next() {
if err = r.addMatch(ctx, it.Event.Match); err != nil {
if err = r.addMatch(ctx, it.Event.Match, it.Event.UseRelayer); err != nil {
return errors.Wrap(err, "failed to add match order")
}

Expand Down Expand Up @@ -51,10 +51,10 @@ func (r *indexer) handleUpdatedMatches(ctx context.Context, opts *bind.FilterOpt
return errors.Wrap(it.Error(), "error occurred while iterating over MatchUpdated events")
}

func (r *indexer) addMatch(ctx context.Context, mo gobind.ISwapicaMatch) error {
func (r *indexer) addMatch(ctx context.Context, mo gobind.ISwapicaMatch, useRelayer bool) error {
log := r.log.WithField("match_id", mo.MatchId.String())
log.Debug("adding new match order")
body := requests.NewAddMatch(mo, r.chainID)
body := requests.NewAddMatch(mo, r.chainID, useRelayer)
u, _ := url.Parse("/match_orders")

err := r.collector.PostJSON(u, body, ctx, nil)
Expand Down
6 changes: 3 additions & 3 deletions internal/service/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (r *indexer) handleCreatedOrders(ctx context.Context, opts *bind.FilterOpts
return errors.Wrap(err, "failed to filter OrderCreated events")
}
for it.Next() {
if err = r.addOrder(ctx, it.Event.Order); err != nil {
if err = r.addOrder(ctx, it.Event.Order, it.Event.UseRelayer); err != nil {
return errors.Wrap(err, "failed to index order")
}

Expand Down Expand Up @@ -51,10 +51,10 @@ func (r *indexer) handleUpdatedOrders(ctx context.Context, opts *bind.FilterOpts
return errors.Wrap(it.Error(), "error occurred while iterating over OrderUpdated events")
}

func (r *indexer) addOrder(ctx context.Context, o gobind.ISwapicaOrder) error {
func (r *indexer) addOrder(ctx context.Context, o gobind.ISwapicaOrder, useRelayer bool) error {
log := r.log.WithField("order_id", o.OrderId.String())
log.Debug("adding new order")
body := requests.NewAddOrder(o, r.chainID)
body := requests.NewAddOrder(o, r.chainID, useRelayer)
u, _ := url.Parse("/orders")

err := r.collector.PostJSON(u, body, ctx, nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/service/requests/add_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"github.com/Swapica/order-aggregator-svc/resources"
)

func NewAddMatch(m gobind.ISwapicaMatch, chainID int64) resources.AddMatchRequest {
func NewAddMatch(m gobind.ISwapicaMatch, chainID int64, useRelayer bool) resources.AddMatchRequest {
return resources.AddMatchRequest{
Data: resources.AddMatch{
Key: resources.Key{
Type: resources.MATCH_ORDER,
},
Attributes: resources.AddMatchAttributes{
AmountToSell: m.AmountToSell.String(),
UseRelayer: useRelayer,
Creator: m.Creator.String(),
MatchId: m.MatchId.Int64(),
State: m.State,
Expand Down
3 changes: 2 additions & 1 deletion internal/service/requests/add_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/Swapica/order-aggregator-svc/resources"
)

func NewAddOrder(o gobind.ISwapicaOrder, chainID int64) resources.AddOrderRequest {
func NewAddOrder(o gobind.ISwapicaOrder, chainID int64, useRelayer bool) resources.AddOrderRequest {
return resources.AddOrderRequest{
Data: resources.AddOrder{
Key: resources.Key{
Expand All @@ -14,6 +14,7 @@ func NewAddOrder(o gobind.ISwapicaOrder, chainID int64) resources.AddOrderReques
Attributes: resources.AddOrderAttributes{
AmountToBuy: o.AmountToBuy.String(),
AmountToSell: o.AmountToSell.String(),
UseRelayer: useRelayer,
Creator: o.Creator.String(),
MatchSwapica: nil, // must be nil by the Swapica contract
OrderId: o.OrderId.Int64(),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ad7458

Please sign in to comment.