From ed0ff8f1e02339c2b99cf4669e8120f7a1e04035 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Mon, 22 Apr 2024 11:28:59 +0200 Subject: [PATCH 01/21] feat(2662): 2phase incoming and outgoing payments --- .../generated/graphql.ts | 70 ++--- .../src/graphql/generated/graphql.schema.json | 290 +++++++++--------- .../backend/src/graphql/generated/graphql.ts | 70 ++--- .../backend/src/graphql/resolvers/index.ts | 8 +- .../src/graphql/resolvers/liquidity.ts | 10 +- packages/backend/src/graphql/schema.graphql | 14 +- packages/frontend/app/generated/graphql.ts | 82 ++--- .../frontend/app/lib/api/payments.server.ts | 44 +-- ....$incomingPaymentId.withdraw-liquidity.tsx | 4 +- ....$outgoingPaymentId.withdraw-liquidity.tsx | 4 +- .../src/generated/graphql.ts | 70 ++--- test/integration/lib/generated/graphql.ts | 70 ++--- 12 files changed, 369 insertions(+), 367 deletions(-) diff --git a/localenv/mock-account-servicing-entity/generated/graphql.ts b/localenv/mock-account-servicing-entity/generated/graphql.ts index a36fd76256..531d7296ac 100644 --- a/localenv/mock-account-servicing-entity/generated/graphql.ts +++ b/localenv/mock-account-servicing-entity/generated/graphql.ts @@ -138,6 +138,13 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -174,6 +181,13 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -544,10 +558,14 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -593,13 +611,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -618,6 +632,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -628,6 +647,11 @@ export type MutationCreateOutgoingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -732,16 +756,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1346,20 +1360,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1449,9 +1449,11 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1548,8 +1550,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1565,9 +1565,11 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1655,8 +1657,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1854,8 +1854,10 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1877,8 +1879,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { diff --git a/packages/backend/src/graphql/generated/graphql.schema.json b/packages/backend/src/graphql/generated/graphql.schema.json index 4d0a06c910..56df1ff29a 100644 --- a/packages/backend/src/graphql/generated/graphql.schema.json +++ b/packages/backend/src/graphql/generated/graphql.schema.json @@ -866,6 +866,49 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "CreateIncomingPaymentWithdrawalInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "idempotencyKey", + "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "incomingPaymentId", + "description": "The id of the incoming payment to withdraw from.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "CreateOrUpdatePeerByUrlInput", @@ -1113,6 +1156,49 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "CreateOutgoingPaymentWithdrawalInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "idempotencyKey", + "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "outgoingPaymentId", + "description": "The id of the outgoing payment to withdraw from.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "CreatePeerInput", @@ -3742,6 +3828,35 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "createIncomingPaymentWithdrawal", + "description": "Withdraw incoming payment liquidity", + "args": [ + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "CreateIncomingPaymentWithdrawalInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "LiquidityMutationResponse", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createOrUpdatePeerByUrl", "description": "Create a peer using a URL", @@ -3808,6 +3923,35 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "createOutgoingPaymentWithdrawal", + "description": "Withdraw outgoing payment liquidity", + "args": [ + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "CreateOutgoingPaymentWithdrawalInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "LiquidityMutationResponse", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createPeer", "description": "Create a peer", @@ -4455,65 +4599,7 @@ "ofType": null }, "isDeprecated": true, - "deprecationReason": "Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal`" - }, - { - "name": "withdrawIncomingPaymentLiquidity", - "description": "Withdraw incoming payment liquidity", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "WithdrawIncomingPaymentLiquidityInput", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LiquidityMutationResponse", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "withdrawOutgoingPaymentLiquidity", - "description": "Withdraw outgoing payment liquidity", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "WithdrawOutgoingPaymentLiquidityInput", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LiquidityMutationResponse", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null + "deprecationReason": "Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal`" } ], "inputFields": null, @@ -8689,92 +8775,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "INPUT_OBJECT", - "name": "WithdrawIncomingPaymentLiquidityInput", - "description": null, - "fields": null, - "inputFields": [ - { - "name": "idempotencyKey", - "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "incomingPaymentId", - "description": "The id of the incoming payment to withdraw from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "WithdrawOutgoingPaymentLiquidityInput", - "description": null, - "fields": null, - "inputFields": [ - { - "name": "idempotencyKey", - "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "outgoingPaymentId", - "description": "The id of the outgoing payment to withdraw from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "__Directive", diff --git a/packages/backend/src/graphql/generated/graphql.ts b/packages/backend/src/graphql/generated/graphql.ts index a36fd76256..531d7296ac 100644 --- a/packages/backend/src/graphql/generated/graphql.ts +++ b/packages/backend/src/graphql/generated/graphql.ts @@ -138,6 +138,13 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -174,6 +181,13 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -544,10 +558,14 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -593,13 +611,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -618,6 +632,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -628,6 +647,11 @@ export type MutationCreateOutgoingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -732,16 +756,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1346,20 +1360,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1449,9 +1449,11 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1548,8 +1550,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1565,9 +1565,11 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1655,8 +1657,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1854,8 +1854,10 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1877,8 +1879,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { diff --git a/packages/backend/src/graphql/resolvers/index.ts b/packages/backend/src/graphql/resolvers/index.ts index 6f1f09abda..d69079d5b4 100644 --- a/packages/backend/src/graphql/resolvers/index.ts +++ b/packages/backend/src/graphql/resolvers/index.ts @@ -44,8 +44,8 @@ import { depositEventLiquidity, withdrawEventLiquidity, depositOutgoingPaymentLiquidity, - withdrawIncomingPaymentLiquidity, - withdrawOutgoingPaymentLiquidity + createIncomingPaymentWithdrawal, + createOutgoingPaymentWithdrawal } from './liquidity' import { GraphQLBigInt, GraphQLUInt8 } from '../scalars' import { @@ -127,8 +127,8 @@ export const resolvers: Resolvers = { depositEventLiquidity, withdrawEventLiquidity, depositOutgoingPaymentLiquidity, - withdrawIncomingPaymentLiquidity, - withdrawOutgoingPaymentLiquidity, + createIncomingPaymentWithdrawal, + createOutgoingPaymentWithdrawal, setFee } } diff --git a/packages/backend/src/graphql/resolvers/liquidity.ts b/packages/backend/src/graphql/resolvers/liquidity.ts index 0659ad78c1..d6c67ec5dd 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.ts @@ -522,7 +522,7 @@ export const depositOutgoingPaymentLiquidity: MutationResolvers[' } } -export const withdrawIncomingPaymentLiquidity: MutationResolvers['withdrawIncomingPaymentLiquidity'] = +export const createIncomingPaymentWithdrawal: MutationResolvers['createIncomingPaymentWithdrawal'] = async ( parent, args, @@ -555,7 +555,8 @@ export const withdrawIncomingPaymentLiquidity: MutationResolvers[ id: incomingPaymentId, asset: incomingPayment.asset }, - amount: incomingPayment.receivedAmount.value + amount: incomingPayment.receivedAmount.value, + timeout: 60 }) if (error) { @@ -582,7 +583,7 @@ export const withdrawIncomingPaymentLiquidity: MutationResolvers[ } } -export const withdrawOutgoingPaymentLiquidity: MutationResolvers['withdrawOutgoingPaymentLiquidity'] = +export const createOutgoingPaymentWithdrawal: MutationResolvers['createOutgoingPaymentWithdrawal'] = async ( parent, args, @@ -620,7 +621,8 @@ export const withdrawOutgoingPaymentLiquidity: MutationResolvers[ id: outgoingPaymentId, asset: outgoingPayment.asset }, - amount: balance + amount: balance, + timeout: 60 }) if (error) { diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index 0ecb1b6659..d9234ce0df 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -193,17 +193,17 @@ type Mutation { input: WithdrawEventLiquidityInput! ): LiquidityMutationResponse @deprecated( - reason: "Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal`" + reason: "Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal`" ) "Withdraw incoming payment liquidity" - withdrawIncomingPaymentLiquidity( - input: WithdrawIncomingPaymentLiquidityInput! + createIncomingPaymentWithdrawal( + input: CreateIncomingPaymentWithdrawalInput! ): LiquidityMutationResponse "Withdraw outgoing payment liquidity" - withdrawOutgoingPaymentLiquidity( - input: WithdrawOutgoingPaymentLiquidityInput! + createOutgoingPaymentWithdrawal( + input: CreateOutgoingPaymentWithdrawalInput! ): LiquidityMutationResponse "Deposit outgoing payment liquidity" @@ -417,14 +417,14 @@ input DepositOutgoingPaymentLiquidityInput { idempotencyKey: String! } -input WithdrawIncomingPaymentLiquidityInput { +input CreateIncomingPaymentWithdrawalInput { "The id of the incoming payment to withdraw from." incomingPaymentId: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! } -input WithdrawOutgoingPaymentLiquidityInput { +input CreateOutgoingPaymentWithdrawalInput { "The id of the outgoing payment to withdraw from." outgoingPaymentId: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" diff --git a/packages/frontend/app/generated/graphql.ts b/packages/frontend/app/generated/graphql.ts index a366cd6233..dc38066fca 100644 --- a/packages/frontend/app/generated/graphql.ts +++ b/packages/frontend/app/generated/graphql.ts @@ -138,6 +138,13 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -174,6 +181,13 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -544,10 +558,14 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -593,13 +611,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -618,6 +632,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -628,6 +647,11 @@ export type MutationCreateOutgoingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -732,16 +756,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1346,20 +1360,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1449,9 +1449,11 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1548,8 +1550,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1565,9 +1565,11 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1655,8 +1657,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1854,8 +1854,10 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1877,8 +1879,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { @@ -2332,19 +2332,19 @@ export type DepositOutgoingPaymentLiquidityVariables = Exact<{ export type DepositOutgoingPaymentLiquidity = { __typename?: 'Mutation', depositOutgoingPaymentLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; -export type WithdrawOutgoingPaymentLiquidityVariables = Exact<{ - input: WithdrawOutgoingPaymentLiquidityInput; +export type CreateOutgoingPaymentWithdrawalVariables = Exact<{ + input: CreateOutgoingPaymentWithdrawalInput; }>; -export type WithdrawOutgoingPaymentLiquidity = { __typename?: 'Mutation', withdrawOutgoingPaymentLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; +export type CreateOutgoingPaymentWithdrawal = { __typename?: 'Mutation', createOutgoingPaymentWithdrawal?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; -export type WithdrawIncomingPaymentLiquidityVariables = Exact<{ - input: WithdrawIncomingPaymentLiquidityInput; +export type CreateIncomingPaymentWithdrawalVariables = Exact<{ + input: CreateIncomingPaymentWithdrawalInput; }>; -export type WithdrawIncomingPaymentLiquidity = { __typename?: 'Mutation', withdrawIncomingPaymentLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; +export type CreateIncomingPaymentWithdrawal = { __typename?: 'Mutation', createIncomingPaymentWithdrawal?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; export type GetPeerQueryVariables = Exact<{ id: Scalars['String']['input']; diff --git a/packages/frontend/app/lib/api/payments.server.ts b/packages/frontend/app/lib/api/payments.server.ts index a8300ee67d..11540e527e 100644 --- a/packages/frontend/app/lib/api/payments.server.ts +++ b/packages/frontend/app/lib/api/payments.server.ts @@ -2,12 +2,12 @@ import { gql } from '@apollo/client' import type { ListPaymentsQuery, ListPaymentsQueryVariables, - WithdrawIncomingPaymentLiquidity, - WithdrawIncomingPaymentLiquidityVariables, - WithdrawIncomingPaymentLiquidityInput, - WithdrawOutgoingPaymentLiquidity, - WithdrawOutgoingPaymentLiquidityVariables, - WithdrawOutgoingPaymentLiquidityInput, + CreateIncomingPaymentWithdrawal, + CreateIncomingPaymentWithdrawalVariables, + CreateIncomingPaymentWithdrawalInput, + CreateOutgoingPaymentWithdrawal, + CreateOutgoingPaymentWithdrawalVariables, + CreateOutgoingPaymentWithdrawalInput, DepositOutgoingPaymentLiquidityInput, DepositOutgoingPaymentLiquidity, DepositOutgoingPaymentLiquidityVariables @@ -164,18 +164,18 @@ export const depositOutgoingPaymentLiquidity = async ( return response.data?.depositOutgoingPaymentLiquidity } -export const withdrawOutgoingPaymentLiquidity = async ( - args: WithdrawOutgoingPaymentLiquidityInput +export const createOutgoingPaymentWithdrawal = async ( + args: CreateOutgoingPaymentWithdrawalInput ) => { const response = await apolloClient.mutate< - WithdrawOutgoingPaymentLiquidity, - WithdrawOutgoingPaymentLiquidityVariables + CreateOutgoingPaymentWithdrawal, + CreateOutgoingPaymentWithdrawalVariables >({ mutation: gql` - mutation WithdrawOutgoingPaymentLiquidity( - $input: WithdrawOutgoingPaymentLiquidityInput! + mutation CreateOutgoingPaymentWithdrawal( + $input: CreateOutgoingPaymentWithdrawalInput! ) { - withdrawOutgoingPaymentLiquidity(input: $input) { + createOutgoingPaymentWithdrawal(input: $input) { success message } @@ -186,21 +186,21 @@ export const withdrawOutgoingPaymentLiquidity = async ( } }) - return response.data?.withdrawOutgoingPaymentLiquidity + return response.data?.createOutgoingPaymentWithdrawal } -export const withdrawIncomingPaymentLiquidity = async ( - args: WithdrawIncomingPaymentLiquidityInput +export const createIncomingPaymentWithdrawal = async ( + args: CreateIncomingPaymentWithdrawalInput ) => { const response = await apolloClient.mutate< - WithdrawIncomingPaymentLiquidity, - WithdrawIncomingPaymentLiquidityVariables + CreateIncomingPaymentWithdrawal, + CreateIncomingPaymentWithdrawalVariables >({ mutation: gql` - mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { success message } @@ -211,5 +211,5 @@ export const withdrawIncomingPaymentLiquidity = async ( } }) - return response.data?.withdrawIncomingPaymentLiquidity + return response.data?.createIncomingPaymentWithdrawal } diff --git a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx index 92deb8e193..69f941669e 100644 --- a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx @@ -2,7 +2,7 @@ import { type ActionFunctionArgs } from '@remix-run/node' import { useNavigate, useOutletContext } from '@remix-run/react' import { v4 } from 'uuid' import { LiquidityConfirmDialog } from '~/components/LiquidityConfirmDialog' -import { withdrawIncomingPaymentLiquidity } from '~/lib/api/payments.server' +import { createIncomingPaymentWithdrawal } from '~/lib/api/payments.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' export default function IncomingPaymentWithdrawLiquidity() { @@ -35,7 +35,7 @@ export async function action({ request, params }: ActionFunctionArgs) { }) } - const response = await withdrawIncomingPaymentLiquidity({ + const response = await createIncomingPaymentWithdrawal({ incomingPaymentId, idempotencyKey: v4() }) diff --git a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx index 4f4667dc43..cc5eb4937c 100644 --- a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx @@ -2,7 +2,7 @@ import { type ActionFunctionArgs } from '@remix-run/node' import { useNavigate, useOutletContext } from '@remix-run/react' import { v4 } from 'uuid' import { LiquidityConfirmDialog } from '~/components/LiquidityConfirmDialog' -import { withdrawOutgoingPaymentLiquidity } from '~/lib/api/payments.server' +import { createOutgoingPaymentWithdrawal } from '~/lib/api/payments.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import type { LiquidityActionOutletContext } from './payments.outgoing.$outgoingPaymentId' @@ -37,7 +37,7 @@ export async function action({ request, params }: ActionFunctionArgs) { }) } - const response = await withdrawOutgoingPaymentLiquidity({ + const response = await createOutgoingPaymentWithdrawal({ outgoingPaymentId, idempotencyKey: v4() }) diff --git a/packages/mock-account-service-lib/src/generated/graphql.ts b/packages/mock-account-service-lib/src/generated/graphql.ts index a36fd76256..531d7296ac 100644 --- a/packages/mock-account-service-lib/src/generated/graphql.ts +++ b/packages/mock-account-service-lib/src/generated/graphql.ts @@ -138,6 +138,13 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -174,6 +181,13 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -544,10 +558,14 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -593,13 +611,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -618,6 +632,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -628,6 +647,11 @@ export type MutationCreateOutgoingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -732,16 +756,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1346,20 +1360,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1449,9 +1449,11 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1548,8 +1550,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1565,9 +1565,11 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1655,8 +1657,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1854,8 +1854,10 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1877,8 +1879,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { diff --git a/test/integration/lib/generated/graphql.ts b/test/integration/lib/generated/graphql.ts index a36fd76256..531d7296ac 100644 --- a/test/integration/lib/generated/graphql.ts +++ b/test/integration/lib/generated/graphql.ts @@ -138,6 +138,13 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -174,6 +181,13 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -544,10 +558,14 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -593,13 +611,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -618,6 +632,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -628,6 +647,11 @@ export type MutationCreateOutgoingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -732,16 +756,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1346,20 +1360,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1449,9 +1449,11 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1548,8 +1550,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1565,9 +1565,11 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1655,8 +1657,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1854,8 +1854,10 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1877,8 +1879,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { From c7015877e5005eff5990d024a8463fdab1e1cecd Mon Sep 17 00:00:00 2001 From: koekiebox Date: Tue, 23 Apr 2024 11:13:15 +0200 Subject: [PATCH 02/21] feat(2662): 2phase incoming and outgoing payments test cases, bruno and mermaid updates --- .../Withdraw Incoming Payment Liquidity.bru | 4 +- .../Withdraw Outgoing Payment Liquidity.bru | 4 +- .../app/lib/webhooks.server.ts | 8 +-- .../src/graphql/resolvers/liquidity.test.ts | 68 +++++++++---------- .../docs/concepts/accounting/liquidity.md | 12 ++-- .../docs/integration/event-handlers.mdx | 8 +-- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru index 173388da95..f3b43ede06 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru @@ -11,8 +11,8 @@ post { } body:graphql { - mutation WithdrawIncomingPaymentLiquidity($input: WithdrawIncomingPaymentLiquidityInput!) { - withdrawIncomingPaymentLiquidity(input: $input) { + mutation CreateIncomingPaymentWithdrawal($input: CreateIncomingPaymentWithdrawalInput!) { + createIncomingPaymentWithdrawal(input: $input) { code error message diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru index e674deb33b..a237a36af0 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru @@ -11,8 +11,8 @@ post { } body:graphql { - mutation WithdrawOutgoingPaymentLiquidity($input: WithdrawOutgoingPaymentLiquidityInput!) { - withdrawOutgoingPaymentLiquidity(input: $input) { + mutation CreateOutgoingPaymentWithdrawal($input: CreateOutgoingPaymentWithdrawalInput!) { + createOutgoingPaymentWithdrawal(input: $input) { code error message diff --git a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts index b8cb327a65..7e97a205f3 100644 --- a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts +++ b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts @@ -128,10 +128,10 @@ export async function handleIncomingPaymentCompletedExpired(wh: Webhook) { await apolloClient .mutate({ mutation: gql` - mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { code success message @@ -148,7 +148,7 @@ export async function handleIncomingPaymentCompletedExpired(wh: Webhook) { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawIncomingPaymentLiquidity + return query.data.createIncomingPaymentWithdrawal } else { throw new Error('Data was empty') } diff --git a/packages/backend/src/graphql/resolvers/liquidity.test.ts b/packages/backend/src/graphql/resolvers/liquidity.test.ts index 132929524f..ad31b503a0 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.test.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.test.ts @@ -2007,7 +2007,7 @@ describe('Liquidity Resolvers', (): void => { ).resolves.toEqual(BigInt(0)) }) - describe('withdrawIncomingPaymentLiquidity', (): void => { + describe('createIncomingPaymentWithdrawal', (): void => { const amount = BigInt(10) beforeEach(async (): Promise => { @@ -2046,10 +2046,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { code success message @@ -2066,7 +2066,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawIncomingPaymentLiquidity + return query.data.createIncomingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2097,10 +2097,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { code success message @@ -2117,7 +2117,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawIncomingPaymentLiquidity + return query.data.createIncomingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2133,10 +2133,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { code success message @@ -2153,7 +2153,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawIncomingPaymentLiquidity + return query.data.createIncomingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2188,10 +2188,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { code success message @@ -2208,7 +2208,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawIncomingPaymentLiquidity + return query.data.createIncomingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2222,7 +2222,7 @@ describe('Liquidity Resolvers', (): void => { }) }) - describe('withdrawOutgoingPaymentLiquidity', (): void => { + describe('createOutgoingPaymentWithdrawal', (): void => { const amount = BigInt(10) beforeEach(async (): Promise => { @@ -2261,10 +2261,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation WithdrawOutgoingPaymentLiquidity( - $input: WithdrawOutgoingPaymentLiquidityInput! + mutation CreateOutgoingPaymentWithdrawal( + $input: CreateOutgoingPaymentWithdrawalInput! ) { - withdrawOutgoingPaymentLiquidity(input: $input) { + createOutgoingPaymentWithdrawal(input: $input) { code success message @@ -2281,7 +2281,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawOutgoingPaymentLiquidity + return query.data.createOutgoingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2301,10 +2301,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation WithdrawOutgoingPaymentLiquidity( - $input: WithdrawOutgoingPaymentLiquidityInput! + mutation CreateOutgoingPaymentWithdrawal( + $input: CreateOutgoingPaymentWithdrawalInput! ) { - withdrawOutgoingPaymentLiquidity(input: $input) { + createOutgoingPaymentWithdrawal(input: $input) { code success message @@ -2321,7 +2321,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawOutgoingPaymentLiquidity + return query.data.createOutgoingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2343,10 +2343,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation withdrawOutgoingPaymentLiquidity( - $input: WithdrawOutgoingPaymentLiquidityInput! + mutation CreateIncomingPaymentWithdrawal( + $input: CreateOutgoingPaymentWithdrawalInput! ) { - withdrawOutgoingPaymentLiquidity(input: $input) { + createOutgoingPaymentWithdrawal(input: $input) { code success message @@ -2363,7 +2363,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawOutgoingPaymentLiquidity + return query.data.createOutgoingPaymentWithdrawal } else { throw new Error('Data was empty') } @@ -2396,10 +2396,10 @@ describe('Liquidity Resolvers', (): void => { const response = await appContainer.apolloClient .mutate({ mutation: gql` - mutation withdrawOutgoingPaymentLiquidity( - $input: WithdrawOutgoingPaymentLiquidityInput! + mutation CreateOutgoingPaymentWithdrawal( + $input: CreateOutgoingPaymentWithdrawalInput! ) { - withdrawOutgoingPaymentLiquidity(input: $input) { + createOutgoingPaymentWithdrawal(input: $input) { code success message @@ -2416,7 +2416,7 @@ describe('Liquidity Resolvers', (): void => { }) .then((query): LiquidityMutationResponse => { if (query.data) { - return query.data.withdrawOutgoingPaymentLiquidity + return query.data.createOutgoingPaymentWithdrawal } else { throw new Error('Data was empty') } diff --git a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md index 8471b69480..4b676cea10 100644 --- a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md +++ b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md @@ -182,10 +182,10 @@ where and ```graphql -mutation WithdrawOutgoingPaymentLiquidity( - $input: WithdrawOutgoingPaymentLiquidityInput! +mutation CreateOutgoingPaymentWithdrawal( + $input: CreateOutgoingPaymentWithdrawalInput! ) { - withdrawOutgoingPaymentLiquidity(input: $input) { + createOutgoingPaymentWithdrawal(input: $input) { code error message @@ -210,10 +210,10 @@ where Withdraw incoming payment liquidity via the Admin API only: ```graphql -mutation WithdrawIncomingPaymentLiquidity( - $input: WithdrawIncomingPaymentLiquidityInput! +mutation CreateIncomingPaymentWithdrawal( + $input: CreateIncomingPaymentWithdrawalInput! ) { - withdrawIncomingPaymentLiquidity(input: $input) { + createIncomingPaymentWithdrawal(input: $input) { code error message diff --git a/packages/documentation/src/content/docs/integration/event-handlers.mdx b/packages/documentation/src/content/docs/integration/event-handlers.mdx index d1ae35a822..996dd90c47 100644 --- a/packages/documentation/src/content/docs/integration/event-handlers.mdx +++ b/packages/documentation/src/content/docs/integration/event-handlers.mdx @@ -33,7 +33,7 @@ Example: An incoming payment was completed and received $10. participant R as Rafiki R->>ASE: webhook event: incoming payment completed,
receivedAmount: $10 - ASE->>R: admin API call: WithdrawIncomingPaymentLiquidity + ASE->>R: admin API call: CreateIncomingPaymentWithdrawal ASE->>ASE: credit receiver's account with $10 `} @@ -51,7 +51,7 @@ Example: An incoming payment has expired and received $2.55. participant R as Rafiki R->>ASE: webhook event: incoming payment expired,
receivedAmount: $2.55 - ASE->>R: admin API call: WithdrawIncomingPaymentLiquidity + ASE->>R: admin API call: CreateIncomingPaymentWithdrawal ASE->>ASE: credit receiver's account with $2.55 `} @@ -87,7 +87,7 @@ Example: An outgoing payment for $12 has been completed. $11.50 were sent. The A participant R as Rafiki R->>ASE: webhook event: outgoing completed,
debitAmount: $12, sentAmount:$11.50 - ASE->>R: admin API call: WithdrawOutgoingPaymentLiquidity + ASE->>R: admin API call: CreateOutgoingPaymentWithdrawal ASE->>ASE: remove the hold and deduct $12 from the sender's account,
credit ASE's account with $0.50 `} @@ -105,7 +105,7 @@ Example: An outgoing payment for $12 has failed. $8 were sent. participant R as Rafiki R->>ASE: webhook event: outgoing failed,
debitAmount: $12, sentAmount:$8 - ASE->>R: admin API call: WithdrawOutgoingPaymentLiquidity + ASE->>R: admin API call: CreateOutgoingPaymentWithdrawal ASE->>ASE: remove the hold and deduct $8 from the sender's account `} From a36cf27715ad1ff2d4944e570a2f7e2fa3711704 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Mon, 29 Apr 2024 10:45:09 +0200 Subject: [PATCH 03/21] feat(2662): add command to remove images after tear down. --- localenv/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/localenv/README.md b/localenv/README.md index 49a70cca9c..693c2f4a64 100644 --- a/localenv/README.md +++ b/localenv/README.md @@ -97,6 +97,9 @@ pnpm localenv:compose up // tear down and remove volumes pnpm localenv:compose down --volumes + +// tear down, delete database volumes and remove images +pnpm localenv:compose down --volumes --rmi all ``` If you want to use Postgres as the accounting database instead of TigerBeetle, you can use the `psql` variant of the `localenv:compose` commands: @@ -147,6 +150,9 @@ pnpm localenv:compose down // tear down and delete database volumes pnpm localenv:compose down --volumes + +// tear down, delete database volumes and remove images +pnpm localenv:compose down --volumes --rmi all ``` ### Commands From 40ca7686fb3f7a7201458744b54ebf04bd0cc0c1 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Wed, 1 May 2024 12:47:44 +0200 Subject: [PATCH 04/21] feat(2662): introduce the timeout as optional argument for withdraws. --- localenv/README.md | 2 + .../generated/graphql.ts | 80 ++-- .../src/graphql/generated/graphql.schema.json | 370 +++++++++++------- .../backend/src/graphql/generated/graphql.ts | 80 ++-- .../src/graphql/resolvers/liquidity.ts | 40 +- packages/backend/src/graphql/schema.graphql | 10 + packages/documentation/README.md | 4 +- .../docs/concepts/accounting/tigerbeetle.md | 2 +- packages/frontend/app/generated/graphql.ts | 92 +++-- .../src/generated/graphql.ts | 80 ++-- test/integration/lib/generated/graphql.ts | 80 ++-- 11 files changed, 491 insertions(+), 349 deletions(-) diff --git a/localenv/README.md b/localenv/README.md index 693c2f4a64..78c4119b3f 100644 --- a/localenv/README.md +++ b/localenv/README.md @@ -117,6 +117,8 @@ The secondary Happy Life Bank docker compose file (`./happy-life-bank/docker-com data stores created by the primary Rafiki instance so it can't be run by itself. The `pnpm localenv:compose up` command starts both the primary instance and the secondary. +See the `frontend` [README](../packages/frontend/README.md#ory-kratos) for more information regarding the Ory Kratos identity and user management system required for Admin UI. + #### Autopeering If you want to start the local env and peer it automatically to rafiki.money, you can run the following commands: diff --git a/localenv/mock-account-servicing-entity/generated/graphql.ts b/localenv/mock-account-servicing-entity/generated/graphql.ts index f97c7554bd..d2b24274b3 100644 --- a/localenv/mock-account-servicing-entity/generated/graphql.ts +++ b/localenv/mock-account-servicing-entity/generated/graphql.ts @@ -123,6 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -138,6 +140,15 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -187,6 +198,15 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -215,6 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -299,6 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; @@ -557,12 +581,16 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; /** Create an Open Payments Outgoing Payment from an incoming payment */ createOutgoingPaymentFromIncomingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -608,13 +636,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -633,6 +657,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -648,6 +677,11 @@ export type MutationCreateOutgoingPaymentFromIncomingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -752,16 +786,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1388,20 +1412,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1491,10 +1501,12 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentFromIncomingPaymentInput: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1593,8 +1605,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1610,10 +1620,12 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentFromIncomingPaymentInput: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1703,8 +1715,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1902,9 +1912,11 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; createOutgoingPaymentFromIncomingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1926,8 +1938,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { diff --git a/packages/backend/src/graphql/generated/graphql.schema.json b/packages/backend/src/graphql/generated/graphql.schema.json index 8f8d1ad33a..a569c9574b 100644 --- a/packages/backend/src/graphql/generated/graphql.schema.json +++ b/packages/backend/src/graphql/generated/graphql.schema.json @@ -785,6 +785,22 @@ "defaultValue": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "timeout", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "UInt64", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "interfaces": null, @@ -866,6 +882,65 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "CreateIncomingPaymentWithdrawalInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "idempotencyKey", + "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "incomingPaymentId", + "description": "The id of the incoming payment to withdraw from.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "timeout", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "UInt64", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "CreateOrUpdatePeerByUrlInput", @@ -1196,6 +1271,65 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "CreateOutgoingPaymentWithdrawalInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "idempotencyKey", + "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "outgoingPaymentId", + "description": "The id of the outgoing payment to withdraw from.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "timeout", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "UInt64", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "INPUT_OBJECT", "name": "CreatePeerInput", @@ -1384,6 +1518,22 @@ "defaultValue": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "timeout", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "UInt64", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "interfaces": null, @@ -2002,6 +2152,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "timeout", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "UInt64", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "walletAddressId", "description": "The id of the Open Payments wallet address to create the withdrawal for.", @@ -3825,6 +3991,35 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "createIncomingPaymentWithdrawal", + "description": "Withdraw incoming payment liquidity", + "args": [ + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "CreateIncomingPaymentWithdrawalInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "LiquidityMutationResponse", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createOrUpdatePeerByUrl", "description": "Create a peer using a URL", @@ -3924,6 +4119,35 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "createOutgoingPaymentWithdrawal", + "description": "Withdraw outgoing payment liquidity", + "args": [ + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "CreateOutgoingPaymentWithdrawalInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "LiquidityMutationResponse", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createPeer", "description": "Create a peer", @@ -4571,65 +4795,7 @@ "ofType": null }, "isDeprecated": true, - "deprecationReason": "Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal`" - }, - { - "name": "withdrawIncomingPaymentLiquidity", - "description": "Withdraw incoming payment liquidity", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "WithdrawIncomingPaymentLiquidityInput", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LiquidityMutationResponse", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "withdrawOutgoingPaymentLiquidity", - "description": "Withdraw outgoing payment liquidity", - "args": [ - { - "name": "input", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "WithdrawOutgoingPaymentLiquidityInput", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "LiquidityMutationResponse", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null + "deprecationReason": "Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal`" } ], "inputFields": null, @@ -8972,92 +9138,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "INPUT_OBJECT", - "name": "WithdrawIncomingPaymentLiquidityInput", - "description": null, - "fields": null, - "inputFields": [ - { - "name": "idempotencyKey", - "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "incomingPaymentId", - "description": "The id of the incoming payment to withdraw from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "WithdrawOutgoingPaymentLiquidityInput", - "description": null, - "fields": null, - "inputFields": [ - { - "name": "idempotencyKey", - "description": "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "outgoingPaymentId", - "description": "The id of the outgoing payment to withdraw from.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "__Directive", diff --git a/packages/backend/src/graphql/generated/graphql.ts b/packages/backend/src/graphql/generated/graphql.ts index f97c7554bd..d2b24274b3 100644 --- a/packages/backend/src/graphql/generated/graphql.ts +++ b/packages/backend/src/graphql/generated/graphql.ts @@ -123,6 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -138,6 +140,15 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -187,6 +198,15 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -215,6 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -299,6 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; @@ -557,12 +581,16 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; /** Create an Open Payments Outgoing Payment from an incoming payment */ createOutgoingPaymentFromIncomingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -608,13 +636,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -633,6 +657,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -648,6 +677,11 @@ export type MutationCreateOutgoingPaymentFromIncomingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -752,16 +786,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1388,20 +1412,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1491,10 +1501,12 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentFromIncomingPaymentInput: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1593,8 +1605,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1610,10 +1620,12 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentFromIncomingPaymentInput: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1703,8 +1715,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1902,9 +1912,11 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; createOutgoingPaymentFromIncomingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1926,8 +1938,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { diff --git a/packages/backend/src/graphql/resolvers/liquidity.ts b/packages/backend/src/graphql/resolvers/liquidity.ts index d6c67ec5dd..9e8885c1ce 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.ts @@ -170,20 +170,21 @@ export const createPeerLiquidityWithdrawal: MutationResolvers['cr ctx ): Promise => { try { - if (args.input.amount === BigInt(0)) { + const { amount, id, timeout, peerId } = args.input + if (amount === BigInt(0)) { return responses[LiquidityError.AmountZero] } const peerService = await ctx.container.use('peerService') - const peer = await peerService.get(args.input.peerId) + const peer = await peerService.get(peerId) if (!peer) { return responses[LiquidityError.UnknownPeer] } const accountingService = await ctx.container.use('accountingService') const error = await accountingService.createWithdrawal({ - id: args.input.id, + id, account: peer, - amount: args.input.amount, - timeout: 60 + amount, + timeout: Number(timeout) }) if (error) { return errorToResponse(error) @@ -216,20 +217,21 @@ export const createAssetLiquidityWithdrawal: MutationResolvers['c ctx ): Promise => { try { - if (args.input.amount === BigInt(0)) { + const { amount, id, timeout, assetId } = args.input + if (amount === 0n) { return responses[LiquidityError.AmountZero] } const assetService = await ctx.container.use('assetService') - const asset = await assetService.get(args.input.assetId) + const asset = await assetService.get(assetId) if (!asset) { return responses[LiquidityError.UnknownAsset] } const accountingService = await ctx.container.use('accountingService') const error = await accountingService.createWithdrawal({ - id: args.input.id, + id, account: asset, - amount: args.input.amount, - timeout: 60 + amount, + timeout: Number(timeout) }) if (error) { return errorToResponse(error) @@ -262,23 +264,21 @@ export const createWalletAddressWithdrawal: MutationResolvers['cr ctx ): Promise => { try { + const { id, walletAddressId, timeout } = args.input const walletAddressService = await ctx.container.use( 'walletAddressService' ) - const walletAddress = await walletAddressService.get( - args.input.walletAddressId - ) + const walletAddress = await walletAddressService.get(walletAddressId) if (!walletAddress) { return responses[ LiquidityError.UnknownWalletAddress ] as unknown as WalletAddressWithdrawalMutationResponse } - const id = args.input.id const accountingService = await ctx.container.use('accountingService') const amount = await accountingService.getBalance(walletAddress.id) if (amount === undefined) throw new Error('missing incoming payment wallet address') - if (amount === BigInt(0)) { + else if (amount === 0n) { return responses[ LiquidityError.AmountZero ] as unknown as WalletAddressWithdrawalMutationResponse @@ -287,7 +287,7 @@ export const createWalletAddressWithdrawal: MutationResolvers['cr id, account: walletAddress, amount, - timeout: 60 + timeout: Number(timeout) }) if (error) { @@ -528,7 +528,7 @@ export const createIncomingPaymentWithdrawal: MutationResolvers[' args, ctx ): Promise => { - const { incomingPaymentId } = args.input + const { incomingPaymentId, timeout } = args.input try { const incomingPaymentService = await ctx.container.use( 'incomingPaymentService' @@ -556,7 +556,7 @@ export const createIncomingPaymentWithdrawal: MutationResolvers[' asset: incomingPayment.asset }, amount: incomingPayment.receivedAmount.value, - timeout: 60 + timeout: Number(timeout) }) if (error) { @@ -589,7 +589,7 @@ export const createOutgoingPaymentWithdrawal: MutationResolvers[' args, ctx ): Promise => { - const { outgoingPaymentId } = args.input + const { outgoingPaymentId, timeout } = args.input try { const outgoingPaymentService = await ctx.container.use( 'outgoingPaymentService' @@ -622,7 +622,7 @@ export const createOutgoingPaymentWithdrawal: MutationResolvers[' asset: outgoingPayment.asset }, amount: balance, - timeout: 60 + timeout: Number(timeout) }) if (error) { diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index cb1991a1c1..664f7d1994 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -388,6 +388,8 @@ input CreatePeerLiquidityWithdrawalInput { id: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." + timeout: UInt64! } input CreateAssetLiquidityWithdrawalInput { @@ -399,6 +401,8 @@ input CreateAssetLiquidityWithdrawalInput { id: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." + timeout: UInt64! } input PostLiquidityWithdrawalInput { @@ -427,6 +431,8 @@ input CreateIncomingPaymentWithdrawalInput { incomingPaymentId: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." + timeout: UInt64! } input CreateOutgoingPaymentWithdrawalInput { @@ -434,6 +440,8 @@ input CreateOutgoingPaymentWithdrawalInput { outgoingPaymentId: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." + timeout: UInt64! } input DepositEventLiquidityInput { @@ -457,6 +465,8 @@ input CreateWalletAddressWithdrawalInput { id: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." + timeout: UInt64! } input JwkInput { diff --git a/packages/documentation/README.md b/packages/documentation/README.md index 51292c04f5..824def64ee 100644 --- a/packages/documentation/README.md +++ b/packages/documentation/README.md @@ -14,7 +14,7 @@ This website is built with [Starlight](https://starlight.astro.build/), a docume $ pnpm i ``` -- Run the dev server from the /packages/documentation folder: +- Run the dev server from the `/packages/documentation` folder: ```sh $ pnpm start @@ -22,7 +22,7 @@ $ pnpm start This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. -- Build the site, again, this must be run from the /packages/documentation folder: +- Build the site, again, this must be run from the `/packages/documentation` folder: ```sh $ pnpm build:docs diff --git a/packages/documentation/src/content/docs/concepts/accounting/tigerbeetle.md b/packages/documentation/src/content/docs/concepts/accounting/tigerbeetle.md index 4b7c97a616..84ce2fde05 100644 --- a/packages/documentation/src/content/docs/concepts/accounting/tigerbeetle.md +++ b/packages/documentation/src/content/docs/concepts/accounting/tigerbeetle.md @@ -15,7 +15,7 @@ Rafiki uses a combination of liquidity and settlement accounts to perform double pnpm --filter backend up tigerbeetle-node --latest # specific version -pnpm --filter backend up tigerbeetle-node@0.12.24 +pnpm --filter backend up tigerbeetle-node@0.15.3 ``` ### Production Environment - Helm charts diff --git a/packages/frontend/app/generated/graphql.ts b/packages/frontend/app/generated/graphql.ts index cdc9e8fa2a..7f8f9d5834 100644 --- a/packages/frontend/app/generated/graphql.ts +++ b/packages/frontend/app/generated/graphql.ts @@ -123,6 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -138,6 +140,15 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -187,6 +198,15 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -215,6 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -299,6 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; @@ -557,12 +581,16 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; /** Create an Open Payments Outgoing Payment from an incoming payment */ createOutgoingPaymentFromIncomingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -608,13 +636,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -633,6 +657,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -648,6 +677,11 @@ export type MutationCreateOutgoingPaymentFromIncomingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -752,16 +786,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1388,20 +1412,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1491,10 +1501,12 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentFromIncomingPaymentInput: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1593,8 +1605,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1610,10 +1620,12 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentFromIncomingPaymentInput: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1703,8 +1715,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1902,9 +1912,11 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; createOutgoingPaymentFromIncomingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1926,8 +1938,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { @@ -2396,19 +2406,19 @@ export type DepositOutgoingPaymentLiquidityVariables = Exact<{ export type DepositOutgoingPaymentLiquidity = { __typename?: 'Mutation', depositOutgoingPaymentLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; -export type WithdrawOutgoingPaymentLiquidityVariables = Exact<{ - input: WithdrawOutgoingPaymentLiquidityInput; +export type CreateOutgoingPaymentWithdrawalVariables = Exact<{ + input: CreateOutgoingPaymentWithdrawalInput; }>; -export type WithdrawOutgoingPaymentLiquidity = { __typename?: 'Mutation', withdrawOutgoingPaymentLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; +export type CreateOutgoingPaymentWithdrawal = { __typename?: 'Mutation', createOutgoingPaymentWithdrawal?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; -export type WithdrawIncomingPaymentLiquidityVariables = Exact<{ - input: WithdrawIncomingPaymentLiquidityInput; +export type CreateIncomingPaymentWithdrawalVariables = Exact<{ + input: CreateIncomingPaymentWithdrawalInput; }>; -export type WithdrawIncomingPaymentLiquidity = { __typename?: 'Mutation', withdrawIncomingPaymentLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; +export type CreateIncomingPaymentWithdrawal = { __typename?: 'Mutation', createIncomingPaymentWithdrawal?: { __typename?: 'LiquidityMutationResponse', success: boolean, message: string } | null }; export type GetPeerQueryVariables = Exact<{ id: Scalars['String']['input']; diff --git a/packages/mock-account-service-lib/src/generated/graphql.ts b/packages/mock-account-service-lib/src/generated/graphql.ts index f97c7554bd..d2b24274b3 100644 --- a/packages/mock-account-service-lib/src/generated/graphql.ts +++ b/packages/mock-account-service-lib/src/generated/graphql.ts @@ -123,6 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -138,6 +140,15 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -187,6 +198,15 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -215,6 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -299,6 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; @@ -557,12 +581,16 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; /** Create an Open Payments Outgoing Payment from an incoming payment */ createOutgoingPaymentFromIncomingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -608,13 +636,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -633,6 +657,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -648,6 +677,11 @@ export type MutationCreateOutgoingPaymentFromIncomingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -752,16 +786,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1388,20 +1412,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1491,10 +1501,12 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentFromIncomingPaymentInput: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1593,8 +1605,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1610,10 +1620,12 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentFromIncomingPaymentInput: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1703,8 +1715,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1902,9 +1912,11 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; createOutgoingPaymentFromIncomingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1926,8 +1938,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { diff --git a/test/integration/lib/generated/graphql.ts b/test/integration/lib/generated/graphql.ts index f97c7554bd..d2b24274b3 100644 --- a/test/integration/lib/generated/graphql.ts +++ b/test/integration/lib/generated/graphql.ts @@ -123,6 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -138,6 +140,15 @@ export type CreateIncomingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateIncomingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the incoming payment to withdraw from. */ + incomingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreateOrUpdatePeerByUrlInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -187,6 +198,15 @@ export type CreateOutgoingPaymentInput = { walletAddressId: Scalars['String']['input']; }; +export type CreateOutgoingPaymentWithdrawalInput = { + /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ + idempotencyKey: Scalars['String']['input']; + /** The id of the outgoing payment to withdraw from. */ + outgoingPaymentId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; +}; + export type CreatePeerInput = { /** Asset id of peering relationship */ assetId: Scalars['String']['input']; @@ -215,6 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -299,6 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ + timeout: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; @@ -557,12 +581,16 @@ export type Mutation = { createAssetLiquidityWithdrawal?: Maybe; /** Create an internal Open Payments Incoming Payment. The receiver has a wallet address on this Rafiki instance. */ createIncomingPayment: IncomingPaymentResponse; + /** Withdraw incoming payment liquidity */ + createIncomingPaymentWithdrawal?: Maybe; /** Create a peer using a URL */ createOrUpdatePeerByUrl: CreateOrUpdatePeerByUrlMutationResponse; /** Create an Open Payments Outgoing Payment */ createOutgoingPayment: OutgoingPaymentResponse; /** Create an Open Payments Outgoing Payment from an incoming payment */ createOutgoingPaymentFromIncomingPayment: OutgoingPaymentResponse; + /** Withdraw outgoing payment liquidity */ + createOutgoingPaymentWithdrawal?: Maybe; /** Create a peer */ createPeer: CreatePeerMutationResponse; /** Withdraw peer liquidity */ @@ -608,13 +636,9 @@ export type Mutation = { voidLiquidityWithdrawal?: Maybe; /** * Withdraw webhook event liquidity - * @deprecated Use `withdrawOutgoingPaymentLiquidity, withdrawIncomingPaymentLiquidity, or createWalletAddressWithdrawal` + * @deprecated Use `createOutgoingPaymentWithdrawal, createIncomingPaymentWithdrawal, or createWalletAddressWithdrawal` */ withdrawEventLiquidity?: Maybe; - /** Withdraw incoming payment liquidity */ - withdrawIncomingPaymentLiquidity?: Maybe; - /** Withdraw outgoing payment liquidity */ - withdrawOutgoingPaymentLiquidity?: Maybe; }; @@ -633,6 +657,11 @@ export type MutationCreateIncomingPaymentArgs = { }; +export type MutationCreateIncomingPaymentWithdrawalArgs = { + input: CreateIncomingPaymentWithdrawalInput; +}; + + export type MutationCreateOrUpdatePeerByUrlArgs = { input: CreateOrUpdatePeerByUrlInput; }; @@ -648,6 +677,11 @@ export type MutationCreateOutgoingPaymentFromIncomingPaymentArgs = { }; +export type MutationCreateOutgoingPaymentWithdrawalArgs = { + input: CreateOutgoingPaymentWithdrawalInput; +}; + + export type MutationCreatePeerArgs = { input: CreatePeerInput; }; @@ -752,16 +786,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; - -export type MutationWithdrawIncomingPaymentLiquidityArgs = { - input: WithdrawIncomingPaymentLiquidityInput; -}; - - -export type MutationWithdrawOutgoingPaymentLiquidityArgs = { - input: WithdrawOutgoingPaymentLiquidityInput; -}; - export type MutationResponse = { code: Scalars['String']['output']; message: Scalars['String']['output']; @@ -1388,20 +1412,6 @@ export type WithdrawEventLiquidityInput = { idempotencyKey: Scalars['String']['input']; }; -export type WithdrawIncomingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the incoming payment to withdraw from. */ - incomingPaymentId: Scalars['String']['input']; -}; - -export type WithdrawOutgoingPaymentLiquidityInput = { - /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ - idempotencyKey: Scalars['String']['input']; - /** The id of the outgoing payment to withdraw from. */ - outgoingPaymentId: Scalars['String']['input']; -}; - export type ResolverTypeWrapper = Promise | T; @@ -1491,10 +1501,12 @@ export type ResolversTypes = { CreateAssetInput: ResolverTypeWrapper>; CreateAssetLiquidityWithdrawalInput: ResolverTypeWrapper>; CreateIncomingPaymentInput: ResolverTypeWrapper>; + CreateIncomingPaymentWithdrawalInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlInput: ResolverTypeWrapper>; CreateOrUpdatePeerByUrlMutationResponse: ResolverTypeWrapper>; CreateOutgoingPaymentFromIncomingPaymentInput: ResolverTypeWrapper>; CreateOutgoingPaymentInput: ResolverTypeWrapper>; + CreateOutgoingPaymentWithdrawalInput: ResolverTypeWrapper>; CreatePeerInput: ResolverTypeWrapper>; CreatePeerLiquidityWithdrawalInput: ResolverTypeWrapper>; CreatePeerMutationResponse: ResolverTypeWrapper>; @@ -1593,8 +1605,6 @@ export type ResolversTypes = { WebhookEventsConnection: ResolverTypeWrapper>; WebhookEventsEdge: ResolverTypeWrapper>; WithdrawEventLiquidityInput: ResolverTypeWrapper>; - WithdrawIncomingPaymentLiquidityInput: ResolverTypeWrapper>; - WithdrawOutgoingPaymentLiquidityInput: ResolverTypeWrapper>; }; /** Mapping between all available schema types and the resolvers parents */ @@ -1610,10 +1620,12 @@ export type ResolversParentTypes = { CreateAssetInput: Partial; CreateAssetLiquidityWithdrawalInput: Partial; CreateIncomingPaymentInput: Partial; + CreateIncomingPaymentWithdrawalInput: Partial; CreateOrUpdatePeerByUrlInput: Partial; CreateOrUpdatePeerByUrlMutationResponse: Partial; CreateOutgoingPaymentFromIncomingPaymentInput: Partial; CreateOutgoingPaymentInput: Partial; + CreateOutgoingPaymentWithdrawalInput: Partial; CreatePeerInput: Partial; CreatePeerLiquidityWithdrawalInput: Partial; CreatePeerMutationResponse: Partial; @@ -1703,8 +1715,6 @@ export type ResolversParentTypes = { WebhookEventsConnection: Partial; WebhookEventsEdge: Partial; WithdrawEventLiquidityInput: Partial; - WithdrawIncomingPaymentLiquidityInput: Partial; - WithdrawOutgoingPaymentLiquidityInput: Partial; }; export type AmountResolvers = { @@ -1902,9 +1912,11 @@ export type MutationResolvers>; createAssetLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createIncomingPayment?: Resolver>; + createIncomingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createOrUpdatePeerByUrl?: Resolver>; createOutgoingPayment?: Resolver>; createOutgoingPaymentFromIncomingPayment?: Resolver>; + createOutgoingPaymentWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createPeer?: Resolver>; createPeerLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; createQuote?: Resolver>; @@ -1926,8 +1938,6 @@ export type MutationResolvers>; voidLiquidityWithdrawal?: Resolver, ParentType, ContextType, RequireFields>; withdrawEventLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawIncomingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; - withdrawOutgoingPaymentLiquidity?: Resolver, ParentType, ContextType, RequireFields>; }; export type MutationResponseResolvers = { From 0fe676d8a10b43dd84681bf664d44373cb8b001d Mon Sep 17 00:00:00 2001 From: koekiebox Date: Wed, 1 May 2024 14:04:51 +0200 Subject: [PATCH 05/21] feat(2662): fix test cases. --- .../src/graphql/resolvers/liquidity.test.ts | 69 ++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/packages/backend/src/graphql/resolvers/liquidity.test.ts b/packages/backend/src/graphql/resolvers/liquidity.test.ts index ad31b503a0..3f8fb352a4 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.test.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.test.ts @@ -500,7 +500,8 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), peerId: peer.id, amount: startingBalance.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -537,7 +538,8 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), peerId: uuid(), amount: '100', - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -575,7 +577,8 @@ describe('Liquidity Resolvers', (): void => { id: 'not a uuid', peerId: peer.id, amount: startingBalance.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -621,7 +624,8 @@ describe('Liquidity Resolvers', (): void => { id, peerId: peer.id, amount: startingBalance.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -664,7 +668,8 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), peerId: peer.id, amount: amount.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -719,7 +724,8 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), assetId: asset.id, amount: startingBalance.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -756,7 +762,8 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), assetId: uuid(), amount: '100', - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -794,7 +801,8 @@ describe('Liquidity Resolvers', (): void => { id: 'not a uuid', assetId: asset.id, amount: startingBalance.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -840,7 +848,8 @@ describe('Liquidity Resolvers', (): void => { id, assetId: asset.id, amount: startingBalance.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -883,7 +892,8 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), assetId: asset.id, amount: amount.toString(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -948,7 +958,8 @@ describe('Liquidity Resolvers', (): void => { input: { id, walletAddressId: walletAddress.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -994,7 +1005,8 @@ describe('Liquidity Resolvers', (): void => { input: { id: uuid(), walletAddressId: uuid(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -1035,7 +1047,8 @@ describe('Liquidity Resolvers', (): void => { input: { id: 'not a uuid', walletAddressId: walletAddress.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -1084,7 +1097,8 @@ describe('Liquidity Resolvers', (): void => { input: { id, walletAddressId: walletAddress.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -1132,7 +1146,8 @@ describe('Liquidity Resolvers', (): void => { input: { id: uuid(), walletAddressId: walletAddress.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2060,7 +2075,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { incomingPaymentId: incomingPayment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2111,7 +2127,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { incomingPaymentId: uuid(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2147,7 +2164,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { incomingPaymentId: incomingPayment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2202,7 +2220,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { incomingPaymentId: incomingPayment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2275,7 +2294,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { outgoingPaymentId: outgoingPayment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2315,7 +2335,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { outgoingPaymentId: uuid(), - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2357,7 +2378,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { outgoingPaymentId: outgoingPayment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) @@ -2410,7 +2432,8 @@ describe('Liquidity Resolvers', (): void => { variables: { input: { outgoingPaymentId: outgoingPayment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeout } } }) From 6d784720f41d73e478104fb45838c96232b239b7 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Thu, 2 May 2024 14:47:58 +0200 Subject: [PATCH 06/21] feat(2662): fix front-end issues wgt timeout. --- .../app/routes/assets.$assetId.withdraw-liquidity.tsx | 4 +++- ...ayments.incoming.$incomingPaymentId.withdraw-liquidity.tsx | 4 +++- ...ayments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx | 4 +++- .../frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx | 4 +++- packages/frontend/app/routes/settings.tsx | 1 + .../wallet-addresses.$walletAddressId.withdraw-liquidity.tsx | 4 +++- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx index dc64314aab..c42a40b86d 100644 --- a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx @@ -7,6 +7,7 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { amountSchema } from '~/lib/validate.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' +import { timeoutTwoPhase } from './settings' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -60,7 +61,8 @@ export async function action({ request, params }: ActionFunctionArgs) { assetId, amount: result.data, id: v4(), - idempotencyKey: v4() + idempotencyKey: v4(), + timeout: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx index 8d8c2317f2..506655aea0 100644 --- a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx @@ -6,6 +6,7 @@ import { createIncomingPaymentWithdrawal } from '~/lib/api/payments.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' +import { timeoutTwoPhase } from './settings' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -45,7 +46,8 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createIncomingPaymentWithdrawal({ incomingPaymentId, - idempotencyKey: v4() + idempotencyKey: v4(), + timeout: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx index 53edcf164f..b7b1ce484f 100644 --- a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx @@ -7,6 +7,7 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import type { LiquidityActionOutletContext } from './payments.outgoing.$outgoingPaymentId' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' +import { timeoutTwoPhase } from './settings' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -47,7 +48,8 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createOutgoingPaymentWithdrawal({ outgoingPaymentId, - idempotencyKey: v4() + idempotencyKey: v4(), + timeout: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx index 02fa21f6f0..fbffb0a53a 100644 --- a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx @@ -7,6 +7,7 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { amountSchema } from '~/lib/validate.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' +import { timeoutTwoPhase } from './settings' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -60,7 +61,8 @@ export async function action({ request, params }: ActionFunctionArgs) { peerId, amount: result.data, id: v4(), - idempotencyKey: v4() + idempotencyKey: v4(), + timeout: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/settings.tsx b/packages/frontend/app/routes/settings.tsx index b97fdc8378..e800b514b2 100644 --- a/packages/frontend/app/routes/settings.tsx +++ b/packages/frontend/app/routes/settings.tsx @@ -10,6 +10,7 @@ import { PageHeader } from '~/components' import { Button, Input } from '../components/ui' import variables from '../lib/envConfig.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' +export const timeoutTwoPhase = BigInt(60) export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx index b19273baf2..c685d363ed 100644 --- a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx @@ -6,6 +6,7 @@ import { createWalletAddressWithdrawal } from '~/lib/api/wallet-address.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' +import { timeoutTwoPhase } from './settings' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -46,7 +47,8 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createWalletAddressWithdrawal({ id: v4(), walletAddressId, - idempotencyKey: v4() + idempotencyKey: v4(), + timeout: timeoutTwoPhase }) if (!response?.success) { From 4801a8c373dd441d233d2c31821650a53f21d4bf Mon Sep 17 00:00:00 2001 From: koekiebox Date: Fri, 3 May 2024 09:21:05 +0200 Subject: [PATCH 07/21] feat(2662): bruno updates. --- .../Rafiki Admin APIs/Create Wallet Address Withdrawal.bru | 3 ++- .../Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru | 3 ++- .../Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru | 3 ++- .../Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru | 3 ++- .../Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru | 3 ++- bruno/collections/Rafiki/environments/Autopeering.bru | 1 + bruno/collections/Rafiki/environments/Local Playground.bru | 1 + bruno/collections/Rafiki/environments/Remote.bru | 1 + 8 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru index 04cd906cbc..7a7da0e54c 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru @@ -40,7 +40,8 @@ body:graphql:vars { "input": { "id": "02ac56f7-ae5d-4abb-8306-17bf2327b43c", "walletAddressId": "{{walletAddressId}}", - "idempotencyKey":"{{idempotencyKey}}" + "idempotencyKey":"{{idempotencyKey}}", + "timeout": {{withdrawalTimeout}} } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru index 9d3a0ba5ba..a7be75e5bc 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru @@ -27,7 +27,8 @@ body:graphql:vars { "id": "{{transferId}}", "assetId": "{{assetId}}", "amount": "100", - "idempotencyKey":"{{idempotencyKey}}" + "idempotencyKey":"{{idempotencyKey}}", + "timeout": {{withdrawalTimeout}} } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru index 35c7a3c731..de460764fe 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru @@ -25,7 +25,8 @@ body:graphql:vars { { "input": { "incomingPaymentId": "{{incomingPaymentId}}", - "idempotencyKey":"{{idempotencyKey}}" + "idempotencyKey": "{{idempotencyKey}}", + "timeout": {{withdrawalTimeout}} } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru index d49a25d612..d79afb956b 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru @@ -25,7 +25,8 @@ body:graphql:vars { { "input": { "outgoingPaymentId": "{{outgoingPaymentId}}", - "idempotencyKey":"{{idempotencyKey}}" + "idempotencyKey": "{{idempotencyKey}}", + "timeout": {{withdrawalTimeout}} } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru index 145065ea81..d0a7cf9215 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru @@ -27,7 +27,8 @@ body:graphql:vars { "id": "{{withdrawalId}}", "peerId": "{{peerId}}", "amount": "100", - "idempotencyKey":"{{idempotencyKey}}" + "idempotencyKey":"{{idempotencyKey}}", + "timeout": {{withdrawalTimeout}} } } diff --git a/bruno/collections/Rafiki/environments/Autopeering.bru b/bruno/collections/Rafiki/environments/Autopeering.bru index a9202702b2..50a8667b2d 100644 --- a/bruno/collections/Rafiki/environments/Autopeering.bru +++ b/bruno/collections/Rafiki/environments/Autopeering.bru @@ -5,4 +5,5 @@ vars { receiverWalletAddress: https://ilp.rafiki.money/d99f0eee signatureUrl: https://kxu5d4mr4blcthphxomjlc4xk40rvdsx.lambda-url.eu-central-1.on.aws/ clientPrivateKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1DNENBUUF3QlFZREsyVndCQ0lFSUUvMmFwQXduMlJPek5WNWd1L2ltZzdpT05rOWE1Ui9yakFxWVlUWHozZzgKLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ== + withdrawalTimeout: 60 } diff --git a/bruno/collections/Rafiki/environments/Local Playground.bru b/bruno/collections/Rafiki/environments/Local Playground.bru index 54b05cc61c..5f4e25551c 100644 --- a/bruno/collections/Rafiki/environments/Local Playground.bru +++ b/bruno/collections/Rafiki/environments/Local Playground.bru @@ -14,4 +14,5 @@ vars { apiSignatureVersion: 1 apiSignatureSecret: iyIgCprjb9uL8wFckR+pLEkJWMB7FJhgkvqhTQR/964= assetId: USD + withdrawalTimeout: 60 } diff --git a/bruno/collections/Rafiki/environments/Remote.bru b/bruno/collections/Rafiki/environments/Remote.bru index 9251a66d8f..e555872f04 100644 --- a/bruno/collections/Rafiki/environments/Remote.bru +++ b/bruno/collections/Rafiki/environments/Remote.bru @@ -5,4 +5,5 @@ vars { receiverWalletAddress: https://ilp.rafiki.money/f1475476 signatureUrl: https://kxu5d4mr4blcthphxomjlc4xk40rvdsx.lambda-url.eu-central-1.on.aws/ clientPrivateKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1DNENBUUF3QlFZREsyVndCQ0lFSUUvMmFwQXduMlJPek5WNWd1L2ltZzdpT05rOWE1Ui9yakFxWVlUWHozZzgKLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ== + withdrawalTimeout: 60 } From e892eb75a1eddd20bd2c8d5d78edfb9220bf6e13 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Mon, 6 May 2024 11:57:25 +0200 Subject: [PATCH 08/21] feat(2662): doc updates. --- .../docs/concepts/accounting/liquidity.md | 85 +++++++++++++++++-- .../src/content/docs/reference/glossary.md | 7 ++ 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md index 4b676cea10..37f16ffed3 100644 --- a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md +++ b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md @@ -89,10 +89,12 @@ where "id": "b97fd85a-126e-42ef-b40d-1a50a70ffa6f", "assetId": "7b8b0f65-896d-4403-b7ba-2e24bf20eb35", "amount": "100", - "idempotencyKey": "b97fd85a-126e-42ef-b40d-1a50a70ffa6f" + "idempotencyKey": "b97fd85a-126e-42ef-b40d-1a50a70ffa6f", + "timeout": 0 } } ``` +See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. ### Peer Liquidity @@ -117,7 +119,8 @@ where "id": "a09b730d-8610-4fda-98fa-ec7acb19c775", "peerId": "73158598-2e0c-4973-895e-aebd115af260", "amount": "1000000", - "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775" + "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775", + "timeout": 0 } } ``` @@ -144,10 +147,12 @@ where "input": { "id": "421fae87-9a59-4217-9ff8-faf55ffab9c6", "peerId": "73158598-2e0c-4973-895e-aebd115af260", - "amount": "100" + "amount": "100", + "timeout": 0 } } ``` +See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. ### Payment Liquidity @@ -200,10 +205,12 @@ where { "input": { "outgoingPaymentId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", - "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775" + "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775", + "timeout": 0 } } ``` +See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. #### Incoming payment @@ -228,7 +235,75 @@ where { "input": { "incomingPaymentId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", - "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775" + "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775", + "timeout": 0 + } +} +``` +See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. + +## `PostLiquidityWithdrawal` or `VoidLiquidityWithdrawal` + +`PostLiquidityWithdrawal` and `PostLiquidityWithdrawal` are only applicable for two-phase withdrawals. + +- `PostLiquidityWithdrawal` - Post liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase commits and are committed via this mutation. +- `VoidLiquidityWithdrawal` - Void liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase commits and are rolled back via this mutation. + +When a withdrawal liquidity transaction is requested with a non-zero `timeout` value _(Zero denotes absence of timeout)_, +the transfer will be created as a two-phase transfer [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) + +If the timeout interval passes before the transfer is either posted or voided, the transfer expires and the full amount is returned to the original account. +Note that timeouts are given as intervals, specified in seconds, rather than as absolute timestamps. + +The following withdrawal payments support two-phase transfers: +- Asset Liquidity Withdrawal +- Wallet Address Withdrawal +- Peer Liquidity Withdrawal +- Incoming Payment Withdrawal +- Outgoing Payment Withdrawal + +### PostLiquidityWithdrawal +```graphql +mutation PostLiquidityWithdrawal($input: PostLiquidityWithdrawalInput!) { + postLiquidityWithdrawal(input: $input) { + code + error + message + success + } +} +``` + +where + +```json +{ + "input": { + "withdrawalId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", + "idempotencyKey":"a09b730d-8610-4fda-98fa-ec7acb19c775" + } +} +``` + +### VoidLiquidityWithdrawal +```graphql +mutation VoidLiquidityWithdrawal($input: VoidLiquidityWithdrawalInput!) { + voidLiquidityWithdrawal(input: $input) { + code + error + message + success + } +} +``` + +where + +```json +{ + "input": { + "withdrawalId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", + "idempotencyKey":"a09b730d-8610-4fda-98fa-ec7acb19c775" } } ``` diff --git a/packages/documentation/src/content/docs/reference/glossary.md b/packages/documentation/src/content/docs/reference/glossary.md index 198fb2da0c..21fc52c78b 100644 --- a/packages/documentation/src/content/docs/reference/glossary.md +++ b/packages/documentation/src/content/docs/reference/glossary.md @@ -42,6 +42,13 @@ STREAM is a multiplexed Interledger Transport Protocol that provides for sending TigerBeetle is a distributed financial accounting database designed for mission critical safety and performance. For more information, see the [official website](https://tigerbeetle.com/). +## Two-Phase Transfers + +A two-phase transfer moves funds in stages: +- Reserve funds (`pending`) +- Resolve funds (`post`, `void`, or `expire`) +The name "two-phase transfer" is a reference to the [two-phase commit protocol for distributed transactions](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). + ## Web Monetization Web Monetization is a JavaScript browser API that allows the creation of a payment stream from the user agent to the website. For more details, see the [Web Monetization Website](https://webmonetization.org/). From 96a4f8150f66b4f94b25a232085c2b660b6d5744 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Mon, 6 May 2024 12:01:44 +0200 Subject: [PATCH 09/21] feat(2662): doc updates. --- .../docs/concepts/accounting/liquidity.md | 19 +++++++++++++------ .../src/content/docs/reference/glossary.md | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md index 37f16ffed3..f32b0f8d27 100644 --- a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md +++ b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md @@ -94,7 +94,8 @@ where } } ``` -See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. + +See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. ### Peer Liquidity @@ -152,6 +153,7 @@ where } } ``` + See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. ### Payment Liquidity @@ -210,6 +212,7 @@ where } } ``` + See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. #### Incoming payment @@ -240,22 +243,24 @@ where } } ``` + See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#postliquiditywithdrawal-or-voidliquiditywithdrawal) section. ## `PostLiquidityWithdrawal` or `VoidLiquidityWithdrawal` -`PostLiquidityWithdrawal` and `PostLiquidityWithdrawal` are only applicable for two-phase withdrawals. +`PostLiquidityWithdrawal` and `PostLiquidityWithdrawal` are only applicable for two-phase withdrawals. - `PostLiquidityWithdrawal` - Post liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase commits and are committed via this mutation. - `VoidLiquidityWithdrawal` - Void liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase commits and are rolled back via this mutation. -When a withdrawal liquidity transaction is requested with a non-zero `timeout` value _(Zero denotes absence of timeout)_, -the transfer will be created as a two-phase transfer [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) +When a withdrawal liquidity transaction is requested with a non-zero `timeout` value _(Zero denotes absence of timeout)_, +the transfer will be created as a two-phase transfer [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) If the timeout interval passes before the transfer is either posted or voided, the transfer expires and the full amount is returned to the original account. Note that timeouts are given as intervals, specified in seconds, rather than as absolute timestamps. The following withdrawal payments support two-phase transfers: + - Asset Liquidity Withdrawal - Wallet Address Withdrawal - Peer Liquidity Withdrawal @@ -263,6 +268,7 @@ The following withdrawal payments support two-phase transfers: - Outgoing Payment Withdrawal ### PostLiquidityWithdrawal + ```graphql mutation PostLiquidityWithdrawal($input: PostLiquidityWithdrawalInput!) { postLiquidityWithdrawal(input: $input) { @@ -280,12 +286,13 @@ where { "input": { "withdrawalId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", - "idempotencyKey":"a09b730d-8610-4fda-98fa-ec7acb19c775" + "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775" } } ``` ### VoidLiquidityWithdrawal + ```graphql mutation VoidLiquidityWithdrawal($input: VoidLiquidityWithdrawalInput!) { voidLiquidityWithdrawal(input: $input) { @@ -303,7 +310,7 @@ where { "input": { "withdrawalId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", - "idempotencyKey":"a09b730d-8610-4fda-98fa-ec7acb19c775" + "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775" } } ``` diff --git a/packages/documentation/src/content/docs/reference/glossary.md b/packages/documentation/src/content/docs/reference/glossary.md index 21fc52c78b..efe0cf8e46 100644 --- a/packages/documentation/src/content/docs/reference/glossary.md +++ b/packages/documentation/src/content/docs/reference/glossary.md @@ -45,9 +45,10 @@ TigerBeetle is a distributed financial accounting database designed for mission ## Two-Phase Transfers A two-phase transfer moves funds in stages: + - Reserve funds (`pending`) - Resolve funds (`post`, `void`, or `expire`) -The name "two-phase transfer" is a reference to the [two-phase commit protocol for distributed transactions](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). + The name "two-phase transfer" is a reference to the [two-phase commit protocol for distributed transactions](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). ## Web Monetization From ffb1c3aeff100dcefea1b0f4222c827fd74970eb Mon Sep 17 00:00:00 2001 From: koekiebox Date: Mon, 6 May 2024 12:24:59 +0200 Subject: [PATCH 10/21] feat(2662): liq test case updates. --- .../src/graphql/resolvers/liquidity.test.ts | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/packages/backend/src/graphql/resolvers/liquidity.test.ts b/packages/backend/src/graphql/resolvers/liquidity.test.ts index 3f8fb352a4..2408b2b358 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.test.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.test.ts @@ -50,7 +50,8 @@ describe('Liquidity Resolvers', (): void => { let appContainer: TestContainer let accountingService: AccountingService let knex: Knex - const timeout = 10 + const timeoutOnePhase = 0 + const timeoutTwoPhase = 10 beforeAll(async (): Promise => { deps = await initIocContainer(Config) @@ -501,7 +502,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -539,7 +540,7 @@ describe('Liquidity Resolvers', (): void => { peerId: uuid(), amount: '100', idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -578,7 +579,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -625,7 +626,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -669,7 +670,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: amount.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -725,7 +726,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -763,7 +764,7 @@ describe('Liquidity Resolvers', (): void => { assetId: uuid(), amount: '100', idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -802,7 +803,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -849,7 +850,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -893,7 +894,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: amount.toString(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -959,7 +960,7 @@ describe('Liquidity Resolvers', (): void => { id, walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -1006,7 +1007,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), walletAddressId: uuid(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -1048,7 +1049,7 @@ describe('Liquidity Resolvers', (): void => { id: 'not a uuid', walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -1098,7 +1099,7 @@ describe('Liquidity Resolvers', (): void => { id, walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -1122,7 +1123,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), account: walletAddress, amount, - timeout + timeout: timeoutOnePhase }) ).resolves.toBeUndefined() const response = await appContainer.apolloClient @@ -1147,7 +1148,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -1187,7 +1188,7 @@ describe('Liquidity Resolvers', (): void => { ...deposit, id: withdrawalId, amount: BigInt(10), - timeout + timeout: timeoutTwoPhase }) ).resolves.toBeUndefined() }) @@ -1400,7 +1401,7 @@ describe('Liquidity Resolvers', (): void => { ...deposit, id: withdrawalId, amount: BigInt(10), - timeout + timeout: timeoutTwoPhase }) ).resolves.toBeUndefined() }) @@ -2076,7 +2077,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2128,7 +2129,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: uuid(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2165,7 +2166,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2221,7 +2222,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2295,7 +2296,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2336,7 +2337,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: uuid(), idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2379,7 +2380,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) @@ -2433,7 +2434,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeout + timeout: timeoutOnePhase } } }) From d290417a0fb425451874aad5f2edc87d58f62ac5 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Sat, 11 May 2024 10:30:21 +0200 Subject: [PATCH 11/21] feat(2662): review updates. --- .../generated/graphql.ts | 20 ++++---- .../src/graphql/generated/graphql.schema.json | 20 ++++---- .../backend/src/graphql/generated/graphql.ts | 20 ++++---- .../src/graphql/resolvers/liquidity.test.ts | 46 +++++++++---------- .../src/graphql/resolvers/liquidity.ts | 20 ++++---- packages/backend/src/graphql/schema.graphql | 20 ++++---- .../docs/concepts/accounting/liquidity.md | 4 +- .../src/content/docs/reference/glossary.md | 3 +- packages/frontend/app/generated/graphql.ts | 20 ++++---- .../src/generated/graphql.ts | 20 ++++---- test/integration/lib/generated/graphql.ts | 20 ++++---- 11 files changed, 107 insertions(+), 106 deletions(-) diff --git a/localenv/mock-account-servicing-entity/generated/graphql.ts b/localenv/mock-account-servicing-entity/generated/graphql.ts index d2b24274b3..c1b05c743c 100644 --- a/localenv/mock-account-servicing-entity/generated/graphql.ts +++ b/localenv/mock-account-servicing-entity/generated/graphql.ts @@ -123,8 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -145,8 +145,8 @@ export type CreateIncomingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the incoming payment to withdraw from. */ incomingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateOrUpdatePeerByUrlInput = { @@ -203,8 +203,8 @@ export type CreateOutgoingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the outgoing payment to withdraw from. */ outgoingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerInput = { @@ -235,8 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -321,8 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; diff --git a/packages/backend/src/graphql/generated/graphql.schema.json b/packages/backend/src/graphql/generated/graphql.schema.json index a569c9574b..2832ed896b 100644 --- a/packages/backend/src/graphql/generated/graphql.schema.json +++ b/packages/backend/src/graphql/generated/graphql.schema.json @@ -787,8 +787,8 @@ "deprecationReason": null }, { - "name": "timeout", - "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "name": "timeoutSeconds", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer.", "type": { "kind": "NON_NULL", "name": null, @@ -921,8 +921,8 @@ "deprecationReason": null }, { - "name": "timeout", - "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "name": "timeoutSeconds", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer.", "type": { "kind": "NON_NULL", "name": null, @@ -1310,8 +1310,8 @@ "deprecationReason": null }, { - "name": "timeout", - "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "name": "timeoutSeconds", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer.", "type": { "kind": "NON_NULL", "name": null, @@ -1520,8 +1520,8 @@ "deprecationReason": null }, { - "name": "timeout", - "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "name": "timeoutSeconds", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer.", "type": { "kind": "NON_NULL", "name": null, @@ -2153,8 +2153,8 @@ "deprecationReason": null }, { - "name": "timeout", - "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout.", + "name": "timeoutSeconds", + "description": "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer.", "type": { "kind": "NON_NULL", "name": null, diff --git a/packages/backend/src/graphql/generated/graphql.ts b/packages/backend/src/graphql/generated/graphql.ts index d2b24274b3..c1b05c743c 100644 --- a/packages/backend/src/graphql/generated/graphql.ts +++ b/packages/backend/src/graphql/generated/graphql.ts @@ -123,8 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -145,8 +145,8 @@ export type CreateIncomingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the incoming payment to withdraw from. */ incomingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateOrUpdatePeerByUrlInput = { @@ -203,8 +203,8 @@ export type CreateOutgoingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the outgoing payment to withdraw from. */ outgoingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerInput = { @@ -235,8 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -321,8 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; diff --git a/packages/backend/src/graphql/resolvers/liquidity.test.ts b/packages/backend/src/graphql/resolvers/liquidity.test.ts index 2408b2b358..46f1b01c6f 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.test.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.test.ts @@ -502,7 +502,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -540,7 +540,7 @@ describe('Liquidity Resolvers', (): void => { peerId: uuid(), amount: '100', idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -579,7 +579,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -626,7 +626,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -670,7 +670,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: amount.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -726,7 +726,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -764,7 +764,7 @@ describe('Liquidity Resolvers', (): void => { assetId: uuid(), amount: '100', idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -803,7 +803,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -850,7 +850,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -894,7 +894,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: amount.toString(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -960,7 +960,7 @@ describe('Liquidity Resolvers', (): void => { id, walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -1007,7 +1007,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), walletAddressId: uuid(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -1049,7 +1049,7 @@ describe('Liquidity Resolvers', (): void => { id: 'not a uuid', walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -1099,7 +1099,7 @@ describe('Liquidity Resolvers', (): void => { id, walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -1148,7 +1148,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2077,7 +2077,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2129,7 +2129,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: uuid(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2166,7 +2166,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2222,7 +2222,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2296,7 +2296,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2337,7 +2337,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: uuid(), idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2380,7 +2380,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) @@ -2434,7 +2434,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeout: timeoutOnePhase + timeoutSeconds: timeoutOnePhase } } }) diff --git a/packages/backend/src/graphql/resolvers/liquidity.ts b/packages/backend/src/graphql/resolvers/liquidity.ts index 9e8885c1ce..6bba4625b3 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.ts @@ -170,7 +170,7 @@ export const createPeerLiquidityWithdrawal: MutationResolvers['cr ctx ): Promise => { try { - const { amount, id, timeout, peerId } = args.input + const { amount, id, timeoutSeconds, peerId } = args.input if (amount === BigInt(0)) { return responses[LiquidityError.AmountZero] } @@ -184,7 +184,7 @@ export const createPeerLiquidityWithdrawal: MutationResolvers['cr id, account: peer, amount, - timeout: Number(timeout) + timeout: Number(timeoutSeconds) }) if (error) { return errorToResponse(error) @@ -217,7 +217,7 @@ export const createAssetLiquidityWithdrawal: MutationResolvers['c ctx ): Promise => { try { - const { amount, id, timeout, assetId } = args.input + const { amount, id, timeoutSeconds, assetId } = args.input if (amount === 0n) { return responses[LiquidityError.AmountZero] } @@ -231,7 +231,7 @@ export const createAssetLiquidityWithdrawal: MutationResolvers['c id, account: asset, amount, - timeout: Number(timeout) + timeout: Number(timeoutSeconds) }) if (error) { return errorToResponse(error) @@ -264,7 +264,7 @@ export const createWalletAddressWithdrawal: MutationResolvers['cr ctx ): Promise => { try { - const { id, walletAddressId, timeout } = args.input + const { id, walletAddressId, timeoutSeconds } = args.input const walletAddressService = await ctx.container.use( 'walletAddressService' ) @@ -287,7 +287,7 @@ export const createWalletAddressWithdrawal: MutationResolvers['cr id, account: walletAddress, amount, - timeout: Number(timeout) + timeout: Number(timeoutSeconds) }) if (error) { @@ -528,7 +528,7 @@ export const createIncomingPaymentWithdrawal: MutationResolvers[' args, ctx ): Promise => { - const { incomingPaymentId, timeout } = args.input + const { incomingPaymentId, timeoutSeconds } = args.input try { const incomingPaymentService = await ctx.container.use( 'incomingPaymentService' @@ -556,7 +556,7 @@ export const createIncomingPaymentWithdrawal: MutationResolvers[' asset: incomingPayment.asset }, amount: incomingPayment.receivedAmount.value, - timeout: Number(timeout) + timeout: Number(timeoutSeconds) }) if (error) { @@ -589,7 +589,7 @@ export const createOutgoingPaymentWithdrawal: MutationResolvers[' args, ctx ): Promise => { - const { outgoingPaymentId, timeout } = args.input + const { outgoingPaymentId, timeoutSeconds } = args.input try { const outgoingPaymentService = await ctx.container.use( 'outgoingPaymentService' @@ -622,7 +622,7 @@ export const createOutgoingPaymentWithdrawal: MutationResolvers[' asset: outgoingPayment.asset }, amount: balance, - timeout: Number(timeout) + timeout: Number(timeoutSeconds) }) if (error) { diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index 664f7d1994..6f7f01ea88 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -388,8 +388,8 @@ input CreatePeerLiquidityWithdrawalInput { id: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! - "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." - timeout: UInt64! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer." + timeoutSeconds: UInt64! } input CreateAssetLiquidityWithdrawalInput { @@ -401,8 +401,8 @@ input CreateAssetLiquidityWithdrawalInput { id: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! - "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." - timeout: UInt64! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer." + timeoutSeconds: UInt64! } input PostLiquidityWithdrawalInput { @@ -431,8 +431,8 @@ input CreateIncomingPaymentWithdrawalInput { incomingPaymentId: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! - "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." - timeout: UInt64! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer." + timeoutSeconds: UInt64! } input CreateOutgoingPaymentWithdrawalInput { @@ -440,8 +440,8 @@ input CreateOutgoingPaymentWithdrawalInput { outgoingPaymentId: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! - "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." - timeout: UInt64! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer." + timeoutSeconds: UInt64! } input DepositEventLiquidityInput { @@ -465,8 +465,8 @@ input CreateWalletAddressWithdrawalInput { id: String! "Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence)" idempotencyKey: String! - "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout." - timeout: UInt64! + "This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer." + timeoutSeconds: UInt64! } input JwkInput { diff --git a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md index f32b0f8d27..8ca98ef2cd 100644 --- a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md +++ b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md @@ -250,8 +250,8 @@ See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#post `PostLiquidityWithdrawal` and `PostLiquidityWithdrawal` are only applicable for two-phase withdrawals. -- `PostLiquidityWithdrawal` - Post liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase commits and are committed via this mutation. -- `VoidLiquidityWithdrawal` - Void liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase commits and are rolled back via this mutation. +- `PostLiquidityWithdrawal` - Post liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase transfers and are committed via this mutation. +- `VoidLiquidityWithdrawal` - Void liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase transfers and are rolled back via this mutation. When a withdrawal liquidity transaction is requested with a non-zero `timeout` value _(Zero denotes absence of timeout)_, the transfer will be created as a two-phase transfer [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) diff --git a/packages/documentation/src/content/docs/reference/glossary.md b/packages/documentation/src/content/docs/reference/glossary.md index efe0cf8e46..2494e6b08d 100644 --- a/packages/documentation/src/content/docs/reference/glossary.md +++ b/packages/documentation/src/content/docs/reference/glossary.md @@ -48,7 +48,8 @@ A two-phase transfer moves funds in stages: - Reserve funds (`pending`) - Resolve funds (`post`, `void`, or `expire`) - The name "two-phase transfer" is a reference to the [two-phase commit protocol for distributed transactions](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). + +The name "two-phase transfer" is a reference to the [two-phase commit protocol for distributed transactions](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). ## Web Monetization diff --git a/packages/frontend/app/generated/graphql.ts b/packages/frontend/app/generated/graphql.ts index 7f8f9d5834..2b96f2cd82 100644 --- a/packages/frontend/app/generated/graphql.ts +++ b/packages/frontend/app/generated/graphql.ts @@ -123,8 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -145,8 +145,8 @@ export type CreateIncomingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the incoming payment to withdraw from. */ incomingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateOrUpdatePeerByUrlInput = { @@ -203,8 +203,8 @@ export type CreateOutgoingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the outgoing payment to withdraw from. */ outgoingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerInput = { @@ -235,8 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -321,8 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; diff --git a/packages/mock-account-service-lib/src/generated/graphql.ts b/packages/mock-account-service-lib/src/generated/graphql.ts index d2b24274b3..c1b05c743c 100644 --- a/packages/mock-account-service-lib/src/generated/graphql.ts +++ b/packages/mock-account-service-lib/src/generated/graphql.ts @@ -123,8 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -145,8 +145,8 @@ export type CreateIncomingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the incoming payment to withdraw from. */ incomingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateOrUpdatePeerByUrlInput = { @@ -203,8 +203,8 @@ export type CreateOutgoingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the outgoing payment to withdraw from. */ outgoingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerInput = { @@ -235,8 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -321,8 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; diff --git a/test/integration/lib/generated/graphql.ts b/test/integration/lib/generated/graphql.ts index d2b24274b3..c1b05c743c 100644 --- a/test/integration/lib/generated/graphql.ts +++ b/test/integration/lib/generated/graphql.ts @@ -123,8 +123,8 @@ export type CreateAssetLiquidityWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateIncomingPaymentInput = { @@ -145,8 +145,8 @@ export type CreateIncomingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the incoming payment to withdraw from. */ incomingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreateOrUpdatePeerByUrlInput = { @@ -203,8 +203,8 @@ export type CreateOutgoingPaymentWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the outgoing payment to withdraw from. */ outgoingPaymentId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerInput = { @@ -235,8 +235,8 @@ export type CreatePeerLiquidityWithdrawalInput = { idempotencyKey: Scalars['String']['input']; /** The id of the peer to create the withdrawal for. */ peerId: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; }; export type CreatePeerMutationResponse = MutationResponse & { @@ -321,8 +321,8 @@ export type CreateWalletAddressWithdrawalInput = { id: Scalars['String']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey: Scalars['String']['input']; - /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes absence of timeout. */ - timeout: Scalars['UInt64']['input']; + /** This is the interval in seconds after a pending transfer's created at which it may be posted or voided. Zero denotes a no timeout single-phase posted transfer. */ + timeoutSeconds: Scalars['UInt64']['input']; /** The id of the Open Payments wallet address to create the withdrawal for. */ walletAddressId: Scalars['String']['input']; }; From 7b157480f5e70c9b6bd409c2eec02bf25d4b6e5a Mon Sep 17 00:00:00 2001 From: koekiebox Date: Sat, 11 May 2024 10:48:37 +0200 Subject: [PATCH 12/21] feat(2662): frontend updates. --- .../frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx | 2 +- .../payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx | 2 +- .../payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx | 2 +- .../frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx | 2 +- .../wallet-addresses.$walletAddressId.withdraw-liquidity.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx index c42a40b86d..7fc1d04050 100644 --- a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx @@ -62,7 +62,7 @@ export async function action({ request, params }: ActionFunctionArgs) { amount: result.data, id: v4(), idempotencyKey: v4(), - timeout: timeoutTwoPhase + timeoutSeconds: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx index 506655aea0..d9447c91e0 100644 --- a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx @@ -47,7 +47,7 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createIncomingPaymentWithdrawal({ incomingPaymentId, idempotencyKey: v4(), - timeout: timeoutTwoPhase + timeoutSeconds: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx index b7b1ce484f..b13c0da5ca 100644 --- a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx @@ -49,7 +49,7 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createOutgoingPaymentWithdrawal({ outgoingPaymentId, idempotencyKey: v4(), - timeout: timeoutTwoPhase + timeoutSeconds: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx index fbffb0a53a..d242abfad3 100644 --- a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx @@ -62,7 +62,7 @@ export async function action({ request, params }: ActionFunctionArgs) { amount: result.data, id: v4(), idempotencyKey: v4(), - timeout: timeoutTwoPhase + timeoutSeconds: timeoutTwoPhase }) if (!response?.success) { diff --git a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx index c685d363ed..3e2b6f2920 100644 --- a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx @@ -48,7 +48,7 @@ export async function action({ request, params }: ActionFunctionArgs) { id: v4(), walletAddressId, idempotencyKey: v4(), - timeout: timeoutTwoPhase + timeoutSeconds: timeoutTwoPhase }) if (!response?.success) { From d663cc82f6e8a101375565cc46f2f5742cab71a5 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Mon, 13 May 2024 09:18:19 +0200 Subject: [PATCH 13/21] feat(2662): bruno updates. --- .../Rafiki Admin APIs/Create Wallet Address Withdrawal.bru | 2 +- .../Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru | 2 +- .../Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru | 2 +- .../Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru | 2 +- .../Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru index 7a7da0e54c..ff377ab90a 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address Withdrawal.bru @@ -41,7 +41,7 @@ body:graphql:vars { "id": "02ac56f7-ae5d-4abb-8306-17bf2327b43c", "walletAddressId": "{{walletAddressId}}", "idempotencyKey":"{{idempotencyKey}}", - "timeout": {{withdrawalTimeout}} + "timeoutSeconds": {{withdrawalTimeout}} } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru index a7be75e5bc..3ee4d48766 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru @@ -28,7 +28,7 @@ body:graphql:vars { "assetId": "{{assetId}}", "amount": "100", "idempotencyKey":"{{idempotencyKey}}", - "timeout": {{withdrawalTimeout}} + "timeoutSeconds": {{withdrawalTimeout}} } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru index de460764fe..97752f81f3 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru @@ -26,7 +26,7 @@ body:graphql:vars { "input": { "incomingPaymentId": "{{incomingPaymentId}}", "idempotencyKey": "{{idempotencyKey}}", - "timeout": {{withdrawalTimeout}} + "timeoutSeconds": {{withdrawalTimeout}} } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru index d79afb956b..832a1ae9f7 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru @@ -26,7 +26,7 @@ body:graphql:vars { "input": { "outgoingPaymentId": "{{outgoingPaymentId}}", "idempotencyKey": "{{idempotencyKey}}", - "timeout": {{withdrawalTimeout}} + "timeoutSeconds": {{withdrawalTimeout}} } } } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru index d0a7cf9215..d11e557709 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru @@ -28,7 +28,7 @@ body:graphql:vars { "peerId": "{{peerId}}", "amount": "100", "idempotencyKey":"{{idempotencyKey}}", - "timeout": {{withdrawalTimeout}} + "timeoutSeconds": {{withdrawalTimeout}} } } From 33b5321ff6175885f41f73bd2ec776e4dc065649 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Tue, 14 May 2024 12:15:36 +0200 Subject: [PATCH 14/21] feat(2662): make use of config from config.server.ts. --- .../app/routes/assets.$assetId.withdraw-liquidity.tsx | 4 ++-- ...ayments.incoming.$incomingPaymentId.withdraw-liquidity.tsx | 2 +- ...ayments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx | 2 +- .../frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx | 2 +- packages/frontend/app/routes/settings.tsx | 1 - .../wallet-addresses.$walletAddressId.withdraw-liquidity.tsx | 2 +- packages/frontend/app/utils/config.server.ts | 3 +++ 7 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 packages/frontend/app/utils/config.server.ts diff --git a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx index 7fc1d04050..535738f013 100644 --- a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx @@ -5,9 +5,9 @@ import { LiquidityDialog } from '~/components/LiquidityDialog' import { withdrawAssetLiquidity } from '~/lib/api/asset.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { amountSchema } from '~/lib/validate.server' -import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' +import { redirectIfUnauthorizedAccess } from '~/lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from './settings' +import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx index d9447c91e0..2d57c3dd14 100644 --- a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx @@ -6,7 +6,7 @@ import { createIncomingPaymentWithdrawal } from '~/lib/api/payments.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from './settings' +import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx index b13c0da5ca..7327ae2476 100644 --- a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx @@ -7,7 +7,7 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import type { LiquidityActionOutletContext } from './payments.outgoing.$outgoingPaymentId' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from './settings' +import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx index d242abfad3..de7eced2d8 100644 --- a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx @@ -7,7 +7,7 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { amountSchema } from '~/lib/validate.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from './settings' +import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/routes/settings.tsx b/packages/frontend/app/routes/settings.tsx index e800b514b2..b97fdc8378 100644 --- a/packages/frontend/app/routes/settings.tsx +++ b/packages/frontend/app/routes/settings.tsx @@ -10,7 +10,6 @@ import { PageHeader } from '~/components' import { Button, Input } from '../components/ui' import variables from '../lib/envConfig.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' -export const timeoutTwoPhase = BigInt(60) export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx index 3e2b6f2920..fb87748c8d 100644 --- a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx @@ -6,7 +6,7 @@ import { createWalletAddressWithdrawal } from '~/lib/api/wallet-address.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from './settings' +import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') diff --git a/packages/frontend/app/utils/config.server.ts b/packages/frontend/app/utils/config.server.ts new file mode 100644 index 0000000000..f23f100e08 --- /dev/null +++ b/packages/frontend/app/utils/config.server.ts @@ -0,0 +1,3 @@ +export const timeoutTwoPhase = BigInt( + process.env.WITHDRAWAL_TIMEOUT_SECONDS || 0 /*2-phase disabled*/ +) From 4fbb2114e8a86efdd5d5972d23a38f843b54780f Mon Sep 17 00:00:00 2001 From: koekiebox Date: Tue, 14 May 2024 14:49:57 +0200 Subject: [PATCH 15/21] feat(2662-2671): review comments. --- ...ty.bru => Create Incoming Payment Withdrawal.bru} | 0 ...ty.bru => Create Outgoing Payment Withdrawal.bru} | 0 .../app/lib/webhooks.server.ts | 3 ++- packages/backend/src/graphql/resolvers/liquidity.ts | 4 +++- .../content/docs/concepts/accounting/liquidity.md | 12 ++++++------ packages/frontend/app/utils/config.server.ts | 4 +--- 6 files changed, 12 insertions(+), 11 deletions(-) rename bruno/collections/Rafiki/Rafiki Admin APIs/{Withdraw Incoming Payment Liquidity.bru => Create Incoming Payment Withdrawal.bru} (100%) rename bruno/collections/Rafiki/Rafiki Admin APIs/{Withdraw Outgoing Payment Liquidity.bru => Create Outgoing Payment Withdrawal.bru} (100%) diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Incoming Payment Withdrawal.bru similarity index 100% rename from bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Incoming Payment Liquidity.bru rename to bruno/collections/Rafiki/Rafiki Admin APIs/Create Incoming Payment Withdrawal.bru diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment Withdrawal.bru similarity index 100% rename from bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Outgoing Payment Liquidity.bru rename to bruno/collections/Rafiki/Rafiki Admin APIs/Create Outgoing Payment Withdrawal.bru diff --git a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts index dfd77e2884..28f46af534 100644 --- a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts +++ b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts @@ -169,7 +169,8 @@ export async function handleIncomingPaymentCompletedExpired(wh: Webhook) { variables: { input: { incomingPaymentId: payment.id, - idempotencyKey: uuid() + idempotencyKey: uuid(), + timeoutSeconds: 0 } } }) diff --git a/packages/backend/src/graphql/resolvers/liquidity.ts b/packages/backend/src/graphql/resolvers/liquidity.ts index 6bba4625b3..df2e6d59fe 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.ts @@ -277,7 +277,9 @@ export const createWalletAddressWithdrawal: MutationResolvers['cr const accountingService = await ctx.container.use('accountingService') const amount = await accountingService.getBalance(walletAddress.id) if (amount === undefined) - throw new Error('missing incoming payment wallet address') + throw new Error( + `Could not get balance for wallet address liquidity account. It's likely the liquidity account does not exist.` + ) else if (amount === 0n) { return responses[ LiquidityError.AmountZero diff --git a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md index 8ca98ef2cd..06a603a34a 100644 --- a/packages/documentation/src/content/docs/concepts/accounting/liquidity.md +++ b/packages/documentation/src/content/docs/concepts/accounting/liquidity.md @@ -90,7 +90,7 @@ where "assetId": "7b8b0f65-896d-4403-b7ba-2e24bf20eb35", "amount": "100", "idempotencyKey": "b97fd85a-126e-42ef-b40d-1a50a70ffa6f", - "timeout": 0 + "timeoutSeconds": 0 } } ``` @@ -121,7 +121,7 @@ where "peerId": "73158598-2e0c-4973-895e-aebd115af260", "amount": "1000000", "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775", - "timeout": 0 + "timeoutSeconds": 0 } } ``` @@ -149,7 +149,7 @@ where "id": "421fae87-9a59-4217-9ff8-faf55ffab9c6", "peerId": "73158598-2e0c-4973-895e-aebd115af260", "amount": "100", - "timeout": 0 + "timeoutSeconds": 0 } } ``` @@ -208,7 +208,7 @@ where "input": { "outgoingPaymentId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775", - "timeout": 0 + "timeoutSeconds": 0 } } ``` @@ -239,7 +239,7 @@ where "input": { "incomingPaymentId": "b4f85d5c-652d-472d-873c-4ba2a5e39052", "idempotencyKey": "a09b730d-8610-4fda-98fa-ec7acb19c775", - "timeout": 0 + "timeoutSeconds": 0 } } ``` @@ -248,7 +248,7 @@ See `PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` at the [below](#post ## `PostLiquidityWithdrawal` or `VoidLiquidityWithdrawal` -`PostLiquidityWithdrawal` and `PostLiquidityWithdrawal` are only applicable for two-phase withdrawals. +`PostLiquidityWithdrawal` and `VoidLiquidityWithdrawal` are only applicable for two-phase withdrawals. - `PostLiquidityWithdrawal` - Post liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase transfers and are committed via this mutation. - `VoidLiquidityWithdrawal` - Void liquidity withdrawal. Withdrawals with `> 0` timeouts are two-phase transfers and are rolled back via this mutation. diff --git a/packages/frontend/app/utils/config.server.ts b/packages/frontend/app/utils/config.server.ts index f23f100e08..e60c15e4a7 100644 --- a/packages/frontend/app/utils/config.server.ts +++ b/packages/frontend/app/utils/config.server.ts @@ -1,3 +1 @@ -export const timeoutTwoPhase = BigInt( - process.env.WITHDRAWAL_TIMEOUT_SECONDS || 0 /*2-phase disabled*/ -) +export const timeoutTwoPhase = BigInt(0 /*2-phase disabled*/) From 3b4b16c1d8ab75c9932fb8335ae4a27037563102 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Tue, 14 May 2024 15:10:07 +0200 Subject: [PATCH 16/21] feat(2662/2671): address review feedback. --- ...set Liquidity.bru => Create Asset Liquidity Withdrawal.bru} | 0 ...Peer Liquidity.bru => Create Peer Liquidity Withdrawal.bru} | 0 .../frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx | 3 +-- ...payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx | 3 +-- ...payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx | 3 +-- .../frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx | 3 +-- .../wallet-addresses.$walletAddressId.withdraw-liquidity.tsx | 3 +-- packages/frontend/app/utils/config.server.ts | 1 - 8 files changed, 5 insertions(+), 11 deletions(-) rename bruno/collections/Rafiki/Rafiki Admin APIs/{Withdraw Asset Liquidity.bru => Create Asset Liquidity Withdrawal.bru} (100%) rename bruno/collections/Rafiki/Rafiki Admin APIs/{Withdraw Peer Liquidity.bru => Create Peer Liquidity Withdrawal.bru} (100%) delete mode 100644 packages/frontend/app/utils/config.server.ts diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Asset Liquidity Withdrawal.bru similarity index 100% rename from bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Asset Liquidity.bru rename to bruno/collections/Rafiki/Rafiki Admin APIs/Create Asset Liquidity Withdrawal.bru diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Peer Liquidity Withdrawal.bru similarity index 100% rename from bruno/collections/Rafiki/Rafiki Admin APIs/Withdraw Peer Liquidity.bru rename to bruno/collections/Rafiki/Rafiki Admin APIs/Create Peer Liquidity Withdrawal.bru diff --git a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx index 535738f013..2bf52d24f4 100644 --- a/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/assets.$assetId.withdraw-liquidity.tsx @@ -7,7 +7,6 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { amountSchema } from '~/lib/validate.server' import { redirectIfUnauthorizedAccess } from '~/lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -62,7 +61,7 @@ export async function action({ request, params }: ActionFunctionArgs) { amount: result.data, id: v4(), idempotencyKey: v4(), - timeoutSeconds: timeoutTwoPhase + timeoutSeconds: BigInt(0) }) if (!response?.success) { diff --git a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx index 2d57c3dd14..8fe1ba6635 100644 --- a/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.incoming.$incomingPaymentId.withdraw-liquidity.tsx @@ -6,7 +6,6 @@ import { createIncomingPaymentWithdrawal } from '~/lib/api/payments.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -47,7 +46,7 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createIncomingPaymentWithdrawal({ incomingPaymentId, idempotencyKey: v4(), - timeoutSeconds: timeoutTwoPhase + timeoutSeconds: BigInt(0) }) if (!response?.success) { diff --git a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx index 7327ae2476..f8f0eb993f 100644 --- a/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/payments.outgoing.$outgoingPaymentId.withdraw-liquidity.tsx @@ -7,7 +7,6 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import type { LiquidityActionOutletContext } from './payments.outgoing.$outgoingPaymentId' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -49,7 +48,7 @@ export async function action({ request, params }: ActionFunctionArgs) { const response = await createOutgoingPaymentWithdrawal({ outgoingPaymentId, idempotencyKey: v4(), - timeoutSeconds: timeoutTwoPhase + timeoutSeconds: BigInt(0) }) if (!response?.success) { diff --git a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx index de7eced2d8..d48a558e14 100644 --- a/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/peers.$peerId.withdraw-liquidity.tsx @@ -7,7 +7,6 @@ import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { amountSchema } from '~/lib/validate.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -62,7 +61,7 @@ export async function action({ request, params }: ActionFunctionArgs) { amount: result.data, id: v4(), idempotencyKey: v4(), - timeoutSeconds: timeoutTwoPhase + timeoutSeconds: BigInt(0) }) if (!response?.success) { diff --git a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx index fb87748c8d..8f15df05db 100644 --- a/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx +++ b/packages/frontend/app/routes/wallet-addresses.$walletAddressId.withdraw-liquidity.tsx @@ -6,7 +6,6 @@ import { createWalletAddressWithdrawal } from '~/lib/api/wallet-address.server' import { messageStorage, setMessageAndRedirect } from '~/lib/message.server' import { redirectIfUnauthorizedAccess } from '../lib/kratos_checks.server' import { type LoaderFunctionArgs } from '@remix-run/node' -import { timeoutTwoPhase } from '~/utils/config.server' export const loader = async ({ request }: LoaderFunctionArgs) => { const cookies = request.headers.get('cookie') @@ -48,7 +47,7 @@ export async function action({ request, params }: ActionFunctionArgs) { id: v4(), walletAddressId, idempotencyKey: v4(), - timeoutSeconds: timeoutTwoPhase + timeoutSeconds: BigInt(0) }) if (!response?.success) { diff --git a/packages/frontend/app/utils/config.server.ts b/packages/frontend/app/utils/config.server.ts deleted file mode 100644 index e60c15e4a7..0000000000 --- a/packages/frontend/app/utils/config.server.ts +++ /dev/null @@ -1 +0,0 @@ -export const timeoutTwoPhase = BigInt(0 /*2-phase disabled*/) From 6bfaa6569438bbf14982b0ab5a62d6a7f8b96da8 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Tue, 14 May 2024 15:16:23 +0200 Subject: [PATCH 17/21] feat(2662/2671): remove variable timeoutOnePhase --- .../src/graphql/resolvers/liquidity.test.ts | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/packages/backend/src/graphql/resolvers/liquidity.test.ts b/packages/backend/src/graphql/resolvers/liquidity.test.ts index 46f1b01c6f..48ba6c2fde 100644 --- a/packages/backend/src/graphql/resolvers/liquidity.test.ts +++ b/packages/backend/src/graphql/resolvers/liquidity.test.ts @@ -50,7 +50,6 @@ describe('Liquidity Resolvers', (): void => { let appContainer: TestContainer let accountingService: AccountingService let knex: Knex - const timeoutOnePhase = 0 const timeoutTwoPhase = 10 beforeAll(async (): Promise => { @@ -502,7 +501,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -540,7 +539,7 @@ describe('Liquidity Resolvers', (): void => { peerId: uuid(), amount: '100', idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -579,7 +578,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -626,7 +625,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -670,7 +669,7 @@ describe('Liquidity Resolvers', (): void => { peerId: peer.id, amount: amount.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -726,7 +725,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -764,7 +763,7 @@ describe('Liquidity Resolvers', (): void => { assetId: uuid(), amount: '100', idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -803,7 +802,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -850,7 +849,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: startingBalance.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -894,7 +893,7 @@ describe('Liquidity Resolvers', (): void => { assetId: asset.id, amount: amount.toString(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -960,7 +959,7 @@ describe('Liquidity Resolvers', (): void => { id, walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -1007,7 +1006,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), walletAddressId: uuid(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -1049,7 +1048,7 @@ describe('Liquidity Resolvers', (): void => { id: 'not a uuid', walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -1099,7 +1098,7 @@ describe('Liquidity Resolvers', (): void => { id, walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -1123,7 +1122,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), account: walletAddress, amount, - timeout: timeoutOnePhase + timeout: 0 }) ).resolves.toBeUndefined() const response = await appContainer.apolloClient @@ -1148,7 +1147,7 @@ describe('Liquidity Resolvers', (): void => { id: uuid(), walletAddressId: walletAddress.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2077,7 +2076,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2129,7 +2128,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: uuid(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2166,7 +2165,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2222,7 +2221,7 @@ describe('Liquidity Resolvers', (): void => { input: { incomingPaymentId: incomingPayment.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2296,7 +2295,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2337,7 +2336,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: uuid(), idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2380,7 +2379,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) @@ -2434,7 +2433,7 @@ describe('Liquidity Resolvers', (): void => { input: { outgoingPaymentId: outgoingPayment.id, idempotencyKey: uuid(), - timeoutSeconds: timeoutOnePhase + timeoutSeconds: 0 } } }) From cd9220326b7e6dff9635df0fb1120213053c0b18 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Wed, 15 May 2024 08:18:42 +0200 Subject: [PATCH 18/21] feat(2662/2671): document updates. --- .../docs/integration/event-handlers.mdx | 48 ++++++++++++++++--- .../src/content/docs/playground/overview.md | 29 +++++------ 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/packages/documentation/src/content/docs/integration/event-handlers.mdx b/packages/documentation/src/content/docs/integration/event-handlers.mdx index 36a82f5d77..816e45d94b 100644 --- a/packages/documentation/src/content/docs/integration/event-handlers.mdx +++ b/packages/documentation/src/content/docs/integration/event-handlers.mdx @@ -25,7 +25,9 @@ The `incoming_payment.created` event indicates that an incoming payment has been The `incoming_payment.completed` event indicates that an incoming payment has been completed, either automatically or manually, and that any funds that have been received into this incoming payment should be withdrawn and credited to the recipient's account with the Account Servicing Entity. -Example: An incoming payment was completed and received $10. +In addition, the `CreateIncomingPaymentWithdrawal` supports two-phase transfers [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). + +Example: An incoming payment was completed and received **$10**. +Example: An incoming payment supporting two-phase transfers was completed and recieved **$10**. + +>ASE: webhook event: incoming payment completed,
receivedAmount: $10 + ASE->>R: admin API call: CreateIncomingPaymentWithdrawal + ASE->>ASE: credit receiver's account with $10 + ASE->>R: admin API call: PostLiquidityWithdrawal + R->>R: 2-phase transfer completed + +`} +/> + ## `incoming_payment.expired` The `incoming_payment.expired` event indicates that an incoming payment has expired, and that any funds that have been received into this incoming payment should be withdrawn and credited to the recipient's account with the Account Servicing Entity. Note that this event is not fired if there were no funds received by the incoming payment since there is no action required by the Account Servicing Entity. -Example: An incoming payment has expired and received $2.55. +Example: An incoming payment has expired and received **$2.55**. +Example: An outgoing payment supporting two-phase transfers for **$12** has been completed. **$11.50** were sent. The Account Servicing Entity keeps **$0.50** as fees. + +>ASE: webhook event: outgoing completed,
debitAmount: $12, sentAmount:$11.50 + ASE->>R: admin API call: CreateOutgoingPaymentWithdrawal + ASE->>ASE: remove the hold and deduct $12 from the sender's account,
credit ASE's account with $0.50 + ASE->>R: admin API call: PostLiquidityWithdrawal + R->>R: 2-phase transfer completed + +`} +/> + ## `outgoing_payment.failed` The `outgoing_payment.failed` event indicates that an outgoing payment has either partially or completely failed and a retry was also unsuccessful. The Account Servicing Entity should withdraw any remaining liquidity from that outgoing payment in Rafiki. If the payment failed completely (the `sentAmount` was 0), the Account Servicing Entity should remove the hold from the sender's account. If the payment failed partially, the Account Servicing Entity should remove the hold from the sender's account and debit it with the amount that has been sent, but they should refrain from taking a sending fee. -Example: An outgoing payment for $12 has failed. $8 were sent. +Example: An outgoing payment for **$12** has failed. **$8** were sent. Date: Wed, 15 May 2024 10:21:06 +0200 Subject: [PATCH 19/21] feat(2662/2671): final doc updates. --- .../src/content/docs/integration/event-handlers.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/documentation/src/content/docs/integration/event-handlers.mdx b/packages/documentation/src/content/docs/integration/event-handlers.mdx index 816e45d94b..34eb25e311 100644 --- a/packages/documentation/src/content/docs/integration/event-handlers.mdx +++ b/packages/documentation/src/content/docs/integration/event-handlers.mdx @@ -25,7 +25,7 @@ The `incoming_payment.created` event indicates that an incoming payment has been The `incoming_payment.completed` event indicates that an incoming payment has been completed, either automatically or manually, and that any funds that have been received into this incoming payment should be withdrawn and credited to the recipient's account with the Account Servicing Entity. -In addition, the `CreateIncomingPaymentWithdrawal` supports two-phase transfers [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). +In addition, the `CreateIncomingPaymentWithdrawal` supports two-phase transfers [see more](/reference/glossary#two-phase-transfers). Example: An incoming payment was completed and received **$10**. @@ -104,7 +104,7 @@ Example: An outgoing payment for **$12** has been created. The `outgoing_payment.completed` event indicates that an outgoing payment has successfully sent as many funds as possible to the receiver. The Account Servicing Entity should withdraw any excess liquidity from that outgoing payment in Rafiki and use it as they see fit. One option would be to return it to the sender. Another option is that the excess liquidity is considered a fee and retained by the Account Servicing Entity. Furthermore, the Account Servicing Entity should remove the hold on the sender's account and debit it. -In addition, the `CreateOutgoingPaymentWithdrawal` supports two-phase transfers [see more](https://en.wikipedia.org/wiki/Two-phase_commit_protocol). +In addition, the `CreateOutgoingPaymentWithdrawal` supports two-phase transfers [see more](/reference/glossary#two-phase-transfers). Example: An outgoing payment amount for **$12** has been completed. **$11.50** were sent. The Account Servicing Entity keeps **$0.50** as fees. From e9e5dac922ecebe8c1b2f920797f9a9195032f19 Mon Sep 17 00:00:00 2001 From: koekiebox Date: Wed, 15 May 2024 14:08:52 +0200 Subject: [PATCH 20/21] feat(2662/2671): more dollar fixes. --- .../src/content/docs/integration/event-handlers.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/documentation/src/content/docs/integration/event-handlers.mdx b/packages/documentation/src/content/docs/integration/event-handlers.mdx index 34eb25e311..44ceb9e417 100644 --- a/packages/documentation/src/content/docs/integration/event-handlers.mdx +++ b/packages/documentation/src/content/docs/integration/event-handlers.mdx @@ -140,7 +140,7 @@ Example: An outgoing payment supporting two-phase transfers for **$12** has been The `outgoing_payment.failed` event indicates that an outgoing payment has either partially or completely failed and a retry was also unsuccessful. The Account Servicing Entity should withdraw any remaining liquidity from that outgoing payment in Rafiki. If the payment failed completely (the `sentAmount` was 0), the Account Servicing Entity should remove the hold from the sender's account. If the payment failed partially, the Account Servicing Entity should remove the hold from the sender's account and debit it with the amount that has been sent, but they should refrain from taking a sending fee. -Example: An outgoing payment for **$12** has failed. **$8** were sent. +Example: An outgoing payment for **$12** has failed. **$8** were sent. Date: Wed, 15 May 2024 16:34:48 +0200 Subject: [PATCH 21/21] feat(2662/2671): more dollar fixes. --- .../src/content/docs/integration/event-handlers.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/documentation/src/content/docs/integration/event-handlers.mdx b/packages/documentation/src/content/docs/integration/event-handlers.mdx index 44ceb9e417..8d9a4d44a2 100644 --- a/packages/documentation/src/content/docs/integration/event-handlers.mdx +++ b/packages/documentation/src/content/docs/integration/event-handlers.mdx @@ -81,7 +81,7 @@ The `outgoing_payment.created` event indicates that an outgoing payment has been In case that outgoing payment should not be fullfilled, the Account Servicing Entity can cancel outgoing payment. Otherwise, the Account Servicing Entity should put a hold on the sender’s account and deposit the funds into Rafiki. -Example: An outgoing payment for **$12** has been created. +Example: An outgoing payment for **$12** has been created. -Example: An outgoing payment supporting two-phase transfers for **$12** has been completed. **$11.50** were sent. The Account Servicing Entity keeps **$0.50** as fees. +Example: An outgoing payment supporting two-phase transfers for **$12** has been completed. **$11.50** were sent. The Account Servicing Entity keeps **$0.50** as fees.