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

Add price and listingType fields to order websocket notification #1223

Merged
merged 8 commits into from
Oct 30, 2018

Conversation

placer14
Copy link
Member

@placer14 placer14 commented Oct 10, 2018

Completes #1188. New fields in order websocket notification.

@placer14 placer14 added this to the v2.3 milestone Oct 10, 2018
@placer14 placer14 requested a review from cpacia October 10, 2018 20:58
@coveralls
Copy link

coveralls commented Oct 10, 2018

Coverage Status

Coverage decreased (-0.08%) to 33.736% when pulling 7c67fa9 on 1188-add-price-fields-order-socket into 0b4e2f5 on multiwallet.

@placer14
Copy link
Member Author

Final example of order websocket notification:

{
  "notifications": [
    {
      "notification": {
        "buyerHandle": "das_test",
        "listingType": "SERVICE",
        "buyerId": "QmVLRA8hzADMwYDxXXFgHf2i9bbmbcm9WQHVojeAensNcR",
        "notificationId": "QmUh2aupaEoudW5feEFeyGmturjSDWxpfdDnzKeuZhx4rR",
        "orderId": "QmZwQbg4XPCRqFqWhDw4Z1694jpD7GjdxuxCebkXpwP2t7",
        "price": {
          "amount": 1000,
          "currencyCode": "eth",
          "priceModifier": 0.0,
          "coinDivisibility": 100000000
        },
        "slug": "vintage-dress-physical-w-options2",
        "thumbnail": {
          "small": "QmVsoT9iabv6GZhxhvtjSpQMJA6QyMivGTs6MmHJr6TBm9",
          "tiny": "QmbjyAxYee4y3443kAMLcmRVwggZsRDKiyXnXus1qdJJWz"
        },
        "title": "Vintage dress (physical; w/ options)",
        "type": "order"
      },
      "read": false,
      "timestamp": "2018-06-08T00:36:16Z",
      "type": "order"
    }
  ],
  "total": 123,
  "unread": 122
}

@placer14 placer14 force-pushed the 1188-add-price-fields-order-socket branch from a6344b8 to 095c8ef Compare October 23, 2018 15:29

// DefaultCurrencyDivisibility is the Divisibility of the Currency if not
// defined otherwise
const DefaultCurrencyDivisibility uint32 = 1e8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this here. Hope no one minds.

if wallet, err := n.Multiwallet.WalletForCurrencyCode(listing.Metadata.CoinType); err != nil {
expectedDivisibility = DefaultCurrencyDivisibility
} else {
expectedDivisibility = uint32(wallet.ExchangeRates().UnitsPerCoin())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if UnitsPerCoin matched types with the listing data. (OpenBazaar/wallet-interface#9)

if err == nil {
return uint32(wallet.ExchangeRates().UnitsPerCoin())
}
return core.DefaultCurrencyDivisibility
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer divisibility from listing, then check wallet's preference, then fail to default as a last resort.

* multiwallet: (49 commits)
  Improve README: fix grammar
  Update out_of_inventory.py test
  Update market_price_modifier.py test
  Update manage_crypto_listings.py test
  Update listings.py test
  Update fulfill_direct_online.py test
  Update escrow_release_after_timeout.py test
  Update dispute_close_split.py test
  Update dispute_close_buyer.py test
  Update complete_moderated_with_timeout.py test
  Update complete_moderated_online.py
  Update complete_disputed.py
  Update complete_direct_online.py
  Update cancel_direct.py test
  Fix bug in ResyncManager
  [#1204] Remove unused package
  CLEANUP: Fix misspellings.
  Update btcrpcclient link
  [#1004] Isolate dependencies in repo/db/stxo_test.go
  improved README
  ...

 Conflicts:
	core/listings_test.go
* multiwallet:
  Log error adding key to peerstore
  Update bitcoin/listeners/transaction_listener.go
  Improved grammar and fixed capitalization in the main README file.
  Fix bug calculating crypto listing market price
  Update remaining qa tests
  Remove arch requirement on make ios_framework task
  Lint fixes after merging latest master into multiwallet
  Fixed import error
  Update Documentation section (PR #1252)
  Remove unused Python modules in qa/chat.py
  HandleOfflineRelay save public key
@cpacia
Copy link
Member

cpacia commented Oct 30, 2018

LGTM

@placer14 placer14 merged commit bcf2441 into multiwallet Oct 30, 2018
@placer14 placer14 deleted the 1188-add-price-fields-order-socket branch October 30, 2018 15:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants