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

Commit d1754ec

Browse files
committed
Fix bug bulk updating currencies on listings
1 parent be3cd33 commit d1754ec

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

core/listings.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error {
650650
if err != nil {
651651
return err
652652
}
653-
654653
walkpath := func(p string, f os.FileInfo, err error) error {
655654
if !f.IsDir() && filepath.Ext(p) == ".json" {
656655
signedProto, err := GetSignedListingFromPath(p)
@@ -667,7 +666,6 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error {
667666
if l.GetContractType() == pb.Listing_Metadata_CRYPTOCURRENCY.String() {
668667
return nil
669668
}
670-
671669
if err := l.SetAcceptedCurrencies(currencies...); err != nil {
672670
return err
673671
}
@@ -694,6 +692,5 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error {
694692
if err != nil {
695693
return err
696694
}
697-
698695
return nil
699696
}

openbazaar-qa renamed to qa/ob

73.5 MB
Binary file not shown.

repo/listing.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,21 @@ func (l *Listing) GetShippingOptions() ([]*pb.Listing_ShippingOption, error) {
10221022
}
10231023
switch l.GetVersion() {
10241024
case 3, 4:
1025-
for _, o := range so {
1026-
for _, s := range o.Services {
1027-
s.BigPrice = big.NewInt(int64(s.Price)).String()
1028-
s.BigAdditionalItemPrice = big.NewInt(int64(s.AdditionalItemPrice)).String()
1025+
for a, o := range so {
1026+
for x, s := range o.Services {
1027+
so[a].Services[x].BigPrice = big.NewInt(int64(s.Price)).String()
1028+
so[a].Services[x].BigAdditionalItemPrice = big.NewInt(int64(s.AdditionalItemPrice)).String()
1029+
}
1030+
}
1031+
case 5:
1032+
for a, o := range so {
1033+
for x, s := range o.Services {
1034+
if s.BigPrice == "" {
1035+
so[a].Services[x].BigPrice = "0"
1036+
}
1037+
if s.BigAdditionalItemPrice == "" {
1038+
so[a].Services[x].BigAdditionalItemPrice = "0"
1039+
}
10291040
}
10301041
}
10311042
}
@@ -1205,6 +1216,9 @@ func (l *Listing) GetInventory() (map[int]*big.Int, error) {
12051216
var amtStr string
12061217
switch l.GetVersion() {
12071218
case 5:
1219+
if s.BigQuantity == "" {
1220+
continue
1221+
}
12081222
amtStr = s.BigQuantity
12091223
default:
12101224
amtStr = strconv.Itoa(int(s.Quantity))

0 commit comments

Comments
 (0)