@halot/sdk 1.0.0
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/README.md +243 -0
- package/dist/auth/actor.d.ts +17 -0
- package/dist/auth/actor.js +33 -0
- package/dist/auth/attestation.d.ts +24 -0
- package/dist/auth/attestation.js +47 -0
- package/dist/client/halot-client.d.ts +37 -0
- package/dist/client/halot-client.js +89 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +5 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +11 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +43 -0
- package/dist/middleware/aggregator-client.d.ts +8 -0
- package/dist/middleware/aggregator-client.js +49 -0
- package/dist/middleware/halot.d.ts +4 -0
- package/dist/middleware/halot.js +142 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.js +5 -0
- package/dist/middleware/types.d.ts +45 -0
- package/dist/middleware/types.js +2 -0
- package/dist/types/common.d.ts +90 -0
- package/dist/types/common.js +66 -0
- package/dist/types/job.d.ts +232 -0
- package/dist/types/job.js +125 -0
- package/dist/types/provider.d.ts +160 -0
- package/dist/types/provider.js +45 -0
- package/dist/types/quote.d.ts +43 -0
- package/dist/types/quote.js +31 -0
- package/dist/types/requester.d.ts +15 -0
- package/dist/types/requester.js +15 -0
- package/dist/types/service.d.ts +140 -0
- package/dist/types/service.js +48 -0
- package/dist/types/verifier.d.ts +144 -0
- package/dist/types/verifier.js +78 -0
- package/dist/types/x402.d.ts +31 -0
- package/dist/types/x402.js +27 -0
- package/dist/utils/amount.d.ts +2 -0
- package/dist/utils/amount.js +11 -0
- package/dist/utils/artifacts.d.ts +42 -0
- package/dist/utils/artifacts.js +378 -0
- package/dist/utils/category.d.ts +4 -0
- package/dist/utils/category.js +25 -0
- package/dist/utils/date.d.ts +2 -0
- package/dist/utils/date.js +10 -0
- package/dist/utils/hash.d.ts +4 -0
- package/dist/utils/hash.js +27 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +7 -0
- package/dist/utils/json-file.d.ts +3 -0
- package/dist/utils/json-file.js +20 -0
- package/dist/utils/schema.d.ts +5 -0
- package/dist/utils/schema.js +66 -0
- package/dist/x402/payment.d.ts +11 -0
- package/dist/x402/payment.js +68 -0
- package/dist/zero-g/compute.d.ts +53 -0
- package/dist/zero-g/compute.js +249 -0
- package/dist/zero-g/storage.d.ts +28 -0
- package/dist/zero-g/storage.js +93 -0
- package/package.json +66 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.halot = halot;
|
|
4
|
+
const config_js_1 = require("../config.js");
|
|
5
|
+
const aggregator_client_js_1 = require("./aggregator-client.js");
|
|
6
|
+
const RECEIPT_HEADER = 'x-halot-receipt';
|
|
7
|
+
function halot(options) {
|
|
8
|
+
const aggregatorUrl = (0, config_js_1.resolveHalotAggregatorUrl)(options.aggregatorUrl);
|
|
9
|
+
const aggregator = new aggregator_client_js_1.AggregatorClient(aggregatorUrl);
|
|
10
|
+
const reportMaxAttempts = Math.max(1, options.reportMaxAttempts ?? 2);
|
|
11
|
+
const reportRetryDelayMs = Math.max(0, options.reportRetryDelayMs ?? 250);
|
|
12
|
+
return async (request, response, next) => {
|
|
13
|
+
const receipt = request.headers[RECEIPT_HEADER];
|
|
14
|
+
const serviceId = await resolveServiceId(options.serviceId, request).catch((error) => {
|
|
15
|
+
options.onError?.(error);
|
|
16
|
+
response.status(400).json({
|
|
17
|
+
error: error instanceof Error ? error.message : 'Failed to resolve service',
|
|
18
|
+
});
|
|
19
|
+
return null;
|
|
20
|
+
});
|
|
21
|
+
if (!serviceId) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!receipt) {
|
|
25
|
+
try {
|
|
26
|
+
const result = await aggregator.quote(serviceId, request.body);
|
|
27
|
+
response
|
|
28
|
+
.status(402)
|
|
29
|
+
.setHeader('PAYMENT-REQUIRED', result.paymentRequired)
|
|
30
|
+
.json({
|
|
31
|
+
x402Version: 2,
|
|
32
|
+
serviceId,
|
|
33
|
+
aggregatorUrl,
|
|
34
|
+
quote: result.quote,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
options.onError?.(error);
|
|
39
|
+
response.status(500).json({ error: 'Failed to fetch payment requirement' });
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let context;
|
|
44
|
+
try {
|
|
45
|
+
const verification = await aggregator.verify(receipt);
|
|
46
|
+
if (!verification.valid) {
|
|
47
|
+
response.status(402).json({ error: 'Invalid or unfunded receipt' });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (verification.serviceId !== serviceId) {
|
|
51
|
+
response.status(403).json({ error: 'Receipt is valid for a different service' });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
context = {
|
|
55
|
+
jobId: verification.jobId,
|
|
56
|
+
quoteId: verification.quoteId,
|
|
57
|
+
serviceId: verification.serviceId,
|
|
58
|
+
providerId: verification.providerId,
|
|
59
|
+
requesterAddress: verification.requesterAddress,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
options.onError?.(error);
|
|
64
|
+
response.status(402).json({ error: 'Receipt verification failed' });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
request.halot = context;
|
|
68
|
+
const originalJson = response.json.bind(response);
|
|
69
|
+
const originalSend = response.send.bind(response);
|
|
70
|
+
let completed = false;
|
|
71
|
+
const sendWithReport = (body, send) => {
|
|
72
|
+
if (completed) {
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
completed = true;
|
|
76
|
+
void (async () => {
|
|
77
|
+
if (response.statusCode >= 200 && response.statusCode < 300) {
|
|
78
|
+
try {
|
|
79
|
+
await reportWithRetry(aggregator, request, context, body, options.providerHeaders, reportMaxAttempts, reportRetryDelayMs);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
options.onError?.(error);
|
|
83
|
+
response.status(502);
|
|
84
|
+
originalJson({ error: 'Failed to report result to Halot' });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
send(body);
|
|
89
|
+
})().catch((error) => {
|
|
90
|
+
options.onError?.(error);
|
|
91
|
+
response.status(500);
|
|
92
|
+
originalJson({ error: 'Failed to finalize Halot response' });
|
|
93
|
+
});
|
|
94
|
+
return response;
|
|
95
|
+
};
|
|
96
|
+
response.json = function (body) {
|
|
97
|
+
return sendWithReport(body, originalJson);
|
|
98
|
+
};
|
|
99
|
+
response.send = function (body) {
|
|
100
|
+
return sendWithReport(body, originalSend);
|
|
101
|
+
};
|
|
102
|
+
next();
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function reportWithRetry(aggregator, request, context, output, providerHeaders, maxAttempts, retryDelayMs) {
|
|
106
|
+
let lastError;
|
|
107
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
108
|
+
try {
|
|
109
|
+
const resolvedHeaders = await resolveProviderHeaders(providerHeaders, request, context);
|
|
110
|
+
await aggregator.report(context.jobId, context.providerId, output, resolvedHeaders);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
lastError = error;
|
|
115
|
+
if (attempt < maxAttempts && retryDelayMs > 0) {
|
|
116
|
+
await sleep(retryDelayMs);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
121
|
+
}
|
|
122
|
+
async function resolveProviderHeaders(providerHeaders, request, context) {
|
|
123
|
+
if (!providerHeaders) {
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
return typeof providerHeaders === 'function'
|
|
127
|
+
? await providerHeaders(request, context)
|
|
128
|
+
: providerHeaders;
|
|
129
|
+
}
|
|
130
|
+
function sleep(ms) {
|
|
131
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
132
|
+
}
|
|
133
|
+
async function resolveServiceId(serviceId, request) {
|
|
134
|
+
const resolved = typeof serviceId === 'function'
|
|
135
|
+
? await serviceId(request)
|
|
136
|
+
: serviceId;
|
|
137
|
+
const normalized = resolved.trim();
|
|
138
|
+
if (!normalized) {
|
|
139
|
+
throw new Error('Resolved serviceId must be a non-empty string');
|
|
140
|
+
}
|
|
141
|
+
return normalized;
|
|
142
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
export type ServiceIdResolver = string | ((request: Request) => string | Promise<string>);
|
|
3
|
+
export type HalotRequestContext = {
|
|
4
|
+
jobId: string;
|
|
5
|
+
quoteId: string;
|
|
6
|
+
serviceId: string;
|
|
7
|
+
providerId: string;
|
|
8
|
+
requesterAddress: string;
|
|
9
|
+
};
|
|
10
|
+
export type ProviderHeadersResolver = Record<string, string> | ((request: Request, context: HalotRequestContext) => Record<string, string> | Promise<Record<string, string>>);
|
|
11
|
+
export type HalotOptions = {
|
|
12
|
+
serviceId: ServiceIdResolver;
|
|
13
|
+
aggregatorUrl?: string;
|
|
14
|
+
providerHeaders?: ProviderHeadersResolver;
|
|
15
|
+
reportMaxAttempts?: number;
|
|
16
|
+
reportRetryDelayMs?: number;
|
|
17
|
+
onError?: (error: unknown) => void;
|
|
18
|
+
};
|
|
19
|
+
export type FacilitateQuoteResponse = {
|
|
20
|
+
quote: {
|
|
21
|
+
quoteId: string;
|
|
22
|
+
total: string;
|
|
23
|
+
currency: string;
|
|
24
|
+
breakdown: Record<string, string>;
|
|
25
|
+
accepts: Array<{
|
|
26
|
+
network: string;
|
|
27
|
+
token: string;
|
|
28
|
+
amount: string;
|
|
29
|
+
payTo: string;
|
|
30
|
+
memo: string;
|
|
31
|
+
}>;
|
|
32
|
+
expiresAt: string;
|
|
33
|
+
};
|
|
34
|
+
paymentRequired: string;
|
|
35
|
+
serviceId: string;
|
|
36
|
+
aggregatorUrl: string;
|
|
37
|
+
};
|
|
38
|
+
export type FacilitateVerifyResponse = {
|
|
39
|
+
valid: boolean;
|
|
40
|
+
jobId: string;
|
|
41
|
+
quoteId: string;
|
|
42
|
+
serviceId: string;
|
|
43
|
+
providerId: string;
|
|
44
|
+
requesterAddress: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const serviceCategoryValues: readonly ["text", "code", "image", "audio", "video", "document", "tool", "workflow"];
|
|
3
|
+
export declare const settlementNetworkValues: readonly ["0g:testnet", "0g:mainnet", "stellar:testnet", "stellar:mainnet"];
|
|
4
|
+
export declare const jobStatusValues: readonly ["relayed", "executing", "verifying", "settlement-pending", "settlement-submitted", "settlement-failed", "approved", "rejected", "escalated"];
|
|
5
|
+
export declare const trustLevelValues: readonly ["standard", "thorough", "critical", "auto"];
|
|
6
|
+
export declare const decisionValues: readonly ["approve", "reject", "uncertain"];
|
|
7
|
+
export declare const ServiceCategorySchema: z.ZodEnum<{
|
|
8
|
+
text: "text";
|
|
9
|
+
code: "code";
|
|
10
|
+
image: "image";
|
|
11
|
+
audio: "audio";
|
|
12
|
+
video: "video";
|
|
13
|
+
document: "document";
|
|
14
|
+
tool: "tool";
|
|
15
|
+
workflow: "workflow";
|
|
16
|
+
}>;
|
|
17
|
+
export declare const SettlementNetworkSchema: z.ZodEnum<{
|
|
18
|
+
"0g:testnet": "0g:testnet";
|
|
19
|
+
"0g:mainnet": "0g:mainnet";
|
|
20
|
+
"stellar:testnet": "stellar:testnet";
|
|
21
|
+
"stellar:mainnet": "stellar:mainnet";
|
|
22
|
+
}>;
|
|
23
|
+
export declare const TrustLevelSchema: z.ZodEnum<{
|
|
24
|
+
standard: "standard";
|
|
25
|
+
thorough: "thorough";
|
|
26
|
+
critical: "critical";
|
|
27
|
+
auto: "auto";
|
|
28
|
+
}>;
|
|
29
|
+
export declare const JobStatusSchema: z.ZodEnum<{
|
|
30
|
+
relayed: "relayed";
|
|
31
|
+
executing: "executing";
|
|
32
|
+
verifying: "verifying";
|
|
33
|
+
"settlement-pending": "settlement-pending";
|
|
34
|
+
"settlement-submitted": "settlement-submitted";
|
|
35
|
+
"settlement-failed": "settlement-failed";
|
|
36
|
+
approved: "approved";
|
|
37
|
+
rejected: "rejected";
|
|
38
|
+
escalated: "escalated";
|
|
39
|
+
}>;
|
|
40
|
+
export declare const DecisionSchema: z.ZodEnum<{
|
|
41
|
+
approve: "approve";
|
|
42
|
+
reject: "reject";
|
|
43
|
+
uncertain: "uncertain";
|
|
44
|
+
}>;
|
|
45
|
+
export declare const trustLevelVerifierCount: Record<TrustLevel, number>;
|
|
46
|
+
export declare function resolveVerifierCount(trustLevel: TrustLevel, baseFee?: number): number;
|
|
47
|
+
export declare const WalletSchema: z.ZodObject<{
|
|
48
|
+
privateKey: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const SettlementWalletsSchema: z.ZodObject<{
|
|
51
|
+
'0g:testnet': z.ZodDefault<z.ZodString>;
|
|
52
|
+
'0g:mainnet': z.ZodDefault<z.ZodString>;
|
|
53
|
+
'stellar:testnet': z.ZodDefault<z.ZodString>;
|
|
54
|
+
'stellar:mainnet': z.ZodDefault<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export declare const WalletBundleSchema: z.ZodObject<{
|
|
57
|
+
authorities: z.ZodObject<{
|
|
58
|
+
'0g:testnet': z.ZodObject<{
|
|
59
|
+
privateKey: z.ZodString;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
'0g:mainnet': z.ZodObject<{
|
|
62
|
+
privateKey: z.ZodString;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
'stellar:testnet': z.ZodObject<{
|
|
65
|
+
privateKey: z.ZodString;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
'stellar:mainnet': z.ZodObject<{
|
|
68
|
+
privateKey: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export declare const OnchainAnchorSchema: z.ZodObject<{
|
|
73
|
+
network: z.ZodEnum<{
|
|
74
|
+
"0g:testnet": "0g:testnet";
|
|
75
|
+
"0g:mainnet": "0g:mainnet";
|
|
76
|
+
"stellar:testnet": "stellar:testnet";
|
|
77
|
+
"stellar:mainnet": "stellar:mainnet";
|
|
78
|
+
}>;
|
|
79
|
+
registryAddress: z.ZodString;
|
|
80
|
+
transactionHash: z.ZodString;
|
|
81
|
+
anchoredAt: z.ZodString;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type ServiceCategory = z.infer<typeof ServiceCategorySchema>;
|
|
84
|
+
export type SettlementNetwork = z.infer<typeof SettlementNetworkSchema>;
|
|
85
|
+
export type TrustLevel = z.infer<typeof TrustLevelSchema>;
|
|
86
|
+
export type JobStatus = z.infer<typeof JobStatusSchema>;
|
|
87
|
+
export type Decision = z.infer<typeof DecisionSchema>;
|
|
88
|
+
export type SettlementWallets = z.infer<typeof SettlementWalletsSchema>;
|
|
89
|
+
export type WalletBundle = z.infer<typeof WalletBundleSchema>;
|
|
90
|
+
export type OnchainAnchor = z.infer<typeof OnchainAnchorSchema>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnchainAnchorSchema = exports.WalletBundleSchema = exports.SettlementWalletsSchema = exports.WalletSchema = exports.trustLevelVerifierCount = exports.DecisionSchema = exports.JobStatusSchema = exports.TrustLevelSchema = exports.SettlementNetworkSchema = exports.ServiceCategorySchema = exports.decisionValues = exports.trustLevelValues = exports.jobStatusValues = exports.settlementNetworkValues = exports.serviceCategoryValues = void 0;
|
|
4
|
+
exports.resolveVerifierCount = resolveVerifierCount;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
exports.serviceCategoryValues = ['text', 'code', 'image', 'audio', 'video', 'document', 'tool', 'workflow'];
|
|
7
|
+
exports.settlementNetworkValues = ['0g:testnet', '0g:mainnet', 'stellar:testnet', 'stellar:mainnet'];
|
|
8
|
+
exports.jobStatusValues = [
|
|
9
|
+
'relayed',
|
|
10
|
+
'executing',
|
|
11
|
+
'verifying',
|
|
12
|
+
'settlement-pending',
|
|
13
|
+
'settlement-submitted',
|
|
14
|
+
'settlement-failed',
|
|
15
|
+
'approved',
|
|
16
|
+
'rejected',
|
|
17
|
+
'escalated',
|
|
18
|
+
];
|
|
19
|
+
exports.trustLevelValues = ['standard', 'thorough', 'critical', 'auto'];
|
|
20
|
+
exports.decisionValues = ['approve', 'reject', 'uncertain'];
|
|
21
|
+
exports.ServiceCategorySchema = zod_1.z.enum(exports.serviceCategoryValues);
|
|
22
|
+
exports.SettlementNetworkSchema = zod_1.z.enum(exports.settlementNetworkValues);
|
|
23
|
+
exports.TrustLevelSchema = zod_1.z.enum(exports.trustLevelValues);
|
|
24
|
+
exports.JobStatusSchema = zod_1.z.enum(exports.jobStatusValues);
|
|
25
|
+
exports.DecisionSchema = zod_1.z.enum(exports.decisionValues);
|
|
26
|
+
exports.trustLevelVerifierCount = {
|
|
27
|
+
standard: 3,
|
|
28
|
+
thorough: 5,
|
|
29
|
+
critical: 7,
|
|
30
|
+
auto: 3,
|
|
31
|
+
};
|
|
32
|
+
function resolveVerifierCount(trustLevel, baseFee) {
|
|
33
|
+
if (trustLevel !== 'auto') {
|
|
34
|
+
return exports.trustLevelVerifierCount[trustLevel];
|
|
35
|
+
}
|
|
36
|
+
if (baseFee !== undefined && baseFee >= 50)
|
|
37
|
+
return 7;
|
|
38
|
+
if (baseFee !== undefined && baseFee >= 10)
|
|
39
|
+
return 5;
|
|
40
|
+
return 3;
|
|
41
|
+
}
|
|
42
|
+
exports.WalletSchema = zod_1.z.object({
|
|
43
|
+
privateKey: zod_1.z.string(),
|
|
44
|
+
});
|
|
45
|
+
exports.SettlementWalletsSchema = zod_1.z.object({
|
|
46
|
+
'0g:testnet': zod_1.z.string().default(''),
|
|
47
|
+
'0g:mainnet': zod_1.z.string().default(''),
|
|
48
|
+
'stellar:testnet': zod_1.z.string().default(''),
|
|
49
|
+
'stellar:mainnet': zod_1.z.string().default(''),
|
|
50
|
+
});
|
|
51
|
+
exports.WalletBundleSchema = zod_1.z.object({
|
|
52
|
+
authorities: zod_1.z.object({
|
|
53
|
+
'0g:testnet': exports.WalletSchema,
|
|
54
|
+
'0g:mainnet': exports.WalletSchema,
|
|
55
|
+
'stellar:testnet': exports.WalletSchema,
|
|
56
|
+
'stellar:mainnet': exports.WalletSchema,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
exports.OnchainAnchorSchema = zod_1.z.object({
|
|
60
|
+
network: exports.SettlementNetworkSchema.refine((value) => value.startsWith('0g:'), {
|
|
61
|
+
message: 'Onchain anchors must use a 0G network',
|
|
62
|
+
}),
|
|
63
|
+
registryAddress: zod_1.z.string(),
|
|
64
|
+
transactionHash: zod_1.z.string(),
|
|
65
|
+
anchoredAt: zod_1.z.string(),
|
|
66
|
+
});
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const TeeProofSchema: z.ZodObject<{
|
|
3
|
+
chatId: z.ZodString;
|
|
4
|
+
digest: z.ZodString;
|
|
5
|
+
signature: z.ZodString;
|
|
6
|
+
signerAddress: z.ZodString;
|
|
7
|
+
signatureUrl: z.ZodOptional<z.ZodString>;
|
|
8
|
+
providerAddress: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const PreparedVerifierSchema: z.ZodObject<{
|
|
11
|
+
verifierId: z.ZodString;
|
|
12
|
+
ownerAddress: z.ZodString;
|
|
13
|
+
signingPublicKey: z.ZodString;
|
|
14
|
+
payoutAddress: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const PreparedJobSchema: z.ZodObject<{
|
|
17
|
+
prepareId: z.ZodString;
|
|
18
|
+
quoteId: z.ZodString;
|
|
19
|
+
assignmentSeed: z.ZodString;
|
|
20
|
+
trustLevel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
jobHash: z.ZodString;
|
|
22
|
+
serviceId: z.ZodString;
|
|
23
|
+
providerId: z.ZodString;
|
|
24
|
+
requesterAddress: z.ZodString;
|
|
25
|
+
paymentNetwork: z.ZodString;
|
|
26
|
+
paymentToken: z.ZodString;
|
|
27
|
+
settlementContractAddress: z.ZodString;
|
|
28
|
+
settlementTokenAddress: z.ZodString;
|
|
29
|
+
settlementTokenDecimals: z.ZodNumber;
|
|
30
|
+
providerPayoutAddress: z.ZodString;
|
|
31
|
+
providerAmount: z.ZodString;
|
|
32
|
+
providerAmountUnits: z.ZodString;
|
|
33
|
+
verifierFee: z.ZodString;
|
|
34
|
+
verifierFeeUnits: z.ZodString;
|
|
35
|
+
computeFee: z.ZodString;
|
|
36
|
+
computeFeeUnits: z.ZodString;
|
|
37
|
+
verifierPool: z.ZodString;
|
|
38
|
+
verifierPoolUnits: z.ZodString;
|
|
39
|
+
platformFee: z.ZodString;
|
|
40
|
+
platformFeeUnits: z.ZodString;
|
|
41
|
+
totalAmount: z.ZodString;
|
|
42
|
+
totalAmountUnits: z.ZodString;
|
|
43
|
+
threshold: z.ZodNumber;
|
|
44
|
+
selectedVerifierIds: z.ZodArray<z.ZodString>;
|
|
45
|
+
assignedVerifiers: z.ZodArray<z.ZodObject<{
|
|
46
|
+
verifierId: z.ZodString;
|
|
47
|
+
ownerAddress: z.ZodString;
|
|
48
|
+
signingPublicKey: z.ZodString;
|
|
49
|
+
payoutAddress: z.ZodString;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
input: z.ZodAny;
|
|
52
|
+
createdAt: z.ZodString;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const JobResultSchema: z.ZodObject<{
|
|
55
|
+
resultHash: z.ZodString;
|
|
56
|
+
output: z.ZodAny;
|
|
57
|
+
submittedAt: z.ZodString;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export declare const AttestationSchema: z.ZodObject<{
|
|
60
|
+
attestationId: z.ZodString;
|
|
61
|
+
attestationHash: z.ZodString;
|
|
62
|
+
jobHash: z.ZodString;
|
|
63
|
+
resultHash: z.ZodString;
|
|
64
|
+
verifierId: z.ZodString;
|
|
65
|
+
verifierAddress: z.ZodString;
|
|
66
|
+
decision: z.ZodEnum<{
|
|
67
|
+
approve: "approve";
|
|
68
|
+
reject: "reject";
|
|
69
|
+
uncertain: "uncertain";
|
|
70
|
+
}>;
|
|
71
|
+
confidence: z.ZodNumber;
|
|
72
|
+
reason: z.ZodString;
|
|
73
|
+
failedCriteria: z.ZodArray<z.ZodString>;
|
|
74
|
+
teeVerified: z.ZodBoolean;
|
|
75
|
+
teeProof: z.ZodObject<{
|
|
76
|
+
chatId: z.ZodString;
|
|
77
|
+
digest: z.ZodString;
|
|
78
|
+
signature: z.ZodString;
|
|
79
|
+
signerAddress: z.ZodString;
|
|
80
|
+
signatureUrl: z.ZodOptional<z.ZodString>;
|
|
81
|
+
providerAddress: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
verifierSignature: z.ZodString;
|
|
84
|
+
createdAt: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export declare const SettlementStateSchema: z.ZodEnum<{
|
|
87
|
+
pending: "pending";
|
|
88
|
+
submitted: "submitted";
|
|
89
|
+
confirmed: "confirmed";
|
|
90
|
+
failed: "failed";
|
|
91
|
+
}>;
|
|
92
|
+
export declare const SettlementSchema: z.ZodObject<{
|
|
93
|
+
network: z.ZodString;
|
|
94
|
+
contractAddress: z.ZodString;
|
|
95
|
+
decision: z.ZodEnum<{
|
|
96
|
+
approve: "approve";
|
|
97
|
+
reject: "reject";
|
|
98
|
+
uncertain: "uncertain";
|
|
99
|
+
}>;
|
|
100
|
+
threshold: z.ZodNumber;
|
|
101
|
+
approvals: z.ZodNumber;
|
|
102
|
+
rejections: z.ZodNumber;
|
|
103
|
+
providerPayout: z.ZodString;
|
|
104
|
+
verifierPayout: z.ZodString;
|
|
105
|
+
requesterRefund: z.ZodString;
|
|
106
|
+
platformFee: z.ZodString;
|
|
107
|
+
state: z.ZodEnum<{
|
|
108
|
+
pending: "pending";
|
|
109
|
+
submitted: "submitted";
|
|
110
|
+
confirmed: "confirmed";
|
|
111
|
+
failed: "failed";
|
|
112
|
+
}>;
|
|
113
|
+
transactionHash: z.ZodOptional<z.ZodString>;
|
|
114
|
+
submittedAt: z.ZodOptional<z.ZodString>;
|
|
115
|
+
settledAt: z.ZodOptional<z.ZodString>;
|
|
116
|
+
confirmedAt: z.ZodOptional<z.ZodString>;
|
|
117
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
ledger: z.ZodOptional<z.ZodString>;
|
|
119
|
+
error: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export declare const JobSchema: z.ZodObject<{
|
|
122
|
+
jobId: z.ZodString;
|
|
123
|
+
quoteId: z.ZodString;
|
|
124
|
+
assignmentSeed: z.ZodString;
|
|
125
|
+
trustLevel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
126
|
+
jobHash: z.ZodString;
|
|
127
|
+
serviceId: z.ZodString;
|
|
128
|
+
providerId: z.ZodString;
|
|
129
|
+
requesterAddress: z.ZodString;
|
|
130
|
+
paymentNetwork: z.ZodString;
|
|
131
|
+
paymentToken: z.ZodString;
|
|
132
|
+
settlementContractAddress: z.ZodString;
|
|
133
|
+
settlementTokenAddress: z.ZodString;
|
|
134
|
+
settlementTokenDecimals: z.ZodNumber;
|
|
135
|
+
totalAmount: z.ZodString;
|
|
136
|
+
breakdown: z.ZodObject<{
|
|
137
|
+
providerFee: z.ZodString;
|
|
138
|
+
verifierFee: z.ZodString;
|
|
139
|
+
computeFee: z.ZodString;
|
|
140
|
+
platformFee: z.ZodString;
|
|
141
|
+
verifierCount: z.ZodNumber;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
currency: z.ZodString;
|
|
144
|
+
input: z.ZodAny;
|
|
145
|
+
status: z.ZodEnum<{
|
|
146
|
+
relayed: "relayed";
|
|
147
|
+
executing: "executing";
|
|
148
|
+
verifying: "verifying";
|
|
149
|
+
"settlement-pending": "settlement-pending";
|
|
150
|
+
"settlement-submitted": "settlement-submitted";
|
|
151
|
+
"settlement-failed": "settlement-failed";
|
|
152
|
+
approved: "approved";
|
|
153
|
+
rejected: "rejected";
|
|
154
|
+
escalated: "escalated";
|
|
155
|
+
}>;
|
|
156
|
+
selectedVerifierIds: z.ZodArray<z.ZodString>;
|
|
157
|
+
createdAt: z.ZodString;
|
|
158
|
+
updatedAt: z.ZodString;
|
|
159
|
+
fundedAt: z.ZodString;
|
|
160
|
+
fundingTransactionHash: z.ZodString;
|
|
161
|
+
fundingBlockNumber: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
fundingLedger: z.ZodOptional<z.ZodString>;
|
|
163
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
resultHash: z.ZodString;
|
|
165
|
+
output: z.ZodAny;
|
|
166
|
+
submittedAt: z.ZodString;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
attestations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
169
|
+
attestationId: z.ZodString;
|
|
170
|
+
attestationHash: z.ZodString;
|
|
171
|
+
jobHash: z.ZodString;
|
|
172
|
+
resultHash: z.ZodString;
|
|
173
|
+
verifierId: z.ZodString;
|
|
174
|
+
verifierAddress: z.ZodString;
|
|
175
|
+
decision: z.ZodEnum<{
|
|
176
|
+
approve: "approve";
|
|
177
|
+
reject: "reject";
|
|
178
|
+
uncertain: "uncertain";
|
|
179
|
+
}>;
|
|
180
|
+
confidence: z.ZodNumber;
|
|
181
|
+
reason: z.ZodString;
|
|
182
|
+
failedCriteria: z.ZodArray<z.ZodString>;
|
|
183
|
+
teeVerified: z.ZodBoolean;
|
|
184
|
+
teeProof: z.ZodObject<{
|
|
185
|
+
chatId: z.ZodString;
|
|
186
|
+
digest: z.ZodString;
|
|
187
|
+
signature: z.ZodString;
|
|
188
|
+
signerAddress: z.ZodString;
|
|
189
|
+
signatureUrl: z.ZodOptional<z.ZodString>;
|
|
190
|
+
providerAddress: z.ZodOptional<z.ZodString>;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
verifierSignature: z.ZodString;
|
|
193
|
+
createdAt: z.ZodString;
|
|
194
|
+
}, z.core.$strip>>>;
|
|
195
|
+
settlement: z.ZodOptional<z.ZodObject<{
|
|
196
|
+
network: z.ZodString;
|
|
197
|
+
contractAddress: z.ZodString;
|
|
198
|
+
decision: z.ZodEnum<{
|
|
199
|
+
approve: "approve";
|
|
200
|
+
reject: "reject";
|
|
201
|
+
uncertain: "uncertain";
|
|
202
|
+
}>;
|
|
203
|
+
threshold: z.ZodNumber;
|
|
204
|
+
approvals: z.ZodNumber;
|
|
205
|
+
rejections: z.ZodNumber;
|
|
206
|
+
providerPayout: z.ZodString;
|
|
207
|
+
verifierPayout: z.ZodString;
|
|
208
|
+
requesterRefund: z.ZodString;
|
|
209
|
+
platformFee: z.ZodString;
|
|
210
|
+
state: z.ZodEnum<{
|
|
211
|
+
pending: "pending";
|
|
212
|
+
submitted: "submitted";
|
|
213
|
+
confirmed: "confirmed";
|
|
214
|
+
failed: "failed";
|
|
215
|
+
}>;
|
|
216
|
+
transactionHash: z.ZodOptional<z.ZodString>;
|
|
217
|
+
submittedAt: z.ZodOptional<z.ZodString>;
|
|
218
|
+
settledAt: z.ZodOptional<z.ZodString>;
|
|
219
|
+
confirmedAt: z.ZodOptional<z.ZodString>;
|
|
220
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
221
|
+
ledger: z.ZodOptional<z.ZodString>;
|
|
222
|
+
error: z.ZodOptional<z.ZodString>;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
export type PreparedVerifier = z.infer<typeof PreparedVerifierSchema>;
|
|
226
|
+
export type PreparedJob = z.infer<typeof PreparedJobSchema>;
|
|
227
|
+
export type TeeProof = z.infer<typeof TeeProofSchema>;
|
|
228
|
+
export type JobResult = z.infer<typeof JobResultSchema>;
|
|
229
|
+
export type Attestation = z.infer<typeof AttestationSchema>;
|
|
230
|
+
export type SettlementState = z.infer<typeof SettlementStateSchema>;
|
|
231
|
+
export type Settlement = z.infer<typeof SettlementSchema>;
|
|
232
|
+
export type Job = z.infer<typeof JobSchema>;
|