From 8e96bc38d10547cfa1afcd55024307f7f874ccc8 Mon Sep 17 00:00:00 2001 From: Tadej Golobic Date: Tue, 20 Aug 2024 16:07:52 +0200 Subject: [PATCH] feat(quote): remove internal fields from schema (#2858) * feat(quote): remote internaly used fields * test(quote): remove removed fields from resolvers response * docs(bruno): remove internal fields * feat(quote): add estimatedExchangeRate field * docs(bruno): add estimatedExchangeRate to quote query * feat(lint): everything * fix(incoming-payment): service test * fix(bruno): remove deprecated internal quote fields --- .../Create Quote.bru | 4 -- .../Peer-to-Peer Payment/Create Quote.bru | 4 -- .../Cancel Outgoing Payment.bru | 5 +- ...Outgoing Payment From Incoming Payment.bru | 5 +- .../Create Outgoing Payment.bru | 5 +- .../Rafiki/Rafiki Admin APIs/Create Quote.bru | 4 -- .../Get Outgoing Payment.bru | 5 +- .../Rafiki/Rafiki Admin APIs/Get Quote.bru | 5 +- .../generated/graphql.ts | 15 +--- .../src/graphql/generated/graphql.schema.json | 68 +++---------------- .../backend/src/graphql/generated/graphql.ts | 15 +--- .../resolvers/outgoing_payment.test.ts | 14 ++-- .../src/graphql/resolvers/quote.test.ts | 8 --- .../backend/src/graphql/resolvers/quote.ts | 7 +- packages/backend/src/graphql/schema.graphql | 10 +-- packages/frontend/app/generated/graphql.ts | 15 +--- .../src/generated/graphql.ts | 15 +--- test/integration/lib/admin-client.ts | 4 -- test/integration/lib/generated/graphql.ts | 15 +--- 19 files changed, 36 insertions(+), 187 deletions(-) diff --git a/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Cross Currency Payment/Create Quote.bru b/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Cross Currency Payment/Create Quote.bru index 406c1548dd..b3c20f6802 100644 --- a/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Cross Currency Payment/Create Quote.bru +++ b/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Cross Currency Payment/Create Quote.bru @@ -16,11 +16,7 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId receiveAmount { assetCode diff --git a/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Create Quote.bru b/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Create Quote.bru index 406c1548dd..b3c20f6802 100644 --- a/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Create Quote.bru +++ b/bruno/collections/Rafiki/Examples/Admin API - only locally/Peer-to-Peer Payment/Create Quote.bru @@ -16,11 +16,7 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId receiveAmount { assetCode diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru index 9d3dc30452..4095780540 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Cancel Outgoing Payment.bru @@ -22,11 +22,8 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate + estimatedExchangeRate walletAddressId receiveAmount { assetCode diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment From Incoming Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment From Incoming Payment.bru index ea46af7d07..bc376464ca 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment From Incoming Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment From Incoming Payment.bru @@ -22,12 +22,9 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId + estimatedExchangeRate receiveAmount { assetCode assetScale diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment.bru index ab0cf3c740..ae3229e021 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment.bru @@ -22,11 +22,8 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate + estimatedExchangeRate walletAddressId receiveAmount { assetCode diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru index dc52218dc1..7211afa661 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru @@ -16,11 +16,7 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId receiveAmount { assetCode diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru index ae9cd5ff47..d0b13d0744 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Outgoing Payment.bru @@ -23,12 +23,9 @@ body:graphql { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId + estimatedExchangeRate receiveAmount { assetCode assetScale diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Quote.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Quote.bru index 2d92319182..3b2ad6b773 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Quote.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Quote.bru @@ -14,13 +14,10 @@ body:graphql { query GetQuote($id: String!) { quote(id: $id) { createdAt - highEstimatedExchangeRate expiresAt id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId + estimatedExchangeRate receiveAmount { assetCode assetScale diff --git a/localenv/mock-account-servicing-entity/generated/graphql.ts b/localenv/mock-account-servicing-entity/generated/graphql.ts index e482374c2f..55a68afa65 100644 --- a/localenv/mock-account-servicing-entity/generated/graphql.ts +++ b/localenv/mock-account-servicing-entity/generated/graphql.ts @@ -1113,18 +1113,12 @@ export type Quote = { createdAt: Scalars['String']['output']; /** Amount to send (fixed send) */ debitAmount: Amount; + /** Estimated exchange rate */ + estimatedExchangeRate?: Maybe; /** Date-time of expiration */ expiresAt: Scalars['String']['output']; - /** Upper bound of probed exchange rate */ - highEstimatedExchangeRate: Scalars['Float']['output']; /** Quote id */ id: Scalars['ID']['output']; - /** Lower bound of probed exchange rate */ - lowEstimatedExchangeRate: Scalars['Float']['output']; - /** Maximum value per packet allowed on the possible routes */ - maxPacketAmount: Scalars['UInt64']['output']; - /** Aggregate exchange rate the payment is guaranteed to meet */ - minExchangeRate: Scalars['Float']['output']; /** Amount to receive (fixed receive) */ receiveAmount: Amount; /** Wallet address URL of the receiver */ @@ -2101,12 +2095,9 @@ export type QueryResolvers = { createdAt?: Resolver; debitAmount?: Resolver; + estimatedExchangeRate?: Resolver, ParentType, ContextType>; expiresAt?: Resolver; - highEstimatedExchangeRate?: Resolver; id?: Resolver; - lowEstimatedExchangeRate?: Resolver; - maxPacketAmount?: Resolver; - minExchangeRate?: Resolver; receiveAmount?: Resolver; receiver?: Resolver; walletAddressId?: Resolver; diff --git a/packages/backend/src/graphql/generated/graphql.schema.json b/packages/backend/src/graphql/generated/graphql.schema.json index f0b8b64033..58c79a704c 100644 --- a/packages/backend/src/graphql/generated/graphql.schema.json +++ b/packages/backend/src/graphql/generated/graphql.schema.json @@ -6596,31 +6596,27 @@ "deprecationReason": null }, { - "name": "expiresAt", - "description": "Date-time of expiration", + "name": "estimatedExchangeRate", + "description": "Estimated exchange rate", "args": [], "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } + "kind": "SCALAR", + "name": "Float", + "ofType": null }, "isDeprecated": false, "deprecationReason": null }, { - "name": "highEstimatedExchangeRate", - "description": "Upper bound of probed exchange rate", + "name": "expiresAt", + "description": "Date-time of expiration", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", - "name": "Float", + "name": "String", "ofType": null } }, @@ -6643,54 +6639,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "lowEstimatedExchangeRate", - "description": "Lower bound of probed exchange rate", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "maxPacketAmount", - "description": "Maximum value per packet allowed on the possible routes", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "UInt64", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "minExchangeRate", - "description": "Aggregate exchange rate the payment is guaranteed to meet", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "receiveAmount", "description": "Amount to receive (fixed receive)", diff --git a/packages/backend/src/graphql/generated/graphql.ts b/packages/backend/src/graphql/generated/graphql.ts index e482374c2f..55a68afa65 100644 --- a/packages/backend/src/graphql/generated/graphql.ts +++ b/packages/backend/src/graphql/generated/graphql.ts @@ -1113,18 +1113,12 @@ export type Quote = { createdAt: Scalars['String']['output']; /** Amount to send (fixed send) */ debitAmount: Amount; + /** Estimated exchange rate */ + estimatedExchangeRate?: Maybe; /** Date-time of expiration */ expiresAt: Scalars['String']['output']; - /** Upper bound of probed exchange rate */ - highEstimatedExchangeRate: Scalars['Float']['output']; /** Quote id */ id: Scalars['ID']['output']; - /** Lower bound of probed exchange rate */ - lowEstimatedExchangeRate: Scalars['Float']['output']; - /** Maximum value per packet allowed on the possible routes */ - maxPacketAmount: Scalars['UInt64']['output']; - /** Aggregate exchange rate the payment is guaranteed to meet */ - minExchangeRate: Scalars['Float']['output']; /** Amount to receive (fixed receive) */ receiveAmount: Amount; /** Wallet address URL of the receiver */ @@ -2101,12 +2095,9 @@ export type QueryResolvers = { createdAt?: Resolver; debitAmount?: Resolver; + estimatedExchangeRate?: Resolver, ParentType, ContextType>; expiresAt?: Resolver; - highEstimatedExchangeRate?: Resolver; id?: Resolver; - lowEstimatedExchangeRate?: Resolver; - maxPacketAmount?: Resolver; - minExchangeRate?: Resolver; receiveAmount?: Resolver; receiver?: Resolver; walletAddressId?: Resolver; diff --git a/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts b/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts index 71c51affcc..d0729f29c1 100644 --- a/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts +++ b/packages/backend/src/graphql/resolvers/outgoing_payment.test.ts @@ -198,10 +198,7 @@ describe('OutgoingPayment Resolvers', (): void => { metadata quote { id - maxPacketAmount - minExchangeRate - lowEstimatedExchangeRate - highEstimatedExchangeRate + estimatedExchangeRate createdAt expiresAt } @@ -245,14 +242,11 @@ describe('OutgoingPayment Resolvers', (): void => { metadata, quote: { id: payment.quote.id, - maxPacketAmount: payment.quote.maxPacketAmount.toString(), - minExchangeRate: payment.quote.minExchangeRate.valueOf(), - lowEstimatedExchangeRate: - payment.quote.lowEstimatedExchangeRate.valueOf(), - highEstimatedExchangeRate: - payment.quote.highEstimatedExchangeRate.valueOf(), createdAt: payment.quote.createdAt.toISOString(), expiresAt: payment.quote.expiresAt.toISOString(), + estimatedExchangeRate: payment.quote.estimatedExchangeRate + ? parseFloat(payment.quote.estimatedExchangeRate?.toString()) + : undefined, __typename: 'Quote' }, createdAt: payment.createdAt.toISOString(), diff --git a/packages/backend/src/graphql/resolvers/quote.test.ts b/packages/backend/src/graphql/resolvers/quote.test.ts index 39efdac43c..dcb703edc6 100644 --- a/packages/backend/src/graphql/resolvers/quote.test.ts +++ b/packages/backend/src/graphql/resolvers/quote.test.ts @@ -93,10 +93,6 @@ describe('Quote Resolvers', (): void => { assetCode assetScale } - maxPacketAmount - minExchangeRate - lowEstimatedExchangeRate - highEstimatedExchangeRate createdAt expiresAt } @@ -124,10 +120,6 @@ describe('Quote Resolvers', (): void => { assetScale: quote.receiveAmount.assetScale, __typename: 'Amount' }, - maxPacketAmount: quote.maxPacketAmount.toString(), - minExchangeRate: quote.minExchangeRate.valueOf(), - lowEstimatedExchangeRate: quote.lowEstimatedExchangeRate.valueOf(), - highEstimatedExchangeRate: quote.highEstimatedExchangeRate.valueOf(), createdAt: quote.createdAt.toISOString(), expiresAt: quote.expiresAt.toISOString(), __typename: 'Quote' diff --git a/packages/backend/src/graphql/resolvers/quote.ts b/packages/backend/src/graphql/resolvers/quote.ts index 638c0fecde..16bd2863e1 100644 --- a/packages/backend/src/graphql/resolvers/quote.ts +++ b/packages/backend/src/graphql/resolvers/quote.ts @@ -104,11 +104,8 @@ export function quoteToGraphql(quote: Quote): SchemaQuote { receiver: quote.receiver, debitAmount: quote.debitAmount, receiveAmount: quote.receiveAmount, - maxPacketAmount: quote.maxPacketAmount, - minExchangeRate: quote.minExchangeRate.valueOf(), - lowEstimatedExchangeRate: quote.lowEstimatedExchangeRate.valueOf(), - highEstimatedExchangeRate: quote.highEstimatedExchangeRate.valueOf(), createdAt: new Date(+quote.createdAt).toISOString(), - expiresAt: new Date(+quote.expiresAt).toISOString() + expiresAt: new Date(+quote.expiresAt).toISOString(), + estimatedExchangeRate: quote.estimatedExchangeRate?.valueOf() } } diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index dcf104c049..ed137ba407 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -957,18 +957,12 @@ type Quote { debitAmount: Amount! "Amount to receive (fixed receive)" receiveAmount: Amount! - "Maximum value per packet allowed on the possible routes" - maxPacketAmount: UInt64! - "Aggregate exchange rate the payment is guaranteed to meet" - minExchangeRate: Float! - "Lower bound of probed exchange rate" - lowEstimatedExchangeRate: Float! - "Upper bound of probed exchange rate" - highEstimatedExchangeRate: Float! "Date-time of creation" createdAt: String! "Date-time of expiration" expiresAt: String! + "Estimated exchange rate" + estimatedExchangeRate: Float } input AmountInput { diff --git a/packages/frontend/app/generated/graphql.ts b/packages/frontend/app/generated/graphql.ts index 10e878774f..db27546a81 100644 --- a/packages/frontend/app/generated/graphql.ts +++ b/packages/frontend/app/generated/graphql.ts @@ -1113,18 +1113,12 @@ export type Quote = { createdAt: Scalars['String']['output']; /** Amount to send (fixed send) */ debitAmount: Amount; + /** Estimated exchange rate */ + estimatedExchangeRate?: Maybe; /** Date-time of expiration */ expiresAt: Scalars['String']['output']; - /** Upper bound of probed exchange rate */ - highEstimatedExchangeRate: Scalars['Float']['output']; /** Quote id */ id: Scalars['ID']['output']; - /** Lower bound of probed exchange rate */ - lowEstimatedExchangeRate: Scalars['Float']['output']; - /** Maximum value per packet allowed on the possible routes */ - maxPacketAmount: Scalars['UInt64']['output']; - /** Aggregate exchange rate the payment is guaranteed to meet */ - minExchangeRate: Scalars['Float']['output']; /** Amount to receive (fixed receive) */ receiveAmount: Amount; /** Wallet address URL of the receiver */ @@ -2101,12 +2095,9 @@ export type QueryResolvers = { createdAt?: Resolver; debitAmount?: Resolver; + estimatedExchangeRate?: Resolver, ParentType, ContextType>; expiresAt?: Resolver; - highEstimatedExchangeRate?: Resolver; id?: Resolver; - lowEstimatedExchangeRate?: Resolver; - maxPacketAmount?: Resolver; - minExchangeRate?: Resolver; receiveAmount?: Resolver; receiver?: Resolver; walletAddressId?: Resolver; diff --git a/packages/mock-account-service-lib/src/generated/graphql.ts b/packages/mock-account-service-lib/src/generated/graphql.ts index e482374c2f..55a68afa65 100644 --- a/packages/mock-account-service-lib/src/generated/graphql.ts +++ b/packages/mock-account-service-lib/src/generated/graphql.ts @@ -1113,18 +1113,12 @@ export type Quote = { createdAt: Scalars['String']['output']; /** Amount to send (fixed send) */ debitAmount: Amount; + /** Estimated exchange rate */ + estimatedExchangeRate?: Maybe; /** Date-time of expiration */ expiresAt: Scalars['String']['output']; - /** Upper bound of probed exchange rate */ - highEstimatedExchangeRate: Scalars['Float']['output']; /** Quote id */ id: Scalars['ID']['output']; - /** Lower bound of probed exchange rate */ - lowEstimatedExchangeRate: Scalars['Float']['output']; - /** Maximum value per packet allowed on the possible routes */ - maxPacketAmount: Scalars['UInt64']['output']; - /** Aggregate exchange rate the payment is guaranteed to meet */ - minExchangeRate: Scalars['Float']['output']; /** Amount to receive (fixed receive) */ receiveAmount: Amount; /** Wallet address URL of the receiver */ @@ -2101,12 +2095,9 @@ export type QueryResolvers = { createdAt?: Resolver; debitAmount?: Resolver; + estimatedExchangeRate?: Resolver, ParentType, ContextType>; expiresAt?: Resolver; - highEstimatedExchangeRate?: Resolver; id?: Resolver; - lowEstimatedExchangeRate?: Resolver; - maxPacketAmount?: Resolver; - minExchangeRate?: Resolver; receiveAmount?: Resolver; receiver?: Resolver; walletAddressId?: Resolver; diff --git a/test/integration/lib/admin-client.ts b/test/integration/lib/admin-client.ts index 08f176ad67..589e6b5ae6 100644 --- a/test/integration/lib/admin-client.ts +++ b/test/integration/lib/admin-client.ts @@ -68,11 +68,7 @@ export class AdminClient { quote { createdAt expiresAt - highEstimatedExchangeRate id - lowEstimatedExchangeRate - maxPacketAmount - minExchangeRate walletAddressId receiveAmount { assetCode diff --git a/test/integration/lib/generated/graphql.ts b/test/integration/lib/generated/graphql.ts index e482374c2f..55a68afa65 100644 --- a/test/integration/lib/generated/graphql.ts +++ b/test/integration/lib/generated/graphql.ts @@ -1113,18 +1113,12 @@ export type Quote = { createdAt: Scalars['String']['output']; /** Amount to send (fixed send) */ debitAmount: Amount; + /** Estimated exchange rate */ + estimatedExchangeRate?: Maybe; /** Date-time of expiration */ expiresAt: Scalars['String']['output']; - /** Upper bound of probed exchange rate */ - highEstimatedExchangeRate: Scalars['Float']['output']; /** Quote id */ id: Scalars['ID']['output']; - /** Lower bound of probed exchange rate */ - lowEstimatedExchangeRate: Scalars['Float']['output']; - /** Maximum value per packet allowed on the possible routes */ - maxPacketAmount: Scalars['UInt64']['output']; - /** Aggregate exchange rate the payment is guaranteed to meet */ - minExchangeRate: Scalars['Float']['output']; /** Amount to receive (fixed receive) */ receiveAmount: Amount; /** Wallet address URL of the receiver */ @@ -2101,12 +2095,9 @@ export type QueryResolvers = { createdAt?: Resolver; debitAmount?: Resolver; + estimatedExchangeRate?: Resolver, ParentType, ContextType>; expiresAt?: Resolver; - highEstimatedExchangeRate?: Resolver; id?: Resolver; - lowEstimatedExchangeRate?: Resolver; - maxPacketAmount?: Resolver; - minExchangeRate?: Resolver; receiveAmount?: Resolver; receiver?: Resolver; walletAddressId?: Resolver;