@xyo-network/payment-payload-plugins 3.0.21 → 3.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/Discount/Payload/Coupon/Conditions/AppraisalAmountCondition.d.ts +3 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/AppraisalAmountCondition.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/AssetQuantityCondition.d.ts +3 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/AssetQuantityCondition.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/BuyerCondition.d.ts +29 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/BuyerCondition.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/index.d.ts +4 -0
- package/dist/neutral/Discount/Payload/Coupon/Conditions/index.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/index.d.ts +1 -0
- package/dist/neutral/Discount/Payload/Coupon/index.d.ts.map +1 -1
- package/dist/neutral/Discount/Payload/Coupon/types/Condition.d.ts +7 -0
- package/dist/neutral/Discount/Payload/Coupon/types/Condition.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts +1 -0
- package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/agent.d.ts +2 -2
- package/dist/neutral/Escrow/validators/escrow/agent.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/appraisal.d.ts +5 -5
- package/dist/neutral/Escrow/validators/escrow/appraisal.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/appraisalAuthorities.d.ts +3 -3
- package/dist/neutral/Escrow/validators/escrow/appraisalAuthorities.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/assets.d.ts +2 -2
- package/dist/neutral/Escrow/validators/escrow/assets.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/buyer.d.ts +2 -2
- package/dist/neutral/Escrow/validators/escrow/buyer.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/buyerSecret.d.ts +4 -4
- package/dist/neutral/Escrow/validators/escrow/buyerSecret.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/nbfExp.d.ts +2 -2
- package/dist/neutral/Escrow/validators/escrow/nbfExp.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/paymentAuthorities.d.ts +2 -2
- package/dist/neutral/Escrow/validators/escrow/paymentAuthorities.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/seller.d.ts +2 -2
- package/dist/neutral/Escrow/validators/escrow/seller.d.ts.map +1 -1
- package/dist/neutral/Escrow/validators/escrow/sellerSecret.d.ts +4 -4
- package/dist/neutral/Escrow/validators/escrow/sellerSecret.d.ts.map +1 -1
- package/dist/neutral/index.mjs +155 -60
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/Discount/Payload/Coupon/Conditions/AppraisalAmountCondition.ts +43 -0
- package/src/Discount/Payload/Coupon/Conditions/AssetQuantityCondition.ts +25 -0
- package/src/Discount/Payload/Coupon/Conditions/BuyerCondition.ts +50 -0
- package/src/Discount/Payload/Coupon/Conditions/index.ts +3 -0
- package/src/Discount/Payload/Coupon/index.ts +1 -0
- package/src/Discount/Payload/Coupon/types/Condition.ts +24 -0
- package/src/Discount/Payload/Coupon/types/index.ts +1 -0
- package/src/Escrow/validators/escrow/agent.ts +2 -2
- package/src/Escrow/validators/escrow/appraisal.ts +5 -5
- package/src/Escrow/validators/escrow/appraisalAuthorities.ts +3 -3
- package/src/Escrow/validators/escrow/assets.ts +2 -2
- package/src/Escrow/validators/escrow/buyer.ts +2 -2
- package/src/Escrow/validators/escrow/buyerSecret.ts +5 -5
- package/src/Escrow/validators/escrow/nbfExp.ts +2 -2
- package/src/Escrow/validators/escrow/paymentAuthorities.ts +2 -2
- package/src/Escrow/validators/escrow/seller.ts +2 -2
- package/src/Escrow/validators/escrow/sellerSecret.ts +5 -5
|
@@ -5,7 +5,7 @@ import { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'
|
|
|
5
5
|
import type { HashLeaseEstimate } from '@xyo-network/diviner-hash-lease'
|
|
6
6
|
import { isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'
|
|
7
7
|
import type {
|
|
8
|
-
Payload,
|
|
8
|
+
Payload, SyncPayloadValidationFunction, WithMeta, WithSources,
|
|
9
9
|
} from '@xyo-network/payload-model'
|
|
10
10
|
|
|
11
11
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
@@ -17,7 +17,7 @@ const name = 'EscrowTerms.appraisal'
|
|
|
17
17
|
* A function that validates the escrow terms for tbe existence of appraisals
|
|
18
18
|
* @returns True if the escrow terms contain appraisals, false otherwise
|
|
19
19
|
*/
|
|
20
|
-
export const appraisalsExistValidator:
|
|
20
|
+
export const appraisalsExistValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
21
21
|
// Validate we have appraisals
|
|
22
22
|
const appraisals = terms.appraisals
|
|
23
23
|
if (!appraisals || appraisals.length === 0) {
|
|
@@ -32,7 +32,7 @@ export const appraisalsExistValidator: PayloadValidationFunction<EscrowTerms> =
|
|
|
32
32
|
* @param dictionary Payload dictionary of the escrow terms
|
|
33
33
|
* @returns A function that validates the escrow terms for appraisals which are from valid authorities
|
|
34
34
|
*/
|
|
35
|
-
export const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>):
|
|
35
|
+
export const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
36
36
|
return (terms: EscrowTerms) => {
|
|
37
37
|
const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)
|
|
38
38
|
const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)
|
|
@@ -70,7 +70,7 @@ export const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Ha
|
|
|
70
70
|
export const getAppraisalsValidValidator = (
|
|
71
71
|
dictionary: Record<Hash, WithMeta<Payload>>,
|
|
72
72
|
minimumExp: number,
|
|
73
|
-
):
|
|
73
|
+
): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
74
74
|
return (terms: EscrowTerms) => {
|
|
75
75
|
// Verify we have an estimate for each of the assets
|
|
76
76
|
const estimatesByAsset = getEstimatesByAsset(terms, dictionary)
|
|
@@ -94,7 +94,7 @@ export const getAppraisalsValidValidator = (
|
|
|
94
94
|
* @param dictionary Payload dictionary of the escrow terms
|
|
95
95
|
* @returns A function that validates the escrow terms for appraisals
|
|
96
96
|
*/
|
|
97
|
-
export const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>):
|
|
97
|
+
export const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
98
98
|
return (terms: EscrowTerms) => {
|
|
99
99
|
// Verify we have an estimate for each of the assets
|
|
100
100
|
const estimatesByAsset = getEstimatesByAsset(terms, dictionary)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asAddress } from '@xylabs/hex'
|
|
2
2
|
import type { ModuleIdentifier } from '@xyo-network/module-model'
|
|
3
|
-
import type {
|
|
3
|
+
import type { SyncPayloadValidationFunction } from '@xyo-network/payload-model'
|
|
4
4
|
|
|
5
5
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
6
6
|
import { moduleIdentifiersContainsAllOf } from '../common/index.ts'
|
|
@@ -11,7 +11,7 @@ const name = 'EscrowTerms.appraisalAuthorities'
|
|
|
11
11
|
* A function that validates the escrow terms for appraisalAuthorities
|
|
12
12
|
* @returns True if the escrow terms contain appraisalAuthorities, false otherwise
|
|
13
13
|
*/
|
|
14
|
-
export const appraisalAuthoritiesExistValidator:
|
|
14
|
+
export const appraisalAuthoritiesExistValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
15
15
|
// Validate we have appraisalAuthorities
|
|
16
16
|
const appraisalAuthorities = terms.appraisalAuthorities
|
|
17
17
|
if (!appraisalAuthorities || appraisalAuthorities.length === 0) {
|
|
@@ -26,7 +26,7 @@ export const appraisalAuthoritiesExistValidator: PayloadValidationFunction<Escro
|
|
|
26
26
|
return true
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]):
|
|
29
|
+
export const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
30
30
|
return (terms: EscrowTerms) => {
|
|
31
31
|
const result = moduleIdentifiersContainsAllOf(terms, t => t.appraisalAuthorities, allowed, true)
|
|
32
32
|
if (!result) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SyncPayloadValidationFunction } from '@xyo-network/payload-model'
|
|
2
2
|
|
|
3
3
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ const name = 'EscrowTerms.assets'
|
|
|
8
8
|
* Returns a function that validates the escrow terms for assets
|
|
9
9
|
* @returns A function that validates the escrow terms for assets
|
|
10
10
|
*/
|
|
11
|
-
export const assetsExistValidator:
|
|
11
|
+
export const assetsExistValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
12
12
|
// Validate we have assets
|
|
13
13
|
const assets = terms.assets
|
|
14
14
|
if (!assets || assets.length === 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asAddress } from '@xylabs/hex'
|
|
2
|
-
import type {
|
|
2
|
+
import type { SyncPayloadValidationFunction } from '@xyo-network/payload-model'
|
|
3
3
|
|
|
4
4
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ const name = 'EscrowTerms.buyer'
|
|
|
9
9
|
* A function that validates the escrow terms for buyer
|
|
10
10
|
* @returns True if the escrow terms contain buyer, false otherwise
|
|
11
11
|
*/
|
|
12
|
-
export const buyerExistsValidator:
|
|
12
|
+
export const buyerExistsValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
13
13
|
// Validate we have buyer
|
|
14
14
|
const buyer = terms.buyer
|
|
15
15
|
if (!buyer || buyer.length === 0) {
|
|
@@ -3,7 +3,7 @@ import type { Hash } from '@xylabs/hex'
|
|
|
3
3
|
import { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'
|
|
4
4
|
import { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'
|
|
5
5
|
import type {
|
|
6
|
-
Payload,
|
|
6
|
+
AsyncPayloadValidationFunction, Payload, SyncPayloadValidationFunction, WithMeta,
|
|
7
7
|
} from '@xyo-network/payload-model'
|
|
8
8
|
|
|
9
9
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
@@ -14,7 +14,7 @@ const name = 'EscrowTerms.buyerSecret'
|
|
|
14
14
|
* Returns a function that validates the escrow terms for buyerSecret
|
|
15
15
|
* @returns A function that validates the escrow terms for buyerSecret
|
|
16
16
|
*/
|
|
17
|
-
export const buyerSecretExistsValidator:
|
|
17
|
+
export const buyerSecretExistsValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
18
18
|
// Validate we have buyerSecret
|
|
19
19
|
const buyerSecret = terms.buyerSecret
|
|
20
20
|
if (!buyerSecret || buyerSecret.length === 0) {
|
|
@@ -29,7 +29,7 @@ export const buyerSecretExistsValidator: PayloadValidationFunction<EscrowTerms>
|
|
|
29
29
|
* @param dictionary Payload dictionary of the escrow terms
|
|
30
30
|
* @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary
|
|
31
31
|
*/
|
|
32
|
-
export const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>):
|
|
32
|
+
export const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
33
33
|
return (terms: EscrowTerms) => {
|
|
34
34
|
const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)
|
|
35
35
|
if (!dictionary[buyerSecret]) {
|
|
@@ -45,8 +45,8 @@ export const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMet
|
|
|
45
45
|
* @param dictionary Payload dictionary of the escrow terms
|
|
46
46
|
* @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer
|
|
47
47
|
*/
|
|
48
|
-
export const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>):
|
|
49
|
-
return async (terms: EscrowTerms) => {
|
|
48
|
+
export const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): AsyncPayloadValidationFunction<EscrowTerms> => {
|
|
49
|
+
return async (terms: EscrowTerms): Promise<boolean> => {
|
|
50
50
|
const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)
|
|
51
51
|
const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)
|
|
52
52
|
// Buyer-signed buyer secrets
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SyncPayloadValidationFunction } from '@xyo-network/payload-model'
|
|
2
2
|
|
|
3
3
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
4
4
|
|
|
5
|
-
export const getNbfExpValidator = (now: number, minRequiredDuration: number):
|
|
5
|
+
export const getNbfExpValidator = (now: number, minRequiredDuration: number): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
6
6
|
const minExp = now + minRequiredDuration
|
|
7
7
|
return (terms: EscrowTerms) => {
|
|
8
8
|
const { exp, nbf } = terms
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ModuleIdentifier } from '@xyo-network/module-model'
|
|
2
|
-
import type {
|
|
2
|
+
import type { SyncPayloadValidationFunction } from '@xyo-network/payload-model'
|
|
3
3
|
|
|
4
4
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
5
5
|
import { moduleIdentifiersContainsAllOf } from '../common/index.ts'
|
|
6
6
|
|
|
7
7
|
const name = 'EscrowTerms.paymentAuthorities'
|
|
8
8
|
|
|
9
|
-
export const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]):
|
|
9
|
+
export const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
10
10
|
return (terms: EscrowTerms) => {
|
|
11
11
|
const result = moduleIdentifiersContainsAllOf(terms, t => t.paymentAuthorities, allowed, true)
|
|
12
12
|
if (!result) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { asAddress } from '@xylabs/hex'
|
|
2
|
-
import type {
|
|
2
|
+
import type { SyncPayloadValidationFunction } from '@xyo-network/payload-model'
|
|
3
3
|
|
|
4
4
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ const name = 'EscrowTerms.seller'
|
|
|
9
9
|
* A function that validates the escrow terms for seller
|
|
10
10
|
* @returns True if the escrow terms contain seller, false otherwise
|
|
11
11
|
*/
|
|
12
|
-
export const sellerExistsValidator:
|
|
12
|
+
export const sellerExistsValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
13
13
|
// Validate we have seller
|
|
14
14
|
const seller = terms.seller
|
|
15
15
|
if (!seller || seller.length === 0) {
|
|
@@ -3,7 +3,7 @@ import type { Hash } from '@xylabs/hex'
|
|
|
3
3
|
import { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'
|
|
4
4
|
import { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'
|
|
5
5
|
import type {
|
|
6
|
-
Payload,
|
|
6
|
+
AsyncPayloadValidationFunction, Payload, SyncPayloadValidationFunction, WithMeta,
|
|
7
7
|
} from '@xyo-network/payload-model'
|
|
8
8
|
|
|
9
9
|
import type { EscrowTerms } from '../../Terms.ts'
|
|
@@ -14,7 +14,7 @@ const name = 'EscrowTerms.sellerSecret'
|
|
|
14
14
|
* Returns a function that validates the escrow terms for sellerSecret
|
|
15
15
|
* @returns A function that validates the escrow terms for sellerSecret
|
|
16
16
|
*/
|
|
17
|
-
export const sellerSecretExistsValidator:
|
|
17
|
+
export const sellerSecretExistsValidator: SyncPayloadValidationFunction<EscrowTerms> = (terms: EscrowTerms) => {
|
|
18
18
|
// Validate we have sellerSecret
|
|
19
19
|
const sellerSecret = terms.sellerSecret
|
|
20
20
|
if (!sellerSecret || sellerSecret.length === 0) {
|
|
@@ -29,7 +29,7 @@ export const sellerSecretExistsValidator: PayloadValidationFunction<EscrowTerms>
|
|
|
29
29
|
* @param dictionary Payload dictionary of the escrow terms
|
|
30
30
|
* @returns A function that validates the escrow terms for the existence of the sellerSecret in the dictionary
|
|
31
31
|
*/
|
|
32
|
-
export const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>):
|
|
32
|
+
export const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): SyncPayloadValidationFunction<EscrowTerms> => {
|
|
33
33
|
return (terms: EscrowTerms) => {
|
|
34
34
|
const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)
|
|
35
35
|
if (!dictionary[sellerSecret]) {
|
|
@@ -45,8 +45,8 @@ export const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMe
|
|
|
45
45
|
* @param dictionary Payload dictionary of the escrow terms
|
|
46
46
|
* @returns A function that validates the escrow terms for the existence of the sellerSecret signed by the seller
|
|
47
47
|
*/
|
|
48
|
-
export const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>):
|
|
49
|
-
return async (terms: EscrowTerms) => {
|
|
48
|
+
export const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): AsyncPayloadValidationFunction<EscrowTerms> => {
|
|
49
|
+
return async (terms: EscrowTerms): Promise<boolean> => {
|
|
50
50
|
const seller = assertEx(terms.seller, () => `${name}: No seller: ${terms.seller}`)
|
|
51
51
|
const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)
|
|
52
52
|
// Seller-signed seller secrets
|