From b2699de9ad4250ec3a7bad593c837b51f1ecdf80 Mon Sep 17 00:00:00 2001 From: okjodom Date: Tue, 5 Nov 2024 18:23:42 +0300 Subject: [PATCH] feat: refine swap definitions --- apps/api/src/swap/swap.controller.ts | 12 +- apps/swap/prisma/client/edge.js | 34 +- apps/swap/prisma/client/index-browser.js | 28 +- apps/swap/prisma/client/index.d.ts | 2062 +++-------------- apps/swap/prisma/client/index.js | 34 +- apps/swap/prisma/client/package.json | 2 +- apps/swap/prisma/client/schema.prisma | 68 +- apps/swap/prisma/client/wasm.js | 28 +- .../migration.sql | 33 - .../migration.sql | 8 - .../migration.sql | 8 - .../migration.sql | 17 - .../migration.sql | 41 + apps/swap/prisma/schema.prisma | 40 +- apps/swap/src/dto/index.ts | 3 +- .../src/dto/mpesa-collection-update.dto.ts | 22 + apps/swap/src/dto/mpesa-payment-update.dto.ts | 71 + .../src/dto/mpesa-transaction-update.dto.ts | 65 - apps/swap/src/dto/send-mpesa.dto.ts | 27 + apps/swap/src/dto/send-stk-push.dto.ts | 28 +- apps/swap/src/dto/utils.ts | 40 + apps/swap/src/events.controller.spec.ts | 8 +- apps/swap/src/events.controller.ts | 4 +- apps/swap/src/intasend/intasend.service.ts | 153 +- apps/swap/src/intasend/intasend.types.ts | 87 +- apps/swap/src/swap.service.spec.ts | 113 +- apps/swap/src/swap.service.ts | 208 +- .../common/src/dto/create-offramp-swap.dto.ts | 11 +- libs/common/src/dto/create-onramp-swap.dto.ts | 48 +- libs/common/src/dto/payments.dto.ts | 18 + libs/common/src/types/proto/swap.ts | 31 +- proto/swap.proto | 41 +- scripts/swap.manual.dev.sh | 2 +- 33 files changed, 1035 insertions(+), 2360 deletions(-) delete mode 100644 apps/swap/prisma/migrations/20241025174151_initialize_swap_models/migration.sql delete mode 100644 apps/swap/prisma/migrations/20241026231657_unique_mpesa_id_on_swap/migration.sql delete mode 100644 apps/swap/prisma/migrations/20241027010339_record_onramp_swap_fx/migration.sql delete mode 100644 apps/swap/prisma/migrations/20241103214340_define_mpesa_offramp_swap/migration.sql create mode 100644 apps/swap/prisma/migrations/20241105150909_define_swap_models/migration.sql create mode 100644 apps/swap/src/dto/mpesa-collection-update.dto.ts create mode 100644 apps/swap/src/dto/mpesa-payment-update.dto.ts delete mode 100644 apps/swap/src/dto/mpesa-transaction-update.dto.ts create mode 100644 apps/swap/src/dto/send-mpesa.dto.ts create mode 100644 apps/swap/src/dto/utils.ts create mode 100644 libs/common/src/dto/payments.dto.ts diff --git a/apps/api/src/swap/swap.controller.ts b/apps/api/src/swap/swap.controller.ts index 43df7a0..d351e92 100644 --- a/apps/api/src/swap/swap.controller.ts +++ b/apps/api/src/swap/swap.controller.ts @@ -125,17 +125,7 @@ export class SwapController { type: CreateOfframpSwapDto, }) postOfframpTransaction(@Body() req: CreateOfframpSwapDto) { - return this.swapService.postOfframpTransaction({ - quote: req.quote, - amount: req.amount, - ref: req.ref, - target: { - currency: req.target.currency, - destination: { - phone: req.target.destination.phone, - }, - }, - }); + return this.swapService.postOfframpTransaction(req); } @Get('offramp/find/:id') diff --git a/apps/swap/prisma/client/edge.js b/apps/swap/prisma/client/edge.js index e7139e0..c2a5772 100644 --- a/apps/swap/prisma/client/edge.js +++ b/apps/swap/prisma/client/edge.js @@ -93,10 +93,11 @@ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + collectionTracker: 'collectionTracker', rate: 'rate', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -105,24 +106,12 @@ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { exports.Prisma.MpesaOfframpSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + phone: 'phone', + paymentTracker: 'paymentTracker', rate: 'rate', - retryCount: 'retryCount', - createdAt: 'createdAt', - updatedAt: 'updatedAt' -}; - -exports.Prisma.IntasendMpesaTransactionScalarFieldEnum = { - id: 'id', - state: 'state', - apiRef: 'apiRef', - value: 'value', - charges: 'charges', - netAmount: 'netAmount', - currency: 'currency', - account: 'account', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -152,8 +141,7 @@ exports.SwapTransactionState = exports.$Enums.SwapTransactionState = { exports.Prisma.ModelName = { MpesaOnrampSwap: 'MpesaOnrampSwap', - MpesaOfframpSwap: 'MpesaOfframpSwap', - IntasendMpesaTransaction: 'IntasendMpesaTransaction' + MpesaOfframpSwap: 'MpesaOfframpSwap' }; /** * Create the Client @@ -210,13 +198,13 @@ const config = { } } }, - "inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"./client\"\n binaryTargets = [\"native\", \"linux-musl-openssl-3.0.x\", \"debian-openssl-1.1.x\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel MpesaOnrampSwap {\n /// Unique identifier for the swap\n id String @id @default(uuid())\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction.\n userId String\n /// References the onramp Mpesa transaction ID.\n mpesaId String @unique\n /// Lightning invoice to pay.\n lightning String\n /// Fx Rate\n rate String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel MpesaOfframpSwap {\n /// Unique identifier for the swap\n id String @id\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction.\n userId String\n /// References the offramp Mpesa transaction ID.\n mpesaId String? @unique\n /// Lightning invoice to be paid before invoice can proceed.\n lightning String\n /// Fx Rate\n rate String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nenum SwapTransactionState {\n PENDING\n PROCESSING\n FAILED\n COMPLETE\n RETRY\n}\n\nmodel IntasendMpesaTransaction {\n id String @id @default(uuid())\n state SwapTransactionState\n apiRef String\n value String\n charges String\n netAmount String\n currency String\n account String\n retryCount Int\n createdAt String\n updatedAt String\n}\n", - "inlineSchemaHash": "7fdc789c2ea4426f4b6e45d909c27e5a3665a94901fed58c8c3642982e2f1117", + "inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"./client\"\n binaryTargets = [\"native\", \"linux-musl-openssl-3.0.x\", \"debian-openssl-1.1.x\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel MpesaOnrampSwap {\n /// Unique identifier for the swap\n id String @id @default(uuid())\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction\n reference String\n /// Lightning invoice to pay.\n lightning String\n /// References the fiat onramp collection ID\n collectionTracker String @unique\n /// Fx Rate from \n rate String\n /// Amount in satoshi\n amountSats String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel MpesaOfframpSwap {\n /// Unique identifier for the swap\n id String @id\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction\n reference String\n /// Lightning invoice to be paid before offramp can proceed\n lightning String\n /// Phone number to send mpesa the payment\n phone String\n /// References the fiat offramp payment ID\n paymentTracker String? @unique\n /// Fx Rate\n rate String\n /// Amount in satoshi\n amountSats String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nenum SwapTransactionState {\n PENDING\n PROCESSING\n FAILED\n COMPLETE\n RETRY\n}\n", + "inlineSchemaHash": "3fc48b2589b611b8a2e949388e8ee01dd228208c1e7ed3fcab9d99b06c07c76c", "copyEngine": true } config.dirname = '/' -config.runtimeDataModel = JSON.parse("{\"models\":{\"MpesaOnrampSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction.\"},{\"name\":\"mpesaId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the onramp Mpesa transaction ID.\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to pay.\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"MpesaOfframpSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction.\"},{\"name\":\"mpesaId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the offramp Mpesa transaction ID.\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to be paid before invoice can proceed.\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"IntasendMpesaTransaction\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiRef\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"value\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"charges\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"netAmount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"currency\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"account\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{\"SwapTransactionState\":{\"values\":[{\"name\":\"PENDING\",\"dbName\":null},{\"name\":\"PROCESSING\",\"dbName\":null},{\"name\":\"FAILED\",\"dbName\":null},{\"name\":\"COMPLETE\",\"dbName\":null},{\"name\":\"RETRY\",\"dbName\":null}],\"dbName\":null}},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"MpesaOnrampSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"reference\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to pay.\"},{\"name\":\"collectionTracker\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the fiat onramp collection ID\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate from \"},{\"name\":\"amountSats\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Amount in satoshi\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"MpesaOfframpSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"reference\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to be paid before offramp can proceed\"},{\"name\":\"phone\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Phone number to send mpesa the payment\"},{\"name\":\"paymentTracker\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the fiat offramp payment ID\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"amountSats\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Amount in satoshi\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{\"SwapTransactionState\":{\"values\":[{\"name\":\"PENDING\",\"dbName\":null},{\"name\":\"PROCESSING\",\"dbName\":null},{\"name\":\"FAILED\",\"dbName\":null},{\"name\":\"COMPLETE\",\"dbName\":null},{\"name\":\"RETRY\",\"dbName\":null}],\"dbName\":null}},\"types\":{}}") defineDmmfProperty(exports.Prisma, config.runtimeDataModel) config.engineWasm = undefined diff --git a/apps/swap/prisma/client/index-browser.js b/apps/swap/prisma/client/index-browser.js index edfbd6a..dd58fbb 100644 --- a/apps/swap/prisma/client/index-browser.js +++ b/apps/swap/prisma/client/index-browser.js @@ -125,10 +125,11 @@ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + collectionTracker: 'collectionTracker', rate: 'rate', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -137,24 +138,12 @@ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { exports.Prisma.MpesaOfframpSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + phone: 'phone', + paymentTracker: 'paymentTracker', rate: 'rate', - retryCount: 'retryCount', - createdAt: 'createdAt', - updatedAt: 'updatedAt' -}; - -exports.Prisma.IntasendMpesaTransactionScalarFieldEnum = { - id: 'id', - state: 'state', - apiRef: 'apiRef', - value: 'value', - charges: 'charges', - netAmount: 'netAmount', - currency: 'currency', - account: 'account', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -184,8 +173,7 @@ exports.SwapTransactionState = exports.$Enums.SwapTransactionState = { exports.Prisma.ModelName = { MpesaOnrampSwap: 'MpesaOnrampSwap', - MpesaOfframpSwap: 'MpesaOfframpSwap', - IntasendMpesaTransaction: 'IntasendMpesaTransaction' + MpesaOfframpSwap: 'MpesaOfframpSwap' }; /** diff --git a/apps/swap/prisma/client/index.d.ts b/apps/swap/prisma/client/index.d.ts index 9a721b6..db81bbb 100644 --- a/apps/swap/prisma/client/index.d.ts +++ b/apps/swap/prisma/client/index.d.ts @@ -23,12 +23,6 @@ export type MpesaOnrampSwap = */ export type MpesaOfframpSwap = $Result.DefaultSelection; -/** - * Model IntasendMpesaTransaction - * - */ -export type IntasendMpesaTransaction = - $Result.DefaultSelection; /** * Enums @@ -225,16 +219,6 @@ export class PrismaClient< * ``` */ get mpesaOfframpSwap(): Prisma.MpesaOfframpSwapDelegate; - - /** - * `prisma.intasendMpesaTransaction`: Exposes CRUD operations for the **IntasendMpesaTransaction** model. - * Example usage: - * ```ts - * // Fetch zero or more IntasendMpesaTransactions - * const intasendMpesaTransactions = await prisma.intasendMpesaTransaction.findMany() - * ``` - */ - get intasendMpesaTransaction(): Prisma.IntasendMpesaTransactionDelegate; } export namespace Prisma { @@ -696,7 +680,6 @@ export namespace Prisma { export const ModelName: { MpesaOnrampSwap: 'MpesaOnrampSwap'; MpesaOfframpSwap: 'MpesaOfframpSwap'; - IntasendMpesaTransaction: 'IntasendMpesaTransaction'; }; export type ModelName = (typeof ModelName)[keyof typeof ModelName]; @@ -721,10 +704,7 @@ export namespace Prisma { ClientOptions = {}, > = { meta: { - modelProps: - | 'mpesaOnrampSwap' - | 'mpesaOfframpSwap' - | 'intasendMpesaTransaction'; + modelProps: 'mpesaOnrampSwap' | 'mpesaOfframpSwap'; txIsolationLevel: Prisma.TransactionIsolationLevel; }; model: { @@ -872,78 +852,6 @@ export namespace Prisma { }; }; }; - IntasendMpesaTransaction: { - payload: Prisma.$IntasendMpesaTransactionPayload; - fields: Prisma.IntasendMpesaTransactionFieldRefs; - operations: { - findUnique: { - args: Prisma.IntasendMpesaTransactionFindUniqueArgs; - result: $Utils.PayloadToResult | null; - }; - findUniqueOrThrow: { - args: Prisma.IntasendMpesaTransactionFindUniqueOrThrowArgs; - result: $Utils.PayloadToResult; - }; - findFirst: { - args: Prisma.IntasendMpesaTransactionFindFirstArgs; - result: $Utils.PayloadToResult | null; - }; - findFirstOrThrow: { - args: Prisma.IntasendMpesaTransactionFindFirstOrThrowArgs; - result: $Utils.PayloadToResult; - }; - findMany: { - args: Prisma.IntasendMpesaTransactionFindManyArgs; - result: $Utils.PayloadToResult[]; - }; - create: { - args: Prisma.IntasendMpesaTransactionCreateArgs; - result: $Utils.PayloadToResult; - }; - createMany: { - args: Prisma.IntasendMpesaTransactionCreateManyArgs; - result: BatchPayload; - }; - createManyAndReturn: { - args: Prisma.IntasendMpesaTransactionCreateManyAndReturnArgs; - result: $Utils.PayloadToResult[]; - }; - delete: { - args: Prisma.IntasendMpesaTransactionDeleteArgs; - result: $Utils.PayloadToResult; - }; - update: { - args: Prisma.IntasendMpesaTransactionUpdateArgs; - result: $Utils.PayloadToResult; - }; - deleteMany: { - args: Prisma.IntasendMpesaTransactionDeleteManyArgs; - result: BatchPayload; - }; - updateMany: { - args: Prisma.IntasendMpesaTransactionUpdateManyArgs; - result: BatchPayload; - }; - upsert: { - args: Prisma.IntasendMpesaTransactionUpsertArgs; - result: $Utils.PayloadToResult; - }; - aggregate: { - args: Prisma.IntasendMpesaTransactionAggregateArgs; - result: $Utils.Optional; - }; - groupBy: { - args: Prisma.IntasendMpesaTransactionGroupByArgs; - result: $Utils.Optional[]; - }; - count: { - args: Prisma.IntasendMpesaTransactionCountArgs; - result: - | $Utils.Optional - | number; - }; - }; - }; }; } & { other: { @@ -1143,10 +1051,11 @@ export namespace Prisma { export type MpesaOnrampSwapMinAggregateOutputType = { id: string | null; state: $Enums.SwapTransactionState | null; - userId: string | null; - mpesaId: string | null; + reference: string | null; lightning: string | null; + collectionTracker: string | null; rate: string | null; + amountSats: string | null; retryCount: number | null; createdAt: Date | null; updatedAt: Date | null; @@ -1155,10 +1064,11 @@ export namespace Prisma { export type MpesaOnrampSwapMaxAggregateOutputType = { id: string | null; state: $Enums.SwapTransactionState | null; - userId: string | null; - mpesaId: string | null; + reference: string | null; lightning: string | null; + collectionTracker: string | null; rate: string | null; + amountSats: string | null; retryCount: number | null; createdAt: Date | null; updatedAt: Date | null; @@ -1167,10 +1077,11 @@ export namespace Prisma { export type MpesaOnrampSwapCountAggregateOutputType = { id: number; state: number; - userId: number; - mpesaId: number; + reference: number; lightning: number; + collectionTracker: number; rate: number; + amountSats: number; retryCount: number; createdAt: number; updatedAt: number; @@ -1188,10 +1099,11 @@ export namespace Prisma { export type MpesaOnrampSwapMinAggregateInputType = { id?: true; state?: true; - userId?: true; - mpesaId?: true; + reference?: true; lightning?: true; + collectionTracker?: true; rate?: true; + amountSats?: true; retryCount?: true; createdAt?: true; updatedAt?: true; @@ -1200,10 +1112,11 @@ export namespace Prisma { export type MpesaOnrampSwapMaxAggregateInputType = { id?: true; state?: true; - userId?: true; - mpesaId?: true; + reference?: true; lightning?: true; + collectionTracker?: true; rate?: true; + amountSats?: true; retryCount?: true; createdAt?: true; updatedAt?: true; @@ -1212,10 +1125,11 @@ export namespace Prisma { export type MpesaOnrampSwapCountAggregateInputType = { id?: true; state?: true; - userId?: true; - mpesaId?: true; + reference?: true; lightning?: true; + collectionTracker?: true; rate?: true; + amountSats?: true; retryCount?: true; createdAt?: true; updatedAt?: true; @@ -1320,10 +1234,11 @@ export namespace Prisma { export type MpesaOnrampSwapGroupByOutputType = { id: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId: string; + reference: string; lightning: string; + collectionTracker: string; rate: string; + amountSats: string; retryCount: number; createdAt: Date; updatedAt: Date; @@ -1354,10 +1269,11 @@ export namespace Prisma { { id?: boolean; state?: boolean; - userId?: boolean; - mpesaId?: boolean; + reference?: boolean; lightning?: boolean; + collectionTracker?: boolean; rate?: boolean; + amountSats?: boolean; retryCount?: boolean; createdAt?: boolean; updatedAt?: boolean; @@ -1371,10 +1287,11 @@ export namespace Prisma { { id?: boolean; state?: boolean; - userId?: boolean; - mpesaId?: boolean; + reference?: boolean; lightning?: boolean; + collectionTracker?: boolean; rate?: boolean; + amountSats?: boolean; retryCount?: boolean; createdAt?: boolean; updatedAt?: boolean; @@ -1385,10 +1302,11 @@ export namespace Prisma { export type MpesaOnrampSwapSelectScalar = { id?: boolean; state?: boolean; - userId?: boolean; - mpesaId?: boolean; + reference?: boolean; lightning?: boolean; + collectionTracker?: boolean; rate?: boolean; + amountSats?: boolean; retryCount?: boolean; createdAt?: boolean; updatedAt?: boolean; @@ -1410,21 +1328,25 @@ export namespace Prisma { */ state: $Enums.SwapTransactionState; /** - * References the user who made the transaction. - */ - userId: string; - /** - * References the onramp Mpesa transaction ID. + * References the user who made the transaction */ - mpesaId: string; + reference: string; /** * Lightning invoice to pay. */ lightning: string; /** - * Fx Rate + * References the fiat onramp collection ID + */ + collectionTracker: string; + /** + * Fx Rate from */ rate: string; + /** + * Amount in satoshi + */ + amountSats: string; /** * Retry count tracker */ @@ -1944,10 +1866,11 @@ export namespace Prisma { interface MpesaOnrampSwapFieldRefs { readonly id: FieldRef<'MpesaOnrampSwap', 'String'>; readonly state: FieldRef<'MpesaOnrampSwap', 'SwapTransactionState'>; - readonly userId: FieldRef<'MpesaOnrampSwap', 'String'>; - readonly mpesaId: FieldRef<'MpesaOnrampSwap', 'String'>; + readonly reference: FieldRef<'MpesaOnrampSwap', 'String'>; readonly lightning: FieldRef<'MpesaOnrampSwap', 'String'>; + readonly collectionTracker: FieldRef<'MpesaOnrampSwap', 'String'>; readonly rate: FieldRef<'MpesaOnrampSwap', 'String'>; + readonly amountSats: FieldRef<'MpesaOnrampSwap', 'String'>; readonly retryCount: FieldRef<'MpesaOnrampSwap', 'Int'>; readonly createdAt: FieldRef<'MpesaOnrampSwap', 'DateTime'>; readonly updatedAt: FieldRef<'MpesaOnrampSwap', 'DateTime'>; @@ -2309,10 +2232,12 @@ export namespace Prisma { export type MpesaOfframpSwapMinAggregateOutputType = { id: string | null; state: $Enums.SwapTransactionState | null; - userId: string | null; - mpesaId: string | null; + reference: string | null; lightning: string | null; + phone: string | null; + paymentTracker: string | null; rate: string | null; + amountSats: string | null; retryCount: number | null; createdAt: Date | null; updatedAt: Date | null; @@ -2321,10 +2246,12 @@ export namespace Prisma { export type MpesaOfframpSwapMaxAggregateOutputType = { id: string | null; state: $Enums.SwapTransactionState | null; - userId: string | null; - mpesaId: string | null; + reference: string | null; lightning: string | null; + phone: string | null; + paymentTracker: string | null; rate: string | null; + amountSats: string | null; retryCount: number | null; createdAt: Date | null; updatedAt: Date | null; @@ -2333,10 +2260,12 @@ export namespace Prisma { export type MpesaOfframpSwapCountAggregateOutputType = { id: number; state: number; - userId: number; - mpesaId: number; + reference: number; lightning: number; + phone: number; + paymentTracker: number; rate: number; + amountSats: number; retryCount: number; createdAt: number; updatedAt: number; @@ -2354,10 +2283,12 @@ export namespace Prisma { export type MpesaOfframpSwapMinAggregateInputType = { id?: true; state?: true; - userId?: true; - mpesaId?: true; + reference?: true; lightning?: true; + phone?: true; + paymentTracker?: true; rate?: true; + amountSats?: true; retryCount?: true; createdAt?: true; updatedAt?: true; @@ -2366,10 +2297,12 @@ export namespace Prisma { export type MpesaOfframpSwapMaxAggregateInputType = { id?: true; state?: true; - userId?: true; - mpesaId?: true; + reference?: true; lightning?: true; + phone?: true; + paymentTracker?: true; rate?: true; + amountSats?: true; retryCount?: true; createdAt?: true; updatedAt?: true; @@ -2378,10 +2311,12 @@ export namespace Prisma { export type MpesaOfframpSwapCountAggregateInputType = { id?: true; state?: true; - userId?: true; - mpesaId?: true; + reference?: true; lightning?: true; + phone?: true; + paymentTracker?: true; rate?: true; + amountSats?: true; retryCount?: true; createdAt?: true; updatedAt?: true; @@ -2486,10 +2421,12 @@ export namespace Prisma { export type MpesaOfframpSwapGroupByOutputType = { id: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId: string | null; + reference: string; lightning: string; + phone: string; + paymentTracker: string | null; rate: string; + amountSats: string; retryCount: number; createdAt: Date; updatedAt: Date; @@ -2521,10 +2458,12 @@ export namespace Prisma { { id?: boolean; state?: boolean; - userId?: boolean; - mpesaId?: boolean; + reference?: boolean; lightning?: boolean; + phone?: boolean; + paymentTracker?: boolean; rate?: boolean; + amountSats?: boolean; retryCount?: boolean; createdAt?: boolean; updatedAt?: boolean; @@ -2538,10 +2477,12 @@ export namespace Prisma { { id?: boolean; state?: boolean; - userId?: boolean; - mpesaId?: boolean; + reference?: boolean; lightning?: boolean; + phone?: boolean; + paymentTracker?: boolean; rate?: boolean; + amountSats?: boolean; retryCount?: boolean; createdAt?: boolean; updatedAt?: boolean; @@ -2552,10 +2493,12 @@ export namespace Prisma { export type MpesaOfframpSwapSelectScalar = { id?: boolean; state?: boolean; - userId?: boolean; - mpesaId?: boolean; + reference?: boolean; lightning?: boolean; + phone?: boolean; + paymentTracker?: boolean; rate?: boolean; + amountSats?: boolean; retryCount?: boolean; createdAt?: boolean; updatedAt?: boolean; @@ -2577,21 +2520,29 @@ export namespace Prisma { */ state: $Enums.SwapTransactionState; /** - * References the user who made the transaction. + * References the user who made the transaction */ - userId: string; + reference: string; /** - * References the offramp Mpesa transaction ID. + * Lightning invoice to be paid before offramp can proceed */ - mpesaId: string | null; + lightning: string; /** - * Lightning invoice to be paid before invoice can proceed. + * Phone number to send mpesa the payment */ - lightning: string; + phone: string; + /** + * References the fiat offramp payment ID + */ + paymentTracker: string | null; /** * Fx Rate */ rate: string; + /** + * Amount in satoshi + */ + amountSats: string; /** * Retry count tracker */ @@ -3111,10 +3062,12 @@ export namespace Prisma { interface MpesaOfframpSwapFieldRefs { readonly id: FieldRef<'MpesaOfframpSwap', 'String'>; readonly state: FieldRef<'MpesaOfframpSwap', 'SwapTransactionState'>; - readonly userId: FieldRef<'MpesaOfframpSwap', 'String'>; - readonly mpesaId: FieldRef<'MpesaOfframpSwap', 'String'>; + readonly reference: FieldRef<'MpesaOfframpSwap', 'String'>; readonly lightning: FieldRef<'MpesaOfframpSwap', 'String'>; + readonly phone: FieldRef<'MpesaOfframpSwap', 'String'>; + readonly paymentTracker: FieldRef<'MpesaOfframpSwap', 'String'>; readonly rate: FieldRef<'MpesaOfframpSwap', 'String'>; + readonly amountSats: FieldRef<'MpesaOfframpSwap', 'String'>; readonly retryCount: FieldRef<'MpesaOfframpSwap', 'Int'>; readonly createdAt: FieldRef<'MpesaOfframpSwap', 'DateTime'>; readonly updatedAt: FieldRef<'MpesaOfframpSwap', 'DateTime'>; @@ -3460,1335 +3413,98 @@ export namespace Prisma { }; /** - * Model IntasendMpesaTransaction + * Enums */ - export type AggregateIntasendMpesaTransaction = { - _count: IntasendMpesaTransactionCountAggregateOutputType | null; - _avg: IntasendMpesaTransactionAvgAggregateOutputType | null; - _sum: IntasendMpesaTransactionSumAggregateOutputType | null; - _min: IntasendMpesaTransactionMinAggregateOutputType | null; - _max: IntasendMpesaTransactionMaxAggregateOutputType | null; - }; - - export type IntasendMpesaTransactionAvgAggregateOutputType = { - retryCount: number | null; - }; - - export type IntasendMpesaTransactionSumAggregateOutputType = { - retryCount: number | null; + export const TransactionIsolationLevel: { + ReadUncommitted: 'ReadUncommitted'; + ReadCommitted: 'ReadCommitted'; + RepeatableRead: 'RepeatableRead'; + Serializable: 'Serializable'; }; - export type IntasendMpesaTransactionMinAggregateOutputType = { - id: string | null; - state: $Enums.SwapTransactionState | null; - apiRef: string | null; - value: string | null; - charges: string | null; - netAmount: string | null; - currency: string | null; - account: string | null; - retryCount: number | null; - createdAt: string | null; - updatedAt: string | null; - }; + export type TransactionIsolationLevel = + (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]; - export type IntasendMpesaTransactionMaxAggregateOutputType = { - id: string | null; - state: $Enums.SwapTransactionState | null; - apiRef: string | null; - value: string | null; - charges: string | null; - netAmount: string | null; - currency: string | null; - account: string | null; - retryCount: number | null; - createdAt: string | null; - updatedAt: string | null; + export const MpesaOnrampSwapScalarFieldEnum: { + id: 'id'; + state: 'state'; + reference: 'reference'; + lightning: 'lightning'; + collectionTracker: 'collectionTracker'; + rate: 'rate'; + amountSats: 'amountSats'; + retryCount: 'retryCount'; + createdAt: 'createdAt'; + updatedAt: 'updatedAt'; }; - export type IntasendMpesaTransactionCountAggregateOutputType = { - id: number; - state: number; - apiRef: number; - value: number; - charges: number; - netAmount: number; - currency: number; - account: number; - retryCount: number; - createdAt: number; - updatedAt: number; - _all: number; - }; + export type MpesaOnrampSwapScalarFieldEnum = + (typeof MpesaOnrampSwapScalarFieldEnum)[keyof typeof MpesaOnrampSwapScalarFieldEnum]; - export type IntasendMpesaTransactionAvgAggregateInputType = { - retryCount?: true; + export const MpesaOfframpSwapScalarFieldEnum: { + id: 'id'; + state: 'state'; + reference: 'reference'; + lightning: 'lightning'; + phone: 'phone'; + paymentTracker: 'paymentTracker'; + rate: 'rate'; + amountSats: 'amountSats'; + retryCount: 'retryCount'; + createdAt: 'createdAt'; + updatedAt: 'updatedAt'; }; - export type IntasendMpesaTransactionSumAggregateInputType = { - retryCount?: true; - }; + export type MpesaOfframpSwapScalarFieldEnum = + (typeof MpesaOfframpSwapScalarFieldEnum)[keyof typeof MpesaOfframpSwapScalarFieldEnum]; - export type IntasendMpesaTransactionMinAggregateInputType = { - id?: true; - state?: true; - apiRef?: true; - value?: true; - charges?: true; - netAmount?: true; - currency?: true; - account?: true; - retryCount?: true; - createdAt?: true; - updatedAt?: true; + export const SortOrder: { + asc: 'asc'; + desc: 'desc'; }; - export type IntasendMpesaTransactionMaxAggregateInputType = { - id?: true; - state?: true; - apiRef?: true; - value?: true; - charges?: true; - netAmount?: true; - currency?: true; - account?: true; - retryCount?: true; - createdAt?: true; - updatedAt?: true; - }; + export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]; - export type IntasendMpesaTransactionCountAggregateInputType = { - id?: true; - state?: true; - apiRef?: true; - value?: true; - charges?: true; - netAmount?: true; - currency?: true; - account?: true; - retryCount?: true; - createdAt?: true; - updatedAt?: true; - _all?: true; + export const QueryMode: { + default: 'default'; + insensitive: 'insensitive'; }; - export type IntasendMpesaTransactionAggregateArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Filter which IntasendMpesaTransaction to aggregate. - */ - where?: IntasendMpesaTransactionWhereInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} - * - * Determine the order of IntasendMpesaTransactions to fetch. - */ - orderBy?: - | IntasendMpesaTransactionOrderByWithRelationInput - | IntasendMpesaTransactionOrderByWithRelationInput[]; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} - * - * Sets the start position - */ - cursor?: IntasendMpesaTransactionWhereUniqueInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Take `±n` IntasendMpesaTransactions from the position of the cursor. - */ - take?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Skip the first `n` IntasendMpesaTransactions. - */ - skip?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} - * - * Count returned IntasendMpesaTransactions - **/ - _count?: true | IntasendMpesaTransactionCountAggregateInputType; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} - * - * Select which fields to average - **/ - _avg?: IntasendMpesaTransactionAvgAggregateInputType; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} - * - * Select which fields to sum - **/ - _sum?: IntasendMpesaTransactionSumAggregateInputType; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} - * - * Select which fields to find the minimum value - **/ - _min?: IntasendMpesaTransactionMinAggregateInputType; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} - * - * Select which fields to find the maximum value - **/ - _max?: IntasendMpesaTransactionMaxAggregateInputType; - }; + export type QueryMode = (typeof QueryMode)[keyof typeof QueryMode]; - export type GetIntasendMpesaTransactionAggregateType< - T extends IntasendMpesaTransactionAggregateArgs, - > = { - [P in keyof T & keyof AggregateIntasendMpesaTransaction]: P extends - | '_count' - | 'count' - ? T[P] extends true - ? number - : GetScalarType - : GetScalarType; + export const NullsOrder: { + first: 'first'; + last: 'last'; }; - export type IntasendMpesaTransactionGroupByArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - where?: IntasendMpesaTransactionWhereInput; - orderBy?: - | IntasendMpesaTransactionOrderByWithAggregationInput - | IntasendMpesaTransactionOrderByWithAggregationInput[]; - by: - | IntasendMpesaTransactionScalarFieldEnum[] - | IntasendMpesaTransactionScalarFieldEnum; - having?: IntasendMpesaTransactionScalarWhereWithAggregatesInput; - take?: number; - skip?: number; - _count?: IntasendMpesaTransactionCountAggregateInputType | true; - _avg?: IntasendMpesaTransactionAvgAggregateInputType; - _sum?: IntasendMpesaTransactionSumAggregateInputType; - _min?: IntasendMpesaTransactionMinAggregateInputType; - _max?: IntasendMpesaTransactionMaxAggregateInputType; - }; + export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder]; - export type IntasendMpesaTransactionGroupByOutputType = { - id: string; - state: $Enums.SwapTransactionState; - apiRef: string; - value: string; - charges: string; - netAmount: string; - currency: string; - account: string; - retryCount: number; - createdAt: string; - updatedAt: string; - _count: IntasendMpesaTransactionCountAggregateOutputType | null; - _avg: IntasendMpesaTransactionAvgAggregateOutputType | null; - _sum: IntasendMpesaTransactionSumAggregateOutputType | null; - _min: IntasendMpesaTransactionMinAggregateOutputType | null; - _max: IntasendMpesaTransactionMaxAggregateOutputType | null; - }; + /** + * Field references + */ - type GetIntasendMpesaTransactionGroupByPayload< - T extends IntasendMpesaTransactionGroupByArgs, - > = Prisma.PrismaPromise< - Array< - PickEnumerable & { - [P in keyof T & - keyof IntasendMpesaTransactionGroupByOutputType]: P extends '_count' - ? T[P] extends boolean - ? number - : GetScalarType - : GetScalarType; - } - > + /** + * Reference to a field of type 'String' + */ + export type StringFieldRefInput<$PrismaModel> = FieldRefInputType< + $PrismaModel, + 'String' >; - export type IntasendMpesaTransactionSelect< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = $Extensions.GetSelect< - { - id?: boolean; - state?: boolean; - apiRef?: boolean; - value?: boolean; - charges?: boolean; - netAmount?: boolean; - currency?: boolean; - account?: boolean; - retryCount?: boolean; - createdAt?: boolean; - updatedAt?: boolean; - }, - ExtArgs['result']['intasendMpesaTransaction'] + /** + * Reference to a field of type 'String[]' + */ + export type ListStringFieldRefInput<$PrismaModel> = FieldRefInputType< + $PrismaModel, + 'String[]' >; - export type IntasendMpesaTransactionSelectCreateManyAndReturn< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = $Extensions.GetSelect< - { - id?: boolean; - state?: boolean; - apiRef?: boolean; - value?: boolean; - charges?: boolean; - netAmount?: boolean; - currency?: boolean; - account?: boolean; - retryCount?: boolean; - createdAt?: boolean; - updatedAt?: boolean; - }, - ExtArgs['result']['intasendMpesaTransaction'] - >; - - export type IntasendMpesaTransactionSelectScalar = { - id?: boolean; - state?: boolean; - apiRef?: boolean; - value?: boolean; - charges?: boolean; - netAmount?: boolean; - currency?: boolean; - account?: boolean; - retryCount?: boolean; - createdAt?: boolean; - updatedAt?: boolean; - }; - - export type $IntasendMpesaTransactionPayload< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - name: 'IntasendMpesaTransaction'; - objects: {}; - scalars: $Extensions.GetPayloadResult< - { - id: string; - state: $Enums.SwapTransactionState; - apiRef: string; - value: string; - charges: string; - netAmount: string; - currency: string; - account: string; - retryCount: number; - createdAt: string; - updatedAt: string; - }, - ExtArgs['result']['intasendMpesaTransaction'] - >; - composites: {}; - }; - - type IntasendMpesaTransactionGetPayload< - S extends boolean | null | undefined | IntasendMpesaTransactionDefaultArgs, - > = $Result.GetResult; - - type IntasendMpesaTransactionCountArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = Omit< - IntasendMpesaTransactionFindManyArgs, - 'select' | 'include' | 'distinct' - > & { - select?: IntasendMpesaTransactionCountAggregateInputType | true; - }; - - export interface IntasendMpesaTransactionDelegate< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > { - [K: symbol]: { - types: Prisma.TypeMap['model']['IntasendMpesaTransaction']; - meta: { name: 'IntasendMpesaTransaction' }; - }; - /** - * Find zero or one IntasendMpesaTransaction that matches the filter. - * @param {IntasendMpesaTransactionFindUniqueArgs} args - Arguments to find a IntasendMpesaTransaction - * @example - * // Get one IntasendMpesaTransaction - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.findUnique({ - * where: { - * // ... provide filter here - * } - * }) - */ - findUnique( - args: SelectSubset>, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'findUnique' - > | null, - null, - ExtArgs - >; - - /** - * Find one IntasendMpesaTransaction that matches the filter or throw an error with `error.code='P2025'` - * if no matches were found. - * @param {IntasendMpesaTransactionFindUniqueOrThrowArgs} args - Arguments to find a IntasendMpesaTransaction - * @example - * // Get one IntasendMpesaTransaction - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.findUniqueOrThrow({ - * where: { - * // ... provide filter here - * } - * }) - */ - findUniqueOrThrow( - args: SelectSubset< - T, - IntasendMpesaTransactionFindUniqueOrThrowArgs - >, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'findUniqueOrThrow' - >, - never, - ExtArgs - >; - - /** - * Find the first IntasendMpesaTransaction that matches the filter. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionFindFirstArgs} args - Arguments to find a IntasendMpesaTransaction - * @example - * // Get one IntasendMpesaTransaction - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.findFirst({ - * where: { - * // ... provide filter here - * } - * }) - */ - findFirst( - args?: SelectSubset>, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'findFirst' - > | null, - null, - ExtArgs - >; - - /** - * Find the first IntasendMpesaTransaction that matches the filter or - * throw `PrismaKnownClientError` with `P2025` code if no matches were found. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionFindFirstOrThrowArgs} args - Arguments to find a IntasendMpesaTransaction - * @example - * // Get one IntasendMpesaTransaction - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.findFirstOrThrow({ - * where: { - * // ... provide filter here - * } - * }) - */ - findFirstOrThrow( - args?: SelectSubset< - T, - IntasendMpesaTransactionFindFirstOrThrowArgs - >, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'findFirstOrThrow' - >, - never, - ExtArgs - >; - - /** - * Find zero or more IntasendMpesaTransactions that matches the filter. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionFindManyArgs} args - Arguments to filter and select certain fields only. - * @example - * // Get all IntasendMpesaTransactions - * const intasendMpesaTransactions = await prisma.intasendMpesaTransaction.findMany() - * - * // Get first 10 IntasendMpesaTransactions - * const intasendMpesaTransactions = await prisma.intasendMpesaTransaction.findMany({ take: 10 }) - * - * // Only select the `id` - * const intasendMpesaTransactionWithIdOnly = await prisma.intasendMpesaTransaction.findMany({ select: { id: true } }) - * - */ - findMany( - args?: SelectSubset>, - ): Prisma.PrismaPromise< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'findMany' - > - >; - - /** - * Create a IntasendMpesaTransaction. - * @param {IntasendMpesaTransactionCreateArgs} args - Arguments to create a IntasendMpesaTransaction. - * @example - * // Create one IntasendMpesaTransaction - * const IntasendMpesaTransaction = await prisma.intasendMpesaTransaction.create({ - * data: { - * // ... data to create a IntasendMpesaTransaction - * } - * }) - * - */ - create( - args: SelectSubset>, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'create' - >, - never, - ExtArgs - >; - - /** - * Create many IntasendMpesaTransactions. - * @param {IntasendMpesaTransactionCreateManyArgs} args - Arguments to create many IntasendMpesaTransactions. - * @example - * // Create many IntasendMpesaTransactions - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.createMany({ - * data: [ - * // ... provide data here - * ] - * }) - * - */ - createMany( - args?: SelectSubset>, - ): Prisma.PrismaPromise; - - /** - * Create many IntasendMpesaTransactions and returns the data saved in the database. - * @param {IntasendMpesaTransactionCreateManyAndReturnArgs} args - Arguments to create many IntasendMpesaTransactions. - * @example - * // Create many IntasendMpesaTransactions - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.createManyAndReturn({ - * data: [ - * // ... provide data here - * ] - * }) - * - * // Create many IntasendMpesaTransactions and only return the `id` - * const intasendMpesaTransactionWithIdOnly = await prisma.intasendMpesaTransaction.createManyAndReturn({ - * select: { id: true }, - * data: [ - * // ... provide data here - * ] - * }) - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * - */ - createManyAndReturn< - T extends IntasendMpesaTransactionCreateManyAndReturnArgs, - >( - args?: SelectSubset< - T, - IntasendMpesaTransactionCreateManyAndReturnArgs - >, - ): Prisma.PrismaPromise< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'createManyAndReturn' - > - >; - - /** - * Delete a IntasendMpesaTransaction. - * @param {IntasendMpesaTransactionDeleteArgs} args - Arguments to delete one IntasendMpesaTransaction. - * @example - * // Delete one IntasendMpesaTransaction - * const IntasendMpesaTransaction = await prisma.intasendMpesaTransaction.delete({ - * where: { - * // ... filter to delete one IntasendMpesaTransaction - * } - * }) - * - */ - delete( - args: SelectSubset>, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'delete' - >, - never, - ExtArgs - >; - - /** - * Update one IntasendMpesaTransaction. - * @param {IntasendMpesaTransactionUpdateArgs} args - Arguments to update one IntasendMpesaTransaction. - * @example - * // Update one IntasendMpesaTransaction - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.update({ - * where: { - * // ... provide filter here - * }, - * data: { - * // ... provide data here - * } - * }) - * - */ - update( - args: SelectSubset>, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'update' - >, - never, - ExtArgs - >; - - /** - * Delete zero or more IntasendMpesaTransactions. - * @param {IntasendMpesaTransactionDeleteManyArgs} args - Arguments to filter IntasendMpesaTransactions to delete. - * @example - * // Delete a few IntasendMpesaTransactions - * const { count } = await prisma.intasendMpesaTransaction.deleteMany({ - * where: { - * // ... provide filter here - * } - * }) - * - */ - deleteMany( - args?: SelectSubset>, - ): Prisma.PrismaPromise; - - /** - * Update zero or more IntasendMpesaTransactions. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionUpdateManyArgs} args - Arguments to update one or more rows. - * @example - * // Update many IntasendMpesaTransactions - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.updateMany({ - * where: { - * // ... provide filter here - * }, - * data: { - * // ... provide data here - * } - * }) - * - */ - updateMany( - args: SelectSubset>, - ): Prisma.PrismaPromise; - - /** - * Create or update one IntasendMpesaTransaction. - * @param {IntasendMpesaTransactionUpsertArgs} args - Arguments to update or create a IntasendMpesaTransaction. - * @example - * // Update or create a IntasendMpesaTransaction - * const intasendMpesaTransaction = await prisma.intasendMpesaTransaction.upsert({ - * create: { - * // ... data to create a IntasendMpesaTransaction - * }, - * update: { - * // ... in case it already exists, update - * }, - * where: { - * // ... the filter for the IntasendMpesaTransaction we want to update - * } - * }) - */ - upsert( - args: SelectSubset>, - ): Prisma__IntasendMpesaTransactionClient< - $Result.GetResult< - Prisma.$IntasendMpesaTransactionPayload, - T, - 'upsert' - >, - never, - ExtArgs - >; - - /** - * Count the number of IntasendMpesaTransactions. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionCountArgs} args - Arguments to filter IntasendMpesaTransactions to count. - * @example - * // Count the number of IntasendMpesaTransactions - * const count = await prisma.intasendMpesaTransaction.count({ - * where: { - * // ... the filter for the IntasendMpesaTransactions we want to count - * } - * }) - **/ - count( - args?: Subset, - ): Prisma.PrismaPromise< - T extends $Utils.Record<'select', any> - ? T['select'] extends true - ? number - : GetScalarType< - T['select'], - IntasendMpesaTransactionCountAggregateOutputType - > - : number - >; - - /** - * Allows you to perform aggregations operations on a IntasendMpesaTransaction. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionAggregateArgs} args - Select which aggregations you would like to apply and on what fields. - * @example - * // Ordered by age ascending - * // Where email contains prisma.io - * // Limited to the 10 users - * const aggregations = await prisma.user.aggregate({ - * _avg: { - * age: true, - * }, - * where: { - * email: { - * contains: "prisma.io", - * }, - * }, - * orderBy: { - * age: "asc", - * }, - * take: 10, - * }) - **/ - aggregate( - args: Subset, - ): Prisma.PrismaPromise>; - - /** - * Group by IntasendMpesaTransaction. - * Note, that providing `undefined` is treated as the value not being there. - * Read more here: https://pris.ly/d/null-undefined - * @param {IntasendMpesaTransactionGroupByArgs} args - Group by arguments. - * @example - * // Group by city, order by createdAt, get count - * const result = await prisma.user.groupBy({ - * by: ['city', 'createdAt'], - * orderBy: { - * createdAt: true - * }, - * _count: { - * _all: true - * }, - * }) - * - **/ - groupBy< - T extends IntasendMpesaTransactionGroupByArgs, - HasSelectOrTake extends Or< - Extends<'skip', Keys>, - Extends<'take', Keys> - >, - OrderByArg extends True extends HasSelectOrTake - ? { orderBy: IntasendMpesaTransactionGroupByArgs['orderBy'] } - : { orderBy?: IntasendMpesaTransactionGroupByArgs['orderBy'] }, - OrderFields extends ExcludeUnderscoreKeys< - Keys> - >, - ByFields extends MaybeTupleToUnion, - ByValid extends Has, - HavingFields extends GetHavingFields, - HavingValid extends Has, - ByEmpty extends T['by'] extends never[] ? True : False, - InputErrors extends ByEmpty extends True - ? `Error: "by" must not be empty.` - : HavingValid extends False - ? { - [P in HavingFields]: P extends ByFields - ? never - : P extends string - ? `Error: Field "${P}" used in "having" needs to be provided in "by".` - : [ - Error, - 'Field ', - P, - ` in "having" needs to be provided in "by"`, - ]; - }[HavingFields] - : 'take' extends Keys - ? 'orderBy' extends Keys - ? ByValid extends True - ? {} - : { - [P in OrderFields]: P extends ByFields - ? never - : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; - }[OrderFields] - : 'Error: If you provide "take", you also need to provide "orderBy"' - : 'skip' extends Keys - ? 'orderBy' extends Keys - ? ByValid extends True - ? {} - : { - [P in OrderFields]: P extends ByFields - ? never - : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; - }[OrderFields] - : 'Error: If you provide "skip", you also need to provide "orderBy"' - : ByValid extends True - ? {} - : { - [P in OrderFields]: P extends ByFields - ? never - : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; - }[OrderFields], - >( - args: SubsetIntersection< - T, - IntasendMpesaTransactionGroupByArgs, - OrderByArg - > & - InputErrors, - ): {} extends InputErrors - ? GetIntasendMpesaTransactionGroupByPayload - : Prisma.PrismaPromise; - /** - * Fields of the IntasendMpesaTransaction model - */ - readonly fields: IntasendMpesaTransactionFieldRefs; - } - - /** - * The delegate class that acts as a "Promise-like" for IntasendMpesaTransaction. - * Why is this prefixed with `Prisma__`? - * Because we want to prevent naming conflicts as mentioned in - * https://github.com/prisma/prisma-client-js/issues/707 - */ - export interface Prisma__IntasendMpesaTransactionClient< - T, - Null = never, - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > extends Prisma.PrismaPromise { - readonly [Symbol.toStringTag]: 'PrismaPromise'; - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then( - onfulfilled?: - | ((value: T) => TResult1 | PromiseLike) - | undefined - | null, - onrejected?: - | ((reason: any) => TResult2 | PromiseLike) - | undefined - | null, - ): $Utils.JsPromise; - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch( - onrejected?: - | ((reason: any) => TResult | PromiseLike) - | undefined - | null, - ): $Utils.JsPromise; - /** - * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The - * resolved value cannot be modified from the callback. - * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). - * @returns A Promise for the completion of the callback. - */ - finally(onfinally?: (() => void) | undefined | null): $Utils.JsPromise; - } - - /** - * Fields of the IntasendMpesaTransaction model - */ - interface IntasendMpesaTransactionFieldRefs { - readonly id: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly state: FieldRef< - 'IntasendMpesaTransaction', - 'SwapTransactionState' - >; - readonly apiRef: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly value: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly charges: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly netAmount: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly currency: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly account: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly retryCount: FieldRef<'IntasendMpesaTransaction', 'Int'>; - readonly createdAt: FieldRef<'IntasendMpesaTransaction', 'String'>; - readonly updatedAt: FieldRef<'IntasendMpesaTransaction', 'String'>; - } - - // Custom InputTypes - /** - * IntasendMpesaTransaction findUnique - */ - export type IntasendMpesaTransactionFindUniqueArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * Filter, which IntasendMpesaTransaction to fetch. - */ - where: IntasendMpesaTransactionWhereUniqueInput; - }; - - /** - * IntasendMpesaTransaction findUniqueOrThrow - */ - export type IntasendMpesaTransactionFindUniqueOrThrowArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * Filter, which IntasendMpesaTransaction to fetch. - */ - where: IntasendMpesaTransactionWhereUniqueInput; - }; - - /** - * IntasendMpesaTransaction findFirst - */ - export type IntasendMpesaTransactionFindFirstArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * Filter, which IntasendMpesaTransaction to fetch. - */ - where?: IntasendMpesaTransactionWhereInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} - * - * Determine the order of IntasendMpesaTransactions to fetch. - */ - orderBy?: - | IntasendMpesaTransactionOrderByWithRelationInput - | IntasendMpesaTransactionOrderByWithRelationInput[]; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} - * - * Sets the position for searching for IntasendMpesaTransactions. - */ - cursor?: IntasendMpesaTransactionWhereUniqueInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Take `±n` IntasendMpesaTransactions from the position of the cursor. - */ - take?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Skip the first `n` IntasendMpesaTransactions. - */ - skip?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} - * - * Filter by unique combinations of IntasendMpesaTransactions. - */ - distinct?: - | IntasendMpesaTransactionScalarFieldEnum - | IntasendMpesaTransactionScalarFieldEnum[]; - }; - - /** - * IntasendMpesaTransaction findFirstOrThrow - */ - export type IntasendMpesaTransactionFindFirstOrThrowArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * Filter, which IntasendMpesaTransaction to fetch. - */ - where?: IntasendMpesaTransactionWhereInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} - * - * Determine the order of IntasendMpesaTransactions to fetch. - */ - orderBy?: - | IntasendMpesaTransactionOrderByWithRelationInput - | IntasendMpesaTransactionOrderByWithRelationInput[]; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} - * - * Sets the position for searching for IntasendMpesaTransactions. - */ - cursor?: IntasendMpesaTransactionWhereUniqueInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Take `±n` IntasendMpesaTransactions from the position of the cursor. - */ - take?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Skip the first `n` IntasendMpesaTransactions. - */ - skip?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} - * - * Filter by unique combinations of IntasendMpesaTransactions. - */ - distinct?: - | IntasendMpesaTransactionScalarFieldEnum - | IntasendMpesaTransactionScalarFieldEnum[]; - }; - - /** - * IntasendMpesaTransaction findMany - */ - export type IntasendMpesaTransactionFindManyArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * Filter, which IntasendMpesaTransactions to fetch. - */ - where?: IntasendMpesaTransactionWhereInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} - * - * Determine the order of IntasendMpesaTransactions to fetch. - */ - orderBy?: - | IntasendMpesaTransactionOrderByWithRelationInput - | IntasendMpesaTransactionOrderByWithRelationInput[]; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} - * - * Sets the position for listing IntasendMpesaTransactions. - */ - cursor?: IntasendMpesaTransactionWhereUniqueInput; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Take `±n` IntasendMpesaTransactions from the position of the cursor. - */ - take?: number; - /** - * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} - * - * Skip the first `n` IntasendMpesaTransactions. - */ - skip?: number; - distinct?: - | IntasendMpesaTransactionScalarFieldEnum - | IntasendMpesaTransactionScalarFieldEnum[]; - }; - - /** - * IntasendMpesaTransaction create - */ - export type IntasendMpesaTransactionCreateArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * The data needed to create a IntasendMpesaTransaction. - */ - data: XOR< - IntasendMpesaTransactionCreateInput, - IntasendMpesaTransactionUncheckedCreateInput - >; - }; - - /** - * IntasendMpesaTransaction createMany - */ - export type IntasendMpesaTransactionCreateManyArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * The data used to create many IntasendMpesaTransactions. - */ - data: - | IntasendMpesaTransactionCreateManyInput - | IntasendMpesaTransactionCreateManyInput[]; - skipDuplicates?: boolean; - }; - - /** - * IntasendMpesaTransaction createManyAndReturn - */ - export type IntasendMpesaTransactionCreateManyAndReturnArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelectCreateManyAndReturn | null; - /** - * The data used to create many IntasendMpesaTransactions. - */ - data: - | IntasendMpesaTransactionCreateManyInput - | IntasendMpesaTransactionCreateManyInput[]; - skipDuplicates?: boolean; - }; - - /** - * IntasendMpesaTransaction update - */ - export type IntasendMpesaTransactionUpdateArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * The data needed to update a IntasendMpesaTransaction. - */ - data: XOR< - IntasendMpesaTransactionUpdateInput, - IntasendMpesaTransactionUncheckedUpdateInput - >; - /** - * Choose, which IntasendMpesaTransaction to update. - */ - where: IntasendMpesaTransactionWhereUniqueInput; - }; - - /** - * IntasendMpesaTransaction updateMany - */ - export type IntasendMpesaTransactionUpdateManyArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * The data used to update IntasendMpesaTransactions. - */ - data: XOR< - IntasendMpesaTransactionUpdateManyMutationInput, - IntasendMpesaTransactionUncheckedUpdateManyInput - >; - /** - * Filter which IntasendMpesaTransactions to update - */ - where?: IntasendMpesaTransactionWhereInput; - }; - - /** - * IntasendMpesaTransaction upsert - */ - export type IntasendMpesaTransactionUpsertArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * The filter to search for the IntasendMpesaTransaction to update in case it exists. - */ - where: IntasendMpesaTransactionWhereUniqueInput; - /** - * In case the IntasendMpesaTransaction found by the `where` argument doesn't exist, create a new IntasendMpesaTransaction with this data. - */ - create: XOR< - IntasendMpesaTransactionCreateInput, - IntasendMpesaTransactionUncheckedCreateInput - >; - /** - * In case the IntasendMpesaTransaction was found with the provided `where` argument, update it with this data. - */ - update: XOR< - IntasendMpesaTransactionUpdateInput, - IntasendMpesaTransactionUncheckedUpdateInput - >; - }; - - /** - * IntasendMpesaTransaction delete - */ - export type IntasendMpesaTransactionDeleteArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - /** - * Filter which IntasendMpesaTransaction to delete. - */ - where: IntasendMpesaTransactionWhereUniqueInput; - }; - - /** - * IntasendMpesaTransaction deleteMany - */ - export type IntasendMpesaTransactionDeleteManyArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Filter which IntasendMpesaTransactions to delete - */ - where?: IntasendMpesaTransactionWhereInput; - }; - - /** - * IntasendMpesaTransaction without action - */ - export type IntasendMpesaTransactionDefaultArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = { - /** - * Select specific fields to fetch from the IntasendMpesaTransaction - */ - select?: IntasendMpesaTransactionSelect | null; - }; - - /** - * Enums - */ - - export const TransactionIsolationLevel: { - ReadUncommitted: 'ReadUncommitted'; - ReadCommitted: 'ReadCommitted'; - RepeatableRead: 'RepeatableRead'; - Serializable: 'Serializable'; - }; - - export type TransactionIsolationLevel = - (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]; - - export const MpesaOnrampSwapScalarFieldEnum: { - id: 'id'; - state: 'state'; - userId: 'userId'; - mpesaId: 'mpesaId'; - lightning: 'lightning'; - rate: 'rate'; - retryCount: 'retryCount'; - createdAt: 'createdAt'; - updatedAt: 'updatedAt'; - }; - - export type MpesaOnrampSwapScalarFieldEnum = - (typeof MpesaOnrampSwapScalarFieldEnum)[keyof typeof MpesaOnrampSwapScalarFieldEnum]; - - export const MpesaOfframpSwapScalarFieldEnum: { - id: 'id'; - state: 'state'; - userId: 'userId'; - mpesaId: 'mpesaId'; - lightning: 'lightning'; - rate: 'rate'; - retryCount: 'retryCount'; - createdAt: 'createdAt'; - updatedAt: 'updatedAt'; - }; - - export type MpesaOfframpSwapScalarFieldEnum = - (typeof MpesaOfframpSwapScalarFieldEnum)[keyof typeof MpesaOfframpSwapScalarFieldEnum]; - - export const IntasendMpesaTransactionScalarFieldEnum: { - id: 'id'; - state: 'state'; - apiRef: 'apiRef'; - value: 'value'; - charges: 'charges'; - netAmount: 'netAmount'; - currency: 'currency'; - account: 'account'; - retryCount: 'retryCount'; - createdAt: 'createdAt'; - updatedAt: 'updatedAt'; - }; - - export type IntasendMpesaTransactionScalarFieldEnum = - (typeof IntasendMpesaTransactionScalarFieldEnum)[keyof typeof IntasendMpesaTransactionScalarFieldEnum]; - - export const SortOrder: { - asc: 'asc'; - desc: 'desc'; - }; - - export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]; - - export const QueryMode: { - default: 'default'; - insensitive: 'insensitive'; - }; - - export type QueryMode = (typeof QueryMode)[keyof typeof QueryMode]; - - export const NullsOrder: { - first: 'first'; - last: 'last'; - }; - - export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder]; - - /** - * Field references - */ - - /** - * Reference to a field of type 'String' - */ - export type StringFieldRefInput<$PrismaModel> = FieldRefInputType< - $PrismaModel, - 'String' - >; - - /** - * Reference to a field of type 'String[]' - */ - export type ListStringFieldRefInput<$PrismaModel> = FieldRefInputType< - $PrismaModel, - 'String[]' - >; - - /** - * Reference to a field of type 'SwapTransactionState' - */ - export type EnumSwapTransactionStateFieldRefInput<$PrismaModel> = - FieldRefInputType<$PrismaModel, 'SwapTransactionState'>; + /** + * Reference to a field of type 'SwapTransactionState' + */ + export type EnumSwapTransactionStateFieldRefInput<$PrismaModel> = + FieldRefInputType<$PrismaModel, 'SwapTransactionState'>; /** * Reference to a field of type 'SwapTransactionState[]' @@ -4856,10 +3572,11 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFilter<'MpesaOnrampSwap'> | $Enums.SwapTransactionState; - userId?: StringFilter<'MpesaOnrampSwap'> | string; - mpesaId?: StringFilter<'MpesaOnrampSwap'> | string; + reference?: StringFilter<'MpesaOnrampSwap'> | string; lightning?: StringFilter<'MpesaOnrampSwap'> | string; + collectionTracker?: StringFilter<'MpesaOnrampSwap'> | string; rate?: StringFilter<'MpesaOnrampSwap'> | string; + amountSats?: StringFilter<'MpesaOnrampSwap'> | string; retryCount?: IntFilter<'MpesaOnrampSwap'> | number; createdAt?: DateTimeFilter<'MpesaOnrampSwap'> | Date | string; updatedAt?: DateTimeFilter<'MpesaOnrampSwap'> | Date | string; @@ -4868,10 +3585,11 @@ export namespace Prisma { export type MpesaOnrampSwapOrderByWithRelationInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + collectionTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -4880,30 +3598,32 @@ export namespace Prisma { export type MpesaOnrampSwapWhereUniqueInput = Prisma.AtLeast< { id?: string; - mpesaId?: string; + collectionTracker?: string; AND?: MpesaOnrampSwapWhereInput | MpesaOnrampSwapWhereInput[]; OR?: MpesaOnrampSwapWhereInput[]; NOT?: MpesaOnrampSwapWhereInput | MpesaOnrampSwapWhereInput[]; state?: | EnumSwapTransactionStateFilter<'MpesaOnrampSwap'> | $Enums.SwapTransactionState; - userId?: StringFilter<'MpesaOnrampSwap'> | string; + reference?: StringFilter<'MpesaOnrampSwap'> | string; lightning?: StringFilter<'MpesaOnrampSwap'> | string; rate?: StringFilter<'MpesaOnrampSwap'> | string; + amountSats?: StringFilter<'MpesaOnrampSwap'> | string; retryCount?: IntFilter<'MpesaOnrampSwap'> | number; createdAt?: DateTimeFilter<'MpesaOnrampSwap'> | Date | string; updatedAt?: DateTimeFilter<'MpesaOnrampSwap'> | Date | string; }, - 'id' | 'mpesaId' + 'id' | 'collectionTracker' >; export type MpesaOnrampSwapOrderByWithAggregationInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + collectionTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -4926,10 +3646,11 @@ export namespace Prisma { state?: | EnumSwapTransactionStateWithAggregatesFilter<'MpesaOnrampSwap'> | $Enums.SwapTransactionState; - userId?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; - mpesaId?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; + reference?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; lightning?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; + collectionTracker?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; rate?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; + amountSats?: StringWithAggregatesFilter<'MpesaOnrampSwap'> | string; retryCount?: IntWithAggregatesFilter<'MpesaOnrampSwap'> | number; createdAt?: DateTimeWithAggregatesFilter<'MpesaOnrampSwap'> | Date | string; updatedAt?: DateTimeWithAggregatesFilter<'MpesaOnrampSwap'> | Date | string; @@ -4943,10 +3664,12 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFilter<'MpesaOfframpSwap'> | $Enums.SwapTransactionState; - userId?: StringFilter<'MpesaOfframpSwap'> | string; - mpesaId?: StringNullableFilter<'MpesaOfframpSwap'> | string | null; + reference?: StringFilter<'MpesaOfframpSwap'> | string; lightning?: StringFilter<'MpesaOfframpSwap'> | string; + phone?: StringFilter<'MpesaOfframpSwap'> | string; + paymentTracker?: StringNullableFilter<'MpesaOfframpSwap'> | string | null; rate?: StringFilter<'MpesaOfframpSwap'> | string; + amountSats?: StringFilter<'MpesaOfframpSwap'> | string; retryCount?: IntFilter<'MpesaOfframpSwap'> | number; createdAt?: DateTimeFilter<'MpesaOfframpSwap'> | Date | string; updatedAt?: DateTimeFilter<'MpesaOfframpSwap'> | Date | string; @@ -4955,10 +3678,12 @@ export namespace Prisma { export type MpesaOfframpSwapOrderByWithRelationInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrderInput | SortOrder; + reference?: SortOrder; lightning?: SortOrder; + phone?: SortOrder; + paymentTracker?: SortOrderInput | SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -4967,30 +3692,34 @@ export namespace Prisma { export type MpesaOfframpSwapWhereUniqueInput = Prisma.AtLeast< { id?: string; - mpesaId?: string; + paymentTracker?: string; AND?: MpesaOfframpSwapWhereInput | MpesaOfframpSwapWhereInput[]; OR?: MpesaOfframpSwapWhereInput[]; NOT?: MpesaOfframpSwapWhereInput | MpesaOfframpSwapWhereInput[]; state?: | EnumSwapTransactionStateFilter<'MpesaOfframpSwap'> | $Enums.SwapTransactionState; - userId?: StringFilter<'MpesaOfframpSwap'> | string; + reference?: StringFilter<'MpesaOfframpSwap'> | string; lightning?: StringFilter<'MpesaOfframpSwap'> | string; + phone?: StringFilter<'MpesaOfframpSwap'> | string; rate?: StringFilter<'MpesaOfframpSwap'> | string; + amountSats?: StringFilter<'MpesaOfframpSwap'> | string; retryCount?: IntFilter<'MpesaOfframpSwap'> | number; createdAt?: DateTimeFilter<'MpesaOfframpSwap'> | Date | string; updatedAt?: DateTimeFilter<'MpesaOfframpSwap'> | Date | string; }, - 'id' | 'mpesaId' + 'id' | 'paymentTracker' >; export type MpesaOfframpSwapOrderByWithAggregationInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrderInput | SortOrder; + reference?: SortOrder; lightning?: SortOrder; + phone?: SortOrder; + paymentTracker?: SortOrderInput | SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5013,13 +3742,15 @@ export namespace Prisma { state?: | EnumSwapTransactionStateWithAggregatesFilter<'MpesaOfframpSwap'> | $Enums.SwapTransactionState; - userId?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; - mpesaId?: + reference?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; + lightning?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; + phone?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; + paymentTracker?: | StringNullableWithAggregatesFilter<'MpesaOfframpSwap'> | string | null; - lightning?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; rate?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; + amountSats?: StringWithAggregatesFilter<'MpesaOfframpSwap'> | string; retryCount?: IntWithAggregatesFilter<'MpesaOfframpSwap'> | number; createdAt?: | DateTimeWithAggregatesFilter<'MpesaOfframpSwap'> @@ -5031,118 +3762,14 @@ export namespace Prisma { | string; }; - export type IntasendMpesaTransactionWhereInput = { - AND?: - | IntasendMpesaTransactionWhereInput - | IntasendMpesaTransactionWhereInput[]; - OR?: IntasendMpesaTransactionWhereInput[]; - NOT?: - | IntasendMpesaTransactionWhereInput - | IntasendMpesaTransactionWhereInput[]; - id?: StringFilter<'IntasendMpesaTransaction'> | string; - state?: - | EnumSwapTransactionStateFilter<'IntasendMpesaTransaction'> - | $Enums.SwapTransactionState; - apiRef?: StringFilter<'IntasendMpesaTransaction'> | string; - value?: StringFilter<'IntasendMpesaTransaction'> | string; - charges?: StringFilter<'IntasendMpesaTransaction'> | string; - netAmount?: StringFilter<'IntasendMpesaTransaction'> | string; - currency?: StringFilter<'IntasendMpesaTransaction'> | string; - account?: StringFilter<'IntasendMpesaTransaction'> | string; - retryCount?: IntFilter<'IntasendMpesaTransaction'> | number; - createdAt?: StringFilter<'IntasendMpesaTransaction'> | string; - updatedAt?: StringFilter<'IntasendMpesaTransaction'> | string; - }; - - export type IntasendMpesaTransactionOrderByWithRelationInput = { - id?: SortOrder; - state?: SortOrder; - apiRef?: SortOrder; - value?: SortOrder; - charges?: SortOrder; - netAmount?: SortOrder; - currency?: SortOrder; - account?: SortOrder; - retryCount?: SortOrder; - createdAt?: SortOrder; - updatedAt?: SortOrder; - }; - - export type IntasendMpesaTransactionWhereUniqueInput = Prisma.AtLeast< - { - id?: string; - AND?: - | IntasendMpesaTransactionWhereInput - | IntasendMpesaTransactionWhereInput[]; - OR?: IntasendMpesaTransactionWhereInput[]; - NOT?: - | IntasendMpesaTransactionWhereInput - | IntasendMpesaTransactionWhereInput[]; - state?: - | EnumSwapTransactionStateFilter<'IntasendMpesaTransaction'> - | $Enums.SwapTransactionState; - apiRef?: StringFilter<'IntasendMpesaTransaction'> | string; - value?: StringFilter<'IntasendMpesaTransaction'> | string; - charges?: StringFilter<'IntasendMpesaTransaction'> | string; - netAmount?: StringFilter<'IntasendMpesaTransaction'> | string; - currency?: StringFilter<'IntasendMpesaTransaction'> | string; - account?: StringFilter<'IntasendMpesaTransaction'> | string; - retryCount?: IntFilter<'IntasendMpesaTransaction'> | number; - createdAt?: StringFilter<'IntasendMpesaTransaction'> | string; - updatedAt?: StringFilter<'IntasendMpesaTransaction'> | string; - }, - 'id' - >; - - export type IntasendMpesaTransactionOrderByWithAggregationInput = { - id?: SortOrder; - state?: SortOrder; - apiRef?: SortOrder; - value?: SortOrder; - charges?: SortOrder; - netAmount?: SortOrder; - currency?: SortOrder; - account?: SortOrder; - retryCount?: SortOrder; - createdAt?: SortOrder; - updatedAt?: SortOrder; - _count?: IntasendMpesaTransactionCountOrderByAggregateInput; - _avg?: IntasendMpesaTransactionAvgOrderByAggregateInput; - _max?: IntasendMpesaTransactionMaxOrderByAggregateInput; - _min?: IntasendMpesaTransactionMinOrderByAggregateInput; - _sum?: IntasendMpesaTransactionSumOrderByAggregateInput; - }; - - export type IntasendMpesaTransactionScalarWhereWithAggregatesInput = { - AND?: - | IntasendMpesaTransactionScalarWhereWithAggregatesInput - | IntasendMpesaTransactionScalarWhereWithAggregatesInput[]; - OR?: IntasendMpesaTransactionScalarWhereWithAggregatesInput[]; - NOT?: - | IntasendMpesaTransactionScalarWhereWithAggregatesInput - | IntasendMpesaTransactionScalarWhereWithAggregatesInput[]; - id?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - state?: - | EnumSwapTransactionStateWithAggregatesFilter<'IntasendMpesaTransaction'> - | $Enums.SwapTransactionState; - apiRef?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - value?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - charges?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - netAmount?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - currency?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - account?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - retryCount?: IntWithAggregatesFilter<'IntasendMpesaTransaction'> | number; - createdAt?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - updatedAt?: StringWithAggregatesFilter<'IntasendMpesaTransaction'> | string; - }; - export type MpesaOnrampSwapCreateInput = { id?: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId: string; + reference: string; lightning: string; + collectionTracker: string; rate: string; + amountSats: string; retryCount: number; createdAt?: Date | string; updatedAt?: Date | string; @@ -5151,10 +3778,11 @@ export namespace Prisma { export type MpesaOnrampSwapUncheckedCreateInput = { id?: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId: string; + reference: string; lightning: string; + collectionTracker: string; rate: string; + amountSats: string; retryCount: number; createdAt?: Date | string; updatedAt?: Date | string; @@ -5165,10 +3793,11 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: StringFieldUpdateOperationsInput | string; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + collectionTracker?: StringFieldUpdateOperationsInput | string; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5179,10 +3808,11 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: StringFieldUpdateOperationsInput | string; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + collectionTracker?: StringFieldUpdateOperationsInput | string; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5191,10 +3821,11 @@ export namespace Prisma { export type MpesaOnrampSwapCreateManyInput = { id?: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId: string; + reference: string; lightning: string; + collectionTracker: string; rate: string; + amountSats: string; retryCount: number; createdAt?: Date | string; updatedAt?: Date | string; @@ -5205,10 +3836,11 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: StringFieldUpdateOperationsInput | string; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + collectionTracker?: StringFieldUpdateOperationsInput | string; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5219,10 +3851,11 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: StringFieldUpdateOperationsInput | string; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + collectionTracker?: StringFieldUpdateOperationsInput | string; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5231,10 +3864,12 @@ export namespace Prisma { export type MpesaOfframpSwapCreateInput = { id: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId?: string | null; + reference: string; lightning: string; + phone: string; + paymentTracker?: string | null; rate: string; + amountSats: string; retryCount: number; createdAt?: Date | string; updatedAt?: Date | string; @@ -5243,10 +3878,12 @@ export namespace Prisma { export type MpesaOfframpSwapUncheckedCreateInput = { id: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId?: string | null; + reference: string; lightning: string; + phone: string; + paymentTracker?: string | null; rate: string; + amountSats: string; retryCount: number; createdAt?: Date | string; updatedAt?: Date | string; @@ -5257,10 +3894,12 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: NullableStringFieldUpdateOperationsInput | string | null; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + phone?: StringFieldUpdateOperationsInput | string; + paymentTracker?: NullableStringFieldUpdateOperationsInput | string | null; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5271,10 +3910,12 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: NullableStringFieldUpdateOperationsInput | string | null; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + phone?: StringFieldUpdateOperationsInput | string; + paymentTracker?: NullableStringFieldUpdateOperationsInput | string | null; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5283,10 +3924,12 @@ export namespace Prisma { export type MpesaOfframpSwapCreateManyInput = { id: string; state: $Enums.SwapTransactionState; - userId: string; - mpesaId?: string | null; + reference: string; lightning: string; + phone: string; + paymentTracker?: string | null; rate: string; + amountSats: string; retryCount: number; createdAt?: Date | string; updatedAt?: Date | string; @@ -5297,10 +3940,12 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: NullableStringFieldUpdateOperationsInput | string | null; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + phone?: StringFieldUpdateOperationsInput | string; + paymentTracker?: NullableStringFieldUpdateOperationsInput | string | null; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; @@ -5311,121 +3956,17 @@ export namespace Prisma { state?: | EnumSwapTransactionStateFieldUpdateOperationsInput | $Enums.SwapTransactionState; - userId?: StringFieldUpdateOperationsInput | string; - mpesaId?: NullableStringFieldUpdateOperationsInput | string | null; + reference?: StringFieldUpdateOperationsInput | string; lightning?: StringFieldUpdateOperationsInput | string; + phone?: StringFieldUpdateOperationsInput | string; + paymentTracker?: NullableStringFieldUpdateOperationsInput | string | null; rate?: StringFieldUpdateOperationsInput | string; + amountSats?: StringFieldUpdateOperationsInput | string; retryCount?: IntFieldUpdateOperationsInput | number; createdAt?: DateTimeFieldUpdateOperationsInput | Date | string; updatedAt?: DateTimeFieldUpdateOperationsInput | Date | string; }; - export type IntasendMpesaTransactionCreateInput = { - id?: string; - state: $Enums.SwapTransactionState; - apiRef: string; - value: string; - charges: string; - netAmount: string; - currency: string; - account: string; - retryCount: number; - createdAt: string; - updatedAt: string; - }; - - export type IntasendMpesaTransactionUncheckedCreateInput = { - id?: string; - state: $Enums.SwapTransactionState; - apiRef: string; - value: string; - charges: string; - netAmount: string; - currency: string; - account: string; - retryCount: number; - createdAt: string; - updatedAt: string; - }; - - export type IntasendMpesaTransactionUpdateInput = { - id?: StringFieldUpdateOperationsInput | string; - state?: - | EnumSwapTransactionStateFieldUpdateOperationsInput - | $Enums.SwapTransactionState; - apiRef?: StringFieldUpdateOperationsInput | string; - value?: StringFieldUpdateOperationsInput | string; - charges?: StringFieldUpdateOperationsInput | string; - netAmount?: StringFieldUpdateOperationsInput | string; - currency?: StringFieldUpdateOperationsInput | string; - account?: StringFieldUpdateOperationsInput | string; - retryCount?: IntFieldUpdateOperationsInput | number; - createdAt?: StringFieldUpdateOperationsInput | string; - updatedAt?: StringFieldUpdateOperationsInput | string; - }; - - export type IntasendMpesaTransactionUncheckedUpdateInput = { - id?: StringFieldUpdateOperationsInput | string; - state?: - | EnumSwapTransactionStateFieldUpdateOperationsInput - | $Enums.SwapTransactionState; - apiRef?: StringFieldUpdateOperationsInput | string; - value?: StringFieldUpdateOperationsInput | string; - charges?: StringFieldUpdateOperationsInput | string; - netAmount?: StringFieldUpdateOperationsInput | string; - currency?: StringFieldUpdateOperationsInput | string; - account?: StringFieldUpdateOperationsInput | string; - retryCount?: IntFieldUpdateOperationsInput | number; - createdAt?: StringFieldUpdateOperationsInput | string; - updatedAt?: StringFieldUpdateOperationsInput | string; - }; - - export type IntasendMpesaTransactionCreateManyInput = { - id?: string; - state: $Enums.SwapTransactionState; - apiRef: string; - value: string; - charges: string; - netAmount: string; - currency: string; - account: string; - retryCount: number; - createdAt: string; - updatedAt: string; - }; - - export type IntasendMpesaTransactionUpdateManyMutationInput = { - id?: StringFieldUpdateOperationsInput | string; - state?: - | EnumSwapTransactionStateFieldUpdateOperationsInput - | $Enums.SwapTransactionState; - apiRef?: StringFieldUpdateOperationsInput | string; - value?: StringFieldUpdateOperationsInput | string; - charges?: StringFieldUpdateOperationsInput | string; - netAmount?: StringFieldUpdateOperationsInput | string; - currency?: StringFieldUpdateOperationsInput | string; - account?: StringFieldUpdateOperationsInput | string; - retryCount?: IntFieldUpdateOperationsInput | number; - createdAt?: StringFieldUpdateOperationsInput | string; - updatedAt?: StringFieldUpdateOperationsInput | string; - }; - - export type IntasendMpesaTransactionUncheckedUpdateManyInput = { - id?: StringFieldUpdateOperationsInput | string; - state?: - | EnumSwapTransactionStateFieldUpdateOperationsInput - | $Enums.SwapTransactionState; - apiRef?: StringFieldUpdateOperationsInput | string; - value?: StringFieldUpdateOperationsInput | string; - charges?: StringFieldUpdateOperationsInput | string; - netAmount?: StringFieldUpdateOperationsInput | string; - currency?: StringFieldUpdateOperationsInput | string; - account?: StringFieldUpdateOperationsInput | string; - retryCount?: IntFieldUpdateOperationsInput | number; - createdAt?: StringFieldUpdateOperationsInput | string; - updatedAt?: StringFieldUpdateOperationsInput | string; - }; - export type StringFilter<$PrismaModel = never> = { equals?: string | StringFieldRefInput<$PrismaModel>; in?: string[] | ListStringFieldRefInput<$PrismaModel>; @@ -5481,10 +4022,11 @@ export namespace Prisma { export type MpesaOnrampSwapCountOrderByAggregateInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + collectionTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5497,10 +4039,11 @@ export namespace Prisma { export type MpesaOnrampSwapMaxOrderByAggregateInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + collectionTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5509,10 +4052,11 @@ export namespace Prisma { export type MpesaOnrampSwapMinOrderByAggregateInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + collectionTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5613,10 +4157,12 @@ export namespace Prisma { export type MpesaOfframpSwapCountOrderByAggregateInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + phone?: SortOrder; + paymentTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5629,10 +4175,12 @@ export namespace Prisma { export type MpesaOfframpSwapMaxOrderByAggregateInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + phone?: SortOrder; + paymentTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5641,10 +4189,12 @@ export namespace Prisma { export type MpesaOfframpSwapMinOrderByAggregateInput = { id?: SortOrder; state?: SortOrder; - userId?: SortOrder; - mpesaId?: SortOrder; + reference?: SortOrder; lightning?: SortOrder; + phone?: SortOrder; + paymentTracker?: SortOrder; rate?: SortOrder; + amountSats?: SortOrder; retryCount?: SortOrder; createdAt?: SortOrder; updatedAt?: SortOrder; @@ -5675,56 +4225,6 @@ export namespace Prisma { _max?: NestedStringNullableFilter<$PrismaModel>; }; - export type IntasendMpesaTransactionCountOrderByAggregateInput = { - id?: SortOrder; - state?: SortOrder; - apiRef?: SortOrder; - value?: SortOrder; - charges?: SortOrder; - netAmount?: SortOrder; - currency?: SortOrder; - account?: SortOrder; - retryCount?: SortOrder; - createdAt?: SortOrder; - updatedAt?: SortOrder; - }; - - export type IntasendMpesaTransactionAvgOrderByAggregateInput = { - retryCount?: SortOrder; - }; - - export type IntasendMpesaTransactionMaxOrderByAggregateInput = { - id?: SortOrder; - state?: SortOrder; - apiRef?: SortOrder; - value?: SortOrder; - charges?: SortOrder; - netAmount?: SortOrder; - currency?: SortOrder; - account?: SortOrder; - retryCount?: SortOrder; - createdAt?: SortOrder; - updatedAt?: SortOrder; - }; - - export type IntasendMpesaTransactionMinOrderByAggregateInput = { - id?: SortOrder; - state?: SortOrder; - apiRef?: SortOrder; - value?: SortOrder; - charges?: SortOrder; - netAmount?: SortOrder; - currency?: SortOrder; - account?: SortOrder; - retryCount?: SortOrder; - createdAt?: SortOrder; - updatedAt?: SortOrder; - }; - - export type IntasendMpesaTransactionSumOrderByAggregateInput = { - retryCount?: SortOrder; - }; - export type StringFieldUpdateOperationsInput = { set?: string; }; @@ -5938,12 +4438,6 @@ export namespace Prisma { export type MpesaOfframpSwapArgs< ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, > = MpesaOfframpSwapDefaultArgs; - /** - * @deprecated Use IntasendMpesaTransactionDefaultArgs instead - */ - export type IntasendMpesaTransactionArgs< - ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, - > = IntasendMpesaTransactionDefaultArgs; /** * Batch Payload for updateMany & deleteMany & createMany diff --git a/apps/swap/prisma/client/index.js b/apps/swap/prisma/client/index.js index dada28c..fbcd5cc 100644 --- a/apps/swap/prisma/client/index.js +++ b/apps/swap/prisma/client/index.js @@ -94,10 +94,11 @@ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + collectionTracker: 'collectionTracker', rate: 'rate', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -106,24 +107,12 @@ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { exports.Prisma.MpesaOfframpSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + phone: 'phone', + paymentTracker: 'paymentTracker', rate: 'rate', - retryCount: 'retryCount', - createdAt: 'createdAt', - updatedAt: 'updatedAt' -}; - -exports.Prisma.IntasendMpesaTransactionScalarFieldEnum = { - id: 'id', - state: 'state', - apiRef: 'apiRef', - value: 'value', - charges: 'charges', - netAmount: 'netAmount', - currency: 'currency', - account: 'account', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -153,8 +142,7 @@ exports.SwapTransactionState = exports.$Enums.SwapTransactionState = { exports.Prisma.ModelName = { MpesaOnrampSwap: 'MpesaOnrampSwap', - MpesaOfframpSwap: 'MpesaOfframpSwap', - IntasendMpesaTransaction: 'IntasendMpesaTransaction' + MpesaOfframpSwap: 'MpesaOfframpSwap' }; /** * Create the Client @@ -211,8 +199,8 @@ const config = { } } }, - "inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"./client\"\n binaryTargets = [\"native\", \"linux-musl-openssl-3.0.x\", \"debian-openssl-1.1.x\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel MpesaOnrampSwap {\n /// Unique identifier for the swap\n id String @id @default(uuid())\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction.\n userId String\n /// References the onramp Mpesa transaction ID.\n mpesaId String @unique\n /// Lightning invoice to pay.\n lightning String\n /// Fx Rate\n rate String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel MpesaOfframpSwap {\n /// Unique identifier for the swap\n id String @id\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction.\n userId String\n /// References the offramp Mpesa transaction ID.\n mpesaId String? @unique\n /// Lightning invoice to be paid before invoice can proceed.\n lightning String\n /// Fx Rate\n rate String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nenum SwapTransactionState {\n PENDING\n PROCESSING\n FAILED\n COMPLETE\n RETRY\n}\n\nmodel IntasendMpesaTransaction {\n id String @id @default(uuid())\n state SwapTransactionState\n apiRef String\n value String\n charges String\n netAmount String\n currency String\n account String\n retryCount Int\n createdAt String\n updatedAt String\n}\n", - "inlineSchemaHash": "7fdc789c2ea4426f4b6e45d909c27e5a3665a94901fed58c8c3642982e2f1117", + "inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"./client\"\n binaryTargets = [\"native\", \"linux-musl-openssl-3.0.x\", \"debian-openssl-1.1.x\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel MpesaOnrampSwap {\n /// Unique identifier for the swap\n id String @id @default(uuid())\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction\n reference String\n /// Lightning invoice to pay.\n lightning String\n /// References the fiat onramp collection ID\n collectionTracker String @unique\n /// Fx Rate from \n rate String\n /// Amount in satoshi\n amountSats String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel MpesaOfframpSwap {\n /// Unique identifier for the swap\n id String @id\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction\n reference String\n /// Lightning invoice to be paid before offramp can proceed\n lightning String\n /// Phone number to send mpesa the payment\n phone String\n /// References the fiat offramp payment ID\n paymentTracker String? @unique\n /// Fx Rate\n rate String\n /// Amount in satoshi\n amountSats String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nenum SwapTransactionState {\n PENDING\n PROCESSING\n FAILED\n COMPLETE\n RETRY\n}\n", + "inlineSchemaHash": "3fc48b2589b611b8a2e949388e8ee01dd228208c1e7ed3fcab9d99b06c07c76c", "copyEngine": true } @@ -233,7 +221,7 @@ if (!fs.existsSync(path.join(__dirname, 'schema.prisma'))) { config.isBundled = true } -config.runtimeDataModel = JSON.parse("{\"models\":{\"MpesaOnrampSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction.\"},{\"name\":\"mpesaId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the onramp Mpesa transaction ID.\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to pay.\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"MpesaOfframpSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction.\"},{\"name\":\"mpesaId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the offramp Mpesa transaction ID.\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to be paid before invoice can proceed.\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"IntasendMpesaTransaction\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiRef\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"value\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"charges\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"netAmount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"currency\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"account\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{\"SwapTransactionState\":{\"values\":[{\"name\":\"PENDING\",\"dbName\":null},{\"name\":\"PROCESSING\",\"dbName\":null},{\"name\":\"FAILED\",\"dbName\":null},{\"name\":\"COMPLETE\",\"dbName\":null},{\"name\":\"RETRY\",\"dbName\":null}],\"dbName\":null}},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"MpesaOnrampSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"reference\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to pay.\"},{\"name\":\"collectionTracker\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the fiat onramp collection ID\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate from \"},{\"name\":\"amountSats\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Amount in satoshi\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"MpesaOfframpSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"reference\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to be paid before offramp can proceed\"},{\"name\":\"phone\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Phone number to send mpesa the payment\"},{\"name\":\"paymentTracker\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":false,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the fiat offramp payment ID\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"amountSats\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Amount in satoshi\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{\"SwapTransactionState\":{\"values\":[{\"name\":\"PENDING\",\"dbName\":null},{\"name\":\"PROCESSING\",\"dbName\":null},{\"name\":\"FAILED\",\"dbName\":null},{\"name\":\"COMPLETE\",\"dbName\":null},{\"name\":\"RETRY\",\"dbName\":null}],\"dbName\":null}},\"types\":{}}") defineDmmfProperty(exports.Prisma, config.runtimeDataModel) config.engineWasm = undefined diff --git a/apps/swap/prisma/client/package.json b/apps/swap/prisma/client/package.json index 3264423..0a7811d 100644 --- a/apps/swap/prisma/client/package.json +++ b/apps/swap/prisma/client/package.json @@ -1,5 +1,5 @@ { - "name": "prisma-client-05e140c23e39d0f1c39eda4ef3d8ce404ba4208518d1a2b7f1227dddff5e30ce", + "name": "prisma-client-8249a439b47caffdc401079e727cadaab3d3608e2625a88d0e4834c1de075f21", "main": "index.js", "types": "index.d.ts", "browser": "index-browser.js", diff --git a/apps/swap/prisma/client/schema.prisma b/apps/swap/prisma/client/schema.prisma index 45fab43..3fc7eca 100644 --- a/apps/swap/prisma/client/schema.prisma +++ b/apps/swap/prisma/client/schema.prisma @@ -11,42 +11,48 @@ datasource db { model MpesaOnrampSwap { /// Unique identifier for the swap - id String @id @default(uuid()) + id String @id @default(uuid()) /// Tracks progress of the swap - state SwapTransactionState - /// References the user who made the transaction. - userId String - /// References the onramp Mpesa transaction ID. - mpesaId String @unique + state SwapTransactionState + /// References the user who made the transaction + reference String /// Lightning invoice to pay. - lightning String - /// Fx Rate - rate String + lightning String + /// References the fiat onramp collection ID + collectionTracker String @unique + /// Fx Rate from + rate String + /// Amount in satoshi + amountSats String /// Retry count tracker - retryCount Int + retryCount Int /// Timestamps - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt } model MpesaOfframpSwap { /// Unique identifier for the swap - id String @id + id String @id /// Tracks progress of the swap - state SwapTransactionState - /// References the user who made the transaction. - userId String - /// References the offramp Mpesa transaction ID. - mpesaId String? @unique - /// Lightning invoice to be paid before invoice can proceed. - lightning String + state SwapTransactionState + /// References the user who made the transaction + reference String + /// Lightning invoice to be paid before offramp can proceed + lightning String + /// Phone number to send mpesa the payment + phone String + /// References the fiat offramp payment ID + paymentTracker String? @unique /// Fx Rate - rate String + rate String + /// Amount in satoshi + amountSats String /// Retry count tracker - retryCount Int + retryCount Int /// Timestamps - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt } enum SwapTransactionState { @@ -56,17 +62,3 @@ enum SwapTransactionState { COMPLETE RETRY } - -model IntasendMpesaTransaction { - id String @id @default(uuid()) - state SwapTransactionState - apiRef String - value String - charges String - netAmount String - currency String - account String - retryCount Int - createdAt String - updatedAt String -} diff --git a/apps/swap/prisma/client/wasm.js b/apps/swap/prisma/client/wasm.js index edfbd6a..dd58fbb 100644 --- a/apps/swap/prisma/client/wasm.js +++ b/apps/swap/prisma/client/wasm.js @@ -125,10 +125,11 @@ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + collectionTracker: 'collectionTracker', rate: 'rate', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -137,24 +138,12 @@ exports.Prisma.MpesaOnrampSwapScalarFieldEnum = { exports.Prisma.MpesaOfframpSwapScalarFieldEnum = { id: 'id', state: 'state', - userId: 'userId', - mpesaId: 'mpesaId', + reference: 'reference', lightning: 'lightning', + phone: 'phone', + paymentTracker: 'paymentTracker', rate: 'rate', - retryCount: 'retryCount', - createdAt: 'createdAt', - updatedAt: 'updatedAt' -}; - -exports.Prisma.IntasendMpesaTransactionScalarFieldEnum = { - id: 'id', - state: 'state', - apiRef: 'apiRef', - value: 'value', - charges: 'charges', - netAmount: 'netAmount', - currency: 'currency', - account: 'account', + amountSats: 'amountSats', retryCount: 'retryCount', createdAt: 'createdAt', updatedAt: 'updatedAt' @@ -184,8 +173,7 @@ exports.SwapTransactionState = exports.$Enums.SwapTransactionState = { exports.Prisma.ModelName = { MpesaOnrampSwap: 'MpesaOnrampSwap', - MpesaOfframpSwap: 'MpesaOfframpSwap', - IntasendMpesaTransaction: 'IntasendMpesaTransaction' + MpesaOfframpSwap: 'MpesaOfframpSwap' }; /** diff --git a/apps/swap/prisma/migrations/20241025174151_initialize_swap_models/migration.sql b/apps/swap/prisma/migrations/20241025174151_initialize_swap_models/migration.sql deleted file mode 100644 index 1d9c19e..0000000 --- a/apps/swap/prisma/migrations/20241025174151_initialize_swap_models/migration.sql +++ /dev/null @@ -1,33 +0,0 @@ --- CreateEnum -CREATE TYPE "SwapTransactionState" AS ENUM ('PENDING', 'PROCESSING', 'FAILED', 'COMPLETE', 'RETRY'); - --- CreateTable -CREATE TABLE "MpesaOnrampSwap" ( - "id" TEXT NOT NULL, - "state" "SwapTransactionState" NOT NULL, - "userId" TEXT NOT NULL, - "mpesaId" TEXT NOT NULL, - "lightning" TEXT NOT NULL, - "retryCount" INTEGER NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "MpesaOnrampSwap_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "IntasendMpesaTransaction" ( - "id" TEXT NOT NULL, - "state" "SwapTransactionState" NOT NULL, - "apiRef" TEXT NOT NULL, - "value" TEXT NOT NULL, - "charges" TEXT NOT NULL, - "netAmount" TEXT NOT NULL, - "currency" TEXT NOT NULL, - "account" TEXT NOT NULL, - "retryCount" INTEGER NOT NULL, - "createdAt" TEXT NOT NULL, - "updatedAt" TEXT NOT NULL, - - CONSTRAINT "IntasendMpesaTransaction_pkey" PRIMARY KEY ("id") -); diff --git a/apps/swap/prisma/migrations/20241026231657_unique_mpesa_id_on_swap/migration.sql b/apps/swap/prisma/migrations/20241026231657_unique_mpesa_id_on_swap/migration.sql deleted file mode 100644 index adf1c9d..0000000 --- a/apps/swap/prisma/migrations/20241026231657_unique_mpesa_id_on_swap/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[mpesaId]` on the table `MpesaOnrampSwap` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "MpesaOnrampSwap_mpesaId_key" ON "MpesaOnrampSwap"("mpesaId"); diff --git a/apps/swap/prisma/migrations/20241027010339_record_onramp_swap_fx/migration.sql b/apps/swap/prisma/migrations/20241027010339_record_onramp_swap_fx/migration.sql deleted file mode 100644 index ebc0992..0000000 --- a/apps/swap/prisma/migrations/20241027010339_record_onramp_swap_fx/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - Added the required column `rate` to the `MpesaOnrampSwap` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE "MpesaOnrampSwap" ADD COLUMN "rate" TEXT NOT NULL; diff --git a/apps/swap/prisma/migrations/20241103214340_define_mpesa_offramp_swap/migration.sql b/apps/swap/prisma/migrations/20241103214340_define_mpesa_offramp_swap/migration.sql deleted file mode 100644 index 37efad7..0000000 --- a/apps/swap/prisma/migrations/20241103214340_define_mpesa_offramp_swap/migration.sql +++ /dev/null @@ -1,17 +0,0 @@ --- CreateTable -CREATE TABLE "MpesaOfframpSwap" ( - "id" TEXT NOT NULL, - "state" "SwapTransactionState" NOT NULL, - "userId" TEXT NOT NULL, - "mpesaId" TEXT, - "lightning" TEXT NOT NULL, - "rate" TEXT NOT NULL, - "retryCount" INTEGER NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "MpesaOfframpSwap_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "MpesaOfframpSwap_mpesaId_key" ON "MpesaOfframpSwap"("mpesaId"); diff --git a/apps/swap/prisma/migrations/20241105150909_define_swap_models/migration.sql b/apps/swap/prisma/migrations/20241105150909_define_swap_models/migration.sql new file mode 100644 index 0000000..f6c1b17 --- /dev/null +++ b/apps/swap/prisma/migrations/20241105150909_define_swap_models/migration.sql @@ -0,0 +1,41 @@ +-- CreateEnum +CREATE TYPE "SwapTransactionState" AS ENUM ('PENDING', 'PROCESSING', 'FAILED', 'COMPLETE', 'RETRY'); + +-- CreateTable +CREATE TABLE "MpesaOnrampSwap" ( + "id" TEXT NOT NULL, + "state" "SwapTransactionState" NOT NULL, + "reference" TEXT NOT NULL, + "lightning" TEXT NOT NULL, + "collectionTracker" TEXT NOT NULL, + "rate" TEXT NOT NULL, + "amountSats" TEXT NOT NULL, + "retryCount" INTEGER NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "MpesaOnrampSwap_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MpesaOfframpSwap" ( + "id" TEXT NOT NULL, + "state" "SwapTransactionState" NOT NULL, + "reference" TEXT NOT NULL, + "lightning" TEXT NOT NULL, + "phone" TEXT NOT NULL, + "paymentTracker" TEXT, + "rate" TEXT NOT NULL, + "amountSats" TEXT NOT NULL, + "retryCount" INTEGER NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "MpesaOfframpSwap_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "MpesaOnrampSwap_collectionTracker_key" ON "MpesaOnrampSwap"("collectionTracker"); + +-- CreateIndex +CREATE UNIQUE INDEX "MpesaOfframpSwap_paymentTracker_key" ON "MpesaOfframpSwap"("paymentTracker"); diff --git a/apps/swap/prisma/schema.prisma b/apps/swap/prisma/schema.prisma index ade8222..4ab7e7a 100644 --- a/apps/swap/prisma/schema.prisma +++ b/apps/swap/prisma/schema.prisma @@ -14,14 +14,16 @@ model MpesaOnrampSwap { id String @id @default(uuid()) /// Tracks progress of the swap state SwapTransactionState - /// References the user who made the transaction. - userId String - /// References the onramp Mpesa transaction ID. - mpesaId String @unique + /// References the user who made the transaction + reference String /// Lightning invoice to pay. lightning String - /// Fx Rate + /// References the fiat onramp collection ID + collectionTracker String @unique + /// Fx Rate from rate String + /// Amount in satoshi + amountSats String /// Retry count tracker retryCount Int /// Timestamps @@ -34,14 +36,18 @@ model MpesaOfframpSwap { id String @id /// Tracks progress of the swap state SwapTransactionState - /// References the user who made the transaction. - userId String - /// References the offramp Mpesa transaction ID. - mpesaId String? @unique - /// Lightning invoice to be paid before invoice can proceed. + /// References the user who made the transaction + reference String + /// Lightning invoice to be paid before offramp can proceed lightning String + /// Phone number to send mpesa the payment + phone String + /// References the fiat offramp payment ID + paymentTracker String? @unique /// Fx Rate rate String + /// Amount in satoshi + amountSats String /// Retry count tracker retryCount Int /// Timestamps @@ -56,17 +62,3 @@ enum SwapTransactionState { COMPLETE RETRY } - -model IntasendMpesaTransaction { - id String @id @default(uuid()) - state SwapTransactionState - apiRef String - value String - charges String - netAmount String - currency String - account String - retryCount Int - createdAt String - updatedAt String -} diff --git a/apps/swap/src/dto/index.ts b/apps/swap/src/dto/index.ts index 4fc5796..8bfcb5f 100644 --- a/apps/swap/src/dto/index.ts +++ b/apps/swap/src/dto/index.ts @@ -1,2 +1,3 @@ export * from './send-stk-push.dto'; -export * from './mpesa-transaction-update.dto'; +export * from './mpesa-payment-update.dto'; +export * from './mpesa-collection-update.dto'; diff --git a/apps/swap/src/dto/mpesa-collection-update.dto.ts b/apps/swap/src/dto/mpesa-collection-update.dto.ts new file mode 100644 index 0000000..624fd7d --- /dev/null +++ b/apps/swap/src/dto/mpesa-collection-update.dto.ts @@ -0,0 +1,22 @@ +import { IsEnum, IsString, IsOptional, IsNotEmpty } from 'class-validator'; +import { + MpesaTransactionState, + type MpesaCollectionUpdate, +} from '../intasend/intasend.types'; + +export class MpesaCollectionUpdateDto implements MpesaCollectionUpdate { + @IsNotEmpty() + @IsString() + invoice_id: string; + + @IsEnum(MpesaTransactionState) + state: MpesaTransactionState; + + @IsOptional() + @IsString() + failed_reason: string | null; + + @IsNotEmpty() + @IsString() + challenge: string; +} diff --git a/apps/swap/src/dto/mpesa-payment-update.dto.ts b/apps/swap/src/dto/mpesa-payment-update.dto.ts new file mode 100644 index 0000000..ea60777 --- /dev/null +++ b/apps/swap/src/dto/mpesa-payment-update.dto.ts @@ -0,0 +1,71 @@ +import { + IsEnum, + IsString, + IsNumber, + IsOptional, + IsNotEmpty, +} from 'class-validator'; +import { + BatchPaymentStatusCode, + type IntasendPayment, + MpesaTransactionState, + MpesaPaymentUpdate, + PaymentStatusCode, +} from '../intasend/intasend.types'; + +export class MpesaPaymentUpdateDto implements MpesaPaymentUpdate { + @IsNotEmpty() + @IsString() + file_id: string; + + @IsNotEmpty() + @IsString() + status: string; + + @IsEnum(MpesaTransactionState) + status_code: BatchPaymentStatusCode; + + @IsNotEmpty() + transactions: IntasendPayment[]; + + @IsNotEmpty() + @IsString() + challenge: string; +} + +export class IntasendPaymentDto implements IntasendPayment { + @IsNotEmpty() + @IsString() + status: string; + + @IsEnum(PaymentStatusCode) + status_code: PaymentStatusCode; + + @IsNotEmpty() + @IsString() + request_reference_id: string; + + @IsNotEmpty() + @IsString() + name: string; + + @IsNotEmpty() + @IsString() + account: string; + + @IsOptional() + @IsString() + id_number: string | null; + + @IsOptional() + @IsString() + bank_code: string | null; + + @IsNotEmpty() + @IsNumber() + amount: number; + + @IsNotEmpty() + @IsString() + narrative: string; +} diff --git a/apps/swap/src/dto/mpesa-transaction-update.dto.ts b/apps/swap/src/dto/mpesa-transaction-update.dto.ts deleted file mode 100644 index a4af17d..0000000 --- a/apps/swap/src/dto/mpesa-transaction-update.dto.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { - IsEnum, - IsString, - IsNumber, - IsDateString, - IsOptional, - IsNotEmpty, -} from 'class-validator'; -import { - MpesaTractactionState, - type MpesaTransactionUpdate, -} from '../intasend/intasend.types'; - -export class MpesaTransactionUpdateDto implements MpesaTransactionUpdate { - @IsNotEmpty() - @IsString() - invoice_id: string; - - @IsEnum(MpesaTractactionState) - state: MpesaTractactionState; - - @IsString() - charges: string; - - @IsNotEmpty() - @IsString() - net_amount: string; - - @IsNotEmpty() - @IsString() - currency: string; - - @IsNotEmpty() - @IsString() - value: string; - - @IsNotEmpty() - @IsString() - account: string; - - @IsNotEmpty() - @IsString() - api_ref: string; - - @IsNumber() - retry_count: number; - - @IsDateString() - created_at: string; - - @IsDateString() - updated_at: string; - - @IsOptional() - @IsString() - failed_reason: string | null; - - @IsOptional() - @IsString() - failed_code: string | null; - - @IsNotEmpty() - @IsString() - challenge: string; -} diff --git a/apps/swap/src/dto/send-mpesa.dto.ts b/apps/swap/src/dto/send-mpesa.dto.ts new file mode 100644 index 0000000..3d3cd57 --- /dev/null +++ b/apps/swap/src/dto/send-mpesa.dto.ts @@ -0,0 +1,27 @@ +import { Type } from 'class-transformer'; +import { IsNotEmpty, IsString, Length, Validate } from 'class-validator'; +import { NormalizePhoneNumber } from './utils'; +import { IsStringifiedNumberConstraint } from '@bitsacco/common'; + +export class SendMpesaDto { + @IsNotEmpty() + @IsString() + @Validate(IsStringifiedNumberConstraint) + @Type(() => String) + amount: string; + + @NormalizePhoneNumber() + @IsString() + @Length(12, 12) + account: string; + + @IsNotEmpty() + @IsString() + @Type(() => String) + name: string; + + @IsNotEmpty() + @IsString() + @Type(() => String) + narrative: string; +} diff --git a/apps/swap/src/dto/send-stk-push.dto.ts b/apps/swap/src/dto/send-stk-push.dto.ts index 361dc45..f06df95 100644 --- a/apps/swap/src/dto/send-stk-push.dto.ts +++ b/apps/swap/src/dto/send-stk-push.dto.ts @@ -1,5 +1,6 @@ -import { Transform, Type } from 'class-transformer'; +import { Type } from 'class-transformer'; import { IsNotEmpty, IsNumber, IsString, Length, Min } from 'class-validator'; +import { NormalizePhoneNumber } from './utils'; export class SendSTKPushDto { @IsNumber() @@ -17,28 +18,3 @@ export class SendSTKPushDto { @Type(() => String) api_ref: string; } - -function NormalizePhoneNumber() { - return Transform((params) => { - const { value } = params; - if (typeof value !== 'string') { - return value; - } - - let normalized = value.replace(/\D/g, ''); - - if (normalized.length === 9) { - normalized = '254' + normalized; - } else if (normalized.startsWith('0')) { - normalized = '254' + normalized.slice(1); - } else if (!normalized.startsWith('254')) { - normalized = '254' + normalized; - } - - if (normalized.length !== 12) { - throw new Error('Invalid phone number format'); - } - - return normalized; - }); -} diff --git a/apps/swap/src/dto/utils.ts b/apps/swap/src/dto/utils.ts new file mode 100644 index 0000000..f2efc4e --- /dev/null +++ b/apps/swap/src/dto/utils.ts @@ -0,0 +1,40 @@ +import { Transform } from 'class-transformer'; +import { MpesaPaymentUpdateDto } from './mpesa-payment-update.dto'; +import { MpesaCollectionUpdateDto } from './mpesa-collection-update.dto'; + +export function NormalizePhoneNumber() { + return Transform((params) => { + const { value } = params; + if (typeof value !== 'string') { + return value; + } + + let normalized = value.replace(/\D/g, ''); + + if (normalized.length === 9) { + normalized = '254' + normalized; + } else if (normalized.startsWith('0')) { + normalized = '254' + normalized.slice(1); + } else if (!normalized.startsWith('254')) { + normalized = '254' + normalized; + } + + if (normalized.length !== 12) { + throw new Error('Invalid phone number format'); + } + + return normalized; + }); +} + +export const isMpesaCollectionUpdate = ( + update: MpesaCollectionUpdateDto | MpesaPaymentUpdateDto, +): update is MpesaCollectionUpdateDto => { + return 'invoice_id' in update; +}; + +export const isMpesaPaymentUpdate = ( + update: MpesaCollectionUpdateDto | MpesaPaymentUpdateDto, +): update is MpesaPaymentUpdateDto => { + return 'file_id' in update; +}; diff --git a/apps/swap/src/events.controller.spec.ts b/apps/swap/src/events.controller.spec.ts index 9a22b3a..6a5cfa6 100644 --- a/apps/swap/src/events.controller.spec.ts +++ b/apps/swap/src/events.controller.spec.ts @@ -2,9 +2,9 @@ import { TestingModule } from '@nestjs/testing'; import { ConfigModule } from '@nestjs/config'; import { createTestingModuleWithValidation } from '@bitsacco/common'; import { EventsController } from './events.controller'; -import { MpesaTransactionUpdateDto } from './dto'; +import { MpesaCollectionUpdateDto } from './dto'; import { SwapService } from './swap.service'; -import { MpesaTractactionState } from './intasend/intasend.types'; +import { MpesaTransactionState } from './intasend/intasend.types'; describe('EventsController', () => { let controller: EventsController; @@ -33,9 +33,9 @@ describe('EventsController', () => { }); it('should call processSwapUpdate', async () => { - const data: MpesaTransactionUpdateDto = { + const data: MpesaCollectionUpdateDto = { invoice_id: 'invid', - state: MpesaTractactionState.Processing, + state: MpesaTransactionState.Processing, charges: '0', net_amount: '100', currency: 'KES', diff --git a/apps/swap/src/events.controller.ts b/apps/swap/src/events.controller.ts index 93d4f93..0165c92 100644 --- a/apps/swap/src/events.controller.ts +++ b/apps/swap/src/events.controller.ts @@ -1,7 +1,7 @@ import { Controller, Logger } from '@nestjs/common'; import { EventPattern } from '@nestjs/microservices'; import { process_swap_update } from '@bitsacco/common'; -import { MpesaTransactionUpdateDto } from './dto'; +import { MpesaCollectionUpdateDto } from './dto'; import { SwapService } from './swap.service'; @Controller('events') @@ -11,7 +11,7 @@ export class EventsController { constructor(private readonly swapService: SwapService) {} @EventPattern(process_swap_update) - async handleSwapUpdate(data: MpesaTransactionUpdateDto) { + async handleSwapUpdate(data: MpesaCollectionUpdateDto) { this.logger.log('Processing Swap Update'); await this.swapService.processSwapUpdate(data); } diff --git a/apps/swap/src/intasend/intasend.service.ts b/apps/swap/src/intasend/intasend.service.ts index 74518ea..5076076 100644 --- a/apps/swap/src/intasend/intasend.service.ts +++ b/apps/swap/src/intasend/intasend.service.ts @@ -1,21 +1,25 @@ import IntaSend = require('intasend-node'); import { ConfigService } from '@nestjs/config'; import { Injectable, Logger } from '@nestjs/common'; -import { MpesaTractactionState, MpesaTxTracker } from './intasend.types'; -import { MpesaTransactionUpdateDto, SendSTKPushDto } from '../dto'; -import { PrismaService } from '../prisma.service'; - -const INTASEND_MPESA_TX_UPDATE_CHALLENGE = 'BITSACCO'; +import { + BatchPaymentStatusCode, + MpesaTransactionState, + MpesaTracker, + PaymentStatusCode, +} from './intasend.types'; +import { + MpesaCollectionUpdateDto, + MpesaPaymentUpdateDto, + SendSTKPushDto, +} from '../dto'; +import { SendMpesaDto } from '../dto/send-mpesa.dto'; @Injectable() export class IntasendService { private readonly logger = new Logger(IntasendService.name); private intasend: IntaSend; - constructor( - private readonly configService: ConfigService, - private readonly prismaService: PrismaService, - ) { + constructor(private readonly configService: ConfigService) { this.logger.log('IntasendService created'); const pubkey = this.configService.getOrThrow('INTASEND_PUBLIC_KEY'); @@ -40,67 +44,122 @@ export class IntasendService { } } - async sendMpesaStkPush(payload: SendSTKPushDto): Promise { + async sendMpesaStkPush(payload: SendSTKPushDto): Promise { this.logger.log(`Sending STK push to ${payload.phone_number}`); const resp = await this.intasend.collection().mpesaStkPush(payload); return { id: resp.invoice.invoice_id, - state: MpesaTractactionState.Pending, + state: MpesaTransactionState.Pending, + }; + } + + async sendMpesaPayment(payload: SendMpesaDto): Promise { + this.logger.log(`Sending Mpesa payment to ${payload.account}`); + const resp = await this.intasend.payouts().mpesa({ + currency: 'KES', + requires_approval: 'NO', + transactions: [payload], + }); + + return { + id: resp.file_id, + state: MpesaTransactionState.Pending, }; } - async updateMpesaTx({ + async getMpesaTrackerFromCollectionUpdate({ invoice_id, state, - api_ref, - value, - charges, - net_amount, - currency, - account, - retry_count, failed_reason, challenge, - created_at, - updated_at, - }: MpesaTransactionUpdateDto): Promise { - if (challenge !== INTASEND_MPESA_TX_UPDATE_CHALLENGE) { - this.logger.error('Unauthorized update. Challenge is invalid'); - throw new Error('Rejected mpesa transaction update'); - } + }: MpesaCollectionUpdateDto): Promise { + this.checkUpdateChallenge(challenge); if (failed_reason) { this.logger.error(`Mpesa transaction failed: ${failed_reason}`); } - const update = { + return { + id: invoice_id, state, - charges, - account, - value, - currency, - apiRef: api_ref, - netAmount: net_amount, - retryCount: retry_count, - createdAt: created_at, - updatedAt: updated_at, }; + } - const tx = await this.prismaService.intasendMpesaTransaction.upsert({ - where: { - id: invoice_id, - }, - update, - create: { - id: invoice_id, - ...update, - }, - }); + async getMpesaTrackerFromPaymentUpdate({ + file_id, + status_code, + transactions, + challenge, + }: MpesaPaymentUpdateDto): Promise { + this.checkUpdateChallenge(challenge); + + let batch: MpesaTransactionState; + switch (status_code) { + case BatchPaymentStatusCode.BP101: + case BatchPaymentStatusCode.BP103: + case BatchPaymentStatusCode.BP104: + case BatchPaymentStatusCode.BP106: + case BatchPaymentStatusCode.BP108: + batch = MpesaTransactionState.Pending; + break; + case BatchPaymentStatusCode.BP109: + case BatchPaymentStatusCode.BP110: + batch = MpesaTransactionState.Processing; + break; + case BatchPaymentStatusCode.BF102: + case BatchPaymentStatusCode.BF105: + case BatchPaymentStatusCode.BF107: + case BatchPaymentStatusCode.BE111: + batch = MpesaTransactionState.Failed; + break; + case BatchPaymentStatusCode.BC100: + batch = MpesaTransactionState.Complete; + break; + } + + let state: MpesaTransactionState; + if (batch === MpesaTransactionState.Complete) { + if (transactions.length !== 1) { + this.logger.error('Invalid transaction update. Expected 1 transaction'); + throw new Error('Rejected mpesa transaction update'); + } + + const tx = transactions[0]; + switch (tx.status_code) { + case PaymentStatusCode.TP101: + case PaymentStatusCode.TP102: + throw new Error('Transaction should not be pending or processing'); + case PaymentStatusCode.TF103: + case PaymentStatusCode.TF104: + case PaymentStatusCode.TF105: + case PaymentStatusCode.TF106: + case PaymentStatusCode.TC108: + state = MpesaTransactionState.Failed; + break; + case PaymentStatusCode.TS100: + state = MpesaTransactionState.Complete; + break; + case PaymentStatusCode.TH107: + state = MpesaTransactionState.Processing; + break; + case PaymentStatusCode.TR109: + state = MpesaTransactionState.Retry; + break; + } + } return { - id: tx.id, + id: file_id, state, }; } + + private checkUpdateChallenge(challenge: string) { + const INTASEND_MPESA_TX_UPDATE_CHALLENGE = 'BITSACCO'; + if (challenge !== INTASEND_MPESA_TX_UPDATE_CHALLENGE) { + this.logger.error('Unauthorized update. Challenge is invalid'); + throw new Error('Rejected mpesa transaction update'); + } + } } diff --git a/apps/swap/src/intasend/intasend.types.ts b/apps/swap/src/intasend/intasend.types.ts index 5799182..9f0a495 100644 --- a/apps/swap/src/intasend/intasend.types.ts +++ b/apps/swap/src/intasend/intasend.types.ts @@ -1,4 +1,4 @@ -export enum MpesaTractactionState { +export enum MpesaTransactionState { Pending = 'PENDING', Processing = 'PROCESSING', Retry = 'RETRY', @@ -6,9 +6,59 @@ export enum MpesaTractactionState { Complete = 'COMPLETE', } +export enum BatchPaymentStatusCode { + // New batch or request, reading in progress + BP101 = 'BP101', + // Batch/request waiting approval + BP103 = 'BP103', + // Queued to check for float balance + BP104 = 'BP104', + // Float/balance check in progress + BP106 = 'BP106', + // Advance internal validations in progress + BP108 = 'BP108', + // Payment to beneficiary in progress + BP109 = 'BP109', + // Sending payments to beneficiary in progress + BP110 = 'BP110', + // Batch/request failed + BF102 = 'BF102', + // Failed checking float balance + BF105 = 'BF105', + // Failed advance float check issue + BF107 = 'BF107', + // Completed sending all transactions. Results ready for review + BC100 = 'BC100', + // Batch/request ended or cancelled early + BE111 = 'BE111', +} + +export enum PaymentStatusCode { + // New transaction. Processing is pending + TP101 = 'TP101', + // Transaction processing started + TP102 = 'TP102', + // Failed to initiate or process transaction. Check failed reason for more details + TF103 = 'TF103', + // Transaction results processing in progress + TF104 = 'TF104', + // Transaction status cannot be determined. Contact support for further check. + TF105 = 'TF105', + // Transaction failed, see failed reasons for more details + TF106 = 'TF106', + // Transaction is successful + TS100 = 'TS100', + // Transaction is under observation + TH107 = 'TH107', + // Transaction canceled + TC108 = 'TC108', + // Transaction is queued for retry + TR109 = 'TR109', +} + export interface MpesaInvoice { invoice_id: string; - state: MpesaTractactionState; + state: MpesaTransactionState; api_ref: string; value: string; charges: string; @@ -20,22 +70,33 @@ export interface MpesaInvoice { updated_at: string; } -export interface MpesaTransactionUpdate extends MpesaInvoice { +export interface IntasendPayment { + status: string; + status_code: PaymentStatusCode; + request_reference_id: string; + name: string; + account: string; + id_number: string | null; + bank_code: string | null; + amount: number; + narrative: string; +} + +export interface MpesaCollectionUpdate { + invoice_id: string; + state: MpesaTransactionState; failed_reason: string | null; - failed_code: string | null; challenge: string; } -export interface SendSTKPushResponse { - id: string; - invoice: MpesaInvoice; - state: MpesaTractactionState; - refundable: boolean; - created_at: string; - updated_at: string; +export interface MpesaPaymentUpdate { + file_id: string; + status: string; + status_code: BatchPaymentStatusCode; + transactions: IntasendPayment[]; } -export interface MpesaTxTracker { +export interface MpesaTracker { id: string; - state: MpesaTractactionState; + state: MpesaTransactionState; } diff --git a/apps/swap/src/swap.service.spec.ts b/apps/swap/src/swap.service.spec.ts index 6084638..8b4dc54 100644 --- a/apps/swap/src/swap.service.spec.ts +++ b/apps/swap/src/swap.service.spec.ts @@ -13,9 +13,9 @@ import { PrismaService } from './prisma.service'; import { FxService } from './fx/fx.service'; import { SwapService } from './swap.service'; import { IntasendService } from './intasend/intasend.service'; -import { MpesaTractactionState } from './intasend/intasend.types'; +import { MpesaTransactionState } from './intasend/intasend.types'; import { FedimintService } from './fedimint/fedimint.service'; -import { MpesaTransactionUpdateDto } from './dto'; +import { MpesaCollectionUpdateDto } from './dto'; const mock_rate = 8708520.117232416; @@ -53,7 +53,8 @@ describe('SwapService', () => { mockIntasendService = { sendMpesaStkPush: jest.fn(), - updateMpesaTx: jest.fn(), + getMpesaTrackerFromCollectionUpdate: jest.fn(), + getMpesaTrackerFromPaymentUpdate: jest.fn(), } as unknown as IntasendService; mockFedimintService = { @@ -164,22 +165,10 @@ describe('SwapService', () => { describe('createOnrampSwap', () => { it('should create an onramp swap with expected fx rate', async () => { - const cache = { - lightning: 'lnbtcexampleinvoicee', - phone: '0700000000', - amount: '100', - rate: mock_rate.toString(), - ref: 'test-onramp-swap', - }; - - (mockCacheManager.get as jest.Mock).mockImplementation( - (_key: string) => cache, - ); - (mockIntasendService.sendMpesaStkPush as jest.Mock).mockImplementation( () => ({ id: '123456789', - state: MpesaTractactionState.Pending, + state: MpesaTransactionState.Pending, }), ); @@ -199,17 +188,25 @@ describe('SwapService', () => { refreshIfExpired: false, }, ref: 'test-onramp-swap', - phone: cache.phone, - amount: cache.amount, - lightning: cache.lightning, + amountFiat: '100', + source: { + currency: Currency.KES, + origin: { + phone: '0700000000', + }, + }, + target: { + invoice: { + invoice: 'lnbtcexampleinvoicee', + }, + }, }; const swap = await swapService.createOnrampSwap(req); expect(swap).toBeDefined(); - expect(swap.rate).toEqual(cache.rate); + expect(swap.rate).toEqual(mock_rate.toString()); expect(swap.status).toEqual(SwapStatus.PENDING); - expect(mockCacheManager.set).toHaveBeenCalled(); }); }); @@ -258,20 +255,10 @@ describe('SwapService', () => { }); describe('processSwapUpdate', () => { - const req: MpesaTransactionUpdateDto = { + const req: MpesaCollectionUpdateDto = { invoice_id: '123456789', - state: MpesaTractactionState.Pending, - charges: '1', - net_amount: '99', - currency: 'KES', - value: '100', - account: '0700000000', - api_ref: 'mpesa-onramp', - retry_count: 0, - created_at: '2021-08-01T00:00:00Z', - updated_at: '2024-10-01T00:00:00Z', + state: MpesaTransactionState.Pending, failed_reason: null, - failed_code: null, challenge: 'BITSACCO-TEST', }; @@ -281,7 +268,7 @@ describe('SwapService', () => { state: SwapTransactionState.PENDING, }; - it('creates a new swap tx if there was none recorded before', async () => { + it.skip('creates a new swap tx if there was none recorded before', async () => { (mockCacheManager.get as jest.Mock).mockImplementation( (_key: string) => ({ lightning: 'lnbtcexampleinvoicee', @@ -289,16 +276,16 @@ describe('SwapService', () => { amount: '100', rate: mock_rate.toString(), ref: 'test-onramp-swap', - state: MpesaTractactionState.Pending, + state: MpesaTransactionState.Pending, }), ); - (mockIntasendService.updateMpesaTx as jest.Mock).mockImplementation( - () => ({ - id: '123456789', - state: MpesaTractactionState.Pending, - }), - ); + ( + mockIntasendService.getMpesaTrackerFromCollectionUpdate as jest.Mock + ).mockImplementation(() => ({ + id: '123456789', + state: MpesaTransactionState.Pending, + })); (mockPrismaService.mpesaOnrampSwap.create as jest.Mock).mockResolvedValue( swap, @@ -319,9 +306,11 @@ describe('SwapService', () => { await swapService.processSwapUpdate({ ...req, - state: MpesaTractactionState.Processing, + state: MpesaTransactionState.Processing, }); - expect(mockIntasendService.updateMpesaTx).toHaveBeenCalled(); + expect( + mockIntasendService.getMpesaTrackerFromCollectionUpdate, + ).toHaveBeenCalled(); expect( mockPrismaService.mpesaOnrampSwap.findUniqueOrThrow, ).toHaveBeenCalled(); @@ -330,12 +319,12 @@ describe('SwapService', () => { }); it('should update swap tx from PENDING to PROCESSING', async () => { - (mockIntasendService.updateMpesaTx as jest.Mock).mockImplementation( - () => ({ - id: '123456789', - state: MpesaTractactionState.Processing, - }), - ); + ( + mockIntasendService.getMpesaTrackerFromCollectionUpdate as jest.Mock + ).mockImplementation(() => ({ + id: '123456789', + state: MpesaTransactionState.Processing, + })); ( mockPrismaService.mpesaOnrampSwap.findUniqueOrThrow as jest.Mock @@ -351,9 +340,11 @@ describe('SwapService', () => { await swapService.processSwapUpdate({ ...req, - state: MpesaTractactionState.Processing, + state: MpesaTransactionState.Processing, }); - expect(mockIntasendService.updateMpesaTx).toHaveBeenCalled(); + expect( + mockIntasendService.getMpesaTrackerFromCollectionUpdate, + ).toHaveBeenCalled(); expect( mockPrismaService.mpesaOnrampSwap.findUniqueOrThrow, ).toHaveBeenCalled(); @@ -368,12 +359,12 @@ describe('SwapService', () => { }); it('should update swap tx from PROCESSING to COMPLETE', async () => { - (mockIntasendService.updateMpesaTx as jest.Mock).mockImplementation( - () => ({ - id: '123456789', - state: MpesaTractactionState.Complete, - }), - ); + ( + mockIntasendService.getMpesaTrackerFromCollectionUpdate as jest.Mock + ).mockImplementation(() => ({ + id: '123456789', + state: MpesaTransactionState.Complete, + })); ( mockPrismaService.mpesaOnrampSwap.findUniqueOrThrow as jest.Mock @@ -392,9 +383,11 @@ describe('SwapService', () => { await swapService.processSwapUpdate({ ...req, - state: MpesaTractactionState.Complete, + state: MpesaTransactionState.Complete, }); - expect(mockIntasendService.updateMpesaTx).toHaveBeenCalled(); + expect( + mockIntasendService.getMpesaTrackerFromCollectionUpdate, + ).toHaveBeenCalled(); expect( mockPrismaService.mpesaOnrampSwap.findUniqueOrThrow, ).toHaveBeenCalled(); @@ -430,7 +423,7 @@ describe('SwapService', () => { refreshIfExpired: false, }, ref: 'test-onramp-swap', - amount: '100', + amountFiat: '100', target: { currency: Currency.KES, destination: { diff --git a/apps/swap/src/swap.service.ts b/apps/swap/src/swap.service.ts index fc7dc23..748afe2 100644 --- a/apps/swap/src/swap.service.ts +++ b/apps/swap/src/swap.service.ts @@ -18,20 +18,21 @@ import { type ReceivePaymentSuccessEvent, } from '@bitsacco/common'; import { v4 as uuidv4 } from 'uuid'; -import { EventEmitter2, OnEvent } from '@nestjs/event-emitter'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; +import { EventEmitter2, OnEvent } from '@nestjs/event-emitter'; import { Inject, Injectable, Logger } from '@nestjs/common'; import { MpesaOnrampSwap, SwapTransactionState } from '../prisma/client'; import { FxService } from './fx/fx.service'; import { PrismaService } from './prisma.service'; import { IntasendService } from './intasend/intasend.service'; -import { MpesaTransactionUpdateDto } from './dto'; -import { MpesaTractactionState } from './intasend/intasend.types'; +import { MpesaCollectionUpdateDto, MpesaPaymentUpdateDto } from './dto'; +import { MpesaTransactionState } from './intasend/intasend.types'; import { FedimintService } from './fedimint/fedimint.service'; import { fedimint_receive_success, fedimint_receive_failure, } from './fedimint/fedimint.const'; +import { isMpesaCollectionUpdate } from './dto/utils'; @Injectable() export class SwapService { @@ -106,7 +107,6 @@ export class SwapService { private async getRate( quote: QuoteDto, req: { - amount: string; from: Currency; to: Currency; }, @@ -128,47 +128,34 @@ export class SwapService { async createOnrampSwap({ quote, + amountFiat, + source, + target, ref, - amount, - phone, - lightning, }: CreateOnrampSwapDto): Promise { const rate = await this.getRate(quote, { - amount, from: Currency.KES, to: Currency.BTC, }); - const mpesa = await this.intasendService.sendMpesaStkPush({ - amount: Number(amount), - phone_number: phone, + const { id, state } = await this.intasendService.sendMpesaStkPush({ + amount: Number(amountFiat), + phone_number: source.origin.phone, api_ref: ref, }); - // We record stk push response to a temporary cache - // so we can track status of the swap later - // NOTE: we use mpesa ids as cache keys - this.cacheManager.set( - mpesa.id, - { - lightning, - phone, - amount, - rate, - state: mpesa.state, - ref, - }, - this.CACHE_TTL_SECS, - ); + const amountSats = Number(rate) * Number(amountFiat); const swap = await this.prismaService.mpesaOnrampSwap.create({ data: { + id, state: SwapTransactionState.PENDING, - userId: phone, - mpesaId: mpesa.id, - lightning, - rate, + reference: ref, + collectionTracker: id, + lightning: target.invoice.invoice, + amountSats: amountSats.toString(), retryCount: 0, + rate, }, }); @@ -216,13 +203,8 @@ export class SwapService { const swaps = onramps .slice(selectPage * size, (selectPage + 1) * size + size) .map((swap) => ({ - id: swap.mpesaId, - rate: swap.rate, + ...swap, status: mapSwapTxStateToSwapStatus(swap.state), - userId: swap.userId, - mpesaId: swap.mpesaId, - lightning: swap.lightning, - retryCount: swap.retryCount, createdAt: swap.createdAt.toDateString(), updatedAt: swap.updatedAt.toDateString(), })); @@ -236,31 +218,31 @@ export class SwapService { } async createOfframpSwap({ - quote, - amount, ref, + quote, + amountFiat, target, }: CreateOfframpSwapDto): Promise { const rate = await this.getRate(quote, { - amount, from: Currency.BTC, to: target.currency, }); - const amountMsat = Number(amount) * 1000; - this.logger.log('Creating offramp swap with ref : ', ref); + const amountSats = Number(rate) * Number(amountFiat); const { invoice: lightning, operationId: id } = - await this.fedimintService.invoice(amountMsat, ref || 'offramp'); + await this.fedimintService.invoice(amountSats * 1000, ref || 'offramp'); const swap = await this.prismaService.mpesaOfframpSwap.create({ data: { id, - state: SwapTransactionState.PENDING, rate, - userId: '254708083339', //target.destination.phone, lightning, retryCount: 0, + reference: ref, + phone: target.destination.phone, + amountSats: amountSats.toString(), + state: SwapTransactionState.PENDING, }, }); @@ -311,13 +293,8 @@ export class SwapService { const swaps = offramps .slice(selectPage * size, (selectPage + 1) * size + size) .map((swap) => ({ - id: swap.mpesaId, - rate: swap.rate, + ...swap, status: mapSwapTxStateToSwapStatus(swap.state), - userId: swap.userId, - mpesaId: swap.mpesaId, - lightning: swap.lightning, - retryCount: swap.retryCount, createdAt: swap.createdAt.toDateString(), updatedAt: swap.updatedAt.toDateString(), })); @@ -330,56 +307,48 @@ export class SwapService { }; } - async processSwapUpdate(data: MpesaTransactionUpdateDto) { - // record mpesa transaction using intasend service - const mpesa = await this.intasendService.updateMpesaTx(data); - - let swap; - try { - swap = await this.prismaService.mpesaOnrampSwap.findUniqueOrThrow({ - where: { - mpesaId: data.invoice_id, - }, - }); - } catch { - // look up mpesa tx in cache - const stk: STKPushCache = await this.cacheManager.get( - mpesa.id, - ); - - // record a new swap in db - swap = await this.prismaService.mpesaOnrampSwap.create({ - data: { - state: SwapTransactionState.PENDING, - userId: stk.phone, - mpesaId: mpesa.id, - lightning: stk.lightning, - rate: stk.rate, - retryCount: 0, - }, - }); + async processSwapUpdate( + update: MpesaCollectionUpdateDto | MpesaPaymentUpdateDto, + ) { + if (isMpesaCollectionUpdate(update)) { + return this.processMpesaCollectionUpdate(update); } + return this.processMpesaPaymentUpdate(update); + } + + private async processMpesaCollectionUpdate(update: MpesaCollectionUpdateDto) { + this.logger.log('Processing Mpesa Collection Update'); + const mpesa = + await this.intasendService.getMpesaTrackerFromCollectionUpdate(update); + + const swap = await this.prismaService.mpesaOnrampSwap.findUniqueOrThrow({ + where: { + id: update.invoice_id, + collectionTracker: update.invoice_id, + }, + }); + if (!swap) { throw new Error('Failed to create or update swap'); } let updates: { state: SwapTransactionState }; switch (mpesa.state) { - case MpesaTractactionState.Complete: + case MpesaTransactionState.Complete: const { state } = await this.swapToBtc(swap); updates = { state }; break; - case MpesaTractactionState.Processing: + case MpesaTransactionState.Processing: updates = { state: SwapTransactionState.PROCESSING }; break; - case MpesaTractactionState.Failed: + case MpesaTransactionState.Failed: updates = { state: SwapTransactionState.FAILED }; break; - case MpesaTractactionState.Retry: + case MpesaTransactionState.Retry: updates = { state: SwapTransactionState.RETRY }; break; - case MpesaTractactionState.Pending: + case MpesaTransactionState.Pending: updates = { state: SwapTransactionState.PENDING }; break; } @@ -421,6 +390,32 @@ export class SwapService { throw new Error('Attempted swap to btc while mpesa is still pending'); } + private async processMpesaPaymentUpdate(update: MpesaPaymentUpdateDto) { + this.logger.log('Processing Mpesa Payment Update'); + const mpesa = + await this.intasendService.getMpesaTrackerFromPaymentUpdate(update); + + const swap = await this.prismaService.mpesaOfframpSwap.findUnique({ + where: { + paymentTracker: update.file_id, + }, + }); + + if (!swap) { + throw new Error('Failed to create or update swap'); + } + + await this.prismaService.mpesaOfframpSwap.update({ + where: { id: swap.id }, + data: { + state: mapMpesaTxStateToSwapTxState(mpesa.state), + }, + }); + + this.logger.log('Swap Updated'); + return; + } + @OnEvent(fedimint_receive_success) private async handleSuccessfulReceive({ context, @@ -428,6 +423,27 @@ export class SwapService { }: ReceivePaymentSuccessEvent) { this.logger.log('Successfully received payment'); this.logger.log(`Context : ${context}, OperationId: ${operationId}`); + + const swap = await this.prismaService.mpesaOfframpSwap.findUnique({ + where: { id: operationId }, + }); + + const amount = Number(swap.amountSats) * Number(swap.rate); + + const { id } = await this.intasendService.sendMpesaPayment({ + amount: amount.toString(), + account: swap.phone, + name: 'bitsacco', + narrative: 'withdrawal', + }); + + await this.prismaService.mpesaOfframpSwap.update({ + where: { id: operationId }, + data: { + paymentTracker: id, + state: SwapTransactionState.PROCESSING, + }, + }); } @OnEvent(fedimint_receive_failure) @@ -440,6 +456,23 @@ export class SwapService { } } +function mapMpesaTxStateToSwapTxState( + state: MpesaTransactionState, +): SwapTransactionState { + switch (state) { + case MpesaTransactionState.Complete: + return SwapTransactionState.COMPLETE; + case MpesaTransactionState.Processing: + return SwapTransactionState.PROCESSING; + case MpesaTransactionState.Failed: + return SwapTransactionState.FAILED; + case MpesaTransactionState.Retry: + return SwapTransactionState.RETRY; + case MpesaTransactionState.Pending: + return SwapTransactionState.PENDING; + } +} + function mapSwapTxStateToSwapStatus(state: SwapTransactionState): SwapStatus { switch (state) { case SwapTransactionState.PENDING: @@ -453,12 +486,3 @@ function mapSwapTxStateToSwapStatus(state: SwapTransactionState): SwapStatus { return SwapStatus.PROCESSING; } } - -interface STKPushCache { - lightning: string; - phone: string; - amount: string; - rate: string; - state: MpesaTractactionState; - ref: string; -} diff --git a/libs/common/src/dto/create-offramp-swap.dto.ts b/libs/common/src/dto/create-offramp-swap.dto.ts index 05dadb3..87c1dc2 100644 --- a/libs/common/src/dto/create-offramp-swap.dto.ts +++ b/libs/common/src/dto/create-offramp-swap.dto.ts @@ -11,18 +11,11 @@ import { ApiProperty } from '@nestjs/swagger'; import { Currency, IsStringifiedNumberConstraint, - MobileMoney, OfframpSwapRequest, OfframpSwapTarget, } from '../types'; import { QuoteDto } from './quote.dto'; - -class MobileMoneyDto implements MobileMoney { - @IsString() - @Type(() => String) - @ApiProperty() - phone: string; -} +import { MobileMoneyDto } from './payments.dto'; class OfframpSwapTargetDto implements OfframpSwapTarget { @IsEnum(Currency) @@ -50,7 +43,7 @@ export class CreateOfframpSwapDto implements OfframpSwapRequest { @Validate(IsStringifiedNumberConstraint) @Type(() => String) @ApiProperty() - amount: string; + amountFiat: string; @IsNotEmpty() @ApiProperty({ type: OfframpSwapTargetDto }) diff --git a/libs/common/src/dto/create-onramp-swap.dto.ts b/libs/common/src/dto/create-onramp-swap.dto.ts index 64d8b67..f0d73bf 100644 --- a/libs/common/src/dto/create-onramp-swap.dto.ts +++ b/libs/common/src/dto/create-onramp-swap.dto.ts @@ -1,9 +1,39 @@ +import { + IsString, + IsOptional, + IsNotEmpty, + Validate, + IsDefined, + IsEnum, +} from 'class-validator'; import { Type } from 'class-transformer'; -import { IsString, IsOptional, IsNotEmpty, Validate } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; -import { OnrampSwapRequest, IsStringifiedNumberConstraint } from '../types'; +import { + OnrampSwapRequest, + IsStringifiedNumberConstraint, + OnrampSwapSource, + Currency, + OnrampSwapTarget, +} from '../types'; +import { Bolt11InvoiceDto, MobileMoneyDto } from './payments.dto'; import { QuoteDto } from './quote.dto'; +class OnrampSwapSourceDto implements OnrampSwapSource { + @IsEnum(Currency) + @ApiProperty({ enum: Currency, enumName: 'Currency' }) + currency: Currency; + + @IsDefined() + @ApiProperty({ type: MobileMoneyDto }) + origin: MobileMoneyDto; +} + +class OnrampSwapTargetDto implements OnrampSwapTarget { + @IsDefined() + @ApiProperty({ type: Bolt11InvoiceDto }) + invoice: Bolt11InvoiceDto; +} + export class CreateOnrampSwapDto implements OnrampSwapRequest { @IsOptional() @ApiProperty({ type: QuoteDto }) @@ -20,17 +50,13 @@ export class CreateOnrampSwapDto implements OnrampSwapRequest { @Validate(IsStringifiedNumberConstraint) @Type(() => String) @ApiProperty() - amount: string; + amountFiat: string; @IsNotEmpty() - @IsString() - @Type(() => String) - @ApiProperty() - phone: string; + @ApiProperty({ type: OnrampSwapSourceDto }) + source: OnrampSwapSourceDto; @IsNotEmpty() - @IsString() - @Type(() => String) - @ApiProperty() - lightning: string; + @ApiProperty({ type: OnrampSwapTargetDto }) + target: OnrampSwapTargetDto; } diff --git a/libs/common/src/dto/payments.dto.ts b/libs/common/src/dto/payments.dto.ts new file mode 100644 index 0000000..08ca5d2 --- /dev/null +++ b/libs/common/src/dto/payments.dto.ts @@ -0,0 +1,18 @@ +import { Type } from 'class-transformer'; +import { IsString } from 'class-validator'; +import { ApiProperty } from '@nestjs/swagger'; +import { Bolt11, MobileMoney } from '../types'; + +export class MobileMoneyDto implements MobileMoney { + @IsString() + @Type(() => String) + @ApiProperty() + phone: string; +} + +export class Bolt11InvoiceDto implements Bolt11 { + @IsString() + @Type(() => String) + @ApiProperty() + invoice: string; +} diff --git a/libs/common/src/types/proto/swap.ts b/libs/common/src/types/proto/swap.ts index 834ed92..911c27a 100644 --- a/libs/common/src/types/proto/swap.ts +++ b/libs/common/src/types/proto/swap.ts @@ -93,11 +93,23 @@ export interface OnrampSwapRequest { * Amount to swap * Any transaction fees will be deducted from this amount */ - amount: string; - /** If provided, the service will attempt mobile money onramp */ - phone?: string | undefined; - /** If provided, the service will attempt to pay a Lightning Network invoice */ - lightning?: string | undefined; + amountFiat: string; + /** Source of the swap */ + source: OnrampSwapSource | undefined; + /** Target of the swap */ + target: OnrampSwapTarget | undefined; +} + +export interface OnrampSwapSource { + /** Currency code for the target currency */ + currency: Currency; + /** Mobile money destination */ + phone?: MobileMoney | undefined; +} + +export interface OnrampSwapTarget { + /** Lightning protocol destination */ + invoice?: Bolt11 | undefined; } export interface OfframpSwapRequest { @@ -110,7 +122,7 @@ export interface OfframpSwapRequest { * Amount to swap * Any transaction fees will be deducted from this amount */ - amount: string; + amountFiat: string; /** Target of the swap */ target: OfframpSwapTarget | undefined; } @@ -119,7 +131,7 @@ export interface OfframpSwapTarget { /** Currency code for the target currency */ currency: Currency; /** Mobile money destination */ - mobileMoney?: MobileMoney | undefined; + phone?: MobileMoney | undefined; } export interface MobileMoney { @@ -127,6 +139,11 @@ export interface MobileMoney { phone: string; } +export interface Bolt11 { + /** Bolt11 lightning invoice */ + invoice: string; +} + /** FindSwapRequest: Represents a request to find a swap. */ export interface FindSwapRequest { /** Unique identifier for the swap */ diff --git a/proto/swap.proto b/proto/swap.proto index c6f41bd..6a700e9 100644 --- a/proto/swap.proto +++ b/proto/swap.proto @@ -88,23 +88,35 @@ message OnrampSwapRequest { // Amount to swap // Any transaction fees will be deducted from this amount - string amount = 3; + string amountFiat = 3; reserved 4, 5, 6, 7, 8, 9; // Source of the swap - oneof source { - // If provided, the service will attempt mobile money onramp - string phone = 10; - } + OnrampSwapSource source = 10; // Target of the swap - oneof target { - // If provided, the service will attempt to pay a Lightning Network invoice - string lightning = 11; + OnrampSwapTarget target = 11; +} + +message OnrampSwapSource { + // Currency code for the target currency + Currency currency = 1; + + // Target destination + oneof origin { + // Mobile money destination + MobileMoney phone = 2; } } +message OnrampSwapTarget { + // Payout destination + oneof payout { + // Lightning protocol destination + Bolt11 invoice = 2; + } +} message OfframpSwapRequest { // Optional reference to a quote. @@ -113,7 +125,7 @@ message OfframpSwapRequest { // Amount to swap // Any transaction fees will be deducted from this amount - string amount = 2; + string amountFiat = 2; // Target of the swap OfframpSwapTarget target = 3; @@ -123,10 +135,10 @@ message OfframpSwapTarget { // Currency code for the target currency Currency currency = 1; - // Target destination - oneof destination { + // Payout destination + oneof payout { // Mobile money destination - MobileMoney mobile_money = 2; + MobileMoney phone = 2; } } @@ -135,6 +147,11 @@ message MobileMoney { string phone = 1; } +message Bolt11 { + // Bolt11 lightning invoice + string invoice = 1; +} + // FindSwapRequest: Represents a request to find a swap. message FindSwapRequest { // Unique identifier for the swap diff --git a/scripts/swap.manual.dev.sh b/scripts/swap.manual.dev.sh index fae4122..0cdf6a2 100755 --- a/scripts/swap.manual.dev.sh +++ b/scripts/swap.manual.dev.sh @@ -1,3 +1,3 @@ -docker compose -f compose.yml -p os up -d api postgres redis swap-clientd +docker compose -f compose.yml -p os up -d postgres redis swap-clientd bunx dotenv -e apps/swap/.env.manual bun run dev swap -- --trace-deprecation