@layr-labs/ecloud-sdk 0.2.0 → 0.2.2-dev
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/VERSION +2 -2
- package/dist/billing.cjs +48 -43
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +6 -3
- package/dist/billing.d.ts +6 -3
- package/dist/billing.js +519 -4
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +5034 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +239 -0
- package/dist/browser.d.ts +239 -0
- package/dist/browser.js +4924 -0
- package/dist/browser.js.map +1 -0
- package/dist/{compute-CF2HOXed.d.ts → compute-BYhSs8en.d.ts} +15 -96
- package/dist/{compute-CbmjA8kJ.d.cts → compute-Bpjb3hYD.d.cts} +15 -96
- package/dist/compute.cjs +875 -846
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.d.cts +2 -2
- package/dist/compute.d.ts +2 -2
- package/dist/compute.js +7009 -8
- package/dist/compute.js.map +1 -1
- package/dist/helpers-CEvhJz7f.d.cts +742 -0
- package/dist/helpers-CQuBwQnu.d.ts +742 -0
- package/dist/index-DeQzn_yM.d.cts +739 -0
- package/dist/index-DeQzn_yM.d.ts +739 -0
- package/dist/index.cjs +1958 -1758
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -414
- package/dist/index.d.ts +69 -414
- package/dist/index.js +7977 -134
- package/dist/index.js.map +1 -1
- package/package.json +17 -2
- package/dist/chunk-CA5Y4OVI.js +0 -744
- package/dist/chunk-CA5Y4OVI.js.map +0 -1
- package/dist/chunk-ZDXN2WKP.js +0 -434
- package/dist/chunk-ZDXN2WKP.js.map +0 -1
- package/dist/chunk-ZTLKZMSW.js +0 -6719
- package/dist/chunk-ZTLKZMSW.js.map +0 -1
- package/dist/index-D2QufVB9.d.cts +0 -342
- package/dist/index-D2QufVB9.d.ts +0 -342
package/dist/browser.js
ADDED
|
@@ -0,0 +1,4924 @@
|
|
|
1
|
+
// src/client/common/types/index.ts
|
|
2
|
+
var noopLogger = {
|
|
3
|
+
debug: () => {
|
|
4
|
+
},
|
|
5
|
+
info: () => {
|
|
6
|
+
},
|
|
7
|
+
warn: () => {
|
|
8
|
+
},
|
|
9
|
+
error: () => {
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/client/common/config/environment.ts
|
|
14
|
+
var SEPOLIA_CHAIN_ID = 11155111;
|
|
15
|
+
var MAINNET_CHAIN_ID = 1;
|
|
16
|
+
var CommonAddresses = {
|
|
17
|
+
ERC7702Delegator: "0x63c0c19a282a1b52b07dd5a65b58948a07dae32b"
|
|
18
|
+
};
|
|
19
|
+
var ChainAddresses = {
|
|
20
|
+
[MAINNET_CHAIN_ID]: {
|
|
21
|
+
PermissionController: "0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5"
|
|
22
|
+
},
|
|
23
|
+
[SEPOLIA_CHAIN_ID]: {
|
|
24
|
+
PermissionController: "0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37"
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var BILLING_ENVIRONMENTS = {
|
|
28
|
+
dev: {
|
|
29
|
+
billingApiServerURL: "https://billingapi-dev.eigencloud.xyz"
|
|
30
|
+
},
|
|
31
|
+
prod: {
|
|
32
|
+
billingApiServerURL: "https://billingapi.eigencloud.xyz"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var ENVIRONMENTS = {
|
|
36
|
+
"sepolia-dev": {
|
|
37
|
+
name: "sepolia",
|
|
38
|
+
build: "dev",
|
|
39
|
+
appControllerAddress: "0xa86DC1C47cb2518327fB4f9A1627F51966c83B92",
|
|
40
|
+
permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,
|
|
41
|
+
erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
|
|
42
|
+
kmsServerURL: "http://10.128.0.57:8080",
|
|
43
|
+
userApiServerURL: "https://userapi-compute-sepolia-dev.eigencloud.xyz",
|
|
44
|
+
defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com"
|
|
45
|
+
},
|
|
46
|
+
sepolia: {
|
|
47
|
+
name: "sepolia",
|
|
48
|
+
build: "prod",
|
|
49
|
+
appControllerAddress: "0x0dd810a6ffba6a9820a10d97b659f07d8d23d4E2",
|
|
50
|
+
permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,
|
|
51
|
+
erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
|
|
52
|
+
kmsServerURL: "http://10.128.15.203:8080",
|
|
53
|
+
userApiServerURL: "https://userapi-compute-sepolia-prod.eigencloud.xyz",
|
|
54
|
+
defaultRPCURL: "https://ethereum-sepolia-rpc.publicnode.com"
|
|
55
|
+
},
|
|
56
|
+
"mainnet-alpha": {
|
|
57
|
+
name: "mainnet-alpha",
|
|
58
|
+
build: "prod",
|
|
59
|
+
appControllerAddress: "0xc38d35Fc995e75342A21CBd6D770305b142Fbe67",
|
|
60
|
+
permissionControllerAddress: ChainAddresses[MAINNET_CHAIN_ID].PermissionController,
|
|
61
|
+
erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,
|
|
62
|
+
kmsServerURL: "http://10.128.0.2:8080",
|
|
63
|
+
userApiServerURL: "https://userapi-compute.eigencloud.xyz",
|
|
64
|
+
defaultRPCURL: "https://ethereum-rpc.publicnode.com"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var CHAIN_ID_TO_ENVIRONMENT = {
|
|
68
|
+
[SEPOLIA_CHAIN_ID.toString()]: "sepolia",
|
|
69
|
+
[MAINNET_CHAIN_ID.toString()]: "mainnet-alpha"
|
|
70
|
+
};
|
|
71
|
+
function getEnvironmentConfig(environment, chainID) {
|
|
72
|
+
const env = ENVIRONMENTS[environment];
|
|
73
|
+
if (!env) {
|
|
74
|
+
throw new Error(`Unknown environment: ${environment}`);
|
|
75
|
+
}
|
|
76
|
+
if (!isEnvironmentAvailable(environment)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Environment ${environment} is not available in this build type. Available environments: ${getAvailableEnvironments().join(", ")}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (chainID) {
|
|
82
|
+
const expectedEnv = CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];
|
|
83
|
+
if (expectedEnv && expectedEnv !== environment) {
|
|
84
|
+
throw new Error(`Environment ${environment} does not match chain ID ${chainID}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
|
|
88
|
+
return {
|
|
89
|
+
...env,
|
|
90
|
+
chainID: BigInt(resolvedChainID)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function getBillingEnvironmentConfig(build) {
|
|
94
|
+
const config = BILLING_ENVIRONMENTS[build];
|
|
95
|
+
if (!config) {
|
|
96
|
+
throw new Error(`Unknown billing environment: ${build}`);
|
|
97
|
+
}
|
|
98
|
+
return config;
|
|
99
|
+
}
|
|
100
|
+
function getBuildType() {
|
|
101
|
+
const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
|
|
102
|
+
const runtimeType = process.env.BUILD_TYPE?.toLowerCase();
|
|
103
|
+
const buildType = buildTimeType || runtimeType;
|
|
104
|
+
if (buildType === "dev") {
|
|
105
|
+
return "dev";
|
|
106
|
+
}
|
|
107
|
+
return "prod";
|
|
108
|
+
}
|
|
109
|
+
function getAvailableEnvironments() {
|
|
110
|
+
const buildType = getBuildType();
|
|
111
|
+
if (buildType === "dev") {
|
|
112
|
+
return ["sepolia-dev"];
|
|
113
|
+
}
|
|
114
|
+
return ["sepolia", "mainnet-alpha"];
|
|
115
|
+
}
|
|
116
|
+
function isEnvironmentAvailable(environment) {
|
|
117
|
+
return getAvailableEnvironments().includes(environment);
|
|
118
|
+
}
|
|
119
|
+
function isMainnet(environmentConfig) {
|
|
120
|
+
return environmentConfig.chainID === BigInt(MAINNET_CHAIN_ID);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/client/common/utils/validation.ts
|
|
124
|
+
import { isAddress } from "viem";
|
|
125
|
+
|
|
126
|
+
// src/client/common/utils/helpers.ts
|
|
127
|
+
import { extractChain, createPublicClient, createWalletClient, http } from "viem";
|
|
128
|
+
import { sepolia as sepolia2 } from "viem/chains";
|
|
129
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
130
|
+
|
|
131
|
+
// src/client/common/constants.ts
|
|
132
|
+
import { sepolia, mainnet } from "viem/chains";
|
|
133
|
+
var SUPPORTED_CHAINS = [mainnet, sepolia];
|
|
134
|
+
|
|
135
|
+
// src/client/common/utils/helpers.ts
|
|
136
|
+
function getChainFromID(chainID, fallback = sepolia2) {
|
|
137
|
+
const id = Number(chainID);
|
|
138
|
+
return extractChain({ chains: SUPPORTED_CHAINS, id }) || fallback;
|
|
139
|
+
}
|
|
140
|
+
function addHexPrefix(value) {
|
|
141
|
+
return value.startsWith("0x") ? value : `0x${value}`;
|
|
142
|
+
}
|
|
143
|
+
function stripHexPrefix(value) {
|
|
144
|
+
return value.startsWith("0x") ? value.slice(2) : value;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/client/common/utils/validation.ts
|
|
148
|
+
function validateAppName(name) {
|
|
149
|
+
if (!name) {
|
|
150
|
+
throw new Error("App name cannot be empty");
|
|
151
|
+
}
|
|
152
|
+
if (name.includes(" ")) {
|
|
153
|
+
throw new Error("App name cannot contain spaces");
|
|
154
|
+
}
|
|
155
|
+
if (name.length > 50) {
|
|
156
|
+
throw new Error("App name cannot be longer than 50 characters");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function validateImageReference(value) {
|
|
160
|
+
if (!value) {
|
|
161
|
+
return "Image reference cannot be empty";
|
|
162
|
+
}
|
|
163
|
+
if (!value.includes("/")) {
|
|
164
|
+
return "Image reference must contain at least one /";
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
function assertValidImageReference(value) {
|
|
169
|
+
const result = validateImageReference(value);
|
|
170
|
+
if (result !== true) {
|
|
171
|
+
throw new Error(result);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function extractAppNameFromImage(imageRef) {
|
|
175
|
+
const parts = imageRef.split("/");
|
|
176
|
+
let imageName = parts.length > 1 ? parts[parts.length - 1] : imageRef;
|
|
177
|
+
if (imageName.includes(":")) {
|
|
178
|
+
imageName = imageName.split(":")[0];
|
|
179
|
+
}
|
|
180
|
+
return imageName;
|
|
181
|
+
}
|
|
182
|
+
function validateInstanceTypeSKU(sku, availableTypes) {
|
|
183
|
+
if (!sku) {
|
|
184
|
+
throw new Error("Instance type SKU cannot be empty");
|
|
185
|
+
}
|
|
186
|
+
for (const it of availableTypes) {
|
|
187
|
+
if (it.sku === sku) {
|
|
188
|
+
return sku;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const validSKUs = availableTypes.map((it) => it.sku).join(", ");
|
|
192
|
+
throw new Error(`Invalid instance-type value: ${sku} (must be one of: ${validSKUs})`);
|
|
193
|
+
}
|
|
194
|
+
function validatePrivateKeyFormat(key) {
|
|
195
|
+
const keyWithoutPrefix = stripHexPrefix(key);
|
|
196
|
+
if (!/^[0-9a-fA-F]{64}$/.test(keyWithoutPrefix)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
function assertValidPrivateKey(key) {
|
|
202
|
+
if (!key) {
|
|
203
|
+
throw new Error("Private key is required");
|
|
204
|
+
}
|
|
205
|
+
if (!validatePrivateKeyFormat(key)) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
"Invalid private key format (must be 64 hex characters, optionally prefixed with 0x)"
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function validateURL(rawURL) {
|
|
212
|
+
if (!rawURL.trim()) {
|
|
213
|
+
return "URL cannot be empty";
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const url = new URL(rawURL);
|
|
217
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
218
|
+
return "URL scheme must be http or https";
|
|
219
|
+
}
|
|
220
|
+
} catch {
|
|
221
|
+
return "Invalid URL format";
|
|
222
|
+
}
|
|
223
|
+
return void 0;
|
|
224
|
+
}
|
|
225
|
+
var VALID_X_HOSTS = ["twitter.com", "www.twitter.com", "x.com", "www.x.com"];
|
|
226
|
+
function validateXURL(rawURL) {
|
|
227
|
+
const urlErr = validateURL(rawURL);
|
|
228
|
+
if (urlErr) {
|
|
229
|
+
return urlErr;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
const url = new URL(rawURL);
|
|
233
|
+
const host = url.hostname.toLowerCase();
|
|
234
|
+
if (!VALID_X_HOSTS.includes(host)) {
|
|
235
|
+
return "URL must be a valid X/Twitter URL (x.com or twitter.com)";
|
|
236
|
+
}
|
|
237
|
+
if (!url.pathname || url.pathname === "/") {
|
|
238
|
+
return "X URL must include a username or profile path";
|
|
239
|
+
}
|
|
240
|
+
} catch {
|
|
241
|
+
return "Invalid X URL format";
|
|
242
|
+
}
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
245
|
+
var MAX_DESCRIPTION_LENGTH = 1e3;
|
|
246
|
+
function validateDescription(description) {
|
|
247
|
+
if (!description.trim()) {
|
|
248
|
+
return "Description cannot be empty";
|
|
249
|
+
}
|
|
250
|
+
if (description.length > MAX_DESCRIPTION_LENGTH) {
|
|
251
|
+
return `Description cannot exceed ${MAX_DESCRIPTION_LENGTH} characters`;
|
|
252
|
+
}
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
255
|
+
var MAX_IMAGE_SIZE = 4 * 1024 * 1024;
|
|
256
|
+
function validateAppID(appID) {
|
|
257
|
+
if (!appID) {
|
|
258
|
+
throw new Error("App ID is required");
|
|
259
|
+
}
|
|
260
|
+
const normalized = typeof appID === "string" ? addHexPrefix(appID) : appID;
|
|
261
|
+
if (isAddress(normalized)) {
|
|
262
|
+
return normalized;
|
|
263
|
+
}
|
|
264
|
+
throw new Error(`Invalid app ID: '${appID}' is not a valid address`);
|
|
265
|
+
}
|
|
266
|
+
function validateLogVisibility(logVisibility) {
|
|
267
|
+
switch (logVisibility) {
|
|
268
|
+
case "public":
|
|
269
|
+
return { logRedirect: "always", publicLogs: true };
|
|
270
|
+
case "private":
|
|
271
|
+
return { logRedirect: "always", publicLogs: false };
|
|
272
|
+
case "off":
|
|
273
|
+
return { logRedirect: "", publicLogs: false };
|
|
274
|
+
default:
|
|
275
|
+
throw new Error(
|
|
276
|
+
`Invalid log-visibility value: ${logVisibility} (must be public, private, or off)`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function hasScheme(rawURL) {
|
|
281
|
+
return rawURL.startsWith("http://") || rawURL.startsWith("https://");
|
|
282
|
+
}
|
|
283
|
+
function sanitizeString(s) {
|
|
284
|
+
return s.trim().replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
285
|
+
}
|
|
286
|
+
function sanitizeURL(rawURL) {
|
|
287
|
+
rawURL = rawURL.trim();
|
|
288
|
+
if (!hasScheme(rawURL)) {
|
|
289
|
+
rawURL = "https://" + rawURL;
|
|
290
|
+
}
|
|
291
|
+
const err = validateURL(rawURL);
|
|
292
|
+
if (err) {
|
|
293
|
+
throw new Error(err);
|
|
294
|
+
}
|
|
295
|
+
return rawURL;
|
|
296
|
+
}
|
|
297
|
+
function sanitizeXURL(rawURL) {
|
|
298
|
+
rawURL = rawURL.trim();
|
|
299
|
+
if (!rawURL.includes("://") && !rawURL.includes(".")) {
|
|
300
|
+
const username = rawURL.startsWith("@") ? rawURL.slice(1) : rawURL;
|
|
301
|
+
rawURL = `https://x.com/${username}`;
|
|
302
|
+
} else if (!hasScheme(rawURL)) {
|
|
303
|
+
rawURL = "https://" + rawURL;
|
|
304
|
+
}
|
|
305
|
+
rawURL = rawURL.replace(/twitter\.com/g, "x.com");
|
|
306
|
+
rawURL = rawURL.replace(/www\.x\.com/g, "x.com");
|
|
307
|
+
const err = validateXURL(rawURL);
|
|
308
|
+
if (err) {
|
|
309
|
+
throw new Error(err);
|
|
310
|
+
}
|
|
311
|
+
return rawURL;
|
|
312
|
+
}
|
|
313
|
+
function validateCreateAppParams(params) {
|
|
314
|
+
if (!params.name) {
|
|
315
|
+
throw new Error("Project name is required");
|
|
316
|
+
}
|
|
317
|
+
if (params.name.includes(" ")) {
|
|
318
|
+
throw new Error("Project name cannot contain spaces");
|
|
319
|
+
}
|
|
320
|
+
if (!params.language) {
|
|
321
|
+
throw new Error("Language is required");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function validateLogsParams(params) {
|
|
325
|
+
if (!params.appID) {
|
|
326
|
+
throw new Error("App ID is required for viewing logs");
|
|
327
|
+
}
|
|
328
|
+
validateAppID(params.appID);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/client/common/utils/billing.ts
|
|
332
|
+
function isSubscriptionActive(status) {
|
|
333
|
+
return status === "active" || status === "trialing";
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// src/client/common/auth/generate.ts
|
|
337
|
+
import { generatePrivateKey, privateKeyToAddress } from "viem/accounts";
|
|
338
|
+
function generateNewPrivateKey() {
|
|
339
|
+
const privateKey = generatePrivateKey();
|
|
340
|
+
const address = privateKeyToAddress(privateKey);
|
|
341
|
+
return {
|
|
342
|
+
privateKey,
|
|
343
|
+
address
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/client/common/utils/userapi.ts
|
|
348
|
+
import axios from "axios";
|
|
349
|
+
|
|
350
|
+
// src/client/common/utils/auth.ts
|
|
351
|
+
import { parseAbi } from "viem";
|
|
352
|
+
var APP_CONTROLLER_ABI = parseAbi([
|
|
353
|
+
"function calculateApiPermissionDigestHash(bytes4 permission, uint256 expiry) view returns (bytes32)"
|
|
354
|
+
]);
|
|
355
|
+
async function calculatePermissionSignature(options) {
|
|
356
|
+
const { permission, expiry, appControllerAddress, publicClient, walletClient } = options;
|
|
357
|
+
const digest = await publicClient.readContract({
|
|
358
|
+
address: appControllerAddress,
|
|
359
|
+
abi: APP_CONTROLLER_ABI,
|
|
360
|
+
functionName: "calculateApiPermissionDigestHash",
|
|
361
|
+
args: [permission, expiry]
|
|
362
|
+
});
|
|
363
|
+
const account = walletClient.account;
|
|
364
|
+
if (!account) {
|
|
365
|
+
throw new Error("WalletClient must have an account attached");
|
|
366
|
+
}
|
|
367
|
+
const signature = await walletClient.signMessage({
|
|
368
|
+
account,
|
|
369
|
+
message: { raw: digest }
|
|
370
|
+
});
|
|
371
|
+
return { signature, digest };
|
|
372
|
+
}
|
|
373
|
+
var generateBillingSigData = (product, expiry) => {
|
|
374
|
+
return {
|
|
375
|
+
domain: {
|
|
376
|
+
name: "EigenCloud Billing API",
|
|
377
|
+
version: "1"
|
|
378
|
+
},
|
|
379
|
+
types: {
|
|
380
|
+
BillingAuth: [
|
|
381
|
+
{ name: "product", type: "string" },
|
|
382
|
+
{ name: "expiry", type: "uint256" }
|
|
383
|
+
]
|
|
384
|
+
},
|
|
385
|
+
primaryType: "BillingAuth",
|
|
386
|
+
message: {
|
|
387
|
+
product,
|
|
388
|
+
expiry
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
async function calculateBillingAuthSignature(options) {
|
|
393
|
+
const { walletClient, product, expiry } = options;
|
|
394
|
+
const account = walletClient.account;
|
|
395
|
+
if (!account) {
|
|
396
|
+
throw new Error("WalletClient must have an account attached");
|
|
397
|
+
}
|
|
398
|
+
const signature = await walletClient.signTypedData({
|
|
399
|
+
account,
|
|
400
|
+
...generateBillingSigData(product, expiry)
|
|
401
|
+
});
|
|
402
|
+
return { signature, expiry };
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/client/common/auth/session.ts
|
|
406
|
+
var SessionError = class extends Error {
|
|
407
|
+
constructor(message, code, statusCode) {
|
|
408
|
+
super(message);
|
|
409
|
+
this.code = code;
|
|
410
|
+
this.statusCode = statusCode;
|
|
411
|
+
this.name = "SessionError";
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
function stripHexPrefix2(hex) {
|
|
415
|
+
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
416
|
+
}
|
|
417
|
+
async function parseErrorResponse(response) {
|
|
418
|
+
try {
|
|
419
|
+
const data = await response.json();
|
|
420
|
+
return data.error || response.statusText;
|
|
421
|
+
} catch {
|
|
422
|
+
return response.statusText;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
async function loginToComputeApi(config, request) {
|
|
426
|
+
let response;
|
|
427
|
+
try {
|
|
428
|
+
response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
|
|
429
|
+
method: "POST",
|
|
430
|
+
credentials: "include",
|
|
431
|
+
// Include cookies for session management
|
|
432
|
+
headers: {
|
|
433
|
+
"Content-Type": "application/json"
|
|
434
|
+
},
|
|
435
|
+
body: JSON.stringify({
|
|
436
|
+
message: request.message,
|
|
437
|
+
signature: stripHexPrefix2(request.signature)
|
|
438
|
+
})
|
|
439
|
+
});
|
|
440
|
+
} catch (error) {
|
|
441
|
+
throw new SessionError(
|
|
442
|
+
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
443
|
+
"NETWORK_ERROR"
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
if (!response.ok) {
|
|
447
|
+
const errorMessage = await parseErrorResponse(response);
|
|
448
|
+
const status = response.status;
|
|
449
|
+
if (status === 400) {
|
|
450
|
+
if (errorMessage.toLowerCase().includes("siwe")) {
|
|
451
|
+
throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
452
|
+
}
|
|
453
|
+
throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
|
|
454
|
+
}
|
|
455
|
+
if (status === 401) {
|
|
456
|
+
throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
|
|
457
|
+
}
|
|
458
|
+
throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
|
|
459
|
+
}
|
|
460
|
+
const data = await response.json();
|
|
461
|
+
return {
|
|
462
|
+
success: data.success,
|
|
463
|
+
address: data.address
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
async function getComputeApiSession(config) {
|
|
467
|
+
let response;
|
|
468
|
+
try {
|
|
469
|
+
response = await fetch(`${config.baseUrl}/auth/session`, {
|
|
470
|
+
method: "GET",
|
|
471
|
+
credentials: "include",
|
|
472
|
+
// Include cookies for session management
|
|
473
|
+
headers: {
|
|
474
|
+
"Content-Type": "application/json"
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
} catch {
|
|
478
|
+
return {
|
|
479
|
+
authenticated: false
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
if (response.status === 401) {
|
|
483
|
+
return {
|
|
484
|
+
authenticated: false
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
if (!response.ok) {
|
|
488
|
+
const errorMessage = await parseErrorResponse(response);
|
|
489
|
+
throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
|
|
490
|
+
}
|
|
491
|
+
const data = await response.json();
|
|
492
|
+
return {
|
|
493
|
+
authenticated: data.authenticated,
|
|
494
|
+
address: data.address,
|
|
495
|
+
chainId: data.chain_id
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
async function logoutFromComputeApi(config) {
|
|
499
|
+
let response;
|
|
500
|
+
try {
|
|
501
|
+
response = await fetch(`${config.baseUrl}/auth/logout`, {
|
|
502
|
+
method: "POST",
|
|
503
|
+
credentials: "include",
|
|
504
|
+
// Include cookies for session management
|
|
505
|
+
headers: {
|
|
506
|
+
"Content-Type": "application/json"
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
} catch (error) {
|
|
510
|
+
throw new SessionError(
|
|
511
|
+
`Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
|
|
512
|
+
"NETWORK_ERROR"
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
if (response.status === 401) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (!response.ok) {
|
|
519
|
+
const errorMessage = await parseErrorResponse(response);
|
|
520
|
+
throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
async function isSessionValid(config) {
|
|
524
|
+
const session = await getComputeApiSession(config);
|
|
525
|
+
return session.authenticated;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// src/client/common/utils/userapi.ts
|
|
529
|
+
function isJsonObject(value) {
|
|
530
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
531
|
+
}
|
|
532
|
+
function readString(obj, key) {
|
|
533
|
+
const v = obj[key];
|
|
534
|
+
return typeof v === "string" ? v : void 0;
|
|
535
|
+
}
|
|
536
|
+
function readNumber(obj, key) {
|
|
537
|
+
const v = obj[key];
|
|
538
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
539
|
+
}
|
|
540
|
+
var MAX_ADDRESS_COUNT = 5;
|
|
541
|
+
var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
542
|
+
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
543
|
+
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
544
|
+
function getDefaultClientId() {
|
|
545
|
+
const version = true ? "0.2.2-dev" : "0.0.0";
|
|
546
|
+
return `ecloud-sdk/v${version}`;
|
|
547
|
+
}
|
|
548
|
+
var UserApiClient = class {
|
|
549
|
+
constructor(config, walletClient, publicClient, options) {
|
|
550
|
+
this.config = config;
|
|
551
|
+
this.walletClient = walletClient;
|
|
552
|
+
this.publicClient = publicClient;
|
|
553
|
+
this.clientId = options?.clientId || getDefaultClientId();
|
|
554
|
+
this.useSession = options?.useSession ?? false;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Get the address of the connected wallet
|
|
558
|
+
*/
|
|
559
|
+
get address() {
|
|
560
|
+
const account = this.walletClient.account;
|
|
561
|
+
if (!account) {
|
|
562
|
+
throw new Error("WalletClient must have an account attached");
|
|
563
|
+
}
|
|
564
|
+
return account.address;
|
|
565
|
+
}
|
|
566
|
+
async getInfos(appIDs, addressCount = 1) {
|
|
567
|
+
const count = Math.min(addressCount, MAX_ADDRESS_COUNT);
|
|
568
|
+
const endpoint = `${this.config.userApiServerURL}/info`;
|
|
569
|
+
const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(",") })}`;
|
|
570
|
+
const res = await this.makeAuthenticatedRequest(url, CanViewSensitiveAppInfoPermission);
|
|
571
|
+
const result = await res.json();
|
|
572
|
+
return result.apps.map((app, i) => {
|
|
573
|
+
const evmAddresses = app.addresses?.data?.evmAddresses?.slice(0, count) || [];
|
|
574
|
+
const solanaAddresses = app.addresses?.data?.solanaAddresses?.slice(0, count) || [];
|
|
575
|
+
return {
|
|
576
|
+
address: appIDs[i],
|
|
577
|
+
status: app.app_status,
|
|
578
|
+
ip: app.ip,
|
|
579
|
+
machineType: app.machine_type,
|
|
580
|
+
profile: app.profile,
|
|
581
|
+
metrics: app.metrics,
|
|
582
|
+
evmAddresses,
|
|
583
|
+
solanaAddresses
|
|
584
|
+
};
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Get app details from UserAPI (includes releases and build/provenance info when available).
|
|
589
|
+
*
|
|
590
|
+
* Endpoint: GET /apps/:appAddress
|
|
591
|
+
*/
|
|
592
|
+
async getApp(appAddress) {
|
|
593
|
+
const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}`;
|
|
594
|
+
const res = await this.makeAuthenticatedRequest(endpoint);
|
|
595
|
+
const raw = await res.json();
|
|
596
|
+
if (!isJsonObject(raw)) {
|
|
597
|
+
throw new Error("Unexpected /apps/:id response: expected object");
|
|
598
|
+
}
|
|
599
|
+
const id = readString(raw, "id");
|
|
600
|
+
if (!id) {
|
|
601
|
+
throw new Error("Unexpected /apps/:id response: missing 'id'");
|
|
602
|
+
}
|
|
603
|
+
const releasesRaw = raw.releases;
|
|
604
|
+
const releases = Array.isArray(releasesRaw) ? releasesRaw.map((r) => transformAppRelease(r)).filter((r) => !!r) : [];
|
|
605
|
+
return {
|
|
606
|
+
id,
|
|
607
|
+
creator: readString(raw, "creator"),
|
|
608
|
+
contractStatus: readString(raw, "contract_status") ?? readString(raw, "contractStatus"),
|
|
609
|
+
releases
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Get available SKUs (instance types) from UserAPI
|
|
614
|
+
*/
|
|
615
|
+
async getSKUs() {
|
|
616
|
+
const endpoint = `${this.config.userApiServerURL}/skus`;
|
|
617
|
+
const response = await this.makeAuthenticatedRequest(endpoint);
|
|
618
|
+
const result = await response.json();
|
|
619
|
+
return {
|
|
620
|
+
skus: result.skus || result.SKUs || []
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Get logs for an app
|
|
625
|
+
*/
|
|
626
|
+
async getLogs(appID) {
|
|
627
|
+
const endpoint = `${this.config.userApiServerURL}/logs/${appID}`;
|
|
628
|
+
const response = await this.makeAuthenticatedRequest(endpoint, CanViewAppLogsPermission);
|
|
629
|
+
return await response.text();
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Get statuses for apps
|
|
633
|
+
*/
|
|
634
|
+
async getStatuses(appIDs) {
|
|
635
|
+
const endpoint = `${this.config.userApiServerURL}/status`;
|
|
636
|
+
const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(",") })}`;
|
|
637
|
+
const response = await this.makeAuthenticatedRequest(url);
|
|
638
|
+
const result = await response.json();
|
|
639
|
+
const apps = result.apps || result.Apps || [];
|
|
640
|
+
return apps.map((app, i) => ({
|
|
641
|
+
address: app.address || appIDs[i],
|
|
642
|
+
status: app.app_status || app.App_Status || ""
|
|
643
|
+
}));
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Upload app profile information with optional image
|
|
647
|
+
*
|
|
648
|
+
* @param appAddress - The app's contract address
|
|
649
|
+
* @param name - Display name for the app
|
|
650
|
+
* @param options - Optional fields including website, description, xURL, and image
|
|
651
|
+
* @param options.image - Image file as Blob or File (browser: from input element, Node.js: new Blob([buffer]))
|
|
652
|
+
* @param options.imageName - Filename for the image (required if image is provided)
|
|
653
|
+
*/
|
|
654
|
+
async uploadAppProfile(appAddress, name, options) {
|
|
655
|
+
const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}/profile`;
|
|
656
|
+
const formData = new FormData();
|
|
657
|
+
formData.append("name", name);
|
|
658
|
+
if (options?.website) {
|
|
659
|
+
formData.append("website", options.website);
|
|
660
|
+
}
|
|
661
|
+
if (options?.description) {
|
|
662
|
+
formData.append("description", options.description);
|
|
663
|
+
}
|
|
664
|
+
if (options?.xURL) {
|
|
665
|
+
formData.append("xURL", options.xURL);
|
|
666
|
+
}
|
|
667
|
+
if (options?.image) {
|
|
668
|
+
const fileName = options.image instanceof File ? options.image.name : options.imageName || "image";
|
|
669
|
+
formData.append("image", options.image, fileName);
|
|
670
|
+
}
|
|
671
|
+
const headers = {
|
|
672
|
+
"x-client-id": this.clientId
|
|
673
|
+
};
|
|
674
|
+
if (!this.useSession) {
|
|
675
|
+
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
|
|
676
|
+
const authHeaders = await this.generateAuthHeaders(CanUpdateAppProfilePermission, expiry);
|
|
677
|
+
Object.assign(headers, authHeaders);
|
|
678
|
+
}
|
|
679
|
+
try {
|
|
680
|
+
const response = await axios.post(endpoint, formData, {
|
|
681
|
+
headers,
|
|
682
|
+
maxRedirects: 0,
|
|
683
|
+
validateStatus: () => true,
|
|
684
|
+
// Don't throw on any status
|
|
685
|
+
maxContentLength: Infinity,
|
|
686
|
+
// Allow large file uploads
|
|
687
|
+
maxBodyLength: Infinity,
|
|
688
|
+
// Allow large file uploads
|
|
689
|
+
withCredentials: true
|
|
690
|
+
// Include cookies for session auth
|
|
691
|
+
});
|
|
692
|
+
const status = response.status;
|
|
693
|
+
if (status !== 200 && status !== 201) {
|
|
694
|
+
const body = typeof response.data === "string" ? response.data : JSON.stringify(response.data);
|
|
695
|
+
if (status === 403 && body.includes("Cloudflare") && body.includes("challenge-platform")) {
|
|
696
|
+
throw new Error(
|
|
697
|
+
`Cloudflare protection is blocking the request. This is likely due to bot detection.
|
|
698
|
+
Status: ${status}`
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
throw new Error(
|
|
702
|
+
`UserAPI request failed: ${status} ${status >= 200 && status < 300 ? "OK" : "Error"} - ${body.substring(0, 500)}${body.length > 500 ? "..." : ""}`
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
return response.data;
|
|
706
|
+
} catch (error) {
|
|
707
|
+
if (error.message?.includes("fetch failed") || error.message?.includes("ECONNREFUSED") || error.message?.includes("ENOTFOUND") || error.cause) {
|
|
708
|
+
const cause = error.cause?.message || error.cause || error.message;
|
|
709
|
+
throw new Error(
|
|
710
|
+
`Failed to connect to UserAPI at ${endpoint}: ${cause}
|
|
711
|
+
Please check:
|
|
712
|
+
1. Your internet connection
|
|
713
|
+
2. The API server is accessible: ${this.config.userApiServerURL}
|
|
714
|
+
3. Firewall/proxy settings`
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
throw error;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
async makeAuthenticatedRequest(url, permission) {
|
|
721
|
+
const headers = {
|
|
722
|
+
"x-client-id": this.clientId
|
|
723
|
+
};
|
|
724
|
+
if (permission && !this.useSession) {
|
|
725
|
+
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
|
|
726
|
+
const authHeaders = await this.generateAuthHeaders(permission, expiry);
|
|
727
|
+
Object.assign(headers, authHeaders);
|
|
728
|
+
}
|
|
729
|
+
try {
|
|
730
|
+
const response = await axios.get(url, {
|
|
731
|
+
headers,
|
|
732
|
+
maxRedirects: 0,
|
|
733
|
+
validateStatus: () => true,
|
|
734
|
+
// Don't throw on any status
|
|
735
|
+
withCredentials: true
|
|
736
|
+
// Include cookies for session auth
|
|
737
|
+
});
|
|
738
|
+
const status = response.status;
|
|
739
|
+
const statusText = status >= 200 && status < 300 ? "OK" : "Error";
|
|
740
|
+
if (status < 200 || status >= 300) {
|
|
741
|
+
const body = typeof response.data === "string" ? response.data : JSON.stringify(response.data);
|
|
742
|
+
throw new Error(`UserAPI request failed: ${status} ${statusText} - ${body}`);
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
json: async () => response.data,
|
|
746
|
+
text: async () => typeof response.data === "string" ? response.data : JSON.stringify(response.data)
|
|
747
|
+
};
|
|
748
|
+
} catch (error) {
|
|
749
|
+
if (error.message?.includes("fetch failed") || error.message?.includes("ECONNREFUSED") || error.message?.includes("ENOTFOUND") || error.cause) {
|
|
750
|
+
const cause = error.cause?.message || error.cause || error.message;
|
|
751
|
+
throw new Error(
|
|
752
|
+
`Failed to connect to UserAPI at ${url}: ${cause}
|
|
753
|
+
Please check:
|
|
754
|
+
1. Your internet connection
|
|
755
|
+
2. The API server is accessible: ${this.config.userApiServerURL}
|
|
756
|
+
3. Firewall/proxy settings`
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
throw error;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Generate authentication headers for UserAPI requests
|
|
764
|
+
*/
|
|
765
|
+
async generateAuthHeaders(permission, expiry) {
|
|
766
|
+
const { signature } = await calculatePermissionSignature({
|
|
767
|
+
permission,
|
|
768
|
+
expiry,
|
|
769
|
+
appControllerAddress: this.config.appControllerAddress,
|
|
770
|
+
publicClient: this.publicClient,
|
|
771
|
+
walletClient: this.walletClient
|
|
772
|
+
});
|
|
773
|
+
return {
|
|
774
|
+
Authorization: `Bearer ${stripHexPrefix(signature)}`,
|
|
775
|
+
"X-eigenx-expiry": expiry.toString()
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
// ==========================================================================
|
|
779
|
+
// SIWE Session Management
|
|
780
|
+
// ==========================================================================
|
|
781
|
+
/**
|
|
782
|
+
* Login to the compute API using SIWE (Sign-In with Ethereum)
|
|
783
|
+
*
|
|
784
|
+
* This establishes a session with the compute API by verifying the SIWE message
|
|
785
|
+
* and signature. On success, a session cookie is set in the browser.
|
|
786
|
+
*
|
|
787
|
+
* @param request - Login request containing SIWE message and signature
|
|
788
|
+
* @returns Login result with the authenticated address
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* ```typescript
|
|
792
|
+
* import { createSiweMessage } from "@layr-labs/ecloud-sdk/browser";
|
|
793
|
+
*
|
|
794
|
+
* const { message } = createSiweMessage({
|
|
795
|
+
* address: userAddress,
|
|
796
|
+
* chainId: 11155111,
|
|
797
|
+
* domain: window.location.host,
|
|
798
|
+
* uri: window.location.origin,
|
|
799
|
+
* });
|
|
800
|
+
*
|
|
801
|
+
* const signature = await signMessageAsync({ message });
|
|
802
|
+
* const result = await client.siweLogin({ message, signature });
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
async siweLogin(request) {
|
|
806
|
+
return loginToComputeApi({ baseUrl: this.config.userApiServerURL }, request);
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Logout from the compute API
|
|
810
|
+
*
|
|
811
|
+
* This destroys the current session and clears the session cookie.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```typescript
|
|
815
|
+
* await client.siweLogout();
|
|
816
|
+
* ```
|
|
817
|
+
*/
|
|
818
|
+
async siweLogout() {
|
|
819
|
+
return logoutFromComputeApi({ baseUrl: this.config.userApiServerURL });
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Get the current SIWE session status from the compute API
|
|
823
|
+
*
|
|
824
|
+
* @returns Session information including authentication status and address
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* ```typescript
|
|
828
|
+
* const session = await client.getSiweSession();
|
|
829
|
+
* if (session.authenticated) {
|
|
830
|
+
* console.log(`Logged in as ${session.address}`);
|
|
831
|
+
* }
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
async getSiweSession() {
|
|
835
|
+
return getComputeApiSession({ baseUrl: this.config.userApiServerURL });
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
function transformAppReleaseBuild(raw) {
|
|
839
|
+
if (!isJsonObject(raw)) return void 0;
|
|
840
|
+
const depsRaw = raw.dependencies;
|
|
841
|
+
const deps = isJsonObject(depsRaw) ? Object.fromEntries(
|
|
842
|
+
Object.entries(depsRaw).flatMap(([digest, depRaw]) => {
|
|
843
|
+
const parsed = transformAppReleaseBuild(depRaw);
|
|
844
|
+
return parsed ? [[digest, parsed]] : [];
|
|
845
|
+
})
|
|
846
|
+
) : void 0;
|
|
847
|
+
return {
|
|
848
|
+
buildId: readString(raw, "build_id") ?? readString(raw, "buildId"),
|
|
849
|
+
billingAddress: readString(raw, "billing_address") ?? readString(raw, "billingAddress"),
|
|
850
|
+
repoUrl: readString(raw, "repo_url") ?? readString(raw, "repoUrl"),
|
|
851
|
+
gitRef: readString(raw, "git_ref") ?? readString(raw, "gitRef"),
|
|
852
|
+
status: readString(raw, "status"),
|
|
853
|
+
buildType: readString(raw, "build_type") ?? readString(raw, "buildType"),
|
|
854
|
+
imageName: readString(raw, "image_name") ?? readString(raw, "imageName"),
|
|
855
|
+
imageDigest: readString(raw, "image_digest") ?? readString(raw, "imageDigest"),
|
|
856
|
+
imageUrl: readString(raw, "image_url") ?? readString(raw, "imageUrl"),
|
|
857
|
+
provenanceJson: raw.provenance_json ?? raw.provenanceJson,
|
|
858
|
+
provenanceSignature: readString(raw, "provenance_signature") ?? readString(raw, "provenanceSignature"),
|
|
859
|
+
createdAt: readString(raw, "created_at") ?? readString(raw, "createdAt"),
|
|
860
|
+
updatedAt: readString(raw, "updated_at") ?? readString(raw, "updatedAt"),
|
|
861
|
+
errorMessage: readString(raw, "error_message") ?? readString(raw, "errorMessage"),
|
|
862
|
+
dependencies: deps
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
function transformAppRelease(raw) {
|
|
866
|
+
if (!isJsonObject(raw)) return void 0;
|
|
867
|
+
return {
|
|
868
|
+
appId: readString(raw, "appId") ?? readString(raw, "app_id"),
|
|
869
|
+
rmsReleaseId: readString(raw, "rmsReleaseId") ?? readString(raw, "rms_release_id"),
|
|
870
|
+
imageDigest: readString(raw, "imageDigest") ?? readString(raw, "image_digest"),
|
|
871
|
+
registryUrl: readString(raw, "registryUrl") ?? readString(raw, "registry_url"),
|
|
872
|
+
publicEnv: readString(raw, "publicEnv") ?? readString(raw, "public_env"),
|
|
873
|
+
encryptedEnv: readString(raw, "encryptedEnv") ?? readString(raw, "encrypted_env"),
|
|
874
|
+
upgradeByTime: readNumber(raw, "upgradeByTime") ?? readNumber(raw, "upgrade_by_time"),
|
|
875
|
+
createdAt: readString(raw, "createdAt") ?? readString(raw, "created_at"),
|
|
876
|
+
createdAtBlock: readString(raw, "createdAtBlock") ?? readString(raw, "created_at_block"),
|
|
877
|
+
build: raw.build ? transformAppReleaseBuild(raw.build) : void 0
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// src/client/common/utils/billingapi.ts
|
|
882
|
+
import axios2 from "axios";
|
|
883
|
+
var BillingApiClient = class {
|
|
884
|
+
constructor(config, walletClient) {
|
|
885
|
+
this.config = config;
|
|
886
|
+
this.walletClient = walletClient;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Get the address of the connected wallet
|
|
890
|
+
*/
|
|
891
|
+
get address() {
|
|
892
|
+
const account = this.walletClient.account;
|
|
893
|
+
if (!account) {
|
|
894
|
+
throw new Error("WalletClient must have an account attached");
|
|
895
|
+
}
|
|
896
|
+
return account.address;
|
|
897
|
+
}
|
|
898
|
+
async createSubscription(productId = "compute", options) {
|
|
899
|
+
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
900
|
+
const body = options ? {
|
|
901
|
+
success_url: options.successUrl,
|
|
902
|
+
cancel_url: options.cancelUrl
|
|
903
|
+
} : void 0;
|
|
904
|
+
const resp = await this.makeAuthenticatedRequest(endpoint, "POST", productId, body);
|
|
905
|
+
return resp.json();
|
|
906
|
+
}
|
|
907
|
+
async getSubscription(productId = "compute") {
|
|
908
|
+
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
909
|
+
const resp = await this.makeAuthenticatedRequest(endpoint, "GET", productId);
|
|
910
|
+
return resp.json();
|
|
911
|
+
}
|
|
912
|
+
async cancelSubscription(productId = "compute") {
|
|
913
|
+
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
914
|
+
await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Make an authenticated request to the billing API
|
|
918
|
+
*/
|
|
919
|
+
async makeAuthenticatedRequest(url, method, productId, body) {
|
|
920
|
+
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
|
|
921
|
+
const { signature } = await calculateBillingAuthSignature({
|
|
922
|
+
walletClient: this.walletClient,
|
|
923
|
+
product: productId,
|
|
924
|
+
expiry
|
|
925
|
+
});
|
|
926
|
+
const headers = {
|
|
927
|
+
Authorization: `Bearer ${signature}`,
|
|
928
|
+
"X-Account": this.address,
|
|
929
|
+
"X-Expiry": expiry.toString()
|
|
930
|
+
};
|
|
931
|
+
if (body) {
|
|
932
|
+
headers["Content-Type"] = "application/json";
|
|
933
|
+
}
|
|
934
|
+
try {
|
|
935
|
+
const response = await axios2({
|
|
936
|
+
method,
|
|
937
|
+
url,
|
|
938
|
+
headers,
|
|
939
|
+
data: body,
|
|
940
|
+
timeout: 3e4,
|
|
941
|
+
maxRedirects: 0,
|
|
942
|
+
validateStatus: () => true
|
|
943
|
+
// Don't throw on any status
|
|
944
|
+
});
|
|
945
|
+
const status = response.status;
|
|
946
|
+
const statusText = status >= 200 && status < 300 ? "OK" : "Error";
|
|
947
|
+
if (status < 200 || status >= 300) {
|
|
948
|
+
const body2 = typeof response.data === "string" ? response.data : JSON.stringify(response.data);
|
|
949
|
+
throw new Error(`BillingAPI request failed: ${status} ${statusText} - ${body2}`);
|
|
950
|
+
}
|
|
951
|
+
return {
|
|
952
|
+
json: async () => response.data,
|
|
953
|
+
text: async () => typeof response.data === "string" ? response.data : JSON.stringify(response.data)
|
|
954
|
+
};
|
|
955
|
+
} catch (error) {
|
|
956
|
+
if (error.message?.includes("fetch failed") || error.message?.includes("ECONNREFUSED") || error.message?.includes("ENOTFOUND") || error.cause) {
|
|
957
|
+
const cause = error.cause?.message || error.cause || error.message;
|
|
958
|
+
throw new Error(
|
|
959
|
+
`Failed to connect to BillingAPI at ${url}: ${cause}
|
|
960
|
+
Please check:
|
|
961
|
+
1. Your internet connection
|
|
962
|
+
2. The API server is accessible: ${this.config.billingApiServerURL}
|
|
963
|
+
3. Firewall/proxy settings`
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
throw error;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
// src/client/common/utils/buildapi.ts
|
|
972
|
+
import axios3 from "axios";
|
|
973
|
+
var MAX_RETRIES = 5;
|
|
974
|
+
var INITIAL_BACKOFF_MS = 1e3;
|
|
975
|
+
var MAX_BACKOFF_MS = 3e4;
|
|
976
|
+
async function sleep(ms) {
|
|
977
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
978
|
+
}
|
|
979
|
+
function getRetryDelay(res, attempt) {
|
|
980
|
+
const retryAfter = res.headers["retry-after"];
|
|
981
|
+
if (retryAfter) {
|
|
982
|
+
const seconds = parseInt(retryAfter, 10);
|
|
983
|
+
if (!isNaN(seconds)) {
|
|
984
|
+
return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
|
|
988
|
+
}
|
|
989
|
+
async function requestWithRetry(config) {
|
|
990
|
+
let lastResponse;
|
|
991
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
992
|
+
const res = await axios3({ ...config, validateStatus: () => true });
|
|
993
|
+
lastResponse = res;
|
|
994
|
+
if (res.status !== 429) {
|
|
995
|
+
return res;
|
|
996
|
+
}
|
|
997
|
+
if (attempt < MAX_RETRIES) {
|
|
998
|
+
const delay = getRetryDelay(res, attempt);
|
|
999
|
+
await sleep(delay);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return lastResponse;
|
|
1003
|
+
}
|
|
1004
|
+
var BuildApiClient = class {
|
|
1005
|
+
constructor(options) {
|
|
1006
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
1007
|
+
this.clientId = options.clientId;
|
|
1008
|
+
this.walletClient = options.walletClient;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Get the address of the connected wallet
|
|
1012
|
+
*/
|
|
1013
|
+
get address() {
|
|
1014
|
+
const account = this.walletClient?.account;
|
|
1015
|
+
if (!account) {
|
|
1016
|
+
throw new Error("WalletClient must have an account attached");
|
|
1017
|
+
}
|
|
1018
|
+
return account.address;
|
|
1019
|
+
}
|
|
1020
|
+
async submitBuild(payload) {
|
|
1021
|
+
return this.authenticatedJsonRequest("/builds", "POST", payload);
|
|
1022
|
+
}
|
|
1023
|
+
async getBuild(buildId) {
|
|
1024
|
+
return this.publicJsonRequest(`/builds/${encodeURIComponent(buildId)}`);
|
|
1025
|
+
}
|
|
1026
|
+
async getBuildByDigest(digest) {
|
|
1027
|
+
return this.publicJsonRequest(`/builds/image/${encodeURIComponent(digest)}`);
|
|
1028
|
+
}
|
|
1029
|
+
async verify(identifier) {
|
|
1030
|
+
return this.publicJsonRequest(`/builds/verify/${encodeURIComponent(identifier)}`);
|
|
1031
|
+
}
|
|
1032
|
+
async getLogs(buildId) {
|
|
1033
|
+
return this.authenticatedTextRequest(`/builds/${encodeURIComponent(buildId)}/logs`);
|
|
1034
|
+
}
|
|
1035
|
+
async listBuilds(params) {
|
|
1036
|
+
const res = await requestWithRetry({
|
|
1037
|
+
url: `${this.baseUrl}/builds`,
|
|
1038
|
+
method: "GET",
|
|
1039
|
+
params,
|
|
1040
|
+
headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
|
|
1041
|
+
timeout: 6e4
|
|
1042
|
+
});
|
|
1043
|
+
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1044
|
+
return res.data;
|
|
1045
|
+
}
|
|
1046
|
+
async publicJsonRequest(path) {
|
|
1047
|
+
const res = await requestWithRetry({
|
|
1048
|
+
url: `${this.baseUrl}${path}`,
|
|
1049
|
+
method: "GET",
|
|
1050
|
+
headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
|
|
1051
|
+
timeout: 6e4
|
|
1052
|
+
});
|
|
1053
|
+
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1054
|
+
return res.data;
|
|
1055
|
+
}
|
|
1056
|
+
async authenticatedJsonRequest(path, method, body) {
|
|
1057
|
+
if (!this.walletClient?.account) {
|
|
1058
|
+
throw new Error("WalletClient with account required for authenticated requests");
|
|
1059
|
+
}
|
|
1060
|
+
const headers = {
|
|
1061
|
+
"Content-Type": "application/json"
|
|
1062
|
+
};
|
|
1063
|
+
if (this.clientId) headers["x-client-id"] = this.clientId;
|
|
1064
|
+
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
|
|
1065
|
+
const { signature } = await calculateBillingAuthSignature({
|
|
1066
|
+
walletClient: this.walletClient,
|
|
1067
|
+
product: "compute",
|
|
1068
|
+
expiry
|
|
1069
|
+
});
|
|
1070
|
+
headers.Authorization = `Bearer ${signature}`;
|
|
1071
|
+
headers["X-eigenx-expiry"] = expiry.toString();
|
|
1072
|
+
headers["X-Account"] = this.address;
|
|
1073
|
+
const res = await requestWithRetry({
|
|
1074
|
+
url: `${this.baseUrl}${path}`,
|
|
1075
|
+
method,
|
|
1076
|
+
headers,
|
|
1077
|
+
data: body,
|
|
1078
|
+
timeout: 6e4
|
|
1079
|
+
});
|
|
1080
|
+
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1081
|
+
return res.data;
|
|
1082
|
+
}
|
|
1083
|
+
async authenticatedTextRequest(path) {
|
|
1084
|
+
if (!this.walletClient?.account) {
|
|
1085
|
+
throw new Error("WalletClient with account required for authenticated requests");
|
|
1086
|
+
}
|
|
1087
|
+
const headers = {};
|
|
1088
|
+
if (this.clientId) headers["x-client-id"] = this.clientId;
|
|
1089
|
+
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
|
|
1090
|
+
const { signature } = await calculateBillingAuthSignature({
|
|
1091
|
+
walletClient: this.walletClient,
|
|
1092
|
+
product: "compute",
|
|
1093
|
+
expiry
|
|
1094
|
+
});
|
|
1095
|
+
headers.Authorization = `Bearer ${signature}`;
|
|
1096
|
+
headers["X-eigenx-expiry"] = expiry.toString();
|
|
1097
|
+
headers["X-Account"] = this.address;
|
|
1098
|
+
const res = await requestWithRetry({
|
|
1099
|
+
url: `${this.baseUrl}${path}`,
|
|
1100
|
+
method: "GET",
|
|
1101
|
+
headers,
|
|
1102
|
+
timeout: 6e4,
|
|
1103
|
+
responseType: "text"
|
|
1104
|
+
});
|
|
1105
|
+
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
1106
|
+
return typeof res.data === "string" ? res.data : JSON.stringify(res.data);
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
function buildApiHttpError(res) {
|
|
1110
|
+
const status = res.status;
|
|
1111
|
+
const body = typeof res.data === "string" ? res.data : res.data ? JSON.stringify(res.data) : "";
|
|
1112
|
+
const url = res.config?.url ? ` ${res.config.url}` : "";
|
|
1113
|
+
return new Error(`BuildAPI request failed: ${status}${url} - ${body || "Unknown error"}`);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
// src/client/common/contract/eip7702.ts
|
|
1117
|
+
import { encodeFunctionData, encodeAbiParameters, decodeErrorResult } from "viem";
|
|
1118
|
+
|
|
1119
|
+
// src/client/common/abis/ERC7702Delegator.json
|
|
1120
|
+
var ERC7702Delegator_default = [
|
|
1121
|
+
{
|
|
1122
|
+
type: "constructor",
|
|
1123
|
+
inputs: [
|
|
1124
|
+
{
|
|
1125
|
+
name: "_delegationManager",
|
|
1126
|
+
type: "address",
|
|
1127
|
+
internalType: "contractIDelegationManager"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
name: "_entryPoint",
|
|
1131
|
+
type: "address",
|
|
1132
|
+
internalType: "contractIEntryPoint"
|
|
1133
|
+
}
|
|
1134
|
+
],
|
|
1135
|
+
stateMutability: "nonpayable"
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
type: "receive",
|
|
1139
|
+
stateMutability: "payable"
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
type: "function",
|
|
1143
|
+
name: "DOMAIN_VERSION",
|
|
1144
|
+
inputs: [],
|
|
1145
|
+
outputs: [
|
|
1146
|
+
{
|
|
1147
|
+
name: "",
|
|
1148
|
+
type: "string",
|
|
1149
|
+
internalType: "string"
|
|
1150
|
+
}
|
|
1151
|
+
],
|
|
1152
|
+
stateMutability: "view"
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
type: "function",
|
|
1156
|
+
name: "NAME",
|
|
1157
|
+
inputs: [],
|
|
1158
|
+
outputs: [
|
|
1159
|
+
{
|
|
1160
|
+
name: "",
|
|
1161
|
+
type: "string",
|
|
1162
|
+
internalType: "string"
|
|
1163
|
+
}
|
|
1164
|
+
],
|
|
1165
|
+
stateMutability: "view"
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
type: "function",
|
|
1169
|
+
name: "PACKED_USER_OP_TYPEHASH",
|
|
1170
|
+
inputs: [],
|
|
1171
|
+
outputs: [
|
|
1172
|
+
{
|
|
1173
|
+
name: "",
|
|
1174
|
+
type: "bytes32",
|
|
1175
|
+
internalType: "bytes32"
|
|
1176
|
+
}
|
|
1177
|
+
],
|
|
1178
|
+
stateMutability: "view"
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
type: "function",
|
|
1182
|
+
name: "VERSION",
|
|
1183
|
+
inputs: [],
|
|
1184
|
+
outputs: [
|
|
1185
|
+
{
|
|
1186
|
+
name: "",
|
|
1187
|
+
type: "string",
|
|
1188
|
+
internalType: "string"
|
|
1189
|
+
}
|
|
1190
|
+
],
|
|
1191
|
+
stateMutability: "view"
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
type: "function",
|
|
1195
|
+
name: "addDeposit",
|
|
1196
|
+
inputs: [],
|
|
1197
|
+
outputs: [],
|
|
1198
|
+
stateMutability: "payable"
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
type: "function",
|
|
1202
|
+
name: "delegationManager",
|
|
1203
|
+
inputs: [],
|
|
1204
|
+
outputs: [
|
|
1205
|
+
{
|
|
1206
|
+
name: "",
|
|
1207
|
+
type: "address",
|
|
1208
|
+
internalType: "contractIDelegationManager"
|
|
1209
|
+
}
|
|
1210
|
+
],
|
|
1211
|
+
stateMutability: "view"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
type: "function",
|
|
1215
|
+
name: "disableDelegation",
|
|
1216
|
+
inputs: [
|
|
1217
|
+
{
|
|
1218
|
+
name: "_delegation",
|
|
1219
|
+
type: "tuple",
|
|
1220
|
+
internalType: "structDelegation",
|
|
1221
|
+
components: [
|
|
1222
|
+
{
|
|
1223
|
+
name: "delegate",
|
|
1224
|
+
type: "address",
|
|
1225
|
+
internalType: "address"
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
name: "delegator",
|
|
1229
|
+
type: "address",
|
|
1230
|
+
internalType: "address"
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
name: "authority",
|
|
1234
|
+
type: "bytes32",
|
|
1235
|
+
internalType: "bytes32"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
name: "caveats",
|
|
1239
|
+
type: "tuple[]",
|
|
1240
|
+
internalType: "structCaveat[]",
|
|
1241
|
+
components: [
|
|
1242
|
+
{
|
|
1243
|
+
name: "enforcer",
|
|
1244
|
+
type: "address",
|
|
1245
|
+
internalType: "address"
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
name: "terms",
|
|
1249
|
+
type: "bytes",
|
|
1250
|
+
internalType: "bytes"
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
name: "args",
|
|
1254
|
+
type: "bytes",
|
|
1255
|
+
internalType: "bytes"
|
|
1256
|
+
}
|
|
1257
|
+
]
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: "salt",
|
|
1261
|
+
type: "uint256",
|
|
1262
|
+
internalType: "uint256"
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
name: "signature",
|
|
1266
|
+
type: "bytes",
|
|
1267
|
+
internalType: "bytes"
|
|
1268
|
+
}
|
|
1269
|
+
]
|
|
1270
|
+
}
|
|
1271
|
+
],
|
|
1272
|
+
outputs: [],
|
|
1273
|
+
stateMutability: "nonpayable"
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
type: "function",
|
|
1277
|
+
name: "eip712Domain",
|
|
1278
|
+
inputs: [],
|
|
1279
|
+
outputs: [
|
|
1280
|
+
{
|
|
1281
|
+
name: "fields",
|
|
1282
|
+
type: "bytes1",
|
|
1283
|
+
internalType: "bytes1"
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
name: "name",
|
|
1287
|
+
type: "string",
|
|
1288
|
+
internalType: "string"
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
name: "version",
|
|
1292
|
+
type: "string",
|
|
1293
|
+
internalType: "string"
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
name: "chainId",
|
|
1297
|
+
type: "uint256",
|
|
1298
|
+
internalType: "uint256"
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
name: "verifyingContract",
|
|
1302
|
+
type: "address",
|
|
1303
|
+
internalType: "address"
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
name: "salt",
|
|
1307
|
+
type: "bytes32",
|
|
1308
|
+
internalType: "bytes32"
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
name: "extensions",
|
|
1312
|
+
type: "uint256[]",
|
|
1313
|
+
internalType: "uint256[]"
|
|
1314
|
+
}
|
|
1315
|
+
],
|
|
1316
|
+
stateMutability: "view"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
type: "function",
|
|
1320
|
+
name: "enableDelegation",
|
|
1321
|
+
inputs: [
|
|
1322
|
+
{
|
|
1323
|
+
name: "_delegation",
|
|
1324
|
+
type: "tuple",
|
|
1325
|
+
internalType: "structDelegation",
|
|
1326
|
+
components: [
|
|
1327
|
+
{
|
|
1328
|
+
name: "delegate",
|
|
1329
|
+
type: "address",
|
|
1330
|
+
internalType: "address"
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
name: "delegator",
|
|
1334
|
+
type: "address",
|
|
1335
|
+
internalType: "address"
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
name: "authority",
|
|
1339
|
+
type: "bytes32",
|
|
1340
|
+
internalType: "bytes32"
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
name: "caveats",
|
|
1344
|
+
type: "tuple[]",
|
|
1345
|
+
internalType: "structCaveat[]",
|
|
1346
|
+
components: [
|
|
1347
|
+
{
|
|
1348
|
+
name: "enforcer",
|
|
1349
|
+
type: "address",
|
|
1350
|
+
internalType: "address"
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
name: "terms",
|
|
1354
|
+
type: "bytes",
|
|
1355
|
+
internalType: "bytes"
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
name: "args",
|
|
1359
|
+
type: "bytes",
|
|
1360
|
+
internalType: "bytes"
|
|
1361
|
+
}
|
|
1362
|
+
]
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
name: "salt",
|
|
1366
|
+
type: "uint256",
|
|
1367
|
+
internalType: "uint256"
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
name: "signature",
|
|
1371
|
+
type: "bytes",
|
|
1372
|
+
internalType: "bytes"
|
|
1373
|
+
}
|
|
1374
|
+
]
|
|
1375
|
+
}
|
|
1376
|
+
],
|
|
1377
|
+
outputs: [],
|
|
1378
|
+
stateMutability: "nonpayable"
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
type: "function",
|
|
1382
|
+
name: "entryPoint",
|
|
1383
|
+
inputs: [],
|
|
1384
|
+
outputs: [
|
|
1385
|
+
{
|
|
1386
|
+
name: "",
|
|
1387
|
+
type: "address",
|
|
1388
|
+
internalType: "contractIEntryPoint"
|
|
1389
|
+
}
|
|
1390
|
+
],
|
|
1391
|
+
stateMutability: "view"
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
type: "function",
|
|
1395
|
+
name: "execute",
|
|
1396
|
+
inputs: [
|
|
1397
|
+
{
|
|
1398
|
+
name: "_execution",
|
|
1399
|
+
type: "tuple",
|
|
1400
|
+
internalType: "structExecution",
|
|
1401
|
+
components: [
|
|
1402
|
+
{
|
|
1403
|
+
name: "target",
|
|
1404
|
+
type: "address",
|
|
1405
|
+
internalType: "address"
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
name: "value",
|
|
1409
|
+
type: "uint256",
|
|
1410
|
+
internalType: "uint256"
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
name: "callData",
|
|
1414
|
+
type: "bytes",
|
|
1415
|
+
internalType: "bytes"
|
|
1416
|
+
}
|
|
1417
|
+
]
|
|
1418
|
+
}
|
|
1419
|
+
],
|
|
1420
|
+
outputs: [],
|
|
1421
|
+
stateMutability: "payable"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
type: "function",
|
|
1425
|
+
name: "execute",
|
|
1426
|
+
inputs: [
|
|
1427
|
+
{
|
|
1428
|
+
name: "_mode",
|
|
1429
|
+
type: "bytes32",
|
|
1430
|
+
internalType: "ModeCode"
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
name: "_executionCalldata",
|
|
1434
|
+
type: "bytes",
|
|
1435
|
+
internalType: "bytes"
|
|
1436
|
+
}
|
|
1437
|
+
],
|
|
1438
|
+
outputs: [],
|
|
1439
|
+
stateMutability: "payable"
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
type: "function",
|
|
1443
|
+
name: "executeFromExecutor",
|
|
1444
|
+
inputs: [
|
|
1445
|
+
{
|
|
1446
|
+
name: "_mode",
|
|
1447
|
+
type: "bytes32",
|
|
1448
|
+
internalType: "ModeCode"
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
name: "_executionCalldata",
|
|
1452
|
+
type: "bytes",
|
|
1453
|
+
internalType: "bytes"
|
|
1454
|
+
}
|
|
1455
|
+
],
|
|
1456
|
+
outputs: [
|
|
1457
|
+
{
|
|
1458
|
+
name: "returnData_",
|
|
1459
|
+
type: "bytes[]",
|
|
1460
|
+
internalType: "bytes[]"
|
|
1461
|
+
}
|
|
1462
|
+
],
|
|
1463
|
+
stateMutability: "payable"
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
type: "function",
|
|
1467
|
+
name: "getDeposit",
|
|
1468
|
+
inputs: [],
|
|
1469
|
+
outputs: [
|
|
1470
|
+
{
|
|
1471
|
+
name: "",
|
|
1472
|
+
type: "uint256",
|
|
1473
|
+
internalType: "uint256"
|
|
1474
|
+
}
|
|
1475
|
+
],
|
|
1476
|
+
stateMutability: "view"
|
|
1477
|
+
},
|
|
1478
|
+
{
|
|
1479
|
+
type: "function",
|
|
1480
|
+
name: "getDomainHash",
|
|
1481
|
+
inputs: [],
|
|
1482
|
+
outputs: [
|
|
1483
|
+
{
|
|
1484
|
+
name: "",
|
|
1485
|
+
type: "bytes32",
|
|
1486
|
+
internalType: "bytes32"
|
|
1487
|
+
}
|
|
1488
|
+
],
|
|
1489
|
+
stateMutability: "view"
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
type: "function",
|
|
1493
|
+
name: "getNonce",
|
|
1494
|
+
inputs: [
|
|
1495
|
+
{
|
|
1496
|
+
name: "_key",
|
|
1497
|
+
type: "uint192",
|
|
1498
|
+
internalType: "uint192"
|
|
1499
|
+
}
|
|
1500
|
+
],
|
|
1501
|
+
outputs: [
|
|
1502
|
+
{
|
|
1503
|
+
name: "",
|
|
1504
|
+
type: "uint256",
|
|
1505
|
+
internalType: "uint256"
|
|
1506
|
+
}
|
|
1507
|
+
],
|
|
1508
|
+
stateMutability: "view"
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
type: "function",
|
|
1512
|
+
name: "getNonce",
|
|
1513
|
+
inputs: [],
|
|
1514
|
+
outputs: [
|
|
1515
|
+
{
|
|
1516
|
+
name: "",
|
|
1517
|
+
type: "uint256",
|
|
1518
|
+
internalType: "uint256"
|
|
1519
|
+
}
|
|
1520
|
+
],
|
|
1521
|
+
stateMutability: "view"
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
type: "function",
|
|
1525
|
+
name: "getPackedUserOperationHash",
|
|
1526
|
+
inputs: [
|
|
1527
|
+
{
|
|
1528
|
+
name: "_userOp",
|
|
1529
|
+
type: "tuple",
|
|
1530
|
+
internalType: "structPackedUserOperation",
|
|
1531
|
+
components: [
|
|
1532
|
+
{
|
|
1533
|
+
name: "sender",
|
|
1534
|
+
type: "address",
|
|
1535
|
+
internalType: "address"
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
name: "nonce",
|
|
1539
|
+
type: "uint256",
|
|
1540
|
+
internalType: "uint256"
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
name: "initCode",
|
|
1544
|
+
type: "bytes",
|
|
1545
|
+
internalType: "bytes"
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
name: "callData",
|
|
1549
|
+
type: "bytes",
|
|
1550
|
+
internalType: "bytes"
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
name: "accountGasLimits",
|
|
1554
|
+
type: "bytes32",
|
|
1555
|
+
internalType: "bytes32"
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
name: "preVerificationGas",
|
|
1559
|
+
type: "uint256",
|
|
1560
|
+
internalType: "uint256"
|
|
1561
|
+
},
|
|
1562
|
+
{
|
|
1563
|
+
name: "gasFees",
|
|
1564
|
+
type: "bytes32",
|
|
1565
|
+
internalType: "bytes32"
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
name: "paymasterAndData",
|
|
1569
|
+
type: "bytes",
|
|
1570
|
+
internalType: "bytes"
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
name: "signature",
|
|
1574
|
+
type: "bytes",
|
|
1575
|
+
internalType: "bytes"
|
|
1576
|
+
}
|
|
1577
|
+
]
|
|
1578
|
+
}
|
|
1579
|
+
],
|
|
1580
|
+
outputs: [
|
|
1581
|
+
{
|
|
1582
|
+
name: "",
|
|
1583
|
+
type: "bytes32",
|
|
1584
|
+
internalType: "bytes32"
|
|
1585
|
+
}
|
|
1586
|
+
],
|
|
1587
|
+
stateMutability: "view"
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
type: "function",
|
|
1591
|
+
name: "getPackedUserOperationTypedDataHash",
|
|
1592
|
+
inputs: [
|
|
1593
|
+
{
|
|
1594
|
+
name: "_userOp",
|
|
1595
|
+
type: "tuple",
|
|
1596
|
+
internalType: "structPackedUserOperation",
|
|
1597
|
+
components: [
|
|
1598
|
+
{
|
|
1599
|
+
name: "sender",
|
|
1600
|
+
type: "address",
|
|
1601
|
+
internalType: "address"
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
name: "nonce",
|
|
1605
|
+
type: "uint256",
|
|
1606
|
+
internalType: "uint256"
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
name: "initCode",
|
|
1610
|
+
type: "bytes",
|
|
1611
|
+
internalType: "bytes"
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
name: "callData",
|
|
1615
|
+
type: "bytes",
|
|
1616
|
+
internalType: "bytes"
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
name: "accountGasLimits",
|
|
1620
|
+
type: "bytes32",
|
|
1621
|
+
internalType: "bytes32"
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
name: "preVerificationGas",
|
|
1625
|
+
type: "uint256",
|
|
1626
|
+
internalType: "uint256"
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
name: "gasFees",
|
|
1630
|
+
type: "bytes32",
|
|
1631
|
+
internalType: "bytes32"
|
|
1632
|
+
},
|
|
1633
|
+
{
|
|
1634
|
+
name: "paymasterAndData",
|
|
1635
|
+
type: "bytes",
|
|
1636
|
+
internalType: "bytes"
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
name: "signature",
|
|
1640
|
+
type: "bytes",
|
|
1641
|
+
internalType: "bytes"
|
|
1642
|
+
}
|
|
1643
|
+
]
|
|
1644
|
+
}
|
|
1645
|
+
],
|
|
1646
|
+
outputs: [
|
|
1647
|
+
{
|
|
1648
|
+
name: "",
|
|
1649
|
+
type: "bytes32",
|
|
1650
|
+
internalType: "bytes32"
|
|
1651
|
+
}
|
|
1652
|
+
],
|
|
1653
|
+
stateMutability: "view"
|
|
1654
|
+
},
|
|
1655
|
+
{
|
|
1656
|
+
type: "function",
|
|
1657
|
+
name: "isDelegationDisabled",
|
|
1658
|
+
inputs: [
|
|
1659
|
+
{
|
|
1660
|
+
name: "_delegationHash",
|
|
1661
|
+
type: "bytes32",
|
|
1662
|
+
internalType: "bytes32"
|
|
1663
|
+
}
|
|
1664
|
+
],
|
|
1665
|
+
outputs: [
|
|
1666
|
+
{
|
|
1667
|
+
name: "",
|
|
1668
|
+
type: "bool",
|
|
1669
|
+
internalType: "bool"
|
|
1670
|
+
}
|
|
1671
|
+
],
|
|
1672
|
+
stateMutability: "view"
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
type: "function",
|
|
1676
|
+
name: "isValidSignature",
|
|
1677
|
+
inputs: [
|
|
1678
|
+
{
|
|
1679
|
+
name: "_hash",
|
|
1680
|
+
type: "bytes32",
|
|
1681
|
+
internalType: "bytes32"
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
name: "_signature",
|
|
1685
|
+
type: "bytes",
|
|
1686
|
+
internalType: "bytes"
|
|
1687
|
+
}
|
|
1688
|
+
],
|
|
1689
|
+
outputs: [
|
|
1690
|
+
{
|
|
1691
|
+
name: "magicValue_",
|
|
1692
|
+
type: "bytes4",
|
|
1693
|
+
internalType: "bytes4"
|
|
1694
|
+
}
|
|
1695
|
+
],
|
|
1696
|
+
stateMutability: "view"
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
type: "function",
|
|
1700
|
+
name: "onERC1155BatchReceived",
|
|
1701
|
+
inputs: [
|
|
1702
|
+
{
|
|
1703
|
+
name: "",
|
|
1704
|
+
type: "address",
|
|
1705
|
+
internalType: "address"
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
name: "",
|
|
1709
|
+
type: "address",
|
|
1710
|
+
internalType: "address"
|
|
1711
|
+
},
|
|
1712
|
+
{
|
|
1713
|
+
name: "",
|
|
1714
|
+
type: "uint256[]",
|
|
1715
|
+
internalType: "uint256[]"
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
name: "",
|
|
1719
|
+
type: "uint256[]",
|
|
1720
|
+
internalType: "uint256[]"
|
|
1721
|
+
},
|
|
1722
|
+
{
|
|
1723
|
+
name: "",
|
|
1724
|
+
type: "bytes",
|
|
1725
|
+
internalType: "bytes"
|
|
1726
|
+
}
|
|
1727
|
+
],
|
|
1728
|
+
outputs: [
|
|
1729
|
+
{
|
|
1730
|
+
name: "",
|
|
1731
|
+
type: "bytes4",
|
|
1732
|
+
internalType: "bytes4"
|
|
1733
|
+
}
|
|
1734
|
+
],
|
|
1735
|
+
stateMutability: "view"
|
|
1736
|
+
},
|
|
1737
|
+
{
|
|
1738
|
+
type: "function",
|
|
1739
|
+
name: "onERC1155Received",
|
|
1740
|
+
inputs: [
|
|
1741
|
+
{
|
|
1742
|
+
name: "",
|
|
1743
|
+
type: "address",
|
|
1744
|
+
internalType: "address"
|
|
1745
|
+
},
|
|
1746
|
+
{
|
|
1747
|
+
name: "",
|
|
1748
|
+
type: "address",
|
|
1749
|
+
internalType: "address"
|
|
1750
|
+
},
|
|
1751
|
+
{
|
|
1752
|
+
name: "",
|
|
1753
|
+
type: "uint256",
|
|
1754
|
+
internalType: "uint256"
|
|
1755
|
+
},
|
|
1756
|
+
{
|
|
1757
|
+
name: "",
|
|
1758
|
+
type: "uint256",
|
|
1759
|
+
internalType: "uint256"
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
name: "",
|
|
1763
|
+
type: "bytes",
|
|
1764
|
+
internalType: "bytes"
|
|
1765
|
+
}
|
|
1766
|
+
],
|
|
1767
|
+
outputs: [
|
|
1768
|
+
{
|
|
1769
|
+
name: "",
|
|
1770
|
+
type: "bytes4",
|
|
1771
|
+
internalType: "bytes4"
|
|
1772
|
+
}
|
|
1773
|
+
],
|
|
1774
|
+
stateMutability: "view"
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
type: "function",
|
|
1778
|
+
name: "onERC721Received",
|
|
1779
|
+
inputs: [
|
|
1780
|
+
{
|
|
1781
|
+
name: "",
|
|
1782
|
+
type: "address",
|
|
1783
|
+
internalType: "address"
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
name: "",
|
|
1787
|
+
type: "address",
|
|
1788
|
+
internalType: "address"
|
|
1789
|
+
},
|
|
1790
|
+
{
|
|
1791
|
+
name: "",
|
|
1792
|
+
type: "uint256",
|
|
1793
|
+
internalType: "uint256"
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
name: "",
|
|
1797
|
+
type: "bytes",
|
|
1798
|
+
internalType: "bytes"
|
|
1799
|
+
}
|
|
1800
|
+
],
|
|
1801
|
+
outputs: [
|
|
1802
|
+
{
|
|
1803
|
+
name: "",
|
|
1804
|
+
type: "bytes4",
|
|
1805
|
+
internalType: "bytes4"
|
|
1806
|
+
}
|
|
1807
|
+
],
|
|
1808
|
+
stateMutability: "view"
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
type: "function",
|
|
1812
|
+
name: "redeemDelegations",
|
|
1813
|
+
inputs: [
|
|
1814
|
+
{
|
|
1815
|
+
name: "_permissionContexts",
|
|
1816
|
+
type: "bytes[]",
|
|
1817
|
+
internalType: "bytes[]"
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
name: "_modes",
|
|
1821
|
+
type: "bytes32[]",
|
|
1822
|
+
internalType: "ModeCode[]"
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
name: "_executionCallDatas",
|
|
1826
|
+
type: "bytes[]",
|
|
1827
|
+
internalType: "bytes[]"
|
|
1828
|
+
}
|
|
1829
|
+
],
|
|
1830
|
+
outputs: [],
|
|
1831
|
+
stateMutability: "nonpayable"
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
type: "function",
|
|
1835
|
+
name: "supportsExecutionMode",
|
|
1836
|
+
inputs: [
|
|
1837
|
+
{
|
|
1838
|
+
name: "_mode",
|
|
1839
|
+
type: "bytes32",
|
|
1840
|
+
internalType: "ModeCode"
|
|
1841
|
+
}
|
|
1842
|
+
],
|
|
1843
|
+
outputs: [
|
|
1844
|
+
{
|
|
1845
|
+
name: "",
|
|
1846
|
+
type: "bool",
|
|
1847
|
+
internalType: "bool"
|
|
1848
|
+
}
|
|
1849
|
+
],
|
|
1850
|
+
stateMutability: "view"
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
type: "function",
|
|
1854
|
+
name: "supportsInterface",
|
|
1855
|
+
inputs: [
|
|
1856
|
+
{
|
|
1857
|
+
name: "_interfaceId",
|
|
1858
|
+
type: "bytes4",
|
|
1859
|
+
internalType: "bytes4"
|
|
1860
|
+
}
|
|
1861
|
+
],
|
|
1862
|
+
outputs: [
|
|
1863
|
+
{
|
|
1864
|
+
name: "",
|
|
1865
|
+
type: "bool",
|
|
1866
|
+
internalType: "bool"
|
|
1867
|
+
}
|
|
1868
|
+
],
|
|
1869
|
+
stateMutability: "view"
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
type: "function",
|
|
1873
|
+
name: "validateUserOp",
|
|
1874
|
+
inputs: [
|
|
1875
|
+
{
|
|
1876
|
+
name: "_userOp",
|
|
1877
|
+
type: "tuple",
|
|
1878
|
+
internalType: "structPackedUserOperation",
|
|
1879
|
+
components: [
|
|
1880
|
+
{
|
|
1881
|
+
name: "sender",
|
|
1882
|
+
type: "address",
|
|
1883
|
+
internalType: "address"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
name: "nonce",
|
|
1887
|
+
type: "uint256",
|
|
1888
|
+
internalType: "uint256"
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
name: "initCode",
|
|
1892
|
+
type: "bytes",
|
|
1893
|
+
internalType: "bytes"
|
|
1894
|
+
},
|
|
1895
|
+
{
|
|
1896
|
+
name: "callData",
|
|
1897
|
+
type: "bytes",
|
|
1898
|
+
internalType: "bytes"
|
|
1899
|
+
},
|
|
1900
|
+
{
|
|
1901
|
+
name: "accountGasLimits",
|
|
1902
|
+
type: "bytes32",
|
|
1903
|
+
internalType: "bytes32"
|
|
1904
|
+
},
|
|
1905
|
+
{
|
|
1906
|
+
name: "preVerificationGas",
|
|
1907
|
+
type: "uint256",
|
|
1908
|
+
internalType: "uint256"
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
name: "gasFees",
|
|
1912
|
+
type: "bytes32",
|
|
1913
|
+
internalType: "bytes32"
|
|
1914
|
+
},
|
|
1915
|
+
{
|
|
1916
|
+
name: "paymasterAndData",
|
|
1917
|
+
type: "bytes",
|
|
1918
|
+
internalType: "bytes"
|
|
1919
|
+
},
|
|
1920
|
+
{
|
|
1921
|
+
name: "signature",
|
|
1922
|
+
type: "bytes",
|
|
1923
|
+
internalType: "bytes"
|
|
1924
|
+
}
|
|
1925
|
+
]
|
|
1926
|
+
},
|
|
1927
|
+
{
|
|
1928
|
+
name: "",
|
|
1929
|
+
type: "bytes32",
|
|
1930
|
+
internalType: "bytes32"
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
name: "_missingAccountFunds",
|
|
1934
|
+
type: "uint256",
|
|
1935
|
+
internalType: "uint256"
|
|
1936
|
+
}
|
|
1937
|
+
],
|
|
1938
|
+
outputs: [
|
|
1939
|
+
{
|
|
1940
|
+
name: "validationData_",
|
|
1941
|
+
type: "uint256",
|
|
1942
|
+
internalType: "uint256"
|
|
1943
|
+
}
|
|
1944
|
+
],
|
|
1945
|
+
stateMutability: "nonpayable"
|
|
1946
|
+
},
|
|
1947
|
+
{
|
|
1948
|
+
type: "function",
|
|
1949
|
+
name: "withdrawDeposit",
|
|
1950
|
+
inputs: [
|
|
1951
|
+
{
|
|
1952
|
+
name: "_withdrawAddress",
|
|
1953
|
+
type: "address",
|
|
1954
|
+
internalType: "addresspayable"
|
|
1955
|
+
},
|
|
1956
|
+
{
|
|
1957
|
+
name: "_withdrawAmount",
|
|
1958
|
+
type: "uint256",
|
|
1959
|
+
internalType: "uint256"
|
|
1960
|
+
}
|
|
1961
|
+
],
|
|
1962
|
+
outputs: [],
|
|
1963
|
+
stateMutability: "nonpayable"
|
|
1964
|
+
},
|
|
1965
|
+
{
|
|
1966
|
+
type: "event",
|
|
1967
|
+
name: "EIP712DomainChanged",
|
|
1968
|
+
inputs: [],
|
|
1969
|
+
anonymous: false
|
|
1970
|
+
},
|
|
1971
|
+
{
|
|
1972
|
+
type: "event",
|
|
1973
|
+
name: "SentPrefund",
|
|
1974
|
+
inputs: [
|
|
1975
|
+
{
|
|
1976
|
+
name: "sender",
|
|
1977
|
+
type: "address",
|
|
1978
|
+
indexed: true,
|
|
1979
|
+
internalType: "address"
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
name: "amount",
|
|
1983
|
+
type: "uint256",
|
|
1984
|
+
indexed: false,
|
|
1985
|
+
internalType: "uint256"
|
|
1986
|
+
},
|
|
1987
|
+
{
|
|
1988
|
+
name: "success",
|
|
1989
|
+
type: "bool",
|
|
1990
|
+
indexed: false,
|
|
1991
|
+
internalType: "bool"
|
|
1992
|
+
}
|
|
1993
|
+
],
|
|
1994
|
+
anonymous: false
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
type: "event",
|
|
1998
|
+
name: "SetDelegationManager",
|
|
1999
|
+
inputs: [
|
|
2000
|
+
{
|
|
2001
|
+
name: "newDelegationManager",
|
|
2002
|
+
type: "address",
|
|
2003
|
+
indexed: true,
|
|
2004
|
+
internalType: "contractIDelegationManager"
|
|
2005
|
+
}
|
|
2006
|
+
],
|
|
2007
|
+
anonymous: false
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
type: "event",
|
|
2011
|
+
name: "SetEntryPoint",
|
|
2012
|
+
inputs: [
|
|
2013
|
+
{
|
|
2014
|
+
name: "entryPoint",
|
|
2015
|
+
type: "address",
|
|
2016
|
+
indexed: true,
|
|
2017
|
+
internalType: "contractIEntryPoint"
|
|
2018
|
+
}
|
|
2019
|
+
],
|
|
2020
|
+
anonymous: false
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
type: "event",
|
|
2024
|
+
name: "TryExecuteUnsuccessful",
|
|
2025
|
+
inputs: [
|
|
2026
|
+
{
|
|
2027
|
+
name: "batchExecutionindex",
|
|
2028
|
+
type: "uint256",
|
|
2029
|
+
indexed: false,
|
|
2030
|
+
internalType: "uint256"
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
name: "result",
|
|
2034
|
+
type: "bytes",
|
|
2035
|
+
indexed: false,
|
|
2036
|
+
internalType: "bytes"
|
|
2037
|
+
}
|
|
2038
|
+
],
|
|
2039
|
+
anonymous: false
|
|
2040
|
+
},
|
|
2041
|
+
{
|
|
2042
|
+
type: "error",
|
|
2043
|
+
name: "ECDSAInvalidSignature",
|
|
2044
|
+
inputs: []
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
type: "error",
|
|
2048
|
+
name: "ECDSAInvalidSignatureLength",
|
|
2049
|
+
inputs: [
|
|
2050
|
+
{
|
|
2051
|
+
name: "length",
|
|
2052
|
+
type: "uint256",
|
|
2053
|
+
internalType: "uint256"
|
|
2054
|
+
}
|
|
2055
|
+
]
|
|
2056
|
+
},
|
|
2057
|
+
{
|
|
2058
|
+
type: "error",
|
|
2059
|
+
name: "ECDSAInvalidSignatureS",
|
|
2060
|
+
inputs: [
|
|
2061
|
+
{
|
|
2062
|
+
name: "s",
|
|
2063
|
+
type: "bytes32",
|
|
2064
|
+
internalType: "bytes32"
|
|
2065
|
+
}
|
|
2066
|
+
]
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
type: "error",
|
|
2070
|
+
name: "ExecutionFailed",
|
|
2071
|
+
inputs: []
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
type: "error",
|
|
2075
|
+
name: "InvalidEIP712NameLength",
|
|
2076
|
+
inputs: []
|
|
2077
|
+
},
|
|
2078
|
+
{
|
|
2079
|
+
type: "error",
|
|
2080
|
+
name: "InvalidEIP712VersionLength",
|
|
2081
|
+
inputs: []
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
type: "error",
|
|
2085
|
+
name: "InvalidShortString",
|
|
2086
|
+
inputs: []
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
type: "error",
|
|
2090
|
+
name: "NotDelegationManager",
|
|
2091
|
+
inputs: []
|
|
2092
|
+
},
|
|
2093
|
+
{
|
|
2094
|
+
type: "error",
|
|
2095
|
+
name: "NotEntryPoint",
|
|
2096
|
+
inputs: []
|
|
2097
|
+
},
|
|
2098
|
+
{
|
|
2099
|
+
type: "error",
|
|
2100
|
+
name: "NotEntryPointOrSelf",
|
|
2101
|
+
inputs: []
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
type: "error",
|
|
2105
|
+
name: "NotSelf",
|
|
2106
|
+
inputs: []
|
|
2107
|
+
},
|
|
2108
|
+
{
|
|
2109
|
+
type: "error",
|
|
2110
|
+
name: "StringTooLong",
|
|
2111
|
+
inputs: [
|
|
2112
|
+
{
|
|
2113
|
+
name: "str",
|
|
2114
|
+
type: "string",
|
|
2115
|
+
internalType: "string"
|
|
2116
|
+
}
|
|
2117
|
+
]
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
type: "error",
|
|
2121
|
+
name: "UnauthorizedCallContext",
|
|
2122
|
+
inputs: []
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
type: "error",
|
|
2126
|
+
name: "UnsupportedCallType",
|
|
2127
|
+
inputs: [
|
|
2128
|
+
{
|
|
2129
|
+
name: "callType",
|
|
2130
|
+
type: "bytes1",
|
|
2131
|
+
internalType: "CallType"
|
|
2132
|
+
}
|
|
2133
|
+
]
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
type: "error",
|
|
2137
|
+
name: "UnsupportedExecType",
|
|
2138
|
+
inputs: [
|
|
2139
|
+
{
|
|
2140
|
+
name: "execType",
|
|
2141
|
+
type: "bytes1",
|
|
2142
|
+
internalType: "ExecType"
|
|
2143
|
+
}
|
|
2144
|
+
]
|
|
2145
|
+
}
|
|
2146
|
+
];
|
|
2147
|
+
|
|
2148
|
+
// src/client/common/contract/eip7702.ts
|
|
2149
|
+
var EXECUTE_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
2150
|
+
var GAS_LIMIT_BUFFER_PERCENTAGE = 20n;
|
|
2151
|
+
var GAS_PRICE_BUFFER_PERCENTAGE = 100n;
|
|
2152
|
+
function encodeExecuteBatchData(executions) {
|
|
2153
|
+
const encodedExecutions = encodeAbiParameters(
|
|
2154
|
+
[
|
|
2155
|
+
{
|
|
2156
|
+
type: "tuple[]",
|
|
2157
|
+
components: [
|
|
2158
|
+
{ name: "target", type: "address" },
|
|
2159
|
+
{ name: "value", type: "uint256" },
|
|
2160
|
+
{ name: "callData", type: "bytes" }
|
|
2161
|
+
]
|
|
2162
|
+
}
|
|
2163
|
+
],
|
|
2164
|
+
[executions]
|
|
2165
|
+
);
|
|
2166
|
+
return encodeFunctionData({
|
|
2167
|
+
abi: ERC7702Delegator_default,
|
|
2168
|
+
functionName: "execute",
|
|
2169
|
+
args: [EXECUTE_BATCH_MODE, encodedExecutions]
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
async function estimateBatchGas(options) {
|
|
2173
|
+
const { publicClient, account, executions } = options;
|
|
2174
|
+
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2175
|
+
const [gasTipCap, block, estimatedGas] = await Promise.all([
|
|
2176
|
+
publicClient.estimateMaxPriorityFeePerGas(),
|
|
2177
|
+
publicClient.getBlock(),
|
|
2178
|
+
publicClient.estimateGas({
|
|
2179
|
+
account,
|
|
2180
|
+
to: account,
|
|
2181
|
+
data: executeBatchData
|
|
2182
|
+
})
|
|
2183
|
+
]);
|
|
2184
|
+
const baseFee = block.baseFeePerGas ?? 0n;
|
|
2185
|
+
const maxFeePerGas = (baseFee + gasTipCap) * (100n + GAS_PRICE_BUFFER_PERCENTAGE) / 100n;
|
|
2186
|
+
const gasLimit = estimatedGas * (100n + GAS_LIMIT_BUFFER_PERCENTAGE) / 100n;
|
|
2187
|
+
const maxCostWei = gasLimit * maxFeePerGas;
|
|
2188
|
+
return {
|
|
2189
|
+
gasLimit,
|
|
2190
|
+
maxFeePerGas,
|
|
2191
|
+
maxPriorityFeePerGas: gasTipCap,
|
|
2192
|
+
maxCostWei,
|
|
2193
|
+
maxCostEth: formatETH(maxCostWei)
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
|
|
2197
|
+
const code = await publicClient.getCode({ address: account });
|
|
2198
|
+
if (!code) {
|
|
2199
|
+
return false;
|
|
2200
|
+
}
|
|
2201
|
+
const expectedCode = `0xef0100${delegatorAddress.slice(2)}`;
|
|
2202
|
+
return code.toLowerCase() === expectedCode.toLowerCase();
|
|
2203
|
+
}
|
|
2204
|
+
async function executeBatch(options, logger = noopLogger) {
|
|
2205
|
+
const { walletClient, publicClient, environmentConfig, executions, pendingMessage, gas } = options;
|
|
2206
|
+
const account = walletClient.account;
|
|
2207
|
+
if (!account) {
|
|
2208
|
+
throw new Error("Wallet client must have an account");
|
|
2209
|
+
}
|
|
2210
|
+
const chain = walletClient.chain;
|
|
2211
|
+
if (!chain) {
|
|
2212
|
+
throw new Error("Wallet client must have a chain");
|
|
2213
|
+
}
|
|
2214
|
+
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2215
|
+
const isDelegated2 = await checkERC7702Delegation(
|
|
2216
|
+
publicClient,
|
|
2217
|
+
account.address,
|
|
2218
|
+
environmentConfig.erc7702DelegatorAddress
|
|
2219
|
+
);
|
|
2220
|
+
let authorizationList = [];
|
|
2221
|
+
if (!isDelegated2) {
|
|
2222
|
+
const transactionNonce = await publicClient.getTransactionCount({
|
|
2223
|
+
address: account.address,
|
|
2224
|
+
blockTag: "pending"
|
|
2225
|
+
});
|
|
2226
|
+
const chainId = await publicClient.getChainId();
|
|
2227
|
+
const authorizationNonce = transactionNonce + 1;
|
|
2228
|
+
logger.debug("Using wallet client signing for EIP-7702 authorization");
|
|
2229
|
+
const signedAuthorization = await walletClient.signAuthorization({
|
|
2230
|
+
account: account.address,
|
|
2231
|
+
contractAddress: environmentConfig.erc7702DelegatorAddress,
|
|
2232
|
+
chainId,
|
|
2233
|
+
nonce: Number(authorizationNonce)
|
|
2234
|
+
});
|
|
2235
|
+
authorizationList = [signedAuthorization];
|
|
2236
|
+
}
|
|
2237
|
+
if (pendingMessage) {
|
|
2238
|
+
logger.info(pendingMessage);
|
|
2239
|
+
}
|
|
2240
|
+
const txRequest = {
|
|
2241
|
+
account: walletClient.account,
|
|
2242
|
+
chain,
|
|
2243
|
+
to: account.address,
|
|
2244
|
+
data: executeBatchData,
|
|
2245
|
+
value: 0n
|
|
2246
|
+
};
|
|
2247
|
+
if (authorizationList.length > 0) {
|
|
2248
|
+
txRequest.authorizationList = authorizationList;
|
|
2249
|
+
}
|
|
2250
|
+
if (gas?.maxFeePerGas) {
|
|
2251
|
+
txRequest.maxFeePerGas = gas.maxFeePerGas;
|
|
2252
|
+
}
|
|
2253
|
+
if (gas?.maxPriorityFeePerGas) {
|
|
2254
|
+
txRequest.maxPriorityFeePerGas = gas.maxPriorityFeePerGas;
|
|
2255
|
+
}
|
|
2256
|
+
const hash = await walletClient.sendTransaction(txRequest);
|
|
2257
|
+
logger.info(`Transaction sent: ${hash}`);
|
|
2258
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2259
|
+
if (receipt.status === "reverted") {
|
|
2260
|
+
let revertReason = "Unknown reason";
|
|
2261
|
+
try {
|
|
2262
|
+
await publicClient.call({
|
|
2263
|
+
to: account.address,
|
|
2264
|
+
data: executeBatchData,
|
|
2265
|
+
account: account.address
|
|
2266
|
+
});
|
|
2267
|
+
} catch (callError) {
|
|
2268
|
+
if (callError.data) {
|
|
2269
|
+
try {
|
|
2270
|
+
const decoded = decodeErrorResult({
|
|
2271
|
+
abi: ERC7702Delegator_default,
|
|
2272
|
+
data: callError.data
|
|
2273
|
+
});
|
|
2274
|
+
revertReason = `${decoded.errorName}: ${JSON.stringify(decoded.args)}`;
|
|
2275
|
+
} catch {
|
|
2276
|
+
revertReason = callError.message || "Unknown reason";
|
|
2277
|
+
}
|
|
2278
|
+
} else {
|
|
2279
|
+
revertReason = callError.message || "Unknown reason";
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
throw new Error(`Transaction reverted: ${hash}. Reason: ${revertReason}`);
|
|
2283
|
+
}
|
|
2284
|
+
return hash;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
// src/client/common/contract/caller.ts
|
|
2288
|
+
import { encodeFunctionData as encodeFunctionData2, decodeErrorResult as decodeErrorResult2, bytesToHex } from "viem";
|
|
2289
|
+
|
|
2290
|
+
// src/client/common/abis/AppController.json
|
|
2291
|
+
var AppController_default = [
|
|
2292
|
+
{
|
|
2293
|
+
type: "constructor",
|
|
2294
|
+
inputs: [
|
|
2295
|
+
{
|
|
2296
|
+
name: "_version",
|
|
2297
|
+
type: "string",
|
|
2298
|
+
internalType: "string"
|
|
2299
|
+
},
|
|
2300
|
+
{
|
|
2301
|
+
name: "_permissionController",
|
|
2302
|
+
type: "address",
|
|
2303
|
+
internalType: "contractIPermissionController"
|
|
2304
|
+
},
|
|
2305
|
+
{
|
|
2306
|
+
name: "_releaseManager",
|
|
2307
|
+
type: "address",
|
|
2308
|
+
internalType: "contractIReleaseManager"
|
|
2309
|
+
},
|
|
2310
|
+
{
|
|
2311
|
+
name: "_computeAVSRegistrar",
|
|
2312
|
+
type: "address",
|
|
2313
|
+
internalType: "contractIComputeAVSRegistrar"
|
|
2314
|
+
},
|
|
2315
|
+
{
|
|
2316
|
+
name: "_computeOperator",
|
|
2317
|
+
type: "address",
|
|
2318
|
+
internalType: "contractIComputeOperator"
|
|
2319
|
+
},
|
|
2320
|
+
{
|
|
2321
|
+
name: "_appBeacon",
|
|
2322
|
+
type: "address",
|
|
2323
|
+
internalType: "contractIBeacon"
|
|
2324
|
+
}
|
|
2325
|
+
],
|
|
2326
|
+
stateMutability: "nonpayable"
|
|
2327
|
+
},
|
|
2328
|
+
{
|
|
2329
|
+
type: "function",
|
|
2330
|
+
name: "API_PERMISSION_TYPEHASH",
|
|
2331
|
+
inputs: [],
|
|
2332
|
+
outputs: [
|
|
2333
|
+
{
|
|
2334
|
+
name: "",
|
|
2335
|
+
type: "bytes32",
|
|
2336
|
+
internalType: "bytes32"
|
|
2337
|
+
}
|
|
2338
|
+
],
|
|
2339
|
+
stateMutability: "view"
|
|
2340
|
+
},
|
|
2341
|
+
{
|
|
2342
|
+
type: "function",
|
|
2343
|
+
name: "appBeacon",
|
|
2344
|
+
inputs: [],
|
|
2345
|
+
outputs: [
|
|
2346
|
+
{
|
|
2347
|
+
name: "",
|
|
2348
|
+
type: "address",
|
|
2349
|
+
internalType: "contractIBeacon"
|
|
2350
|
+
}
|
|
2351
|
+
],
|
|
2352
|
+
stateMutability: "view"
|
|
2353
|
+
},
|
|
2354
|
+
{
|
|
2355
|
+
type: "function",
|
|
2356
|
+
name: "calculateApiPermissionDigestHash",
|
|
2357
|
+
inputs: [
|
|
2358
|
+
{
|
|
2359
|
+
name: "permission",
|
|
2360
|
+
type: "bytes4",
|
|
2361
|
+
internalType: "bytes4"
|
|
2362
|
+
},
|
|
2363
|
+
{
|
|
2364
|
+
name: "expiry",
|
|
2365
|
+
type: "uint256",
|
|
2366
|
+
internalType: "uint256"
|
|
2367
|
+
}
|
|
2368
|
+
],
|
|
2369
|
+
outputs: [
|
|
2370
|
+
{
|
|
2371
|
+
name: "",
|
|
2372
|
+
type: "bytes32",
|
|
2373
|
+
internalType: "bytes32"
|
|
2374
|
+
}
|
|
2375
|
+
],
|
|
2376
|
+
stateMutability: "view"
|
|
2377
|
+
},
|
|
2378
|
+
{
|
|
2379
|
+
type: "function",
|
|
2380
|
+
name: "calculateAppId",
|
|
2381
|
+
inputs: [
|
|
2382
|
+
{
|
|
2383
|
+
name: "deployer",
|
|
2384
|
+
type: "address",
|
|
2385
|
+
internalType: "address"
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
name: "salt",
|
|
2389
|
+
type: "bytes32",
|
|
2390
|
+
internalType: "bytes32"
|
|
2391
|
+
}
|
|
2392
|
+
],
|
|
2393
|
+
outputs: [
|
|
2394
|
+
{
|
|
2395
|
+
name: "",
|
|
2396
|
+
type: "address",
|
|
2397
|
+
internalType: "contractIApp"
|
|
2398
|
+
}
|
|
2399
|
+
],
|
|
2400
|
+
stateMutability: "view"
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
type: "function",
|
|
2404
|
+
name: "computeAVSRegistrar",
|
|
2405
|
+
inputs: [],
|
|
2406
|
+
outputs: [
|
|
2407
|
+
{
|
|
2408
|
+
name: "",
|
|
2409
|
+
type: "address",
|
|
2410
|
+
internalType: "contractIComputeAVSRegistrar"
|
|
2411
|
+
}
|
|
2412
|
+
],
|
|
2413
|
+
stateMutability: "view"
|
|
2414
|
+
},
|
|
2415
|
+
{
|
|
2416
|
+
type: "function",
|
|
2417
|
+
name: "computeOperator",
|
|
2418
|
+
inputs: [],
|
|
2419
|
+
outputs: [
|
|
2420
|
+
{
|
|
2421
|
+
name: "",
|
|
2422
|
+
type: "address",
|
|
2423
|
+
internalType: "contractIComputeOperator"
|
|
2424
|
+
}
|
|
2425
|
+
],
|
|
2426
|
+
stateMutability: "view"
|
|
2427
|
+
},
|
|
2428
|
+
{
|
|
2429
|
+
type: "function",
|
|
2430
|
+
name: "createApp",
|
|
2431
|
+
inputs: [
|
|
2432
|
+
{
|
|
2433
|
+
name: "salt",
|
|
2434
|
+
type: "bytes32",
|
|
2435
|
+
internalType: "bytes32"
|
|
2436
|
+
},
|
|
2437
|
+
{
|
|
2438
|
+
name: "release",
|
|
2439
|
+
type: "tuple",
|
|
2440
|
+
internalType: "structIAppController.Release",
|
|
2441
|
+
components: [
|
|
2442
|
+
{
|
|
2443
|
+
name: "rmsRelease",
|
|
2444
|
+
type: "tuple",
|
|
2445
|
+
internalType: "structIReleaseManagerTypes.Release",
|
|
2446
|
+
components: [
|
|
2447
|
+
{
|
|
2448
|
+
name: "artifacts",
|
|
2449
|
+
type: "tuple[]",
|
|
2450
|
+
internalType: "structIReleaseManagerTypes.Artifact[]",
|
|
2451
|
+
components: [
|
|
2452
|
+
{
|
|
2453
|
+
name: "digest",
|
|
2454
|
+
type: "bytes32",
|
|
2455
|
+
internalType: "bytes32"
|
|
2456
|
+
},
|
|
2457
|
+
{
|
|
2458
|
+
name: "registry",
|
|
2459
|
+
type: "string",
|
|
2460
|
+
internalType: "string"
|
|
2461
|
+
}
|
|
2462
|
+
]
|
|
2463
|
+
},
|
|
2464
|
+
{
|
|
2465
|
+
name: "upgradeByTime",
|
|
2466
|
+
type: "uint32",
|
|
2467
|
+
internalType: "uint32"
|
|
2468
|
+
}
|
|
2469
|
+
]
|
|
2470
|
+
},
|
|
2471
|
+
{
|
|
2472
|
+
name: "publicEnv",
|
|
2473
|
+
type: "bytes",
|
|
2474
|
+
internalType: "bytes"
|
|
2475
|
+
},
|
|
2476
|
+
{
|
|
2477
|
+
name: "encryptedEnv",
|
|
2478
|
+
type: "bytes",
|
|
2479
|
+
internalType: "bytes"
|
|
2480
|
+
}
|
|
2481
|
+
]
|
|
2482
|
+
}
|
|
2483
|
+
],
|
|
2484
|
+
outputs: [
|
|
2485
|
+
{
|
|
2486
|
+
name: "app",
|
|
2487
|
+
type: "address",
|
|
2488
|
+
internalType: "contractIApp"
|
|
2489
|
+
}
|
|
2490
|
+
],
|
|
2491
|
+
stateMutability: "nonpayable"
|
|
2492
|
+
},
|
|
2493
|
+
{
|
|
2494
|
+
type: "function",
|
|
2495
|
+
name: "domainSeparator",
|
|
2496
|
+
inputs: [],
|
|
2497
|
+
outputs: [
|
|
2498
|
+
{
|
|
2499
|
+
name: "",
|
|
2500
|
+
type: "bytes32",
|
|
2501
|
+
internalType: "bytes32"
|
|
2502
|
+
}
|
|
2503
|
+
],
|
|
2504
|
+
stateMutability: "view"
|
|
2505
|
+
},
|
|
2506
|
+
{
|
|
2507
|
+
type: "function",
|
|
2508
|
+
name: "getActiveAppCount",
|
|
2509
|
+
inputs: [
|
|
2510
|
+
{
|
|
2511
|
+
name: "user",
|
|
2512
|
+
type: "address",
|
|
2513
|
+
internalType: "address"
|
|
2514
|
+
}
|
|
2515
|
+
],
|
|
2516
|
+
outputs: [
|
|
2517
|
+
{
|
|
2518
|
+
name: "",
|
|
2519
|
+
type: "uint32",
|
|
2520
|
+
internalType: "uint32"
|
|
2521
|
+
}
|
|
2522
|
+
],
|
|
2523
|
+
stateMutability: "view"
|
|
2524
|
+
},
|
|
2525
|
+
{
|
|
2526
|
+
type: "function",
|
|
2527
|
+
name: "getAppCreator",
|
|
2528
|
+
inputs: [
|
|
2529
|
+
{
|
|
2530
|
+
name: "app",
|
|
2531
|
+
type: "address",
|
|
2532
|
+
internalType: "contractIApp"
|
|
2533
|
+
}
|
|
2534
|
+
],
|
|
2535
|
+
outputs: [
|
|
2536
|
+
{
|
|
2537
|
+
name: "",
|
|
2538
|
+
type: "address",
|
|
2539
|
+
internalType: "address"
|
|
2540
|
+
}
|
|
2541
|
+
],
|
|
2542
|
+
stateMutability: "view"
|
|
2543
|
+
},
|
|
2544
|
+
{
|
|
2545
|
+
type: "function",
|
|
2546
|
+
name: "getAppLatestReleaseBlockNumber",
|
|
2547
|
+
inputs: [
|
|
2548
|
+
{
|
|
2549
|
+
name: "app",
|
|
2550
|
+
type: "address",
|
|
2551
|
+
internalType: "contractIApp"
|
|
2552
|
+
}
|
|
2553
|
+
],
|
|
2554
|
+
outputs: [
|
|
2555
|
+
{
|
|
2556
|
+
name: "",
|
|
2557
|
+
type: "uint32",
|
|
2558
|
+
internalType: "uint32"
|
|
2559
|
+
}
|
|
2560
|
+
],
|
|
2561
|
+
stateMutability: "view"
|
|
2562
|
+
},
|
|
2563
|
+
{
|
|
2564
|
+
type: "function",
|
|
2565
|
+
name: "getAppOperatorSetId",
|
|
2566
|
+
inputs: [
|
|
2567
|
+
{
|
|
2568
|
+
name: "app",
|
|
2569
|
+
type: "address",
|
|
2570
|
+
internalType: "contractIApp"
|
|
2571
|
+
}
|
|
2572
|
+
],
|
|
2573
|
+
outputs: [
|
|
2574
|
+
{
|
|
2575
|
+
name: "",
|
|
2576
|
+
type: "uint32",
|
|
2577
|
+
internalType: "uint32"
|
|
2578
|
+
}
|
|
2579
|
+
],
|
|
2580
|
+
stateMutability: "view"
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2583
|
+
type: "function",
|
|
2584
|
+
name: "getAppStatus",
|
|
2585
|
+
inputs: [
|
|
2586
|
+
{
|
|
2587
|
+
name: "app",
|
|
2588
|
+
type: "address",
|
|
2589
|
+
internalType: "contractIApp"
|
|
2590
|
+
}
|
|
2591
|
+
],
|
|
2592
|
+
outputs: [
|
|
2593
|
+
{
|
|
2594
|
+
name: "",
|
|
2595
|
+
type: "uint8",
|
|
2596
|
+
internalType: "enumIAppController.AppStatus"
|
|
2597
|
+
}
|
|
2598
|
+
],
|
|
2599
|
+
stateMutability: "view"
|
|
2600
|
+
},
|
|
2601
|
+
{
|
|
2602
|
+
type: "function",
|
|
2603
|
+
name: "getApps",
|
|
2604
|
+
inputs: [
|
|
2605
|
+
{
|
|
2606
|
+
name: "offset",
|
|
2607
|
+
type: "uint256",
|
|
2608
|
+
internalType: "uint256"
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
name: "limit",
|
|
2612
|
+
type: "uint256",
|
|
2613
|
+
internalType: "uint256"
|
|
2614
|
+
}
|
|
2615
|
+
],
|
|
2616
|
+
outputs: [
|
|
2617
|
+
{
|
|
2618
|
+
name: "apps",
|
|
2619
|
+
type: "address[]",
|
|
2620
|
+
internalType: "contractIApp[]"
|
|
2621
|
+
},
|
|
2622
|
+
{
|
|
2623
|
+
name: "appConfigsMem",
|
|
2624
|
+
type: "tuple[]",
|
|
2625
|
+
internalType: "structIAppController.AppConfig[]",
|
|
2626
|
+
components: [
|
|
2627
|
+
{
|
|
2628
|
+
name: "creator",
|
|
2629
|
+
type: "address",
|
|
2630
|
+
internalType: "address"
|
|
2631
|
+
},
|
|
2632
|
+
{
|
|
2633
|
+
name: "operatorSetId",
|
|
2634
|
+
type: "uint32",
|
|
2635
|
+
internalType: "uint32"
|
|
2636
|
+
},
|
|
2637
|
+
{
|
|
2638
|
+
name: "latestReleaseBlockNumber",
|
|
2639
|
+
type: "uint32",
|
|
2640
|
+
internalType: "uint32"
|
|
2641
|
+
},
|
|
2642
|
+
{
|
|
2643
|
+
name: "status",
|
|
2644
|
+
type: "uint8",
|
|
2645
|
+
internalType: "enumIAppController.AppStatus"
|
|
2646
|
+
}
|
|
2647
|
+
]
|
|
2648
|
+
}
|
|
2649
|
+
],
|
|
2650
|
+
stateMutability: "view"
|
|
2651
|
+
},
|
|
2652
|
+
{
|
|
2653
|
+
type: "function",
|
|
2654
|
+
name: "getAppsByCreator",
|
|
2655
|
+
inputs: [
|
|
2656
|
+
{
|
|
2657
|
+
name: "creator",
|
|
2658
|
+
type: "address",
|
|
2659
|
+
internalType: "address"
|
|
2660
|
+
},
|
|
2661
|
+
{
|
|
2662
|
+
name: "offset",
|
|
2663
|
+
type: "uint256",
|
|
2664
|
+
internalType: "uint256"
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2667
|
+
name: "limit",
|
|
2668
|
+
type: "uint256",
|
|
2669
|
+
internalType: "uint256"
|
|
2670
|
+
}
|
|
2671
|
+
],
|
|
2672
|
+
outputs: [
|
|
2673
|
+
{
|
|
2674
|
+
name: "apps",
|
|
2675
|
+
type: "address[]",
|
|
2676
|
+
internalType: "contractIApp[]"
|
|
2677
|
+
},
|
|
2678
|
+
{
|
|
2679
|
+
name: "appConfigsMem",
|
|
2680
|
+
type: "tuple[]",
|
|
2681
|
+
internalType: "structIAppController.AppConfig[]",
|
|
2682
|
+
components: [
|
|
2683
|
+
{
|
|
2684
|
+
name: "creator",
|
|
2685
|
+
type: "address",
|
|
2686
|
+
internalType: "address"
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
name: "operatorSetId",
|
|
2690
|
+
type: "uint32",
|
|
2691
|
+
internalType: "uint32"
|
|
2692
|
+
},
|
|
2693
|
+
{
|
|
2694
|
+
name: "latestReleaseBlockNumber",
|
|
2695
|
+
type: "uint32",
|
|
2696
|
+
internalType: "uint32"
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
name: "status",
|
|
2700
|
+
type: "uint8",
|
|
2701
|
+
internalType: "enumIAppController.AppStatus"
|
|
2702
|
+
}
|
|
2703
|
+
]
|
|
2704
|
+
}
|
|
2705
|
+
],
|
|
2706
|
+
stateMutability: "view"
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
type: "function",
|
|
2710
|
+
name: "getAppsByDeveloper",
|
|
2711
|
+
inputs: [
|
|
2712
|
+
{
|
|
2713
|
+
name: "developer",
|
|
2714
|
+
type: "address",
|
|
2715
|
+
internalType: "address"
|
|
2716
|
+
},
|
|
2717
|
+
{
|
|
2718
|
+
name: "offset",
|
|
2719
|
+
type: "uint256",
|
|
2720
|
+
internalType: "uint256"
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
name: "limit",
|
|
2724
|
+
type: "uint256",
|
|
2725
|
+
internalType: "uint256"
|
|
2726
|
+
}
|
|
2727
|
+
],
|
|
2728
|
+
outputs: [
|
|
2729
|
+
{
|
|
2730
|
+
name: "apps",
|
|
2731
|
+
type: "address[]",
|
|
2732
|
+
internalType: "contractIApp[]"
|
|
2733
|
+
},
|
|
2734
|
+
{
|
|
2735
|
+
name: "appConfigsMem",
|
|
2736
|
+
type: "tuple[]",
|
|
2737
|
+
internalType: "structIAppController.AppConfig[]",
|
|
2738
|
+
components: [
|
|
2739
|
+
{
|
|
2740
|
+
name: "creator",
|
|
2741
|
+
type: "address",
|
|
2742
|
+
internalType: "address"
|
|
2743
|
+
},
|
|
2744
|
+
{
|
|
2745
|
+
name: "operatorSetId",
|
|
2746
|
+
type: "uint32",
|
|
2747
|
+
internalType: "uint32"
|
|
2748
|
+
},
|
|
2749
|
+
{
|
|
2750
|
+
name: "latestReleaseBlockNumber",
|
|
2751
|
+
type: "uint32",
|
|
2752
|
+
internalType: "uint32"
|
|
2753
|
+
},
|
|
2754
|
+
{
|
|
2755
|
+
name: "status",
|
|
2756
|
+
type: "uint8",
|
|
2757
|
+
internalType: "enumIAppController.AppStatus"
|
|
2758
|
+
}
|
|
2759
|
+
]
|
|
2760
|
+
}
|
|
2761
|
+
],
|
|
2762
|
+
stateMutability: "view"
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
type: "function",
|
|
2766
|
+
name: "getMaxActiveAppsPerUser",
|
|
2767
|
+
inputs: [
|
|
2768
|
+
{
|
|
2769
|
+
name: "user",
|
|
2770
|
+
type: "address",
|
|
2771
|
+
internalType: "address"
|
|
2772
|
+
}
|
|
2773
|
+
],
|
|
2774
|
+
outputs: [
|
|
2775
|
+
{
|
|
2776
|
+
name: "",
|
|
2777
|
+
type: "uint32",
|
|
2778
|
+
internalType: "uint32"
|
|
2779
|
+
}
|
|
2780
|
+
],
|
|
2781
|
+
stateMutability: "view"
|
|
2782
|
+
},
|
|
2783
|
+
{
|
|
2784
|
+
type: "function",
|
|
2785
|
+
name: "globalActiveAppCount",
|
|
2786
|
+
inputs: [],
|
|
2787
|
+
outputs: [
|
|
2788
|
+
{
|
|
2789
|
+
name: "",
|
|
2790
|
+
type: "uint32",
|
|
2791
|
+
internalType: "uint32"
|
|
2792
|
+
}
|
|
2793
|
+
],
|
|
2794
|
+
stateMutability: "view"
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
type: "function",
|
|
2798
|
+
name: "initialize",
|
|
2799
|
+
inputs: [
|
|
2800
|
+
{
|
|
2801
|
+
name: "admin",
|
|
2802
|
+
type: "address",
|
|
2803
|
+
internalType: "address"
|
|
2804
|
+
}
|
|
2805
|
+
],
|
|
2806
|
+
outputs: [],
|
|
2807
|
+
stateMutability: "nonpayable"
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
type: "function",
|
|
2811
|
+
name: "maxGlobalActiveApps",
|
|
2812
|
+
inputs: [],
|
|
2813
|
+
outputs: [
|
|
2814
|
+
{
|
|
2815
|
+
name: "",
|
|
2816
|
+
type: "uint32",
|
|
2817
|
+
internalType: "uint32"
|
|
2818
|
+
}
|
|
2819
|
+
],
|
|
2820
|
+
stateMutability: "view"
|
|
2821
|
+
},
|
|
2822
|
+
{
|
|
2823
|
+
type: "function",
|
|
2824
|
+
name: "permissionController",
|
|
2825
|
+
inputs: [],
|
|
2826
|
+
outputs: [
|
|
2827
|
+
{
|
|
2828
|
+
name: "",
|
|
2829
|
+
type: "address",
|
|
2830
|
+
internalType: "contractIPermissionController"
|
|
2831
|
+
}
|
|
2832
|
+
],
|
|
2833
|
+
stateMutability: "view"
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
type: "function",
|
|
2837
|
+
name: "releaseManager",
|
|
2838
|
+
inputs: [],
|
|
2839
|
+
outputs: [
|
|
2840
|
+
{
|
|
2841
|
+
name: "",
|
|
2842
|
+
type: "address",
|
|
2843
|
+
internalType: "contractIReleaseManager"
|
|
2844
|
+
}
|
|
2845
|
+
],
|
|
2846
|
+
stateMutability: "view"
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
type: "function",
|
|
2850
|
+
name: "setMaxActiveAppsPerUser",
|
|
2851
|
+
inputs: [
|
|
2852
|
+
{
|
|
2853
|
+
name: "user",
|
|
2854
|
+
type: "address",
|
|
2855
|
+
internalType: "address"
|
|
2856
|
+
},
|
|
2857
|
+
{
|
|
2858
|
+
name: "limit",
|
|
2859
|
+
type: "uint32",
|
|
2860
|
+
internalType: "uint32"
|
|
2861
|
+
}
|
|
2862
|
+
],
|
|
2863
|
+
outputs: [],
|
|
2864
|
+
stateMutability: "nonpayable"
|
|
2865
|
+
},
|
|
2866
|
+
{
|
|
2867
|
+
type: "function",
|
|
2868
|
+
name: "setMaxGlobalActiveApps",
|
|
2869
|
+
inputs: [
|
|
2870
|
+
{
|
|
2871
|
+
name: "limit",
|
|
2872
|
+
type: "uint32",
|
|
2873
|
+
internalType: "uint32"
|
|
2874
|
+
}
|
|
2875
|
+
],
|
|
2876
|
+
outputs: [],
|
|
2877
|
+
stateMutability: "nonpayable"
|
|
2878
|
+
},
|
|
2879
|
+
{
|
|
2880
|
+
type: "function",
|
|
2881
|
+
name: "startApp",
|
|
2882
|
+
inputs: [
|
|
2883
|
+
{
|
|
2884
|
+
name: "app",
|
|
2885
|
+
type: "address",
|
|
2886
|
+
internalType: "contractIApp"
|
|
2887
|
+
}
|
|
2888
|
+
],
|
|
2889
|
+
outputs: [],
|
|
2890
|
+
stateMutability: "nonpayable"
|
|
2891
|
+
},
|
|
2892
|
+
{
|
|
2893
|
+
type: "function",
|
|
2894
|
+
name: "stopApp",
|
|
2895
|
+
inputs: [
|
|
2896
|
+
{
|
|
2897
|
+
name: "app",
|
|
2898
|
+
type: "address",
|
|
2899
|
+
internalType: "contractIApp"
|
|
2900
|
+
}
|
|
2901
|
+
],
|
|
2902
|
+
outputs: [],
|
|
2903
|
+
stateMutability: "nonpayable"
|
|
2904
|
+
},
|
|
2905
|
+
{
|
|
2906
|
+
type: "function",
|
|
2907
|
+
name: "suspend",
|
|
2908
|
+
inputs: [
|
|
2909
|
+
{
|
|
2910
|
+
name: "account",
|
|
2911
|
+
type: "address",
|
|
2912
|
+
internalType: "address"
|
|
2913
|
+
},
|
|
2914
|
+
{
|
|
2915
|
+
name: "apps",
|
|
2916
|
+
type: "address[]",
|
|
2917
|
+
internalType: "contractIApp[]"
|
|
2918
|
+
}
|
|
2919
|
+
],
|
|
2920
|
+
outputs: [],
|
|
2921
|
+
stateMutability: "nonpayable"
|
|
2922
|
+
},
|
|
2923
|
+
{
|
|
2924
|
+
type: "function",
|
|
2925
|
+
name: "terminateApp",
|
|
2926
|
+
inputs: [
|
|
2927
|
+
{
|
|
2928
|
+
name: "app",
|
|
2929
|
+
type: "address",
|
|
2930
|
+
internalType: "contractIApp"
|
|
2931
|
+
}
|
|
2932
|
+
],
|
|
2933
|
+
outputs: [],
|
|
2934
|
+
stateMutability: "nonpayable"
|
|
2935
|
+
},
|
|
2936
|
+
{
|
|
2937
|
+
type: "function",
|
|
2938
|
+
name: "terminateAppByAdmin",
|
|
2939
|
+
inputs: [
|
|
2940
|
+
{
|
|
2941
|
+
name: "app",
|
|
2942
|
+
type: "address",
|
|
2943
|
+
internalType: "contractIApp"
|
|
2944
|
+
}
|
|
2945
|
+
],
|
|
2946
|
+
outputs: [],
|
|
2947
|
+
stateMutability: "nonpayable"
|
|
2948
|
+
},
|
|
2949
|
+
{
|
|
2950
|
+
type: "function",
|
|
2951
|
+
name: "updateAppMetadataURI",
|
|
2952
|
+
inputs: [
|
|
2953
|
+
{
|
|
2954
|
+
name: "app",
|
|
2955
|
+
type: "address",
|
|
2956
|
+
internalType: "contractIApp"
|
|
2957
|
+
},
|
|
2958
|
+
{
|
|
2959
|
+
name: "metadataURI",
|
|
2960
|
+
type: "string",
|
|
2961
|
+
internalType: "string"
|
|
2962
|
+
}
|
|
2963
|
+
],
|
|
2964
|
+
outputs: [],
|
|
2965
|
+
stateMutability: "nonpayable"
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
type: "function",
|
|
2969
|
+
name: "upgradeApp",
|
|
2970
|
+
inputs: [
|
|
2971
|
+
{
|
|
2972
|
+
name: "app",
|
|
2973
|
+
type: "address",
|
|
2974
|
+
internalType: "contractIApp"
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
name: "release",
|
|
2978
|
+
type: "tuple",
|
|
2979
|
+
internalType: "structIAppController.Release",
|
|
2980
|
+
components: [
|
|
2981
|
+
{
|
|
2982
|
+
name: "rmsRelease",
|
|
2983
|
+
type: "tuple",
|
|
2984
|
+
internalType: "structIReleaseManagerTypes.Release",
|
|
2985
|
+
components: [
|
|
2986
|
+
{
|
|
2987
|
+
name: "artifacts",
|
|
2988
|
+
type: "tuple[]",
|
|
2989
|
+
internalType: "structIReleaseManagerTypes.Artifact[]",
|
|
2990
|
+
components: [
|
|
2991
|
+
{
|
|
2992
|
+
name: "digest",
|
|
2993
|
+
type: "bytes32",
|
|
2994
|
+
internalType: "bytes32"
|
|
2995
|
+
},
|
|
2996
|
+
{
|
|
2997
|
+
name: "registry",
|
|
2998
|
+
type: "string",
|
|
2999
|
+
internalType: "string"
|
|
3000
|
+
}
|
|
3001
|
+
]
|
|
3002
|
+
},
|
|
3003
|
+
{
|
|
3004
|
+
name: "upgradeByTime",
|
|
3005
|
+
type: "uint32",
|
|
3006
|
+
internalType: "uint32"
|
|
3007
|
+
}
|
|
3008
|
+
]
|
|
3009
|
+
},
|
|
3010
|
+
{
|
|
3011
|
+
name: "publicEnv",
|
|
3012
|
+
type: "bytes",
|
|
3013
|
+
internalType: "bytes"
|
|
3014
|
+
},
|
|
3015
|
+
{
|
|
3016
|
+
name: "encryptedEnv",
|
|
3017
|
+
type: "bytes",
|
|
3018
|
+
internalType: "bytes"
|
|
3019
|
+
}
|
|
3020
|
+
]
|
|
3021
|
+
}
|
|
3022
|
+
],
|
|
3023
|
+
outputs: [
|
|
3024
|
+
{
|
|
3025
|
+
name: "",
|
|
3026
|
+
type: "uint256",
|
|
3027
|
+
internalType: "uint256"
|
|
3028
|
+
}
|
|
3029
|
+
],
|
|
3030
|
+
stateMutability: "nonpayable"
|
|
3031
|
+
},
|
|
3032
|
+
{
|
|
3033
|
+
type: "function",
|
|
3034
|
+
name: "version",
|
|
3035
|
+
inputs: [],
|
|
3036
|
+
outputs: [
|
|
3037
|
+
{
|
|
3038
|
+
name: "",
|
|
3039
|
+
type: "string",
|
|
3040
|
+
internalType: "string"
|
|
3041
|
+
}
|
|
3042
|
+
],
|
|
3043
|
+
stateMutability: "view"
|
|
3044
|
+
},
|
|
3045
|
+
{
|
|
3046
|
+
type: "event",
|
|
3047
|
+
name: "AppCreated",
|
|
3048
|
+
inputs: [
|
|
3049
|
+
{
|
|
3050
|
+
name: "creator",
|
|
3051
|
+
type: "address",
|
|
3052
|
+
indexed: true,
|
|
3053
|
+
internalType: "address"
|
|
3054
|
+
},
|
|
3055
|
+
{
|
|
3056
|
+
name: "app",
|
|
3057
|
+
type: "address",
|
|
3058
|
+
indexed: true,
|
|
3059
|
+
internalType: "contractIApp"
|
|
3060
|
+
},
|
|
3061
|
+
{
|
|
3062
|
+
name: "operatorSetId",
|
|
3063
|
+
type: "uint32",
|
|
3064
|
+
indexed: false,
|
|
3065
|
+
internalType: "uint32"
|
|
3066
|
+
}
|
|
3067
|
+
],
|
|
3068
|
+
anonymous: false
|
|
3069
|
+
},
|
|
3070
|
+
{
|
|
3071
|
+
type: "event",
|
|
3072
|
+
name: "AppMetadataURIUpdated",
|
|
3073
|
+
inputs: [
|
|
3074
|
+
{
|
|
3075
|
+
name: "app",
|
|
3076
|
+
type: "address",
|
|
3077
|
+
indexed: true,
|
|
3078
|
+
internalType: "contractIApp"
|
|
3079
|
+
},
|
|
3080
|
+
{
|
|
3081
|
+
name: "metadataURI",
|
|
3082
|
+
type: "string",
|
|
3083
|
+
indexed: false,
|
|
3084
|
+
internalType: "string"
|
|
3085
|
+
}
|
|
3086
|
+
],
|
|
3087
|
+
anonymous: false
|
|
3088
|
+
},
|
|
3089
|
+
{
|
|
3090
|
+
type: "event",
|
|
3091
|
+
name: "AppStarted",
|
|
3092
|
+
inputs: [
|
|
3093
|
+
{
|
|
3094
|
+
name: "app",
|
|
3095
|
+
type: "address",
|
|
3096
|
+
indexed: true,
|
|
3097
|
+
internalType: "contractIApp"
|
|
3098
|
+
}
|
|
3099
|
+
],
|
|
3100
|
+
anonymous: false
|
|
3101
|
+
},
|
|
3102
|
+
{
|
|
3103
|
+
type: "event",
|
|
3104
|
+
name: "AppStopped",
|
|
3105
|
+
inputs: [
|
|
3106
|
+
{
|
|
3107
|
+
name: "app",
|
|
3108
|
+
type: "address",
|
|
3109
|
+
indexed: true,
|
|
3110
|
+
internalType: "contractIApp"
|
|
3111
|
+
}
|
|
3112
|
+
],
|
|
3113
|
+
anonymous: false
|
|
3114
|
+
},
|
|
3115
|
+
{
|
|
3116
|
+
type: "event",
|
|
3117
|
+
name: "AppSuspended",
|
|
3118
|
+
inputs: [
|
|
3119
|
+
{
|
|
3120
|
+
name: "app",
|
|
3121
|
+
type: "address",
|
|
3122
|
+
indexed: true,
|
|
3123
|
+
internalType: "contractIApp"
|
|
3124
|
+
}
|
|
3125
|
+
],
|
|
3126
|
+
anonymous: false
|
|
3127
|
+
},
|
|
3128
|
+
{
|
|
3129
|
+
type: "event",
|
|
3130
|
+
name: "AppTerminated",
|
|
3131
|
+
inputs: [
|
|
3132
|
+
{
|
|
3133
|
+
name: "app",
|
|
3134
|
+
type: "address",
|
|
3135
|
+
indexed: true,
|
|
3136
|
+
internalType: "contractIApp"
|
|
3137
|
+
}
|
|
3138
|
+
],
|
|
3139
|
+
anonymous: false
|
|
3140
|
+
},
|
|
3141
|
+
{
|
|
3142
|
+
type: "event",
|
|
3143
|
+
name: "AppTerminatedByAdmin",
|
|
3144
|
+
inputs: [
|
|
3145
|
+
{
|
|
3146
|
+
name: "app",
|
|
3147
|
+
type: "address",
|
|
3148
|
+
indexed: true,
|
|
3149
|
+
internalType: "contractIApp"
|
|
3150
|
+
}
|
|
3151
|
+
],
|
|
3152
|
+
anonymous: false
|
|
3153
|
+
},
|
|
3154
|
+
{
|
|
3155
|
+
type: "event",
|
|
3156
|
+
name: "AppUpgraded",
|
|
3157
|
+
inputs: [
|
|
3158
|
+
{
|
|
3159
|
+
name: "app",
|
|
3160
|
+
type: "address",
|
|
3161
|
+
indexed: true,
|
|
3162
|
+
internalType: "contractIApp"
|
|
3163
|
+
},
|
|
3164
|
+
{
|
|
3165
|
+
name: "rmsReleaseId",
|
|
3166
|
+
type: "uint256",
|
|
3167
|
+
indexed: false,
|
|
3168
|
+
internalType: "uint256"
|
|
3169
|
+
},
|
|
3170
|
+
{
|
|
3171
|
+
name: "release",
|
|
3172
|
+
type: "tuple",
|
|
3173
|
+
indexed: false,
|
|
3174
|
+
internalType: "structIAppController.Release",
|
|
3175
|
+
components: [
|
|
3176
|
+
{
|
|
3177
|
+
name: "rmsRelease",
|
|
3178
|
+
type: "tuple",
|
|
3179
|
+
internalType: "structIReleaseManagerTypes.Release",
|
|
3180
|
+
components: [
|
|
3181
|
+
{
|
|
3182
|
+
name: "artifacts",
|
|
3183
|
+
type: "tuple[]",
|
|
3184
|
+
internalType: "structIReleaseManagerTypes.Artifact[]",
|
|
3185
|
+
components: [
|
|
3186
|
+
{
|
|
3187
|
+
name: "digest",
|
|
3188
|
+
type: "bytes32",
|
|
3189
|
+
internalType: "bytes32"
|
|
3190
|
+
},
|
|
3191
|
+
{
|
|
3192
|
+
name: "registry",
|
|
3193
|
+
type: "string",
|
|
3194
|
+
internalType: "string"
|
|
3195
|
+
}
|
|
3196
|
+
]
|
|
3197
|
+
},
|
|
3198
|
+
{
|
|
3199
|
+
name: "upgradeByTime",
|
|
3200
|
+
type: "uint32",
|
|
3201
|
+
internalType: "uint32"
|
|
3202
|
+
}
|
|
3203
|
+
]
|
|
3204
|
+
},
|
|
3205
|
+
{
|
|
3206
|
+
name: "publicEnv",
|
|
3207
|
+
type: "bytes",
|
|
3208
|
+
internalType: "bytes"
|
|
3209
|
+
},
|
|
3210
|
+
{
|
|
3211
|
+
name: "encryptedEnv",
|
|
3212
|
+
type: "bytes",
|
|
3213
|
+
internalType: "bytes"
|
|
3214
|
+
}
|
|
3215
|
+
]
|
|
3216
|
+
}
|
|
3217
|
+
],
|
|
3218
|
+
anonymous: false
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
type: "event",
|
|
3222
|
+
name: "GlobalMaxActiveAppsSet",
|
|
3223
|
+
inputs: [
|
|
3224
|
+
{
|
|
3225
|
+
name: "limit",
|
|
3226
|
+
type: "uint32",
|
|
3227
|
+
indexed: false,
|
|
3228
|
+
internalType: "uint32"
|
|
3229
|
+
}
|
|
3230
|
+
],
|
|
3231
|
+
anonymous: false
|
|
3232
|
+
},
|
|
3233
|
+
{
|
|
3234
|
+
type: "event",
|
|
3235
|
+
name: "Initialized",
|
|
3236
|
+
inputs: [
|
|
3237
|
+
{
|
|
3238
|
+
name: "version",
|
|
3239
|
+
type: "uint8",
|
|
3240
|
+
indexed: false,
|
|
3241
|
+
internalType: "uint8"
|
|
3242
|
+
}
|
|
3243
|
+
],
|
|
3244
|
+
anonymous: false
|
|
3245
|
+
},
|
|
3246
|
+
{
|
|
3247
|
+
type: "event",
|
|
3248
|
+
name: "MaxActiveAppsSet",
|
|
3249
|
+
inputs: [
|
|
3250
|
+
{
|
|
3251
|
+
name: "user",
|
|
3252
|
+
type: "address",
|
|
3253
|
+
indexed: true,
|
|
3254
|
+
internalType: "address"
|
|
3255
|
+
},
|
|
3256
|
+
{
|
|
3257
|
+
name: "limit",
|
|
3258
|
+
type: "uint32",
|
|
3259
|
+
indexed: false,
|
|
3260
|
+
internalType: "uint32"
|
|
3261
|
+
}
|
|
3262
|
+
],
|
|
3263
|
+
anonymous: false
|
|
3264
|
+
},
|
|
3265
|
+
{
|
|
3266
|
+
type: "error",
|
|
3267
|
+
name: "AccountHasActiveApps",
|
|
3268
|
+
inputs: []
|
|
3269
|
+
},
|
|
3270
|
+
{
|
|
3271
|
+
type: "error",
|
|
3272
|
+
name: "AppAlreadyExists",
|
|
3273
|
+
inputs: []
|
|
3274
|
+
},
|
|
3275
|
+
{
|
|
3276
|
+
type: "error",
|
|
3277
|
+
name: "AppDoesNotExist",
|
|
3278
|
+
inputs: []
|
|
3279
|
+
},
|
|
3280
|
+
{
|
|
3281
|
+
type: "error",
|
|
3282
|
+
name: "GlobalMaxActiveAppsExceeded",
|
|
3283
|
+
inputs: []
|
|
3284
|
+
},
|
|
3285
|
+
{
|
|
3286
|
+
type: "error",
|
|
3287
|
+
name: "InvalidAppStatus",
|
|
3288
|
+
inputs: []
|
|
3289
|
+
},
|
|
3290
|
+
{
|
|
3291
|
+
type: "error",
|
|
3292
|
+
name: "InvalidPermissions",
|
|
3293
|
+
inputs: []
|
|
3294
|
+
},
|
|
3295
|
+
{
|
|
3296
|
+
type: "error",
|
|
3297
|
+
name: "InvalidReleaseMetadataURI",
|
|
3298
|
+
inputs: []
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
type: "error",
|
|
3302
|
+
name: "InvalidShortString",
|
|
3303
|
+
inputs: []
|
|
3304
|
+
},
|
|
3305
|
+
{
|
|
3306
|
+
type: "error",
|
|
3307
|
+
name: "InvalidSignature",
|
|
3308
|
+
inputs: []
|
|
3309
|
+
},
|
|
3310
|
+
{
|
|
3311
|
+
type: "error",
|
|
3312
|
+
name: "MaxActiveAppsExceeded",
|
|
3313
|
+
inputs: []
|
|
3314
|
+
},
|
|
3315
|
+
{
|
|
3316
|
+
type: "error",
|
|
3317
|
+
name: "MoreThanOneArtifact",
|
|
3318
|
+
inputs: []
|
|
3319
|
+
},
|
|
3320
|
+
{
|
|
3321
|
+
type: "error",
|
|
3322
|
+
name: "SignatureExpired",
|
|
3323
|
+
inputs: []
|
|
3324
|
+
},
|
|
3325
|
+
{
|
|
3326
|
+
type: "error",
|
|
3327
|
+
name: "StringTooLong",
|
|
3328
|
+
inputs: [
|
|
3329
|
+
{
|
|
3330
|
+
name: "str",
|
|
3331
|
+
type: "string",
|
|
3332
|
+
internalType: "string"
|
|
3333
|
+
}
|
|
3334
|
+
]
|
|
3335
|
+
}
|
|
3336
|
+
];
|
|
3337
|
+
|
|
3338
|
+
// src/client/common/abis/PermissionController.json
|
|
3339
|
+
var PermissionController_default = [
|
|
3340
|
+
{
|
|
3341
|
+
type: "function",
|
|
3342
|
+
name: "acceptAdmin",
|
|
3343
|
+
inputs: [
|
|
3344
|
+
{
|
|
3345
|
+
name: "account",
|
|
3346
|
+
type: "address",
|
|
3347
|
+
internalType: "address"
|
|
3348
|
+
}
|
|
3349
|
+
],
|
|
3350
|
+
outputs: [],
|
|
3351
|
+
stateMutability: "nonpayable"
|
|
3352
|
+
},
|
|
3353
|
+
{
|
|
3354
|
+
type: "function",
|
|
3355
|
+
name: "addPendingAdmin",
|
|
3356
|
+
inputs: [
|
|
3357
|
+
{
|
|
3358
|
+
name: "account",
|
|
3359
|
+
type: "address",
|
|
3360
|
+
internalType: "address"
|
|
3361
|
+
},
|
|
3362
|
+
{
|
|
3363
|
+
name: "admin",
|
|
3364
|
+
type: "address",
|
|
3365
|
+
internalType: "address"
|
|
3366
|
+
}
|
|
3367
|
+
],
|
|
3368
|
+
outputs: [],
|
|
3369
|
+
stateMutability: "nonpayable"
|
|
3370
|
+
},
|
|
3371
|
+
{
|
|
3372
|
+
type: "function",
|
|
3373
|
+
name: "canCall",
|
|
3374
|
+
inputs: [
|
|
3375
|
+
{
|
|
3376
|
+
name: "account",
|
|
3377
|
+
type: "address",
|
|
3378
|
+
internalType: "address"
|
|
3379
|
+
},
|
|
3380
|
+
{
|
|
3381
|
+
name: "caller",
|
|
3382
|
+
type: "address",
|
|
3383
|
+
internalType: "address"
|
|
3384
|
+
},
|
|
3385
|
+
{
|
|
3386
|
+
name: "target",
|
|
3387
|
+
type: "address",
|
|
3388
|
+
internalType: "address"
|
|
3389
|
+
},
|
|
3390
|
+
{
|
|
3391
|
+
name: "selector",
|
|
3392
|
+
type: "bytes4",
|
|
3393
|
+
internalType: "bytes4"
|
|
3394
|
+
}
|
|
3395
|
+
],
|
|
3396
|
+
outputs: [
|
|
3397
|
+
{
|
|
3398
|
+
name: "",
|
|
3399
|
+
type: "bool",
|
|
3400
|
+
internalType: "bool"
|
|
3401
|
+
}
|
|
3402
|
+
],
|
|
3403
|
+
stateMutability: "nonpayable"
|
|
3404
|
+
},
|
|
3405
|
+
{
|
|
3406
|
+
type: "function",
|
|
3407
|
+
name: "getAdmins",
|
|
3408
|
+
inputs: [
|
|
3409
|
+
{
|
|
3410
|
+
name: "account",
|
|
3411
|
+
type: "address",
|
|
3412
|
+
internalType: "address"
|
|
3413
|
+
}
|
|
3414
|
+
],
|
|
3415
|
+
outputs: [
|
|
3416
|
+
{
|
|
3417
|
+
name: "",
|
|
3418
|
+
type: "address[]",
|
|
3419
|
+
internalType: "address[]"
|
|
3420
|
+
}
|
|
3421
|
+
],
|
|
3422
|
+
stateMutability: "view"
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
type: "function",
|
|
3426
|
+
name: "getAppointeePermissions",
|
|
3427
|
+
inputs: [
|
|
3428
|
+
{
|
|
3429
|
+
name: "account",
|
|
3430
|
+
type: "address",
|
|
3431
|
+
internalType: "address"
|
|
3432
|
+
},
|
|
3433
|
+
{
|
|
3434
|
+
name: "appointee",
|
|
3435
|
+
type: "address",
|
|
3436
|
+
internalType: "address"
|
|
3437
|
+
}
|
|
3438
|
+
],
|
|
3439
|
+
outputs: [
|
|
3440
|
+
{
|
|
3441
|
+
name: "",
|
|
3442
|
+
type: "address[]",
|
|
3443
|
+
internalType: "address[]"
|
|
3444
|
+
},
|
|
3445
|
+
{
|
|
3446
|
+
name: "",
|
|
3447
|
+
type: "bytes4[]",
|
|
3448
|
+
internalType: "bytes4[]"
|
|
3449
|
+
}
|
|
3450
|
+
],
|
|
3451
|
+
stateMutability: "nonpayable"
|
|
3452
|
+
},
|
|
3453
|
+
{
|
|
3454
|
+
type: "function",
|
|
3455
|
+
name: "getAppointees",
|
|
3456
|
+
inputs: [
|
|
3457
|
+
{
|
|
3458
|
+
name: "account",
|
|
3459
|
+
type: "address",
|
|
3460
|
+
internalType: "address"
|
|
3461
|
+
},
|
|
3462
|
+
{
|
|
3463
|
+
name: "target",
|
|
3464
|
+
type: "address",
|
|
3465
|
+
internalType: "address"
|
|
3466
|
+
},
|
|
3467
|
+
{
|
|
3468
|
+
name: "selector",
|
|
3469
|
+
type: "bytes4",
|
|
3470
|
+
internalType: "bytes4"
|
|
3471
|
+
}
|
|
3472
|
+
],
|
|
3473
|
+
outputs: [
|
|
3474
|
+
{
|
|
3475
|
+
name: "",
|
|
3476
|
+
type: "address[]",
|
|
3477
|
+
internalType: "address[]"
|
|
3478
|
+
}
|
|
3479
|
+
],
|
|
3480
|
+
stateMutability: "nonpayable"
|
|
3481
|
+
},
|
|
3482
|
+
{
|
|
3483
|
+
type: "function",
|
|
3484
|
+
name: "getPendingAdmins",
|
|
3485
|
+
inputs: [
|
|
3486
|
+
{
|
|
3487
|
+
name: "account",
|
|
3488
|
+
type: "address",
|
|
3489
|
+
internalType: "address"
|
|
3490
|
+
}
|
|
3491
|
+
],
|
|
3492
|
+
outputs: [
|
|
3493
|
+
{
|
|
3494
|
+
name: "",
|
|
3495
|
+
type: "address[]",
|
|
3496
|
+
internalType: "address[]"
|
|
3497
|
+
}
|
|
3498
|
+
],
|
|
3499
|
+
stateMutability: "view"
|
|
3500
|
+
},
|
|
3501
|
+
{
|
|
3502
|
+
type: "function",
|
|
3503
|
+
name: "isAdmin",
|
|
3504
|
+
inputs: [
|
|
3505
|
+
{
|
|
3506
|
+
name: "account",
|
|
3507
|
+
type: "address",
|
|
3508
|
+
internalType: "address"
|
|
3509
|
+
},
|
|
3510
|
+
{
|
|
3511
|
+
name: "caller",
|
|
3512
|
+
type: "address",
|
|
3513
|
+
internalType: "address"
|
|
3514
|
+
}
|
|
3515
|
+
],
|
|
3516
|
+
outputs: [
|
|
3517
|
+
{
|
|
3518
|
+
name: "",
|
|
3519
|
+
type: "bool",
|
|
3520
|
+
internalType: "bool"
|
|
3521
|
+
}
|
|
3522
|
+
],
|
|
3523
|
+
stateMutability: "view"
|
|
3524
|
+
},
|
|
3525
|
+
{
|
|
3526
|
+
type: "function",
|
|
3527
|
+
name: "isPendingAdmin",
|
|
3528
|
+
inputs: [
|
|
3529
|
+
{
|
|
3530
|
+
name: "account",
|
|
3531
|
+
type: "address",
|
|
3532
|
+
internalType: "address"
|
|
3533
|
+
},
|
|
3534
|
+
{
|
|
3535
|
+
name: "pendingAdmin",
|
|
3536
|
+
type: "address",
|
|
3537
|
+
internalType: "address"
|
|
3538
|
+
}
|
|
3539
|
+
],
|
|
3540
|
+
outputs: [
|
|
3541
|
+
{
|
|
3542
|
+
name: "",
|
|
3543
|
+
type: "bool",
|
|
3544
|
+
internalType: "bool"
|
|
3545
|
+
}
|
|
3546
|
+
],
|
|
3547
|
+
stateMutability: "view"
|
|
3548
|
+
},
|
|
3549
|
+
{
|
|
3550
|
+
type: "function",
|
|
3551
|
+
name: "removeAdmin",
|
|
3552
|
+
inputs: [
|
|
3553
|
+
{
|
|
3554
|
+
name: "account",
|
|
3555
|
+
type: "address",
|
|
3556
|
+
internalType: "address"
|
|
3557
|
+
},
|
|
3558
|
+
{
|
|
3559
|
+
name: "admin",
|
|
3560
|
+
type: "address",
|
|
3561
|
+
internalType: "address"
|
|
3562
|
+
}
|
|
3563
|
+
],
|
|
3564
|
+
outputs: [],
|
|
3565
|
+
stateMutability: "nonpayable"
|
|
3566
|
+
},
|
|
3567
|
+
{
|
|
3568
|
+
type: "function",
|
|
3569
|
+
name: "removeAppointee",
|
|
3570
|
+
inputs: [
|
|
3571
|
+
{
|
|
3572
|
+
name: "account",
|
|
3573
|
+
type: "address",
|
|
3574
|
+
internalType: "address"
|
|
3575
|
+
},
|
|
3576
|
+
{
|
|
3577
|
+
name: "appointee",
|
|
3578
|
+
type: "address",
|
|
3579
|
+
internalType: "address"
|
|
3580
|
+
},
|
|
3581
|
+
{
|
|
3582
|
+
name: "target",
|
|
3583
|
+
type: "address",
|
|
3584
|
+
internalType: "address"
|
|
3585
|
+
},
|
|
3586
|
+
{
|
|
3587
|
+
name: "selector",
|
|
3588
|
+
type: "bytes4",
|
|
3589
|
+
internalType: "bytes4"
|
|
3590
|
+
}
|
|
3591
|
+
],
|
|
3592
|
+
outputs: [],
|
|
3593
|
+
stateMutability: "nonpayable"
|
|
3594
|
+
},
|
|
3595
|
+
{
|
|
3596
|
+
type: "function",
|
|
3597
|
+
name: "removePendingAdmin",
|
|
3598
|
+
inputs: [
|
|
3599
|
+
{
|
|
3600
|
+
name: "account",
|
|
3601
|
+
type: "address",
|
|
3602
|
+
internalType: "address"
|
|
3603
|
+
},
|
|
3604
|
+
{
|
|
3605
|
+
name: "admin",
|
|
3606
|
+
type: "address",
|
|
3607
|
+
internalType: "address"
|
|
3608
|
+
}
|
|
3609
|
+
],
|
|
3610
|
+
outputs: [],
|
|
3611
|
+
stateMutability: "nonpayable"
|
|
3612
|
+
},
|
|
3613
|
+
{
|
|
3614
|
+
type: "function",
|
|
3615
|
+
name: "setAppointee",
|
|
3616
|
+
inputs: [
|
|
3617
|
+
{
|
|
3618
|
+
name: "account",
|
|
3619
|
+
type: "address",
|
|
3620
|
+
internalType: "address"
|
|
3621
|
+
},
|
|
3622
|
+
{
|
|
3623
|
+
name: "appointee",
|
|
3624
|
+
type: "address",
|
|
3625
|
+
internalType: "address"
|
|
3626
|
+
},
|
|
3627
|
+
{
|
|
3628
|
+
name: "target",
|
|
3629
|
+
type: "address",
|
|
3630
|
+
internalType: "address"
|
|
3631
|
+
},
|
|
3632
|
+
{
|
|
3633
|
+
name: "selector",
|
|
3634
|
+
type: "bytes4",
|
|
3635
|
+
internalType: "bytes4"
|
|
3636
|
+
}
|
|
3637
|
+
],
|
|
3638
|
+
outputs: [],
|
|
3639
|
+
stateMutability: "nonpayable"
|
|
3640
|
+
},
|
|
3641
|
+
{
|
|
3642
|
+
type: "function",
|
|
3643
|
+
name: "version",
|
|
3644
|
+
inputs: [],
|
|
3645
|
+
outputs: [
|
|
3646
|
+
{
|
|
3647
|
+
name: "",
|
|
3648
|
+
type: "string",
|
|
3649
|
+
internalType: "string"
|
|
3650
|
+
}
|
|
3651
|
+
],
|
|
3652
|
+
stateMutability: "view"
|
|
3653
|
+
},
|
|
3654
|
+
{
|
|
3655
|
+
type: "event",
|
|
3656
|
+
name: "AdminRemoved",
|
|
3657
|
+
inputs: [
|
|
3658
|
+
{
|
|
3659
|
+
name: "account",
|
|
3660
|
+
type: "address",
|
|
3661
|
+
indexed: true,
|
|
3662
|
+
internalType: "address"
|
|
3663
|
+
},
|
|
3664
|
+
{
|
|
3665
|
+
name: "admin",
|
|
3666
|
+
type: "address",
|
|
3667
|
+
indexed: false,
|
|
3668
|
+
internalType: "address"
|
|
3669
|
+
}
|
|
3670
|
+
],
|
|
3671
|
+
anonymous: false
|
|
3672
|
+
},
|
|
3673
|
+
{
|
|
3674
|
+
type: "event",
|
|
3675
|
+
name: "AdminSet",
|
|
3676
|
+
inputs: [
|
|
3677
|
+
{
|
|
3678
|
+
name: "account",
|
|
3679
|
+
type: "address",
|
|
3680
|
+
indexed: true,
|
|
3681
|
+
internalType: "address"
|
|
3682
|
+
},
|
|
3683
|
+
{
|
|
3684
|
+
name: "admin",
|
|
3685
|
+
type: "address",
|
|
3686
|
+
indexed: false,
|
|
3687
|
+
internalType: "address"
|
|
3688
|
+
}
|
|
3689
|
+
],
|
|
3690
|
+
anonymous: false
|
|
3691
|
+
},
|
|
3692
|
+
{
|
|
3693
|
+
type: "event",
|
|
3694
|
+
name: "AppointeeRemoved",
|
|
3695
|
+
inputs: [
|
|
3696
|
+
{
|
|
3697
|
+
name: "account",
|
|
3698
|
+
type: "address",
|
|
3699
|
+
indexed: true,
|
|
3700
|
+
internalType: "address"
|
|
3701
|
+
},
|
|
3702
|
+
{
|
|
3703
|
+
name: "appointee",
|
|
3704
|
+
type: "address",
|
|
3705
|
+
indexed: true,
|
|
3706
|
+
internalType: "address"
|
|
3707
|
+
},
|
|
3708
|
+
{
|
|
3709
|
+
name: "target",
|
|
3710
|
+
type: "address",
|
|
3711
|
+
indexed: false,
|
|
3712
|
+
internalType: "address"
|
|
3713
|
+
},
|
|
3714
|
+
{
|
|
3715
|
+
name: "selector",
|
|
3716
|
+
type: "bytes4",
|
|
3717
|
+
indexed: false,
|
|
3718
|
+
internalType: "bytes4"
|
|
3719
|
+
}
|
|
3720
|
+
],
|
|
3721
|
+
anonymous: false
|
|
3722
|
+
},
|
|
3723
|
+
{
|
|
3724
|
+
type: "event",
|
|
3725
|
+
name: "AppointeeSet",
|
|
3726
|
+
inputs: [
|
|
3727
|
+
{
|
|
3728
|
+
name: "account",
|
|
3729
|
+
type: "address",
|
|
3730
|
+
indexed: true,
|
|
3731
|
+
internalType: "address"
|
|
3732
|
+
},
|
|
3733
|
+
{
|
|
3734
|
+
name: "appointee",
|
|
3735
|
+
type: "address",
|
|
3736
|
+
indexed: true,
|
|
3737
|
+
internalType: "address"
|
|
3738
|
+
},
|
|
3739
|
+
{
|
|
3740
|
+
name: "target",
|
|
3741
|
+
type: "address",
|
|
3742
|
+
indexed: false,
|
|
3743
|
+
internalType: "address"
|
|
3744
|
+
},
|
|
3745
|
+
{
|
|
3746
|
+
name: "selector",
|
|
3747
|
+
type: "bytes4",
|
|
3748
|
+
indexed: false,
|
|
3749
|
+
internalType: "bytes4"
|
|
3750
|
+
}
|
|
3751
|
+
],
|
|
3752
|
+
anonymous: false
|
|
3753
|
+
},
|
|
3754
|
+
{
|
|
3755
|
+
type: "event",
|
|
3756
|
+
name: "PendingAdminAdded",
|
|
3757
|
+
inputs: [
|
|
3758
|
+
{
|
|
3759
|
+
name: "account",
|
|
3760
|
+
type: "address",
|
|
3761
|
+
indexed: true,
|
|
3762
|
+
internalType: "address"
|
|
3763
|
+
},
|
|
3764
|
+
{
|
|
3765
|
+
name: "admin",
|
|
3766
|
+
type: "address",
|
|
3767
|
+
indexed: false,
|
|
3768
|
+
internalType: "address"
|
|
3769
|
+
}
|
|
3770
|
+
],
|
|
3771
|
+
anonymous: false
|
|
3772
|
+
},
|
|
3773
|
+
{
|
|
3774
|
+
type: "event",
|
|
3775
|
+
name: "PendingAdminRemoved",
|
|
3776
|
+
inputs: [
|
|
3777
|
+
{
|
|
3778
|
+
name: "account",
|
|
3779
|
+
type: "address",
|
|
3780
|
+
indexed: true,
|
|
3781
|
+
internalType: "address"
|
|
3782
|
+
},
|
|
3783
|
+
{
|
|
3784
|
+
name: "admin",
|
|
3785
|
+
type: "address",
|
|
3786
|
+
indexed: false,
|
|
3787
|
+
internalType: "address"
|
|
3788
|
+
}
|
|
3789
|
+
],
|
|
3790
|
+
anonymous: false
|
|
3791
|
+
},
|
|
3792
|
+
{
|
|
3793
|
+
type: "error",
|
|
3794
|
+
name: "AdminAlreadyPending",
|
|
3795
|
+
inputs: []
|
|
3796
|
+
},
|
|
3797
|
+
{
|
|
3798
|
+
type: "error",
|
|
3799
|
+
name: "AdminAlreadySet",
|
|
3800
|
+
inputs: []
|
|
3801
|
+
},
|
|
3802
|
+
{
|
|
3803
|
+
type: "error",
|
|
3804
|
+
name: "AdminNotPending",
|
|
3805
|
+
inputs: []
|
|
3806
|
+
},
|
|
3807
|
+
{
|
|
3808
|
+
type: "error",
|
|
3809
|
+
name: "AdminNotSet",
|
|
3810
|
+
inputs: []
|
|
3811
|
+
},
|
|
3812
|
+
{
|
|
3813
|
+
type: "error",
|
|
3814
|
+
name: "AppointeeAlreadySet",
|
|
3815
|
+
inputs: []
|
|
3816
|
+
},
|
|
3817
|
+
{
|
|
3818
|
+
type: "error",
|
|
3819
|
+
name: "AppointeeNotSet",
|
|
3820
|
+
inputs: []
|
|
3821
|
+
},
|
|
3822
|
+
{
|
|
3823
|
+
type: "error",
|
|
3824
|
+
name: "CannotHaveZeroAdmins",
|
|
3825
|
+
inputs: []
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
type: "error",
|
|
3829
|
+
name: "NotAdmin",
|
|
3830
|
+
inputs: []
|
|
3831
|
+
}
|
|
3832
|
+
];
|
|
3833
|
+
|
|
3834
|
+
// src/client/common/contract/caller.ts
|
|
3835
|
+
function formatETH(wei) {
|
|
3836
|
+
const eth = Number(wei) / 1e18;
|
|
3837
|
+
const costStr = eth.toFixed(6);
|
|
3838
|
+
const trimmed = costStr.replace(/\.?0+$/, "");
|
|
3839
|
+
if (trimmed === "0" && wei > 0n) {
|
|
3840
|
+
return "<0.000001";
|
|
3841
|
+
}
|
|
3842
|
+
return trimmed;
|
|
3843
|
+
}
|
|
3844
|
+
async function estimateTransactionGas(options) {
|
|
3845
|
+
const { publicClient, from, to, data, value = 0n } = options;
|
|
3846
|
+
const fees = await publicClient.estimateFeesPerGas();
|
|
3847
|
+
const gasLimit = await publicClient.estimateGas({
|
|
3848
|
+
account: from,
|
|
3849
|
+
to,
|
|
3850
|
+
data,
|
|
3851
|
+
value
|
|
3852
|
+
});
|
|
3853
|
+
const maxFeePerGas = fees.maxFeePerGas;
|
|
3854
|
+
const maxPriorityFeePerGas = fees.maxPriorityFeePerGas;
|
|
3855
|
+
const maxCostWei = gasLimit * maxFeePerGas;
|
|
3856
|
+
const maxCostEth = formatETH(maxCostWei);
|
|
3857
|
+
return {
|
|
3858
|
+
gasLimit,
|
|
3859
|
+
maxFeePerGas,
|
|
3860
|
+
maxPriorityFeePerGas,
|
|
3861
|
+
maxCostWei,
|
|
3862
|
+
maxCostEth
|
|
3863
|
+
};
|
|
3864
|
+
}
|
|
3865
|
+
async function calculateAppID(options) {
|
|
3866
|
+
const { publicClient, environmentConfig, ownerAddress, salt } = options;
|
|
3867
|
+
const saltHexString = bytesToHex(salt).slice(2);
|
|
3868
|
+
const paddedSaltHex = saltHexString.padStart(64, "0");
|
|
3869
|
+
const saltHex = `0x${paddedSaltHex}`;
|
|
3870
|
+
const appID = await publicClient.readContract({
|
|
3871
|
+
address: environmentConfig.appControllerAddress,
|
|
3872
|
+
abi: AppController_default,
|
|
3873
|
+
functionName: "calculateAppId",
|
|
3874
|
+
args: [ownerAddress, saltHex]
|
|
3875
|
+
});
|
|
3876
|
+
return appID;
|
|
3877
|
+
}
|
|
3878
|
+
async function prepareDeployBatch(options, logger = noopLogger) {
|
|
3879
|
+
const { walletClient, publicClient, environmentConfig, salt, release, publicLogs } = options;
|
|
3880
|
+
const account = walletClient.account;
|
|
3881
|
+
if (!account) {
|
|
3882
|
+
throw new Error("WalletClient must have an account attached");
|
|
3883
|
+
}
|
|
3884
|
+
logger.info("Calculating app ID...");
|
|
3885
|
+
const appId = await calculateAppID({
|
|
3886
|
+
publicClient,
|
|
3887
|
+
environmentConfig,
|
|
3888
|
+
ownerAddress: account.address,
|
|
3889
|
+
salt
|
|
3890
|
+
});
|
|
3891
|
+
logger.debug(`App ID calculated: ${appId}`);
|
|
3892
|
+
logger.debug(`This address will be used for acceptAdmin call`);
|
|
3893
|
+
const saltHexString = bytesToHex(salt).slice(2);
|
|
3894
|
+
const paddedSaltHex = saltHexString.padStart(64, "0");
|
|
3895
|
+
const saltHex = `0x${paddedSaltHex}`;
|
|
3896
|
+
const releaseForViem = {
|
|
3897
|
+
rmsRelease: {
|
|
3898
|
+
artifacts: release.rmsRelease.artifacts.map((artifact) => ({
|
|
3899
|
+
digest: `0x${bytesToHex(artifact.digest).slice(2).padStart(64, "0")}`,
|
|
3900
|
+
registry: artifact.registry
|
|
3901
|
+
})),
|
|
3902
|
+
upgradeByTime: release.rmsRelease.upgradeByTime
|
|
3903
|
+
},
|
|
3904
|
+
publicEnv: bytesToHex(release.publicEnv),
|
|
3905
|
+
encryptedEnv: bytesToHex(release.encryptedEnv)
|
|
3906
|
+
};
|
|
3907
|
+
const createData = encodeFunctionData2({
|
|
3908
|
+
abi: AppController_default,
|
|
3909
|
+
functionName: "createApp",
|
|
3910
|
+
args: [saltHex, releaseForViem]
|
|
3911
|
+
});
|
|
3912
|
+
const acceptAdminData = encodeFunctionData2({
|
|
3913
|
+
abi: PermissionController_default,
|
|
3914
|
+
functionName: "acceptAdmin",
|
|
3915
|
+
args: [appId]
|
|
3916
|
+
});
|
|
3917
|
+
const executions = [
|
|
3918
|
+
{
|
|
3919
|
+
target: environmentConfig.appControllerAddress,
|
|
3920
|
+
value: 0n,
|
|
3921
|
+
callData: createData
|
|
3922
|
+
},
|
|
3923
|
+
{
|
|
3924
|
+
target: environmentConfig.permissionControllerAddress,
|
|
3925
|
+
value: 0n,
|
|
3926
|
+
callData: acceptAdminData
|
|
3927
|
+
}
|
|
3928
|
+
];
|
|
3929
|
+
if (publicLogs) {
|
|
3930
|
+
const anyoneCanViewLogsData = encodeFunctionData2({
|
|
3931
|
+
abi: PermissionController_default,
|
|
3932
|
+
functionName: "setAppointee",
|
|
3933
|
+
args: [
|
|
3934
|
+
appId,
|
|
3935
|
+
"0x493219d9949348178af1f58740655951a8cd110c",
|
|
3936
|
+
// AnyoneCanCallAddress
|
|
3937
|
+
"0x57ee1fb74c1087e26446abc4fb87fd8f07c43d8d",
|
|
3938
|
+
// ApiPermissionsTarget
|
|
3939
|
+
"0x2fd3f2fe"
|
|
3940
|
+
// CanViewAppLogsPermission
|
|
3941
|
+
]
|
|
3942
|
+
});
|
|
3943
|
+
executions.push({
|
|
3944
|
+
target: environmentConfig.permissionControllerAddress,
|
|
3945
|
+
value: 0n,
|
|
3946
|
+
callData: anyoneCanViewLogsData
|
|
3947
|
+
});
|
|
3948
|
+
}
|
|
3949
|
+
return {
|
|
3950
|
+
appId,
|
|
3951
|
+
salt,
|
|
3952
|
+
executions,
|
|
3953
|
+
walletClient,
|
|
3954
|
+
publicClient,
|
|
3955
|
+
environmentConfig
|
|
3956
|
+
};
|
|
3957
|
+
}
|
|
3958
|
+
async function executeDeployBatch(data, context, gas, logger = noopLogger) {
|
|
3959
|
+
const pendingMessage = "Deploying new app...";
|
|
3960
|
+
const txHash = await executeBatch(
|
|
3961
|
+
{
|
|
3962
|
+
walletClient: context.walletClient,
|
|
3963
|
+
publicClient: context.publicClient,
|
|
3964
|
+
environmentConfig: context.environmentConfig,
|
|
3965
|
+
executions: data.executions,
|
|
3966
|
+
pendingMessage,
|
|
3967
|
+
gas
|
|
3968
|
+
},
|
|
3969
|
+
logger
|
|
3970
|
+
);
|
|
3971
|
+
return { appId: data.appId, txHash };
|
|
3972
|
+
}
|
|
3973
|
+
async function deployApp(options, logger = noopLogger) {
|
|
3974
|
+
const prepared = await prepareDeployBatch(options, logger);
|
|
3975
|
+
const data = {
|
|
3976
|
+
appId: prepared.appId,
|
|
3977
|
+
salt: prepared.salt,
|
|
3978
|
+
executions: prepared.executions
|
|
3979
|
+
};
|
|
3980
|
+
const context = {
|
|
3981
|
+
walletClient: prepared.walletClient,
|
|
3982
|
+
publicClient: prepared.publicClient,
|
|
3983
|
+
environmentConfig: prepared.environmentConfig
|
|
3984
|
+
};
|
|
3985
|
+
return executeDeployBatch(data, context, options.gas, logger);
|
|
3986
|
+
}
|
|
3987
|
+
function supportsEIP7702(walletClient) {
|
|
3988
|
+
const account = walletClient.account;
|
|
3989
|
+
if (!account) return false;
|
|
3990
|
+
return account.type === "local";
|
|
3991
|
+
}
|
|
3992
|
+
async function executeDeploySequential(options, logger = noopLogger) {
|
|
3993
|
+
const { walletClient, publicClient, environmentConfig, data, publicLogs, onProgress } = options;
|
|
3994
|
+
const account = walletClient.account;
|
|
3995
|
+
if (!account) {
|
|
3996
|
+
throw new Error("WalletClient must have an account attached");
|
|
3997
|
+
}
|
|
3998
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
3999
|
+
const txHashes = {
|
|
4000
|
+
createApp: "0x",
|
|
4001
|
+
acceptAdmin: "0x"
|
|
4002
|
+
};
|
|
4003
|
+
logger.info("Step 1/3: Creating app...");
|
|
4004
|
+
onProgress?.("createApp");
|
|
4005
|
+
const createAppExecution = data.executions[0];
|
|
4006
|
+
const createAppHash = await walletClient.sendTransaction({
|
|
4007
|
+
account,
|
|
4008
|
+
to: createAppExecution.target,
|
|
4009
|
+
data: createAppExecution.callData,
|
|
4010
|
+
value: createAppExecution.value,
|
|
4011
|
+
chain
|
|
4012
|
+
});
|
|
4013
|
+
logger.info(`createApp transaction sent: ${createAppHash}`);
|
|
4014
|
+
const createAppReceipt = await publicClient.waitForTransactionReceipt({ hash: createAppHash });
|
|
4015
|
+
if (createAppReceipt.status === "reverted") {
|
|
4016
|
+
throw new Error(`createApp transaction reverted: ${createAppHash}`);
|
|
4017
|
+
}
|
|
4018
|
+
txHashes.createApp = createAppHash;
|
|
4019
|
+
logger.info(`createApp confirmed in block ${createAppReceipt.blockNumber}`);
|
|
4020
|
+
logger.info("Step 2/3: Accepting admin role...");
|
|
4021
|
+
onProgress?.("acceptAdmin", createAppHash);
|
|
4022
|
+
const acceptAdminExecution = data.executions[1];
|
|
4023
|
+
const acceptAdminHash = await walletClient.sendTransaction({
|
|
4024
|
+
account,
|
|
4025
|
+
to: acceptAdminExecution.target,
|
|
4026
|
+
data: acceptAdminExecution.callData,
|
|
4027
|
+
value: acceptAdminExecution.value,
|
|
4028
|
+
chain
|
|
4029
|
+
});
|
|
4030
|
+
logger.info(`acceptAdmin transaction sent: ${acceptAdminHash}`);
|
|
4031
|
+
const acceptAdminReceipt = await publicClient.waitForTransactionReceipt({
|
|
4032
|
+
hash: acceptAdminHash
|
|
4033
|
+
});
|
|
4034
|
+
if (acceptAdminReceipt.status === "reverted") {
|
|
4035
|
+
throw new Error(`acceptAdmin transaction reverted: ${acceptAdminHash}`);
|
|
4036
|
+
}
|
|
4037
|
+
txHashes.acceptAdmin = acceptAdminHash;
|
|
4038
|
+
logger.info(`acceptAdmin confirmed in block ${acceptAdminReceipt.blockNumber}`);
|
|
4039
|
+
if (publicLogs && data.executions.length > 2) {
|
|
4040
|
+
logger.info("Step 3/3: Setting public logs permission...");
|
|
4041
|
+
onProgress?.("setPublicLogs", acceptAdminHash);
|
|
4042
|
+
const setAppointeeExecution = data.executions[2];
|
|
4043
|
+
const setAppointeeHash = await walletClient.sendTransaction({
|
|
4044
|
+
account,
|
|
4045
|
+
to: setAppointeeExecution.target,
|
|
4046
|
+
data: setAppointeeExecution.callData,
|
|
4047
|
+
value: setAppointeeExecution.value,
|
|
4048
|
+
chain
|
|
4049
|
+
});
|
|
4050
|
+
logger.info(`setAppointee transaction sent: ${setAppointeeHash}`);
|
|
4051
|
+
const setAppointeeReceipt = await publicClient.waitForTransactionReceipt({
|
|
4052
|
+
hash: setAppointeeHash
|
|
4053
|
+
});
|
|
4054
|
+
if (setAppointeeReceipt.status === "reverted") {
|
|
4055
|
+
throw new Error(`setAppointee transaction reverted: ${setAppointeeHash}`);
|
|
4056
|
+
}
|
|
4057
|
+
txHashes.setPublicLogs = setAppointeeHash;
|
|
4058
|
+
logger.info(`setAppointee confirmed in block ${setAppointeeReceipt.blockNumber}`);
|
|
4059
|
+
}
|
|
4060
|
+
onProgress?.("complete", txHashes.setPublicLogs || txHashes.acceptAdmin);
|
|
4061
|
+
logger.info(`Deployment complete! App ID: ${data.appId}`);
|
|
4062
|
+
return {
|
|
4063
|
+
appId: data.appId,
|
|
4064
|
+
txHashes
|
|
4065
|
+
};
|
|
4066
|
+
}
|
|
4067
|
+
async function supportsEIP5792(walletClient) {
|
|
4068
|
+
try {
|
|
4069
|
+
if (typeof walletClient.getCapabilities !== "function") {
|
|
4070
|
+
return false;
|
|
4071
|
+
}
|
|
4072
|
+
const account = walletClient.account;
|
|
4073
|
+
if (!account) return false;
|
|
4074
|
+
const capabilities = await walletClient.getCapabilities({
|
|
4075
|
+
account: account.address
|
|
4076
|
+
});
|
|
4077
|
+
return capabilities !== null && capabilities !== void 0 && Object.keys(capabilities).length > 0;
|
|
4078
|
+
} catch {
|
|
4079
|
+
return false;
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
async function executeDeployBatched(options, logger = noopLogger) {
|
|
4083
|
+
const { walletClient, environmentConfig, data, publicLogs, onProgress } = options;
|
|
4084
|
+
const account = walletClient.account;
|
|
4085
|
+
if (!account) {
|
|
4086
|
+
throw new Error("WalletClient must have an account attached");
|
|
4087
|
+
}
|
|
4088
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
4089
|
+
const calls = data.executions.map(
|
|
4090
|
+
(execution) => ({
|
|
4091
|
+
to: execution.target,
|
|
4092
|
+
data: execution.callData,
|
|
4093
|
+
value: execution.value
|
|
4094
|
+
})
|
|
4095
|
+
);
|
|
4096
|
+
const filteredCalls = publicLogs ? calls : calls.slice(0, 2);
|
|
4097
|
+
logger.info(`Deploying with EIP-5792 sendCalls (${filteredCalls.length} calls)...`);
|
|
4098
|
+
onProgress?.("createApp");
|
|
4099
|
+
try {
|
|
4100
|
+
const { id: batchId } = await walletClient.sendCalls({
|
|
4101
|
+
account,
|
|
4102
|
+
chain,
|
|
4103
|
+
calls: filteredCalls,
|
|
4104
|
+
forceAtomic: true
|
|
4105
|
+
});
|
|
4106
|
+
logger.info(`Batch submitted with ID: ${batchId}`);
|
|
4107
|
+
onProgress?.("acceptAdmin");
|
|
4108
|
+
let status;
|
|
4109
|
+
let attempts = 0;
|
|
4110
|
+
const maxAttempts = 120;
|
|
4111
|
+
while (attempts < maxAttempts) {
|
|
4112
|
+
try {
|
|
4113
|
+
status = await walletClient.getCallsStatus({ id: batchId });
|
|
4114
|
+
if (status.status === "success" || status.status === "confirmed") {
|
|
4115
|
+
logger.info(`Batch confirmed with ${status.receipts?.length || 0} receipts`);
|
|
4116
|
+
break;
|
|
4117
|
+
}
|
|
4118
|
+
if (status.status === "failed" || status.status === "reverted") {
|
|
4119
|
+
throw new Error(`Batch transaction failed: ${status.status}`);
|
|
4120
|
+
}
|
|
4121
|
+
} catch (statusError) {
|
|
4122
|
+
if (statusError.message?.includes("not supported")) {
|
|
4123
|
+
logger.warn("getCallsStatus not supported, waiting for chain confirmation...");
|
|
4124
|
+
await new Promise((resolve) => setTimeout(resolve, 15e3));
|
|
4125
|
+
break;
|
|
4126
|
+
}
|
|
4127
|
+
throw statusError;
|
|
4128
|
+
}
|
|
4129
|
+
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
4130
|
+
attempts++;
|
|
4131
|
+
}
|
|
4132
|
+
if (attempts >= maxAttempts) {
|
|
4133
|
+
throw new Error("Timeout waiting for batch confirmation");
|
|
4134
|
+
}
|
|
4135
|
+
if (publicLogs) {
|
|
4136
|
+
onProgress?.("setPublicLogs");
|
|
4137
|
+
}
|
|
4138
|
+
onProgress?.("complete");
|
|
4139
|
+
const receipts = (status?.receipts || []).map((r) => ({
|
|
4140
|
+
transactionHash: r.transactionHash || r.hash
|
|
4141
|
+
}));
|
|
4142
|
+
logger.info(`Deployment complete! App ID: ${data.appId}`);
|
|
4143
|
+
return {
|
|
4144
|
+
appId: data.appId,
|
|
4145
|
+
batchId,
|
|
4146
|
+
receipts
|
|
4147
|
+
};
|
|
4148
|
+
} catch (error) {
|
|
4149
|
+
if (error.message?.includes("not supported") || error.message?.includes("wallet_sendCalls") || error.code === -32601) {
|
|
4150
|
+
throw new Error("EIP5792_NOT_SUPPORTED");
|
|
4151
|
+
}
|
|
4152
|
+
throw error;
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
async function prepareUpgradeBatch(options) {
|
|
4156
|
+
const {
|
|
4157
|
+
walletClient,
|
|
4158
|
+
publicClient,
|
|
4159
|
+
environmentConfig,
|
|
4160
|
+
appID,
|
|
4161
|
+
release,
|
|
4162
|
+
publicLogs,
|
|
4163
|
+
needsPermissionChange
|
|
4164
|
+
} = options;
|
|
4165
|
+
const releaseForViem = {
|
|
4166
|
+
rmsRelease: {
|
|
4167
|
+
artifacts: release.rmsRelease.artifacts.map((artifact) => ({
|
|
4168
|
+
digest: `0x${bytesToHex(artifact.digest).slice(2).padStart(64, "0")}`,
|
|
4169
|
+
registry: artifact.registry
|
|
4170
|
+
})),
|
|
4171
|
+
upgradeByTime: release.rmsRelease.upgradeByTime
|
|
4172
|
+
},
|
|
4173
|
+
publicEnv: bytesToHex(release.publicEnv),
|
|
4174
|
+
encryptedEnv: bytesToHex(release.encryptedEnv)
|
|
4175
|
+
};
|
|
4176
|
+
const upgradeData = encodeFunctionData2({
|
|
4177
|
+
abi: AppController_default,
|
|
4178
|
+
functionName: "upgradeApp",
|
|
4179
|
+
args: [appID, releaseForViem]
|
|
4180
|
+
});
|
|
4181
|
+
const executions = [
|
|
4182
|
+
{
|
|
4183
|
+
target: environmentConfig.appControllerAddress,
|
|
4184
|
+
value: 0n,
|
|
4185
|
+
callData: upgradeData
|
|
4186
|
+
}
|
|
4187
|
+
];
|
|
4188
|
+
if (needsPermissionChange) {
|
|
4189
|
+
if (publicLogs) {
|
|
4190
|
+
const addLogsData = encodeFunctionData2({
|
|
4191
|
+
abi: PermissionController_default,
|
|
4192
|
+
functionName: "setAppointee",
|
|
4193
|
+
args: [
|
|
4194
|
+
appID,
|
|
4195
|
+
"0x493219d9949348178af1f58740655951a8cd110c",
|
|
4196
|
+
// AnyoneCanCallAddress
|
|
4197
|
+
"0x57ee1fb74c1087e26446abc4fb87fd8f07c43d8d",
|
|
4198
|
+
// ApiPermissionsTarget
|
|
4199
|
+
"0x2fd3f2fe"
|
|
4200
|
+
// CanViewAppLogsPermission
|
|
4201
|
+
]
|
|
4202
|
+
});
|
|
4203
|
+
executions.push({
|
|
4204
|
+
target: environmentConfig.permissionControllerAddress,
|
|
4205
|
+
value: 0n,
|
|
4206
|
+
callData: addLogsData
|
|
4207
|
+
});
|
|
4208
|
+
} else {
|
|
4209
|
+
const removeLogsData = encodeFunctionData2({
|
|
4210
|
+
abi: PermissionController_default,
|
|
4211
|
+
functionName: "removeAppointee",
|
|
4212
|
+
args: [
|
|
4213
|
+
appID,
|
|
4214
|
+
"0x493219d9949348178af1f58740655951a8cd110c",
|
|
4215
|
+
// AnyoneCanCallAddress
|
|
4216
|
+
"0x57ee1fb74c1087e26446abc4fb87fd8f07c43d8d",
|
|
4217
|
+
// ApiPermissionsTarget
|
|
4218
|
+
"0x2fd3f2fe"
|
|
4219
|
+
// CanViewAppLogsPermission
|
|
4220
|
+
]
|
|
4221
|
+
});
|
|
4222
|
+
executions.push({
|
|
4223
|
+
target: environmentConfig.permissionControllerAddress,
|
|
4224
|
+
value: 0n,
|
|
4225
|
+
callData: removeLogsData
|
|
4226
|
+
});
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4229
|
+
return {
|
|
4230
|
+
appId: appID,
|
|
4231
|
+
executions,
|
|
4232
|
+
walletClient,
|
|
4233
|
+
publicClient,
|
|
4234
|
+
environmentConfig
|
|
4235
|
+
};
|
|
4236
|
+
}
|
|
4237
|
+
async function executeUpgradeBatch(data, context, gas, logger = noopLogger) {
|
|
4238
|
+
const pendingMessage = `Upgrading app ${data.appId}...`;
|
|
4239
|
+
const txHash = await executeBatch(
|
|
4240
|
+
{
|
|
4241
|
+
walletClient: context.walletClient,
|
|
4242
|
+
publicClient: context.publicClient,
|
|
4243
|
+
environmentConfig: context.environmentConfig,
|
|
4244
|
+
executions: data.executions,
|
|
4245
|
+
pendingMessage,
|
|
4246
|
+
gas
|
|
4247
|
+
},
|
|
4248
|
+
logger
|
|
4249
|
+
);
|
|
4250
|
+
return txHash;
|
|
4251
|
+
}
|
|
4252
|
+
async function upgradeApp(options, logger = noopLogger) {
|
|
4253
|
+
const prepared = await prepareUpgradeBatch(options);
|
|
4254
|
+
const data = {
|
|
4255
|
+
appId: prepared.appId,
|
|
4256
|
+
executions: prepared.executions
|
|
4257
|
+
};
|
|
4258
|
+
const context = {
|
|
4259
|
+
walletClient: prepared.walletClient,
|
|
4260
|
+
publicClient: prepared.publicClient,
|
|
4261
|
+
environmentConfig: prepared.environmentConfig
|
|
4262
|
+
};
|
|
4263
|
+
return executeUpgradeBatch(data, context, options.gas, logger);
|
|
4264
|
+
}
|
|
4265
|
+
async function sendAndWaitForTransaction(options, logger = noopLogger) {
|
|
4266
|
+
const {
|
|
4267
|
+
walletClient,
|
|
4268
|
+
publicClient,
|
|
4269
|
+
environmentConfig,
|
|
4270
|
+
to,
|
|
4271
|
+
data,
|
|
4272
|
+
value = 0n,
|
|
4273
|
+
pendingMessage,
|
|
4274
|
+
txDescription,
|
|
4275
|
+
gas
|
|
4276
|
+
} = options;
|
|
4277
|
+
const account = walletClient.account;
|
|
4278
|
+
if (!account) {
|
|
4279
|
+
throw new Error("WalletClient must have an account attached");
|
|
4280
|
+
}
|
|
4281
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
4282
|
+
if (pendingMessage) {
|
|
4283
|
+
logger.info(`
|
|
4284
|
+
${pendingMessage}`);
|
|
4285
|
+
}
|
|
4286
|
+
const hash = await walletClient.sendTransaction({
|
|
4287
|
+
account,
|
|
4288
|
+
to,
|
|
4289
|
+
data,
|
|
4290
|
+
value,
|
|
4291
|
+
...gas?.maxFeePerGas && { maxFeePerGas: gas.maxFeePerGas },
|
|
4292
|
+
...gas?.maxPriorityFeePerGas && {
|
|
4293
|
+
maxPriorityFeePerGas: gas.maxPriorityFeePerGas
|
|
4294
|
+
},
|
|
4295
|
+
chain
|
|
4296
|
+
});
|
|
4297
|
+
logger.info(`Transaction sent: ${hash}`);
|
|
4298
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
4299
|
+
if (receipt.status === "reverted") {
|
|
4300
|
+
let revertReason = "Unknown reason";
|
|
4301
|
+
try {
|
|
4302
|
+
await publicClient.call({
|
|
4303
|
+
to,
|
|
4304
|
+
data,
|
|
4305
|
+
account: account.address
|
|
4306
|
+
});
|
|
4307
|
+
} catch (callError) {
|
|
4308
|
+
if (callError.data) {
|
|
4309
|
+
try {
|
|
4310
|
+
const decoded = decodeErrorResult2({
|
|
4311
|
+
abi: AppController_default,
|
|
4312
|
+
data: callError.data
|
|
4313
|
+
});
|
|
4314
|
+
const formattedError = formatAppControllerError(decoded);
|
|
4315
|
+
revertReason = formattedError.message;
|
|
4316
|
+
} catch {
|
|
4317
|
+
revertReason = callError.message || "Unknown reason";
|
|
4318
|
+
}
|
|
4319
|
+
} else {
|
|
4320
|
+
revertReason = callError.message || "Unknown reason";
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
logger.error(`${txDescription} transaction (hash: ${hash}) reverted: ${revertReason}`);
|
|
4324
|
+
throw new Error(`${txDescription} transaction (hash: ${hash}) reverted: ${revertReason}`);
|
|
4325
|
+
}
|
|
4326
|
+
return hash;
|
|
4327
|
+
}
|
|
4328
|
+
function formatAppControllerError(decoded) {
|
|
4329
|
+
const errorName = decoded.errorName;
|
|
4330
|
+
switch (errorName) {
|
|
4331
|
+
case "MaxActiveAppsExceeded":
|
|
4332
|
+
return new Error(
|
|
4333
|
+
"you have reached your app deployment limit. To request access or increase your limit, please visit https://onboarding.eigencloud.xyz/ or reach out to the Eigen team"
|
|
4334
|
+
);
|
|
4335
|
+
case "GlobalMaxActiveAppsExceeded":
|
|
4336
|
+
return new Error(
|
|
4337
|
+
"the platform has reached the maximum number of active apps. please try again later"
|
|
4338
|
+
);
|
|
4339
|
+
case "InvalidPermissions":
|
|
4340
|
+
return new Error("you don't have permission to perform this operation");
|
|
4341
|
+
case "AppAlreadyExists":
|
|
4342
|
+
return new Error("an app with this owner and salt already exists");
|
|
4343
|
+
case "AppDoesNotExist":
|
|
4344
|
+
return new Error("the specified app does not exist");
|
|
4345
|
+
case "InvalidAppStatus":
|
|
4346
|
+
return new Error("the app is in an invalid state for this operation");
|
|
4347
|
+
case "MoreThanOneArtifact":
|
|
4348
|
+
return new Error("only one artifact is allowed per release");
|
|
4349
|
+
case "InvalidSignature":
|
|
4350
|
+
return new Error("invalid signature provided");
|
|
4351
|
+
case "SignatureExpired":
|
|
4352
|
+
return new Error("the provided signature has expired");
|
|
4353
|
+
case "InvalidReleaseMetadataURI":
|
|
4354
|
+
return new Error("invalid release metadata URI provided");
|
|
4355
|
+
case "InvalidShortString":
|
|
4356
|
+
return new Error("invalid short string format");
|
|
4357
|
+
default:
|
|
4358
|
+
return new Error(`contract error: ${errorName}`);
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
async function getActiveAppCount(publicClient, environmentConfig, user) {
|
|
4362
|
+
const count = await publicClient.readContract({
|
|
4363
|
+
address: environmentConfig.appControllerAddress,
|
|
4364
|
+
abi: AppController_default,
|
|
4365
|
+
functionName: "getActiveAppCount",
|
|
4366
|
+
args: [user]
|
|
4367
|
+
});
|
|
4368
|
+
return Number(count);
|
|
4369
|
+
}
|
|
4370
|
+
async function getMaxActiveAppsPerUser(publicClient, environmentConfig, user) {
|
|
4371
|
+
const quota = await publicClient.readContract({
|
|
4372
|
+
address: environmentConfig.appControllerAddress,
|
|
4373
|
+
abi: AppController_default,
|
|
4374
|
+
functionName: "getMaxActiveAppsPerUser",
|
|
4375
|
+
args: [user]
|
|
4376
|
+
});
|
|
4377
|
+
return Number(quota);
|
|
4378
|
+
}
|
|
4379
|
+
async function getAppsByCreator(publicClient, environmentConfig, creator, offset, limit) {
|
|
4380
|
+
const result = await publicClient.readContract({
|
|
4381
|
+
address: environmentConfig.appControllerAddress,
|
|
4382
|
+
abi: AppController_default,
|
|
4383
|
+
functionName: "getAppsByCreator",
|
|
4384
|
+
args: [creator, offset, limit]
|
|
4385
|
+
});
|
|
4386
|
+
return {
|
|
4387
|
+
apps: result[0],
|
|
4388
|
+
appConfigs: result[1]
|
|
4389
|
+
};
|
|
4390
|
+
}
|
|
4391
|
+
async function getAppsByDeveloper(publicClient, environmentConfig, developer, offset, limit) {
|
|
4392
|
+
const result = await publicClient.readContract({
|
|
4393
|
+
address: environmentConfig.appControllerAddress,
|
|
4394
|
+
abi: AppController_default,
|
|
4395
|
+
functionName: "getAppsByDeveloper",
|
|
4396
|
+
args: [developer, offset, limit]
|
|
4397
|
+
});
|
|
4398
|
+
return {
|
|
4399
|
+
apps: result[0],
|
|
4400
|
+
appConfigs: result[1]
|
|
4401
|
+
};
|
|
4402
|
+
}
|
|
4403
|
+
async function getAllAppsByDeveloper(publicClient, env, developer, pageSize = 100n) {
|
|
4404
|
+
let offset = 0n;
|
|
4405
|
+
const allApps = [];
|
|
4406
|
+
const allConfigs = [];
|
|
4407
|
+
while (true) {
|
|
4408
|
+
const { apps, appConfigs } = await getAppsByDeveloper(
|
|
4409
|
+
publicClient,
|
|
4410
|
+
env,
|
|
4411
|
+
developer,
|
|
4412
|
+
offset,
|
|
4413
|
+
pageSize
|
|
4414
|
+
);
|
|
4415
|
+
if (apps.length === 0) break;
|
|
4416
|
+
allApps.push(...apps);
|
|
4417
|
+
allConfigs.push(...appConfigs);
|
|
4418
|
+
if (apps.length < Number(pageSize)) break;
|
|
4419
|
+
offset += pageSize;
|
|
4420
|
+
}
|
|
4421
|
+
return {
|
|
4422
|
+
apps: allApps,
|
|
4423
|
+
appConfigs: allConfigs
|
|
4424
|
+
};
|
|
4425
|
+
}
|
|
4426
|
+
async function suspend(options, logger = noopLogger) {
|
|
4427
|
+
const { walletClient, publicClient, environmentConfig, account, apps } = options;
|
|
4428
|
+
const suspendData = encodeFunctionData2({
|
|
4429
|
+
abi: AppController_default,
|
|
4430
|
+
functionName: "suspend",
|
|
4431
|
+
args: [account, apps]
|
|
4432
|
+
});
|
|
4433
|
+
const pendingMessage = `Suspending ${apps.length} app(s)...`;
|
|
4434
|
+
return sendAndWaitForTransaction(
|
|
4435
|
+
{
|
|
4436
|
+
walletClient,
|
|
4437
|
+
publicClient,
|
|
4438
|
+
environmentConfig,
|
|
4439
|
+
to: environmentConfig.appControllerAddress,
|
|
4440
|
+
data: suspendData,
|
|
4441
|
+
pendingMessage,
|
|
4442
|
+
txDescription: "Suspend"
|
|
4443
|
+
},
|
|
4444
|
+
logger
|
|
4445
|
+
);
|
|
4446
|
+
}
|
|
4447
|
+
async function isDelegated(options) {
|
|
4448
|
+
const { publicClient, environmentConfig, address } = options;
|
|
4449
|
+
return checkERC7702Delegation(
|
|
4450
|
+
publicClient,
|
|
4451
|
+
address,
|
|
4452
|
+
environmentConfig.erc7702DelegatorAddress
|
|
4453
|
+
);
|
|
4454
|
+
}
|
|
4455
|
+
async function undelegate(options, logger = noopLogger) {
|
|
4456
|
+
const { walletClient, publicClient, environmentConfig } = options;
|
|
4457
|
+
const account = walletClient.account;
|
|
4458
|
+
if (!account) {
|
|
4459
|
+
throw new Error("WalletClient must have an account attached");
|
|
4460
|
+
}
|
|
4461
|
+
const chain = getChainFromID(environmentConfig.chainID);
|
|
4462
|
+
const transactionNonce = await publicClient.getTransactionCount({
|
|
4463
|
+
address: account.address,
|
|
4464
|
+
blockTag: "pending"
|
|
4465
|
+
});
|
|
4466
|
+
const chainId = await publicClient.getChainId();
|
|
4467
|
+
const authorizationNonce = BigInt(transactionNonce) + 1n;
|
|
4468
|
+
logger.debug("Signing undelegate authorization");
|
|
4469
|
+
const signedAuthorization = await walletClient.signAuthorization({
|
|
4470
|
+
contractAddress: "0x0000000000000000000000000000000000000000",
|
|
4471
|
+
chainId,
|
|
4472
|
+
nonce: Number(authorizationNonce),
|
|
4473
|
+
account
|
|
4474
|
+
});
|
|
4475
|
+
const authorizationList = [signedAuthorization];
|
|
4476
|
+
const hash = await walletClient.sendTransaction({
|
|
4477
|
+
account,
|
|
4478
|
+
to: account.address,
|
|
4479
|
+
// Send to self
|
|
4480
|
+
data: "0x",
|
|
4481
|
+
// Empty data
|
|
4482
|
+
value: 0n,
|
|
4483
|
+
authorizationList,
|
|
4484
|
+
chain
|
|
4485
|
+
});
|
|
4486
|
+
logger.info(`Transaction sent: ${hash}`);
|
|
4487
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
4488
|
+
if (receipt.status === "reverted") {
|
|
4489
|
+
logger.error(`Undelegate transaction (hash: ${hash}) reverted`);
|
|
4490
|
+
throw new Error(`Undelegate transaction (hash: ${hash}) reverted`);
|
|
4491
|
+
}
|
|
4492
|
+
return hash;
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
// src/client/common/contract/encoders.ts
|
|
4496
|
+
import { parseAbi as parseAbi2, encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
4497
|
+
var CONTROLLER_ABI = parseAbi2([
|
|
4498
|
+
"function startApp(address appId)",
|
|
4499
|
+
"function stopApp(address appId)",
|
|
4500
|
+
"function terminateApp(address appId)"
|
|
4501
|
+
]);
|
|
4502
|
+
function encodeStartAppData(appId) {
|
|
4503
|
+
return encodeFunctionData3({
|
|
4504
|
+
abi: CONTROLLER_ABI,
|
|
4505
|
+
functionName: "startApp",
|
|
4506
|
+
args: [appId]
|
|
4507
|
+
});
|
|
4508
|
+
}
|
|
4509
|
+
function encodeStopAppData(appId) {
|
|
4510
|
+
return encodeFunctionData3({
|
|
4511
|
+
abi: CONTROLLER_ABI,
|
|
4512
|
+
functionName: "stopApp",
|
|
4513
|
+
args: [appId]
|
|
4514
|
+
});
|
|
4515
|
+
}
|
|
4516
|
+
function encodeTerminateAppData(appId) {
|
|
4517
|
+
return encodeFunctionData3({
|
|
4518
|
+
abi: CONTROLLER_ABI,
|
|
4519
|
+
functionName: "terminateApp",
|
|
4520
|
+
args: [appId]
|
|
4521
|
+
});
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
// src/client/common/auth/siwe.ts
|
|
4525
|
+
import { SiweMessage, generateNonce as siweGenerateNonce } from "siwe";
|
|
4526
|
+
var generateNonce = siweGenerateNonce;
|
|
4527
|
+
function createSiweMessage(params) {
|
|
4528
|
+
const now = /* @__PURE__ */ new Date();
|
|
4529
|
+
const nonce = params.nonce || generateNonce();
|
|
4530
|
+
const issuedAt = params.issuedAt || now;
|
|
4531
|
+
const expirationTime = params.expirationTime || new Date(now.getTime() + 24 * 60 * 60 * 1e3);
|
|
4532
|
+
const siweMessage = new SiweMessage({
|
|
4533
|
+
domain: params.domain,
|
|
4534
|
+
address: params.address,
|
|
4535
|
+
statement: params.statement,
|
|
4536
|
+
uri: params.uri,
|
|
4537
|
+
version: "1",
|
|
4538
|
+
chainId: params.chainId,
|
|
4539
|
+
nonce,
|
|
4540
|
+
issuedAt: issuedAt.toISOString(),
|
|
4541
|
+
expirationTime: expirationTime.toISOString(),
|
|
4542
|
+
notBefore: params.notBefore?.toISOString(),
|
|
4543
|
+
requestId: params.requestId,
|
|
4544
|
+
resources: params.resources
|
|
4545
|
+
});
|
|
4546
|
+
return {
|
|
4547
|
+
message: siweMessage.prepareMessage(),
|
|
4548
|
+
params: {
|
|
4549
|
+
address: params.address,
|
|
4550
|
+
chainId: params.chainId,
|
|
4551
|
+
domain: params.domain,
|
|
4552
|
+
uri: params.uri,
|
|
4553
|
+
nonce,
|
|
4554
|
+
issuedAt,
|
|
4555
|
+
statement: params.statement,
|
|
4556
|
+
expirationTime,
|
|
4557
|
+
notBefore: params.notBefore,
|
|
4558
|
+
requestId: params.requestId,
|
|
4559
|
+
resources: params.resources
|
|
4560
|
+
}
|
|
4561
|
+
};
|
|
4562
|
+
}
|
|
4563
|
+
function parseSiweMessage(message) {
|
|
4564
|
+
try {
|
|
4565
|
+
const siweMessage = new SiweMessage(message);
|
|
4566
|
+
return {
|
|
4567
|
+
address: siweMessage.address,
|
|
4568
|
+
chainId: siweMessage.chainId,
|
|
4569
|
+
domain: siweMessage.domain,
|
|
4570
|
+
uri: siweMessage.uri,
|
|
4571
|
+
nonce: siweMessage.nonce,
|
|
4572
|
+
statement: siweMessage.statement,
|
|
4573
|
+
issuedAt: siweMessage.issuedAt ? new Date(siweMessage.issuedAt) : void 0,
|
|
4574
|
+
expirationTime: siweMessage.expirationTime ? new Date(siweMessage.expirationTime) : void 0,
|
|
4575
|
+
notBefore: siweMessage.notBefore ? new Date(siweMessage.notBefore) : void 0,
|
|
4576
|
+
requestId: siweMessage.requestId,
|
|
4577
|
+
resources: siweMessage.resources
|
|
4578
|
+
};
|
|
4579
|
+
} catch {
|
|
4580
|
+
return null;
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
function isSiweMessageExpired(params) {
|
|
4584
|
+
if (!params.expirationTime) return false;
|
|
4585
|
+
return /* @__PURE__ */ new Date() > params.expirationTime;
|
|
4586
|
+
}
|
|
4587
|
+
function isSiweMessageNotYetValid(params) {
|
|
4588
|
+
if (!params.notBefore) return false;
|
|
4589
|
+
return /* @__PURE__ */ new Date() < params.notBefore;
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4592
|
+
// src/client/common/hooks/useComputeSession.ts
|
|
4593
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4594
|
+
function useComputeSession(config) {
|
|
4595
|
+
const {
|
|
4596
|
+
baseUrl,
|
|
4597
|
+
refreshInterval = 6e4,
|
|
4598
|
+
// 1 minute default
|
|
4599
|
+
checkOnMount = true,
|
|
4600
|
+
onSessionExpired,
|
|
4601
|
+
onSessionRefreshed,
|
|
4602
|
+
onError
|
|
4603
|
+
} = config;
|
|
4604
|
+
const [session, setSession] = useState(null);
|
|
4605
|
+
const [isLoading, setIsLoading] = useState(checkOnMount);
|
|
4606
|
+
const [error, setError] = useState(null);
|
|
4607
|
+
const wasAuthenticatedRef = useRef(false);
|
|
4608
|
+
const isMountedRef = useRef(true);
|
|
4609
|
+
const refreshIntervalRef = useRef(null);
|
|
4610
|
+
const apiConfig = { baseUrl };
|
|
4611
|
+
const checkSession = useCallback(async () => {
|
|
4612
|
+
try {
|
|
4613
|
+
const sessionInfo = await getComputeApiSession(apiConfig);
|
|
4614
|
+
if (!isMountedRef.current) {
|
|
4615
|
+
return sessionInfo;
|
|
4616
|
+
}
|
|
4617
|
+
setSession(sessionInfo);
|
|
4618
|
+
setError(null);
|
|
4619
|
+
if (wasAuthenticatedRef.current && !sessionInfo.authenticated) {
|
|
4620
|
+
onSessionExpired?.();
|
|
4621
|
+
}
|
|
4622
|
+
wasAuthenticatedRef.current = sessionInfo.authenticated;
|
|
4623
|
+
if (sessionInfo.authenticated) {
|
|
4624
|
+
onSessionRefreshed?.(sessionInfo);
|
|
4625
|
+
}
|
|
4626
|
+
return sessionInfo;
|
|
4627
|
+
} catch (err) {
|
|
4628
|
+
if (!isMountedRef.current) {
|
|
4629
|
+
throw err;
|
|
4630
|
+
}
|
|
4631
|
+
const sessionError = err instanceof SessionError ? err : new SessionError(`Failed to check session: ${String(err)}`, "UNKNOWN");
|
|
4632
|
+
setError(sessionError);
|
|
4633
|
+
onError?.(sessionError);
|
|
4634
|
+
const fallbackSession = { authenticated: false };
|
|
4635
|
+
setSession(fallbackSession);
|
|
4636
|
+
return fallbackSession;
|
|
4637
|
+
}
|
|
4638
|
+
}, [baseUrl, onSessionExpired, onSessionRefreshed, onError]);
|
|
4639
|
+
const refresh = useCallback(async () => {
|
|
4640
|
+
setIsLoading(true);
|
|
4641
|
+
try {
|
|
4642
|
+
return await checkSession();
|
|
4643
|
+
} finally {
|
|
4644
|
+
if (isMountedRef.current) {
|
|
4645
|
+
setIsLoading(false);
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
}, [checkSession]);
|
|
4649
|
+
const login = useCallback(
|
|
4650
|
+
async (params, signMessage) => {
|
|
4651
|
+
setIsLoading(true);
|
|
4652
|
+
setError(null);
|
|
4653
|
+
try {
|
|
4654
|
+
let domain = params.domain;
|
|
4655
|
+
let uri = params.uri;
|
|
4656
|
+
if (typeof window !== "undefined") {
|
|
4657
|
+
domain = domain || window.location.host;
|
|
4658
|
+
uri = uri || window.location.origin;
|
|
4659
|
+
}
|
|
4660
|
+
if (!domain || !uri) {
|
|
4661
|
+
throw new SessionError(
|
|
4662
|
+
"domain and uri are required when not in browser environment",
|
|
4663
|
+
"INVALID_MESSAGE"
|
|
4664
|
+
);
|
|
4665
|
+
}
|
|
4666
|
+
const siweMessage = createSiweMessage({
|
|
4667
|
+
...params,
|
|
4668
|
+
domain,
|
|
4669
|
+
uri,
|
|
4670
|
+
statement: params.statement || "Sign in to EigenCloud Compute API"
|
|
4671
|
+
});
|
|
4672
|
+
const signature = await signMessage({ message: siweMessage.message });
|
|
4673
|
+
await loginToComputeApi(apiConfig, {
|
|
4674
|
+
message: siweMessage.message,
|
|
4675
|
+
signature
|
|
4676
|
+
});
|
|
4677
|
+
const sessionInfo = await checkSession();
|
|
4678
|
+
if (!isMountedRef.current) {
|
|
4679
|
+
return sessionInfo;
|
|
4680
|
+
}
|
|
4681
|
+
wasAuthenticatedRef.current = sessionInfo.authenticated;
|
|
4682
|
+
return sessionInfo;
|
|
4683
|
+
} catch (err) {
|
|
4684
|
+
if (!isMountedRef.current) {
|
|
4685
|
+
throw err;
|
|
4686
|
+
}
|
|
4687
|
+
const sessionError = err instanceof SessionError ? err : new SessionError(`Login failed: ${String(err)}`, "UNKNOWN");
|
|
4688
|
+
setError(sessionError);
|
|
4689
|
+
onError?.(sessionError);
|
|
4690
|
+
throw sessionError;
|
|
4691
|
+
} finally {
|
|
4692
|
+
if (isMountedRef.current) {
|
|
4693
|
+
setIsLoading(false);
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
},
|
|
4697
|
+
[baseUrl, checkSession, onError]
|
|
4698
|
+
);
|
|
4699
|
+
const logout = useCallback(async () => {
|
|
4700
|
+
setIsLoading(true);
|
|
4701
|
+
setError(null);
|
|
4702
|
+
try {
|
|
4703
|
+
await logoutFromComputeApi(apiConfig);
|
|
4704
|
+
if (!isMountedRef.current) {
|
|
4705
|
+
return;
|
|
4706
|
+
}
|
|
4707
|
+
const newSession = { authenticated: false };
|
|
4708
|
+
setSession(newSession);
|
|
4709
|
+
wasAuthenticatedRef.current = false;
|
|
4710
|
+
} catch (err) {
|
|
4711
|
+
if (!isMountedRef.current) {
|
|
4712
|
+
throw err;
|
|
4713
|
+
}
|
|
4714
|
+
const sessionError = err instanceof SessionError ? err : new SessionError(`Logout failed: ${String(err)}`, "UNKNOWN");
|
|
4715
|
+
setError(sessionError);
|
|
4716
|
+
onError?.(sessionError);
|
|
4717
|
+
setSession({ authenticated: false });
|
|
4718
|
+
wasAuthenticatedRef.current = false;
|
|
4719
|
+
} finally {
|
|
4720
|
+
if (isMountedRef.current) {
|
|
4721
|
+
setIsLoading(false);
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
}, [baseUrl, onError]);
|
|
4725
|
+
const clearError = useCallback(() => {
|
|
4726
|
+
setError(null);
|
|
4727
|
+
}, []);
|
|
4728
|
+
useEffect(() => {
|
|
4729
|
+
isMountedRef.current = true;
|
|
4730
|
+
if (checkOnMount) {
|
|
4731
|
+
checkSession().finally(() => {
|
|
4732
|
+
if (isMountedRef.current) {
|
|
4733
|
+
setIsLoading(false);
|
|
4734
|
+
}
|
|
4735
|
+
});
|
|
4736
|
+
}
|
|
4737
|
+
return () => {
|
|
4738
|
+
isMountedRef.current = false;
|
|
4739
|
+
};
|
|
4740
|
+
}, [checkOnMount, checkSession]);
|
|
4741
|
+
useEffect(() => {
|
|
4742
|
+
if (refreshInterval <= 0) {
|
|
4743
|
+
return;
|
|
4744
|
+
}
|
|
4745
|
+
if (refreshIntervalRef.current) {
|
|
4746
|
+
clearInterval(refreshIntervalRef.current);
|
|
4747
|
+
}
|
|
4748
|
+
refreshIntervalRef.current = setInterval(() => {
|
|
4749
|
+
if (wasAuthenticatedRef.current) {
|
|
4750
|
+
checkSession();
|
|
4751
|
+
}
|
|
4752
|
+
}, refreshInterval);
|
|
4753
|
+
return () => {
|
|
4754
|
+
if (refreshIntervalRef.current) {
|
|
4755
|
+
clearInterval(refreshIntervalRef.current);
|
|
4756
|
+
refreshIntervalRef.current = null;
|
|
4757
|
+
}
|
|
4758
|
+
};
|
|
4759
|
+
}, [refreshInterval, checkSession]);
|
|
4760
|
+
return {
|
|
4761
|
+
session,
|
|
4762
|
+
isLoading,
|
|
4763
|
+
error,
|
|
4764
|
+
isAuthenticated: session?.authenticated ?? false,
|
|
4765
|
+
login,
|
|
4766
|
+
logout,
|
|
4767
|
+
refresh,
|
|
4768
|
+
clearError
|
|
4769
|
+
};
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
// src/client/common/encryption/kms.ts
|
|
4773
|
+
import { importSPKI, CompactEncrypt } from "jose";
|
|
4774
|
+
function getAppProtectedHeaders(appID) {
|
|
4775
|
+
return {
|
|
4776
|
+
"x-eigenx-app-id": appID
|
|
4777
|
+
};
|
|
4778
|
+
}
|
|
4779
|
+
async function encryptRSAOAEPAndAES256GCM(encryptionKeyPEM, plaintext, protectedHeaders) {
|
|
4780
|
+
const pemString = typeof encryptionKeyPEM === "string" ? encryptionKeyPEM : encryptionKeyPEM.toString("utf-8");
|
|
4781
|
+
const publicKey = await importSPKI(pemString, "RSA-OAEP-256", {
|
|
4782
|
+
extractable: true
|
|
4783
|
+
});
|
|
4784
|
+
const header = {
|
|
4785
|
+
alg: "RSA-OAEP-256",
|
|
4786
|
+
// Key encryption algorithm (SHA-256)
|
|
4787
|
+
enc: "A256GCM",
|
|
4788
|
+
// Content encryption algorithm
|
|
4789
|
+
...protectedHeaders || {}
|
|
4790
|
+
// Add custom protected headers
|
|
4791
|
+
};
|
|
4792
|
+
const plaintextBytes = new Uint8Array(plaintext);
|
|
4793
|
+
const jwe = await new CompactEncrypt(plaintextBytes).setProtectedHeader(header).encrypt(publicKey);
|
|
4794
|
+
return jwe;
|
|
4795
|
+
}
|
|
4796
|
+
|
|
4797
|
+
// keys/mainnet-alpha/prod/kms-encryption-public-key.pem
|
|
4798
|
+
var kms_encryption_public_key_default = "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0kHU86k17ofCIGcJKDcf\nAFurFhSLeWmOL0bwWLCeVnTPG0MMHtJOq+woE0XXSWw6lzm+jzavBBTwKde1dgal\nAp91vULAZFMUpiUdd2dNUVtvU89qW0Pgf1Eu5FDj7BkY/SnyECbWJM4ga0BmpiGy\nnQwLNN9mMGhjVoVLn2zwEGZ7JzS9Nz11EZKO/k/9DcO6LaoIFmKuvVf3jl6lvZg8\naeA0LoZXjkycHlRUt/kfKwZnhakUaYHP1ksV7ZNmolS5GYDTSKGB2KPPNR1s4/Xu\nu8zeEFC8HuGRU8XuuBeaAunitnGhbNVREUNJGff6HZOGB6CIFNXjbQETeZ3p5uro\n0v+hd1QqQYBv7+DEaMCmGnJNGAyIMr2mn4vr7wGsIj0HonlSHmQ8rmdUhL2ocNTc\nLhKgZiZmBuDpSbFW/r53R2G7CHcqaqGeUBnT54QCH4zsYKw0/4dOtwFxQpTyBf9/\n+k+KaWEJYKkx9d9OzKGyAvzrTDVOFoajddiJ6LPvRlMdOUQr3hl4IAC0/nh9lhHq\nD0R+i5WAU96TkdAe7B7iTGH2D22k0KUPR6Q9W3aF353SLxQAMPNrgG4QQufAdRJn\nAF+8ntun5TkTqjTWRSwAsUJZ1z4wb96DympWJbDi0OciJRZ3Fz3j9+amC43yCHGg\naaEMjdt35ewbztUSc04F10MCAwEAAQ==\n-----END PUBLIC KEY-----";
|
|
4799
|
+
|
|
4800
|
+
// keys/mainnet-alpha/prod/kms-signing-public-key.pem
|
|
4801
|
+
var kms_signing_public_key_default = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfxbhXJjH4D0DH/iW5/rK1HzWS+f9\nEyooZTrCYjCfezuOEmRuOWNaZLvwXN8SdzrvjWA7gSvOS85hLzp4grANRQ==\n-----END PUBLIC KEY-----";
|
|
4802
|
+
|
|
4803
|
+
// keys/sepolia/dev/kms-encryption-public-key.pem
|
|
4804
|
+
var kms_encryption_public_key_default2 = "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAr/vqttU6aXX35HtsXavU\n5teysunDzZB3HyaFM4qcuRnqj+70KxqLOwZsERN5SwZ/56Jm8T2ds1CcXsQCMUMw\n+MPlsF6KMGfzghLtYHONwvKLnn+U9y886aAay6W8a0A7O7YCZehNYD3kQnCXjOIc\nMj6v8AEvMw+w/lNabjRXnwSBMKVIGp/cSL0hGwt8fGoC3TsxQN9opzvU1Z4rAw9K\na119l6dlPnqezDva378TCaXDjqKe/jSZOI1CcYpaSK2SJ+95Wbvte5j3lXbg1oT2\n0rXeJUHEJ68QxMtJplfw0Sg+Ek4CUJ2c/kbdg0u7sIIO5wcB4WHL/Lfbw2XPmcBI\nt0r0EC575D3iHF/aI01Ms2IRA0GDeHnNcr5FJLWJljTjNLEt4tFITrXwBe1Ealm3\nNCxamApl5bBSwQ72Gb5fiQFwB8Fl2/XG3wfGTFInFEvWE4c/H8dtu1wHTsyEFZcG\nB47IkD5GBSZq90Hd9xuZva55dxGpqUVrEJO88SqHGP9Oa+HLTYdEe5AR5Hitw4Mu\ndk1cCH+X5OqY9dfpdoCNbKAM0N2SJvNAnDTU2JKGYheXrnDslXR6atBmU5gDkH+W\nQVryDYl9xbwWIACMQsAQjrrtKw5xqJ4V89+06FN/wyEVF7KWAcJ4AhKiVnCvLqzb\nBbISc+gOkRsefhCDJVPEKDkCAwEAAQ==\n-----END PUBLIC KEY-----";
|
|
4805
|
+
|
|
4806
|
+
// keys/sepolia/dev/kms-signing-public-key.pem
|
|
4807
|
+
var kms_signing_public_key_default2 = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEb2Q88/cxdic2xi4jS2V0dtYHjLwq\n4wVFBFmaY8TTXoMXNggKEdU6PuE8EovocVKMpw3SIlaM27z9uxksNVL2xw==\n-----END PUBLIC KEY-----\n";
|
|
4808
|
+
|
|
4809
|
+
// keys/sepolia/prod/kms-encryption-public-key.pem
|
|
4810
|
+
var kms_encryption_public_key_default3 = "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEApDvk8pAivkgtiC5li5MP\nxMTJDduTeorBl18ynrooTxp2BwwgPwXfXbJaCA0qRubvc0aO2uh2VDrPM27CqMLH\no2S9YLtpLii4A1Nl7SE/MdWKWdG6v94xNGpc2YyPP7yWtHfqOkgDWp8sokl3Uq/9\nMS0pjUaI7RyS5boCTy8Qw90BxGMpucjOmqm+luw4EdPWZCrgriUR2bbGRRgAmrT1\nK4ou4IgPp799r120hwHbCWxnOvLdQdpiv2507b900xS/3yZahhnHCAn66146LU/f\nBrRpQKSM0qSpktXrrc9MH/ru2VLR5cGLp89ZcZMQA9cRGglWM5XWVY3Ti2TPJ6Kd\nAn1d7qNkGJaSdVa3x3HkOf6c6HeTyqis5/L/6L+PFhUsTRbmKg1FtwD+3xxdyf7h\nabFxryE9rv+WatHL6r6z5ztV0znJ/Fpfs5A45FWA6pfb28fA59RGpi/DQ8RxgdCH\nnZRNvdz8dTgRaXSPgkfGXBcCFqb/QhFmad7XbWDthGzfhbPOxNPtiaGRQ1Dr/Pgq\nn0ugdLbRQLmDOAFgaQcnr0U4y1TUlWJnvoZMETkVN7gmITtXA4F324ALT7Rd+Lgk\nHikW5vG+NjAEwXfPsK0YzT+VbHd7o1lbru9UxiDlN03XVEkz/oRQi47CvSTo3FSr\n5dB4lz8kov3UUcNJfQFZolMCAwEAAQ==\n-----END PUBLIC KEY-----";
|
|
4811
|
+
|
|
4812
|
+
// keys/sepolia/prod/kms-signing-public-key.pem
|
|
4813
|
+
var kms_signing_public_key_default3 = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsk6ZdmmvBqFfKHs+1cYjIemRGN7h\n1NatIEitFRyx+3q8wmTJ9LknTE1FwWBLcCNTseJDti8Rh+SaVxfGOyJuuA==\n-----END PUBLIC KEY-----";
|
|
4814
|
+
|
|
4815
|
+
// src/client/common/utils/keys.ts
|
|
4816
|
+
var KEYS = {
|
|
4817
|
+
"mainnet-alpha": {
|
|
4818
|
+
prod: {
|
|
4819
|
+
encryption: kms_encryption_public_key_default,
|
|
4820
|
+
signing: kms_signing_public_key_default
|
|
4821
|
+
}
|
|
4822
|
+
},
|
|
4823
|
+
sepolia: {
|
|
4824
|
+
dev: {
|
|
4825
|
+
encryption: kms_encryption_public_key_default2,
|
|
4826
|
+
signing: kms_signing_public_key_default2
|
|
4827
|
+
},
|
|
4828
|
+
prod: {
|
|
4829
|
+
encryption: kms_encryption_public_key_default3,
|
|
4830
|
+
signing: kms_signing_public_key_default3
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
};
|
|
4834
|
+
function getKMSKeysForEnvironment(environment, build = "prod") {
|
|
4835
|
+
const envKeys = KEYS[environment];
|
|
4836
|
+
if (!envKeys) {
|
|
4837
|
+
throw new Error(`No keys found for environment: ${environment}`);
|
|
4838
|
+
}
|
|
4839
|
+
const buildKeys = envKeys[build];
|
|
4840
|
+
if (!buildKeys) {
|
|
4841
|
+
throw new Error(`No keys found for environment: ${environment}, build: ${build}`);
|
|
4842
|
+
}
|
|
4843
|
+
return {
|
|
4844
|
+
encryptionKey: Buffer.from(buildKeys.encryption),
|
|
4845
|
+
signingKey: Buffer.from(buildKeys.signing)
|
|
4846
|
+
};
|
|
4847
|
+
}
|
|
4848
|
+
export {
|
|
4849
|
+
BillingApiClient,
|
|
4850
|
+
BuildApiClient,
|
|
4851
|
+
SessionError,
|
|
4852
|
+
UserApiClient,
|
|
4853
|
+
addHexPrefix,
|
|
4854
|
+
assertValidImageReference,
|
|
4855
|
+
assertValidPrivateKey,
|
|
4856
|
+
calculateAppID,
|
|
4857
|
+
checkERC7702Delegation,
|
|
4858
|
+
createSiweMessage,
|
|
4859
|
+
deployApp,
|
|
4860
|
+
encodeStartAppData,
|
|
4861
|
+
encodeStopAppData,
|
|
4862
|
+
encodeTerminateAppData,
|
|
4863
|
+
encryptRSAOAEPAndAES256GCM,
|
|
4864
|
+
estimateBatchGas,
|
|
4865
|
+
estimateTransactionGas,
|
|
4866
|
+
executeBatch,
|
|
4867
|
+
executeDeployBatch,
|
|
4868
|
+
executeDeployBatched,
|
|
4869
|
+
executeDeploySequential,
|
|
4870
|
+
executeUpgradeBatch,
|
|
4871
|
+
extractAppNameFromImage,
|
|
4872
|
+
formatETH,
|
|
4873
|
+
generateNewPrivateKey,
|
|
4874
|
+
generateNonce,
|
|
4875
|
+
getActiveAppCount,
|
|
4876
|
+
getAllAppsByDeveloper,
|
|
4877
|
+
getAppProtectedHeaders,
|
|
4878
|
+
getAppsByCreator,
|
|
4879
|
+
getAppsByDeveloper,
|
|
4880
|
+
getAvailableEnvironments,
|
|
4881
|
+
getBillingEnvironmentConfig,
|
|
4882
|
+
getBuildType,
|
|
4883
|
+
getChainFromID,
|
|
4884
|
+
getComputeApiSession,
|
|
4885
|
+
getEnvironmentConfig,
|
|
4886
|
+
getKMSKeysForEnvironment,
|
|
4887
|
+
getMaxActiveAppsPerUser,
|
|
4888
|
+
isDelegated,
|
|
4889
|
+
isEnvironmentAvailable,
|
|
4890
|
+
isMainnet,
|
|
4891
|
+
isSessionValid,
|
|
4892
|
+
isSiweMessageExpired,
|
|
4893
|
+
isSiweMessageNotYetValid,
|
|
4894
|
+
isSubscriptionActive,
|
|
4895
|
+
loginToComputeApi,
|
|
4896
|
+
logoutFromComputeApi,
|
|
4897
|
+
noopLogger,
|
|
4898
|
+
parseSiweMessage,
|
|
4899
|
+
prepareDeployBatch,
|
|
4900
|
+
prepareUpgradeBatch,
|
|
4901
|
+
sanitizeString,
|
|
4902
|
+
sanitizeURL,
|
|
4903
|
+
sanitizeXURL,
|
|
4904
|
+
sendAndWaitForTransaction,
|
|
4905
|
+
stripHexPrefix,
|
|
4906
|
+
supportsEIP5792,
|
|
4907
|
+
supportsEIP7702,
|
|
4908
|
+
suspend,
|
|
4909
|
+
undelegate,
|
|
4910
|
+
upgradeApp,
|
|
4911
|
+
useComputeSession,
|
|
4912
|
+
validateAppID,
|
|
4913
|
+
validateAppName,
|
|
4914
|
+
validateCreateAppParams,
|
|
4915
|
+
validateDescription,
|
|
4916
|
+
validateImageReference,
|
|
4917
|
+
validateInstanceTypeSKU,
|
|
4918
|
+
validateLogVisibility,
|
|
4919
|
+
validateLogsParams,
|
|
4920
|
+
validatePrivateKeyFormat,
|
|
4921
|
+
validateURL,
|
|
4922
|
+
validateXURL
|
|
4923
|
+
};
|
|
4924
|
+
//# sourceMappingURL=browser.js.map
|