@phala/cloud 0.2.5 → 0.2.9
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/actions/apps/check_app_cvms_is_allowed.d.ts +164 -0
- package/dist/actions/apps/check_app_is_allowed.d.ts +109 -0
- package/dist/actions/apps/create_app_instance.d.ts +196 -0
- package/dist/actions/apps/get_app_device_allowlist.d.ts +2 -2
- package/dist/actions/blockchains/abi/dstack_app.d.ts +30 -0
- package/dist/actions/blockchains/check_compose_hash_allowed.d.ts +43 -0
- package/dist/actions/blockchains/check_on_chain_prerequisites.d.ts +59 -0
- package/dist/actions/cvms/check_cvm_is_allowed.d.ts +145 -0
- package/dist/actions/cvms/commit_cvm_provision.d.ts +19 -0
- package/dist/actions/cvms/commit_cvm_update.d.ts +100 -0
- package/dist/actions/cvms/confirm_cvm_patch.d.ts +92 -0
- package/dist/actions/cvms/patch_cvm.d.ts +447 -0
- package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +8 -0
- package/dist/actions/index.d.ts +9 -0
- package/dist/client.d.ts +5 -0
- package/dist/index.js +741 -191
- package/dist/index.mjs +710 -191
- package/dist/types/app_info_v20260121.d.ts +90 -6
- package/dist/types/cvm_info_v20260121.d.ts +60 -4
- package/dist/utils/error_codes.d.ts +48 -0
- package/dist/utils/errors.d.ts +9 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/verify-webhook.d.ts +35 -0
- package/dist/webhook.d.ts +11 -0
- package/dist/webhook.js +68 -0
- package/dist/webhook.mjs +40 -0
- package/package.json +7 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AppCvmsBatchIsAllowedResponseSchema: z.ZodObject<{
|
|
3
|
+
is_onchain: z.ZodBoolean;
|
|
4
|
+
results: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
5
|
+
app_contract_address: z.ZodString;
|
|
6
|
+
compose_hash: z.ZodString;
|
|
7
|
+
device_id: z.ZodString;
|
|
8
|
+
compose_hash_allowed: z.ZodBoolean;
|
|
9
|
+
allow_any_device: z.ZodBoolean;
|
|
10
|
+
device_id_allowed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
11
|
+
is_allowed: z.ZodBoolean;
|
|
12
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
} & {
|
|
14
|
+
cvm_id: z.ZodNumber;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
device_id: string;
|
|
17
|
+
compose_hash: string;
|
|
18
|
+
compose_hash_allowed: boolean;
|
|
19
|
+
is_allowed: boolean;
|
|
20
|
+
cvm_id: number;
|
|
21
|
+
app_contract_address: string;
|
|
22
|
+
allow_any_device: boolean;
|
|
23
|
+
error?: string | null | undefined;
|
|
24
|
+
device_id_allowed?: boolean | null | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
device_id: string;
|
|
27
|
+
compose_hash: string;
|
|
28
|
+
compose_hash_allowed: boolean;
|
|
29
|
+
is_allowed: boolean;
|
|
30
|
+
cvm_id: number;
|
|
31
|
+
app_contract_address: string;
|
|
32
|
+
allow_any_device: boolean;
|
|
33
|
+
error?: string | null | undefined;
|
|
34
|
+
device_id_allowed?: boolean | null | undefined;
|
|
35
|
+
}>, "many">>;
|
|
36
|
+
total: z.ZodDefault<z.ZodNumber>;
|
|
37
|
+
allowed_count: z.ZodDefault<z.ZodNumber>;
|
|
38
|
+
denied_count: z.ZodDefault<z.ZodNumber>;
|
|
39
|
+
error_count: z.ZodDefault<z.ZodNumber>;
|
|
40
|
+
skipped_cvm_ids: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
total: number;
|
|
43
|
+
is_onchain: boolean;
|
|
44
|
+
results: {
|
|
45
|
+
device_id: string;
|
|
46
|
+
compose_hash: string;
|
|
47
|
+
compose_hash_allowed: boolean;
|
|
48
|
+
is_allowed: boolean;
|
|
49
|
+
cvm_id: number;
|
|
50
|
+
app_contract_address: string;
|
|
51
|
+
allow_any_device: boolean;
|
|
52
|
+
error?: string | null | undefined;
|
|
53
|
+
device_id_allowed?: boolean | null | undefined;
|
|
54
|
+
}[];
|
|
55
|
+
allowed_count: number;
|
|
56
|
+
denied_count: number;
|
|
57
|
+
error_count: number;
|
|
58
|
+
skipped_cvm_ids: number[];
|
|
59
|
+
}, {
|
|
60
|
+
is_onchain: boolean;
|
|
61
|
+
total?: number | undefined;
|
|
62
|
+
results?: {
|
|
63
|
+
device_id: string;
|
|
64
|
+
compose_hash: string;
|
|
65
|
+
compose_hash_allowed: boolean;
|
|
66
|
+
is_allowed: boolean;
|
|
67
|
+
cvm_id: number;
|
|
68
|
+
app_contract_address: string;
|
|
69
|
+
allow_any_device: boolean;
|
|
70
|
+
error?: string | null | undefined;
|
|
71
|
+
device_id_allowed?: boolean | null | undefined;
|
|
72
|
+
}[] | undefined;
|
|
73
|
+
allowed_count?: number | undefined;
|
|
74
|
+
denied_count?: number | undefined;
|
|
75
|
+
error_count?: number | undefined;
|
|
76
|
+
skipped_cvm_ids?: number[] | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
export type AppCvmsBatchIsAllowedResponse = z.infer<typeof AppCvmsBatchIsAllowedResponseSchema>;
|
|
79
|
+
export declare const CheckAppCvmsIsAllowedRequestSchema: z.ZodObject<{
|
|
80
|
+
appId: z.ZodString;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
appId: string;
|
|
83
|
+
}, {
|
|
84
|
+
appId: string;
|
|
85
|
+
}>;
|
|
86
|
+
export type CheckAppCvmsIsAllowedRequest = z.infer<typeof CheckAppCvmsIsAllowedRequestSchema>;
|
|
87
|
+
/**
|
|
88
|
+
* Batch check on-chain deployment allowance for all CVMs under an app.
|
|
89
|
+
*
|
|
90
|
+
* For on-chain KMS apps, queries the blockchain via multicall3 to check
|
|
91
|
+
* compose hash and device allowance for each CVM.
|
|
92
|
+
* For offchain KMS apps, returns is_onchain=false with no results.
|
|
93
|
+
*
|
|
94
|
+
* @param client - The API client
|
|
95
|
+
* @param request - Request parameters
|
|
96
|
+
* @param request.appId - The hex app identifier
|
|
97
|
+
* @returns Batch allowance check results for all CVMs
|
|
98
|
+
*/
|
|
99
|
+
declare const checkAppCvmsIsAllowed: {
|
|
100
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
101
|
+
appId: string;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
total: number;
|
|
104
|
+
is_onchain: boolean;
|
|
105
|
+
results: {
|
|
106
|
+
device_id: string;
|
|
107
|
+
compose_hash: string;
|
|
108
|
+
compose_hash_allowed: boolean;
|
|
109
|
+
is_allowed: boolean;
|
|
110
|
+
cvm_id: number;
|
|
111
|
+
app_contract_address: string;
|
|
112
|
+
allow_any_device: boolean;
|
|
113
|
+
error?: string | null | undefined;
|
|
114
|
+
device_id_allowed?: boolean | null | undefined;
|
|
115
|
+
}[];
|
|
116
|
+
allowed_count: number;
|
|
117
|
+
denied_count: number;
|
|
118
|
+
error_count: number;
|
|
119
|
+
skipped_cvm_ids: number[];
|
|
120
|
+
}>;
|
|
121
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
122
|
+
appId: string;
|
|
123
|
+
}, parameters: {
|
|
124
|
+
schema: T;
|
|
125
|
+
}): Promise<z.TypeOf<T>>;
|
|
126
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
127
|
+
appId: string;
|
|
128
|
+
}, parameters: {
|
|
129
|
+
schema: false;
|
|
130
|
+
}): Promise<unknown>;
|
|
131
|
+
}, safeCheckAppCvmsIsAllowed: {
|
|
132
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
133
|
+
appId: string;
|
|
134
|
+
}): Promise<import("../..").SafeResult<{
|
|
135
|
+
total: number;
|
|
136
|
+
is_onchain: boolean;
|
|
137
|
+
results: {
|
|
138
|
+
device_id: string;
|
|
139
|
+
compose_hash: string;
|
|
140
|
+
compose_hash_allowed: boolean;
|
|
141
|
+
is_allowed: boolean;
|
|
142
|
+
cvm_id: number;
|
|
143
|
+
app_contract_address: string;
|
|
144
|
+
allow_any_device: boolean;
|
|
145
|
+
error?: string | null | undefined;
|
|
146
|
+
device_id_allowed?: boolean | null | undefined;
|
|
147
|
+
}[];
|
|
148
|
+
allowed_count: number;
|
|
149
|
+
denied_count: number;
|
|
150
|
+
error_count: number;
|
|
151
|
+
skipped_cvm_ids: number[];
|
|
152
|
+
}>>;
|
|
153
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
154
|
+
appId: string;
|
|
155
|
+
}, parameters: {
|
|
156
|
+
schema: T;
|
|
157
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
158
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
159
|
+
appId: string;
|
|
160
|
+
}, parameters: {
|
|
161
|
+
schema: false;
|
|
162
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
163
|
+
};
|
|
164
|
+
export { checkAppCvmsIsAllowed, safeCheckAppCvmsIsAllowed };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CheckAppIsAllowedRequestSchema: z.ZodObject<{
|
|
3
|
+
appId: z.ZodString;
|
|
4
|
+
compose_hash: z.ZodString;
|
|
5
|
+
node_id: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
device_id: z.ZodOptional<z.ZodString>;
|
|
7
|
+
chain_id: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
compose_hash: string;
|
|
10
|
+
appId: string;
|
|
11
|
+
chain_id?: number | undefined;
|
|
12
|
+
device_id?: string | undefined;
|
|
13
|
+
node_id?: number | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
compose_hash: string;
|
|
16
|
+
appId: string;
|
|
17
|
+
chain_id?: number | undefined;
|
|
18
|
+
device_id?: string | undefined;
|
|
19
|
+
node_id?: number | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type CheckAppIsAllowedRequest = z.infer<typeof CheckAppIsAllowedRequestSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a deployment is allowed by an on-chain DStack App contract.
|
|
24
|
+
*
|
|
25
|
+
* Supports pure contract query (no DB) when all parameters including chain_id are provided.
|
|
26
|
+
*
|
|
27
|
+
* @param client - The API client
|
|
28
|
+
* @param request - Request parameters
|
|
29
|
+
* @param request.appId - App contract address
|
|
30
|
+
* @param request.compose_hash - Compose hash to check
|
|
31
|
+
* @param request.node_id - Node ID (resolves device_id from DB)
|
|
32
|
+
* @param request.device_id - Device ID (hex, direct)
|
|
33
|
+
* @param request.chain_id - Chain ID for RPC URL resolution
|
|
34
|
+
* @returns On-chain allowance check result
|
|
35
|
+
*/
|
|
36
|
+
declare const checkAppIsAllowed: {
|
|
37
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
38
|
+
compose_hash: string;
|
|
39
|
+
appId: string;
|
|
40
|
+
chain_id?: number | undefined;
|
|
41
|
+
device_id?: string | undefined;
|
|
42
|
+
node_id?: number | undefined;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
device_id: string;
|
|
45
|
+
compose_hash: string;
|
|
46
|
+
compose_hash_allowed: boolean;
|
|
47
|
+
is_allowed: boolean;
|
|
48
|
+
app_contract_address: string;
|
|
49
|
+
allow_any_device: boolean;
|
|
50
|
+
error?: string | null | undefined;
|
|
51
|
+
device_id_allowed?: boolean | null | undefined;
|
|
52
|
+
cvm_id?: number | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
55
|
+
compose_hash: string;
|
|
56
|
+
appId: string;
|
|
57
|
+
chain_id?: number | undefined;
|
|
58
|
+
device_id?: string | undefined;
|
|
59
|
+
node_id?: number | undefined;
|
|
60
|
+
}, parameters: {
|
|
61
|
+
schema: T;
|
|
62
|
+
}): Promise<z.TypeOf<T>>;
|
|
63
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
64
|
+
compose_hash: string;
|
|
65
|
+
appId: string;
|
|
66
|
+
chain_id?: number | undefined;
|
|
67
|
+
device_id?: string | undefined;
|
|
68
|
+
node_id?: number | undefined;
|
|
69
|
+
}, parameters: {
|
|
70
|
+
schema: false;
|
|
71
|
+
}): Promise<unknown>;
|
|
72
|
+
}, safeCheckAppIsAllowed: {
|
|
73
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
74
|
+
compose_hash: string;
|
|
75
|
+
appId: string;
|
|
76
|
+
chain_id?: number | undefined;
|
|
77
|
+
device_id?: string | undefined;
|
|
78
|
+
node_id?: number | undefined;
|
|
79
|
+
}): Promise<import("../..").SafeResult<{
|
|
80
|
+
device_id: string;
|
|
81
|
+
compose_hash: string;
|
|
82
|
+
compose_hash_allowed: boolean;
|
|
83
|
+
is_allowed: boolean;
|
|
84
|
+
app_contract_address: string;
|
|
85
|
+
allow_any_device: boolean;
|
|
86
|
+
error?: string | null | undefined;
|
|
87
|
+
device_id_allowed?: boolean | null | undefined;
|
|
88
|
+
cvm_id?: number | undefined;
|
|
89
|
+
}>>;
|
|
90
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
91
|
+
compose_hash: string;
|
|
92
|
+
appId: string;
|
|
93
|
+
chain_id?: number | undefined;
|
|
94
|
+
device_id?: string | undefined;
|
|
95
|
+
node_id?: number | undefined;
|
|
96
|
+
}, parameters: {
|
|
97
|
+
schema: T;
|
|
98
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
99
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
100
|
+
compose_hash: string;
|
|
101
|
+
appId: string;
|
|
102
|
+
chain_id?: number | undefined;
|
|
103
|
+
device_id?: string | undefined;
|
|
104
|
+
node_id?: number | undefined;
|
|
105
|
+
}, parameters: {
|
|
106
|
+
schema: false;
|
|
107
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
108
|
+
};
|
|
109
|
+
export { checkAppIsAllowed, safeCheckAppIsAllowed };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new instance under an existing app
|
|
4
|
+
*
|
|
5
|
+
* Deploy a new CVM instance under an existing app, optionally with a new
|
|
6
|
+
* Docker Compose file. For on-chain KMS apps, this uses a two-phase flow:
|
|
7
|
+
* the first request returns HTTP 465 with a commit token; after registering
|
|
8
|
+
* the compose hash on-chain, the second request commits with the token and
|
|
9
|
+
* transaction hash.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createClient, createAppInstance } from '@phala/cloud'
|
|
14
|
+
*
|
|
15
|
+
* const client = createClient();
|
|
16
|
+
*
|
|
17
|
+
* // Create instance with existing compose
|
|
18
|
+
* const instance = await createAppInstance(client, {
|
|
19
|
+
* appId: '50b0e827cc6c53f4010b57e588a18c5ef9388cc1',
|
|
20
|
+
* node_id: 5,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Create instance with new Docker Compose
|
|
24
|
+
* const instance2 = await createAppInstance(client, {
|
|
25
|
+
* appId: '50b0e827cc6c53f4010b57e588a18c5ef9388cc1',
|
|
26
|
+
* docker_compose_file: 'services:\n app:\n image: nginx',
|
|
27
|
+
* node_id: 5,
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ## Safe Version
|
|
32
|
+
*
|
|
33
|
+
* Use `safeCreateAppInstance` for error handling without exceptions:
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const result = await safeCreateAppInstance(client, { appId: 'my-app-id' });
|
|
37
|
+
* if (result.success) {
|
|
38
|
+
* console.log('Instance created:', result.data.vm_uuid);
|
|
39
|
+
* } else {
|
|
40
|
+
* console.error('Failed:', result.error.message);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const CreateAppInstanceRequestSchema: z.ZodObject<{
|
|
45
|
+
appId: z.ZodString;
|
|
46
|
+
node_id: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
docker_compose_file: z.ZodOptional<z.ZodString>;
|
|
48
|
+
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
49
|
+
encrypted_env: z.ZodOptional<z.ZodString>;
|
|
50
|
+
compose_hash: z.ZodOptional<z.ZodString>;
|
|
51
|
+
token: z.ZodOptional<z.ZodString>;
|
|
52
|
+
transaction_hash: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, "strict", z.ZodTypeAny, {
|
|
54
|
+
appId: string;
|
|
55
|
+
compose_hash?: string | undefined;
|
|
56
|
+
node_id?: number | undefined;
|
|
57
|
+
docker_compose_file?: string | undefined;
|
|
58
|
+
pre_launch_script?: string | undefined;
|
|
59
|
+
encrypted_env?: string | undefined;
|
|
60
|
+
transaction_hash?: string | undefined;
|
|
61
|
+
token?: string | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
appId: string;
|
|
64
|
+
compose_hash?: string | undefined;
|
|
65
|
+
node_id?: number | undefined;
|
|
66
|
+
docker_compose_file?: string | undefined;
|
|
67
|
+
pre_launch_script?: string | undefined;
|
|
68
|
+
encrypted_env?: string | undefined;
|
|
69
|
+
transaction_hash?: string | undefined;
|
|
70
|
+
token?: string | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
export type CreateAppInstanceRequest = z.infer<typeof CreateAppInstanceRequestSchema>;
|
|
73
|
+
declare const createAppInstance: {
|
|
74
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
75
|
+
appId: string;
|
|
76
|
+
compose_hash?: string | undefined;
|
|
77
|
+
node_id?: number | undefined;
|
|
78
|
+
docker_compose_file?: string | undefined;
|
|
79
|
+
pre_launch_script?: string | undefined;
|
|
80
|
+
encrypted_env?: string | undefined;
|
|
81
|
+
transaction_hash?: string | undefined;
|
|
82
|
+
token?: string | undefined;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
status: string;
|
|
85
|
+
name: string;
|
|
86
|
+
id: number;
|
|
87
|
+
app_id: string;
|
|
88
|
+
instance_id: string | null;
|
|
89
|
+
vcpu: number;
|
|
90
|
+
memory: number;
|
|
91
|
+
disk_size: number;
|
|
92
|
+
teepod_id: number;
|
|
93
|
+
vm_uuid: string | null;
|
|
94
|
+
encrypted_env_pubkey: string | null;
|
|
95
|
+
created_at: string;
|
|
96
|
+
version?: string | null | undefined;
|
|
97
|
+
app_url?: string | null | undefined;
|
|
98
|
+
teepod?: {
|
|
99
|
+
name: string;
|
|
100
|
+
id: number;
|
|
101
|
+
region_identifier?: string | null | undefined;
|
|
102
|
+
} | null | undefined;
|
|
103
|
+
base_image?: string | null | undefined;
|
|
104
|
+
user_id?: number | null | undefined;
|
|
105
|
+
docker_compose_file?: string | null | undefined;
|
|
106
|
+
features?: string[] | null | undefined;
|
|
107
|
+
manifest_version?: number | null | undefined;
|
|
108
|
+
runner?: string | null | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
111
|
+
appId: string;
|
|
112
|
+
compose_hash?: string | undefined;
|
|
113
|
+
node_id?: number | undefined;
|
|
114
|
+
docker_compose_file?: string | undefined;
|
|
115
|
+
pre_launch_script?: string | undefined;
|
|
116
|
+
encrypted_env?: string | undefined;
|
|
117
|
+
transaction_hash?: string | undefined;
|
|
118
|
+
token?: string | undefined;
|
|
119
|
+
}, parameters: {
|
|
120
|
+
schema: T;
|
|
121
|
+
}): Promise<z.TypeOf<T>>;
|
|
122
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
123
|
+
appId: string;
|
|
124
|
+
compose_hash?: string | undefined;
|
|
125
|
+
node_id?: number | undefined;
|
|
126
|
+
docker_compose_file?: string | undefined;
|
|
127
|
+
pre_launch_script?: string | undefined;
|
|
128
|
+
encrypted_env?: string | undefined;
|
|
129
|
+
transaction_hash?: string | undefined;
|
|
130
|
+
token?: string | undefined;
|
|
131
|
+
}, parameters: {
|
|
132
|
+
schema: false;
|
|
133
|
+
}): Promise<unknown>;
|
|
134
|
+
}, safeCreateAppInstance: {
|
|
135
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
136
|
+
appId: string;
|
|
137
|
+
compose_hash?: string | undefined;
|
|
138
|
+
node_id?: number | undefined;
|
|
139
|
+
docker_compose_file?: string | undefined;
|
|
140
|
+
pre_launch_script?: string | undefined;
|
|
141
|
+
encrypted_env?: string | undefined;
|
|
142
|
+
transaction_hash?: string | undefined;
|
|
143
|
+
token?: string | undefined;
|
|
144
|
+
}): Promise<import("../..").SafeResult<{
|
|
145
|
+
status: string;
|
|
146
|
+
name: string;
|
|
147
|
+
id: number;
|
|
148
|
+
app_id: string;
|
|
149
|
+
instance_id: string | null;
|
|
150
|
+
vcpu: number;
|
|
151
|
+
memory: number;
|
|
152
|
+
disk_size: number;
|
|
153
|
+
teepod_id: number;
|
|
154
|
+
vm_uuid: string | null;
|
|
155
|
+
encrypted_env_pubkey: string | null;
|
|
156
|
+
created_at: string;
|
|
157
|
+
version?: string | null | undefined;
|
|
158
|
+
app_url?: string | null | undefined;
|
|
159
|
+
teepod?: {
|
|
160
|
+
name: string;
|
|
161
|
+
id: number;
|
|
162
|
+
region_identifier?: string | null | undefined;
|
|
163
|
+
} | null | undefined;
|
|
164
|
+
base_image?: string | null | undefined;
|
|
165
|
+
user_id?: number | null | undefined;
|
|
166
|
+
docker_compose_file?: string | null | undefined;
|
|
167
|
+
features?: string[] | null | undefined;
|
|
168
|
+
manifest_version?: number | null | undefined;
|
|
169
|
+
runner?: string | null | undefined;
|
|
170
|
+
}>>;
|
|
171
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
172
|
+
appId: string;
|
|
173
|
+
compose_hash?: string | undefined;
|
|
174
|
+
node_id?: number | undefined;
|
|
175
|
+
docker_compose_file?: string | undefined;
|
|
176
|
+
pre_launch_script?: string | undefined;
|
|
177
|
+
encrypted_env?: string | undefined;
|
|
178
|
+
transaction_hash?: string | undefined;
|
|
179
|
+
token?: string | undefined;
|
|
180
|
+
}, parameters: {
|
|
181
|
+
schema: T;
|
|
182
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
183
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
184
|
+
appId: string;
|
|
185
|
+
compose_hash?: string | undefined;
|
|
186
|
+
node_id?: number | undefined;
|
|
187
|
+
docker_compose_file?: string | undefined;
|
|
188
|
+
pre_launch_script?: string | undefined;
|
|
189
|
+
encrypted_env?: string | undefined;
|
|
190
|
+
transaction_hash?: string | undefined;
|
|
191
|
+
token?: string | undefined;
|
|
192
|
+
}, parameters: {
|
|
193
|
+
schema: false;
|
|
194
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
195
|
+
};
|
|
196
|
+
export { createAppInstance, safeCreateAppInstance };
|
|
@@ -54,8 +54,8 @@ declare const DeviceAllowlistResponseSchema: z.ZodObject<{
|
|
|
54
54
|
}[];
|
|
55
55
|
is_onchain_kms: boolean;
|
|
56
56
|
chain_id?: number | null | undefined;
|
|
57
|
-
allow_any_device?: boolean | null | undefined;
|
|
58
57
|
app_contract_address?: string | null | undefined;
|
|
58
|
+
allow_any_device?: boolean | null | undefined;
|
|
59
59
|
}, {
|
|
60
60
|
is_onchain_kms: boolean;
|
|
61
61
|
chain_id?: number | null | undefined;
|
|
@@ -66,8 +66,8 @@ declare const DeviceAllowlistResponseSchema: z.ZodObject<{
|
|
|
66
66
|
cvm_ids: number[];
|
|
67
67
|
allowed_onchain: boolean;
|
|
68
68
|
}[] | undefined;
|
|
69
|
-
allow_any_device?: boolean | null | undefined;
|
|
70
69
|
app_contract_address?: string | null | undefined;
|
|
70
|
+
allow_any_device?: boolean | null | undefined;
|
|
71
71
|
}>;
|
|
72
72
|
export type DeviceAllowlistItem = z.infer<typeof DeviceAllowlistItemSchema>;
|
|
73
73
|
export type DeviceAllowlistResponse = z.infer<typeof DeviceAllowlistResponseSchema>;
|
|
@@ -68,6 +68,36 @@ export declare const dstackAppAbi: readonly [{
|
|
|
68
68
|
}];
|
|
69
69
|
readonly stateMutability: "view";
|
|
70
70
|
readonly type: "function";
|
|
71
|
+
}, {
|
|
72
|
+
readonly inputs: readonly [{
|
|
73
|
+
readonly internalType: "bytes32";
|
|
74
|
+
readonly name: "";
|
|
75
|
+
readonly type: "bytes32";
|
|
76
|
+
}];
|
|
77
|
+
readonly name: "allowedComposeHashes";
|
|
78
|
+
readonly outputs: readonly [{
|
|
79
|
+
readonly internalType: "bool";
|
|
80
|
+
readonly name: "";
|
|
81
|
+
readonly type: "bool";
|
|
82
|
+
}];
|
|
83
|
+
readonly stateMutability: "view";
|
|
84
|
+
readonly type: "function";
|
|
85
|
+
}, {
|
|
86
|
+
readonly inputs: readonly [{
|
|
87
|
+
readonly internalType: "address";
|
|
88
|
+
readonly name: "owner";
|
|
89
|
+
readonly type: "address";
|
|
90
|
+
}];
|
|
91
|
+
readonly name: "OwnableInvalidOwner";
|
|
92
|
+
readonly type: "error";
|
|
93
|
+
}, {
|
|
94
|
+
readonly inputs: readonly [{
|
|
95
|
+
readonly internalType: "address";
|
|
96
|
+
readonly name: "account";
|
|
97
|
+
readonly type: "address";
|
|
98
|
+
}];
|
|
99
|
+
readonly name: "OwnableUnauthorizedAccount";
|
|
100
|
+
readonly type: "error";
|
|
71
101
|
}, {
|
|
72
102
|
readonly anonymous: false;
|
|
73
103
|
readonly inputs: readonly [{
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Chain, type Address, type PublicClient } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Check whether a specific compose hash is allowed by a DstackApp contract.
|
|
4
|
+
*
|
|
5
|
+
* Reads the `allowedComposeHashes(hash)` mapping on-chain.
|
|
6
|
+
*
|
|
7
|
+
* @group Actions
|
|
8
|
+
* @since 0.7.0
|
|
9
|
+
*
|
|
10
|
+
* ## Usage
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { checkComposeHashAllowed } from '@phala/cloud'
|
|
14
|
+
* import { base } from 'viem/chains'
|
|
15
|
+
*
|
|
16
|
+
* const allowed = await checkComposeHashAllowed({
|
|
17
|
+
* chain: base,
|
|
18
|
+
* appAddress: "0x1234...abcd",
|
|
19
|
+
* composeHash: "0xaabbccdd...",
|
|
20
|
+
* })
|
|
21
|
+
* console.log(allowed) // true or false
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type CheckComposeHashAllowedRequest = {
|
|
25
|
+
chain?: Chain;
|
|
26
|
+
rpcUrl?: string;
|
|
27
|
+
appAddress: Address;
|
|
28
|
+
composeHash: string;
|
|
29
|
+
publicClient?: PublicClient;
|
|
30
|
+
};
|
|
31
|
+
export declare function checkComposeHashAllowed(request: CheckComposeHashAllowedRequest): Promise<boolean>;
|
|
32
|
+
export declare function safeCheckComposeHashAllowed(request: CheckComposeHashAllowedRequest): Promise<{
|
|
33
|
+
success: true;
|
|
34
|
+
data: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
success: false;
|
|
37
|
+
error: {
|
|
38
|
+
isRequestError: true;
|
|
39
|
+
message: string;
|
|
40
|
+
status: number;
|
|
41
|
+
detail: string;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type Chain, type Address, type PublicClient } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Check on-chain prerequisites for a CVM update in a single RPC call.
|
|
4
|
+
*
|
|
5
|
+
* Uses `multicall` to batch-check:
|
|
6
|
+
* 1. `allowAnyDevice()` — whether the contract allows any device
|
|
7
|
+
* 2. `allowedDeviceIds(deviceId)` — whether the specific device is registered
|
|
8
|
+
* 3. `allowedComposeHashes(composeHash)` — whether the compose hash is already registered
|
|
9
|
+
*
|
|
10
|
+
* @group Actions
|
|
11
|
+
* @since 0.7.0
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { checkOnChainPrerequisites } from '@phala/cloud'
|
|
17
|
+
* import { base } from 'viem/chains'
|
|
18
|
+
*
|
|
19
|
+
* const prereqs = await checkOnChainPrerequisites({
|
|
20
|
+
* chain: base,
|
|
21
|
+
* appAddress: "0x1234...abcd",
|
|
22
|
+
* deviceId: "0xaabbccdd...",
|
|
23
|
+
* composeHash: "0xeeff0011...",
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* if (!prereqs.deviceAllowed) {
|
|
27
|
+
* // Need to call addDevice first
|
|
28
|
+
* }
|
|
29
|
+
* if (prereqs.composeHashAllowed) {
|
|
30
|
+
* // Can skip addComposeHash transaction
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type CheckOnChainPrerequisitesRequest = {
|
|
35
|
+
chain?: Chain;
|
|
36
|
+
rpcUrl?: string;
|
|
37
|
+
appAddress: Address;
|
|
38
|
+
deviceId: string;
|
|
39
|
+
composeHash: string;
|
|
40
|
+
publicClient?: PublicClient;
|
|
41
|
+
};
|
|
42
|
+
export type OnChainPrerequisites = {
|
|
43
|
+
allowAnyDevice: boolean;
|
|
44
|
+
deviceAllowed: boolean;
|
|
45
|
+
composeHashAllowed: boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare function checkOnChainPrerequisites(request: CheckOnChainPrerequisitesRequest): Promise<OnChainPrerequisites>;
|
|
48
|
+
export declare function safeCheckOnChainPrerequisites(request: CheckOnChainPrerequisitesRequest): Promise<{
|
|
49
|
+
success: true;
|
|
50
|
+
data: OnChainPrerequisites;
|
|
51
|
+
} | {
|
|
52
|
+
success: false;
|
|
53
|
+
error: {
|
|
54
|
+
isRequestError: true;
|
|
55
|
+
message: string;
|
|
56
|
+
status: number;
|
|
57
|
+
detail: string;
|
|
58
|
+
};
|
|
59
|
+
}>;
|