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