Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 5da4d62

Browse files
committed
Fix bugs in compatibility
1 parent afdde88 commit 5da4d62

File tree

13 files changed

+739
-689
lines changed

13 files changed

+739
-689
lines changed

core/order.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (n *OpenBazaarNode) Purchase(data *repo.PurchaseData) (orderID string, paym
169169
Code: defn.Code.String(),
170170
Divisibility: uint32(defn.Divisibility),
171171
}
172+
payment.Coin = defn.Code.String()
172173

173174
// Calculate payment amount
174175
total, err := n.CalculateOrderTotal(contract)
@@ -181,6 +182,7 @@ func (n *OpenBazaarNode) Purchase(data *repo.PurchaseData) (orderID string, paym
181182
}
182183

183184
payment.BigAmount = total.String()
185+
payment.Amount = total.Uint64()
184186

185187
contract, err = n.SignOrder(contract)
186188
if err != nil {
@@ -238,11 +240,13 @@ func prepareModeratedOrderContract(data *repo.PurchaseData, n *OpenBazaarNode, c
238240
Code: defn.Code.String(),
239241
Divisibility: uint32(defn.Divisibility),
240242
}
243+
payment.Coin = defn.Code.String()
241244
total, err := n.CalculateOrderTotal(contract)
242245
if err != nil {
243246
return nil, err
244247
}
245248
payment.BigAmount = total.String()
249+
payment.Amount = total.Uint64()
246250
contract.BuyerOrder.Payment = payment
247251

248252
fpb := wal.GetFeePerByte(wallet.NORMAL)
@@ -708,7 +712,6 @@ func getListing(n *OpenBazaarNode, contract *pb.RicardianContract, item repo.Ite
708712
if err := sl.GetListing().GetVendorID().Valid(); err != nil {
709713
return nil, fmt.Errorf("invalid vendor info: %s", err.Error())
710714
}
711-
712715
if err := sl.ValidateListing(n.TestNetworkEnabled() || n.RegressionNetworkEnabled()); err != nil {
713716
return nil, fmt.Errorf("validating listing (%s): %s", sl.GetSlug(), err.Error())
714717
}
@@ -982,7 +985,7 @@ func (n *OpenBazaarNode) CalculateOrderTotal(contract *pb.RicardianContract) (*b
982985
}
983986
for _, vendorCoupon := range nrl.GetProtobuf().Coupons {
984987
if id.B58String() == vendorCoupon.GetHash() {
985-
if disc, ok := new(big.Int).SetString(vendorCoupon.BigPriceDiscount, 10); ok && disc.Cmp(big.NewInt(0)) > 0 {
988+
if disc, ok := new(big.Int).SetString(vendorCoupon.GetBigPriceDiscount(), 10); ok && disc.Cmp(big.NewInt(0)) > 0 {
986989
// apply fixed discount
987990
itemOriginAmt = itemOriginAmt.SubBigInt(disc)
988991
} else if discountF := vendorCoupon.GetPercentDiscount(); discountF > 0 {

pb/api.pb.go

Lines changed: 37 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)