diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address Additional Properties.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address Additional Properties.bru new file mode 100644 index 0000000000..a9f64bf244 --- /dev/null +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address Additional Properties.bru @@ -0,0 +1,29 @@ +meta { + name: Get Wallet Address Additional Properties + type: graphql + seq: 21 +} + +post { + url: {{RafikiGraphqlHost}}/graphql + body: graphql + auth: none +} + +body:graphql { + query GetWalletAddressAdditionalProperties { + additionalProperties { + properties { + key + value + visibleInOpenPayments + } + } + } +} + +script:pre-request { + const scripts = require('./scripts'); + + scripts.addApiSignatureHeader(); +} diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address.bru index f1bb959347..86e08cbc02 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Get Wallet Address.bru @@ -66,13 +66,6 @@ body:graphql { } } status - additionalProperties { - properties { - key - value - visibleInOpenPayments - } - } } } } diff --git a/localenv/mock-account-servicing-entity/generated/graphql.ts b/localenv/mock-account-servicing-entity/generated/graphql.ts index a5f60c104b..fda91df392 100644 --- a/localenv/mock-account-servicing-entity/generated/graphql.ts +++ b/localenv/mock-account-servicing-entity/generated/graphql.ts @@ -1007,6 +1007,8 @@ export type PostLiquidityWithdrawalInput = { export type Query = { __typename?: 'Query'; + /** Get the list of of additional properties associated with [walletAddressId] wallet address. */ + additionalProperties?: Maybe; /** Fetch an asset */ asset?: Maybe; /** Fetch a page of assets. */ @@ -1025,7 +1027,7 @@ export type Query = { quote?: Maybe; /** Get an local or remote Open Payments Incoming Payment. The receiver has a wallet address on either this or another Open Payments resource server. */ receiver?: Maybe; - /** Fetch a wallet address, and optionally additional properties. */ + /** Fetch a wallet address. */ walletAddress?: Maybe; /** Fetch a page of wallet addresses. */ walletAddresses: WalletAddressesConnection; @@ -1034,6 +1036,11 @@ export type Query = { }; +export type QueryAdditionalPropertiesArgs = { + walletAddressId: Scalars['String']['input']; +}; + + export type QueryAssetArgs = { id: Scalars['String']['input']; }; @@ -1094,7 +1101,6 @@ export type QueryReceiverArgs = { export type QueryWalletAddressArgs = { id: Scalars['String']['input']; - includeAdditionalProperties?: InputMaybe; }; @@ -1312,8 +1318,6 @@ export type VoidLiquidityWithdrawalInput = { export type WalletAddress = Model & { __typename?: 'WalletAddress'; - /** List of additional properties associated with this wallet address */ - additionalProperties?: Maybe; /** Asset of the wallet address */ asset: Asset; /** Date-time of creation */ @@ -2137,6 +2141,7 @@ export type PeersConnectionResolvers = { + additionalProperties?: Resolver, ParentType, ContextType, RequireFields>; asset?: Resolver, ParentType, ContextType, RequireFields>; assets?: Resolver>; incomingPayment?: Resolver, ParentType, ContextType, RequireFields>; @@ -2255,7 +2260,6 @@ export type UpdateWalletAddressMutationResponseResolvers = { - additionalProperties?: Resolver, ParentType, ContextType>; asset?: Resolver; createdAt?: Resolver; id?: Resolver; diff --git a/packages/backend/src/graphql/generated/graphql.schema.json b/packages/backend/src/graphql/generated/graphql.schema.json index eb7c90e3f2..fc9daf746b 100644 --- a/packages/backend/src/graphql/generated/graphql.schema.json +++ b/packages/backend/src/graphql/generated/graphql.schema.json @@ -6396,6 +6396,35 @@ "name": "Query", "description": null, "fields": [ + { + "name": "additionalProperties", + "description": "Get the list of of additional properties associated with [walletAddressId] wallet address.", + "args": [ + { + "name": "walletAddressId", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "AdditionalPropertyConnection", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "asset", "description": "Fetch an asset", @@ -6815,7 +6844,7 @@ }, { "name": "walletAddress", - "description": "Fetch a wallet address, and optionally additional properties.", + "description": "Fetch a wallet address.", "args": [ { "name": "id", @@ -6832,18 +6861,6 @@ "defaultValue": null, "isDeprecated": false, "deprecationReason": null - }, - { - "name": "includeAdditionalProperties", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null } ], "type": { @@ -8442,18 +8459,6 @@ "name": "WalletAddress", "description": null, "fields": [ - { - "name": "additionalProperties", - "description": "List of additional properties associated with this wallet address", - "args": [], - "type": { - "kind": "OBJECT", - "name": "AdditionalPropertyConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "asset", "description": "Asset of the wallet address", diff --git a/packages/backend/src/graphql/generated/graphql.ts b/packages/backend/src/graphql/generated/graphql.ts index a5f60c104b..fda91df392 100644 --- a/packages/backend/src/graphql/generated/graphql.ts +++ b/packages/backend/src/graphql/generated/graphql.ts @@ -1007,6 +1007,8 @@ export type PostLiquidityWithdrawalInput = { export type Query = { __typename?: 'Query'; + /** Get the list of of additional properties associated with [walletAddressId] wallet address. */ + additionalProperties?: Maybe; /** Fetch an asset */ asset?: Maybe; /** Fetch a page of assets. */ @@ -1025,7 +1027,7 @@ export type Query = { quote?: Maybe; /** Get an local or remote Open Payments Incoming Payment. The receiver has a wallet address on either this or another Open Payments resource server. */ receiver?: Maybe; - /** Fetch a wallet address, and optionally additional properties. */ + /** Fetch a wallet address. */ walletAddress?: Maybe; /** Fetch a page of wallet addresses. */ walletAddresses: WalletAddressesConnection; @@ -1034,6 +1036,11 @@ export type Query = { }; +export type QueryAdditionalPropertiesArgs = { + walletAddressId: Scalars['String']['input']; +}; + + export type QueryAssetArgs = { id: Scalars['String']['input']; }; @@ -1094,7 +1101,6 @@ export type QueryReceiverArgs = { export type QueryWalletAddressArgs = { id: Scalars['String']['input']; - includeAdditionalProperties?: InputMaybe; }; @@ -1312,8 +1318,6 @@ export type VoidLiquidityWithdrawalInput = { export type WalletAddress = Model & { __typename?: 'WalletAddress'; - /** List of additional properties associated with this wallet address */ - additionalProperties?: Maybe; /** Asset of the wallet address */ asset: Asset; /** Date-time of creation */ @@ -2137,6 +2141,7 @@ export type PeersConnectionResolvers = { + additionalProperties?: Resolver, ParentType, ContextType, RequireFields>; asset?: Resolver, ParentType, ContextType, RequireFields>; assets?: Resolver>; incomingPayment?: Resolver, ParentType, ContextType, RequireFields>; @@ -2255,7 +2260,6 @@ export type UpdateWalletAddressMutationResponseResolvers = { - additionalProperties?: Resolver, ParentType, ContextType>; asset?: Resolver; createdAt?: Resolver; id?: Resolver; diff --git a/packages/backend/src/graphql/resolvers/index.ts b/packages/backend/src/graphql/resolvers/index.ts index a61ca27a5e..5696a05a05 100644 --- a/packages/backend/src/graphql/resolvers/index.ts +++ b/packages/backend/src/graphql/resolvers/index.ts @@ -56,6 +56,7 @@ import { getWalletAddressKeys, revokeWalletAddressKey } from './walletAddressKey' +import { getWalletAddressAdditionalProperties } from './walletAddressAdditionalProperties' import { createReceiver, getReceiver } from './receiver' import { getWebhookEvents } from './webhooks' import { setFee } from './fee' @@ -88,7 +89,8 @@ export const resolvers: Resolvers = { quote: getQuote, webhookEvents: getWebhookEvents, payments: getCombinedPayments, - receiver: getReceiver + receiver: getReceiver, + additionalProperties: getWalletAddressAdditionalProperties }, WalletAddress: { liquidity: getWalletAddressLiquidity, diff --git a/packages/backend/src/graphql/resolvers/walletAddressAdditionalProperties.ts b/packages/backend/src/graphql/resolvers/walletAddressAdditionalProperties.ts new file mode 100644 index 0000000000..134bc791a4 --- /dev/null +++ b/packages/backend/src/graphql/resolvers/walletAddressAdditionalProperties.ts @@ -0,0 +1,39 @@ +import { + ResolversTypes, + AdditionalProperty, + QueryResolvers +} from '../generated/graphql' +import { ApolloContext } from '../../app' +import { WalletAddressAdditionalProperty } from '../../open_payments/wallet_address/additional_property/model' + +export const getWalletAddressAdditionalProperties: QueryResolvers['additionalProperties'] = + async ( + parent, + args, + ctx + ): Promise => { + if (!args.walletAddressId) { + throw new Error('missing wallet address id') + } + const walletAddressService = await ctx.container.use('walletAddressService') + const additionalProperties = + await walletAddressService.getAdditionalProperties( + args.walletAddressId, + false // Include all Additional Properties + ) + if (!additionalProperties) return { properties: [] } + + return { + properties: additionalProperties.map((itm) => + additionalPropertyToGraphql(itm) + ) + } + } + +export const additionalPropertyToGraphql = ( + addProp: WalletAddressAdditionalProperty +): AdditionalProperty => ({ + key: addProp.fieldKey, + value: addProp.fieldValue, + visibleInOpenPayments: addProp.visibleInOpenPayments +}) diff --git a/packages/backend/src/graphql/resolvers/wallet_address.test.ts b/packages/backend/src/graphql/resolvers/wallet_address.test.ts index 0db4fec758..39c47b215b 100644 --- a/packages/backend/src/graphql/resolvers/wallet_address.test.ts +++ b/packages/backend/src/graphql/resolvers/wallet_address.test.ts @@ -31,7 +31,8 @@ import { WalletAddress, WalletAddressStatus, UpdateWalletAddressMutationResponse, - WalletAddressesConnection + WalletAddressesConnection, + AdditionalPropertyConnection } from '../generated/graphql' import { getPageTests } from './page.test' import { WalletAddressAdditionalProperty } from '../../open_payments/wallet_address/additional_property/model' @@ -510,26 +511,12 @@ describe('Wallet Address Resolvers', (): void => { const queryAddProps = await appContainer.apolloClient .query({ query: gql` - query WalletAddress($walletAddressId: String!) { - walletAddress( - id: $walletAddressId - includeAdditionalProperties: true - ) { - id - liquidity - asset { - code - scale - } - url - publicName - status - additionalProperties { - properties { - key - value - visibleInOpenPayments - } + query Query($walletAddressId: String!) { + additionalProperties(walletAddressId: $walletAddressId) { + properties { + key + value + visibleInOpenPayments } } } @@ -538,26 +525,15 @@ describe('Wallet Address Resolvers', (): void => { walletAddressId: walletAddress.id } }) - .then((query): WalletAddress => { + .then((query): AdditionalPropertyConnection => { if (query.data) { - return query.data.walletAddress + return query.data } else { throw new Error('Data was empty') } }) expect(queryAddProps).toEqual({ - __typename: 'WalletAddress', - id: walletAddress.id, - liquidity: '0', - asset: { - __typename: 'Asset', - code: walletAddress.asset.code, - scale: walletAddress.asset.scale - }, - url: walletAddress.url, - publicName: publicName ?? null, - status: WalletAddressStatus.Active, additionalProperties: { __typename: 'AdditionalPropertyConnection', properties: [ diff --git a/packages/backend/src/graphql/resolvers/wallet_address.ts b/packages/backend/src/graphql/resolvers/wallet_address.ts index accd223811..21ec7ccfa5 100644 --- a/packages/backend/src/graphql/resolvers/wallet_address.ts +++ b/packages/backend/src/graphql/resolvers/wallet_address.ts @@ -4,9 +4,7 @@ import { ResolversTypes, WalletAddress as SchemaWalletAddress, MutationResolvers, - WalletAddressStatus, - AdditionalPropertyConnection, - AdditionalProperty + WalletAddressStatus } from '../generated/graphql' import { ApolloContext } from '../../app' import { @@ -55,12 +53,6 @@ export const getWalletAddress: QueryResolvers['walletAddress'] = const walletAddress = await walletAddressService.get(args.id) if (!walletAddress) { throw new Error('No wallet address') - } else if (args.includeAdditionalProperties) { - walletAddress.additionalProperties = - await walletAddressService.getAdditionalProperties( - walletAddress.id, - false - ) } return walletAddressToGraphql(walletAddress) } @@ -181,25 +173,5 @@ export const walletAddressToGraphql = ( createdAt: new Date(+walletAddress.createdAt).toISOString(), status: walletAddress.isActive ? WalletAddressStatus.Active - : WalletAddressStatus.Inactive, - additionalProperties: additionalPropertiesToGraphql( - walletAddress.additionalProperties - ) -}) - -export const additionalPropertiesToGraphql = ( - addProperties: WalletAddressAdditionalProperty[] | undefined -): AdditionalPropertyConnection => { - if (addProperties === undefined) return { properties: [] } - return { - properties: addProperties.map((itm) => additionalPropertyToGraphql(itm)) - } -} - -export const additionalPropertyToGraphql = ( - addProp: WalletAddressAdditionalProperty -): AdditionalProperty => ({ - key: addProp.fieldKey, - value: addProp.fieldValue, - visibleInOpenPayments: addProp.visibleInOpenPayments + : WalletAddressStatus.Inactive }) diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index 1583ba3b0f..86abda9e37 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -33,11 +33,8 @@ type Query { sortOrder: SortOrder ): PeersConnection! - "Fetch a wallet address, and optionally additional properties." - walletAddress( - id: String! - includeAdditionalProperties: Boolean - ): WalletAddress + "Fetch a wallet address." + walletAddress(id: String!): WalletAddress "Fetch a page of wallet addresses." walletAddresses( @@ -96,6 +93,9 @@ type Query { "Get an local or remote Open Payments Incoming Payment. The receiver has a wallet address on either this or another Open Payments resource server." receiver(id: String!): Receiver + + "Get the list of of additional properties associated with [walletAddressId] wallet address." + additionalProperties(walletAddressId: String!): AdditionalPropertyConnection } type Mutation { @@ -624,14 +624,19 @@ type WalletAddressEdge { type WalletAddress implements Model { "Wallet address id" id: ID! + "Asset of the wallet address" asset: Asset! + "Available liquidity" liquidity: UInt64 + "Wallet Address URL" url: String! + "Public name associated with the wallet address" publicName: String + "List of incoming payments received by this wallet address" incomingPayments( "Paginating forwards: the cursor before the the requested page." @@ -645,6 +650,7 @@ type WalletAddress implements Model { "Ascending or descending order of creation." sortOrder: SortOrder ): IncomingPaymentConnection + "List of quotes created at this wallet address" quotes( "Paginating forwards: the cursor before the the requested page." @@ -658,6 +664,7 @@ type WalletAddress implements Model { "Ascending or descending order of creation." sortOrder: SortOrder ): QuoteConnection + "List of outgoing payments sent from this wallet address" outgoingPayments( "Paginating forwards: the cursor before the the requested page." @@ -671,10 +678,13 @@ type WalletAddress implements Model { "Ascending or descending order of creation." sortOrder: SortOrder ): OutgoingPaymentConnection + "Date-time of creation" createdAt: String! + "Status of the wallet address" status: WalletAddressStatus! + "List of keys associated with this wallet address" walletAddressKeys( "Paginating forwards: the cursor before the the requested page." @@ -688,8 +698,6 @@ type WalletAddress implements Model { "Ascending or descending order of creation." sortOrder: SortOrder ): WalletAddressKeyConnection - "List of additional properties associated with this wallet address" - additionalProperties: AdditionalPropertyConnection } type AdditionalPropertyConnection { diff --git a/packages/frontend/app/generated/graphql.ts b/packages/frontend/app/generated/graphql.ts index 82b2a88d52..eb21db5b95 100644 --- a/packages/frontend/app/generated/graphql.ts +++ b/packages/frontend/app/generated/graphql.ts @@ -1007,6 +1007,8 @@ export type PostLiquidityWithdrawalInput = { export type Query = { __typename?: 'Query'; + /** Get the list of of additional properties associated with [walletAddressId] wallet address. */ + additionalProperties?: Maybe; /** Fetch an asset */ asset?: Maybe; /** Fetch a page of assets. */ @@ -1025,7 +1027,7 @@ export type Query = { quote?: Maybe; /** Get an local or remote Open Payments Incoming Payment. The receiver has a wallet address on either this or another Open Payments resource server. */ receiver?: Maybe; - /** Fetch a wallet address, and optionally additional properties. */ + /** Fetch a wallet address. */ walletAddress?: Maybe; /** Fetch a page of wallet addresses. */ walletAddresses: WalletAddressesConnection; @@ -1034,6 +1036,11 @@ export type Query = { }; +export type QueryAdditionalPropertiesArgs = { + walletAddressId: Scalars['String']['input']; +}; + + export type QueryAssetArgs = { id: Scalars['String']['input']; }; @@ -1094,7 +1101,6 @@ export type QueryReceiverArgs = { export type QueryWalletAddressArgs = { id: Scalars['String']['input']; - includeAdditionalProperties?: InputMaybe; }; @@ -1312,8 +1318,6 @@ export type VoidLiquidityWithdrawalInput = { export type WalletAddress = Model & { __typename?: 'WalletAddress'; - /** List of additional properties associated with this wallet address */ - additionalProperties?: Maybe; /** Asset of the wallet address */ asset: Asset; /** Date-time of creation */ @@ -2137,6 +2141,7 @@ export type PeersConnectionResolvers = { + additionalProperties?: Resolver, ParentType, ContextType, RequireFields>; asset?: Resolver, ParentType, ContextType, RequireFields>; assets?: Resolver>; incomingPayment?: Resolver, ParentType, ContextType, RequireFields>; @@ -2255,7 +2260,6 @@ export type UpdateWalletAddressMutationResponseResolvers = { - additionalProperties?: Resolver, ParentType, ContextType>; asset?: Resolver; createdAt?: Resolver; id?: Resolver; diff --git a/packages/mock-account-service-lib/src/generated/graphql.ts b/packages/mock-account-service-lib/src/generated/graphql.ts index a5f60c104b..fda91df392 100644 --- a/packages/mock-account-service-lib/src/generated/graphql.ts +++ b/packages/mock-account-service-lib/src/generated/graphql.ts @@ -1007,6 +1007,8 @@ export type PostLiquidityWithdrawalInput = { export type Query = { __typename?: 'Query'; + /** Get the list of of additional properties associated with [walletAddressId] wallet address. */ + additionalProperties?: Maybe; /** Fetch an asset */ asset?: Maybe; /** Fetch a page of assets. */ @@ -1025,7 +1027,7 @@ export type Query = { quote?: Maybe; /** Get an local or remote Open Payments Incoming Payment. The receiver has a wallet address on either this or another Open Payments resource server. */ receiver?: Maybe; - /** Fetch a wallet address, and optionally additional properties. */ + /** Fetch a wallet address. */ walletAddress?: Maybe; /** Fetch a page of wallet addresses. */ walletAddresses: WalletAddressesConnection; @@ -1034,6 +1036,11 @@ export type Query = { }; +export type QueryAdditionalPropertiesArgs = { + walletAddressId: Scalars['String']['input']; +}; + + export type QueryAssetArgs = { id: Scalars['String']['input']; }; @@ -1094,7 +1101,6 @@ export type QueryReceiverArgs = { export type QueryWalletAddressArgs = { id: Scalars['String']['input']; - includeAdditionalProperties?: InputMaybe; }; @@ -1312,8 +1318,6 @@ export type VoidLiquidityWithdrawalInput = { export type WalletAddress = Model & { __typename?: 'WalletAddress'; - /** List of additional properties associated with this wallet address */ - additionalProperties?: Maybe; /** Asset of the wallet address */ asset: Asset; /** Date-time of creation */ @@ -2137,6 +2141,7 @@ export type PeersConnectionResolvers = { + additionalProperties?: Resolver, ParentType, ContextType, RequireFields>; asset?: Resolver, ParentType, ContextType, RequireFields>; assets?: Resolver>; incomingPayment?: Resolver, ParentType, ContextType, RequireFields>; @@ -2255,7 +2260,6 @@ export type UpdateWalletAddressMutationResponseResolvers = { - additionalProperties?: Resolver, ParentType, ContextType>; asset?: Resolver; createdAt?: Resolver; id?: Resolver; diff --git a/test/integration/lib/generated/graphql.ts b/test/integration/lib/generated/graphql.ts index a5f60c104b..fda91df392 100644 --- a/test/integration/lib/generated/graphql.ts +++ b/test/integration/lib/generated/graphql.ts @@ -1007,6 +1007,8 @@ export type PostLiquidityWithdrawalInput = { export type Query = { __typename?: 'Query'; + /** Get the list of of additional properties associated with [walletAddressId] wallet address. */ + additionalProperties?: Maybe; /** Fetch an asset */ asset?: Maybe; /** Fetch a page of assets. */ @@ -1025,7 +1027,7 @@ export type Query = { quote?: Maybe; /** Get an local or remote Open Payments Incoming Payment. The receiver has a wallet address on either this or another Open Payments resource server. */ receiver?: Maybe; - /** Fetch a wallet address, and optionally additional properties. */ + /** Fetch a wallet address. */ walletAddress?: Maybe; /** Fetch a page of wallet addresses. */ walletAddresses: WalletAddressesConnection; @@ -1034,6 +1036,11 @@ export type Query = { }; +export type QueryAdditionalPropertiesArgs = { + walletAddressId: Scalars['String']['input']; +}; + + export type QueryAssetArgs = { id: Scalars['String']['input']; }; @@ -1094,7 +1101,6 @@ export type QueryReceiverArgs = { export type QueryWalletAddressArgs = { id: Scalars['String']['input']; - includeAdditionalProperties?: InputMaybe; }; @@ -1312,8 +1318,6 @@ export type VoidLiquidityWithdrawalInput = { export type WalletAddress = Model & { __typename?: 'WalletAddress'; - /** List of additional properties associated with this wallet address */ - additionalProperties?: Maybe; /** Asset of the wallet address */ asset: Asset; /** Date-time of creation */ @@ -2137,6 +2141,7 @@ export type PeersConnectionResolvers = { + additionalProperties?: Resolver, ParentType, ContextType, RequireFields>; asset?: Resolver, ParentType, ContextType, RequireFields>; assets?: Resolver>; incomingPayment?: Resolver, ParentType, ContextType, RequireFields>; @@ -2255,7 +2260,6 @@ export type UpdateWalletAddressMutationResponseResolvers = { - additionalProperties?: Resolver, ParentType, ContextType>; asset?: Resolver; createdAt?: Resolver; id?: Resolver;