Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
upgrade horizonclient to patched version to fix delete offer op issue (
Browse files Browse the repository at this point in the history
…closes #375) (#376)

* 1 - upgrade stellar/go dependency version to 'horizonclient-v2.0.0/3_fix_txnbuild_delete_offer_op'

* 2 - use new txnbuild.DeleteOfferOp2 method from horizonclient-v2.0.0/3_fix_txnbuild_delete_offer_op
  • Loading branch information
nikhilsaraf authored Feb 17, 2020
1 parent ea505bd commit 2cbfb67
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions glide.lock

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

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import:
- package: github.com/stellar/go
repo: [email protected]:nikhilsaraf/go.git
vcs: git
version: horizonclient-v2.0.0/2_max_fee_stats
version: horizonclient-v2.0.0/3_fix_txnbuild_delete_offer_op
subpackages:
- build
- clients/horizonclient
Expand Down
6 changes: 4 additions & 2 deletions plugins/sdex.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,12 @@ func (sdex *SDEX) DeleteAllOffers(offers []hProtocol.Offer) []txnbuild.Operation
func (sdex *SDEX) DeleteOffer(offer hProtocol.Offer) txnbuild.ManageSellOffer {
var result txnbuild.ManageSellOffer
var e error

txOffer := utils.Offer2TxnBuildSellOffer(offer)
if sdex.SourceAccount == sdex.TradingAccount {
result, e = txnbuild.DeleteOfferOp(offer.ID)
result, e = txnbuild.DeleteOfferOp2(txOffer)
} else {
result, e = txnbuild.DeleteOfferOp(offer.ID, &txnbuild.SimpleAccount{AccountID: sdex.TradingAccount})
result, e = txnbuild.DeleteOfferOp2(txOffer, &txnbuild.SimpleAccount{AccountID: sdex.TradingAccount})
}

if e != nil {
Expand Down
11 changes: 11 additions & 0 deletions support/utils/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,14 @@ func ParseMaybeFloat(valueString string) (*float64, error) {
}
return &valueFloat, nil
}

// Offer2TxnBuildSellOffer converts an hProtocol.Offer to a txnbuild.ManageSellOffer
func Offer2TxnBuildSellOffer(offer hProtocol.Offer) txnbuild.ManageSellOffer {
return txnbuild.ManageSellOffer{
Selling: Asset2Asset(offer.Selling),
Buying: Asset2Asset(offer.Buying),
Amount: offer.Amount,
Price: offer.Price,
OfferID: offer.ID,
}
}

0 comments on commit 2cbfb67

Please sign in to comment.