diff --git a/apps/backend/pnpm-lock.yaml b/apps/backend/pnpm-lock.yaml index b85cbe7..99dfc25 100644 --- a/apps/backend/pnpm-lock.yaml +++ b/apps/backend/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true diff --git a/apps/backend/src/super-token-accounting/client/types.d.ts b/apps/backend/src/super-token-accounting/client/types.d.ts index e53a60b..119dfc1 100644 --- a/apps/backend/src/super-token-accounting/client/types.d.ts +++ b/apps/backend/src/super-token-accounting/client/types.d.ts @@ -3,14 +3,15 @@ * Do not make direct changes to the file. */ + export interface paths { - '/v1/stream-periods': { + "/v1/stream-periods": { /** @description Fetch virtualized stream periods */ get: { parameters: { query: { /** @description Number array for the Chain IDs you want to limit your accounting data to. */ - chains: components['schemas']['Network'][]; + chains: components["schemas"]["Network"][]; /** @description The addresses array you’re getting accounting data for. */ addresses: string[]; /** @description The Unix timestamp where your accounting data is to start from. */ @@ -18,11 +19,11 @@ export interface paths { /** @description The Unix timestamp where your accounting data is to end. */ end: number; /** @description When getting pricing data for each accounting record, you have the choice as to whether you want the instanteous price at the end of the timeframe of the accounting record or the average price over a certain lag from the end of the timeframe of the accounting record. */ - priceGranularity: components['schemas']['VirtualizationPeriod']; + priceGranularity: components["schemas"]["VirtualizationPeriod"]; /** @description The duration represented in each accounting record in your accounting data. (NB! Please use hourly period with small timeframe or single sender/receiver address.) */ - virtualization: components['schemas']['VirtualizationPeriod']; + virtualization: components["schemas"]["VirtualizationPeriod"]; /** @description The currency with which price data will be displayed in. */ - currency: components['schemas']['Currency']; + currency: components["schemas"]["Currency"]; /** @description Addresses that are either sending or receiving streams from the addresses account(s) that you want to limit your accounting data to. */ counterparties?: string[]; }; @@ -31,7 +32,7 @@ export interface paths { /** @description Array of stream periods containing virtualized periods. */ 200: { content: { - 'application/json': components['schemas']['StreamPeriod'][]; + "application/json": components["schemas"]["StreamPeriod"]; }; }; }; @@ -44,25 +45,9 @@ export type webhooks = Record; export interface components { schemas: { /** @enum {string} */ - VirtualizationPeriod: 'hour' | 'day' | 'week' | 'month' | 'year'; + VirtualizationPeriod: "hour" | "day" | "week" | "month" | "year"; /** @enum {string} */ - Currency: - | 'USD' - | 'EUR' - | 'AUD' - | 'BRL' - | 'CAD' - | 'CHF' - | 'CNY' - | 'GBP' - | 'HKD' - | 'INR' - | 'JPY' - | 'KRW' - | 'MXN' - | 'NOK' - | 'RUB' - | 'SEK'; + Currency: "USD" | "EUR" | "AUD" | "BRL" | "CAD" | "CHF" | "CNY" | "GBP" | "HKD" | "INR" | "JPY" | "KRW" | "MXN" | "NOK" | "RUB" | "SEK"; /** @enum {number} */ Network: 1 | 10 | 56 | 100 | 137 | 42161 | 42220 | 43114 | 8453; Token: { @@ -80,8 +65,8 @@ export interface components { StreamPeriod: { id: string; flowRate: string; - token: components['schemas']['Token']; - chainId: components['schemas']['Network']; + token: components["schemas"]["Token"]; + chainId: components["schemas"]["Network"]; sender: string; receiver: string; startedAtTimestamp: number; @@ -91,11 +76,12 @@ export interface components { stoppedAtBlockNumber?: number; stoppedAtEvent?: string; totalAmountStreamed: string; - virtualPeriods?: components['schemas']['VirtualPeriod'][]; + virtualPeriods?: components["schemas"]["VirtualPeriod"][]; }; }; responses: never; - parameters: {}; + parameters: { + }; requestBodies: never; headers: never; pathItems: never; diff --git a/apps/backend/src/super-token-accounting/super-token-accounting.service.ts b/apps/backend/src/super-token-accounting/super-token-accounting.service.ts index 5dd4064..2196650 100644 --- a/apps/backend/src/super-token-accounting/super-token-accounting.service.ts +++ b/apps/backend/src/super-token-accounting/super-token-accounting.service.ts @@ -53,17 +53,19 @@ export class SuperTokenAccountingService { if (error) { throw error; } else { - const streamPeriods = response.data.filter( - (x) => x.token!.id!.toLowerCase() === superTokenAddress.toLowerCase(), - ); - const sumTransferred = streamPeriods.reduce( - (acc, { sender, totalAmountStreamed }) => - acc + - (sender.toLowerCase() === senderAddress.toLowerCase() ? 1n : -1n) * - (totalAmountStreamed ? BigInt(totalAmountStreamed) : 0n), - 0n, - ); - return sumTransferred; + // const streamPeriods = response.data.filter( + // (x) => x.token!.id!.toLowerCase() === superTokenAddress.toLowerCase(), + // ); + // const sumTransferred = streamPeriods.reduce( + // (acc, { sender, totalAmountStreamed }) => + // acc + + // (sender.toLowerCase() === senderAddress.toLowerCase() ? 1n : -1n) * + // (totalAmountStreamed ? BigInt(totalAmountStreamed) : 0n), + // 0n, + // ); + // return sumTransferred; + + return 0n; } } } diff --git a/apps/backend/src/superfluid-stripe-converter/superfluid-stripe-converter.controller.ts b/apps/backend/src/superfluid-stripe-converter/superfluid-stripe-converter.controller.ts index 4453316..6fe6513 100644 --- a/apps/backend/src/superfluid-stripe-converter/superfluid-stripe-converter.controller.ts +++ b/apps/backend/src/superfluid-stripe-converter/superfluid-stripe-converter.controller.ts @@ -15,6 +15,11 @@ type ProductResponse = { paymentDetails: WidgetProps['paymentDetails']; }; +type InvoiceResponse = { + stripeInvoice: Stripe.Invoice; + productConfig: ProductResponse; +}; + @Controller('superfluid-stripe-converter') export class SuperfluidStripeConverterController { constructor( @@ -93,6 +98,21 @@ export class SuperfluidStripeConverterController { await this.superfluidStripeConfigService.loadOrInitializeLookAndFeelConfig(); return lookAndFeelConfig; } + + @Get('invoice') + async invoice(@Query('invoice-id') invoiceId: string): Promise { + const stripeInvoice = await this.stripeClient.invoices.retrieve(invoiceId); + const product = await this.stripeClient.products.retrieve( + stripeInvoice.lines.data[0].price?.product as string, + ); + + const productConfig = await this.mapStripeProductToCheckoutWidget(product.id); + + return { + stripeInvoice, + productConfig, + }; + } } const logger = new Logger(SuperfluidStripeConverterController.name); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b9f188..7e0e5af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true