Skip to content

Commit

Permalink
Add location to F2F payment option
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Sep 30, 2023
1 parent 534e4c0 commit cb75397
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,28 @@ class ExpiryReasons(models.IntegerChoices):
blank=False,
)

# optionally makers can choose a coordinate for F2F
latitude = models.DecimalField(
max_digits=8,
decimal_places=6,
null=True,
validators=[
MinValueValidator(config(-90, cast=float)),
MaxValueValidator(config(90, cast=float)),
],
blank=False,
)
longitude = models.DecimalField(
max_digits=9,

Check failure on line 143 in api/models/order.py

View workflow job for this annotation

GitHub Actions / Flake8

api/models/order.py#L143

Trailing whitespace (W291)
decimal_places=6,
null=True,
validators=[
MinValueValidator(config(-180, cast=float)),
MaxValueValidator(config(180, cast=float)),
],
blank=False,
)

# how many sats at creation and at last check (relevant for marked to market)
t0_satoshis = models.PositiveBigIntegerField(
null=True,
Expand Down
16 changes: 16 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Meta:
"taker",
"escrow_duration",
"bond_size",
"latitude",
"longitude"
)


Expand Down Expand Up @@ -253,6 +255,14 @@ class OrderDetailSerializer(serializers.ModelSerializer):
required=False,
help_text="in percentage, the swap fee rate the platform charges",
)
latitude = serializers.FloatField(
required=False,
help_text="Latitude of the order for F2F payments",
)
longitude = serializers.FloatField(
required=False,
help_text="Longitude of the order for F2F payments",
)
pending_cancel = serializers.BooleanField(
required=False,
help_text="Your counterparty requested for a collaborative cancel when `status` is either `8`, `9` or `10`",
Expand Down Expand Up @@ -391,6 +401,8 @@ class Meta:
"sent_satoshis",
"txid",
"network",
"latitude",
"longitude",
)


Expand Down Expand Up @@ -430,6 +442,8 @@ class Meta:
"escrow_duration",
"satoshis_now",
"bond_size",
"latitude",
"longitude"
)


Expand Down Expand Up @@ -469,6 +483,8 @@ class Meta:
"public_duration",
"escrow_duration",
"bond_size",
"latitude",
"longitude"
)


Expand Down
4 changes: 4 additions & 0 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def post(self, request):
public_duration = serializer.data.get("public_duration")
escrow_duration = serializer.data.get("escrow_duration")
bond_size = serializer.data.get("bond_size")
latitude = serializer.data.get("latitude")

Check failure on line 113 in api/views.py

View workflow job for this annotation

GitHub Actions / Flake8

api/views.py#L113

Local variable 'latitude' is assigned to but never used (F841)
longitude = serializer.data.get("longitude")

Check failure on line 114 in api/views.py

View workflow job for this annotation

GitHub Actions / Flake8

api/views.py#L114

Local variable 'longitude' is assigned to but never used (F841)

# Optional params
if public_duration is None:
Expand Down Expand Up @@ -283,6 +285,8 @@ def get(self, request, format=None):
data["taker_nick"] = str(order.taker)
data["status_message"] = Order.Status(order.status).label
data["is_fiat_sent"] = order.is_fiat_sent
data["latitude"] = order.latitude
data["longitude"] = order.longitude
data["is_disputed"] = order.is_disputed
data["ur_nick"] = request.user.username
data["satoshis_now"] = order.last_satoshis
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/models/Book.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface PublicOrder {
premium: number;
satoshis: number;
satoshis_now: number;
latitude: number;
longitude: number;
bond_size: number;
maker: number;
escrow_duration: number;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/models/Order.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface Order {
taker_status: 'Active' | 'Seen recently' | 'Inactive';
price_now: number | undefined;
satoshis_now: number;
latitude: number;
longitude: number;
premium_now: number | undefined;
premium_percentile: number;
num_similar_orders: number;
Expand Down

0 comments on commit cb75397

Please sign in to comment.