From 5191cdc3fae5dcbb9e91d8596d7c3b3a6ed2ced7 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:22:50 -0500 Subject: [PATCH 1/7] Add Identity functions for additional escrow types --- .../payload/packages/payments/src/Escrow/Terms.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/payload/packages/payments/src/Escrow/Terms.ts b/packages/payload/packages/payments/src/Escrow/Terms.ts index 3bc217076..60f739379 100644 --- a/packages/payload/packages/payments/src/Escrow/Terms.ts +++ b/packages/payload/packages/payments/src/Escrow/Terms.ts @@ -1,5 +1,5 @@ import { Address, Hash } from '@xylabs/hex' -import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model' +import { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources, Payload } from '@xyo-network/payload-model' import { EscrowSchema } from './Schema' @@ -59,4 +59,17 @@ export interface EscrowTermsFields { */ export type EscrowTerms = Payload, EscrowTermsSchema> +/** + * Identity function for determining if an object is an EscrowTerms + */ export const isEscrowTerms = isPayloadOfSchemaType(EscrowTermsSchema) + +/** + * Identity function for determining if an object is an EscrowTerms with sources + */ +export const isEscrowTermsWithSources = isPayloadOfSchemaTypeWithSources(EscrowTermsSchema) + +/** + * Identity function for determining if an object is an EscrowTerms with meta + */ +export const isEscrowTermsWithMeta = isPayloadOfSchemaTypeWithMeta(EscrowTermsSchema) From ac7ce5f841d394267c0ea947059f6f9c78cfd03a Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:23:16 -0500 Subject: [PATCH 2/7] Rename property to match escrow terms --- packages/payload/packages/payments/src/Purchase.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/payload/packages/payments/src/Purchase.ts b/packages/payload/packages/payments/src/Purchase.ts index 3246d78fd..6761e664d 100644 --- a/packages/payload/packages/payments/src/Purchase.ts +++ b/packages/payload/packages/payments/src/Purchase.ts @@ -6,9 +6,9 @@ export const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase' export interface PurchaseFields { /** - * The hashes that were purchased + * The things that were purchased */ - hashes: Hash[] + assets: Hash[] /** * The payments for this purchase. Array to allow for multiple payments * for a single quote. From 7f071a2bc1e4622dd1ba2f0edd573d9f1b12977d Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:24:56 -0500 Subject: [PATCH 3/7] Add Identity functions for additional payment types --- .../payload/packages/payments/src/Payment.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/payload/packages/payments/src/Payment.ts b/packages/payload/packages/payments/src/Payment.ts index 2d1dafc90..fd81b509d 100644 --- a/packages/payload/packages/payments/src/Payment.ts +++ b/packages/payload/packages/payments/src/Payment.ts @@ -1,4 +1,9 @@ -import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model' +import { + isPayloadOfSchemaType, + isPayloadOfSchemaTypeWithMeta, + isPayloadOfSchemaTypeWithSources, + PayloadWithSources, +} from '@xyo-network/payload-model' import { SupportedCurrency } from './Currency' @@ -21,4 +26,17 @@ export interface PaymentFields { */ export type Payment = PayloadWithSources +/** + * Identity function for determine if an object is a Payment + */ export const isPayment = isPayloadOfSchemaType(PaymentSchema) + +/** + * Identity function for determine if an object is a Payment with sources + */ +export const isPaymentWithSources = isPayloadOfSchemaTypeWithSources(PaymentSchema) + +/** + * Identity function for determine if an object is a Payment with meta + */ +export const isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta(PaymentSchema) From ddb193683e25d87081ec54e46d46f3f8b92a0be1 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:26:03 -0500 Subject: [PATCH 4/7] Add Identity functions for additional purchase types --- .../payload/packages/payments/src/Purchase.ts | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/payload/packages/payments/src/Purchase.ts b/packages/payload/packages/payments/src/Purchase.ts index 6761e664d..a4e403aea 100644 --- a/packages/payload/packages/payments/src/Purchase.ts +++ b/packages/payload/packages/payments/src/Purchase.ts @@ -1,5 +1,10 @@ import { Hash } from '@xylabs/hex' -import { PayloadWithSources } from '@xyo-network/payload-model' +import { + isPayloadOfSchemaType, + isPayloadOfSchemaTypeWithMeta, + isPayloadOfSchemaTypeWithSources, + PayloadWithSources, +} from '@xyo-network/payload-model' export type PurchaseSchema = 'network.xyo.payments.purchase' export const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase' @@ -20,3 +25,18 @@ export interface PurchaseFields { * A purchase ties a payment made to a quote */ export type Purchase = PayloadWithSources + +/** + * Identity function for determine if an object is a Payment + */ +export const isPayment = isPayloadOfSchemaType(PurchaseSchema) + +/** + * Identity function for determine if an object is a Payment with sources + */ +export const isPaymentWithSources = isPayloadOfSchemaTypeWithSources(PurchaseSchema) + +/** + * Identity function for determine if an object is a Payment with meta + */ +export const isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta(PurchaseSchema) From c0fa45c10e803ed4ae706aea3a752955f51db9f4 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:34:15 -0500 Subject: [PATCH 5/7] Update description --- packages/payload/packages/payments/src/Payment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/payload/packages/payments/src/Payment.ts b/packages/payload/packages/payments/src/Payment.ts index fd81b509d..79cbefac8 100644 --- a/packages/payload/packages/payments/src/Payment.ts +++ b/packages/payload/packages/payments/src/Payment.ts @@ -22,7 +22,7 @@ export interface PaymentFields { } /** - * A payment is a record of a payment made + * A payment is a record of an amount to be paid */ export type Payment = PayloadWithSources From 1eee09bc1ed7f018c19f96299b92e1d22ded440d Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:34:40 -0500 Subject: [PATCH 6/7] Change purchase to reference receipts --- .../payload/packages/payments/src/Purchase.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/payload/packages/payments/src/Purchase.ts b/packages/payload/packages/payments/src/Purchase.ts index a4e403aea..aae9de853 100644 --- a/packages/payload/packages/payments/src/Purchase.ts +++ b/packages/payload/packages/payments/src/Purchase.ts @@ -15,10 +15,10 @@ export interface PurchaseFields { */ assets: Hash[] /** - * The payments for this purchase. Array to allow for multiple payments + * The receipts for payments for this purchase. Array to allow for multiple payments * for a single quote. */ - payments: Hash[] + receipts: Hash[] } /** @@ -27,16 +27,16 @@ export interface PurchaseFields { export type Purchase = PayloadWithSources /** - * Identity function for determine if an object is a Payment + * Identity function for determine if an object is a Purchase */ -export const isPayment = isPayloadOfSchemaType(PurchaseSchema) +export const isPurchase = isPayloadOfSchemaType(PurchaseSchema) /** - * Identity function for determine if an object is a Payment with sources + * Identity function for determine if an object is a Purchase with sources */ -export const isPaymentWithSources = isPayloadOfSchemaTypeWithSources(PurchaseSchema) +export const isPurchaseWithSources = isPayloadOfSchemaTypeWithSources(PurchaseSchema) /** - * Identity function for determine if an object is a Payment with meta + * Identity function for determine if an object is a Purchase with meta */ -export const isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta(PurchaseSchema) +export const isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta(PurchaseSchema) From e044216ff060f18c102ae4d1ef43c166a829f633 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Fri, 5 Apr 2024 18:34:50 -0500 Subject: [PATCH 7/7] Add receipts --- .../payload/packages/payments/src/Receipt.ts | 42 +++++++++++++++++++ .../payload/packages/payments/src/index.ts | 1 + 2 files changed, 43 insertions(+) create mode 100644 packages/payload/packages/payments/src/Receipt.ts diff --git a/packages/payload/packages/payments/src/Receipt.ts b/packages/payload/packages/payments/src/Receipt.ts new file mode 100644 index 000000000..211091c74 --- /dev/null +++ b/packages/payload/packages/payments/src/Receipt.ts @@ -0,0 +1,42 @@ +import { + isPayloadOfSchemaType, + isPayloadOfSchemaTypeWithMeta, + isPayloadOfSchemaTypeWithSources, + PayloadWithSources, +} from '@xyo-network/payload-model' + +import { SupportedCurrency } from './Currency' + +export type ReceiptSchema = 'network.xyo.payments.receipt' +export const ReceiptSchema: ReceiptSchema = 'network.xyo.payments.receipt' + +export interface ReceiptFields { + /** + * The amount paid + */ + amount: number + /** + * The currency of the amount paid + */ + currency: SupportedCurrency +} + +/** + * A receipt is a record of a payment made + */ +export type Receipt = PayloadWithSources + +/** + * Identity function for determine if an object is a Receipt + */ +export const isReceipt = isPayloadOfSchemaType(ReceiptSchema) + +/** + * Identity function for determine if an object is a Receipt with sources + */ +export const isReceiptWithSources = isPayloadOfSchemaTypeWithSources(ReceiptSchema) + +/** + * Identity function for determine if an object is a Receipt with meta + */ +export const isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta(ReceiptSchema) diff --git a/packages/payload/packages/payments/src/index.ts b/packages/payload/packages/payments/src/index.ts index 6b57936c2..5f8d8f39b 100644 --- a/packages/payload/packages/payments/src/index.ts +++ b/packages/payload/packages/payments/src/index.ts @@ -2,3 +2,4 @@ export * from './Currency' export * from './Escrow' export * from './Payment' export * from './Purchase' +export * from './Receipt'