Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Supports passing exchange pair's rate as string #1000

Merged
merged 4 commits into from
May 14, 2019

Conversation

unnawut
Copy link
Contributor

@unnawut unnawut commented May 10, 2019

Issue/Task Number: #996
Closes: #996

Overview

This PR add supports for exchange pair's creation and update by passing the rate as a string.

Changes

  • Attempts to parse a string rate into float in EWallet.ExchangePairGate

Implementation Details

This is a small update to the ExchangePairGate that tries to parse a string rate before doing the insert/update.

A caveat is that this uses Float.parse/1 which means that there could be precision loss in the floating point returned. But since the DB is already storing the rate as a floating point, this does not introduce more precision loss than it already is. The precision loss is #998.

Usage

curl -X POST localhost:4000/api/admin/exchange_pair.create \
-H "Accept: application/vnd.omisego.v1+json" \
-H "Authorization: OMGAdmin <truncated>" \
-H "Content-Type: application/json" \
-d '{
  "from_token_id":"tok_ETH_01d7brbvs76ceqyp683enns91a",
  "to_token_id":"tok_KNC_01d7brbvnftq9efg039emzbch9",
  "rate":"1000",
  "sync_opposite":true
}' \
-v -w "\n" | jq

Impact

  • No changes to DB schemas.
  • API specs is updated with a non-breaking change (allow exchange pair request bodies to have rate that is either string or number).

@unnawut unnawut added this to the v1.2 milestone May 10, 2019
@unnawut unnawut self-assigned this May 10, 2019
Unnawut Leepaisalsuwanna added 2 commits May 10, 2019 13:23
@unnawut unnawut merged commit 06f6ee0 into omgnetwork:v1.2 May 14, 2019
@unnawut unnawut deleted the 996-string-rate branch May 14, 2019 08:31
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.

3 participants