@xyo-network/payment-payload-plugins 2.89.1 → 2.89.2
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/browser/Escrow/Schema.d.cts +3 -0
- package/dist/browser/Escrow/Schema.d.cts.map +1 -0
- package/dist/browser/Escrow/Schema.d.mts +3 -0
- package/dist/browser/Escrow/Schema.d.mts.map +1 -0
- package/dist/browser/Escrow/Schema.d.ts +3 -0
- package/dist/browser/Escrow/Schema.d.ts.map +1 -0
- package/dist/browser/Escrow/Terms.d.cts +58 -0
- package/dist/browser/Escrow/Terms.d.cts.map +1 -0
- package/dist/browser/Escrow/Terms.d.mts +58 -0
- package/dist/browser/Escrow/Terms.d.mts.map +1 -0
- package/dist/browser/Escrow/Terms.d.ts +58 -0
- package/dist/browser/Escrow/Terms.d.ts.map +1 -0
- package/dist/browser/Escrow/createEscrowIntent.d.cts +20 -0
- package/dist/browser/Escrow/createEscrowIntent.d.cts.map +1 -0
- package/dist/browser/Escrow/createEscrowIntent.d.mts +20 -0
- package/dist/browser/Escrow/createEscrowIntent.d.mts.map +1 -0
- package/dist/browser/Escrow/createEscrowIntent.d.ts +20 -0
- package/dist/browser/Escrow/createEscrowIntent.d.ts.map +1 -0
- package/dist/browser/Escrow/getEscrowSecret.d.cts +7 -0
- package/dist/browser/Escrow/getEscrowSecret.d.cts.map +1 -0
- package/dist/browser/Escrow/getEscrowSecret.d.mts +7 -0
- package/dist/browser/Escrow/getEscrowSecret.d.mts.map +1 -0
- package/dist/browser/Escrow/getEscrowSecret.d.ts +7 -0
- package/dist/browser/Escrow/getEscrowSecret.d.ts.map +1 -0
- package/dist/browser/Escrow/index.d.cts +5 -0
- package/dist/browser/Escrow/index.d.cts.map +1 -0
- package/dist/browser/Escrow/index.d.mts +5 -0
- package/dist/browser/Escrow/index.d.mts.map +1 -0
- package/dist/browser/Escrow/index.d.ts +5 -0
- package/dist/browser/Escrow/index.d.ts.map +1 -0
- package/dist/browser/index.cjs +29 -2
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +29 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/Escrow/Schema.d.cts +3 -0
- package/dist/node/Escrow/Schema.d.cts.map +1 -0
- package/dist/node/Escrow/Schema.d.mts +3 -0
- package/dist/node/Escrow/Schema.d.mts.map +1 -0
- package/dist/node/Escrow/Schema.d.ts +3 -0
- package/dist/node/Escrow/Schema.d.ts.map +1 -0
- package/dist/node/Escrow/Terms.d.cts +58 -0
- package/dist/node/Escrow/Terms.d.cts.map +1 -0
- package/dist/node/Escrow/Terms.d.mts +58 -0
- package/dist/node/Escrow/Terms.d.mts.map +1 -0
- package/dist/node/Escrow/Terms.d.ts +58 -0
- package/dist/node/Escrow/Terms.d.ts.map +1 -0
- package/dist/node/Escrow/createEscrowIntent.d.cts +20 -0
- package/dist/node/Escrow/createEscrowIntent.d.cts.map +1 -0
- package/dist/node/Escrow/createEscrowIntent.d.mts +20 -0
- package/dist/node/Escrow/createEscrowIntent.d.mts.map +1 -0
- package/dist/node/Escrow/createEscrowIntent.d.ts +20 -0
- package/dist/node/Escrow/createEscrowIntent.d.ts.map +1 -0
- package/dist/node/Escrow/getEscrowSecret.d.cts +7 -0
- package/dist/node/Escrow/getEscrowSecret.d.cts.map +1 -0
- package/dist/node/Escrow/getEscrowSecret.d.mts +7 -0
- package/dist/node/Escrow/getEscrowSecret.d.mts.map +1 -0
- package/dist/node/Escrow/getEscrowSecret.d.ts +7 -0
- package/dist/node/Escrow/getEscrowSecret.d.ts.map +1 -0
- package/dist/node/Escrow/index.d.cts +5 -0
- package/dist/node/Escrow/index.d.cts.map +1 -0
- package/dist/node/Escrow/index.d.mts +5 -0
- package/dist/node/Escrow/index.d.mts.map +1 -0
- package/dist/node/Escrow/index.d.ts +5 -0
- package/dist/node/Escrow/index.d.ts.map +1 -0
- package/dist/node/index.cjs +34 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +29 -2
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Escrow/Schema.ts +2 -0
- package/src/Escrow/Terms.ts +62 -0
- package/src/Escrow/createEscrowIntent.ts +15 -0
- package/src/Escrow/getEscrowSecret.ts +10 -0
- package/src/Escrow/index.ts +4 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Address, Hash } from '@xylabs/hex';
|
|
2
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
3
|
+
export declare const EscrowTermsSchema: "network.xyo.escrow.terms";
|
|
4
|
+
export type EscrowTermsSchema = typeof EscrowTermsSchema;
|
|
5
|
+
export interface EscrowTermsFields {
|
|
6
|
+
/**
|
|
7
|
+
* The trusted estimators for the worth of the things being sold
|
|
8
|
+
*/
|
|
9
|
+
appraisalAuthorities: Address[];
|
|
10
|
+
/**
|
|
11
|
+
* The estimated worths of the things being sold
|
|
12
|
+
*/
|
|
13
|
+
appraisals: Hash[];
|
|
14
|
+
/**
|
|
15
|
+
* The things being sold
|
|
16
|
+
*/
|
|
17
|
+
assets: Hash[];
|
|
18
|
+
/**
|
|
19
|
+
* The buyer
|
|
20
|
+
*/
|
|
21
|
+
buyer: Address[];
|
|
22
|
+
/**
|
|
23
|
+
* The buyer
|
|
24
|
+
*/
|
|
25
|
+
buyerSecret: Hash;
|
|
26
|
+
/**
|
|
27
|
+
* The escrow agent responsible for the escrow
|
|
28
|
+
*/
|
|
29
|
+
escrowAgent: Address;
|
|
30
|
+
/**
|
|
31
|
+
* The time the escrow expires
|
|
32
|
+
*/
|
|
33
|
+
exp: number;
|
|
34
|
+
/**
|
|
35
|
+
* The time the escrow starts
|
|
36
|
+
*/
|
|
37
|
+
nbf: number;
|
|
38
|
+
/**
|
|
39
|
+
* The trusted payment authorities
|
|
40
|
+
*/
|
|
41
|
+
paymentAuthorities: Address[];
|
|
42
|
+
/**
|
|
43
|
+
* The seller
|
|
44
|
+
*/
|
|
45
|
+
seller: Address[];
|
|
46
|
+
/**
|
|
47
|
+
* The seller
|
|
48
|
+
*/
|
|
49
|
+
sellerSecret: Hash;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The terms of an escrow
|
|
53
|
+
*/
|
|
54
|
+
export type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>;
|
|
55
|
+
export declare const isEscrowTerms: (x?: unknown) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
56
|
+
schema: "network.xyo.escrow.terms";
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=Terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAyB,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAI3E,eAAO,MAAM,iBAAiB,4BAAmC,CAAA;AACjE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAGxD,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,oBAAoB,EAAE,OAAO,EAAE,CAAA;IAC/B;;OAEG;IACH,UAAU,EAAE,IAAI,EAAE,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,IAAI,EAAE,CAAA;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,kBAAkB,EAAE,OAAO,EAAE,CAAA;IAC7B;;OAEG;IACH,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB;;OAEG;IACH,YAAY,EAAE,IAAI,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhF,eAAO,MAAM,aAAa;;CAAwD,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Address, Hash } from '@xylabs/hex';
|
|
2
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
3
|
+
export declare const EscrowTermsSchema: "network.xyo.escrow.terms";
|
|
4
|
+
export type EscrowTermsSchema = typeof EscrowTermsSchema;
|
|
5
|
+
export interface EscrowTermsFields {
|
|
6
|
+
/**
|
|
7
|
+
* The trusted estimators for the worth of the things being sold
|
|
8
|
+
*/
|
|
9
|
+
appraisalAuthorities: Address[];
|
|
10
|
+
/**
|
|
11
|
+
* The estimated worths of the things being sold
|
|
12
|
+
*/
|
|
13
|
+
appraisals: Hash[];
|
|
14
|
+
/**
|
|
15
|
+
* The things being sold
|
|
16
|
+
*/
|
|
17
|
+
assets: Hash[];
|
|
18
|
+
/**
|
|
19
|
+
* The buyer
|
|
20
|
+
*/
|
|
21
|
+
buyer: Address[];
|
|
22
|
+
/**
|
|
23
|
+
* The buyer
|
|
24
|
+
*/
|
|
25
|
+
buyerSecret: Hash;
|
|
26
|
+
/**
|
|
27
|
+
* The escrow agent responsible for the escrow
|
|
28
|
+
*/
|
|
29
|
+
escrowAgent: Address;
|
|
30
|
+
/**
|
|
31
|
+
* The time the escrow expires
|
|
32
|
+
*/
|
|
33
|
+
exp: number;
|
|
34
|
+
/**
|
|
35
|
+
* The time the escrow starts
|
|
36
|
+
*/
|
|
37
|
+
nbf: number;
|
|
38
|
+
/**
|
|
39
|
+
* The trusted payment authorities
|
|
40
|
+
*/
|
|
41
|
+
paymentAuthorities: Address[];
|
|
42
|
+
/**
|
|
43
|
+
* The seller
|
|
44
|
+
*/
|
|
45
|
+
seller: Address[];
|
|
46
|
+
/**
|
|
47
|
+
* The seller
|
|
48
|
+
*/
|
|
49
|
+
sellerSecret: Hash;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The terms of an escrow
|
|
53
|
+
*/
|
|
54
|
+
export type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>;
|
|
55
|
+
export declare const isEscrowTerms: (x?: unknown) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
56
|
+
schema: "network.xyo.escrow.terms";
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=Terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAyB,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAI3E,eAAO,MAAM,iBAAiB,4BAAmC,CAAA;AACjE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAGxD,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,oBAAoB,EAAE,OAAO,EAAE,CAAA;IAC/B;;OAEG;IACH,UAAU,EAAE,IAAI,EAAE,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,IAAI,EAAE,CAAA;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,kBAAkB,EAAE,OAAO,EAAE,CAAA;IAC7B;;OAEG;IACH,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB;;OAEG;IACH,YAAY,EAAE,IAAI,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhF,eAAO,MAAM,aAAa;;CAAwD,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccountInstance } from '@xyo-network/account-model';
|
|
2
|
+
import { EscrowTerms } from './Terms';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an escrow intent
|
|
5
|
+
* @param terms The payloads describing the terms for the escrow
|
|
6
|
+
* @param account The account to create the escrow intent with
|
|
7
|
+
* @returns The escrow intent
|
|
8
|
+
*/
|
|
9
|
+
export declare const createEscrowIntent: (terms: EscrowTerms[], account: AccountInstance) => Promise<[import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
10
|
+
schema: "network.xyo.boundwitness";
|
|
11
|
+
}>, import("@xyo-network/payload-model").WithMeta<{
|
|
12
|
+
schema: string;
|
|
13
|
+
} & import("@xyo-network/payload-model").PayloadFields>[], import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
14
|
+
message?: string | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
query?: Lowercase<string> | undefined;
|
|
17
|
+
schema: "network.xyo.error.module";
|
|
18
|
+
sources?: Lowercase<string>[] | undefined;
|
|
19
|
+
}>[]]>;
|
|
20
|
+
//# sourceMappingURL=createEscrowIntent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEscrowIntent.d.ts","sourceRoot":"","sources":["../../../src/Escrow/createEscrowIntent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAiB,WAAW,EAAE,WAAW,eAAe;;;;;;;;;;MAGtF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccountInstance } from '@xyo-network/account-model';
|
|
2
|
+
import { EscrowTerms } from './Terms';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an escrow intent
|
|
5
|
+
* @param terms The payloads describing the terms for the escrow
|
|
6
|
+
* @param account The account to create the escrow intent with
|
|
7
|
+
* @returns The escrow intent
|
|
8
|
+
*/
|
|
9
|
+
export declare const createEscrowIntent: (terms: EscrowTerms[], account: AccountInstance) => Promise<[import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
10
|
+
schema: "network.xyo.boundwitness";
|
|
11
|
+
}>, import("@xyo-network/payload-model").WithMeta<{
|
|
12
|
+
schema: string;
|
|
13
|
+
} & import("@xyo-network/payload-model").PayloadFields>[], import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
14
|
+
message?: string | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
query?: Lowercase<string> | undefined;
|
|
17
|
+
schema: "network.xyo.error.module";
|
|
18
|
+
sources?: Lowercase<string>[] | undefined;
|
|
19
|
+
}>[]]>;
|
|
20
|
+
//# sourceMappingURL=createEscrowIntent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEscrowIntent.d.ts","sourceRoot":"","sources":["../../../src/Escrow/createEscrowIntent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAiB,WAAW,EAAE,WAAW,eAAe;;;;;;;;;;MAGtF,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccountInstance } from '@xyo-network/account-model';
|
|
2
|
+
import { EscrowTerms } from './Terms';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an escrow intent
|
|
5
|
+
* @param terms The payloads describing the terms for the escrow
|
|
6
|
+
* @param account The account to create the escrow intent with
|
|
7
|
+
* @returns The escrow intent
|
|
8
|
+
*/
|
|
9
|
+
export declare const createEscrowIntent: (terms: EscrowTerms[], account: AccountInstance) => Promise<[import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
10
|
+
schema: "network.xyo.boundwitness";
|
|
11
|
+
}>, import("@xyo-network/payload-model").WithMeta<{
|
|
12
|
+
schema: string;
|
|
13
|
+
} & import("@xyo-network/payload-model").PayloadFields>[], import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
14
|
+
message?: string | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
query?: Lowercase<string> | undefined;
|
|
17
|
+
schema: "network.xyo.error.module";
|
|
18
|
+
sources?: Lowercase<string>[] | undefined;
|
|
19
|
+
}>[]]>;
|
|
20
|
+
//# sourceMappingURL=createEscrowIntent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEscrowIntent.d.ts","sourceRoot":"","sources":["../../../src/Escrow/createEscrowIntent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAiB,WAAW,EAAE,WAAW,eAAe;;;;;;;;;;MAGtF,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IdPayload } from '@xyo-network/id-payload-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a cryptographically random secret to use for escrow
|
|
4
|
+
* @returns The escrow secret
|
|
5
|
+
*/
|
|
6
|
+
export declare const getEscrowSecret: () => IdPayload;
|
|
7
|
+
//# sourceMappingURL=getEscrowSecret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEscrowSecret.d.ts","sourceRoot":"","sources":["../../../src/Escrow/getEscrowSecret.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,gCAAgC,CAAA;AAEpE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,SAElC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IdPayload } from '@xyo-network/id-payload-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a cryptographically random secret to use for escrow
|
|
4
|
+
* @returns The escrow secret
|
|
5
|
+
*/
|
|
6
|
+
export declare const getEscrowSecret: () => IdPayload;
|
|
7
|
+
//# sourceMappingURL=getEscrowSecret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEscrowSecret.d.ts","sourceRoot":"","sources":["../../../src/Escrow/getEscrowSecret.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,gCAAgC,CAAA;AAEpE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,SAElC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IdPayload } from '@xyo-network/id-payload-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a cryptographically random secret to use for escrow
|
|
4
|
+
* @returns The escrow secret
|
|
5
|
+
*/
|
|
6
|
+
export declare const getEscrowSecret: () => IdPayload;
|
|
7
|
+
//# sourceMappingURL=getEscrowSecret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEscrowSecret.d.ts","sourceRoot":"","sources":["../../../src/Escrow/getEscrowSecret.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,gCAAgC,CAAA;AAEpE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,SAElC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Escrow/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Escrow/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Escrow/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -20,23 +20,55 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
EscrowSchema: () => EscrowSchema,
|
|
24
|
+
EscrowTermsSchema: () => EscrowTermsSchema,
|
|
23
25
|
PaymentSchema: () => PaymentSchema,
|
|
24
26
|
PurchaseSchema: () => PurchaseSchema,
|
|
27
|
+
createEscrowIntent: () => createEscrowIntent,
|
|
28
|
+
getEscrowSecret: () => getEscrowSecret,
|
|
29
|
+
isEscrowTerms: () => isEscrowTerms,
|
|
25
30
|
isPayment: () => isPayment
|
|
26
31
|
});
|
|
27
32
|
module.exports = __toCommonJS(src_exports);
|
|
28
33
|
|
|
29
|
-
// src/
|
|
34
|
+
// src/Escrow/createEscrowIntent.ts
|
|
35
|
+
var import_boundwitness_builder = require("@xyo-network/boundwitness-builder");
|
|
36
|
+
var createEscrowIntent = async (terms, account) => {
|
|
37
|
+
const result = await new import_boundwitness_builder.BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build();
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/Escrow/getEscrowSecret.ts
|
|
42
|
+
var import_crypto = require("@xylabs/crypto");
|
|
43
|
+
var import_id_payload_plugin = require("@xyo-network/id-payload-plugin");
|
|
44
|
+
var getEscrowSecret = () => {
|
|
45
|
+
return { salt: import_crypto.Crypto.randomUUID(), schema: import_id_payload_plugin.IdSchema };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/Escrow/Schema.ts
|
|
49
|
+
var EscrowSchema = "network.xyo.escrow";
|
|
50
|
+
|
|
51
|
+
// src/Escrow/Terms.ts
|
|
30
52
|
var import_payload_model = require("@xyo-network/payload-model");
|
|
53
|
+
var EscrowTermsSchema = `${EscrowSchema}.terms`;
|
|
54
|
+
var isEscrowTerms = (0, import_payload_model.isPayloadOfSchemaType)(EscrowTermsSchema);
|
|
55
|
+
|
|
56
|
+
// src/Payment.ts
|
|
57
|
+
var import_payload_model2 = require("@xyo-network/payload-model");
|
|
31
58
|
var PaymentSchema = "network.xyo.payments.payment";
|
|
32
|
-
var isPayment = (0,
|
|
59
|
+
var isPayment = (0, import_payload_model2.isPayloadOfSchemaType)(PaymentSchema);
|
|
33
60
|
|
|
34
61
|
// src/Purchase.ts
|
|
35
62
|
var PurchaseSchema = "network.xyo.payments.purchase";
|
|
36
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
64
|
0 && (module.exports = {
|
|
65
|
+
EscrowSchema,
|
|
66
|
+
EscrowTermsSchema,
|
|
38
67
|
PaymentSchema,
|
|
39
68
|
PurchaseSchema,
|
|
69
|
+
createEscrowIntent,
|
|
70
|
+
getEscrowSecret,
|
|
71
|
+
isEscrowTerms,
|
|
40
72
|
isPayment
|
|
41
73
|
});
|
|
42
74
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["export * from './Currency'\nexport * from './Payment'\nexport * from './Purchase'\n","import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["export * from './Currency'\nexport * from './Escrow'\nexport * from './Payment'\nexport * from './Purchase'\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n","import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kCAAoC;AAU7B,IAAM,qBAAqB,OAAO,OAAsB,YAA6B;AAC1F,QAAM,SAAS,MAAM,IAAI,gDAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM;AACjG,SAAO;AACT;;;ACdA,oBAAuB;AACvB,+BAAoC;AAM7B,IAAM,kBAAkB,MAAiB;AAC9C,SAAO,EAAE,MAAM,qBAAO,WAAW,GAAG,QAAQ,kCAAS;AACvD;;;ACRO,IAAM,eAA6B;;;ACA1C,2BAA+C;AAIxC,IAAM,oBAAoB,GAAG,YAAY;AAwDzC,IAAM,oBAAgB,4CAAmC,iBAAiB;;;AC7DjF,IAAAA,wBAA0D;AAKnD,IAAM,gBAA+B;AAkBrC,IAAM,gBAAY,6CAA+B,aAAa;;;ACnB9D,IAAM,iBAAiC;","names":["import_payload_model"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/Escrow/createEscrowIntent.ts
|
|
2
|
+
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
3
|
+
var createEscrowIntent = async (terms, account) => {
|
|
4
|
+
const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build();
|
|
5
|
+
return result;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/Escrow/getEscrowSecret.ts
|
|
9
|
+
import { Crypto } from "@xylabs/crypto";
|
|
10
|
+
import { IdSchema } from "@xyo-network/id-payload-plugin";
|
|
11
|
+
var getEscrowSecret = () => {
|
|
12
|
+
return { salt: Crypto.randomUUID(), schema: IdSchema };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/Escrow/Schema.ts
|
|
16
|
+
var EscrowSchema = "network.xyo.escrow";
|
|
17
|
+
|
|
18
|
+
// src/Escrow/Terms.ts
|
|
2
19
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
20
|
+
var EscrowTermsSchema = `${EscrowSchema}.terms`;
|
|
21
|
+
var isEscrowTerms = isPayloadOfSchemaType(EscrowTermsSchema);
|
|
22
|
+
|
|
23
|
+
// src/Payment.ts
|
|
24
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType2 } from "@xyo-network/payload-model";
|
|
3
25
|
var PaymentSchema = "network.xyo.payments.payment";
|
|
4
|
-
var isPayment =
|
|
26
|
+
var isPayment = isPayloadOfSchemaType2(PaymentSchema);
|
|
5
27
|
|
|
6
28
|
// src/Purchase.ts
|
|
7
29
|
var PurchaseSchema = "network.xyo.payments.purchase";
|
|
8
30
|
export {
|
|
31
|
+
EscrowSchema,
|
|
32
|
+
EscrowTermsSchema,
|
|
9
33
|
PaymentSchema,
|
|
10
34
|
PurchaseSchema,
|
|
35
|
+
createEscrowIntent,
|
|
36
|
+
getEscrowSecret,
|
|
37
|
+
isEscrowTerms,
|
|
11
38
|
isPayment
|
|
12
39
|
};
|
|
13
40
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n","import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n"],"mappings":";AACA,SAAS,2BAA2B;AAU7B,IAAM,qBAAqB,OAAO,OAAsB,YAA6B;AAC1F,QAAM,SAAS,MAAM,IAAI,oBAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM;AACjG,SAAO;AACT;;;ACdA,SAAS,cAAc;AACvB,SAAoB,gBAAgB;AAM7B,IAAM,kBAAkB,MAAiB;AAC9C,SAAO,EAAE,MAAM,OAAO,WAAW,GAAG,QAAQ,SAAS;AACvD;;;ACRO,IAAM,eAA6B;;;ACA1C,SAAS,6BAAsC;AAIxC,IAAM,oBAAoB,GAAG,YAAY;AAwDzC,IAAM,gBAAgB,sBAAmC,iBAAiB;;;AC7DjF,SAAS,yBAAAA,8BAAiD;AAKnD,IAAM,gBAA+B;AAkBrC,IAAM,YAAYA,uBAA+B,aAAa;;;ACnB9D,IAAM,iBAAiC;","names":["isPayloadOfSchemaType"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Address, Hash } from '@xylabs/hex'
|
|
2
|
+
import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'
|
|
3
|
+
|
|
4
|
+
import { EscrowSchema } from './Schema'
|
|
5
|
+
|
|
6
|
+
export const EscrowTermsSchema = `${EscrowSchema}.terms` as const
|
|
7
|
+
export type EscrowTermsSchema = typeof EscrowTermsSchema
|
|
8
|
+
|
|
9
|
+
// TODO: Include escrow agent in escrow terms
|
|
10
|
+
export interface EscrowTermsFields {
|
|
11
|
+
/**
|
|
12
|
+
* The trusted estimators for the worth of the things being sold
|
|
13
|
+
*/
|
|
14
|
+
appraisalAuthorities: Address[]
|
|
15
|
+
/**
|
|
16
|
+
* The estimated worths of the things being sold
|
|
17
|
+
*/
|
|
18
|
+
appraisals: Hash[]
|
|
19
|
+
/**
|
|
20
|
+
* The things being sold
|
|
21
|
+
*/
|
|
22
|
+
assets: Hash[]
|
|
23
|
+
/**
|
|
24
|
+
* The buyer
|
|
25
|
+
*/
|
|
26
|
+
buyer: Address[]
|
|
27
|
+
/**
|
|
28
|
+
* The buyer
|
|
29
|
+
*/
|
|
30
|
+
buyerSecret: Hash
|
|
31
|
+
/**
|
|
32
|
+
* The escrow agent responsible for the escrow
|
|
33
|
+
*/
|
|
34
|
+
escrowAgent: Address
|
|
35
|
+
/**
|
|
36
|
+
* The time the escrow expires
|
|
37
|
+
*/
|
|
38
|
+
exp: number
|
|
39
|
+
/**
|
|
40
|
+
* The time the escrow starts
|
|
41
|
+
*/
|
|
42
|
+
nbf: number
|
|
43
|
+
/**
|
|
44
|
+
* The trusted payment authorities
|
|
45
|
+
*/
|
|
46
|
+
paymentAuthorities: Address[]
|
|
47
|
+
/**
|
|
48
|
+
* The seller
|
|
49
|
+
*/
|
|
50
|
+
seller: Address[]
|
|
51
|
+
/**
|
|
52
|
+
* The seller
|
|
53
|
+
*/
|
|
54
|
+
sellerSecret: Hash
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The terms of an escrow
|
|
59
|
+
*/
|
|
60
|
+
export type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>
|
|
61
|
+
|
|
62
|
+
export const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AccountInstance } from '@xyo-network/account-model'
|
|
2
|
+
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
3
|
+
|
|
4
|
+
import { EscrowTerms } from './Terms'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates an escrow intent
|
|
8
|
+
* @param terms The payloads describing the terms for the escrow
|
|
9
|
+
* @param account The account to create the escrow intent with
|
|
10
|
+
* @returns The escrow intent
|
|
11
|
+
*/
|
|
12
|
+
export const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {
|
|
13
|
+
const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()
|
|
14
|
+
return result
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Crypto } from '@xylabs/crypto'
|
|
2
|
+
import { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a cryptographically random secret to use for escrow
|
|
6
|
+
* @returns The escrow secret
|
|
7
|
+
*/
|
|
8
|
+
export const getEscrowSecret = (): IdPayload => {
|
|
9
|
+
return { salt: Crypto.randomUUID(), schema: IdSchema }
|
|
10
|
+
}
|
package/src/index.ts
CHANGED