diff --git a/src/common/payment.ts b/src/common/payment.ts index e5276393..63b8397c 100644 --- a/src/common/payment.ts +++ b/src/common/payment.ts @@ -81,7 +81,15 @@ export class TurboUnauthenticatedPaymentService allowedStatuses: [200, 404], }); - return balance.winc ? balance : { winc: '0' }; + return balance.winc + ? balance + : { + winc: '0', + controlledWinc: '0', + effectiveBalance: '0', + givenApprovals: [], + receivedApprovals: [], + }; } public getFiatRates(): Promise { diff --git a/src/types.ts b/src/types.ts index c7d15fc5..ac051761 100644 --- a/src/types.ts +++ b/src/types.ts @@ -155,10 +155,35 @@ export type TurboCheckoutSessionResponse = TurboWincForFiatResponse & { paymentAmount: number; }; -export type TurboBalanceResponse = Omit< - TurboPriceResponse, - 'adjustments' | 'fees' ->; +export interface DelegatedPaymentApproval { + approvalDataItemId: TransactionId; + approvedAddress: UserAddress; + payerAddress: UserAddress; + approvedWincAmount: string; + usedWincAmount: string; + creationDate: string; + expirationDate: string | undefined; +} + +export type TurboBalanceResponse = { + /** + * Amount of winc controlled by the user, that they could + * spend or share if all current approvals were revoked + */ + controlledWinc: string; + /** + * Amount of winc that a user can currently spend or share + */ + winc: string; + /** + * Amount of winc that a user can currently spend or share + * plus the amount of remaining winc from received approvals + */ + effectiveBalance: string; + + receivedApprovals: DelegatedPaymentApproval[]; + givenApprovals: DelegatedPaymentApproval[]; +}; export type TurboFiatToArResponse = { currency: Currency;