2 releases

0.1.1 Nov 24, 2023
0.1.0 Oct 25, 2023

#2223 in Magic Beans

45 downloads per month

MIT license

49KB
733 lines


Logo

valence_market

Pipeline Status

valence_market is a plug-in for Valence that lets you set up a web3 marketplace in seconds. Let your users buy and sell assets in a distributed marketplace, where the only fees are the ones you set, and your users are in control of their own trades.

Official documentation »

How to Use

valence_market provides routes that you can plug in to your base Valence node to turn it into a fully functional marketplace. It is designed to be used as a library and can be imported into your Valence project.

..

🔧 Installation

If you have cargo-add installed, you can simply run the following command:

cargo add valence_market

Otherwise, add the following to your Cargo.toml file:

[dependencies]
valence_market = "0.1.0"

(back to top)

..

🔌 Available Routes

GET /listings

Retrieve a list of available assets that users can browse and potentially buy

..

GET /listings/:id

Retrieve a specific listing by its ID

..

POST /listings

Create a new listing. The structure for the request body will need to follow the Listing interface, which looks like:

{
    "_id": "a8f163782fb07c69f511248e",
    "title": "Asset_test",
    "description": "This is a test asset listing",
    "initial_price": 100,
    "quantity": 10
}

..

GET /orders/:id

Retrieve a list of orders that have been placed, retrieved by the listing ID

..

POST /orders

Create a new order. The structure for the request body will need to follow the Order interface, which looks like:

{
    "id": "8c6dbdaea24a234fad18eca6",
    "asset_id": "f837cb510db38d9040889e83",
    "price": 100,
    "quantity": 2,
    "is_bid": false,
    "created_at": "20 June 2023",
    "druid": "g092384435098",
    "desired_asset_id": null
}

(back to top)

..

🚧 Further Work

  • Paginate orders
  • Add cache functionality
  • Add cuckoo filter functionality
  • Separate ID from Listing and Order structs (create MongoDB wrapper struct with ID)
  • Construct initial order when new listing is created (does this form part of the listing POST call?)
  • Add tests
  • Add logging
  • Refactor and improve error messages for call failures
  • Create user functionality
  • With user functionality enabled, add user ID to listing and order structs
  • With user functionality enabled, add PUT/DELETE calls for listings and orders

(back to top)

..

Dependencies

~35–50MB
~1M SLoC